Fix bug with tax calculation after shipping method update

This commit is contained in:
Tomasz Szymanski 2021-02-12 09:28:17 +01:00
parent 4160fb685c
commit c561b0a7f7
3 changed files with 33 additions and 3 deletions

View file

@ -426,6 +426,16 @@ const orderShippingMethodUpdateMutation = gql`
id id
name name
} }
total {
tax {
amount
currency
}
gross {
amount
currency
}
}
id id
shippingMethod { shippingMethod {
id id

View file

@ -20,6 +20,24 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_availableSh
name: string; name: string;
} }
export interface OrderShippingMethodUpdate_orderUpdateShipping_order_total_tax {
__typename: "Money";
amount: number;
currency: string;
}
export interface OrderShippingMethodUpdate_orderUpdateShipping_order_total_gross {
__typename: "Money";
amount: number;
currency: string;
}
export interface OrderShippingMethodUpdate_orderUpdateShipping_order_total {
__typename: "TaxedMoney";
tax: OrderShippingMethodUpdate_orderUpdateShipping_order_total_tax;
gross: OrderShippingMethodUpdate_orderUpdateShipping_order_total_gross;
}
export interface OrderShippingMethodUpdate_orderUpdateShipping_order_shippingMethod_price { export interface OrderShippingMethodUpdate_orderUpdateShipping_order_shippingMethod_price {
__typename: "Money"; __typename: "Money";
amount: number; amount: number;
@ -47,6 +65,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_shippingPri
export interface OrderShippingMethodUpdate_orderUpdateShipping_order { export interface OrderShippingMethodUpdate_orderUpdateShipping_order {
__typename: "Order"; __typename: "Order";
availableShippingMethods: (OrderShippingMethodUpdate_orderUpdateShipping_order_availableShippingMethods | null)[] | null; availableShippingMethods: (OrderShippingMethodUpdate_orderUpdateShipping_order_availableShippingMethods | null)[] | null;
total: OrderShippingMethodUpdate_orderUpdateShipping_order_total;
id: string; id: string;
shippingMethod: OrderShippingMethodUpdate_orderUpdateShipping_order_shippingMethod | null; shippingMethod: OrderShippingMethodUpdate_orderUpdateShipping_order_shippingMethod | null;
shippingMethodName: string | null; shippingMethodName: string | null;

View file

@ -163,9 +163,10 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
onPaymentCapture={orderMessages.handlePaymentCapture} onPaymentCapture={orderMessages.handlePaymentCapture}
onUpdate={orderMessages.handleUpdate} onUpdate={orderMessages.handleUpdate}
onDraftUpdate={orderMessages.handleDraftUpdate} onDraftUpdate={orderMessages.handleDraftUpdate}
onShippingMethodUpdate={ onShippingMethodUpdate={data => {
orderMessages.handleShippingMethodUpdate orderMessages.handleShippingMethodUpdate(data);
} order.total = data.orderUpdateShipping.order.total;
}}
onOrderLineDelete={orderMessages.handleOrderLineDelete} onOrderLineDelete={orderMessages.handleOrderLineDelete}
onOrderLinesAdd={orderMessages.handleOrderLinesAdd} onOrderLinesAdd={orderMessages.handleOrderLinesAdd}
onOrderLineUpdate={orderMessages.handleOrderLineUpdate} onOrderLineUpdate={orderMessages.handleOrderLineUpdate}