Skip to content

Commit f4bfb71

Browse files
authored
Merge pull request #47 from MediaJel/ez-fixSpecialCharacters
2 parents 62a844f + 93b1bf6 commit f4bfb71

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/processor/intuit/intuit.processor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
QuickbooksFindCustomersInput,
1717
SalesforceClosedWonResource,
1818
} from "@/utils/types";
19-
import { isProduction } from "@/utils/utils";
19+
import { isProduction, sanitizeDisplayName } from "@/utils/utils";
2020
import { Job } from "bull";
2121

2222
const logger = createLogger("Intuit Processor");
@@ -154,7 +154,7 @@ const processCustomerHierarchy = async (
154154
const parentProducerId = isProduction ? parent?.AVSFQB__Quickbooks_Id__c : parent.QBO_Account_ID_Staging__c;
155155

156156
const parentCustomer = await processCustomer(service, parentProducerId, parent.Id, {
157-
DisplayName: parent.Name,
157+
DisplayName: sanitizeDisplayName(parent.Name),
158158
CompanyName: parent.Name,
159159
BillAddr: {
160160
City: parent.BillingCity,
@@ -178,7 +178,7 @@ const processCustomerHierarchy = async (
178178
job.log(`Successfully created parent customer: ${parentCustomer.DisplayName}`);
179179

180180
await processCustomer(service, accountProducerId, account.Id, {
181-
DisplayName: account.Name,
181+
DisplayName: sanitizeDisplayName(account.Name),
182182
CompanyName: account.Name,
183183
PrimaryEmailAddr: {
184184
Address: contact.Email,
@@ -202,7 +202,7 @@ const processCustomerHierarchy = async (
202202
logger.info(`Account Info: ${JSON.stringify(account, null, 2)}`);
203203

204204
const customer = await processCustomer(service, accountProducerId, account.Id, {
205-
DisplayName: account.Name,
205+
DisplayName: sanitizeDisplayName(account.Name),
206206
CompanyName: account.Name,
207207
PrimaryEmailAddr: {
208208
Address: contact.Email,

src/utils/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ export const isProduction = process.env.NODE_ENV === "production";
4747
export const isStaging = process.env.NODE_ENV === "staging";
4848

4949
export const isDeployed = isProduction || isStaging;
50+
51+
/**
52+
* Sanitizes a display name by removing special characters like colons (:)
53+
* that might cause issues in QuickBooks
54+
*
55+
* @param displayName string
56+
* @returns string with special characters removed
57+
*/
58+
export const sanitizeDisplayName = (displayName: string): string => {
59+
if (!displayName) return displayName;
60+
61+
// Remove colons and other problematic special characters
62+
return displayName.replace(/[:]/g, "").trim();
63+
};

0 commit comments

Comments
 (0)