private string GetInvoiceID() { DateTime period = Report.EndPeriod.AddMonths(-1); return(string.Format("SUB {0} {1:MM/yy} {2} {3}" , ReportSettings.GetServiceUnitBillingNumber(period, Report.BillingCategory) , period , ReportSettings.CompanyName , Utility.EnumToString(Report.BillingCategory).ToLower() )); }
//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); }