From b3ffe701a271adf7e9a2185b3d03042e9a2ce72c Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 5 May 2018 14:26:07 +0200 Subject: [PATCH] Yet more work on nonpresentation currency in database --- Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs index c07791fc..86c8eea3 100644 --- a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs +++ b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs @@ -613,6 +613,7 @@ namespace Swarmops.Site.Pages.Ledgers ImportResults result = new ImportResults(); int count = 0; int progressUpdateInterval = import.Records.Length/40; + Int64 importedCentsTotal = 0; if (progressUpdateInterval > 100) { @@ -670,6 +671,7 @@ namespace Swarmops.Site.Pages.Ledgers } Int64 foreignCents = amountCents; + importedCentsTotal += amountCents; if (accountCurrency.Identity != organizationCurrency.Identity) { @@ -787,15 +789,11 @@ namespace Swarmops.Site.Pages.Ledgers if (autosetInitialBalance) { - if (accountCurrency.Identity == organizationCurrency.Identity) // ordinary presentation currency - { - // assetAccount. - } - else - { - // non-presentation currency - - } + Int64 newInitialBalanceCents = result.BalanceMismatchCents - importedCentsTotal; + + assetAccount.InitialBalanceCents = new Money(newInitialBalanceCents, accountCurrency); + result.InitialBalanceCents = (newInitialBalanceCents/100.0).ToString("N2"); + result.InitialBalanceCurrency = accountCurrency.DisplayCode; } }