From 8a8b3e8a7be8a80d3b6d7b058967b0d3ea0a8276 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 24 Mar 2015 00:10:00 +0100 Subject: [PATCH] Last code for sprint Red-5 --- Backend/Program.cs | 17 ++- Logic/Financial/FinancialTransaction.cs | 5 + Site5/App_GlobalResources/Global.resx | 12 ++ Site5/App_GlobalResources/Pages.Ledgers.resx | 30 +---- .../sv-SE/Pages.Ledgers.sv-SE.resx | 43 +++---- Site5/Controls/v5/Base/DropDown.ascx | 63 ++++++++-- Site5/Controls/v5/Base/DropDown.ascx.cs | 12 +- Site5/Controls/v5/Financial/ComboBudgets.ascx | 12 ++ .../Pages/v5/Ledgers/BalanceTransactions.aspx | 54 ++++++++- .../v5/Ledgers/BalanceTransactions.aspx.cs | 110 +++++++++++++++++- .../v5/Ledgers/Json-BalanceSheetData.aspx.cs | 8 +- .../v5/Ledgers/Json-ProfitLossData.aspx.cs | 8 +- Site5/Style/v5-easyui-overrides.css | 10 ++ 13 files changed, 298 insertions(+), 86 deletions(-) diff --git a/Backend/Program.cs b/Backend/Program.cs index 6d02e802..2bc9433b 100644 --- a/Backend/Program.cs +++ b/Backend/Program.cs @@ -8,6 +8,7 @@ using Swarmops.Database; using Swarmops.Logic.Communications; using Swarmops.Logic.Communications.Transmission; using Swarmops.Logic.Financial; +using Swarmops.Logic.Structure; using Swarmops.Logic.Support; using Swarmops.Utility; using Swarmops.Utility.BotCode; @@ -470,9 +471,9 @@ namespace Swarmops.Backend if (SwarmDb.DbVersion < SwarmDb.DbVersionExpected) { - BotLog.Write (1, "MainCycle", "Entering DbUpgrade"); + BotLog.Write (1, "OneHour", "Entering DbUpgrade"); DatabaseMaintenance.UpgradeSchemata(); - BotLog.Write (1, "MainCycle", "Exited DbUpgrade"); + BotLog.Write (1, "OneHour", "Exited DbUpgrade"); } } catch (Exception e) @@ -483,6 +484,18 @@ namespace Swarmops.Backend try { + BotLog.Write(1, "OneHour", "Entering Automatch"); + Organizations organizations = Organizations.GetAll(); + foreach (Organization organization in organizations) + { + if (organization.IsEconomyEnabled) + { + BotLog.Write(1, "OneHour", "Automatching org #" + organization.Identity.ToString(CultureInfo.InvariantCulture)); + Payouts.AutomatchAgainstUnbalancedTransactions(organization); + } + } + BotLog.Write(1, "OneHour", "Exited Automatch"); + /*TestTrace("Running PaymentGroupMapper.Run()..."); PaymentGroupMapper.Run(); TestTrace(" done.\r\n");*/ diff --git a/Logic/Financial/FinancialTransaction.cs b/Logic/Financial/FinancialTransaction.cs index 2bf692e6..501eafcb 100644 --- a/Logic/Financial/FinancialTransaction.cs +++ b/Logic/Financial/FinancialTransaction.cs @@ -85,6 +85,11 @@ namespace Swarmops.Logic.Financial } } + public Organization Organization + { + get { return Organization.FromIdentity (base.OrganizationId); } + } + public Documents Documents { get { return Documents.ForObject (this); } diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index 0ab752b3..5ba2b49d 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -648,4 +648,16 @@ Options For various page-specific checkboxes etc + + [...loading...] + + + [...] + + + (no match) + + + Working... + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index fa2b8b1f..c923f8ba 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -129,9 +129,6 @@ Account - - Assets - Balance Sheet for {0}, {0} is the organization name. The year follows immediately, so keep ending comma. @@ -139,9 +136,6 @@ Current - - Liabilities - BalanceSheet Must ONLY contain A-Z, a-z characters - nothing accented! @@ -179,16 +173,10 @@ P&L for {0} for The {0} is the organization name. The year number follows this string. - - Expenses - ProfitLoss Must ONLY contain A-Z, a-z characters - nothing accented! - - Revenue - The P&L is an overview of income and expenditures, which are grouped by budgets or cost/income type. The sum of all income and expenditure is the yearly result. You may also want to look at the <a href="BalanceSheet.aspx">balance sheet</a> which is the overview of assets and debts. @@ -198,18 +186,6 @@ Profit & Loss Statement - - Q1 - - - Q2 - - - Q3 - - - Q4 - Results Footer on P&L statement @@ -694,7 +670,7 @@ Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced"). - Balancing/Matching Transaction #<span id="spanModalTransactionId">67890</span> + Balancing/Matching Transaction #<span id="spanModalTransactionId">67890</span> From <span id="spanModalTransactionDate">yyyy-mmm-dd</span> The span text is replaced runtime. @@ -752,4 +728,8 @@ Amount Within 10% Tolerance Header in selection list. Capitalize as customary for culture. + + Payout #{0:N0}, expected {1:yyyy-MMM-dd}, for {2}: {3} {4:N2} + 0 is the payout Id, 1 is the date (do culturally edit format if called for), 2 is the recipient name, and 3 4 is the currency and amount + \ No newline at end of file diff --git a/Site5/App_GlobalResources/sv-SE/Pages.Ledgers.sv-SE.resx b/Site5/App_GlobalResources/sv-SE/Pages.Ledgers.sv-SE.resx index 4cc87277..919cafe7 100644 --- a/Site5/App_GlobalResources/sv-SE/Pages.Ledgers.sv-SE.resx +++ b/Site5/App_GlobalResources/sv-SE/Pages.Ledgers.sv-SE.resx @@ -59,46 +59,46 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - - + + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -268,9 +268,6 @@ Olika banker har olika sätt att få BGMAX-filen. På SEB går du till <strong>betalningar</strong> och <strong>filkommunikation</strong> för att se en lista över filer att hämta. Andra banker har andra metoder. I vilket fall, så ladda upp dem här. - - - <p>Filen innehöll {0:N0} transaktioner. <strong>{1:N0} transaktioner</strong> har importerats till kontot <em>{2}</em>. ({3:N0} transaktioner var dubbletter.)</p><p><strong>Men bankens saldo stämmer inte med bokföringen i Swarmops.</strong> Detta beror oftast på saknade transaktioner. Ladda upp ett kontoutdrag över med ett större tidsintervall så att Swarmops får alla transaktioner.</p><p>Swarmops bokföring konto är för närvarande <strong>inte i synk</strong> med bankens.</p> Displayed when import successful, but end balance out of sync. Assumes plural along all pasted numbers. @@ -495,7 +492,6 @@ Granska bokföring - Ingående balans @@ -505,7 +501,6 @@ Detta är den underliggande bokföringens huvudbok för organisationens finanser. Du kan studera bokföringen i detalj, t.ex. för revision. <span id="SpanInfoProfitLossAccount" style="display:none"> <strong>Du tittar just nu på ett resultat konto, så tecknen är omvända - inkomst är negativ och kostnad positivt</strong> på grund av hur venetiansk dubbel bokföring fungerar.</span> - Det finns inga transaktioner i det här kontot för den valda tidsperioden. @@ -682,7 +677,7 @@ Några automatimporterade finansiella transaktioner kunde inte matchas automatiskt mot den löpande redovisningen. Det är här som du manuellt matchar transaktionerna att "balansera" (om en transaktion bara har ena sidan redovisad, till exempel utbetalda pengar från organisationen utan motsvarande post vad pengarna gick till, så sägs transaktionen vara "obalanserad"). - Balanserar/matchar transaktionen #<span id="spanModalTransactionId">67890</span> + Balanserar/matchar transaktionen #<span id="spanModalTransactionId">67890</span> från <span id="spanModalTransactionDate">67890</span> The span text is replaced runtime. @@ -740,4 +735,4 @@ Belopp inom 10% tolerans Header in selection list. Capitalize as customary for culture. - + \ No newline at end of file diff --git a/Site5/Controls/v5/Base/DropDown.ascx b/Site5/Controls/v5/Base/DropDown.ascx index 1edce31a..5b24adaa 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx +++ b/Site5/Controls/v5/Base/DropDown.ascx @@ -1,14 +1,13 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DropDown.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.Base.DropDown" %> <%@ Import Namespace="System.Threading" %> - - + diff --git a/Site5/Controls/v5/Base/DropDown.ascx.cs b/Site5/Controls/v5/Base/DropDown.ascx.cs index ab802f04..58df8b5b 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx.cs +++ b/Site5/Controls/v5/Base/DropDown.ascx.cs @@ -5,22 +5,14 @@ namespace Swarmops.Frontend.Controls.v5.Base { public partial class DropDown : ControlV5Base { - public ListItemCollection Items - { - get { return this.DropControl.Items; } - } - public string SelectedValue - { - get { return this.DropControl.SelectedValue; } - set { this.DropControl.SelectedValue = value; } - } public string OnClientChange { get; set; } + public string DataUrl { get; set; } public string ClientControlID { - get { return this.DropControl.ClientID; } + get { return this.ClientID + "_DropDown"; } } protected void Page_Load (object sender, EventArgs e) diff --git a/Site5/Controls/v5/Financial/ComboBudgets.ascx b/Site5/Controls/v5/Financial/ComboBudgets.ascx index 44f20b76..05612d61 100644 --- a/Site5/Controls/v5/Financial/ComboBudgets.ascx +++ b/Site5/Controls/v5/Financial/ComboBudgets.ascx @@ -51,6 +51,18 @@ }); }); + function <%=this.ClientID %>_val(newValue) { + if (newValue === undefined) { + // getter + return $('#<%=this.ClientID %>_DropBudgets').combotree('getValue'); + } else { + // setter + $('#<%=this.ClientID %>_DropBudgets').combotree('setValue', newValue); + } + } + + + \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx index 59b20eab..d28378b8 100644 --- a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx +++ b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx @@ -31,23 +31,67 @@ function onFixTransaction(newTransactionId) { transactionId = newTransactionId; - SwarmopsJS.formatInteger(transactionId, function(result) { $('span#spanModalTransactionId').text(result); }); + $('span#spanModalTransactionId').text("<%=Resources.Global.Global_LoadingPlaceholder%>"); + SwarmopsJS.formatInteger(transactionId, function (result) { $('span#spanModalTransactionId').text(result); }); $('input:radio[name="TxOptions"]').prop('checked', false); $('div.radioOption').hide(); <%= this.DialogTx.ClientID %>_open(); $('#spanTransactionUnbalancedBy').text('[...]'); - $('#<%=this.DropOpenPayouts.ClientID%>') + $('span#spanModalTransactionDate').text('[...]'); + <%=this.DropOpenPayouts.ClientControlID%>_loadData([{ id: 0, text: "<%=Resources.Global.Global_LoadingPlaceholder%>" }]); + <%=this.DropOpenPayouts.ClientControlID%>_val('0'); SwarmopsJS.ajaxCall( "/Pages/v5/Ledgers/BalanceTransactions.aspx/GetTransactionMatchability", { transactionId: transactionId }, function(data) { - console.log(data); $('#spanTransactionUnbalancedBy').text(data.DifferingAmount); + $('span#spanModalTransactionDate').text(data.TransactionDate); + + if (data.OpenPayoutData.length > 0) { + <%=this.DropOpenPayouts.ClientControlID%>_loadData(data.OpenPayoutData); + <%=this.DropOpenPayouts.ClientControlID%>_text("<%=Resources.Global.Global_SelectOne%>"); + } else { + <%=this.DropOpenPayouts.ClientControlID%>_loadData({}); + <%=this.DropOpenPayouts.ClientControlID%>_text("<%=Resources.Global.Global_NoMatch%>"); + } + }); } + + function onBalanceTransaction() { + var accountId = <%=this.DropBudgetBalance.ClientID%>_val(); + + if (accountId > 0) { + <%= this.DialogTx.ClientID %>_close(); + + SwarmopsJS.ajaxCall( + "/Pages/v5/Ledgers/BalanceTransactions.aspx/BalanceTransactionManually", + { transactionId: transactionId, accountId: accountId }, + function () { + $('#gridTransactions').datagrid('reload'); + }); + + } + } + + function onMatchOpenPayout() { + var payoutId = <%=this.DropOpenPayouts.ClientControlID%>_val(); + + if (payoutId > 0) { + <%= this.DialogTx.ClientID %>_close(); + SwarmopsJS.ajaxCall( + "/Pages/v5/Ledgers/BalanceTransactions.aspx/MatchTransactionOpenPayout", + { transactionId: transactionId, payoutId: payoutId }, + function () { + $('#gridTransactions').datagrid('reload'); + }); + + } + } +