Using real line items

This commit is contained in:
Michaela Brydon 2024-03-08 11:48:14 -05:00
parent 55cf1ae9f6
commit 41a1d8b74c
3 changed files with 20 additions and 48 deletions

View file

@ -34,7 +34,7 @@
class="d-flex justify-content-between align-items-center">
<span
id="base-price-label"
class="label">{{ BasePriceLabel }}</span>
class="label">{{ basePriceLabel }}</span>
<span id="base-price-value">{{ getDisplayed(baseServicePrice) }}</span>
</div>
</div>
@ -44,6 +44,7 @@
<script>
import { useMainStore } from '@/store';
import getPriceOfLineItems from '@/helpers/price-calculator.js';
const VERIFYING_COVERAGE = 'Verifying coverage';
@ -58,7 +59,9 @@ export default {
baseServiceLineItems: Array
},
data() {
const { currentDeductible } = useMainStore().order;
return {
deductible: currentDeductible,
isExpanded: false,
currencyFormatter: new Intl.NumberFormat('en-US', {
style: 'currency',
@ -67,16 +70,8 @@ export default {
};
},
computed: {
deductible() {
return useMainStore().order.currentDeductible;
},
// TODO share with claim registration page
baseServicePrice() {
return this.baseServiceLineItems
.reduce(
(accumulator, lineItem) => accumulator + this.getTotalLineItemPrice(lineItem),
0
);
return getPriceOfLineItems(this.baseServiceLineItems);
},
showDeductibleLineItem() {
return !useMainStore().isNoComp && !useMainStore().policy.isITAC;
@ -96,10 +91,6 @@ export default {
return this.showAsPaid
? 0
: this.subTotal + this.salesTax;
},
clonedGlassParts() {
const valueToClone = useMainStore().order.lineItems.glassParts ?? [];
return JSON.parse(JSON.stringify(valueToClone)) ?? [];
}
},
methods: {
@ -109,36 +100,10 @@ export default {
getFormattedAmount(amount) {
return this.currencyFormatter.format(amount);
},
// TODO share with claim registration page
getTotalLineItemPrice(lineItem) {
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
},
getDisplayed(amount) {
return this.isUnverified && this.showDeductibleLineItem
? VERIFYING_COVERAGE
: this.getFormattedAmount(amount);
},
async temporaryMethod() {
// TODO need supporting items
// TODO need pricing results from getPriceOrderItems
// get base service line items
const supportingItems = await useMainStore().getSupportingItems();
supportingItems.then((data) => {
// TODO do something
});
const availableLineItems = [
...(supportingItems ?? []),
...(this.clonedGlassParts)
];
let pricingResults = [];
if (useMainStore().policy.policyLookupSuccessful && useMainStore().vehicle.policyVehicleId >= 0) {
// await useMainStore().getFinalDeductible();
// I don't think we need to perform the getFinalDeductible call
// policy data is set in policy.policyData
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
}
return [];
}
}
};

View file

@ -105,16 +105,23 @@ export default {
});
},
data() {
const { supportingItems, glassParts, otherParts } = useMainStore().lineItems;
const baseServiceLineItems = [
...(supportingItems ?? []),
...(glassParts ?? []),
...(otherParts ?? [])
];
return {
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
// TODO set line items
baseServiceLineItems: [
{
kitPrice: 1,
laborAmount: 2,
sellingPrice: 3
}
],
// baseServiceLineItems: [
// {
// kitPrice: 1,
// laborAmount: 2,
// sellingPrice: 3
// }
// ],
baseServiceLineItems,
rules: {
optionRequired: globalRules.OPTION_REQUIRED
},

View file

@ -259,7 +259,7 @@ export const useMainStore = defineStore({
isClaimAlreadyRegistered: (state) => state.order.payment.insuranceCoverage.claimNumber !== null,
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
isNoComp: (state) => state.order.policy.coverageStatus === coverageStatuses.NO_COMP,
isVerifiedCoverageStatus: (state) => state.order.policy.coverageStatus === coverageStatuses.VERIFIED,
isVerifiedCoverageStatus: (state) => state.order.payment.insuranceCoverage.coverageStatus === coverageStatuses.VERIFIED,
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);
return matchedEvent?.eventValue;