partial work
This commit is contained in:
parent
b81b79740a
commit
a881fe932a
7 changed files with 1219 additions and 20 deletions
8
src/constants/cart-item-categories.js
Normal file
8
src/constants/cart-item-categories.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const cartItemCategories = {
|
||||
VAPS: "vaps",
|
||||
GLASS_PARTS: "glassParts",
|
||||
SUPPORTING_ITEMS: "supportingItems",
|
||||
PROMOS: "promos",
|
||||
};
|
||||
|
||||
export { cartItemCategories };
|
||||
15
src/constants/cart-item-types.js
Normal file
15
src/constants/cart-item-types.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const cartItemTypes = {
|
||||
FRONT_WIPERS: "FRONT WIPERS",
|
||||
REAR_WIPERS: "REAR WIPERS",
|
||||
SUPPORTING_ITEMS: "SUPPORTING ITEMS",
|
||||
GLASS_PARTS: "GLASS PARTS",
|
||||
RAIN_DEFENSE: "RAIN DEFENSE",
|
||||
RECYCLE_FEE: "RECYCLE FEE",
|
||||
REPLACE_FEE: "REPLACE FEE",
|
||||
MOBILE_FEE: "MOBILE FEE",
|
||||
PROMOS: "PROMOS",
|
||||
EARLY_BIRD: "EARLY BIRD",
|
||||
SUPPLIES_REPAIR: "SUPPLIES-REPAIR",
|
||||
};
|
||||
|
||||
export { cartItemTypes };
|
||||
|
|
@ -3,8 +3,8 @@ import damageLocationsSelected from '@/constants/damage-locations-selected';
|
|||
import packageNames from '@/constants/package-names';
|
||||
|
||||
export function findLineItemsWithPartType(typeToFind, itemsToSearch) {
|
||||
const partTypeMatches = itemsToSearch?.filter((lineItem) => lineItem.partType.toUpperCase() === typeToFind.toUpperCase());
|
||||
return partTypeMatches;
|
||||
return itemsToSearch
|
||||
?.filter((lineItem) => lineItem.partType.toUpperCase() === typeToFind.toUpperCase());
|
||||
}
|
||||
|
||||
export function containsLineItemWithPartType(typeToFind, itemsToSearch) {
|
||||
|
|
@ -55,7 +55,6 @@ export function shouldFrontWipersBeAvailable(
|
|||
export function shouldRearWipersBeAvailable(
|
||||
glassToReplace,
|
||||
availableLineItems,
|
||||
isRepair,
|
||||
targetTier
|
||||
) {
|
||||
const rearWiperIsAvailable = containsLineItemWithPartType(
|
||||
|
|
@ -103,11 +102,13 @@ export function shouldRainDefenseBeAvailable(
|
|||
const rearWipersInTierTwo = shouldRearWipersBeAvailable(
|
||||
glassToReplace,
|
||||
availableLineItems,
|
||||
isRepair,
|
||||
packageNames.TIER_TWO
|
||||
);
|
||||
|
||||
return isTierThree && !(rearWipersInTierTwo && !frontWipersInTierTwo && frontWipersInTierThree);
|
||||
return isTierThree
|
||||
&& !(rearWipersInTierTwo
|
||||
&& !frontWipersInTierTwo
|
||||
&& frontWipersInTierThree);
|
||||
}
|
||||
|
||||
export function getPackageContents(glassToReplace, availableLineItems, isRepair, targetTier) {
|
||||
|
|
@ -117,7 +118,7 @@ export function getPackageContents(glassToReplace, availableLineItems, isRepair,
|
|||
vaps.push(partTypeStrings.FRONT_WIPER);
|
||||
}
|
||||
|
||||
if (shouldRearWipersBeAvailable(glassToReplace, availableLineItems, isRepair, targetTier)) {
|
||||
if (shouldRearWipersBeAvailable(glassToReplace, availableLineItems, targetTier)) {
|
||||
vaps.push(partTypeStrings.REAR_WIPER);
|
||||
}
|
||||
|
||||
|
|
|
|||
1007
src/helpers/service-package-helper.spec.js
Normal file
1007
src/helpers/service-package-helper.spec.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -18,7 +18,7 @@
|
|||
class="cart-table">
|
||||
<div
|
||||
id="cart-deductible-or-base-price"
|
||||
class="mt-4 cart-line-item color-gray-100 px-5 py-1">
|
||||
class="mt-4 cart-line-item color-gray-100">
|
||||
<div
|
||||
v-if="showDeductibleLineItem"
|
||||
id="cart-deductible"
|
||||
|
|
@ -39,12 +39,28 @@
|
|||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="cart-service"
|
||||
class="d-flex justify-content-between align-items-center">
|
||||
<span
|
||||
id="service-label"
|
||||
class="label">{{ serviceLabel }}</span>
|
||||
<span id="service-value">{{ formatAmountInDollars(serviceValue) }}</span>
|
||||
id="cart-service-package"
|
||||
class="cart-line-item">
|
||||
<div
|
||||
id="service-package-name"
|
||||
class="d-flex justify-content-between align-items-center">
|
||||
<span
|
||||
id="service-package-label"
|
||||
class="label">{{ servicePackageLabel }}</span>
|
||||
<span id="service-package-price">{{ formatAmountInDollars(packagePrice) }}</span>
|
||||
<span
|
||||
v-if="servicePackageRemovable && !readOnly"
|
||||
id="service-package-remove">Remove</span>
|
||||
</div>
|
||||
<!-- TODO make inclusion of service items a for loop -->
|
||||
<div
|
||||
id="service-item"
|
||||
class="py-1 ps-4 d-flex justify-content-between align-items-center">
|
||||
<span id="service">Wiper blades</span>
|
||||
<span
|
||||
v-if="!readOnly"
|
||||
id="remove-service-link">Remove</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -54,6 +70,12 @@
|
|||
import { useMainStore } from '@/store';
|
||||
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||
import { getHighestFullySatisfiedTier, getAvailablePackages } from '@/helpers/service-package-helper.js';
|
||||
|
||||
// Constants
|
||||
import partTypeStrings from '@/constants/part-type-strings.js';
|
||||
import cartItemCategories from '@/constants/cart-item-categories.js';
|
||||
import cartItemTypes from '@/constants/cart-item-types.js';
|
||||
|
||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||
|
||||
|
|
@ -65,20 +87,23 @@ export default {
|
|||
amountDueLabel: String,
|
||||
deductibleLabel: String,
|
||||
basePriceLabel: String,
|
||||
serviceLabel: String
|
||||
servicePackageLabel: String,
|
||||
readOnly: Boolean
|
||||
// TODO add allowRemoveItems
|
||||
},
|
||||
data() {
|
||||
const { currentDeductible } = useMainStore().order;
|
||||
const { supportingItems, glassParts, otherParts } = useMainStore().lineItems;
|
||||
const { supportingItems, glassParts, otherParts, vaps } = useMainStore().lineItems;
|
||||
const baseServiceLineItems = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
...(otherParts ?? [])
|
||||
];
|
||||
return {
|
||||
vaps: vaps ?? [],
|
||||
deductible: currentDeductible,
|
||||
baseServiceLineItems,
|
||||
isExpanded: false
|
||||
isExpanded: true// false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -102,11 +127,141 @@ export default {
|
|||
amountDue() {
|
||||
return this.showAsPaid
|
||||
? 0
|
||||
: this.subTotal + this.salesTax;
|
||||
: this.subTotal + this.packagePrice + this.salesTax;
|
||||
},
|
||||
|
||||
// frontWiperCartItemName() {
|
||||
// return this.getCmsContentForVapsType(partTypeStrings.FRONT_WIPER);
|
||||
// },
|
||||
// frontWipersCartItem() {
|
||||
// let cartItem = null;
|
||||
|
||||
// const frontWiperLineItems = this.vaps.filter((vapsLineItem) => vapsLineItem.partType == partTypeStrings.FRONT_WIPER);
|
||||
|
||||
// if (frontWiperLineItems.length > 0) {
|
||||
// cartItem = {
|
||||
// name: this.frontWiperCartItemName,
|
||||
// category: cartItemCategories.VAPS,
|
||||
// cartItemType: cartItemTypes.FRONT_WIPERS,
|
||||
// isDisplayed: true,
|
||||
// isRemovable: true,
|
||||
// subTotal: 0,
|
||||
// salesTax: 0,
|
||||
// lineItems: []
|
||||
// };
|
||||
|
||||
// frontWiperLineItems.forEach((lineItem) => {
|
||||
// lineItem.cartItemType = cartItem.cartItemType;
|
||||
// cartItem.lineItems.push(lineItem);
|
||||
|
||||
// cartItem.subTotal
|
||||
// += (lineItem.kitPrice ?? 0)
|
||||
// + (lineItem.laborAmount ?? 0)
|
||||
// + (lineItem.sellingPrice ?? 0);
|
||||
|
||||
// cartItem.salesTax += lineItem.salesTax ?? 0;
|
||||
// });
|
||||
// }
|
||||
|
||||
// return cartItem;
|
||||
// },
|
||||
// rearWiperCartItemName() {
|
||||
// return this.getCmsContentForVapsType(partTypeStrings.REAR_WIPER);
|
||||
// },
|
||||
// rearWipersCartItem() {
|
||||
// let cartItem = null;
|
||||
|
||||
// const rearWiperLineItems = this.vaps.filter((vapsLineItem) => vapsLineItem.partType == partTypeStrings.REAR_WIPER);
|
||||
|
||||
// if (rearWiperLineItems.length > 0) {
|
||||
// cartItem = {
|
||||
// name: this.rearWiperCartItemName,
|
||||
// category: cartItemCategories.VAPS,
|
||||
// cartItemType: cartItemTypes.REAR_WIPERS,
|
||||
// isDisplayed: true,
|
||||
// isRemovable: true,
|
||||
// subTotal: 0,
|
||||
// salesTax: 0,
|
||||
// lineItems: []
|
||||
// };
|
||||
|
||||
// rearWiperLineItems.forEach((lineItem) => {
|
||||
// lineItem.cartItemType = cartItem.cartItemType;
|
||||
// cartItem.lineItems.push(lineItem);
|
||||
|
||||
// cartItem.subTotal
|
||||
// += (lineItem.kitPrice ?? 0)
|
||||
// + (lineItem.laborAmount ?? 0)
|
||||
// + (lineItem.sellingPrice ?? 0);
|
||||
|
||||
// cartItem.salesTax += lineItem.salesTax ?? 0;
|
||||
// });
|
||||
// }
|
||||
|
||||
// return cartItem;
|
||||
// },
|
||||
rainDefenseCartItemName() {
|
||||
return this.getCmsContentForVapsType(partTypeStrings.RAIN_DEFENSE);
|
||||
},
|
||||
rainDefenseCartItem() {
|
||||
let cartItem = null;
|
||||
|
||||
const rainDefenseLineItem = this.vaps.find((vapsLineItem) => vapsLineItem.partType === partTypeStrings.RAIN_DEFENSE);
|
||||
rainDefenseLineItem.cartItemType = cartItemTypes.RAIN_DEFENSE;
|
||||
if (rainDefenseLineItem) {
|
||||
cartItem = {
|
||||
name: this.rainDefenseCartItemName,
|
||||
category: cartItemCategories.VAPS,
|
||||
cartItemType: cartItemTypes.RAIN_DEFENSE,
|
||||
isDisplayed: true,
|
||||
isRemovable: true,
|
||||
subTotal: getPriceOfLineItems([rainDefenseLineItem]),
|
||||
salesTax: rainDefenseLineItem.salesTax ?? 0,
|
||||
lineItems: [rainDefenseLineItem]
|
||||
};
|
||||
}
|
||||
return cartItem;
|
||||
},
|
||||
|
||||
servicePackageLabelCalc() {
|
||||
// If just rain, "Rain"
|
||||
return '';
|
||||
},
|
||||
packageLevel() {
|
||||
const tier = getHighestFullySatisfiedTier(
|
||||
this.glassToReplace,
|
||||
this.baseServiceLineItems,
|
||||
this.isRepair,
|
||||
this.vaps
|
||||
);
|
||||
|
||||
return tier;
|
||||
},
|
||||
packagePrice() {
|
||||
return getPriceOfLineItems(this.packageLineItems);
|
||||
},
|
||||
// TODO
|
||||
serviceValue() {
|
||||
return 25;
|
||||
packageLineItems() {
|
||||
return this.vaps;
|
||||
},
|
||||
// TODO finish
|
||||
servicePackageRemovable() {
|
||||
// If valid package level then false
|
||||
// otherwise true
|
||||
return false;
|
||||
},
|
||||
// TODO finish
|
||||
isValidPackageLevel() {
|
||||
const availablePackages = getAvailablePackages(
|
||||
// TODO what is glass to replace
|
||||
this.glassToReplace,
|
||||
// TODO what are available line items
|
||||
this.availableLineItems,
|
||||
this.isRepair
|
||||
);
|
||||
availablePackages.find((servicePackage) => servicePackage.forEach() == this.vaps);
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -135,6 +290,7 @@ export default {
|
|||
}
|
||||
|
||||
.cart-line-item {
|
||||
padding: 0.25rem 1.5rem;
|
||||
color: $darker-gray;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@
|
|||
:amountDueLabel="amountDueText"
|
||||
:deductibleLabel="deductibleLabel"
|
||||
:basePriceLabel="basePriceLabel"
|
||||
:serviceLabel="serviceLabel" />
|
||||
:servicePackageLabel="serviceLabel"
|
||||
:readOnly="false" />
|
||||
<hr class="mt-0 mb-5" />
|
||||
<div>Pia Alert Placeholder</div>
|
||||
<paymentMethodQuestion
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import queryStrings from '@/constants/query-strings';
|
|||
import dynamicStrings from '@/constants/dynamic-strings';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import widgetFields from '@/constants/cms-widget-fields.js';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -36,6 +37,16 @@ export default {
|
|||
savePageDataToStore(page, data) {
|
||||
useMainStore().updatePageData({ page, data });
|
||||
},
|
||||
// TODO confirm this is not what we want
|
||||
// getTierOnePackagePrice(lineItems) {
|
||||
// const lineItemsToPrice = lineItems.filter((lineItem) => (
|
||||
// lineItem.partType !== partTypeStrings.FRONT_WIPER
|
||||
// && lineItem.partType !== partTypeStrings.REAR_WIPER
|
||||
// && lineItem.partType !== partTypeStrings.RAIN_DEFENSE
|
||||
// ));
|
||||
|
||||
// return this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice, false);
|
||||
// },
|
||||
getTotalPriceOfAllLineItemsAndChildParts(lineItems, includeTax) {
|
||||
let totalPrice = 0;
|
||||
lineItems.forEach((lineItem) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue