Using real line items
This commit is contained in:
parent
55cf1ae9f6
commit
41a1d8b74c
3 changed files with 20 additions and 48 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
class="d-flex justify-content-between align-items-center">
|
class="d-flex justify-content-between align-items-center">
|
||||||
<span
|
<span
|
||||||
id="base-price-label"
|
id="base-price-label"
|
||||||
class="label">{{ BasePriceLabel }}</span>
|
class="label">{{ basePriceLabel }}</span>
|
||||||
<span id="base-price-value">{{ getDisplayed(baseServicePrice) }}</span>
|
<span id="base-price-value">{{ getDisplayed(baseServicePrice) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||||
|
|
||||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||||
|
|
||||||
|
|
@ -58,7 +59,9 @@ export default {
|
||||||
baseServiceLineItems: Array
|
baseServiceLineItems: Array
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const { currentDeductible } = useMainStore().order;
|
||||||
return {
|
return {
|
||||||
|
deductible: currentDeductible,
|
||||||
isExpanded: false,
|
isExpanded: false,
|
||||||
currencyFormatter: new Intl.NumberFormat('en-US', {
|
currencyFormatter: new Intl.NumberFormat('en-US', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
|
|
@ -67,16 +70,8 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
deductible() {
|
|
||||||
return useMainStore().order.currentDeductible;
|
|
||||||
},
|
|
||||||
// TODO share with claim registration page
|
|
||||||
baseServicePrice() {
|
baseServicePrice() {
|
||||||
return this.baseServiceLineItems
|
return getPriceOfLineItems(this.baseServiceLineItems);
|
||||||
.reduce(
|
|
||||||
(accumulator, lineItem) => accumulator + this.getTotalLineItemPrice(lineItem),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
showDeductibleLineItem() {
|
showDeductibleLineItem() {
|
||||||
return !useMainStore().isNoComp && !useMainStore().policy.isITAC;
|
return !useMainStore().isNoComp && !useMainStore().policy.isITAC;
|
||||||
|
|
@ -96,10 +91,6 @@ export default {
|
||||||
return this.showAsPaid
|
return this.showAsPaid
|
||||||
? 0
|
? 0
|
||||||
: this.subTotal + this.salesTax;
|
: this.subTotal + this.salesTax;
|
||||||
},
|
|
||||||
clonedGlassParts() {
|
|
||||||
const valueToClone = useMainStore().order.lineItems.glassParts ?? [];
|
|
||||||
return JSON.parse(JSON.stringify(valueToClone)) ?? [];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -109,36 +100,10 @@ export default {
|
||||||
getFormattedAmount(amount) {
|
getFormattedAmount(amount) {
|
||||||
return this.currencyFormatter.format(amount);
|
return this.currencyFormatter.format(amount);
|
||||||
},
|
},
|
||||||
// TODO share with claim registration page
|
|
||||||
getTotalLineItemPrice(lineItem) {
|
|
||||||
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
|
|
||||||
},
|
|
||||||
getDisplayed(amount) {
|
getDisplayed(amount) {
|
||||||
return this.isUnverified && this.showDeductibleLineItem
|
return this.isUnverified && this.showDeductibleLineItem
|
||||||
? VERIFYING_COVERAGE
|
? VERIFYING_COVERAGE
|
||||||
: this.getFormattedAmount(amount);
|
: 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 [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -105,16 +105,23 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const { supportingItems, glassParts, otherParts } = useMainStore().lineItems;
|
||||||
|
const baseServiceLineItems = [
|
||||||
|
...(supportingItems ?? []),
|
||||||
|
...(glassParts ?? []),
|
||||||
|
...(otherParts ?? [])
|
||||||
|
];
|
||||||
return {
|
return {
|
||||||
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
||||||
// TODO set line items
|
// TODO set line items
|
||||||
baseServiceLineItems: [
|
// baseServiceLineItems: [
|
||||||
{
|
// {
|
||||||
kitPrice: 1,
|
// kitPrice: 1,
|
||||||
laborAmount: 2,
|
// laborAmount: 2,
|
||||||
sellingPrice: 3
|
// sellingPrice: 3
|
||||||
}
|
// }
|
||||||
],
|
// ],
|
||||||
|
baseServiceLineItems,
|
||||||
rules: {
|
rules: {
|
||||||
optionRequired: globalRules.OPTION_REQUIRED
|
optionRequired: globalRules.OPTION_REQUIRED
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ export const useMainStore = defineStore({
|
||||||
isClaimAlreadyRegistered: (state) => state.order.payment.insuranceCoverage.claimNumber !== null,
|
isClaimAlreadyRegistered: (state) => state.order.payment.insuranceCoverage.claimNumber !== null,
|
||||||
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
|
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
|
||||||
isNoComp: (state) => state.order.policy.coverageStatus === coverageStatuses.NO_COMP,
|
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) => {
|
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
|
||||||
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);
|
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);
|
||||||
return matchedEvent?.eventValue;
|
return matchedEvent?.eventValue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue