Try our conversational search powered by Generative AI!

Saving OrderGroup TaxAmount not working

Vote:
 

I'm calling the IOrderRepository method Save that takes an IOrderGroup, but the TaxTotal amount I update is not persisting to the database.

Here is a code snippet (pulled from many methods to be concise)...

var purchaseOrder = _orderRepository.Load(orderId);

var order = purchaseOrder as OrderGroup;
 if (order != null && taxResult?.TotalTaxes != null) {
    order.TaxTotal = taxResult.TotalTaxes.MoneyValue; // I see this get set to a dollar amount
 }

if (order != null) {
    var orderGroup = order as OrderGroup;

    if (orderGroup == null) {
        result = _orderRepository.Save(order);
    }
    else {
        // at this point, I still see the dollar amount set above
        result = _orderRepository.Save(orderGroup); // this is the code path that gets executed
    }
}

End result is a TaxTotal of 0.0 in OrderGroup table.  This is driving me crazy.  Any help will be appreciated.

#188361
Edited, Feb 20, 2018 22:49
Vote:
 

with the new abstraction APIs, you don't save the TaxTotal, you "calculate" it. So you can use IOrderGroupTotalsCalculator to get the tax values back (provided you implement ITaxCalculator to calculate taxes through your preferred service).

In Commerce 12, the values will be cached, so Commerce will save tax values for you internally. 

#188363
Feb 21, 2018 6:51
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.