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;