Advertisement
Guest User

report logic

a guest
Jul 24th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 23.44 KB | None | 0 0
  1. public  class GLReportManager
  2.     {
  3.         public static VoucherManager VoucherManager=new VoucherManager();
  4.         static TransactionManager TransactionManager = new TransactionManager();
  5.         #region Trial Balance
  6.  
  7.         public static List<TrialBalanceRow> CalculateTrialBalance(int companyId,DateTime tbDate)
  8.         {
  9.             List<TrialBalanceRow> rows = new List<TrialBalanceRow>();
  10.             var charts = ChartManager.GetAll(companyId).OrderBy(c => c.AccountTypeId);
  11.             Company company = CompanyManager.Find(companyId);
  12.             company.CalculateDates(tbDate);
  13.             double sumPL = 0;
  14.            
  15.             DateTime currentYearStart= (DateTime) company.CurrentYearStart;
  16.             DateTime openingBlanceDate = company.OpeningBlanceDate;
  17.                
  18.             foreach (Account c in charts)
  19.                 {
  20.                     var row = new TrialBalanceRow { AccountName = c.AccountName, AccountType = c.AccountType.Type,ConsolidationId = c.ConsolidationId,AccountTypeId = c.AccountTypeId};
  21.                     if (c.AccountType.Type == "Income" || c.AccountType.Type == "Expense" ||
  22.                         c.AccountType.Type == "Dividend" || c.AccountType.Type == "Acc P&L")
  23.                     {
  24.                         TrialBalanceCalculateRow(row, currentYearStart, tbDate, c.AccountId);
  25.                         sumPL += TrialBalanceGetSumPl(openingBlanceDate,(DateTime)company.LastYearClosing, c.AccountId);
  26.  
  27.                         if (c.AccountType.Type == "Acc P&L")
  28.                         {
  29.                             if (sumPL > 0)
  30.                             { row.Debit += sumPL; }
  31.                             else
  32.                             { row.Credit += Math.Abs(sumPL); }
  33.                         }
  34.                     }
  35.                     else
  36.                     {
  37.                         TrialBalanceCalculateRow(row, openingBlanceDate, tbDate, c.AccountId);
  38.                     }
  39.                     if(row.Debit+row.Credit>0) rows.Add(row);
  40.                 }
  41.             ConsolidateRows(companyId, rows);
  42.             if (rows.Count > 0)
  43.                 {
  44.                     rows.Add(new TrialBalanceRow { AccountName = "Total", Debit = rows.Sum(r => r.Debit), Credit = rows.Sum(r => r.Credit),AccountTypeId = 100});
  45.                 }
  46.                 rows=rows.OrderBy(r => r.AccountTypeId).ToList();
  47.                 return rows;
  48.         }
  49.  
  50.         private static void TrialBalanceCalculateRow(TrialBalanceRow row, DateTime fromDate, DateTime toDate, int accountId)
  51.         {
  52.             row.Debit = TransactionManager.GetAll(VoucherManager.GetByDateRange(fromDate, toDate)).Where(t => t.AccountId == accountId).Sum(t => t.Debit);
  53.             row.Credit = TransactionManager.GetAll(VoucherManager.GetByDateRange(fromDate, toDate)).Where(t => t.AccountId == accountId).Sum(t => t.Credit);
  54.             AdjustDrCr(row);
  55.         }
  56.        
  57.         private static void ConsolidateRows(int companyId, List<TrialBalanceRow> rows)
  58.         {
  59.             var conNames = rows.Where(r => r.ConsolidationId > 0).Select(r => r.AccountType).Distinct().ToList();
  60.  
  61.             foreach (string conName in conNames)
  62.             {
  63.                 if(!string.IsNullOrEmpty(conName))
  64.                 {
  65.                     var acType = AccountTypeManager.GetAccountTypebyName(conName);
  66.                     Consolidation con=ConsolidationManager.GetAll(companyId).FirstOrDefault(c => c.AccountTypeId == acType.Id);
  67.                     double debit = rows.Where(r=>r.AccountType==conName&&r.ConsolidationId>0).Sum(r => r.Debit);
  68.                     double credit = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0).Sum(r => r.Credit);
  69.                     var row = new TrialBalanceRow{AccountName = con.Name,AccountType = acType.Type,Debit = debit,Credit = credit,AccountTypeId = acType.Id,ConsolidationId = 0};  
  70.                     AdjustDrCr(row);
  71.                     rows.Add(row);
  72.                 }
  73.             }
  74.            
  75.             rows.RemoveAll(r => r.ConsolidationId > 0);
  76.         }
  77.  
  78.         private static double TrialBalanceGetSumPl(DateTime fromDate, DateTime toDate, int accountId)
  79.         {
  80.             double pldSum = TransactionManager.GetAll(VoucherManager.GetByDateRange(fromDate, toDate)).Where(t => t.AccountId == accountId).Sum(t => t.Debit);
  81.             double plcSum = TransactionManager.GetAll(VoucherManager.GetByDateRange(fromDate, toDate)).Where(t => t.AccountId == accountId).Sum(t => t.Credit);
  82.             return (pldSum - plcSum);
  83.         }
  84.  
  85.         #endregion
  86.  
  87.         #region Reciept Payment
  88.         public static List<TrialBalanceRow> CalculateRP(int companyId,DateTime fromDate,DateTime toDate,bool consolidation)
  89.         {
  90.             List<TrialBalanceRow> rows = new List<TrialBalanceRow>();
  91.             List<Account> charts = new List<Account>();
  92.            
  93.             #region Opening Balance
  94.             rows.Add(new TrialBalanceRow { AccountName = "Opening Balance" });
  95.             charts = ChartManager.GetAll(companyId).Where(c => c.AccountType.Type == "Cash" || c.AccountType.Type == "Bank").ToList();
  96.  
  97.             foreach (var chartOfAccount in charts)
  98.             {
  99.                 rows.Add(new TrialBalanceRow
  100.                 {
  101.                     AccountName = chartOfAccount.AccountName,
  102.                     Debit = TransactionManager.GetAll(companyId,chartOfAccount.AccountId).Where(t =>  t.Voucher.Date < fromDate).Sum(t => t.Debit),
  103.                     Credit = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t => t.Voucher.Date < fromDate).Sum(t => t.Credit),
  104.                     ConsolidationId = chartOfAccount.ConsolidationId,
  105.                     AccountTypeId = 1,
  106.                     AccountType = chartOfAccount.AccountType.Type,
  107.                 });
  108.             }
  109.             #endregion
  110.  
  111.             #region Transaction During period
  112.             charts = ChartManager.GetAll(companyId).Where(c => c.AccountType.Type != "Cash" && c.AccountType.Type != "Bank").ToList();
  113.             rows.Add(new TrialBalanceRow());
  114.             foreach (var chartOfAccount in charts)
  115.             {
  116.                 rows.Add(new TrialBalanceRow
  117.                 {
  118.                     AccountName = chartOfAccount.AccountName,
  119.                     Debit = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t => t.Voucher.Date >= fromDate && t.Voucher.Date <= toDate && t.Credit > 0 && t.Voucher.Type != "Journal").Sum(t => t.Credit),
  120.                     Credit = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t =>t.Voucher.Date >= fromDate && t.Voucher.Date <= toDate && t.Debit > 0 && t.Voucher.Type != "Journal").Sum(t => t.Debit),
  121.                     ConsolidationId = chartOfAccount.ConsolidationId,
  122.                     AccountTypeId = 2,
  123.                     AccountType = chartOfAccount.AccountType.Type,
  124.                 });
  125.             }
  126.             Adjustments(rows);
  127.             TrialBalanceRow closingRow = new TrialBalanceRow
  128.             {
  129.                 AccountName = "Closing Balance",
  130.                 AccountTypeId = 2,
  131.  
  132.             };
  133.             var closingBalance = rows.Where(r => r.AccountTypeId == 1 || r.AccountTypeId == 2).Sum(r => r.Debit) -
  134.                                  rows.Where(r => r.AccountTypeId == 1 || r.AccountTypeId == 2).Sum(r => r.Credit);
  135.  
  136.             if (closingBalance < 0)
  137.                 closingRow.Credit = closingBalance;
  138.             else
  139.                 closingRow.Debit = Math.Abs(closingBalance);
  140.  
  141.             rows.Add(closingRow);
  142.             Adjustments(rows);
  143.             rows.Add(new TrialBalanceRow { AccountName = "Total", Debit = rows.Sum(r => r.Debit), Credit = rows.Sum(r => r.Credit) });
  144.             rows.Add(new TrialBalanceRow());
  145.             #endregion
  146.  
  147.             #region Closing Balance Explanation
  148.             charts = ChartManager.GetAll(companyId).Where(c => c.AccountType.Type == "Cash" || c.AccountType.Type == "Bank").ToList();
  149.             foreach (var chartOfAccount in charts)
  150.             {
  151.                 rows.Add(new TrialBalanceRow
  152.                 {
  153.                     AccountName = chartOfAccount.AccountName,
  154.                     Debit = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t => t.Voucher.Date <= toDate).Sum(t => t.Debit),
  155.                     Credit = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t =>  t.Voucher.Date <= toDate).Sum(t => t.Credit),
  156.                     AccountTypeId = 3,
  157.                     ConsolidationId = chartOfAccount.ConsolidationId,
  158.                     AccountType = chartOfAccount.AccountType.Type,
  159.                 });
  160.             }
  161.             Adjustments(rows);
  162.             rows.RemoveAll(r => r.AccountTypeId > 0 && r.Debit == 0 && r.Credit == 0);
  163.             #endregion
  164.  
  165.             if(consolidation) ConsolidateRPRows(companyId, rows);
  166.             return rows;
  167.         }
  168.  
  169.         private static void Adjustments(List<TrialBalanceRow> rows)
  170.         {
  171.             foreach (var trialBalanceRow in rows)
  172.             {
  173.                 //break;
  174.                 if (trialBalanceRow.AccountTypeId > 0)
  175.                 {
  176.                     if (trialBalanceRow.Debit > trialBalanceRow.Credit)
  177.                     {
  178.                         trialBalanceRow.Debit -= trialBalanceRow.Credit;
  179.                         trialBalanceRow.Credit = 0;
  180.                     }
  181.                     else
  182.                     {
  183.  
  184.                         trialBalanceRow.Credit -= trialBalanceRow.Debit;
  185.                         trialBalanceRow.Debit = 0;
  186.                     }
  187.                 }
  188.             }
  189.         }
  190.  
  191.         private static void ConsolidateRPRows(int companyId, List<TrialBalanceRow> rows)
  192.         {
  193.             for (int i = 1; i < 4; i++) {
  194.             var conNames = rows.Where(r => r.ConsolidationId > 0 && r.AccountTypeId==i).Select(r => r.AccountType).Distinct().ToList();
  195.  
  196.             foreach (string conName in conNames)
  197.             {
  198.                 if (!string.IsNullOrEmpty(conName))
  199.                 {
  200.                     var acType = AccountTypeManager.GetAccountTypebyName(conName);
  201.                     Consolidation con = ConsolidationManager.GetAll(companyId).FirstOrDefault(c => c.AccountTypeId == acType.Id);
  202.                     double debit = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0 && r.AccountTypeId == i).Sum(r => r.Debit);
  203.                     double credit = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0 && r.AccountTypeId == i).Sum(r => r.Credit);
  204.                     var row = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0 && r.AccountTypeId == i).FirstOrDefault();
  205.                     row.Debit = debit;
  206.                     row.Credit = credit;
  207.                     row.AccountName = con.Name;
  208.                     row.AccountType = acType.Type;
  209.                     row.AccountTypeId = i;
  210.                     row.ConsolidationId = 0;
  211.                     AdjustDrCr(row);
  212.                 }
  213.             }
  214.  
  215.             }
  216.             rows.RemoveAll(r => r.ConsolidationId > 0);
  217.         }
  218.  
  219.         #endregion
  220.  
  221.         #region Balance Sheet
  222.         public static List<BalanceSheetRow> CalculateBalanceSheet(int companyId, DateTime tbDate,bool consolidate)
  223.         {
  224.             DateTime balanceDate = tbDate, fromDate = new DateTime();
  225.             Company company = CompanyManager.Find(companyId);
  226.             company.CalculateDates(balanceDate);
  227.             List<BalanceSheetRow> rows = new List<BalanceSheetRow>();
  228.             List<Account> charts = ChartManager.GetAll(companyId).OrderBy(c => c.AccountTypeId).ToList();
  229.             double sumAcPL = 0, sumProfitLoss = 0;
  230.  
  231.             foreach (Account c in charts)
  232.             {
  233.                 BalanceSheetRow row = new BalanceSheetRow
  234.                                           {
  235.                                               AccountName = c.AccountName,
  236.                                               AccountType = c.AccountType.Type,
  237.                                               ConsolidationId = c.ConsolidationId,
  238.                                           };
  239.  
  240.                 if (c.AccountType.Type == "Income" || c.AccountType.Type == "Expense" ||
  241.                     c.AccountType.Type == "Dividend" || c.AccountType.Type == "Acc P&L")
  242.                 {
  243.                     fromDate = (DateTime)company.CurrentYearStart;
  244.  
  245.                     var ploss = TransactionManager.GetTransactionData(companyId)
  246.                         .Where(t => t.AccountId == c.AccountId &&
  247.                             t.Date >= company.OpeningBlanceDate && t.Date <= company.LastYearClosing);
  248.                     sumAcPL += ploss.Sum(t => t.Debit - t.Credit);
  249.                 }
  250.                 else
  251.                 {
  252.                     fromDate = company.OpeningBlanceDate;
  253.                 }
  254.  
  255.                 var transactionList = TransactionManager.GetTransactionData(companyId).
  256.                     Where(t => t.AccountId == c.AccountId && t.Date >= fromDate && t.Date <= balanceDate);
  257.                 BalanceSheetCalculateRow(row, transactionList, rows, ref sumProfitLoss);
  258.  
  259.                 if (c.AccountType.Type == "Acc P&L")
  260.                 {
  261.                     if (sumAcPL > 0)
  262.                     {
  263.                         row.Debit += sumAcPL;
  264.                     }
  265.                     else
  266.                     {
  267.                         row.Credit -= sumAcPL;
  268.                     }
  269.                 }
  270.             }
  271.             BalanceSheetRow profitloss = new BalanceSheetRow
  272.             {
  273.                 AccountName = " for the period",
  274.             };
  275.             if (sumProfitLoss >= 0)
  276.             {
  277.                 profitloss.Credit = sumProfitLoss;
  278.                 profitloss.Debit = 0;
  279.                 profitloss.AccountName = "Profit" + profitloss.AccountName;
  280.             }
  281.             else
  282.             {
  283.                 profitloss.Debit = Math.Abs(sumProfitLoss);
  284.                 profitloss.Credit = 0;
  285.                 profitloss.AccountName = "Loss"+profitloss.AccountName;
  286.             }
  287.             rows.Add(profitloss);
  288.            
  289.  
  290.             foreach (BalanceSheetRow row in rows)
  291.             {
  292.                 if (row.AccountType != "Fixed Asset" && row.AccountType != "Current Asset" && row.AccountType != "Cash" && row.AccountType != "Bank")
  293.                 {
  294.                     row.Balance = row.Credit - row.Debit;
  295.                 }
  296.                 else
  297.                 {
  298.                     row.Balance = row.Debit - row.Credit;
  299.                 }
  300.             }
  301.  
  302.            
  303.             rows.RemoveAll(r => r.Balance == 0);
  304.             if(consolidate) ConsolidateBSRows(companyId,rows);
  305.             return rows;
  306.         }
  307.  
  308.         private static void ConsolidateBSRows(int companyId, List<BalanceSheetRow> rows)
  309.         {
  310.                 var conNames = rows.Where(r => r.ConsolidationId > 0).Select(r => r.AccountType).Distinct().ToList();
  311.  
  312.                 foreach (string conName in conNames)
  313.                 {
  314.                     if (!string.IsNullOrEmpty(conName))
  315.                     {
  316.                         var acType = AccountTypeManager.GetAccountTypebyName(conName);
  317.                         Consolidation con = ConsolidationManager.GetAll(companyId).FirstOrDefault(c => c.AccountTypeId == acType.Id);
  318.                         double debit = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0 ).Sum(r => r.Debit);
  319.                         double credit = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0).Sum(r => r.Credit);
  320.                         var row = rows.Where(r => r.AccountType == conName && r.ConsolidationId > 0).FirstOrDefault();
  321.                         row.Debit = debit;
  322.                         row.Credit = credit;
  323.                         row.AccountName = con.Name;
  324.                         row.AccountType = acType.Type;
  325.                         //row.AccountTypeId = i;
  326.                         row.ConsolidationId = 0;
  327.                         AdjustDrCr(row);
  328.                     }
  329.                 }
  330.  
  331.            
  332.             rows.RemoveAll(r => r.ConsolidationId > 0);
  333.         }
  334.  
  335.         private static void BalanceSheetCalculateRow( BalanceSheetRow row, IEnumerable<TransactionData> tset, List<BalanceSheetRow> rows, ref double sumProfitLoss)
  336.         {
  337.             row.Debit = tset.Sum(t => t.Debit);
  338.             row.Credit = tset.Sum(t => t.Credit);
  339.  
  340.             if (row.Debit > row.Credit)
  341.             {
  342.                 row.Debit = row.Debit - row.Credit;
  343.                 row.Credit = 0;
  344.             }
  345.             else
  346.             {
  347.                 row.Credit = Math.Abs(row.Debit - row.Credit);
  348.                 row.Debit = 0;
  349.             }
  350.             if (row.AccountType == "Income" || row.AccountType == "Expense")
  351.             {
  352.                 sumProfitLoss += row.Credit - row.Debit;
  353.             }
  354.             else
  355.             {
  356.                 rows.Add(row);
  357.             }
  358.  
  359.         }
  360.         #endregion
  361.  
  362.         #region Income Statement
  363.         public static List<TrialBalanceRow> CalculateIncomeRows(int companyId, DateTime fromDate, DateTime toDate)
  364.         {
  365.             double drSum, crSum;
  366.             var rows = new List<TrialBalanceRow>();
  367.             var charts = ChartManager.GetAll(companyId).Where(c => c.AccountType.Type == "Income" || c.AccountType.Type == "Expense");
  368.  
  369.             foreach (var chartOfAccount in charts)
  370.             {
  371.                 drSum = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t =>  t.Voucher.Date >= fromDate && t.Voucher.Date <= toDate).Sum(t => t.Debit);
  372.                 crSum = TransactionManager.GetAll(companyId, chartOfAccount.AccountId).Where(t =>  t.Voucher.Date >= fromDate && t.Voucher.Date <= toDate).Sum(t => t.Credit);
  373.                 var row = new TrialBalanceRow
  374.                                           {
  375.                                               AccountName = chartOfAccount.AccountName,
  376.                                               AccountType = chartOfAccount.AccountType.Type,
  377.                                               Debit = drSum,
  378.                                               Credit = crSum,
  379.                                               ConsolidationId = chartOfAccount.ConsolidationId,
  380.                                               AccountTypeId = chartOfAccount.AccountTypeId
  381.                                           };
  382.                 AdjustDrCr(row);
  383.                if(row.Debit+row.Credit>0) rows.Add(row);
  384.             }
  385.            
  386.             drSum = rows.Sum(r => r.Debit);
  387.             crSum = rows.Sum(r => r.Credit);
  388.             string status = drSum - crSum > 0 ? "Profit for the period" : "Loss for the period";
  389.             var bottomRow = new TrialBalanceRow
  390.             {
  391.                 AccountName = status,
  392.                 Debit = drSum,
  393.                 Credit = crSum,
  394.                
  395.                 AccountTypeId = 100
  396.             };
  397.             AdjustDrCr(bottomRow);
  398.             rows.Add(bottomRow);
  399.             return rows;
  400.         }
  401.         #endregion
  402.  
  403.         #region Ledger Report
  404.  
  405.         public static List<LedgerRow> CalculateLedger(string type, int companyId, DateTime fromDate, DateTime toDate, int accountId)
  406.         {
  407.             Company company = CompanyManager.Find(companyId);
  408.             double openingCreditSum, openingDebitSum;
  409.             List<LedgerRow> rows=new List<LedgerRow>();
  410.            
  411.             company.CalculateDates(fromDate);
  412.  
  413.             if (type == "Income" || type == "Expense" || type == "Dividend")
  414.             {
  415.                 openingDebitSum = TransactionManager.GetAll(VoucherManager.GetByDateRange((DateTime)company.CurrentYearStart, fromDate.AddDays(-1))).Where(t => t.AccountId == accountId).Sum(t => t.Debit);
  416.                 openingCreditSum = TransactionManager.GetAll(VoucherManager.GetByDateRange((DateTime)company.CurrentYearStart, fromDate.AddDays(-1))).Where(t => t.AccountId == accountId).Sum(t => t.Credit);
  417.             }
  418.             else
  419.             {
  420.                 openingDebitSum = TransactionManager.GetAll(VoucherManager.GetByDateRange(company.OpeningBlanceDate, fromDate.AddDays(-1))).Where(t => t.AccountId == accountId).Sum(t => t.Debit);
  421.                 openingCreditSum = TransactionManager.GetAll(VoucherManager.GetByDateRange(company.OpeningBlanceDate, fromDate.AddDays(-1))).Where(t => t.AccountId == accountId).Sum(t => t.Credit);
  422.             }
  423.             rows.Add(new LedgerRow { VoucherNumber = "Opening Balance", Details = "Opening Balance", Credit = openingCreditSum, Debit = openingDebitSum, Balance = Math.Abs(openingDebitSum - openingCreditSum), Status = GetStatus(openingDebitSum - openingCreditSum) });
  424.  
  425.  
  426.             var transactiondata = from transaction in TransactionManager.GetAll(companyId, accountId)
  427.                                   where transaction.Voucher.Deleted == false &&
  428.                                       transaction.Voucher.Date >= fromDate && transaction.Voucher.Date <= toDate
  429.                                   select new LedgerRow
  430.                                   {
  431.                                       VoucherNumber = transaction.Voucher.VoucherNumber,
  432.                                       Details = transaction.Voucher.Details,
  433.                                       Debit = transaction.Debit,
  434.                                       Credit = transaction.Credit,
  435.                                   };
  436.  
  437.             rows.AddRange(transactiondata);
  438.             double rowBalance = 0;
  439.             foreach (LedgerRow ledgerRow in rows)
  440.             {
  441.                 rowBalance = rowBalance + ledgerRow.Debit - ledgerRow.Credit;
  442.                 ledgerRow.Balance = Math.Abs(rowBalance);
  443.                 ledgerRow.Status = GetStatus(rowBalance);
  444.                 List<int> accountIds = new List<int>();
  445.                
  446.                 if (ledgerRow.Debit > 0)
  447.                 {
  448.                     accountIds = TransactionManager.GetAll(companyId)
  449.                     .Where(t => t.VoucherNumber == ledgerRow.VoucherNumber
  450.                         && t.AccountId != accountId && t.Credit > 0).Select(r => r.AccountId).ToList();
  451.                 }
  452.                 else
  453.                 {
  454.                     accountIds = TransactionManager.GetAll(companyId)
  455.                     .Where(t => t.VoucherNumber == ledgerRow.VoucherNumber
  456.                         && t.AccountId != accountId && t.Debit > 0).Select(r => r.AccountId).ToList();
  457.                 }
  458.                 for (int i = 0; i < accountIds.Count; i++)
  459.                 {
  460.                     ledgerRow.Accounts += ChartManager.Get(accountIds[i], companyId).AccountName;
  461.                     if (i < accountIds.Count - 1) ledgerRow.Accounts += ",";
  462.                 }
  463.  
  464.  
  465.             }
  466.             rows.Add(new LedgerRow { VoucherNumber = "Total", Debit = rows.Sum(r => r.Debit), Credit = rows.Sum(r => r.Credit), Balance = Math.Abs(rowBalance), Status = GetStatus(rowBalance) });
  467.             return rows;
  468.         }
  469.  
  470.         static string GetStatus(double balance)
  471.         {
  472.             return balance < 0 ? "Cr" : "Dr";
  473.         }
  474.         #endregion
  475.  
  476.         #region CommonFunctions
  477.         private static void AdjustDrCr(TrialBalanceRow row)
  478.         {
  479.             if (row.Debit > row.Credit)
  480.             {
  481.                 row.Debit = row.Debit - row.Credit;
  482.                 row.Credit = 0;
  483.             }
  484.             else
  485.             {
  486.                 row.Credit = row.Credit - row.Debit;
  487.                 row.Debit = 0;
  488.             }
  489.         }
  490.         #endregion
  491.  
  492.  
  493.        
  494.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement