From f5896a46aa9ab498cfc461c88f73c6d0c529b082 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 4 Mar 2019 21:02:05 +0100 Subject: [PATCH] Disabled a false double check of forex P&L --- Backend/BackendLoop.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index bd477819..3dd7c005 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Net; @@ -827,21 +828,9 @@ namespace Swarmops.Backend { try { - // Detect and log any forex difference exceeding 100 cents. + Dictionary accountTested = new Dictionary(); - FinancialAccounts allAccounts = FinancialAccounts.GetAll(); // across ALL ORGS! - - foreach (FinancialAccount account in allAccounts) - { - // For every account, if it's based on foreign currency, check for forex gains/losses - - if (account.ForeignCurrency != null) - { - account.CheckForexProfitLoss(); - } - } - - // Also check the bitcoin hotwallets for forex profit/loss as a special case of the above. + // Check the bitcoin hotwallets for forex profit/loss as a special case of the above. Organizations allOrganizations = Organizations.GetAll(); @@ -852,8 +841,24 @@ namespace Swarmops.Backend if (hotWalletAccount != null) { BitcoinUtility.CheckHotwalletForexProfitLoss(hotWalletAccount); + accountTested[hotWalletAccount.Identity] = true; } } + + // Detect and log any forex difference exceeding 100 cents. + + FinancialAccounts allAccounts = FinancialAccounts.GetAll(); // across ALL ORGS! + + foreach (FinancialAccount account in allAccounts) + { + // For every account, if it's based on foreign currency, check for forex gains/losses + + if (account.ForeignCurrency != null && !accountTested.ContainsKey(account.Identity)) + { + account.CheckForexProfitLoss(); + } + } + } catch (Exception e) {