Ejemplo n.º 1
0
        private void ProcessJUC(DataTable dtReport, DataRow drBilling, ReportAccount debitAcct, string journalLineRef, double subsidyDiscount, ref double total)
        {
            if (debitAcct.FundCode != "20000" && debitAcct.FundCode != "25000" && !(debitAcct.FundCode == "10000" && debitAcct.ProgramCode == "CSTSH"))
            {
                DataRow newdr = dtReport.NewRow();
                newdr["ReportType"]                  = Utility.EnumToString(Report.ReportType);
                newdr["ChargeType"]                  = Utility.EnumToString(Report.BillingCategory);
                newdr["JournalUnitType"]             = Report.JournalUnitType;
                newdr["Period"]                      = drBilling["Period"];
                newdr["Account"]                     = debitAcct.Account;
                newdr["FundCode"]                    = debitAcct.FundCode;
                newdr["DeptID"]                      = debitAcct.DeptID;
                newdr["ProgramCode"]                 = debitAcct.ProgramCode;
                newdr["Class"]                       = debitAcct.Class;
                newdr["ProjectGrant"]                = debitAcct.ProjectGrant;
                newdr["DepartmentalReferenceNumber"] = journalLineRef;
                newdr["ItemDescription"]             = GetItemDescription(drBilling, $"{ReportSettings.CompanyName}{ChargeTypeAbbreviation()}C");
                newdr["MerchandiseAmount"]           = (Math.Round(subsidyDiscount, 2) * -1).ToString("0.00");

                //Used to calculate the total credit amount
                total += Utility.ConvertTo(newdr["MerchandiseAmount"], 0D);

                dtReport.Rows.Add(newdr);
            }
        }
