public void PaymentEdit_AutoSplitForPayment_NoNegativeAutoSplits() { long provNumA = ProviderT.CreateProvider("provA"); Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 70); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0150", ProcStat.C, "", 20); //make an overpayment for one of the procedures so it spills over. DateTime payDate = DateTime.Today; Payment pay = PaymentT.MakePayment(pat.PatNum, 71, payDate, procNum: proc1.ProcNum); //pre-existing payment //attempt to make another payment. Auto splits should not suggest a negative split. Payment newPayment = PaymentT.MakePaymentNoSplits(pat.PatNum, 2, payDate, isNew: true, payType: Defs.GetDefsForCategory(DefCat.PaymentTypes, true)[0].DefNum);//current payment we're trying to make PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, newPayment, new List <long>() { pat.PatNum }, true, false); PaymentEdit.ConstructChargesData chargeData = PaymentEdit.GetConstructChargesData(new List <long> { pat.PatNum }, pat.PatNum, PaySplits.GetForPayment(pay.PayNum), pay.PayNum, false); PaymentEdit.ConstructResults constructResults = PaymentEdit.ConstructAndLinkChargeCredits(new List <long> { pat.PatNum }, pat.PatNum , chargeData.ListPaySplits, newPayment, new List <Procedure> ()); PaymentEdit.AutoSplit autoSplits = PaymentEdit.AutoSplitForPayment(constructResults); Assert.AreEqual(0, autoSplits.ListAutoSplits.FindAll(x => x.SplitAmt < 0).Count); //assert no negative auto splits were made. Assert.AreEqual(0, autoSplits.ListSplitsCur.FindAll(x => x.SplitAmt < 0).Count); //auto splits not catching everything }