问题
We have a custom checkbox on the SOOrderEntry screen which we'd like to use to change the tax jurisdiction on the sales order after somebody has entered line items. The reason for this is that if the customer is out of state but will be picking up the order at the store in person, they will need to pay the local taxes at the store location and not their state taxes. If the order was shipped, the taxes would be those for the customer's location.
The issue we're having is that when we set the Tax Zone ID before line items are entered, it works correctly and the right taxes are created. If the user changes the checkbox value, the taxes will still be the ones from the original tax zone and not the one currently reflected on the screen.
We found a few methods on the SOOrderEntry graph that appear to be for recalculating taxes but their for Avalara and thow an exception if called because we're not using Avalara in this system, only Acumatica's internal tax engine.
Is there a way to have Acumatica recalculate the taxes when the tax zone changes on the order?
Any help would be very appreciated, we haven't made much headway with help documentation or trial and error.
There's not much code to it, but here's the few lines that we have:
// Customer Pickup, update sales tax on the order
Location branchLoc = PXSelectJoin<Location,
InnerJoin<Branch, On<Location.bAccountID, Equal<Branch.bAccountID>>>,
Where<Branch.branchID, Equal<Required<SOOrder.branchID>>>>
.Select(Base, order.BranchID);
cache.SetValue<SOOrder.overrideTaxZone>(order, true);
cache.SetValue<SOOrder.taxZoneID>(order, branchLoc.VTaxZoneID);
回答1:
TaxAttrbibute adds ZoneUpdated event handler to the TaxZoneID_FieldUpdated event of the Sales Order. To trigger this event, you should use
cache.SetValueExt<SOOrder.taxZoneID>(order, branchLoc.VTaxZoneID);
The SetValueExt method raises events when setting field value unlike SetValue method.
来源:https://stackoverflow.com/questions/51844292/programmatically-recalculate-taxes-with-acumatica