public void LedgersTests_ComputeAging_PayPlanDynamicCreditsWithClaimProcs() { List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamic"); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); Family fam = Patients.GetFamily(pat.PatNum); Procedure proc45 = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum); ClaimProc cp45 = new ClaimProc(); InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, "DynPayPlan"); ClaimProcs.CreateEst(cp45, proc45, insInfo.PriInsPlan, insInfo.PriInsSub); cp45.Status = ClaimProcStatus.NotReceived; cp45.InsEstTotal = -1; cp45.InsPayEst = 15; cp45.WriteOffEst = 0; cp45.WriteOff = 0; ClaimProcs.Update(cp45); listProcs.AddRange(new List <Procedure> { proc45 }); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 30, listProcs, listAdjs); //make two non payplan productions to put on the account Procedure procUnattached = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 35, DateTime.Today.AddDays(-91), provNum: provNum); //Run pay plan logic to generate first set of charges List <PayPlanCharge> listChargesDb = PayPlanCharges.GetForPayPlan(payPlan.PayPlanNum); List <PayPlanLink> listEntries = PayPlanLinks.GetForPayPlans(new List <long> { payPlan.PayPlanNum }); PayPlanTerms terms = PayPlanT.GetTerms(payPlan, listEntries); List <PayPlanCharge> listChargesThisPeriod = PayPlanEdit.GetListExpectedCharges(listChargesDb, terms, fam, listEntries, payPlan, true); Assert.AreEqual(30, listChargesThisPeriod.Sum(x => x.Principal)); foreach (PayPlanCharge charge in listChargesThisPeriod) { PayPlanCharges.Insert(charge); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 30, 0, 15, 35, 30, YN.Yes); //new - pay plan credit of $30 gets applied to cooresponding procedure CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.No); //old - pay plan credit gets applied to oldest production on the account CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.Unknown); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public void LedgersTests_ComputeAging_PayPlanDynamic() { List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamic"); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); Family fam = Patients.GetFamily(pat.PatNum); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 55, DateTime.Today.AddDays(-32), provNum: provNum); Procedure proc3 = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 65, DateTime.Today.AddDays(-15), provNum: provNum); Adjustment adjProc2 = AdjustmentT.MakeAdjustment(pat.PatNum, 10, proc2.ProcDate, proc2.ProcDate, proc2.ProcNum, provNum); Adjustment adjProc3 = AdjustmentT.MakeAdjustment(pat.PatNum, 20, proc3.ProcDate, proc3.ProcDate, proc3.ProcNum, provNum); Adjustment adj = AdjustmentT.MakeAdjustment(pat.PatNum, 30, DateTime.Today.AddDays(-5), provNum: provNum); listProcs.AddRange(new List <Procedure> { proc1, proc2, proc3 }); listAdjs.AddRange(new List <Adjustment> { adj }); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 40, listProcs, listAdjs); //PayPlan payplan=PayPlanT.CreatePayPlanWithCredits(pat.PatNum,40,DateTime.Today,provNum:provNum,listProcs,195,pat.PatNum); //make two non payplan productions to put on the account Procedure procUnattached = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 35, DateTime.Today.AddDays(-91), provNum: provNum); //Run pay plan logic to generate first set of charges List <PayPlanCharge> listChargesDb = PayPlanCharges.GetForPayPlan(payPlan.PayPlanNum); List <PayPlanLink> listEntries = PayPlanLinks.GetForPayPlans(new List <long> { payPlan.PayPlanNum }); PayPlanTerms terms = PayPlanT.GetTerms(payPlan, listEntries); List <PayPlanCharge> listChargesThisPeriod = PayPlanEdit.GetListExpectedCharges(listChargesDb, terms, fam, listEntries, payPlan, true); Assert.AreEqual(40, listChargesThisPeriod.Sum(x => x.Principal)); foreach (PayPlanCharge charge in listChargesThisPeriod) { PayPlanCharges.Insert(charge); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 70, 0, 0, 5, 40, YN.Yes); //new CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.No); //old CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.Unknown); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public static PayPlanTerms GetTerms(PayPlan payplan, List <PayPlanLink> listLinksForPayPlan) { PayPlanTerms terms = new PayPlanTerms(); terms.APR = payplan.APR; terms.DateAgreement = payplan.PayPlanDate; terms.DateFirstPayment = payplan.DatePayPlanStart; terms.Frequency = payplan.ChargeFrequency; terms.PaySchedule = payplan.PaySchedule; terms.PeriodPayment = (decimal)payplan.PayAmt; terms.PrincipalAmount = (double)PayPlanProductionEntry.GetProductionForLinks(listLinksForPayPlan) .Sum(x => x.AmountOverride == 0?x.AmountOriginal:x.AmountOverride); terms.RoundDec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits; return(terms); }
///<summary></summary> public static List <PayPlanCharge> GetForDownPayment(PayPlanTerms terms, Family family, List <PayPlanLink> listPayPlanLinks, PayPlan payplan) { //No remoting role check; no call to db //Create a temporary variable to keep track of the original PeriodPayment. decimal periodPaymentTemp = terms.PeriodPayment; double aprTemp = terms.APR; //Set the PeriodPayment to the current DownPayment so that the full amount of the down payment gets generated. //E.g. there are several procedures attached to the payment plan and the down payment only covers one and a half (partial proc). terms.PeriodPayment = (decimal)terms.DownPayment; terms.APR = 0;//downpayments should pay on principal only List <PayPlanCharge> listDownPayments = PayPlanEdit.GetListExpectedCharges(new List <PayPlanCharge>(), terms, family, listPayPlanLinks, payplan, true , true, new List <PaySplit>()); listDownPayments.ForEach(x => { x.Note = "Down Payment"; x.ChargeDate = DateTime.Today.Date; x.Interest = 0; }); //Put the PeriodPayment back to the way it was upon entry. terms.PeriodPayment = periodPaymentTemp; terms.APR = aprTemp; return(listDownPayments); }