diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx
index 81fb3036..519677eb 100644
--- a/Site5/App_GlobalResources/Global.resx
+++ b/Site5/App_GlobalResources/Global.resx
@@ -748,4 +748,40 @@
Personhood
+
+ All
+
+
+ Description
+ As a general header of any description field
+
+
+ Q1
+ First quarter of the year
+
+
+ Q2
+ Second quarter of the year
+
+
+ Q3
+ Third quarter of the year
+
+
+ Q4
+ Fourth quarter of the year
+
+
+ Timestamp
+
+
+ Balance
+ As in 'account balance', not as in staying upright
+
+
+ Credit
+
+
+ Debit
+
\ No newline at end of file
diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx
index 7a9b1d12..a1ea7818 100644
--- a/Site5/App_GlobalResources/Pages.Ledgers.resx
+++ b/Site5/App_GlobalResources/Pages.Ledgers.resx
@@ -506,4 +506,37 @@
Inspect Ledgers
+
+ Flagging a transaction for closer inspection is not yet implemented. It is scheduled for one of the early Swarmops Red sprints, some time late 2005Q1.
+
+
+ Inbound Balance
+
+
+ No Previous Balance
+
+
+ This is the raw underlying Venetian bookkeeping ledgers for the organization's finances. You can study them here in detail for auditing purposes. <span id="SpanInfoProfitLossAccount" style="display:none"><strong>You're currently watching a P&L account, so signs are reversed - income is negative and expenses positive</strong> due to how Venetian double bookkeeping works.</span>
+
+
+ Inspecting a single transaction is not yet implemented. It is scheduled for one of the early Swarmops Red sprints, late 2005Q1.
+
+
+ Outbound Balance
+
+
+ Ending Balance
+
+
+ Ending Balance (to date)
+ Displayed if the end-balance date isn't reached yet
+
+
+ (Please select an account.)
+ Displayed initially and when no valid account selected
+
+
+ Tx#
+ Keep VERY short.
+
\ No newline at end of file
diff --git a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx
index 89cc0821..b0c2710c 100644
--- a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx
+++ b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx
@@ -6,13 +6,104 @@
+
+
+
+
+
+
-
Inspect for
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
index 1f9d61bd..b6a6df7e 100644
--- a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
@@ -21,7 +21,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read);
this.DbVersionRequired = 0; // base schema is fine
- this.PageTitle = "Inspect Ledgers"; // TODO localize
+ this.PageTitle = Resources.Pages.Ledgers.InspectLedgers_PageTitle;
+ this.InfoBoxLiteral = Resources.Pages.Ledgers.InspectLedgers_Info;
this.PageIcon = "iconshock-ledger-inspect";
if (!Page.IsPostBack)
@@ -41,6 +42,12 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.DropMonths.Items.Add(new ListItem(new DateTime(2014, monthNumber, 1).ToString("MMM"), monthNumber.ToString(CultureInfo.InvariantCulture))); // will autolocalize
}
+ this.DropMonths.Items.Add(new ListItem(Resources.Global.Global_Q1, "21")); // quarters and all-year are coded as fake month numbers
+ this.DropMonths.Items.Add(new ListItem(Resources.Global.Global_Q2, "22"));
+ this.DropMonths.Items.Add(new ListItem(Resources.Global.Global_Q3, "23"));
+ this.DropMonths.Items.Add(new ListItem(Resources.Global.Global_Q4, "24"));
+ this.DropMonths.Items.Add(new ListItem(Resources.Global.Global_AllYear, "31"));
+
this.DropYears.SelectedIndex = 0;
this.DropMonths.SelectedValue = today.Month.ToString(CultureInfo.InvariantCulture);
}
@@ -50,7 +57,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
private void Localize()
{
-
+ this.LabelHeaderInspect.Text = Resources.Pages.Ledgers.InspectLedgers_Header_Inspect;
+ this.LabelHeaderInspectFor.Text = Resources.Pages.Ledgers.InspectLedgers_Header_For;
+ this.LabelGridHeaderAction.Text = Resources.Global.Global_Action;
+ this.LabelGridHeaderBalance.Text = Resources.Global.Ledgers_Balance;
+ this.LabelGridHeaderDateTime.Text = Resources.Global.Global_Timestamp;
+ this.LabelGridHeaderDeltaNegative.Text = Resources.Global.Ledgers_Credit;
+ this.LabelGridHeaderDeltaPositive.Text = Resources.Global.Ledgers_Debit;
+ this.LabelGridHeaderDescription.Text = Resources.Global.Global_Description;
+ this.LabelGridHeaderId.Text = Resources.Pages.Ledgers.InspectLedgers_TransactionId;
}
}
}
\ No newline at end of file
diff --git a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx
new file mode 100644
index 00000000..2c86bf3d
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx
@@ -0,0 +1 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-InspectLedgerData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.Json_InspectLedgerData" %>
\ No newline at end of file
diff --git a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs
new file mode 100644
index 00000000..98b84a7c
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Swarmops.Basic.Enums;
+using Swarmops.Logic.Financial;
+using Swarmops.Logic.Security;
+
+namespace Swarmops.Frontend.Pages.v5.Ledgers
+{
+ public partial class Json_InspectLedgerData : DataV5Base
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ Response.ContentType = "application/json";
+
+ string accountIdString = Request.QueryString["AccountId"];
+ string yearString = Request.QueryString["Year"];
+ string monthString = Request.QueryString["Month"];
+
+ string emptyResponse = "[{\"id\":\"-\",\"description\":\"" + JsonSanitize(Resources.Pages.Ledgers.InspectLedgers_PleaseSelectAccount) + "\"}]";
+
+ if (string.IsNullOrEmpty(accountIdString) || string.IsNullOrEmpty(yearString) ||
+ string.IsNullOrEmpty(monthString) || accountIdString == "undefined")
+ {
+ Response.Output.WriteLine(emptyResponse);
+ Response.End();
+ }
+
+ int accountId = Int32.Parse(accountIdString);
+ int year = Int32.Parse(yearString);
+ int month = Int32.Parse(monthString);
+
+ DateTime dawnOfMankind = new DateTime(1901,1,1); // no org will ever import bookkeeping from before this date
+
+ if (accountId <= 0)
+ {
+ Response.Output.WriteLine(emptyResponse);
+ Response.End();
+ }
+
+ FinancialAccount account = FinancialAccount.FromIdentity(accountId);
+ if (account.OrganizationId != CurrentOrganization.Identity)
+ {
+ throw new UnauthorizedAccessException("All the nopes in the world");
+ }
+
+ if (!CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
+ {
+ throw new UnauthorizedAccessException("Access denied because security tokens say so");
+ }
+
+ DateTime periodStart, periodEnd;
+ DateTime balanceStart = dawnOfMankind;
+ bool zeroStart = false;
+ bool zeroEnd = false;
+
+ if (month > 0 && month <= 12)
+ {
+ periodStart = new DateTime(year, month, 1);
+ periodEnd = periodStart.AddMonths(1);
+ if (account.AccountType == FinancialAccountType.Income ||
+ account.AccountType == FinancialAccountType.Cost)
+ {
+ balanceStart = new DateTime(year, 1, 1);
+
+ if (month == 1)
+ {
+ zeroStart = true;
+ }
+ if (month == 12)
+ {
+ zeroEnd = true;
+ }
+ }
+ }
+ else if (month > 20 && month < 25) // quarters 1..4 are coded as months 21..24
+ {
+ periodStart = new DateTime(year, (month - 21) * 3 + 1, 1);
+ periodEnd = periodStart.AddMonths(3);
+ if (account.AccountType == FinancialAccountType.Income ||
+ account.AccountType == FinancialAccountType.Cost)
+ {
+ balanceStart = new DateTime(year, 1, 1);
+
+ if (month == 21)
+ {
+ zeroStart = true;
+ }
+ if (month == 24)
+ {
+ zeroEnd = true;
+ }
+ }
+ }
+ else if (month == 31) // "whole year" is coded as month 31
+ {
+ periodStart = new DateTime(year, 1, 1);
+ periodEnd = new DateTime(year + 1, 1, 1);
+ if (account.AccountType == FinancialAccountType.Income ||
+ account.AccountType == FinancialAccountType.Cost)
+ {
+ zeroStart = true;
+ zeroEnd = true;
+ }
+ }
+ else
+ {
+ throw new ArgumentException("Invalid month supplied: " + month.ToString(CultureInfo.InvariantCulture));
+ }
+
+
+ FinancialAccountRows rows = account.GetRows(periodStart, periodEnd);
+
+ StringBuilder result = new StringBuilder(16384);
+
+ Int64 runningBalance = 0L;
+ string startString = Resources.Pages.Ledgers.InspectLedgers_InboundBalanceZero;
+ string endString = Resources.Pages.Ledgers.InspectLedgers_OutboundBalanceZero;
+
+ if (!zeroStart)
+ {
+ runningBalance = account.GetDeltaCents(dawnOfMankind, periodStart);
+ startString = Resources.Pages.Ledgers.InspectLedgers_InboundBalance;
+ }
+ if (!zeroEnd)
+ {
+ endString = Resources.Pages.Ledgers.InspectLedgers_OutboundBalance;
+ }
+ else if (periodEnd > DateTime.Now)
+ {
+ // account is zeroed at end of this period, but we're not yet at end of period, so add a "to date" disclaimer
+ endString = Resources.Pages.Ledgers.InspectLedgers_OutboundBalanceZeroToDate;
+ }
+
+ result.Append("{" +
+ String.Format("\"description\":\"{0}\",\"balance\":\"{1:N0}\"", JsonSanitize(startString), runningBalance / 100.0) + "},");
+
+ foreach (FinancialAccountRow row in rows)
+ {
+ string creditString = string.Empty;
+ string debitString = string.Empty;
+
+ if (row.AmountCents < 0)
+ {
+ creditString = String.Format("{0:N0}", row.AmountCents/100.0);
+ }
+ else if (row.AmountCents > 0)
+ {
+ debitString = String.Format("{0:N0}", row.AmountCents/100.0);
+ }
+
+ runningBalance += row.AmountCents;
+
+ result.Append("{" + String.Format(
+ "\"id\":\"{0}\",\"datetime\":\"{1:MMM-dd HH:mm}\",\"description\":\"{2}\"," +
+ "\"deltaPos\":\"{3}\",\"deltaNeg\":\"{4}\",\"balance\":\"{5:N0}\"",
+ row.FinancialTransactionId,
+ row.TransactionDateTime,
+ JsonSanitize(row.Description),
+ debitString,
+ creditString,
+ runningBalance / 100.0) + "},");
+ }
+
+ result.Append("{" +
+ String.Format("\"description\":\"{0}\",\"balance\":\"{1:N0}\"", JsonSanitize(endString), runningBalance / 100.0) + "},");
+
+ Response.Output.WriteLine("[" + result.ToString().TrimEnd(',') + "]");
+ Response.End();
+ }
+ }
+}
\ No newline at end of file