Пример #1
0
        }         // BuildFinancialStatsXls

        private KeyValuePair <ReportQuery, DataTable> CreateFinancialStatsReport(Report report, DateTime today, DateTime tomorrow)
        {
            var rpt = new ReportQuery(report)
            {
                DateStart = today,
                DateEnd   = tomorrow
            };

            var ea = new EarnedInterest.EarnedInterest(DB, EarnedInterest.EarnedInterest.WorkingMode.ForPeriod, true, today, tomorrow, this);
            SortedDictionary <int, decimal> earned = ea.Run();

            DataTable oOutput = new DataTable();

            oOutput.Columns.Add("SortOrder", typeof(int));
            oOutput.Columns.Add("Caption", typeof(string));
            oOutput.Columns.Add("Value", typeof(decimal));

            rpt.Execute(DB, (sr, bRowsetStart) => {
                oOutput.Rows.Add((int)sr[0], (string)sr[1], (decimal)sr[2]);
                return(ActionResult.Continue);
            });

            oOutput.Rows.Add(0, "Earned interest", earned.Sum(pair => pair.Value));

            return(new KeyValuePair <ReportQuery, DataTable>(rpt, oOutput));
        } // CreateFinancialStatsReport
Пример #2
0
        }         // BuildEarnedInterestXls

        private KeyValuePair <ReportQuery, DataTable> CreateEarnedInterestReport(Report report, bool bAccountingMode, DateTime today, DateTime tomorrow)
        {
            var ea = new EarnedInterest.EarnedInterest(DB, EarnedInterest.EarnedInterest.WorkingMode.ForPeriod, bAccountingMode, today, tomorrow, this);
            SortedDictionary <int, decimal> earned = ea.Run();

            var rpt = new ReportQuery(report)
            {
                DateStart = today,
                DateEnd   = tomorrow
            };

            var oTotal = new EarnedInterestRow(true, CustomerStatus.Enabled, CustomerStatus.Enabled);

            var oRows = new List <EarnedInterestRow>();

            rpt.Execute(DB, (sr, bRowsetStart) => {
                int nLoanID = sr["LoanID"];

                if (!earned.ContainsKey(nLoanID))
                {
                    return(ActionResult.Continue);
                }

                int nClientID = sr["ClientID"];

                var oNewRow = new EarnedInterestRow(false, ea.CustomerStatusHistory.Data.GetLast(nClientID).NewStatus, ea.CustomerStatusHistory.GetCurrent(nClientID).NewStatus)
                {
                    IssueDate       = sr["IssueDate"],
                    ClientID        = nClientID,
                    LoanID          = nLoanID,
                    ClientName      = sr["ClientName"],
                    ClientEmail     = sr["ClientEmail"],
                    EarnedInterest  = earned[nLoanID],
                    LoanAmount      = sr["LoanAmount"],
                    TotalRepaid     = sr["TotalRepaid"],
                    PrincipalRepaid = sr["PrincipalRepaid"],
                    SetupFees       = sr["SetupFees"],
                    OtherFees       = sr["OtherFees"],
                    Rollover        = sr["Rollover"],
                };

                oTotal.Update(oNewRow);
                oRows.Add(oNewRow);

                return(ActionResult.Continue);
            });             // for each earned interest

            oRows.Sort(EarnedInterestRow.Compare);

            DataTable oOutput = oTotal.ToTable();

            oRows.ForEach(r => r.ToRow(oOutput));

            return(new KeyValuePair <ReportQuery, DataTable>(rpt, oOutput));
        }         // CreateEarnedInterestReport
Пример #3
0
        }         // class LoansIssuedRow

        private KeyValuePair <ReportQuery, DataTable> CreateLoansIssuedReport(Report report, DateTime today, DateTime tomorrow)
        {
            var rpt = new ReportQuery(report)
            {
                DateStart = today,
                DateEnd   = tomorrow
            };

            var ea = new EarnedInterest.EarnedInterest(DB, EarnedInterest.EarnedInterest.WorkingMode.ByIssuedLoans, false, today, tomorrow, this);
            SortedDictionary <int, decimal> earned = ea.Run();

            var oRows = new List <LoansIssuedRow>();

            var oTotal = new LoansIssuedRow(null);

            int nRowCount = 0;

            rpt.Execute(DB, (sr, bRowsetStart) => {
                nRowCount++;

                var lir = new LoansIssuedRow(sr);
                oRows.Add(lir);

                lir.SetInterests(earned);

                oTotal.AddClient(lir);
                oTotal.AccumulateTotals(lir);

                return(ActionResult.Continue);
            });

            oTotal.SetLoanCount(nRowCount);

            DataTable oOutput = oTotal.ToTable();

            oRows.ForEach(lir => lir.ToRow(oOutput));

            return(new KeyValuePair <ReportQuery, DataTable>(rpt, oOutput));
        }         // CreateLoansIssuedReport
Пример #4
0
        }         // class AccountingLoanBalanceRow

        private KeyValuePair <ReportQuery, DataTable> CreateAccountingLoanBalanceReport(
            Report report,
            DateTime today,
            DateTime tomorrow
            )
        {
            Debug("Creating accounting loan balance report...");

            Debug("Creating accounting loan balance report: loading earned interest...");

            var ea = new EarnedInterest.EarnedInterest(
                DB,
                EarnedInterest.EarnedInterest.WorkingMode.ForPeriod,
                true,
                today,
                tomorrow,
                this
                );
            SortedDictionary <int, decimal> earned = ea.Run();

            Debug("Creating accounting loan balance report: loading earned interest complete.");

            var rpt = new ReportQuery(report)
            {
                DateStart = today,
                DateEnd   = tomorrow
            };

            var oRows = new SortedDictionary <int, AccountingLoanBalanceRow>();

            Debug("Creating accounting loan balance report: loading report data...");

            rpt.Execute(DB, (sr, bRowsetStart) => {
                int nLoanID = sr["LoanID"];

                decimal nEarnedInterest = earned.ContainsKey(nLoanID) ? earned[nLoanID] : 0;

                if (oRows.ContainsKey(nLoanID))
                {
                    oRows[nLoanID].Update(sr);
                }
                else
                {
                    int nClientID  = sr["ClientID"];
                    oRows[nLoanID] = new AccountingLoanBalanceRow(
                        sr,
                        nEarnedInterest,
                        ea.CustomerStatusHistory.Data.GetLast(nClientID),
                        ea.CustomerStatusHistory.GetCurrent(nClientID),
                        ea.CustomerStatusHistory.Data.GetWriteOffDate(nClientID) ?? tomorrow
                        );
                }                 // if

                return(ActionResult.Continue);
            });

            Debug("Creating accounting loan balance report: loading report data complete.");

            Debug("Creating accounting loan balance report: creating an output...");

            DataTable oOutput = AccountingLoanBalanceRow.ToTable();

            Debug("Creating accounting loan balance report: table is ready, filling it...");

            var oTotal = new AccountingLoanBalanceRow();

            foreach (KeyValuePair <int, AccountingLoanBalanceRow> pair in oRows)
            {
                oTotal.UpdateTotal(pair.Value);
            }

            oTotal.ToRow(oOutput);

            foreach (KeyValuePair <int, AccountingLoanBalanceRow> pair in oRows)
            {
                pair.Value.ToRow(oOutput);
            }

            Debug("Creating accounting loan balance report complete.");

            return(new KeyValuePair <ReportQuery, DataTable>(rpt, oOutput));
        } // CreateAccountingLoanBalanceReport