private void butDelete_Click(object sender, System.EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; } else { if (_listSplitsForAdjustment.Count > 0) { MsgBox.Show(this, "Cannot delete adjustment while a payment split is attached."); return; } bool isAttachedToPayPlan = PayPlanLinks.GetForFKeyAndLinkType(_adjustmentCur.AdjNum, PayPlanLinkType.Adjustment).Count > 0; if (isAttachedToPayPlan) { MsgBox.Show(this, "Cannot delete adjustment that is attached to a dynamic payment plan"); return; } if (_listSplitsForAdjustment.Count > 0 && !MsgBox.Show(this, MsgBoxButtons.YesNo, "There are payment splits associated to this adjustment. Do you want to continue deleting?")) { //There are splits for this adjustment return; } SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, _adjustmentCur.PatNum , "Delete for patient: " + _patCur.GetNameLF() + ", " + _adjustmentCur.AdjAmt.ToString("c"), 0, _adjustmentCur.SecDateTEdit); Adjustments.Delete(_adjustmentCur); DialogResult = DialogResult.OK; } }
///<summary>For use with Dynamic Payment Plans. Production (proceudres and adjustments) is attached via PayPlanLinks.</summary> public static PayPlanLink CreatePaymentPlanLink(PayPlan payplan, long procOrAdjNum, PayPlanLinkType linkType) { PayPlanLink link = new PayPlanLink(); link.PayPlanNum = payplan.PayPlanNum; link.AmountOverride = 0; link.FKey = procOrAdjNum; link.LinkType = linkType; PayPlanLinks.Insert(link); return(link); }
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); } }
private void FormAdjust_Load(object sender, System.EventArgs e) { if (AvaTax.IsEnabled()) { //We do not want to allow the user to make edits or delete SalesTax and SalesTaxReturn Adjustments. Popup if no permission so user knows why disabled. if (AvaTax.IsEnabled() && (_adjustmentCur.AdjType == AvaTax.SalesTaxAdjType || _adjustmentCur.AdjType == AvaTax.SalesTaxReturnAdjType) && !Security.IsAuthorized(Permissions.SalesTaxAdjEdit)) { DisableForm(textNote, butCancel); textNote.ReadOnly = true; //This will allow the user to copy the note if desired. } } if (IsNew) { if (!Security.IsAuthorized(Permissions.AdjustmentCreate, true)) //Date not checked here. Message will show later. { if (!Security.IsAuthorized(Permissions.AdjustmentEditZero, true)) //Let user create an adjustment of zero if they have this perm. { MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate)); DialogResult = DialogResult.Cancel; return; } //Make sure amount is 0 after OK click. _checkZeroAmount = true; } } else { if (!Security.IsAuthorized(Permissions.AdjustmentEdit, _adjustmentCur.AdjDate)) { butOK.Enabled = false; butDelete.Enabled = false; //User can't edit but has edit zero amount perm. Allow delete only if date is today. if (Security.IsAuthorized(Permissions.AdjustmentEditZero, true) && _adjustmentCur.AdjAmt == 0 && _adjustmentCur.DateEntry.Date == MiscData.GetNowDateTime().Date) { butDelete.Enabled = true; } } bool isAttachedToPayPlan = PayPlanLinks.GetForFKeyAndLinkType(_adjustmentCur.AdjNum, PayPlanLinkType.Adjustment).Count > 0; _listSplitsForAdjustment = PaySplits.GetForAdjustments(new List <long>() { _adjustmentCur.AdjNum }); if (_listSplitsForAdjustment.Count > 0 || isAttachedToPayPlan) { butAttachProc.Enabled = false; butDetachProc.Enabled = false; labelProcDisabled.Visible = true; } //Do not let the user change the adjustment type if the current adjustment is a "discount plan" adjustment type. if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp") { labelAdditions.Text = Lan.g(this, "Discount Plan") + ": " + Defs.GetName(DefCat.AdjTypes, _adjustmentCur.AdjType); labelSubtractions.Visible = false; listTypePos.Visible = false; listTypeNeg.Visible = false; } } textDateEntry.Text = _adjustmentCur.DateEntry.ToShortDateString(); textAdjDate.Text = _adjustmentCur.AdjDate.ToShortDateString(); textProcDate.Text = _adjustmentCur.ProcDate.ToShortDateString(); if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "+") //pos { textAmount.Text = _adjustmentCur.AdjAmt.ToString("F"); } else if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "-") //neg { textAmount.Text = (-_adjustmentCur.AdjAmt).ToString("F"); //shows without the neg sign } else if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp") //Discount Plan (neg) { textAmount.Text = (-_adjustmentCur.AdjAmt).ToString("F"); //shows without the neg sign } comboClinic.SelectedClinicNum = _adjustmentCur.ClinicNum; comboProv.SetSelectedProvNum(_adjustmentCur.ProvNum); FillComboProv(); if (_adjustmentCur.ProcNum != 0 && PrefC.GetInt(PrefName.RigorousAdjustments) == (int)RigorousAdjustments.EnforceFully) { comboProv.Enabled = false; butPickProv.Enabled = false; comboClinic.Enabled = false; if (Security.IsAuthorized(Permissions.Setup, true)) { labelEditAnyway.Visible = true; butEditAnyway.Visible = true; } } //prevents FillProcedure from being called too many times. Event handlers hooked back up after the lists are filled. listTypeNeg.SelectedIndexChanged -= listTypeNeg_SelectedIndexChanged; listTypePos.SelectedIndexChanged -= listTypePos_SelectedIndexChanged; List <Def> adjCat = Defs.GetDefsForCategory(DefCat.AdjTypes, true); //Positive adjustment types _listAdjPosCats = adjCat.FindAll(x => x.ItemValue == "+"); _listAdjPosCats.ForEach(x => listTypePos.Items.Add(x.ItemName)); listTypePos.SelectedIndex = _listAdjPosCats.FindIndex(x => x.DefNum == _adjustmentCur.AdjType); //can be -1 //Negative adjustment types _listAdjNegCats = adjCat.FindAll(x => x.ItemValue == "-"); _listAdjNegCats.ForEach(x => listTypeNeg.Items.Add(x.ItemName)); listTypeNeg.SelectedIndex = _listAdjNegCats.FindIndex(x => x.DefNum == _adjustmentCur.AdjType);//can be -1 listTypeNeg.SelectedIndexChanged += listTypeNeg_SelectedIndexChanged; listTypePos.SelectedIndexChanged += listTypePos_SelectedIndexChanged; FillProcedure(); textNote.Text = _adjustmentCur.AdjNote; }