Accounting and Database design, storing debit and credit amount

后端 未结 7 1857
你的背包
你的背包 2021-02-06 00:47

QUESTION: In the case below should I have stored all my amount as positives decimal amounts then flag the amount as either being a \"Debit\" or \"Credit\" rather than storing d

7条回答
  •  粉色の甜心
    2021-02-06 01:15

    As accounting is all based on journal entries, it might be best for your data model to follow from that. This would mean having two columns in your table, one for debit and one for credit. You then leave it up to the application to determine what should be considered a "positive" value and what should be considered "negative". (The question always arises - positive from whose point of view? When you transfer money between bank accounts, it a "negative" for one account but a "positive" for the other.)

    It's a while since I worked on this kind of thing, but I seem to remember that it is possible for the debit AND credit columns to contain both positive AND negative values. Accountants have a different way of thinking about numbers than us programmers, so when writing software for them, it can simplify things if you try to work with their conventions.

提交回复
热议问题