如何解决如何计算付款和应用程序的自定义折扣
美好的一天
我正在“付款和应用程序”屏幕上进行自定义折扣计算。
折扣适用于原始发票余额 (ARInvoice.CuryDocBal) 乘以 discPecent 折扣 = OriginalInvoiceBalance * (CurrentCustomerTerms.discPercent.Value / 100);
主要区别在于 Acumatica 使用发票金额而不是余额。
在计算出我的折扣和付款并尝试发放付款后,我收到以下错误:
public void Calculate(PXCache cache,aradjust row)
{
try
{
if (row == null)
return;
if (!(row.Released != true && row.Voided != true))
return;
// row.AdjdRefNbr current invoice
ARPayment currentARPayment = this.Base.Document.Current;
if (currentARPayment.DocType != "PMT" || currentARPayment.Status == "C")
return;
if (row.AdjdDocType != "INV")
return;
if (row.Selected != true)
return;
Customer currentCustomer = this.Base.customer.Current;
Terms CurrentCustomerTerms = PXSelect<
Terms,Where<Terms.termsID,Equal<required<Customer.termsID>>>>
.Select(Base,currentCustomer.TermsID);
ARInvoice aRInvoicerow = PXSelect<
ARInvoice,Where<ARInvoice.docType,Equal<required<aradjust.adjdDocType>>,And<ARInvoice.refNbr,Equal<required<aradjust.adjdRefNbr>>>>>
.Select(Base,row.AdjdDocType,row.AdjdRefNbr);
Termschecks checks = new Termschecks();
// check if current row should get discount according to the date
// bool inTerms = checks.checkIfdiscountshouldBeAplyed(row.AdjdDocDate.Value,CurrentCustomerTerms,currentARPayment.AdjDate.Value);
bool inTerms = true; // hard code true for testing
decimal? discount = 0;
decimal? discountHalfCents = 0;
decimal? OriginalInvoiceBalance = aRInvoicerow.CuryDocBal.Value;
decimal? OriginalInvoiceCuryOrigdiscAmt = aRInvoicerow.CuryOrigdiscAmt.Value;
decimal? discountWithOutHalfCents = 0;
decimal? amountToBepaidbeforeround;
//work out the discount
if (inTerms)
{
if (CurrentCustomerTerms.discPercent.Value == 0)
{
discount = 0;
}
else
{
discount = OriginalInvoiceBalance * (CurrentCustomerTerms.discPercent.Value / 100);
discountWithOutHalfCents = Math.Truncate(100 * discount.Value) / 100;
discountHalfCents = discount - discountWithOutHalfCents;
amountToBepaidbeforeround = OriginalInvoiceBalance - discount;
}
}
decimal? amountToBepaid;
amountToBepaid = OriginalInvoiceBalance - discount;
if ((amountToBepaid - discountHalfCents) > currentARPayment.CuryUnappliedBal)
{
//set discount to 0 because full amount will not be payed
discount = 0;
// if the total amount that has been payed is greater or equals the amount the client payed no more money is left to pay this invoice
if (currentARPayment.CuryOrigDocAmt.Value <= currentARPayment.CuryUnappliedBal)
{
amountToBepaid = 0;
}
else
{
amountToBepaid = OriginalInvoiceBalance - (OriginalInvoiceBalance - currentARPayment.CuryUnappliedBal.Value);
}
}
decimal? Balance = OriginalInvoiceBalance - amountToBepaid - discount;
decimal? CashdiscountBal = OriginalInvoiceCuryOrigdiscAmt - discount;
row.CuryAdjgAmt = amountToBepaid;
row.CuryAdjgPPdamt = discount;//Cash discount Taken
}
catch (System.Exception ex)
{
PXTrace.WriteError(ex);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。