fix: Account for non-discountable items in getRefundTotal (#347)
This commit is contained in:
1 parent
143f06aa39
commit
fd14e243da
3 files changed
+71
-1
No files matched your search
@@ -330,6 +330,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "line2",
|
||||
unit_price: 100,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "product2",
|
||||
@@ -349,6 +350,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "line2",
|
||||
unit_price: 100,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "product2",
|
||||
@@ -368,6 +370,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "line",
|
||||
unit_price: 100,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "product",
|
||||
@@ -386,6 +389,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "line2",
|
||||
unit_price: 100,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "testp2",
|
||||
@@ -404,6 +408,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "line2",
|
||||
unit_price: 100,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "testp2",
|
||||
@@ -422,6 +427,7 @@ describe("TotalsService", () => {
|
||||
{
|
||||
id: "notInOrder",
|
||||
unit_price: 123,
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
id: "variant",
|
||||
product_id: "pid",
|
||||
|
||||
@@ -122,7 +122,7 @@ class TotalsService extends BaseService {
|
||||
|
||||
const discount = discounts.find(({ rule }) => rule.type !== "free_shipping")
|
||||
|
||||
if (!discount) {
|
||||
if (!discount || !lineItem.allow_discounts) {
|
||||
return lineItem.unit_price * lineItem.quantity * (1 + taxRate)
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ class TotalsService extends BaseService {
|
||||
|
||||
return this.getLineItemRefund(order, i)
|
||||
})
|
||||
|
||||
return this.rounded(refunds.reduce((acc, next) => acc + next, 0))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user