Ejemplo n.º 2
0
        //this should be called by the inheriting class in the GenerateDataTablesForSUB override
        protected override void ProcessTable(DataTable dtBilling)
        {
            DataTable dtReport = InitTable();

            string deptRefNum      = string.Empty;
            double subsidyDiscount = 0;
            double total           = 0;

            BillingUnit summary = new BillingUnit();

            //for loop each record in ClientID and AccountID aggregate
            foreach (DataRow cadr in ClientAccountData.Rows)
            {
                if (cadr.RowState != DataRowState.Deleted)
                {
                    ValidPeriodCheck(cadr);

                    double chargeAmount = Math.Round(Utility.ConvertTo(dtBilling.Compute("SUM(LineCost)", DataRowFilter(cadr)), 0D), 2);
                    if (dtBilling.Columns.Contains("SubsidyDiscount"))
                    {
                        subsidyDiscount = Utility.ConvertTo(dtBilling.Compute("SUM(SubsidyDiscount)", DataRowFilter(cadr)), 0D);
                    }

                    if (chargeAmount != 0)
                    {
                        //2011-02-08 There will be some unavoidable rounding difference, so we basicaly ignore anything for 1 cent
                        if (Math.Abs(chargeAmount) > 0.01)
                        {
                            DataRow[] billingrows = dtBilling.Select(DataRowFilter(cadr));
                            if (billingrows.Length > 0)
                            {
                                DataRow       dr = billingrows[0];
                                string        debitAcctNumber = Utility.ConvertTo(dr["Number"], string.Empty);
                                ReportAccount debitAcct       = new ReportAccount(debitAcctNumber);

                                //get manager's name
                                deptRefNum = ManagerName(cadr);

                                DateTime p           = Utility.ConvertTo(dr["Period"], DateTime.MinValue);
                                DateTime invoiceDate = (p.Equals(DateTime.MinValue)) ? Report.EndPeriod.AddMonths(-1) : p;

                                DataRow newdr = dtReport.NewRow();
                                newdr["ReportType"]   = Utility.EnumToString(Report.ReportType);
                                newdr["ChargeType"]   = Utility.EnumToString(Report.BillingCategory);
                                newdr["Period"]       = dr["Period"];
                                newdr["CardType"]     = 1;
                                newdr["ShortCode"]    = dr["ShortCode"];
                                newdr["Account"]      = debitAcct.Account;
                                newdr["FundCode"]     = debitAcct.FundCode;
                                newdr["DeptID"]       = debitAcct.DeptID;
                                newdr["ProgramCode"]  = debitAcct.ProgramCode;
                                newdr["Class"]        = debitAcct.Class;
                                newdr["ProjectGrant"] = debitAcct.ProjectGrant;
                                newdr["VendorID"]     = "0000456136"; //wtf?
                                newdr["InvoiceDate"]  = invoiceDate.ToString("yyyy/MM/dd");
                                newdr["InvoiceID"]    = GetInvoiceID();
                                newdr["Uniqname"]     = dr["UserName"];
                                newdr["DepartmentalReferenceNumber"] = deptRefNum;
                                newdr["ItemDescription"]             = GetItemDescription(dr);
                                newdr["QuantityVouchered"]           = "1.0000";
                                newdr["CreditAccount"]     = CreditAccount;
                                newdr["UsageCharge"]       = Math.Round(chargeAmount, 2).ToString("0.00");
                                newdr["SubsidyDiscount"]   = Math.Round(subsidyDiscount, 2).ToString("0.00");
                                newdr["BilledCharge"]      = Math.Round(chargeAmount - subsidyDiscount, 2).ToString("0.00");
                                newdr["UnitOfMeasure"]     = Math.Round(chargeAmount, 5).ToString("0.00000");
                                newdr["MerchandiseAmount"] = newdr["UsageCharge"];

                                //Used to calculate the total credit amount
                                total += chargeAmount;

                                //for testing purpose
                                newdr["AccountID"] = cadr["AccountID"];

                                dtReport.Rows.Add(newdr);
                            }
                        }
                    }
                }
            }

            _ReportTables.Add(dtReport);

            //Summary row
            ReportAccount credit_acct = new ReportAccount(CreditAccount);

            summary.CardType     = 1;
            summary.ShortCode    = CreditAccountShortCode;
            summary.Account      = credit_acct.Account;
            summary.FundCode     = credit_acct.FundCode;
            summary.DeptID       = credit_acct.DeptID;
            summary.ProgramCode  = credit_acct.ProgramCode;
            summary.ClassName    = credit_acct.Class;
            summary.ProjectGrant = credit_acct.ProjectGrant;
            summary.InvoiceDate  = Report.EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd");
            summary.Uniqname     = ReportSettings.FinancialManagerUserName;
            summary.DepartmentalReferenceNumber = deptRefNum;
            summary.ItemDescription             = ReportSettings.FinancialManagerUserName;
            summary.MerchandiseAmount           = -total;
            summary.CreditAccount     = CreditAccount;
            summary.QuantityVouchered = "1.0000";
            AddSummary(summary);

            double SumUsageCharge     = 0;
            double SumSubsidyDiscount = 0;
            double SumBilledCharge    = 0;

            foreach (DataRow dr in dtReport.Rows)
            {
                SumUsageCharge     += Utility.ConvertTo(dr["UsageCharge"], 0D);
                SumSubsidyDiscount += Utility.ConvertTo(dr["SubsidyDiscount"], 0D);
                SumBilledCharge    += Utility.ConvertTo(dr["BilledCharge"], 0D);
                if (Report.BillingCategory == BillingCategory.Store)
                {
                    dr["UsageCharge"]     = string.Empty;
                    dr["SubsidyDiscount"] = string.Empty;
                }
            }

            DataRow totalrow = dtReport.NewRow();

            totalrow["ReportType"]      = Utility.EnumToString(Report.ReportType);
            totalrow["ChargeType"]      = Utility.EnumToString(Report.BillingCategory);
            totalrow["Period"]          = Report.EndPeriod.AddMonths(-1);
            totalrow["ShortCode"]       = dtReport.Rows.Count - 1;
            totalrow["UsageCharge"]     = (Report.BillingCategory == BillingCategory.Store) ? string.Empty : SumUsageCharge.ToString("0.00");
            totalrow["SubsidyDiscount"] = (Report.BillingCategory == BillingCategory.Store) ? string.Empty : SumSubsidyDiscount.ToString("0.00");
            totalrow["BilledCharge"]    = SumBilledCharge.ToString("0.00");
            dtReport.Rows.Add(totalrow);
        }
