public IList<Report> GetReports(int year, int clientId) { _year = year; _clientId = clientId; PrepareReport(); GetAccounts(); AccountsGrouping(); foreach (var account in _accounts) { _report = new Report { AccountName = account.Name, Dt = new List<ReportDocument>(), Ct = new List<ReportDocument>() }; GetAccountOpeningsDictionaryForAccount(account); GetAccountDocumentsForAccountSide(account, report => report.Dt, openings => openings.Dt, document=>document.AccountDt); GetAccountDocumentsForAccountSide(account, report => report.Ct, openings => openings.Ct, document=>document.AccountCt); CalculateSums(); CalculateClosingForSideCt(); CalculateClosingForSideDt(); if (AnyDocumentsExists()) _result.Add(_report); } return _result; }
private string GetAccountTable(Report report) { var rows = ""; for (int i = 0; i < Math.Max(report.Ct.Count, report.Dt.Count); i++) { var dtName = report.Dt.Count > i ? report.Dt[i].AutoNumber : ""; var dtPrice = report.Dt.Count > i ? DecimalToString(report.Dt[i].Price) : ""; var ctName = report.Ct.Count > i ? report.Ct[i].AutoNumber : ""; var ctPrice = report.Ct.Count > i ? DecimalToString(report.Ct[i].Price) : ""; rows += "<tr><td class=\"col-2\">" + dtName + "</td><td class=\"col-4 right\">" + dtPrice + "</td><td class=\"col-2\">" + ctName + "</td><td class=\"col-4 right\">" + ctPrice + "</td></tr>"; } var dtBzName = IsZero(report.DtClosing) ? "" : "BZ"; var dtBzPrice = IsZero(report.DtClosing) ? "" : DecimalToString(report.DtClosing); var ctBzName = IsZero(report.CtClosing) ? "" : "BZ"; var ctBzPrice = IsZero(report.CtClosing) ? "" : DecimalToString(report.CtClosing); var table = "<table class=\"main col-11\" id=\"one-column-emphasis\"><thead>" + "<tr><th colspan=\"4\"><b>Konto: " + report.AccountName + "</b></th></tr>" + "<tr><th class=\"col-2\"></th><th class=\"col-4 right\">Ma</th><th class=\"col-2\"></th><th class=\"col-4 right\">Wn</th></tr>" + "</thead><tbody></tbody></table>" + "<table class=\"col-11\" id=\"one-column-emphasis\"><thead></thead><tbody>" + rows + "</tbody></table>" + "<table class=\"main col-11\" id=\"one-column-emphasis\"><thead></thead><tbody>" + "<tr class=\"bold\"><td class=\"col-2\">suma:</td><td class=\"col-4 right\">" + DecimalToString(report.DtSum) + "</td><td class=\"col-2\">suma:</td><td class=\"col-4 right\">" + DecimalToString(report.CtSum) + "</td></tr>" + "<tr class=\"bold\"><td class=\"col-2\">" + dtBzName + "</td><td class=\"col-4 right\">" + dtBzPrice + "</td><td class=\"col-2\">" + ctBzName + "</td><td class=\"col-4 right\">" + ctBzPrice + "</td></tr></tbody></table>"; return table; }