CASH-152: refactoring changes
This commit is contained in:
parent
08f10f8ab4
commit
e4fee3c8ab
6 changed files with 28 additions and 22 deletions
|
|
@ -178,7 +178,7 @@ import {
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
getSubTotal,
|
||||||
getSalesTax,
|
getSalesTax,
|
||||||
} from "@/helpers/cart-and-payment-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,25 @@ export function getAmountDue(lineItems, includeTax = true) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const order = baseMixin?.methods?.hasSubmittedOrder() ? baseMixin?.methods?.getSubmittedOrder() : store.getters.order;
|
const order = baseMixin?.methods?.hasSubmittedOrder()
|
||||||
|
? baseMixin?.methods?.getSubmittedOrder()
|
||||||
|
: store.getters.order;
|
||||||
if (store.getters.coverageIsVerified && !order.policy.isNoComp && !order.policy.isItac) {
|
if (store.getters.coverageIsVerified && !order.policy.isNoComp && !order.policy.isItac) {
|
||||||
amountDue = order.policy.currentDeductible;
|
amountDue = order.policy.currentDeductible;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineItems?.vaps) {
|
if (lineItems?.vaps) {
|
||||||
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(lineItems.vaps, includeTax);
|
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(
|
||||||
|
lineItems.vaps,
|
||||||
|
includeTax
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineItems?.promos) {
|
if (lineItems?.promos) {
|
||||||
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(lineItems.promos, includeTax);
|
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(
|
||||||
|
lineItems.promos,
|
||||||
|
includeTax
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((amountDue * 100) / 100).toFixed(2);
|
return ((amountDue * 100) / 100).toFixed(2);
|
||||||
|
|
@ -33,34 +33,32 @@ const lineItems = {
|
||||||
promos: [],
|
promos: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('cart-and-payment-helper', () => {
|
describe("cart-and-payment-helper", () => {
|
||||||
|
describe("getDisplayAmountDue", () => {
|
||||||
describe('getDisplayAmountDue', () => {
|
it("should return the correct display amount due", () => {
|
||||||
it('should return the correct display amount due', () => {
|
|
||||||
const result = getDisplayAmountDue(lineItems);
|
const result = getDisplayAmountDue(lineItems);
|
||||||
expect(result).toBe('53.00');
|
expect(result).toBe("53.00");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getAmountDue', () => {
|
describe("getAmountDue", () => {
|
||||||
it('should return the correct amount due', () => {
|
it("should return the correct amount due", () => {
|
||||||
const result = getAmountDue(lineItems, true);
|
const result = getAmountDue(lineItems, true);
|
||||||
expect(result).toBe('53.00');
|
expect(result).toBe("53.00");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getSubTotal', () => {
|
describe("getSubTotal", () => {
|
||||||
it('should return the correct subtotal', () => {
|
it("should return the correct subtotal", () => {
|
||||||
const result = getSubTotal(lineItems);
|
const result = getSubTotal(lineItems);
|
||||||
expect(result).toBe('50.00');
|
expect(result).toBe("50.00");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getSalesTax', () => {
|
describe("getSalesTax", () => {
|
||||||
it('should return the correct sales tax', () => {
|
it("should return the correct sales tax", () => {
|
||||||
const result = getSalesTax(lineItems);
|
const result = getSalesTax(lineItems);
|
||||||
expect(result).toBe('3.00');
|
expect(result).toBe("3.00");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ import {
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
getSubTotal,
|
||||||
getSalesTax,
|
getSalesTax,
|
||||||
} from "@/helpers/cart-and-payment-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
|
|
||||||
defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED));
|
defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED));
|
defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED));
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import {
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
getSubTotal,
|
||||||
getSalesTax,
|
getSalesTax,
|
||||||
} from "@/helpers/cart-and-payment-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
// iframeResizer IS loaded into the page and necessary for the package to
|
// iframeResizer IS loaded into the page and necessary for the package to
|
||||||
// to auto scale the iFrame this page is loaded in
|
// to auto scale the iFrame this page is loaded in
|
||||||
// Do not remove despite showing as "unused" CASH-309
|
// Do not remove despite showing as "unused" CASH-309
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ import {
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
getSubTotal,
|
||||||
getSalesTax,
|
getSalesTax,
|
||||||
} from "@/helpers/cart-and-payment-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "payment",
|
name: "payment",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue