Merge pull request #779 from Safelite/feature/richardson/SSR-1207.3

Override tender amount for deductible case
This commit is contained in:
brich1212safe 2024-07-01 11:23:12 -04:00 committed by GitHub
commit 9da1c3e553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 16 deletions

View file

@ -13,6 +13,7 @@ import { useMainStore } from '@/store/index.js';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import getQueryStringParameter from '@/helpers/querystring-helper.js'; import getQueryStringParameter from '@/helpers/querystring-helper.js';
import { paymentMethods } from '@/constants/payment-method-constants.js'; import { paymentMethods } from '@/constants/payment-method-constants.js';
import { getCartTotal } from '@/helpers/cart-helper';
import { submitWorkOrder } from '@/helpers/order-helper.js'; import { submitWorkOrder } from '@/helpers/order-helper.js';
import showIssLoadingModal from '@/helpers/loading-modal-helper'; import showIssLoadingModal from '@/helpers/loading-modal-helper';
import submitType from '@/constants/submit-type'; import submitType from '@/constants/submit-type';
@ -105,7 +106,8 @@ export default {
async processPaypalResponse() { async processPaypalResponse() {
const token = getQueryStringParameter(queryStrings.TOKEN); const token = getQueryStringParameter(queryStrings.TOKEN);
this.mainStore.updatePaypalToken(token); this.mainStore.updatePaypalToken(token);
const cartTotal = getCartTotal(useMainStore().order);
useMainStore().order.payment.nextGenSettledAmount = cartTotal;
await this.saveAndSubmitWorkOrder(); await this.saveAndSubmitWorkOrder();
}, },
async processCreditCardResponse() { async processCreditCardResponse() {
@ -115,6 +117,8 @@ export default {
this.navigateOnPayInAdvanceError(); this.navigateOnPayInAdvanceError();
} else { } else {
useMainStore().updateCreditCardToken(this.creditCardToken); useMainStore().updateCreditCardToken(this.creditCardToken);
const cartTotal = getCartTotal(useMainStore().order);
useMainStore().order.payment.nextGenSettledAmount = cartTotal;
await this.saveAndSubmitWorkOrder(); await this.saveAndSubmitWorkOrder();
} }
}, },

View file

@ -38,8 +38,8 @@
</div> </div>
</div> </div>
<loadingModal <loadingModal
ref="loadingModal" ref="loadingModal"
:textSlides="loadingText" /> :textSlides="loadingText" />
<contentGroupModal <contentGroupModal
ref="RainDefenseModal" ref="RainDefenseModal"
cmsWidgetName="RainDefenseModal" /> cmsWidgetName="RainDefenseModal" />

View file

@ -162,6 +162,7 @@ export const getDefaultState = () => ({
payment: { payment: {
parentAccountNumber: 0, parentAccountNumber: 0,
isPayInAdvance: null, isPayInAdvance: null,
nextGenSettledAmount: 0,
payInAdvanceType: null, payInAdvanceType: null,
paypalToken: null, paypalToken: null,
creditCardToken: { creditCardToken: {
@ -1283,8 +1284,11 @@ export const useMainStore = defineStore({
} }
const loadedFromDupeCheck = !!(this.order.loadedFromDupeCheck && !this.order.loadedSessionClearedPreviousData); const loadedFromDupeCheck = !!(this.order.loadedFromDupeCheck && !this.order.loadedSessionClearedPreviousData);
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace); 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 = { const payload = {
applicationUser: { applicationUser: {
@ -1349,10 +1353,10 @@ export const useMainStore = defineStore({
isSmsOptIn: contactInfo.requestTextUpdates ?? false isSmsOptIn: contactInfo.requestTextUpdates ?? false
}, },
lineItems: { lineItems: {
glassParts: lineItems.glassParts, glassParts: payloadGlassParts,
serverData: lineItems.serverData, serverData: lineItems.serverData,
supportingItems: lineItems.supportingItems, supportingItems: payloadSupportingItems,
vaps: lineItems.vaps vaps: payloadVapsItems
}, },
insuranceCoverage: { insuranceCoverage: {
coverageType: insuranceCoverage.coverageType, coverageType: insuranceCoverage.coverageType,
@ -1365,6 +1369,7 @@ export const useMainStore = defineStore({
isPaypal: payment.payInAdvanceType === paymentMethods.PAYPAL, isPaypal: payment.payInAdvanceType === paymentMethods.PAYPAL,
isCreditCard: payment.payInAdvanceType === paymentMethods.CREDIT_CARD, isCreditCard: payment.payInAdvanceType === paymentMethods.CREDIT_CARD,
isAfterpay: payment.payInAdvanceType === paymentMethods.AFTERPAY, isAfterpay: payment.payInAdvanceType === paymentMethods.AFTERPAY,
nextGenSettledAmount: payment.nextGenSettledAmount,
CCToken: payment.creditCardToken, CCToken: payment.creditCardToken,
insuranceCoverage: { insuranceCoverage: {
isVerified: this.isVerified, isVerified: this.isVerified,
@ -1724,17 +1729,31 @@ export const useMainStore = defineStore({
}, },
async setPriceAndSalesTaxForOrderLineItems() { async setPriceAndSalesTaxForOrderLineItems() {
const lineItemsToTax = [ const lineItemsToPrice = [
...(this.order.lineItems.supportingItems ?? []), ...(this.order.lineItems.supportingItems ?? []),
...(this.order.lineItems.glassParts ?? []), ...(this.order.lineItems.glassParts ?? []),
...(this.order.lineItems.otherParts ?? []), ...(this.order.lineItems.otherParts ?? []),
...(this.order.lineItems.vaps ?? []), ...(this.order.lineItems.vaps ?? []),
...(this.order.lineItems.feeItems ?? [] ...(this.order.lineItems.feeItems ?? [])
)
]; ];
await this.getInsurancePriceOrderItems(lineItemsToTax); let lineItemsToTax = [];
await this.getTaxOrderItems(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) { updateVehicle(vehicle) {
@ -2723,3 +2742,17 @@ function providersEqual(providerA, providerB) {
function provisionalTriggersToString(provisionalTriggers) { function provisionalTriggersToString(provisionalTriggers) {
return `ProvisionalTriggers:${provisionalTriggers.join(',')}`; 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;
}

View file

@ -779,9 +779,18 @@ describe('Store', () => {
}); });
it('calls api with expected lineItems', async () => { it('calls api with expected lineItems', async () => {
// Arrange // Arrange
const glassParts = getRandomString(6, 6); const glassParts = [{
const supportingItems = getRandomString(6, 6); partNumber: getRandomString(6, 6),
const vaps = 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.glassParts = glassParts;
store.order.lineItems.supportingItems = supportingItems; store.order.lineItems.supportingItems = supportingItems;
store.order.lineItems.vaps = vaps; store.order.lineItems.vaps = vaps;
@ -808,7 +817,7 @@ describe('Store', () => {
[coverageStatuses.PENDING, coverageType.Deductible, null], [coverageStatuses.PENDING, coverageType.Deductible, null],
[coverageStatuses.VERIFIED, coverageType.ITAC, 'V_ITAC_123'], [coverageStatuses.VERIFIED, coverageType.ITAC, 'V_ITAC_123'],
[coverageStatuses.VERIFIED, coverageType.Deductible, 'V_Deductible_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) => { ])('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 () => { test(`calls api with coverageStatus is ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)} and claimNumber is ${claimNumber}`, async () => {
// Arrange // Arrange