From cf83c241358c3ef53f71a201a81d2e950bf5dad2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 9 Oct 2017 13:43:40 +0200 Subject: [PATCH] Work on VAT reports --- Logic/Financial/InboundInvoice.cs | 4 ++-- Logic/Financial/VatReport.cs | 19 +++++++++++++------ Site/Master-v5.master.cs | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Logic/Financial/InboundInvoice.cs b/Logic/Financial/InboundInvoice.cs index 156f06dc..6002f84f 100644 --- a/Logic/Financial/InboundInvoice.cs +++ b/Logic/Financial/InboundInvoice.cs @@ -206,8 +206,8 @@ namespace Swarmops.Logic.Financial // Create a corresponding financial transaction with rows FinancialTransaction transaction = - FinancialTransaction.Create (organization.Identity, DateTime.Now, - "Invoice #" + newInvoice.Identity + " from " + supplier); + FinancialTransaction.Create (organization.Identity, DateTime.UtcNow, + "Invoice #" + newInvoice.OrganizationSequenceId + " from " + supplier); transaction.AddRow (organization.FinancialAccounts.DebtsInboundInvoices, -amountCents, creatingPerson); if (vatCents > 0) diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs index 4d8b139b..d0be05f0 100644 --- a/Logic/Financial/VatReport.cs +++ b/Logic/Financial/VatReport.cs @@ -91,12 +91,19 @@ namespace Swarmops.Logic.Financial { // if there's anything to report - FinancialTransaction vatReportTransaction = FinancialTransaction.Create(organization, DateTime.UtcNow, + FinancialTransaction vatReportTransaction = FinancialTransaction.Create(organization, endDate.AddDays(4).AddHours(9), transactionComment); - vatReportTransaction.AddRow(organization.FinancialAccounts.AssetsVatInboundUnreported, - -newReport.VatInboundCents, null); - vatReportTransaction.AddRow(organization.FinancialAccounts.DebtsVatOutboundUnreported, - newReport.VatOutboundCents, null); // not negative, because our number is sign-different from the bookkeeping's + if (newReport.VatInboundCents > 0) + { + vatReportTransaction.AddRow(organization.FinancialAccounts.AssetsVatInboundUnreported, + -newReport.VatInboundCents, null); + } + if (newReport.VatOutboundCents > 0) + { + vatReportTransaction.AddRow(organization.FinancialAccounts.DebtsVatOutboundUnreported, + newReport.VatOutboundCents, null); + // not negative, because our number is sign-different from the bookkeeping's + } if (differenceCents < 0) // outbound > inbound { @@ -163,7 +170,7 @@ namespace Swarmops.Logic.Financial } else if (turnoverAccountLookup.ContainsKey(txRow.FinancialAccountId)) { - turnOver += txRow.AmountCents; + turnOver -= txRow.AmountCents; // turnover accounts are sign reversed, so convert to positive } } diff --git a/Site/Master-v5.master.cs b/Site/Master-v5.master.cs index 42001bac..86cf1f8e 100644 --- a/Site/Master-v5.master.cs +++ b/Site/Master-v5.master.cs @@ -39,7 +39,7 @@ namespace Swarmops.Frontend // BEGIN TEST CODE - //VatReports.CreateNewReports(); + // VatReports.CreateNewReports(); // END TEST CODE