From 61da5f365061c3d82d402e250d61ac8991b590a2 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Thu, 3 Nov 2022 16:22:49 +0100 Subject: [PATCH] fix(medusa-plugin-brightpearl): account for shipping prices being tax inclusive (#2536) **What** BP plugin was recording total shipping price based on the shipping_method.price; however, this value may be with or without taxes depending on the tax inclusivity setting. This change ensures that the shipping price is calculated correctly. --- .changeset/chilled-ads-flash.md | 5 +++++ .../src/services/__tests__/brightpearl.js | 4 ++++ .../medusa-plugin-brightpearl/src/services/brightpearl.js | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilled-ads-flash.md diff --git a/.changeset/chilled-ads-flash.md b/.changeset/chilled-ads-flash.md new file mode 100644 index 0000000000..bc34580810 --- /dev/null +++ b/.changeset/chilled-ads-flash.md @@ -0,0 +1,5 @@ +--- +"medusa-plugin-brightpearl": patch +--- + +fix(medusa-plugin-brightpearl): account for shipping prices being tax inclusive diff --git a/packages/medusa-plugin-brightpearl/src/services/__tests__/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/__tests__/brightpearl.js index 41aec8fae2..273ca2a0ae 100644 --- a/packages/medusa-plugin-brightpearl/src/services/__tests__/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/__tests__/brightpearl.js @@ -25,6 +25,7 @@ const order = { { name: "standard", price: 12399, + subtotal: 12399, }, ], payment_method: { @@ -66,6 +67,7 @@ const krwOrder = { { name: "standard", price: 12399, + subtotal: 12399, }, ], payment_method: { @@ -109,6 +111,7 @@ const roundingOrder = { { name: "standard", price: 0, + subtotal: 0, }, ], discounts: [ @@ -159,6 +162,7 @@ const TotalsService = { getShippingMethodTotals: () => { return { price: 0, + subtotal: 0, discount_total: 0, tax_total: 0, } diff --git a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js index d62946d23f..0c89c7f38f 100644 --- a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js @@ -994,7 +994,7 @@ class BrightpearlService extends BaseService { } ) return { - price: accum.price + totals.price, + price: accum.price + totals.subtotal, tax: accum.tax + totals.tax_total, } }, Promise.resolve({ price: 0, tax: 0 }))