From fa5f7a2ab7094c8500344f4d613359d8c64209ad Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 17 Jan 2016 13:35:16 +0100 Subject: [PATCH] REFACTOR: YearlyReport => AnnualReport --- .../{YearlyReport.cs => AnnualReport.cs} | 736 +++++++++--------- Logic/Logic.csproj | 2 +- .../Pages/v5/Ledgers/Csv-BalanceData.aspx.cs | 10 +- .../v5/Ledgers/Csv-ProfitLossData.aspx.cs | 10 +- .../v5/Ledgers/Json-BalanceSheetData.aspx.cs | 10 +- .../v5/Ledgers/Json-ProfitLossData.aspx.cs | 12 +- .../TaxForms/Json-Payroll-TaxFormData.aspx.cs | 8 +- 7 files changed, 394 insertions(+), 394 deletions(-) rename Logic/Financial/{YearlyReport.cs => AnnualReport.cs} (85%) diff --git a/Logic/Financial/YearlyReport.cs b/Logic/Financial/AnnualReport.cs similarity index 85% rename from Logic/Financial/YearlyReport.cs rename to Logic/Financial/AnnualReport.cs index 6dadf237..0a50f121 100644 --- a/Logic/Financial/YearlyReport.cs +++ b/Logic/Financial/AnnualReport.cs @@ -1,369 +1,369 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Swarmops.Common.Enums; -using Swarmops.Logic.Structure; - -namespace Swarmops.Logic.Financial -{ - [Serializable] - public class YearlyReport - { - public Organization Organization; - public List ReportLines; - public YearlyReportNode Totals; - public int Year; - private FinancialAccountType _accountType; - private Dictionary[] _singleLookups; - private Dictionary[] _treeLookups; - private Dictionary> _treeMap; - - public static YearlyReport Create (Organization organization, int year, FinancialAccountType accountType) - { - YearlyReport report = new YearlyReport(); - report.Organization = organization; - report.Year = year; - report._accountType = accountType; - - // Get accounts - - FinancialAccounts accounts = FinancialAccounts.ForOrganization (organization, accountType); - - // Remove unwanted accounts - - FinancialAccount resultsAccount = organization.FinancialAccounts.CostsYearlyResult; - - foreach (FinancialAccount account in accounts) - { - // For now, just remove the "results" account. TODO: Remove inactive accounts, too. - - if (account.Identity == resultsAccount.Identity) - { - accounts.Remove (account); - break; - } - } - - // Build tree (there should be a template for this) - - report._treeMap = new Dictionary>(); - - foreach (FinancialAccount account in accounts) - { - if (!report._treeMap.ContainsKey (account.ParentIdentity)) - { - report._treeMap[account.ParentIdentity] = new List(); - } - - report._treeMap[account.ParentIdentity].Add (account); - } - - - FinancialAccounts orderedList = new FinancialAccounts(); - // This list is guaranteed to have parents before children - - report.PopulateOrderedList (orderedList, 0); // recursively add nodes parents-first - report.PopulateLookups (orderedList); // populate the lookup tables for results per account - report.PopulateTotals(); - - report.ReportLines = new List(); - report.RecurseAddLines (report.ReportLines, 0); - - // Aggregate accounts, if appropriate - - if (report._treeMap[0].Count > 3) - { - // regroup list - - report.AggregateAccounts(); - } - - return report; - } - - - private void AggregateAccounts() - { - const int assetIdentity = 1000000001; - const int debtIdentity = 1000000002; - const int incomeIdentity = 1000000003; - const int costIdentity = 1000000004; - - Dictionary remapLookup = - new Dictionary(); - - List newRootLevel = new List(); - - int equityIdentity = this._treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity; - - if (this._accountType == FinancialAccountType.Balance) - { - YearlyReportLine assetLine = new YearlyReportLine - {AccountId = assetIdentity, AccountName = "%ASSET_ACCOUNTGROUP%"}; - YearlyReportLine debtLine = new YearlyReportLine - {AccountId = debtIdentity, AccountName = "%DEBT_ACCOUNTGROUP%"}; - remapLookup[FinancialAccountType.Asset] = assetLine; - remapLookup[FinancialAccountType.Debt] = debtLine; - - newRootLevel.Add (assetLine); - newRootLevel.Add (debtLine); - } - else if (this._accountType == FinancialAccountType.Result) - { - YearlyReportLine incomeLine = new YearlyReportLine - {AccountId = incomeIdentity, AccountName = "%INCOME_ACCOUNTGROUP%"}; - YearlyReportLine costLine = new YearlyReportLine - {AccountId = costIdentity, AccountName = "%COST_ACCOUNTGROUP%"}; - remapLookup[FinancialAccountType.Income] = incomeLine; - remapLookup[FinancialAccountType.Cost] = costLine; - - newRootLevel.Add (incomeLine); - newRootLevel.Add (costLine); - } - else - { - throw new InvalidOperationException ( - "AccountType other than Balance or Result passed to YearlyReport.AggregateAccounts()"); - } - - foreach (YearlyReportLine reportLine in this.ReportLines) - { - if (reportLine.AccountId == equityIdentity) - { - newRootLevel.Add (reportLine); - } - else - { - YearlyReportLine aggregateLine = remapLookup[reportLine.AccountType]; - if (aggregateLine.Children == null) - { - aggregateLine.Children = new List(); - } - - aggregateLine.Children.Add (reportLine); - - aggregateLine.AccountTreeValues.PreviousYear += reportLine.AccountTreeValues.PreviousYear; - for (int quarter = 0; quarter < 4; quarter++) - { - aggregateLine.AccountTreeValues.Quarters[quarter] += - reportLine.AccountTreeValues.Quarters[quarter]; - } - - aggregateLine.AccountTreeValues.ThisYear += reportLine.AccountTreeValues.ThisYear; - } - } - - this.ReportLines = newRootLevel; - } - - - private void PopulateTotals() - { - this.Totals = new YearlyReportNode(); - - this.Totals.PreviousYear = PopulateOneTotal (this._singleLookups[0]); - this.Totals.ThisYear = PopulateOneTotal (this._singleLookups[5]); - - for (int quarter = 0; quarter < 4; quarter++) - { - this.Totals.Quarters[quarter] = PopulateOneTotal (this._singleLookups[quarter + 1]); - } - } - - private Int64 PopulateOneTotal (Dictionary lookup) - { - Int64[] allValues = lookup.Values.ToArray(); - - return allValues.Sum(); - } - - - private void RecurseAddLines (List list, int renderNodeId) - { - foreach (FinancialAccount account in this._treeMap[renderNodeId]) - { - YearlyReportLine newLine = new YearlyReportLine(); - newLine.AccountId = account.Identity; - newLine.AccountName = account.Name; - newLine.AccountType = account.AccountType; - newLine.AccountValues = CreateYearlyReportNode (account.Identity, this._singleLookups); - newLine.AccountTreeValues = CreateYearlyReportNode (account.Identity, this._treeLookups); - - if (this._treeMap.ContainsKey (account.Identity)) - { - RecurseAddLines (newLine.Children, account.Identity); - } - - list.Add (newLine); - } - } - - - private YearlyReportNode CreateYearlyReportNode (int accountId, Dictionary[] lookup) - { - YearlyReportNode node = new YearlyReportNode(); - node.PreviousYear = lookup[0][accountId]; - - for (int quarter = 1; quarter <= 4; quarter++) - { - node.Quarters[quarter - 1] = lookup[quarter][accountId]; - } - - node.ThisYear = lookup[5][accountId]; - return node; - } - - - private void PopulateOrderedList (FinancialAccounts orderedList, int renderNodeId) - { - foreach (FinancialAccount account in this._treeMap[renderNodeId]) - { - orderedList.Add (account); - - if (this._treeMap.ContainsKey (account.Identity)) - { - PopulateOrderedList (orderedList, account.Identity); // recursive call - } - } - } - - - private void PopulateLookups (FinancialAccounts accounts) - { - this._singleLookups = new Dictionary[6]; - this._treeLookups = new Dictionary[6]; - - for (int index = 0; index < 6; index++) - { - this._treeLookups[index] = new Dictionary(); - this._singleLookups[index] = new Dictionary(); - } - - DateTime[] quarterBoundaries = - { - new DateTime (this.Year, 1, 1), new DateTime (this.Year, 4, 1), new DateTime (this.Year, 7, 1), - new DateTime (this.Year, 10, 1), new DateTime (this.Year + 1, 1, 1) - }; - - // 1) Actually, the accounts are already sorted. Or are supposed to be, anyway, - // since FinancialAccounts.ForOrganization gets the _tree_ rather than the flat list. - - // 2) Add all values to the accounts. - - foreach (FinancialAccount account in accounts) - { - // Find this year's inbound - - if (this._accountType == FinancialAccountType.Result) - { - this._singleLookups[0][account.Identity] = account.GetDeltaCents ( - new DateTime (this.Year - 1, 1, 1), - new DateTime (this.Year, 1, 1)); - } - else if (this._accountType == FinancialAccountType.Balance) - { - this._singleLookups[0][account.Identity] = account.GetDeltaCents (new DateTime (1900, 1, 1), - new DateTime (this.Year, 1, 1)); - } - else - { - throw new InvalidOperationException ( - "Can only calculate yearly reports for balance or P&L statements"); - } - - // Find quarter diffs - - for (int quarter = 0; quarter < 4; quarter++) - { - this._singleLookups[quarter + 1][account.Identity] = - account.GetDeltaCents (quarterBoundaries[quarter], - quarterBoundaries[quarter + 1]); - } - - // Find outbound - - if (this._accountType == FinancialAccountType.Result) - { - this._singleLookups[5][account.Identity] = account.GetDeltaCents (new DateTime (this.Year, 1, 1), - new DateTime (this.Year + 1, 1, 1)); - } - else if (this._accountType == FinancialAccountType.Balance) - { - this._singleLookups[5][account.Identity] = account.GetDeltaCents (new DateTime (1900, 1, 1), - new DateTime (this.Year + 1, 1, 1)); - } - else - { - throw new InvalidOperationException ( - "Can only calculate yearly reports for balance or P&L statements"); - } - - // copy to treeLookups - - for (int index = 0; index < 6; index++) - { - this._treeLookups[index][account.Identity] = this._singleLookups[index][account.Identity]; - } - } - - // 3) Add all children's values to parents - - for (int index = 0; index < 6; index++) - { - AddChildrenValuesToParents (this._treeLookups[index], accounts); - } - - // Done. - } - - - private void AddChildrenValuesToParents (Dictionary lookup, FinancialAccounts accounts) - { - // Iterate backwards and add any value to its parent's value, as they are sorted in tree order. - - for (int index = accounts.Count - 1; index >= 0; index--) - { - int parentFinancialAccountId = accounts[index].ParentFinancialAccountId; - int accountId = accounts[index].Identity; - - if (parentFinancialAccountId != 0) - { - lookup[parentFinancialAccountId] += lookup[accountId]; - } - } - } - } - - - [Serializable] - public class YearlyReportLine - { - public int AccountId; - public string AccountName; - public YearlyReportNode AccountTreeValues; - public FinancialAccountType AccountType; - public YearlyReportNode AccountValues; - - public List Children; - - public YearlyReportLine() - { - this.Children = new List(); - this.AccountValues = new YearlyReportNode(); - this.AccountTreeValues = new YearlyReportNode(); - } - } - - [Serializable] - public class YearlyReportNode - { - public Int64 PreviousYear; - public Int64[] Quarters; - public Int64 ThisYear; - - public YearlyReportNode() - { - this.Quarters = new Int64[4]; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using Swarmops.Common.Enums; +using Swarmops.Logic.Structure; + +namespace Swarmops.Logic.Financial +{ + [Serializable] + public class AnnualReport + { + public Organization Organization; + public List ReportLines; + public AnnualReportNode Totals; + public int Year; + private FinancialAccountType _accountType; + private Dictionary[] _singleLookups; + private Dictionary[] _treeLookups; + private Dictionary> _treeMap; + + public static AnnualReport Create (Organization organization, int year, FinancialAccountType accountType) + { + AnnualReport report = new AnnualReport(); + report.Organization = organization; + report.Year = year; + report._accountType = accountType; + + // Get accounts + + FinancialAccounts accounts = FinancialAccounts.ForOrganization (organization, accountType); + + // Remove unwanted accounts + + FinancialAccount resultsAccount = organization.FinancialAccounts.CostsYearlyResult; + + foreach (FinancialAccount account in accounts) + { + // For now, just remove the "results" account. TODO: Remove inactive accounts, too. + + if (account.Identity == resultsAccount.Identity) + { + accounts.Remove (account); + break; + } + } + + // Build tree (there should be a template for this) + + report._treeMap = new Dictionary>(); + + foreach (FinancialAccount account in accounts) + { + if (!report._treeMap.ContainsKey (account.ParentIdentity)) + { + report._treeMap[account.ParentIdentity] = new List(); + } + + report._treeMap[account.ParentIdentity].Add (account); + } + + + FinancialAccounts orderedList = new FinancialAccounts(); + // This list is guaranteed to have parents before children + + report.PopulateOrderedList (orderedList, 0); // recursively add nodes parents-first + report.PopulateLookups (orderedList); // populate the lookup tables for results per account + report.PopulateTotals(); + + report.ReportLines = new List(); + report.RecurseAddLines (report.ReportLines, 0); + + // Aggregate accounts, if appropriate + + if (report._treeMap[0].Count > 3) + { + // regroup list + + report.AggregateAccounts(); + } + + return report; + } + + + private void AggregateAccounts() + { + const int assetIdentity = 1000000001; + const int debtIdentity = 1000000002; + const int incomeIdentity = 1000000003; + const int costIdentity = 1000000004; + + Dictionary remapLookup = + new Dictionary(); + + List newRootLevel = new List(); + + int equityIdentity = this._treeMap[0][0].Organization.FinancialAccounts.DebtsEquity.Identity; + + if (this._accountType == FinancialAccountType.Balance) + { + AnnualReportLine assetLine = new AnnualReportLine + {AccountId = assetIdentity, AccountName = "%ASSET_ACCOUNTGROUP%"}; + AnnualReportLine debtLine = new AnnualReportLine + {AccountId = debtIdentity, AccountName = "%DEBT_ACCOUNTGROUP%"}; + remapLookup[FinancialAccountType.Asset] = assetLine; + remapLookup[FinancialAccountType.Debt] = debtLine; + + newRootLevel.Add (assetLine); + newRootLevel.Add (debtLine); + } + else if (this._accountType == FinancialAccountType.Result) + { + AnnualReportLine incomeLine = new AnnualReportLine + {AccountId = incomeIdentity, AccountName = "%INCOME_ACCOUNTGROUP%"}; + AnnualReportLine costLine = new AnnualReportLine + {AccountId = costIdentity, AccountName = "%COST_ACCOUNTGROUP%"}; + remapLookup[FinancialAccountType.Income] = incomeLine; + remapLookup[FinancialAccountType.Cost] = costLine; + + newRootLevel.Add (incomeLine); + newRootLevel.Add (costLine); + } + else + { + throw new InvalidOperationException ( + "AccountType other than Balance or Result passed to AnnualReport.AggregateAccounts()"); + } + + foreach (AnnualReportLine reportLine in this.ReportLines) + { + if (reportLine.AccountId == equityIdentity) + { + newRootLevel.Add (reportLine); + } + else + { + AnnualReportLine aggregateLine = remapLookup[reportLine.AccountType]; + if (aggregateLine.Children == null) + { + aggregateLine.Children = new List(); + } + + aggregateLine.Children.Add (reportLine); + + aggregateLine.AccountTreeValues.PreviousYear += reportLine.AccountTreeValues.PreviousYear; + for (int quarter = 0; quarter < 4; quarter++) + { + aggregateLine.AccountTreeValues.Quarters[quarter] += + reportLine.AccountTreeValues.Quarters[quarter]; + } + + aggregateLine.AccountTreeValues.ThisYear += reportLine.AccountTreeValues.ThisYear; + } + } + + this.ReportLines = newRootLevel; + } + + + private void PopulateTotals() + { + this.Totals = new AnnualReportNode(); + + this.Totals.PreviousYear = PopulateOneTotal (this._singleLookups[0]); + this.Totals.ThisYear = PopulateOneTotal (this._singleLookups[5]); + + for (int quarter = 0; quarter < 4; quarter++) + { + this.Totals.Quarters[quarter] = PopulateOneTotal (this._singleLookups[quarter + 1]); + } + } + + private Int64 PopulateOneTotal (Dictionary lookup) + { + Int64[] allValues = lookup.Values.ToArray(); + + return allValues.Sum(); + } + + + private void RecurseAddLines (List list, int renderNodeId) + { + foreach (FinancialAccount account in this._treeMap[renderNodeId]) + { + AnnualReportLine newLine = new AnnualReportLine(); + newLine.AccountId = account.Identity; + newLine.AccountName = account.Name; + newLine.AccountType = account.AccountType; + newLine.AccountValues = CreateYearlyReportNode (account.Identity, this._singleLookups); + newLine.AccountTreeValues = CreateYearlyReportNode (account.Identity, this._treeLookups); + + if (this._treeMap.ContainsKey (account.Identity)) + { + RecurseAddLines (newLine.Children, account.Identity); + } + + list.Add (newLine); + } + } + + + private AnnualReportNode CreateYearlyReportNode (int accountId, Dictionary[] lookup) + { + AnnualReportNode node = new AnnualReportNode(); + node.PreviousYear = lookup[0][accountId]; + + for (int quarter = 1; quarter <= 4; quarter++) + { + node.Quarters[quarter - 1] = lookup[quarter][accountId]; + } + + node.ThisYear = lookup[5][accountId]; + return node; + } + + + private void PopulateOrderedList (FinancialAccounts orderedList, int renderNodeId) + { + foreach (FinancialAccount account in this._treeMap[renderNodeId]) + { + orderedList.Add (account); + + if (this._treeMap.ContainsKey (account.Identity)) + { + PopulateOrderedList (orderedList, account.Identity); // recursive call + } + } + } + + + private void PopulateLookups (FinancialAccounts accounts) + { + this._singleLookups = new Dictionary[6]; + this._treeLookups = new Dictionary[6]; + + for (int index = 0; index < 6; index++) + { + this._treeLookups[index] = new Dictionary(); + this._singleLookups[index] = new Dictionary(); + } + + DateTime[] quarterBoundaries = + { + new DateTime (this.Year, 1, 1), new DateTime (this.Year, 4, 1), new DateTime (this.Year, 7, 1), + new DateTime (this.Year, 10, 1), new DateTime (this.Year + 1, 1, 1) + }; + + // 1) Actually, the accounts are already sorted. Or are supposed to be, anyway, + // since FinancialAccounts.ForOrganization gets the _tree_ rather than the flat list. + + // 2) Add all values to the accounts. + + foreach (FinancialAccount account in accounts) + { + // Find this year's inbound + + if (this._accountType == FinancialAccountType.Result) + { + this._singleLookups[0][account.Identity] = account.GetDeltaCents ( + new DateTime (this.Year - 1, 1, 1), + new DateTime (this.Year, 1, 1)); + } + else if (this._accountType == FinancialAccountType.Balance) + { + this._singleLookups[0][account.Identity] = account.GetDeltaCents (new DateTime (1900, 1, 1), + new DateTime (this.Year, 1, 1)); + } + else + { + throw new InvalidOperationException ( + "Can only calculate yearly reports for balance or P&L statements"); + } + + // Find quarter diffs + + for (int quarter = 0; quarter < 4; quarter++) + { + this._singleLookups[quarter + 1][account.Identity] = + account.GetDeltaCents (quarterBoundaries[quarter], + quarterBoundaries[quarter + 1]); + } + + // Find outbound + + if (this._accountType == FinancialAccountType.Result) + { + this._singleLookups[5][account.Identity] = account.GetDeltaCents (new DateTime (this.Year, 1, 1), + new DateTime (this.Year + 1, 1, 1)); + } + else if (this._accountType == FinancialAccountType.Balance) + { + this._singleLookups[5][account.Identity] = account.GetDeltaCents (new DateTime (1900, 1, 1), + new DateTime (this.Year + 1, 1, 1)); + } + else + { + throw new InvalidOperationException ( + "Can only calculate yearly reports for balance or P&L statements"); + } + + // copy to treeLookups + + for (int index = 0; index < 6; index++) + { + this._treeLookups[index][account.Identity] = this._singleLookups[index][account.Identity]; + } + } + + // 3) Add all children's values to parents + + for (int index = 0; index < 6; index++) + { + AddChildrenValuesToParents (this._treeLookups[index], accounts); + } + + // Done. + } + + + private void AddChildrenValuesToParents (Dictionary lookup, FinancialAccounts accounts) + { + // Iterate backwards and add any value to its parent's value, as they are sorted in tree order. + + for (int index = accounts.Count - 1; index >= 0; index--) + { + int parentFinancialAccountId = accounts[index].ParentFinancialAccountId; + int accountId = accounts[index].Identity; + + if (parentFinancialAccountId != 0) + { + lookup[parentFinancialAccountId] += lookup[accountId]; + } + } + } + } + + + [Serializable] + public class AnnualReportLine + { + public int AccountId; + public string AccountName; + public AnnualReportNode AccountTreeValues; + public FinancialAccountType AccountType; + public AnnualReportNode AccountValues; + + public List Children; + + public AnnualReportLine() + { + this.Children = new List(); + this.AccountValues = new AnnualReportNode(); + this.AccountTreeValues = new AnnualReportNode(); + } + } + + [Serializable] + public class AnnualReportNode + { + public Int64 PreviousYear; + public Int64[] Quarters; + public Int64 ThisYear; + + public AnnualReportNode() + { + this.Quarters = new Int64[4]; + } + } } \ No newline at end of file diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 0d323882..1b529b36 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -220,7 +220,7 @@ - + True True diff --git a/Site5/Pages/v5/Ledgers/Csv-BalanceData.aspx.cs b/Site5/Pages/v5/Ledgers/Csv-BalanceData.aspx.cs index 88d31a80..fb8aaad4 100644 --- a/Site5/Pages/v5/Ledgers/Csv-BalanceData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Csv-BalanceData.aspx.cs @@ -22,7 +22,7 @@ public partial class Pages_v5_Ledgers_Csv_BalanceData : DataV5Base this._year = Int32.Parse (yearParameter); // will throw if non-numeric - don't matter for app } - YearlyReport report = YearlyReport.Create (CurrentOrganization, this._year, FinancialAccountType.Balance); + AnnualReport report = AnnualReport.Create (CurrentOrganization, this._year, FinancialAccountType.Balance); Response.ClearContent(); Response.ClearHeaders(); @@ -50,7 +50,7 @@ public partial class Pages_v5_Ledgers_Csv_BalanceData : DataV5Base } - private void LocalizeRoot (List lines) + private void LocalizeRoot (List lines) { Dictionary localizeMap = new Dictionary(); @@ -59,7 +59,7 @@ public partial class Pages_v5_Ledgers_Csv_BalanceData : DataV5Base localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; - foreach (YearlyReportLine line in lines) + foreach (AnnualReportLine line in lines) { if (localizeMap.ContainsKey (line.AccountName)) { @@ -69,9 +69,9 @@ public partial class Pages_v5_Ledgers_Csv_BalanceData : DataV5Base } - private void RecurseCsvReport (List reportLines, string accountPrefix) + private void RecurseCsvReport (List reportLines, string accountPrefix) { - foreach (YearlyReportLine line in reportLines) + foreach (AnnualReportLine line in reportLines) { Response.Output.WriteLine ("\"{0}{1}\",{2},{3},{4},{5},{6},{7}", accountPrefix, line.AccountName, diff --git a/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs index 69dc795f..c2e72895 100644 --- a/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs @@ -22,7 +22,7 @@ public partial class Pages_v5_Ledgers_Csv_ProfitLossData : DataV5Base this._year = Int32.Parse (yearParameter); // will throw if non-numeric - don't matter for app } - YearlyReport report = YearlyReport.Create (CurrentOrganization, this._year, FinancialAccountType.Result); + AnnualReport report = AnnualReport.Create (CurrentOrganization, this._year, FinancialAccountType.Result); Response.ClearContent(); Response.ClearHeaders(); @@ -55,7 +55,7 @@ public partial class Pages_v5_Ledgers_Csv_ProfitLossData : DataV5Base } - private void LocalizeRoot (List lines) + private void LocalizeRoot (List lines) { Dictionary localizeMap = new Dictionary(); @@ -64,7 +64,7 @@ public partial class Pages_v5_Ledgers_Csv_ProfitLossData : DataV5Base localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; - foreach (YearlyReportLine line in lines) + foreach (AnnualReportLine line in lines) { if (localizeMap.ContainsKey (line.AccountName)) { @@ -74,9 +74,9 @@ public partial class Pages_v5_Ledgers_Csv_ProfitLossData : DataV5Base } - private void RecurseCsvReport (List reportLines, string accountPrefix) + private void RecurseCsvReport (List reportLines, string accountPrefix) { - foreach (YearlyReportLine line in reportLines) + foreach (AnnualReportLine line in reportLines) { Response.Output.WriteLine ("\"{0}{1}\",{2},{3},{4},{5},{6},{7}", accountPrefix, line.AccountName, diff --git a/Site5/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs index 32ee4bb6..711d74b1 100644 --- a/Site5/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-BalanceSheetData.aspx.cs @@ -30,7 +30,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers this._year = Int32.Parse (yearParameter); // will throw if non-numeric - don't matter for app } - YearlyReport report = YearlyReport.Create (this._authenticationData.CurrentOrganization, this._year, + AnnualReport report = AnnualReport.Create (this._authenticationData.CurrentOrganization, this._year, FinancialAccountType.Balance); LocalizeRoot (report.ReportLines); @@ -41,7 +41,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers Response.End(); } - private void LocalizeRoot (List lines) + private void LocalizeRoot (List lines) { Dictionary localizeMap = new Dictionary(); @@ -50,7 +50,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; - foreach (YearlyReportLine line in lines) + foreach (AnnualReportLine line in lines) { if (localizeMap.ContainsKey (line.AccountName)) { @@ -60,11 +60,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers } - private string RecurseReport (List reportLines) + private string RecurseReport (List reportLines) { List elements = new List(); - foreach (YearlyReportLine line in reportLines) + foreach (AnnualReportLine line in reportLines) { string element = string.Format ("\"id\":\"{0}\",\"name\":\"{1}\"", line.AccountId, JsonSanitize (line.AccountName)); diff --git a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs index 95e1afba..2c4c03a6 100644 --- a/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-ProfitLossData.aspx.cs @@ -27,7 +27,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base this._year = Int32.Parse (yearParameter); // will throw if non-numeric - don't matter for app } - YearlyReport report = YearlyReport.Create (CurrentOrganization, this._year, FinancialAccountType.Result); + AnnualReport report = AnnualReport.Create (CurrentOrganization, this._year, FinancialAccountType.Result); LocalizeRoot (report.ReportLines); Response.ContentType = "application/json"; @@ -39,7 +39,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base } - private void LocalizeRoot (List lines) + private void LocalizeRoot (List lines) { Dictionary localizeMap = new Dictionary(); @@ -48,7 +48,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; - foreach (YearlyReportLine line in lines) + foreach (AnnualReportLine line in lines) { if (localizeMap.ContainsKey (line.AccountName)) { @@ -58,7 +58,7 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base } - private string WriteFooter (YearlyReportNode totals) + private string WriteFooter (AnnualReportNode totals) { string result = string.Format ("\"name\":\"{0}\"", Ledgers.ProfitLossStatement_Results); @@ -77,11 +77,11 @@ public partial class Pages_v5_Ledgers_Json_ProfitLossData : DataV5Base } - private string RecurseReport (List reportLines) + private string RecurseReport (List reportLines) { List elements = new List(); - foreach (YearlyReportLine line in reportLines) + foreach (AnnualReportLine line in reportLines) { string element = string.Format ("\"id\":\"{0}\",\"name\":\"{1}\"", line.AccountId, JsonSanitize (line.AccountName)); diff --git a/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs index 941113df..e1f190ff 100644 --- a/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs @@ -121,7 +121,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms - private void LocalizeRoot (List lines) + private void LocalizeRoot (List lines) { Dictionary localizeMap = new Dictionary(); @@ -130,7 +130,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Global.Financial_Income; localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Global.Financial_Cost; - foreach (YearlyReportLine line in lines) + foreach (AnnualReportLine line in lines) { if (localizeMap.ContainsKey (line.AccountName)) { @@ -140,11 +140,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms } - private string RecurseReport (List reportLines) + private string RecurseReport (List reportLines) { List elements = new List(); - foreach (YearlyReportLine line in reportLines) + foreach (AnnualReportLine line in reportLines) { string element = string.Format ("\"id\":\"{0}\",\"monthYear\":\"{1}\"", line.AccountId, JsonSanitize (line.AccountName));