Ejemplo n.º 3
0
        //this should be called by the inheriting class in the GenerateDataTablesForSUB override
        protected override void ProcessTable(DataTable dtBilling)
        {
            DataTable dtReport = InitTable();

            double chargeAmount;
            string journalLineRef = string.Empty;
            double subsidyDiscount;
            double total = 0;

            //for loop each record in clientID and AccountID aggregate
            foreach (DataRow cadr in ClientAccountData.Rows)
            {
                if (cadr.RowState != DataRowState.Deleted)
                {
                    ValidPeriodCheck(cadr);

                    chargeAmount = Math.Round(Convert.ToDouble(dtBilling.Compute("SUM(LineCost)", DataRowFilter(cadr))), 2);
                    if (Math.Abs(chargeAmount) > 0.01)
                    {
                        subsidyDiscount = Utility.ConvertTo(dtBilling.Compute("SUM(SubsidyDiscount)", DataRowFilter(cadr)), 0D);
                        if (chargeAmount != 0 && subsidyDiscount != 0)
                        {
                            DataRow[]     billingrows  = dtBilling.Select(DataRowFilter(cadr));
                            DataRow       drBilling    = billingrows[0];
                            string        debitAccount = Utility.ConvertTo(drBilling["Number"], string.Empty);
                            ReportAccount dai          = new ReportAccount(debitAccount);

                            //get manager's name
                            journalLineRef = Utility.Clip(ManagerName(drBilling), 10);

                            switch (Report.JournalUnitType)
                            {
                            case JournalUnitTypes.A:
                                ProcessJUA(dtReport, drBilling, dai, journalLineRef, subsidyDiscount, ref total);
                                break;

                            case JournalUnitTypes.B:
                                ProcessJUB(dtReport, drBilling, dai, journalLineRef, subsidyDiscount, ref total);
                                break;

                            case JournalUnitTypes.C:
                                ProcessJUC(dtReport, drBilling, dai, journalLineRef, subsidyDiscount, ref total);
                                break;

                            default:
                                throw new ArgumentException("Invalid JournalUnitType. Allowed values: A, B, C");
                            }
                        }
                    }
                }
            }

            _ReportTables.Add(dtReport);

            //Summary row
            ReportAccount cai = new ReportAccount(CreditAccount);

            DateTime period = Report.EndPeriod.AddMonths(-1);

            string account = (Report.JournalUnitType == JournalUnitTypes.C) ? "613280" : cai.Account;

            /*
             * [2021-11-22 jg] Add the JournalUnitType next to BillingCategory in the ItemDescription
             *
             * Excerpt from email from Dave DeWeerd Oct 27, 2021:
             *
             * 2) I’d add the case type so for instance rather than
             *  08/21 LNF Room Subsidy;SUB662
             * enter
             *  08/21 LNF RoomA Subsidy;SUB662
             * or
             *  08/21 LNF Tool Subsidy;SUB663
             * enter
             *  08/21 LNF ToolC Subsidy;SUB663
             * (this line I believe comes through on subsidy funds, so when we review the non-943 activity super clear which case it is if we ever need to reference it)
             * Other than those two items, seems a nice update, consistent with how we have been submitting the billing and probably takes out a few steps in the process, adds more consistency to the data
             */

            Report.CreditEntry = new CreditEntry
            {
                Account      = account,
                FundCode     = cai.FundCode,
                DeptID       = cai.DeptID,
                ProgramCode  = cai.ProgramCode,
                ClassName    = cai.Class,
                ProjectGrant = cai.ProjectGrant,
                DepartmentalReferenceNumber = ReportSettings.FinancialManagerUserName,
                // CreditEntryItemDescription example: {0:MM/yy} {1} {2}{3} Subsidy;SUB{4}
                ItemDescription = string.Format(
                    Utility.GetRequiredAppSetting("CreditEntryItemDescription"),
                    /*0*/ period,
                    /*1*/ ReportSettings.CompanyName,
                    /*2*/ Utility.EnumToString(Report.BillingCategory),
                    /*3*/ Utility.EnumToString(Report.JournalUnitType),
                    /*4*/ ReportSettings.GetServiceUnitBillingNumber(period, Report.BillingCategory)
                    ),
                MerchandiseAmount = Math.Round(-total, 2),
                CreditAccount     = CreditAccount
            };

            DataRow totalrow = dtReport.NewRow();

            totalrow["ReportType"]                  = Utility.EnumToString(Report.ReportType);
            totalrow["ChargeType"]                  = Utility.EnumToString(Report.BillingCategory);
            totalrow["JournalUnitType"]             = Report.JournalUnitType;
            totalrow["Period"]                      = period;
            totalrow["Account"]                     = account;
            totalrow["FundCode"]                    = cai.FundCode;
            totalrow["DeptID"]                      = cai.DeptID;
            totalrow["ProgramCode"]                 = cai.ProgramCode;
            totalrow["Class"]                       = cai.Class;
            totalrow["ProjectGrant"]                = cai.ProjectGrant;
            totalrow["DepartmentalReferenceNumber"] = string.Empty;
            totalrow["ItemDescription"]             = $"zz{ReportSettings.FinancialManagerUserName}";
            totalrow["MerchandiseAmount"]           = Math.Round(-total, 2).ToString("0.00");
            dtReport.Rows.Add(totalrow);
        }