Nonpresentation currency should now be correctly imported, but needs additional validation

This commit is contained in:
Rick Falkvinge
2018-04-28 20:59:54 +02:00
parent 6784fafd4d
commit 2df4ff115b
2 changed files with 25 additions and 2 deletions
+1 -1
View File
@@ -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
+24 -1
View File
@@ -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)