Simplified balance sheet with footer

This commit is contained in:
Falkvinge
2017-05-14 14:48:11 +02:00
parent 8dbbe4f019
commit 8a318da04d
5 changed files with 109 additions and 5 deletions
+27
View File
@@ -402,6 +402,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to The Balance Sheet is an overview of assets and debts at a snapshot in time, and is used to see how results affect the overall financial health of the organization. You may also want to look at the &lt;a href=&quot;BalanceSheet&quot;&gt;advanced balance sheet&lt;/a&gt; for more detail, or the &lt;a href=&quot;ProfitLossStatement&quot;&gt;profit-and-loss statement&lt;/a&gt; which is the overview of income and expenditure..
/// </summary>
internal static string BalanceSheet_Info_Simplified {
get {
return ResourceManager.GetString("BalanceSheet_Info_Simplified", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Liabilities XXXX.
/// </summary>
@@ -420,6 +429,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Loss to date ({0}).
/// </summary>
internal static string BalanceSheet_LossToDate {
get {
return ResourceManager.GetString("BalanceSheet_LossToDate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Balance Sheet.
/// </summary>
@@ -429,6 +447,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Profit to date ({0}).
/// </summary>
internal static string BalanceSheet_ProfitToDate {
get {
return ResourceManager.GetString("BalanceSheet_ProfitToDate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change Q1.
/// </summary>
@@ -793,6 +793,9 @@
<value>(change)</value>
<comment>Change from previous year's close, which is same as from start of this year</comment>
</data>
<data name="BalanceSheet_Info_Simplified" xml:space="preserve">
<value>The Balance Sheet is an overview of assets and debts at a snapshot in time, and is used to see how results affect the overall financial health of the organization. You may also want to look at the &lt;a href="BalanceSheet"&gt;advanced balance sheet&lt;/a&gt; for more detail, or the &lt;a href="ProfitLossStatement"&gt;profit-and-loss statement&lt;/a&gt; which is the overview of income and expenditure.</value>
</data>
<data name="BalanceSheet_Liabilities" xml:space="preserve">
<value>Liabilities XXXX</value>
<comment>For the simplified view - XXXX is replaced with year</comment>
@@ -801,4 +804,12 @@
<value>(change)</value>
<comment>Change from previous year's close, which is same as from start of this year</comment>
</data>
<data name="BalanceSheet_LossToDate" xml:space="preserve">
<value>Loss to date ({0})</value>
<comment>The {0} is the year of the report</comment>
</data>
<data name="BalanceSheet_ProfitToDate" xml:space="preserve">
<value>Profit to date ({0})</value>
<comment>The {0} is the year of the report</comment>
</data>
</root>
@@ -62,6 +62,13 @@
$('div.datagrid').css('opacity', 0.4);
});
function formatGray(val, row, index) {
if (val === undefined) {
return undefined;
}
return "<span style='color:#AAA'>" + val + "</span>";
}
var currentYear = <%=DateTime.Today.Year %>;
</script>
@@ -72,6 +79,14 @@
color: #1C397E;
letter-spacing: 1px;
}
.datagrid-row-selected,.datagrid-row-over{
background:transparent;
}
table.datagrid-ftable {
font-weight: 500;
}
</style>
</style>
</asp:Content>
@@ -82,15 +97,15 @@
url="Json-BalanceSheetDataSimplified.aspx"
rownumbers="false"
animate="true"
fitColumns="true"
fitColumns="true" showFooter="true"
idField="id" treeField="name">
<thead>
<tr>
<th field="name" width="178"><asp:Literal ID="LiteralHeaderAccountName" runat="server"/></th>
<th field="assets" width="140" align="right"><span class="commonHeader" id="headerAssetsCardinal" style="display:none"><asp:Literal ID="LiteralAssets" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="assetdelta" width="100" align="right"><span class="commonHeader" id="headerAssetsDelta" style="display:none"><asp:Literal ID="LiteralAssetsDelta" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="assetdelta" width="100" align="right" formatter="formatGray"><span class="commonHeader" id="headerAssetsDelta" style="display:none"><asp:Literal ID="LiteralAssetsDelta" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="liabilities" width="140" align="right"><span class="commonHeader" id="headerLiabilitiesCardinal" style="display:none"><asp:Literal ID="LiteralLiabilities" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="liabilitydelta" width="100" align="right"><span class="commonHeader" id="headerLiabilitiesDelta" style="display:none"><asp:Literal ID="LiteralLiabilitiesDelta" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
<th field="liabilitydelta" width="100" align="right" formatter="formatGray"><span class="commonHeader" id="headerLiabilitiesDelta" style="display:none"><asp:Literal ID="LiteralLiabilitiesDelta" runat="server" /></span><span class="loadingHeader">&mdash;</span></th>
</tr>
</thead>
</table>
@@ -19,7 +19,7 @@ namespace Swarmops.Frontend.Pages.Ledgers
PageIcon = "iconshock-treasure";
PageTitle = Resources.Pages.Ledgers.BalanceSheet_PageTitle;
InfoBoxLiteral = Resources.Pages.Ledgers.BalanceSheet_Info;
InfoBoxLiteral = Resources.Pages.Ledgers.BalanceSheet_Info_Simplified;
// Security: If the org has open ledgers, then anyone may read. Otherwise, Financials.Read.
@@ -35,13 +35,59 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
FinancialAccountType.Balance);
LocalizeRoot (report.ReportLines);
_totals = new BalanceSimplifiedTotals();
Response.ContentType = "application/json";
Response.Output.WriteLine (RecurseReport (report.ReportLines));
Response.Output.WriteLine("{\"rows\": " + RecurseReport(report.ReportLines) + ", \"footer\": [" +
WriteFooter() + "]}");
Response.End();
}
private class BalanceSimplifiedTotals
{
public Int64 AssetsCents { get; set; }
public Int64 LiabilitiesCents { get; set; }
}
private BalanceSimplifiedTotals _totals;
private string WriteFooter()
{
string line1 = string.Format("\"name\":\"{0}\"", Resources.Global.Global_Total);
line1 += string.Format(CultureInfo.CurrentCulture, ",\"assets\":\"{0:N0}\"",
_totals.AssetsCents / 100.0);
line1 += string.Format(CultureInfo.CurrentCulture, ",\"liabilities\":\"{0:N0}\"", _totals.LiabilitiesCents/-100.0);
if (_totals.AssetsCents == _totals.LiabilitiesCents)
{
return "{" + line1 + "}";
}
else if (_totals.AssetsCents > _totals.LiabilitiesCents) // Predicted profit
{
string line2 = string.Format("\"name\":\"{0}\"", string.Format(Resources.Pages.Ledgers.BalanceSheet_ProfitToDate, _year));
line2 += string.Format(CultureInfo.CurrentCulture, ",\"liabilities\":\"{0:N0}\"",
(_totals.AssetsCents-_totals.LiabilitiesCents) / 100.0);
return "[{" + line1 + "},{" + line2 + "}]";
}
else
{
string line2 = string.Format("\"name\":\"{0}\"", string.Format(Resources.Pages.Ledgers.BalanceSheet_LossToDate, _year));
line2 += string.Format(CultureInfo.CurrentCulture, ",\"assets\":\"{0:N0}\"",
(_totals.LiabilitiesCents - _totals.AssetsCents) / 100.0);
return "[{" + line1 + "},{" + line2 + "}]";
}
}
private void LocalizeRoot (List<AnnualReportLine> lines)
{
Dictionary<string, string> localizeMap = new Dictionary<string, string>();
@@ -77,6 +123,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
columnCardinal = "liabilities";
columnDelta = "liabilitydelta";
signReverser = -1;
this._totals.LiabilitiesCents += line.AccountValues.ThisYear;
}
else
{
this._totals.AssetsCents += line.AccountValues.ThisYear;
}
string element = string.Format ("\"id\":\"{0}\",\"name\":\"{1}\"", line.AccountId,