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

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

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