CASH-152: refactoring changes

This commit is contained in:
Adam Caouette 2025-03-11 15:15:45 -04:00
parent 08f10f8ab4
commit e4fee3c8ab
6 changed files with 28 additions and 22 deletions

View file

@ -178,7 +178,7 @@ import {
getAmountDue,
getSubTotal,
getSalesTax,
} from "@/helpers/cart-and-payment-helper.js";
} from "@/helpers/pricing-helper.js";
// Constants
import { partTypeStrings } from "@/constants/part-type-strings";

View file

@ -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) {
amountDue = order.policy.currentDeductible;
}
if (lineItems?.vaps) {
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(lineItems.vaps, includeTax);
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(
lineItems.vaps,
includeTax
);
}
if (lineItems?.promos) {
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(lineItems.promos, includeTax);
amountDue += baseMixin?.methods?.getTotalPriceOfAllLineItemsAndChildParts(
lineItems.promos,
includeTax
);
}
return ((amountDue * 100) / 100).toFixed(2);

View file

@ -33,34 +33,32 @@ const lineItems = {
promos: [],
};
describe('cart-and-payment-helper', () => {
describe('getDisplayAmountDue', () => {
it('should return the correct display amount due', () => {
describe("cart-and-payment-helper", () => {
describe("getDisplayAmountDue", () => {
it("should return the correct display amount due", () => {
const result = getDisplayAmountDue(lineItems);
expect(result).toBe('53.00');
expect(result).toBe("53.00");
});
});
describe('getAmountDue', () => {
it('should return the correct amount due', () => {
describe("getAmountDue", () => {
it("should return the correct amount due", () => {
const result = getAmountDue(lineItems, true);
expect(result).toBe('53.00');
expect(result).toBe("53.00");
});
});
describe('getSubTotal', () => {
it('should return the correct subtotal', () => {
describe("getSubTotal", () => {
it("should return the correct subtotal", () => {
const result = getSubTotal(lineItems);
expect(result).toBe('50.00');
expect(result).toBe("50.00");
});
});
describe('getSalesTax', () => {
it('should return the correct sales tax', () => {
describe("getSalesTax", () => {
it("should return the correct sales tax", () => {
const result = getSalesTax(lineItems);
expect(result).toBe('3.00');
expect(result).toBe("3.00");
});
});
});

View file

@ -163,7 +163,7 @@ import {
getAmountDue,
getSubTotal,
getSalesTax,
} from "@/helpers/cart-and-payment-helper.js";
} from "@/helpers/pricing-helper.js";
defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED));
defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED));

View file

@ -20,7 +20,7 @@ import {
getAmountDue,
getSubTotal,
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
// to auto scale the iFrame this page is loaded in
// Do not remove despite showing as "unused" CASH-309

View file

@ -239,7 +239,7 @@ import {
getAmountDue,
getSubTotal,
getSalesTax,
} from "@/helpers/cart-and-payment-helper.js";
} from "@/helpers/pricing-helper.js";
export default {
name: "payment",