acumatica - Tax calculation is wrong when updating UnitPrice while creating the Invoice from Shipment, TaxAttribute.Calculate uses the old extprice -
in our add-on, modifying unitprice when creating invoice shipment based on our own calculation regex expression. seems fine fields, except taxes take soorder taxes.
we created pxgraphextension , used following:
public void invoiceorder(datetime invoicedate, pxresult<soordershipment, soorder, currencyinfo, soaddress, socontact, soordertype> order, pxresultset<soshipline, soline> details, customer customer, documentlist<arinvoice, soinvoice> list, action<datetime, pxresult<soordershipment, soorder, currencyinfo, soaddress, socontact, soordertype>, pxresultset<soshipline, soline>, customer, documentlist<arinvoice, soinvoice>> method) { using (var scope = new pxtransactionscope()) { method(invoicedate, order, details, customer, list); lookupbalesfromorderandshipment(); scope.complete(); } }
in lookupbalesfromorderandshipment(); modify unitprice based on our calculation, , call base.transactions.update(updatedline); our new value , base.persist();
all data seems fine except tax details tab, still uses old curylineamt instead of new curylineamt of newly created invoice.
i have tried forcing tax recalculation in rowupdated event doesn't seem doing anything.
protected virtual void artran_rowupdated(pxcache cache, pxrowupdatedeventargs e, pxrowupdated invokebasehandler) { if (invokebasehandler != null) invokebasehandler(cache, e); taxattribute.calculate<artran.taxcategoryid>(cache, e); }
declaring var row = (artran)e.row; , inspecting variable tells me right new curylineamt, taxes still seem calculated on came in soorder.
is there other way force tax calculation or update artax , artaxtran table without risks?
the base function invoiceorder changes tax calculation methods fit initial salesinvoice creation:
taxattribute.settaxcalc<artran.taxcategoryid>(this.transactions.cache, null, taxcalc.manualcalc);
every other time access page, tax calculation method used 1 set in soinvoiceentry's constructor:
taxattribute.settaxcalc<artran.taxcategoryid>(transactions.cache, null, taxcalc.manuallinecalc);
your solution set appropriate tax calculation method after calling base delegate:
public delegate void invoiceorderdelegate(datetime invoicedate, pxresult<soordershipment,soorder,currencyinfo,soaddress,socontact,soordertype> order, pxresultset<soshipline,soline> details, customer customer, documentlist<arinvoice,soinvoice> list); [pxoverride] public void invoiceorder(datetime invoicedate, pxresult<soordershipment,soorder,currencyinfo,soaddress,socontact,soordertype> order, pxresultset<soshipline,soline> details, customer customer, documentlist<arinvoice,soinvoice> list, invoiceorderdelegate basemethod) { basemethod(invoicedate,order,details,customer,list); taxattribute.settaxcalc<artran.taxcategoryid>(base.transactions.cache, null, taxcalc.manuallinecalc); var tran = base.transactions.current; tran.curyunitprice = tran.curyunitprice + 10m; base.transactions.update(tran); base.actions.presssave(); }
Comments
Post a Comment