简体   繁体   中英

database design: accounts with multi currency

In your accounting software how would you design your accounts database for COA

Design 1) 1 account can hold 1 currency only

Design 2) 1 account can hold multi currency, just filter the transaction by CurrencyId (USD, GBP etc..)

Design 1) 1 account can hold 1 currency only

ACCOUNT
Id
AccountNumber
CurrencyCode
...

TRANSACTION
Id
AccountId
Amount
...

Design 2) 1 account can hold multi currency

ACCOUNT
Id
AccountNumber
...

TRANSACTION
Id
AccountId
Amount
CurrencyCode
....

In the first place, I wouldn't design accounting software. I'd buy it. Accounting is one of the fields where you need domain experts (that is, accountants) helping to develop the software.

In the second place, if you're required to accept multiple currencies, then you have to store the type of currency along with the value. In a system like that, a debit of 30 is meaningless. Only debits of 30 USD or 30 EUR are meaningful.

But storage is the simplest part of your problem. How are you going to add up transactions involving multiple currencies? There's more than one way to do that, there's probably more than one "right" answer, and your accountants will probably come to blows over which way is the "right" way.

You could use existing services as a guide - eg, Paypal.

In Paypal, for each account you have to nominate the base currency for that account. Then, any transactions are converted to that currency before being applied to the account. The original amount, its currency, and the conversion rate applied at the time, could also be stored alongside, but for doing calculations you'd use the base currency.

As a general safety rule, always go for the more flexible design. In this interconnected world, it is almost certain that there will be transactions in all kind of currencies (except maybe the local car boot sale, although I am not sure about it). So, store the currency code in the transaction table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM