finance - Should I store refund records in positive or negative amount? -


i asking best practice veteran financial programmers.

eg psudo code:

class transaction(model):     order = foreignkey()     amount = decimalfield()     type = 'refund' or 'purchase' 

if storing refunds in negative amount, can run sum() of transactions balance, math operations become bit native.

if storing refunds in positive amount, it's more human friendly on formula purchase - refund = balance, don't need invert display positive amount of refund in template.

which 1 should pick have benefits , less gotchas?

one approach have amount field holds value positive , field signedamount holds signed version of it. so, when want display or log use amount, when want include in calculation use signedamount.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -