From ba6c7075e19ac5b4424050b9225d9cbc7fa5bb41 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 9 May 2024 15:32:40 -0400 Subject: [PATCH] get sales tax from tax api --- src/helpers/querystring-helper.js | 9 +++++++++ src/store/index.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/helpers/querystring-helper.js b/src/helpers/querystring-helper.js index 59c1579c..0327071d 100644 --- a/src/helpers/querystring-helper.js +++ b/src/helpers/querystring-helper.js @@ -28,3 +28,12 @@ export function getLineItemQueryString(lineItems, parameterName) { `${parameterName}[${index}].partNumber=${lineItem.partNumber}`).join('&'); return queryString.length !== 0 ? `&${queryString}` : ''; } + +export function getTaxLineItemQueryString(lineItems, parameterName) { + const queryString = getLineItemsFlattened(lineItems).map((lineItem, index) => + `${parameterName}[${index}].partNumber=${lineItem.partNumber}` + + `&${parameterName}[${index}].laborAmount=${lineItem.laborAmount}` + + `&${parameterName}[${index}].sellingPrice=${lineItem.sellingPrice}` + + `&${parameterName}[${index}].kitPrice=${lineItem.kitPrice}`).join('&'); + return queryString.length !== 0 ? `&${queryString}` : ''; +} diff --git a/src/store/index.js b/src/store/index.js index e0d248cd..2bcee233 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -26,7 +26,7 @@ import bailoutMessage from '@/constants/bailoutMessage'; import bailoutCode from '@/constants/bailoutCode'; import partNumberStrings from '@/constants/part-number-strings'; import { getLineItemsFlattened } from '@/helpers/line-items-helper'; -import { buildQueryStringParameterFromArrayOfComplexObjects, getLineItemQueryString } from '@/helpers/querystring-helper'; +import { buildQueryStringParameterFromArrayOfComplexObjects, getLineItemQueryString, getTaxLineItemQueryString } from '@/helpers/querystring-helper'; const storeId = 'main'; @@ -2021,7 +2021,7 @@ export const useMainStore = defineStore({ const serviceLocationState = serviceLocation.state; const serviceLocationZipCode = serviceLocation.zipCode; - const lineItemsQueryString = getLineItemQueryString(pricedLineItems, 'lineItems'); + const lineItemsQueryString = getTaxLineItemQueryString(pricedLineItems, 'lineItems'); let queryString = ''; if (appointmentType === AppointmentTypeStrings.MOBILE