Example #1
0
            }             // ToTable

            public void UpdateTotal(AccountingLoanBalanceRow row)
            {
                LoanID++;

                IssuedAmount    += row.IssuedAmount;
                RepaidPrincipal += row.RepaidPrincipal;
                RepaidInterest  += row.RepaidInterest;
                FeesRepaid      += row.FeesRepaid;
                SetupFee        += row.SetupFee;
                EarnedInterest  += row.EarnedInterest;

                EarnedFees  += row.EarnedFees;
                CashPaid    += row.CashPaid;
                NonCashPaid += row.NonCashPaid;

                WriteOffEarnedFees  += row.WriteOffEarnedFees;
                WriteOffCashPaid    += row.WriteOffCashPaid;
                WriteOffNonCashPaid += row.WriteOffNonCashPaid;

                TotalBalance += row.Balance;

                if (row.CurrentCustomerStatus == CustomerStatus.WriteOff)
                {
                    WriteOffTotalBalance +=
                        row.IssuedAmount +
                        row.SetupFee +
                        row.EarnedInterest +
                        row.WriteOffEarnedFees -
                        row.WriteOffCashPaid -
                        row.WriteOffNonCashPaid;
                }         // if
            }             // UpdateTotal
Example #2
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