From 9d25adf1259631a045144ae9cc7555e8befcee30 Mon Sep 17 00:00:00 2001 From: ashwin1111 Date: Fri, 11 Oct 2024 22:44:02 +0530 Subject: [PATCH 1/3] feat: Single credit line for Journal Entry --- src/app/branding/c1-contents-config.ts | 4 +- src/app/branding/fyle-contents-config.ts | 4 +- .../branding/content-configuration.model.ts | 2 + .../netsuite-advanced-settings.model.ts | 7 ++- .../netsuite-advanced-settings.component.html | 26 +++++---- .../netsuite-advanced-settings.component.ts | 4 ++ .../netsuite-export-settings.component.ts | 54 +++++++++++++++++++ 7 files changed, 87 insertions(+), 14 deletions(-) diff --git a/src/app/branding/c1-contents-config.ts b/src/app/branding/c1-contents-config.ts index faac3dffa..7bd7b072a 100644 --- a/src/app/branding/c1-contents-config.ts +++ b/src/app/branding/c1-contents-config.ts @@ -85,7 +85,9 @@ export const c1Contents = { preferenceLabel: 'Other preferences', preferenceSubLabel: 'Create new records in NetSuite if no vendor record is found or the accounting period is closed.', previewDescriptionFieldLabel: 'Preview of the description field', - autoCreateMerchantsLabel: 'Auto create merchant on NetSuite for credit card charge' + autoCreateMerchantsLabel: 'Auto create merchant on NetSuite for credit card charge', + singleCreditLineJELabel: 'Create a single itemized offset credit entry for Journal', + singleCreditLineJESubLabel: 'Merge all Credits in a Journal to create a single entry.' } } }, diff --git a/src/app/branding/fyle-contents-config.ts b/src/app/branding/fyle-contents-config.ts index 98b73c303..e69af6c72 100644 --- a/src/app/branding/fyle-contents-config.ts +++ b/src/app/branding/fyle-contents-config.ts @@ -85,7 +85,9 @@ export const fyleContents = { preferenceLabel: 'Other Preferences', preferenceSubLabel: 'Based on your preference, you can choose whether you want to create any new records in NetSuite from Fyle. (when there is no employee record found, or when the accounting period is closed).', previewDescriptionFieldLabel: 'Preview of the Description Field', - autoCreateMerchantsLabel: 'Auto Create Merchant on NetSuite for Credit Card Charge' + autoCreateMerchantsLabel: 'Auto Create Merchant on NetSuite for Credit Card Charge', + singleCreditLineJELabel: 'Create a single itemized offset credit entry for Journal', + singleCreditLineJESubLabel: 'Merge all Credits in a Journal to create a single entry.' } } }, diff --git a/src/app/core/models/branding/content-configuration.model.ts b/src/app/core/models/branding/content-configuration.model.ts index b58e66ae5..37dcf0f8b 100644 --- a/src/app/core/models/branding/content-configuration.model.ts +++ b/src/app/core/models/branding/content-configuration.model.ts @@ -82,6 +82,8 @@ export type ContentConfiguration = { scheduleSubLabel: string; previewDescriptionFieldLabel: string; autoCreateMerchantsLabel: string; + singleCreditLineJELabel: string; + singleCreditLineJESubLabel: string; } }, }, diff --git a/src/app/core/models/netsuite/netsuite-configuration/netsuite-advanced-settings.model.ts b/src/app/core/models/netsuite/netsuite-configuration/netsuite-advanced-settings.model.ts index 99ec7f324..69de8200b 100644 --- a/src/app/core/models/netsuite/netsuite-configuration/netsuite-advanced-settings.model.ts +++ b/src/app/core/models/netsuite/netsuite-configuration/netsuite-advanced-settings.model.ts @@ -14,7 +14,8 @@ export type NetsuiteAdvancedSettingConfiguration = { auto_create_destination_entity: boolean, auto_create_merchants: boolean, change_accounting_period: boolean, - memo_structure: string[] + memo_structure: string[], + je_single_credit_line: boolean } export type NetsuiteAdvancedSettingGeneralMapping = { @@ -138,6 +139,7 @@ export class NetsuiteAdvancedSettingModel extends HelperUtility { useEmployeeClass: new FormControl(advancedSettings?.general_mappings.use_employee_class ? advancedSettings?.general_mappings.use_employee_class : false), changeAccountingPeriod: new FormControl(advancedSettings?.configuration.change_accounting_period), autoCreateVendors: new FormControl(advancedSettings?.configuration.auto_create_destination_entity), + singleCreditLineJE: new FormControl(advancedSettings?.configuration.je_single_credit_line), exportSchedule: new FormControl(advancedSettings?.workspace_schedules?.enabled ? true : false), exportScheduleFrequency: new FormControl(advancedSettings?.workspace_schedules?.enabled ? advancedSettings?.workspace_schedules.interval_hours : 1), memoStructure: new FormControl(advancedSettings?.configuration.memo_structure), @@ -160,7 +162,8 @@ export class NetsuiteAdvancedSettingModel extends HelperUtility { auto_create_destination_entity: advancedSettingsForm.get('autoCreateVendors')?.value, change_accounting_period: advancedSettingsForm.get('changeAccountingPeriod')?.value, memo_structure: advancedSettingsForm.get('memoStructure')?.value, - auto_create_merchants: advancedSettingsForm.get('autoCreateMerchants')?.value + auto_create_merchants: advancedSettingsForm.get('autoCreateMerchants')?.value, + je_single_credit_line: advancedSettingsForm.get('singleCreditLineJE')?.value || false }, general_mappings: { vendor_payment_account: advancedSettingsForm.get('paymentAccount')?.value ? advancedSettingsForm.get('paymentAccount')?.value : emptyDestinationAttribute, diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.html b/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.html index 721f4dd75..c20939b98 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.html +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.html @@ -87,17 +87,15 @@ [formControllerName]="'changeAccountingPeriod'"> -
- - -
+ + - + + +
diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.ts b/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.ts index b8d2a030f..c5d3b29a7 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.ts +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component.ts @@ -194,6 +194,10 @@ export class NetsuiteAdvancedSettingsComponent implements OnInit { return this.workspaceGeneralSettings.reimbursable_expenses_object && this.workspaceGeneralSettings.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY; } + isSingleCreditLineJEFieldVisible(): boolean { + return this.workspaceGeneralSettings.reimbursable_expenses_object === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY || this.workspaceGeneralSettings.corporate_credit_card_expenses_object === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY; + } + onMultiSelectChange() { const memo = this.advancedSettingForm.controls.memoStructure.value; const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoOptions)[1]; diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts index f7cfdb22c..80f913e0b 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts @@ -206,6 +206,8 @@ export class NetsuiteExportSettingsComponent implements OnInit { if (this.isOnboarding) { this.workspaceService.setOnboardingState(NetsuiteOnboardingState.IMPORT_SETTINGS); this.router.navigate([`/integrations/netsuite/onboarding/import_settings`]); + } else if (this.isAdvancedSettingAffected()) { + this.router.navigate(['/integrations/netsuite/main/configuration/advanced_settings']); } }, () => { this.isSaveInProgress = false; @@ -218,7 +220,59 @@ export class NetsuiteExportSettingsComponent implements OnInit { this.router.navigate([`/integrations/netsuite/onboarding/connector`]); } + private isAdvancedSettingAffected(): boolean { + return (this.exportSettings?.configuration?.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.reimbursableExportType === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY) || (this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.creditCardExportType === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY); + } + + private replaceContentBasedOnConfiguration(updatedConfiguration: string, existingConfiguration: string | undefined | null, exportType: string): string { + const configurationUpdate = `You have changed the export type of $exportType expense from $existingExportType to $updatedExportType, + which would impact a few configurations in the Advanced settings.

Please revisit the Advanced settings to check and enable the + features that could help customize and automate your integration workflows.`; + + let content = ''; + // If both are not none and it is an update case else for the new addition case + if (updatedConfiguration && existingConfiguration) { + content = configurationUpdate.replace('$exportType', exportType).replace('$existingExportType', existingConfiguration.toLowerCase().replace(/^\w/, (c: string) => c.toUpperCase())).replace('$updatedExportType', updatedConfiguration.toLowerCase().replace(/^\w/, (c: string) => c.toUpperCase())); + } + + return content; + } + + private constructWarningMessage(): string { + let content: string = ''; + const existingReimbursableExportType = this.exportSettings?.configuration?.reimbursable_expenses_object; + const existingCorporateCardExportType = this.exportSettings?.configuration?.corporate_credit_card_expenses_object; + + const updatedReimbursableExportType = this.exportSettingForm.value.reimbursableExportType ? this.exportSettingForm.value.reimbursableExportType : null; + const updatedCorporateCardExportType = this.exportSettingForm.value.creditCardExportType ? this.exportSettingForm.value.creditCardExportType : null; + + let updatedExportType; + let existingExportType; + let exportType; + + if (existingReimbursableExportType !== updatedReimbursableExportType) { + updatedExportType = updatedReimbursableExportType; + existingExportType = existingReimbursableExportType; + exportType = 'reimbursable'; + } else if (existingCorporateCardExportType !== updatedCorporateCardExportType) { + updatedExportType = updatedCorporateCardExportType; + existingExportType = existingCorporateCardExportType; + exportType = 'credit card'; + } + + if (this.isAdvancedSettingAffected() && exportType) { + content = this.replaceContentBasedOnConfiguration(updatedExportType, existingExportType, exportType); + } + + return content; + } + save(): void { + if (this.isAdvancedSettingAffected()) { + this.warningDialogText = this.constructWarningMessage(); + this.isConfirmationDialogVisible = true; + return; + } this.constructPayloadAndSave({hasAccepted: true, event: ConfigurationWarningEvent.NETSUITE_EXPORT_SETTINGS}); } From 7a7acbe49adee8afc76d40dcba7f82e32aa249ce Mon Sep 17 00:00:00 2001 From: ashwin1111 Date: Mon, 14 Oct 2024 21:10:07 +0530 Subject: [PATCH 2/3] new org case --- .../netsuite-export-settings.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts index 5d12efe02..96a293e08 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts @@ -268,7 +268,7 @@ export class NetsuiteExportSettingsComponent implements OnInit { } save(): void { - if (this.isAdvancedSettingAffected()) { + if (this.isAdvancedSettingAffected() && this.exportSettings.configuration) { this.warningDialogText = this.constructWarningMessage(); this.isConfirmationDialogVisible = true; return; From 08a2bdb80556b19682c17960c3d948f4dd4ac147 Mon Sep 17 00:00:00 2001 From: ashwin1111 Date: Mon, 14 Oct 2024 21:29:48 +0530 Subject: [PATCH 3/3] fix new case --- .../netsuite-export-settings.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts index 96a293e08..966af2ff8 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.ts @@ -221,7 +221,7 @@ export class NetsuiteExportSettingsComponent implements OnInit { } private isAdvancedSettingAffected(): boolean { - return (this.exportSettings?.configuration?.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.reimbursableExportType === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY) || (this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.creditCardExportType === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY); + return (this.exportSettings?.configuration?.reimbursable_expenses_object !== null && this.exportSettings?.configuration?.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.reimbursableExportType === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY) || (this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== null && this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.creditCardExportType === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY); } private replaceContentBasedOnConfiguration(updatedConfiguration: string, existingConfiguration: string | undefined | null, exportType: string): string {