Checks and payments entry record creating Programmatically using .csv File
Payment Type Pmt Number CashAcct Pmt Date VendID ApplyToVendorRef ApplyToAmt TotalAmt
CHECK 10184000001 ORE-OP 11/16/2021 PIOT INV2809 2185.02 2185.02
the above fields i have in csv file.. using Vendor reference number am fetching data from Bills Screen and then am trying to create checks and payments record against to that bill- am able to create header part when coming to insert in APAdjust table am facing an issue above error throwing
Error: An error occurred during processing of the field Reference Nbr. value 032616 Error: Reference Nbr. '032616' cannot be found in the system.
am also sending the code which i have written for APAdjust .. Please suggest me with the Solution
APPayment payment = new APPayment();
payment.DocType = APDocType.Check;
payment = PXCache<APPayment>.CreateCopy(grp.Document.Insert(payment));
payment.VendorID = inv.VendorID;
payment.VendorLocationID = inv.PayLocationID;
payment.AdjDate = row.PmtDate;
payment.CuryID = inv.CuryID;
payment.PaymentMethodID = inv.PayTypeID;
payment.DocDesc = inv.DocDesc;
this.FieldDefaulting.AddHandler<APPayment.cashAccountID>((sender, e) =>
{
if (inv.DocType == APDocType.Prepayment)
{
e.NewValue = null;
e.Cancel = true;
}
});
this.FieldDefaulting.AddHandler<CurrencyInfo.curyID>((sender, e) =>
{
if (e.Row != null)
{
e.NewValue = ((CurrencyInfo)e.Row).CuryID;
e.Cancel = true;
}
});
payment = grp.Document.Update(payment);
decimal? controlamt = 0;
grp.Document.Current = payment;
foreach (TSAWSPayment lin in PXSelect<TSAWSPayment, Where<TSAWSPayment.printNbr, Equal<Required<TSAWSPayment.printNbr>>,
And<TSAWSPayment.vendorID, Equal<Required<TSAWSPayment.vendorID>>>>>.Select(this, row.PrintNbr, row.VendorID))
{
TSAWSPayment payrow = lin;
InsertAPAdjustments(payrow, grp, payment,inv);
//grp.Adjustments.Current = grp.Adjustments.Search<APAdjust.adjdDocType, APAdjust.adjdRefNbr>(inv.DocType, inv.RefNbr);
APAdjust adj = new APAdjust();
adj = PXCache<APAdjust>.CreateCopy(grp.Adjustments.Insert(adj));
adj.AdjdDocType = inv.DocType;
adj.AdjdRefNbr = inv.RefNbr;
grp.Adjustments.Cache.RaiseFieldUpdated<APAdjust.adjdRefNbr>(adj, null);
adj=grp.Adjustments.Insert(adj);
controlamt = controlamt + payrow.ApplytoAmt;
}
Version-21.106.0024