From 1040a488ce361d6cd7c84dc2d6ec643cd28153c7 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 3 Mar 2015 21:18:00 +0100 Subject: [PATCH] More on Open Ledgers --- Site5/App_GlobalResources/Pages.Ledgers.resx | 3 +++ Site5/Pages/v5/Ledgers/InspectLedgers.aspx | 10 ++++++---- Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs | 9 +++++++++ Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs | 9 ++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index 3e545708..46e4a728 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -670,4 +670,7 @@ Annual Profit + + (detailed description withheld) + \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx index 4ee05da5..59e61d6e 100644 --- a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx +++ b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx @@ -147,12 +147,12 @@ var selectedYear = $('#<%=DropYears.ClientID %>').val(); var selectedMonth = $('#<%=DropMonths.ClientID %>').val(); + currentYear = selectedYear; + $('#gridLedgers').datagrid({ url: 'Json-InspectLedgerData.aspx?Year=' + selectedYear + "&Month=" + selectedMonth + "&AccountId=" + accountId}); $('#imageLoadIndicator').show(); $('div.datagrid').css('opacity', 0.4); - - // $('#gridOutstandingAccounts').datagrid('reload'); } function prefillUnbalancedAmount() { @@ -190,7 +190,7 @@ var jsonData = {}; jsonData.txId = transactionId; - if (canWriteRows) { + if (canWriteRows && ledgersClosedUntil < currentYear) { prefillUnbalancedAmount(); } @@ -223,7 +223,7 @@ } else { $('#divTransactionTracking').hide(); - if (canWriteRows) { + if (canWriteRows && currentYear > ledgersClosedUntil) { $('#divEditTransaction').show(); } else { $('#divEditTransaction').hide(); @@ -248,6 +248,8 @@ var canSeeDetail = ; var canWriteRows = ; var canAuditTx = ; + var ledgersClosedUntil = ; + var currentYear = 0; diff --git a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs index cbf36d0d..35820116 100644 --- a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs +++ b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs @@ -10,6 +10,7 @@ using Swarmops.Common.Enums; using Swarmops.Common.Interfaces; using Swarmops.Logic.Financial; using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; using Swarmops.Logic.Support; namespace Swarmops.Frontend.Pages.v5.Ledgers @@ -120,6 +121,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers (CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read))) ? "true" : "false"; + + this.LiteralLedgersClosedUntil.Text = CurrentOrganization.Parameters.FiscalBooksClosedUntilYear.ToString(); } [WebMethod] @@ -135,6 +138,12 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers } FinancialTransaction transaction = FinancialTransaction.FromIdentity(txId); + + if (authData.CurrentOrganization.Parameters.FiscalBooksClosedUntilYear >= transaction.DateTime.Year) + { + return false; // can't edit closed books + } + FinancialAccount account = FinancialAccount.FromIdentity (accountId); Double amountFloat = Double.Parse (amountString); diff --git a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs index 858f1226..f887b8ac 100644 --- a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs @@ -55,6 +55,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers DateTime balanceStart = dawnOfMankind; bool zeroStart = false; bool zeroEnd = false; + bool displayDescription = CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read)); if (month > 0 && month <= 12) { @@ -142,6 +143,12 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { string creditString = string.Empty; string debitString = string.Empty; + string description = row.Description; + + if (!displayDescription) + { + description = Resources.Pages.Ledgers.InspectLedgers_TxDetail_DescriptionWithheld; + } if (row.AmountCents < 0) { @@ -163,7 +170,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers "\"deltaPos\":\"{3}\",\"deltaNeg\":\"{4}\",\"balance\":\"{5:N0}\",\"action\":\"{6}\"", row.FinancialTransactionId, row.TransactionDateTime, - JsonSanitize (row.Description), + JsonSanitize (description), debitString, creditString, runningBalance/100.0,