diff --git a/README.md b/README.md index d5a92e21..45858dfb 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Beta-6 features progress Beta-6 will be released on June 5 with string freeze on June 2. Its focus is to increase multicurrency functionality for payouts and bank imports. - [x] Parameterize the bank file import procedure (big feature!) -- [ ] Make it possible to import bank files in non-presentation currency +- [x] Make it possible to import bank files in non-presentation currency - [ ] Rewrite payment addresses (a new name for this? Account vs. designator?) - [ ] Enable payment destinations, with currency diff --git a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs index 5a567442..745f6641 100644 --- a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs +++ b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs @@ -615,6 +615,14 @@ namespace Swarmops.Site.Pages.Ledgers progressUpdateInterval = 100; } + Currency organizationCurrency = assetAccount.Organization.Currency; + Currency accountCurrency = assetAccount.ForeignCurrency; + + if (accountCurrency == null) + { + accountCurrency = organizationCurrency; + } + foreach (ExternalBankDataRecord row in import.Records) { // Update progress. @@ -650,6 +658,14 @@ namespace Swarmops.Site.Pages.Ledgers amountCents = row.TransactionGrossCents; } + Int64 foreignCents = amountCents; + + if (accountCurrency.Identity != organizationCurrency.Identity) + { + amountCents = + new Money(amountCents, accountCurrency, row.DateTime).ToCurrency(organizationCurrency).Cents; + } + FinancialTransaction transaction = FinancialTransaction.ImportWithStub (args.Organization.Identity, row.DateTime, assetAccount.Identity, amountCents, @@ -658,10 +674,17 @@ namespace Swarmops.Site.Pages.Ledgers if (transaction != null) { - // The transaction was created. Examine if the autobook criteria are true. + // The transaction was created. result.TransactionsImported++; + // If non-presentation currency, log the account currency amount as well. + + if (accountCurrency.Identity != organizationCurrency.Identity) + { + transaction.Rows[0].AmountForeignCents = new Money(foreignCents, accountCurrency); + } + FinancialAccounts accounts = FinancialAccounts.FromBankTransactionTag (row.Description); if (accounts.Count == 1)