From 87a4a9c84b647635fd805871ef6fb50e69dbd7a8 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Sat, 28 Oct 2017 11:27:05 +0200 Subject: [PATCH] First test on VAT report data --- Logic/Financial/VatReportItem.cs | 5 ++ Site/Pages/v5/Ledgers/Json-VatReportData.aspx | 1 + .../v5/Ledgers/Json-VatReportData.aspx.cs | 74 +++++++++++++++++++ .../Json-VatReportData.aspx.designer.cs | 15 ++++ Site/Pages/v5/Ledgers/ViewVatReports.aspx | 2 +- Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs | 4 + Site/Site.csproj | 8 ++ 7 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 Site/Pages/v5/Ledgers/Json-VatReportData.aspx create mode 100644 Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs create mode 100644 Site/Pages/v5/Ledgers/Json-VatReportData.aspx.designer.cs diff --git a/Logic/Financial/VatReportItem.cs b/Logic/Financial/VatReportItem.cs index 3e9cfd09..26375eff 100644 --- a/Logic/Financial/VatReportItem.cs +++ b/Logic/Financial/VatReportItem.cs @@ -61,5 +61,10 @@ namespace Swarmops.Logic.Financial } #endregion + + public FinancialTransaction Transaction + { + get { return FinancialTransaction.FromIdentity(this.FinancialTransactionId); } + } } } diff --git a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx new file mode 100644 index 00000000..daad028f --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.Json_VatReportData" Codebehind="Json-VatReportData.aspx.cs" %> diff --git a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs new file mode 100644 index 00000000..61538f80 --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using Swarmops.Common.Enums; +using Swarmops.Database; +using Swarmops.Logic.Financial; + +namespace Swarmops.Frontend.Pages.v5.Ledgers +{ + public partial class Json_VatReportData : DataV5Base + { + private AuthenticationData _authenticationData; + + private int _reportId = 0; + + protected void Page_Load (object sender, EventArgs e) + { + // Get auth data + + this._authenticationData = GetAuthenticationDataAndCulture(); + + string reportIdParameter = Request.QueryString["ReportId"]; + string reportKeyParameter = Request.QueryString["ReportKey"]; + + if (!string.IsNullOrEmpty (reportIdParameter)) + { + this._reportId = Int32.Parse (reportIdParameter); // will throw if non-numeric - don't matter for app + } + else if (!string.IsNullOrEmpty(reportKeyParameter)) + { + this._reportId = + SwarmDb.GetDatabaseForReading().GetVatReportIdFromGuid(reportKeyParameter.ToLowerInvariant().Trim()); + } + else + { + throw new ArgumentException("No Report Requested"); + } + + VatReport report = VatReport.FromIdentity(_reportId); + + Response.ContentType = "application/json"; + + Int64 turnoverTotal; + Int64 inboundTotal; + Int64 outboundTotal; + + StringBuilder response = new StringBuilder(16384); + + VatReportItems items = report.Items; + List lines = new List(); + + foreach (VatReportItem item in items) + { + FinancialTransaction transaction = item.Transaction; + + string element = string.Format("\"id\":\"{0}\",\"txid\":\"{1}\",\"datetime\":\"{2}\",\"description\":\"{3}\"", + transaction.Identity, + transaction.OrganizationSequenceId, + "date time", + JsonSanitize(transaction.Description)); + + + lines.Add("{" + element + "}"); + } + + Response.Write("[" + String.Join(",", lines.ToArray()) + "]"); + + Response.End(); + } + + + } +} \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.designer.cs b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.designer.cs new file mode 100644 index 00000000..e34bef4a --- /dev/null +++ b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Pages.v5.Ledgers { + + + public partial class Json_VatReportData { + } +} diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx b/Site/Pages/v5/Ledgers/ViewVatReports.aspx index ed82060e..27733a9d 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx @@ -61,7 +61,7 @@

<%= CurrentOrganization.Currency.DisplayCode %>
  Loading

Json-AccountPlanData.aspx + + Json-VatReportData.aspx + ASPXCodeBehind + + + Json-VatReportData.aspx + Json-BalanceSheetDataSimplified.aspx ASPXCodeBehind @@ -1100,6 +1107,7 @@ +