Loading...

Last updated: Apr 16 2018

Area: Episerver Commerce Applies to versions: 12 and higher

Return purchase order calculator

The ReturnPurchaseOrderCalculator calculates the total, subtotal, and shipping subtotal for a purchase order.

  • Total. Calculates the total of all return order forms in a purchase order.
    public void GetTotal(IPurchaseOrder purchaseOrder, IReturnPurchaseOrderCalculator returnPurchaseOrderCalculator)
    {
        var total = returnPurchaseOrderCalculator.GetTotal(purchaseOrder);
        Debug.WriteLine("Total for return order '{0}': {1}", purchaseOrder.OrderLink.OrderGroupId, total);
    }
  • SubTotal. Calculates the subtotal of all return order forms in a purchase order.
    public void GetSubTotal(IPurchaseOrder purchaseOrder, IReturnPurchaseOrderCalculator returnPurchaseOrderCalculator)
    {
        var subTotal = returnPurchaseOrderCalculator.GetSubTotal(purchaseOrder);
        Debug.WriteLine("Subtotal for return order '{0}': {1}", purchaseOrder.OrderLink.OrderGroupId, subTotal);
    }
  • ShippingSubTotal. Calculates the shipping subtotal of all return order forms in a purchase order.
    public void GetShippingSubTotal(IPurchaseOrder purchaseOrder, IReturnPurchaseOrderCalculator returnPurchaseOrderCalculator)
    {
        var shippingSubTotal = returnPurchaseOrderCalculator.GetShippingSubTotal(purchaseOrder);
        Debug.WriteLine("Shipping subtotal for return order '{0}': {1}", purchaseOrder.OrderLink.OrderGroupId, shippingSubTotal);
    }

Changing the default calculation

By inheriting from the default implementation of the interface, DefaultReturnPurchaseOrderCalculator, you can override the calculations. Just override one or more methods in DefaultReturnPurchaseOrderCalculator.

Changing the default validation

The default implementation validates that the totals are not negative after the calculation. To change the behavior, override the ValidateTotal, ValidateSubTotal and ValidateShippingSubTotal methods.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/