From c561b0a7f76d2a83e934f24c92eea149b17da211 Mon Sep 17 00:00:00 2001 From: Tomasz Szymanski Date: Fri, 12 Feb 2021 09:28:17 +0100 Subject: [PATCH] Fix bug with tax calculation after shipping method update --- src/orders/mutations.ts | 10 ++++++++++ src/orders/types/OrderShippingMethodUpdate.ts | 19 +++++++++++++++++++ src/orders/views/OrderDetails/index.tsx | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/orders/mutations.ts b/src/orders/mutations.ts index 6acf4c61c..45c40931d 100644 --- a/src/orders/mutations.ts +++ b/src/orders/mutations.ts @@ -426,6 +426,16 @@ const orderShippingMethodUpdateMutation = gql` id name } + total { + tax { + amount + currency + } + gross { + amount + currency + } + } id shippingMethod { id diff --git a/src/orders/types/OrderShippingMethodUpdate.ts b/src/orders/types/OrderShippingMethodUpdate.ts index 7d6687ab9..a070298bf 100644 --- a/src/orders/types/OrderShippingMethodUpdate.ts +++ b/src/orders/types/OrderShippingMethodUpdate.ts @@ -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; diff --git a/src/orders/views/OrderDetails/index.tsx b/src/orders/views/OrderDetails/index.tsx index aae9cceff..51f836bde 100644 --- a/src/orders/views/OrderDetails/index.tsx +++ b/src/orders/views/OrderDetails/index.tsx @@ -163,9 +163,10 @@ export const OrderDetails: React.FC = ({ 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}