Merge pull request #779 from Safelite/feature/richardson/SSR-1207.3
Override tender amount for deductible case
This commit is contained in:
commit
9da1c3e553
4 changed files with 62 additions and 16 deletions
|
|
@ -13,6 +13,7 @@ import { useMainStore } from '@/store/index.js';
|
|||
import queryStrings from '@/constants/query-strings';
|
||||
import getQueryStringParameter from '@/helpers/querystring-helper.js';
|
||||
import { paymentMethods } from '@/constants/payment-method-constants.js';
|
||||
import { getCartTotal } from '@/helpers/cart-helper';
|
||||
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||
import submitType from '@/constants/submit-type';
|
||||
|
|
@ -105,7 +106,8 @@ export default {
|
|||
async processPaypalResponse() {
|
||||
const token = getQueryStringParameter(queryStrings.TOKEN);
|
||||
this.mainStore.updatePaypalToken(token);
|
||||
|
||||
const cartTotal = getCartTotal(useMainStore().order);
|
||||
useMainStore().order.payment.nextGenSettledAmount = cartTotal;
|
||||
await this.saveAndSubmitWorkOrder();
|
||||
},
|
||||
async processCreditCardResponse() {
|
||||
|
|
@ -115,6 +117,8 @@ export default {
|
|||
this.navigateOnPayInAdvanceError();
|
||||
} else {
|
||||
useMainStore().updateCreditCardToken(this.creditCardToken);
|
||||
const cartTotal = getCartTotal(useMainStore().order);
|
||||
useMainStore().order.payment.nextGenSettledAmount = cartTotal;
|
||||
await this.saveAndSubmitWorkOrder();
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<loadingModal
|
||||
ref="loadingModal"
|
||||
:textSlides="loadingText" />
|
||||
ref="loadingModal"
|
||||
:textSlides="loadingText" />
|
||||
<contentGroupModal
|
||||
ref="RainDefenseModal"
|
||||
cmsWidgetName="RainDefenseModal" />
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ export const getDefaultState = () => ({
|
|||
payment: {
|
||||
parentAccountNumber: 0,
|
||||
isPayInAdvance: null,
|
||||
nextGenSettledAmount: 0,
|
||||
payInAdvanceType: null,
|
||||
paypalToken: null,
|
||||
creditCardToken: {
|
||||
|
|
@ -1283,8 +1284,11 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
|
||||
const loadedFromDupeCheck = !!(this.order.loadedFromDupeCheck && !this.order.loadedSessionClearedPreviousData);
|
||||
|
||||
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace);
|
||||
const shouldClearOnSubmit = this.isVerified && this.isDeductible;
|
||||
const payloadGlassParts = setClearOnSubmit(lineItems.glassParts, shouldClearOnSubmit);
|
||||
const payloadSupportingItems = setClearOnSubmit(lineItems.supportingItems, shouldClearOnSubmit);
|
||||
const payloadVapsItems = setClearOnSubmit(lineItems.vaps, shouldClearOnSubmit);
|
||||
|
||||
const payload = {
|
||||
applicationUser: {
|
||||
|
|
@ -1349,10 +1353,10 @@ export const useMainStore = defineStore({
|
|||
isSmsOptIn: contactInfo.requestTextUpdates ?? false
|
||||
},
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
glassParts: payloadGlassParts,
|
||||
serverData: lineItems.serverData,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
supportingItems: payloadSupportingItems,
|
||||
vaps: payloadVapsItems
|
||||
},
|
||||
insuranceCoverage: {
|
||||
coverageType: insuranceCoverage.coverageType,
|
||||
|
|
@ -1365,6 +1369,7 @@ export const useMainStore = defineStore({
|
|||
isPaypal: payment.payInAdvanceType === paymentMethods.PAYPAL,
|
||||
isCreditCard: payment.payInAdvanceType === paymentMethods.CREDIT_CARD,
|
||||
isAfterpay: payment.payInAdvanceType === paymentMethods.AFTERPAY,
|
||||
nextGenSettledAmount: payment.nextGenSettledAmount,
|
||||
CCToken: payment.creditCardToken,
|
||||
insuranceCoverage: {
|
||||
isVerified: this.isVerified,
|
||||
|
|
@ -1724,17 +1729,31 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
async setPriceAndSalesTaxForOrderLineItems() {
|
||||
const lineItemsToTax = [
|
||||
const lineItemsToPrice = [
|
||||
...(this.order.lineItems.supportingItems ?? []),
|
||||
...(this.order.lineItems.glassParts ?? []),
|
||||
...(this.order.lineItems.otherParts ?? []),
|
||||
...(this.order.lineItems.vaps ?? []),
|
||||
...(this.order.lineItems.feeItems ?? []
|
||||
)
|
||||
...(this.order.lineItems.feeItems ?? [])
|
||||
];
|
||||
|
||||
await this.getInsurancePriceOrderItems(lineItemsToTax);
|
||||
await this.getTaxOrderItems(lineItemsToTax);
|
||||
let lineItemsToTax = [];
|
||||
if (!this.isVerified || !this.isDeductible) {
|
||||
lineItemsToTax = [
|
||||
...lineItemsToPrice
|
||||
];
|
||||
} else {
|
||||
lineItemsToTax = [
|
||||
...(this.order.lineItems.vaps ?? []),
|
||||
...(this.order.lineItems.feeItems ?? [])
|
||||
];
|
||||
}
|
||||
|
||||
await this.getInsurancePriceOrderItems(lineItemsToPrice);
|
||||
|
||||
if (lineItemsToTax && lineItemsToTax.length > 0) {
|
||||
await this.getTaxOrderItems(lineItemsToTax);
|
||||
}
|
||||
},
|
||||
|
||||
updateVehicle(vehicle) {
|
||||
|
|
@ -2723,3 +2742,17 @@ function providersEqual(providerA, providerB) {
|
|||
function provisionalTriggersToString(provisionalTriggers) {
|
||||
return `ProvisionalTriggers:${provisionalTriggers.join(',')}`;
|
||||
}
|
||||
|
||||
function setClearOnSubmit(lineItemArray, shouldClearOnSubmit) {
|
||||
const retArray = [];
|
||||
if (lineItemArray && lineItemArray.length > 0) {
|
||||
lineItemArray.forEach((part) => {
|
||||
const newPart = { ...part };
|
||||
newPart.clearOnSubmit = shouldClearOnSubmit;
|
||||
|
||||
retArray.push(newPart);
|
||||
});
|
||||
}
|
||||
|
||||
return retArray;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -779,9 +779,18 @@ describe('Store', () => {
|
|||
});
|
||||
it('calls api with expected lineItems', async () => {
|
||||
// Arrange
|
||||
const glassParts = getRandomString(6, 6);
|
||||
const supportingItems = getRandomString(6, 6);
|
||||
const vaps = getRandomString(6, 6);
|
||||
const glassParts = [{
|
||||
partNumber: getRandomString(6, 6),
|
||||
clearOnSubmit: false
|
||||
}];
|
||||
const supportingItems = [{
|
||||
partNumber: getRandomString(6, 6),
|
||||
clearOnSubmit: false
|
||||
}];
|
||||
const vaps = [{
|
||||
partNumber: getRandomString(6, 6),
|
||||
clearOnSubmit: false
|
||||
}];
|
||||
store.order.lineItems.glassParts = glassParts;
|
||||
store.order.lineItems.supportingItems = supportingItems;
|
||||
store.order.lineItems.vaps = vaps;
|
||||
|
|
@ -808,7 +817,7 @@ describe('Store', () => {
|
|||
[coverageStatuses.PENDING, coverageType.Deductible, null],
|
||||
[coverageStatuses.VERIFIED, coverageType.ITAC, 'V_ITAC_123'],
|
||||
[coverageStatuses.VERIFIED, coverageType.Deductible, 'V_Deductible_123'],
|
||||
[coverageStatuses.NO_COVERAGE, coverageType.NONE, null],
|
||||
[coverageStatuses.NO_COVERAGE, coverageType.NONE, null]
|
||||
])('calls api with expected insuranceCoverage', (status, type, claimNumber) => {
|
||||
test(`calls api with coverageStatus is ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)} and claimNumber is ${claimNumber}`, async () => {
|
||||
// Arrange
|
||||
|
|
|
|||
Loading…
Reference in a new issue