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
name
}
total {
tax {
amount
currency
}
gross {
amount
currency
}
}
id
shippingMethod {
id

View file

@ -20,6 +20,24 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_availableSh
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 {
__typename: "Money";
amount: number;
@ -47,6 +65,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_shippingPri
export interface OrderShippingMethodUpdate_orderUpdateShipping_order {
__typename: "Order";
availableShippingMethods: (OrderShippingMethodUpdate_orderUpdateShipping_order_availableShippingMethods | null)[] | null;
total: OrderShippingMethodUpdate_orderUpdateShipping_order_total;
id: string;
shippingMethod: OrderShippingMethodUpdate_orderUpdateShipping_order_shippingMethod | null;
shippingMethodName: string | null;

View file

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