From b8ebf424efa85559dd15741b252b1d575e3a21ee Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 7 Oct 2017 17:39:08 +0200 Subject: [PATCH] Work on VAT reports --- Database/Database-VatReports.cs | 22 ++++++++++++---------- Logic/Financial/VatReport.cs | 10 ++++++++++ Logic/Financial/VatReports.cs | 15 +++++++++++++++ Logic/Logic.csproj | 1 + 4 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 Logic/Financial/VatReports.cs diff --git a/Database/Database-VatReports.cs b/Database/Database-VatReports.cs index 28604bf9..3d68958c 100644 --- a/Database/Database-VatReports.cs +++ b/Database/Database-VatReports.cs @@ -165,22 +165,23 @@ namespace Swarmops.Database #region Creation and manipulation - stored procedures - public int CreateVatReport (int payrollItemId, DateTime payoutDate, Int64 baseSalaryCents, Int64 netSalaryCents, - Int64 subtractiveTaxCents, Int64 additiveTaxCents) + public int CreateVatReport (int organizationId, string guid, int yearMonthStart, int monthCount) { + guid = guid.Replace("-", ""); // remove noise before committing + DateTime nowUtc = DateTime.UtcNow; + using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); - DbCommand command = GetDbCommand ("CreateSalaryPrecise", connection); + DbCommand command = GetDbCommand ("CreateVatReport", connection); command.CommandType = CommandType.StoredProcedure; - AddParameterWithName (command, "payrollItemId", payrollItemId); - AddParameterWithName (command, "payoutDate", payoutDate); - AddParameterWithName (command, "baseSalaryCents", baseSalaryCents); - AddParameterWithName (command, "netSalaryCents", netSalaryCents); - AddParameterWithName (command, "subtractiveTaxCents", subtractiveTaxCents); - AddParameterWithName (command, "additiveTaxCents", additiveTaxCents); + AddParameterWithName (command, "organizationId", organizationId); + AddParameterWithName (command, "guid", guid); + AddParameterWithName (command, "createdDateTime", nowUtc); + AddParameterWithName (command, "yearMonthStart", yearMonthStart); + AddParameterWithName (command, "monthCount", monthCount); return Convert.ToInt32 (command.ExecuteScalar()); } @@ -211,7 +212,7 @@ namespace Swarmops.Database } } - + public void SetVatReportReleased (int vatReportId) { using (DbConnection connection = GetMySqlDbConnection()) @@ -251,4 +252,5 @@ namespace Swarmops.Database #endregion } } + \ No newline at end of file diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs index 39896573..b0e15fc5 100644 --- a/Logic/Financial/VatReport.cs +++ b/Logic/Financial/VatReport.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Swarmops.Basic.Types.Financial; using Swarmops.Common.Interfaces; using Swarmops.Database; +using Swarmops.Logic.Structure; namespace Swarmops.Logic.Financial { @@ -37,6 +38,15 @@ namespace Swarmops.Logic.Financial return FromBasic(SwarmDb.GetDatabaseForWriting().GetVatReport(vatReportId)); } + public static VatReport Create(Organization organization, int year, int startMonth, int monthCount) + { + System.Guid guid = System.Guid.NewGuid(); + + int vatReportId = SwarmDb.GetDatabaseForWriting() + .CreateVatReport(organization.Identity, guid.ToString(), year*100 + startMonth, monthCount); + return FromIdentityAggressive(vatReportId); + } + #endregion public void AddItem(FinancialTransaction transaction, Int64 turnoverCents, diff --git a/Logic/Financial/VatReports.cs b/Logic/Financial/VatReports.cs new file mode 100644 index 00000000..f4f3bd48 --- /dev/null +++ b/Logic/Financial/VatReports.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Basic.Types.Financial; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Financial +{ + public class VatReports: PluralBase + { + + } +} diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 1f2acb4a..49177135 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -129,6 +129,7 @@ + True True