Does anybody know a method on the arinvoiceservice to call to make it recalculate the total of the invoice?
If I call OnChangeOfLineUnitPrice and then UpdateMasterUsingPasteInsertRowMod, which are the two calls that show up when I do this manually, the line unit price successfully updates, but the invoice total is wrong. For example, I use a function to change the unit price on the line from $0 to $2, the invoice total is still $0.
I don’t want to calculate the invoice total myself, way too much code. There has to be a way to make it realize that the total needs to be updated, right?
Or is there any easier way to accomplish this? Trying to use a UD value for the unit price on the credit memo line when the credit memo line is related to an RMA.
Erp.Tablesets.ARInvoiceTableset tsInvoice = null;
this.CallService<Erp.Contracts.ARInvoiceSvcContract>(invcSvc =>
{
tsInvoice = invcSvc.GetByID(this.InvoiceNum);
var l = tsInvoice.InvcDtl.FirstOrDefault(line => line.InvoiceLine == this.InvoiceLine);
if (l !=null) {
if (l.RMALine>0)
{
var Part = (from p in Db.Part where p.Company == l.Company && p.PartNum == l.PartNum select p).FirstOrDefault();
if (Part != null)
{
credit = Part.UserDecimal1;
}
else
{
}
if (credit>0)
{
var originalRow = tsInvoice.InvcDtl.NewRow();
BufferCopy.Copy(l, originalRow);
tsInvoice.InvcDtl.Add(originalRow);
l.RowMod = "U";
l.UnitPrice = credit;
l.DocUnitPrice = credit;
invcSvc.OnChangeofLineUnitPrice(this.InvoiceNum, l.InvoiceLine, credit, ref tsInvoice);
bool b1 = false;
var d1 = 0M;
var s1 = "";
var s2 = "";
bool b2 = false;
invcSvc.UpdateMasterUsingPasteInsertRowMod (ref tsInvoice, this.groupID, "InvcDtl", false, false, ref b1, false, this.InvoiceNum, l.InvoiceLine,
"", true, 0, false, out d1, out s1, out s2, out b2, "");
}
}
}
});