Exemplo n.º 1
0
 public static PaymentEdit.IncomeTransferData IncomeTransfer(long patNum, Family fam, Payment payCur, List <PayPlanCharge> listPayPlanCredits,
                                                             bool doIncludeHidden = false)
 {
     #region generate charges and credits for account
     //go through the logic that constructs the charges for the income transfer manager
     PaymentEdit.ConstructResults results = PaymentEdit.ConstructAndLinkChargeCredits(fam.ListPats.Select(x => x.PatNum).ToList(),
                                                                                      patNum, new List <PaySplit>(), payCur, new List <AccountEntry>(), true, false, doShowHiddenSplits: doIncludeHidden);
     PaymentEdit.IncomeTransferData transfers      = new PaymentEdit.IncomeTransferData();
     List <AccountEntry>            listPosCharges = results.ListAccountCharges.FindAll(x => x.AmountEnd > 0).OrderBy(x => x.Date).ToList();
     List <AccountEntry>            listNegCharges = results.ListAccountCharges.FindAll(x => x.AmountEnd < 0).OrderBy(x => x.Date).ToList();
     List <long>         listPatsWithPosCharges    = listPosCharges.Select(y => y.PatNum).Distinct().ToList();
     List <AccountEntry> listAccountEntries        = results.ListAccountCharges.FindAll(x => x.PatNum.In(listPatsWithPosCharges));
     #endregion
     //begin transfer loops
     #region transfer within payplans first
     PaymentEdit.IncomeTransferData payPlanResults = PaymentEdit.CreatePayplanLoop(listPosCharges, listNegCharges, listAccountEntries
                                                                                   , payCur.PayNum, listPayPlanCredits, DateTimeOD.Today);
     transfers.MergeIncomeTransferData(payPlanResults);
     #endregion
     #region regular transfers
     PaymentEdit.IncomeTransferData txfrResults = PaymentEdit.CreateTransferLoop(listPosCharges, listNegCharges, listAccountEntries
                                                                                 , payCur.PayNum, listPayPlanCredits, DateTimeOD.Today);
     transfers.MergeIncomeTransferData(txfrResults);
     #endregion
     return(transfers);
 }
Exemplo n.º 2
0
        ///<summary>Creates micro-allocations intelligently based on most to least matching criteria of selected charges.</summary>
        private string CreateTransfers(List <AccountEntry> listPosCharges, List <AccountEntry> listNegCharges, List <AccountEntry> listAccountEntries
                                       , FamilyAccount famAccount, Payment payCur)
        {
            PaymentEdit.IncomeTransferData transferResults = new PaymentEdit.IncomeTransferData();
            List <PayPlanCharge>           listCredits     = famAccount.Account.ListPayPlanCharges.FindAll(x => x.ChargeType == PayPlanChargeType.Credit);
            string retVal = "";

            transferResults = PaymentEdit.CreatePayplanLoop(listPosCharges, listNegCharges, listAccountEntries, payCur.PayNum, listCredits, datePicker.Value);
            transferResults.MergeIncomeTransferData(PaymentEdit.CreateTransferLoop(listPosCharges, listNegCharges, listAccountEntries, payCur.PayNum
                                                                                   , listCredits, datePicker.Value, famAccount.Guarantor.PatNum));
            famAccount.ListSplits.AddRange(transferResults.ListSplitsCur);
            famAccount.ListSplitsAssociated.AddRange(transferResults.ListSplitsAssociated);
            retVal += transferResults.SummaryText;
            return(retVal);
        }