From 4e5ab9dfd9cc820a7cdf75f6b10fa81365c1c1a1 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 15 Apr 2018 16:21:06 +0200 Subject: [PATCH] Added sales tree to VAT reports --- Logic/Financial/VatReport.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs index 72c5b9a3..42a067c8 100644 --- a/Logic/Financial/VatReport.cs +++ b/Logic/Financial/VatReport.cs @@ -69,10 +69,11 @@ namespace Swarmops.Logic.Financial FinancialAccount vatInbound = organization.FinancialAccounts.AssetsVatInboundUnreported; FinancialAccount vatOutbound = organization.FinancialAccounts.DebtsVatOutboundUnreported; FinancialAccount sales = organization.FinancialAccounts.IncomeSales; + FinancialAccounts salesTree = sales.ThisAndBelow(); FinancialAccountRows inboundRows = RowsNotInVatReport(vatInbound, endDate); FinancialAccountRows outboundRows = RowsNotInVatReport(vatOutbound, endDate); - FinancialAccountRows turnoverRows = RowsNotInVatReport(sales, endDate); + FinancialAccountRows turnoverRows = RowsNotInVatReport(salesTree, endDate); Dictionary transactionsIncludedLookup = new Dictionary(); @@ -228,6 +229,17 @@ namespace Swarmops.Logic.Financial get { return VatReportItems.ForReport(this); } } + + private static FinancialAccountRows RowsNotInVatReport(FinancialAccounts accounts, DateTime endTime) + { + FinancialAccountRows result = new FinancialAccountRows(); + + result.AddRange(accounts.SelectMany(account => RowsNotInVatReport(account, endTime))); + + return result; + } + + private static FinancialAccountRows RowsNotInVatReport(FinancialAccount account, DateTime endDateTime) { Organization organization = account.Organization;