Merge pull request #2919 from Safelite/feature/tax-fixes
Fix cart issue
This commit is contained in:
commit
0b26c2713d
2 changed files with 15 additions and 43 deletions
|
|
@ -309,40 +309,6 @@ describe("cart.vue", () => {
|
||||||
expect(found).toBe(true);
|
expect(found).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Service package discount Fee Cart Item
|
|
||||||
test("only if there is service package discount fee for the package, a service package discount cart item should be added to the cart", () => {
|
|
||||||
// Arrange
|
|
||||||
const lineItems = {
|
|
||||||
glassParts: [],
|
|
||||||
supportingItems: [
|
|
||||||
{
|
|
||||||
description: null,
|
|
||||||
id: "bc00294e-6baa-403e-866e-52c267187a15",
|
|
||||||
kitPrice: 0,
|
|
||||||
laborAmount: 0,
|
|
||||||
partNumber: "DISC CASHSAVE70",
|
|
||||||
partType: "SERVICE PACKAGE DISCOUNT",
|
|
||||||
salesTax: null,
|
|
||||||
sellingPrice: -70,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
vaps: [],
|
|
||||||
promos: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const availableVaps = [];
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const { wrapper } = setupMocks({
|
|
||||||
props: {
|
|
||||||
modelValue: lineItems,
|
|
||||||
availableVaps: availableVaps,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.servicePackageDiscountCartItem).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Other Supporting Items Cart Item
|
// Other Supporting Items Cart Item
|
||||||
test("if there are other supporting items on the order, an other supporting items cart item should be added to the cart but should not be displayed", () => {
|
test("if there are other supporting items on the order, an other supporting items cart item should be added to the cart but should not be displayed", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -312,10 +312,23 @@ export default {
|
||||||
this.lineItems[category] = this.lineItems[category].filter(
|
this.lineItems[category] = this.lineItems[category].filter(
|
||||||
(lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType
|
(lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType
|
||||||
);
|
);
|
||||||
|
let shouldSaveSupportingItems = category == cartItemCategories.SUPPORTING_ITEMS;
|
||||||
if (category == cartItemCategories.VAPS || category == cartItemCategories.PROMOS) {
|
if (category == cartItemCategories.VAPS || category == cartItemCategories.PROMOS) {
|
||||||
this.saveVaps(this.lineItems);
|
this.saveVaps(this.lineItems);
|
||||||
|
// Check if service package discount should be removed after vaps change
|
||||||
|
if (
|
||||||
|
this.servicePackageDiscountCartItem &&
|
||||||
|
this.discountPackageNames != this.packageLevel
|
||||||
|
) {
|
||||||
|
this.lineItems.supportingItems = this.lineItems.supportingItems.filter(
|
||||||
|
(lineItemsToKeep) =>
|
||||||
|
lineItemsToKeep.cartItemType !=
|
||||||
|
this.servicePackageDiscountCartItem.cartItemType
|
||||||
|
);
|
||||||
|
shouldSaveSupportingItems = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (category == cartItemCategories.SUPPORTING_ITEMS) {
|
if (shouldSaveSupportingItems) {
|
||||||
await this.dispatchStoreAction(
|
await this.dispatchStoreAction(
|
||||||
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||||
this.lineItems.supportingItems,
|
this.lineItems.supportingItems,
|
||||||
|
|
@ -471,14 +484,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.servicePackageDiscountCartItem) {
|
if (this.servicePackageDiscountCartItem) {
|
||||||
if (this.discountPackageNames != this.packageLevel) {
|
cartItems.push(this.servicePackageDiscountCartItem);
|
||||||
this.removeItem(
|
|
||||||
this.servicePackageDiscountCartItem.cartItemType,
|
|
||||||
cartItemCategories.SUPPORTING_ITEMS
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
cartItems.push(this.servicePackageDiscountCartItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.premiumAppointmentDiscountCartItem) {
|
if (this.premiumAppointmentDiscountCartItem) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue