Beispiel #1
0
        private void CalcBalances(object row, bool isCalcRGOL, bool DiscOnDiscDate)
        {
            ARAdjust adj = (ARAdjust)row;

            PXCache cache = Caches[typeof(ARAdjust)];

            ARPayment payment = (ARPayment)ARPayment_CustomerID_DocType_RefNbr.Select(adj.CustomerID, adj.AdjgDocType, adj.AdjgRefNbr);

            if (payment == null)
            {
                return;
            }

            PaymentEntry.CalcBalances <ARPayment, ARAdjust>(CurrencyInfo_CuryInfoID, adj.AdjgCuryInfoID, adj.AdjdCuryInfoID, payment, adj);

            if (DiscOnDiscDate)
            {
                PaymentEntry.CalcDiscount <ARPayment, ARAdjust>(adj.AdjgDocDate, payment, adj);
            }

            PaymentEntry.AdjustBalance <ARAdjust>(CurrencyInfo_CuryInfoID, adj);
            if (isCalcRGOL)
            {
                PaymentEntry.CalcRGOL <ARPayment, ARAdjust>(CurrencyInfo_CuryInfoID, payment, adj);
                adj.RGOLAmt = (bool)adj.ReverseGainLoss ? -1m * adj.RGOLAmt : adj.RGOLAmt;
            }
        }
Beispiel #2
0
        public static void CalculateBalancesAR <TInvoice>(PXGraph graph, PXSelectBase <CurrencyInfo> curyInfoSelect, ARAdjust adj, TInvoice invoice, bool isCalcRGOL, bool DiscOnDiscDate)
            where TInvoice : IInvoice
        {
            Customer currentCustomer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Optional <CABankTran.payeeBAccountID> > > > .Select(graph);

            PaymentEntry.CalcBalances <TInvoice, ARAdjust>(curyInfoSelect, adj.AdjgCuryInfoID, adj.AdjdCuryInfoID, invoice, adj);
            if (DiscOnDiscDate)
            {
                PaymentEntry.CalcDiscount <TInvoice, ARAdjust>(adj.AdjgDocDate, invoice, adj);
            }
            PaymentEntry.WarnDiscount <TInvoice, ARAdjust>(graph, adj.AdjgDocDate, invoice, adj);

            CurrencyInfo pay_info   = curyInfoSelect.Select(adj.AdjgCuryInfoID);
            CurrencyInfo vouch_info = curyInfoSelect.Select(adj.AdjdCuryInfoID);

            if (vouch_info != null && string.Equals(pay_info.CuryID, vouch_info.CuryID) == false)
            {
                adj.AdjdCuryRate = Math.Round((vouch_info.CuryMultDiv == "M" ? (decimal)vouch_info.CuryRate : 1 / (decimal)vouch_info.CuryRate) * (pay_info.CuryMultDiv == "M" ? 1 / (decimal)pay_info.CuryRate : (decimal)pay_info.CuryRate), 8, MidpointRounding.AwayFromZero);
            }
            else
            {
                adj.AdjdCuryRate = 1m;
            }

            if (currentCustomer != null && currentCustomer.SmallBalanceAllow == true && adj.AdjgDocType != ARDocType.Refund && adj.AdjdDocType != ARDocType.CreditMemo)
            {
                decimal      payment_smallbalancelimit;
                CurrencyInfo payment_info = curyInfoSelect.Select(adj.AdjgCuryInfoID);
                PXDBCurrencyAttribute.CuryConvCury(curyInfoSelect.Cache, payment_info, currentCustomer.SmallBalanceLimit ?? 0m, out payment_smallbalancelimit);
                adj.CuryWOBal = payment_smallbalancelimit;
                adj.WOBal     = currentCustomer.SmallBalanceLimit;
            }
            else
            {
                adj.CuryWOBal = 0m;
                adj.WOBal     = 0m;
            }

            PaymentEntry.AdjustBalance <ARAdjust>(curyInfoSelect, adj);
            if (isCalcRGOL && (adj.Voided != true))
            {
                PaymentEntry.CalcRGOL <TInvoice, ARAdjust>(curyInfoSelect, invoice, adj);
                adj.RGOLAmt = (bool)adj.ReverseGainLoss ? -1.0m * adj.RGOLAmt : adj.RGOLAmt;
            }
        }