From 5870d256056c47f0b7e90daf93627ab7ae57e0dd Mon Sep 17 00:00:00 2001 From: Ashwin Thanaraj <37061471+ashwin1111@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:20:58 +0530 Subject: [PATCH] Revert "feat: add advanced search to ccc export settings fields in netsuite (#867)" (#874) This reverts commit ce6b051fba73f1d3b23edea5652ea97ecce2c8d1. --- .../models/common/export-settings.model.ts | 8 +- src/app/core/models/enum/enum.model.ts | 7 -- .../export-settings.model.ts | 5 +- .../intacct-export-settings.component.ts | 11 +- .../netsuite-export-settings.component.html | 36 +----- .../netsuite-export-settings.component.ts | 107 ++---------------- .../configuration-select-field.component.ts | 7 +- 7 files changed, 30 insertions(+), 151 deletions(-) diff --git a/src/app/core/models/common/export-settings.model.ts b/src/app/core/models/common/export-settings.model.ts index e00f87cfb..122045d9a 100644 --- a/src/app/core/models/common/export-settings.model.ts +++ b/src/app/core/models/common/export-settings.model.ts @@ -1,5 +1,5 @@ import { DefaultDestinationAttribute, DestinationAttribute } from "../db/destination-attribute.model"; -import { ExpenseGroupingFieldOption, ExportDateType, IntacctCorporateCreditCardExpensesObject, IntacctExportSettingDestinationOptionKey, IntacctReimbursableExpensesObject, NetsuiteExportSettingDestinationOptionKey, SplitExpenseGrouping } from "../enum/enum.model"; +import { ExpenseGroupingFieldOption, ExportDateType, IntacctCorporateCreditCardExpensesObject, IntacctReimbursableExpensesObject, SplitExpenseGrouping } from "../enum/enum.model"; import { SelectFormOption } from "./select-form-option.model"; export type ExportSettingValidatorRule = { @@ -12,12 +12,6 @@ export type ExportModuleRule = { requiredValue: Record }; -export type ExportSettingOptionSearch = { - searchTerm: string, - destinationAttributes: any[], - destinationOptionKey: IntacctExportSettingDestinationOptionKey | NetsuiteExportSettingDestinationOptionKey; -}; - export class ExportSettingModel { static getSplitExpenseGroupingOptions(): SelectFormOption[] { return [ diff --git a/src/app/core/models/enum/enum.model.ts b/src/app/core/models/enum/enum.model.ts index 169f17744..b807769f2 100644 --- a/src/app/core/models/enum/enum.model.ts +++ b/src/app/core/models/enum/enum.model.ts @@ -627,13 +627,6 @@ export enum IntacctExportSettingDestinationOptionKey { CHARGE_CARD = 'CHARGE_CARD' } -export enum NetsuiteExportSettingDestinationOptionKey { - VENDOR = 'VENDOR', - ACCOUNTS_PAYABLE = 'ACCOUNTS_PAYABLE', - BANK_ACCOUNT = 'BANK_ACCOUNT', - CREDIT_CARD_ACCOUNT = 'CREDIT_CARD_ACCOUNT', -} - export enum IntegrationName { SAGE300 = 'SAGE300' } diff --git a/src/app/core/models/intacct/intacct-configuration/export-settings.model.ts b/src/app/core/models/intacct/intacct-configuration/export-settings.model.ts index 676f8a91a..b427abec2 100644 --- a/src/app/core/models/intacct/intacct-configuration/export-settings.model.ts +++ b/src/app/core/models/intacct/intacct-configuration/export-settings.model.ts @@ -4,7 +4,6 @@ import { DefaultDestinationAttribute, DestinationAttribute } from "../../db/dest import { IntacctDestinationAttribute } from "../db/destination-attribute.model"; import { SelectFormOption } from "../../common/select-form-option.model"; import { brandingConfig, brandingContent, brandingFeatureConfig } from "src/app/branding/branding-config"; -import { ExportSettingOptionSearch } from "../../common/export-settings.model"; export type ExportSettingFormOption = { label: string, @@ -56,7 +55,9 @@ export type ExportSettingPost = { general_mappings: ExportSettingGeneralMapping } -export interface IntacctExportSettingOptionSearch extends ExportSettingOptionSearch { +export type ExportSettingOptionSearch = { + searchTerm: string, + destinationAttributes: any[], destinationOptionKey: IntacctExportSettingDestinationOptionKey } diff --git a/src/app/integrations/intacct/intacct-shared/intacct-export-settings/intacct-export-settings.component.ts b/src/app/integrations/intacct/intacct-shared/intacct-export-settings/intacct-export-settings.component.ts index fc44001da..e7de253b1 100644 --- a/src/app/integrations/intacct/intacct-shared/intacct-export-settings/intacct-export-settings.component.ts +++ b/src/app/integrations/intacct/intacct-shared/intacct-export-settings/intacct-export-settings.component.ts @@ -5,11 +5,11 @@ import { DomSanitizer } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { Observable, Subject, debounceTime, filter, forkJoin } from 'rxjs'; import { brandingConfig, brandingContent, brandingFeatureConfig, brandingKbArticles } from 'src/app/branding/branding-config'; -import { ExportSettingModel, ExportSettingOptionSearch } from 'src/app/core/models/common/export-settings.model'; +import { ExportSettingModel } from 'src/app/core/models/common/export-settings.model'; import { DefaultDestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; import { CCCExpenseState, ConfigurationCta, IntacctCorporateCreditCardExpensesObject, FyleField, ExpenseGroupedBy, ExpenseState, ExportDateType, IntacctReimbursableExpensesObject, ExpenseGroupingFieldOption, Page, ToastSeverity, IntacctOnboardingState, ProgressPhase, IntacctUpdateEvent, AppName, IntacctExportSettingDestinationOptionKey, TrackingApp, EmployeeFieldMapping } from 'src/app/core/models/enum/enum.model'; import { ExportSettingDestinationAttributeOption, IntacctDestinationAttribute, PaginatedintacctDestinationAttribute } from 'src/app/core/models/intacct/db/destination-attribute.model'; -import { ExportSettingFormOption, ExportSettingGet, ExportSettingModel as IntacctExportSettingModel, IntacctExportSettingOptionSearch } from 'src/app/core/models/intacct/intacct-configuration/export-settings.model'; +import { ExportSettingFormOption, ExportSettingGet, ExportSettingModel as IntacctExportSettingModel, ExportSettingOptionSearch } from 'src/app/core/models/intacct/intacct-configuration/export-settings.model'; import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; import { TrackingService } from 'src/app/core/services/integration/tracking.service'; import { SiExportSettingService } from 'src/app/core/services/si/si-configuration/si-export-setting.service'; @@ -146,7 +146,7 @@ export class IntacctExportSettingsComponent implements OnInit { } ]; - private optionSearchUpdate = new Subject(); + private optionSearchUpdate = new Subject(); readonly brandingFeatureConfig = brandingFeatureConfig; @@ -589,7 +589,7 @@ export class IntacctExportSettingsComponent implements OnInit { private optionSearchWatcher(): void { this.optionSearchUpdate.pipe( debounceTime(1000) - ).subscribe((event: IntacctExportSettingOptionSearch) => { + ).subscribe((event: ExportSettingOptionSearch) => { const existingOptions = this.destinationOptions[event.destinationOptionKey].concat(); const newOptions: IntacctDestinationAttribute[] = []; @@ -623,8 +623,7 @@ export class IntacctExportSettingsComponent implements OnInit { }); } - searchOptionsDropdown(_event: ExportSettingOptionSearch): void { - const event = _event as IntacctExportSettingOptionSearch; + searchOptionsDropdown(event: ExportSettingOptionSearch): void { if (event.searchTerm) { this.isOptionSearchInProgress = true; this.optionSearchUpdate.next(event); diff --git a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.html b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.html index 3cdb47d80..de01b4864 100644 --- a/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.html +++ b/src/app/integrations/netsuite/netsuite-shared/netsuite-export-settings/netsuite-export-settings.component.html @@ -48,8 +48,6 @@ + [formControllerName]="'bankAccount'"> @@ -67,8 +63,6 @@ + [formControllerName]="'accountsPayable'"> @@ -194,8 +186,6 @@ + [formControllerName]="'accountsPayable'"> @@ -213,8 +201,6 @@ + [formControllerName]="'bankAccount'"> @@ -232,8 +216,6 @@ + [formControllerName]="'creditCardAccount'"> @@ -251,8 +231,6 @@ + [formControllerName]="'defaultCreditCardVendor'"> 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 7bc77cdad..0dde01c82 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 @@ -2,13 +2,13 @@ import { TitleCasePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; -import { Observable, Subject, debounceTime, filter, forkJoin } from 'rxjs'; +import { forkJoin } from 'rxjs'; import { brandingConfig, brandingContent, brandingFeatureConfig, brandingKbArticles } from 'src/app/branding/branding-config'; -import { ExportSettingModel, ExportSettingOptionSearch } from 'src/app/core/models/common/export-settings.model'; +import { ExportSettingModel } from 'src/app/core/models/common/export-settings.model'; import { HelperUtility } from 'src/app/core/models/common/helper.model'; import { SelectFormOption } from 'src/app/core/models/common/select-form-option.model'; -import { DefaultDestinationAttribute, PaginatedDestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; -import { AppName, ConfigurationCta, ConfigurationWarningEvent, EmployeeFieldMapping, ExpenseGroupingFieldOption, FyleField, NameInJournalEntry, NetSuiteCorporateCreditCardExpensesObject, NetsuiteExportSettingDestinationOptionKey, NetsuiteOnboardingState, NetsuiteReimbursableExpensesObject, ToastSeverity } from 'src/app/core/models/enum/enum.model'; +import { DefaultDestinationAttribute, DestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; +import { AppName, ConfigurationCta, ConfigurationWarningEvent, EmployeeFieldMapping, ExpenseGroupingFieldOption, FyleField, NameInJournalEntry, NetSuiteCorporateCreditCardExpensesObject, NetsuiteOnboardingState, NetsuiteReimbursableExpensesObject, ToastSeverity } from 'src/app/core/models/enum/enum.model'; import { ConfigurationWarningOut } from 'src/app/core/models/misc/configuration-warning.model'; import { NetSuiteExportSettingGet, NetSuiteExportSettingModel } from 'src/app/core/models/netsuite/netsuite-configuration/netsuite-export-setting.model'; import { HelperService } from 'src/app/core/services/common/helper.service'; @@ -106,12 +106,6 @@ export class NetsuiteExportSettingsComponent implements OnInit { readonly brandingFeatureConfig = brandingFeatureConfig; - isOptionSearchInProgress: boolean; - - private optionSearchUpdate = new Subject(); - - NetsuiteExportSettingDestinationOptionKey = NetsuiteExportSettingDestinationOptionKey; - constructor( private exportSettingService: NetsuiteExportSettingsService, public helperService: HelperService, @@ -278,96 +272,20 @@ export class NetsuiteExportSettingsComponent implements OnInit { }); } - - private optionSearchWatcher(): void { - this.optionSearchUpdate.pipe( - debounceTime(1000) - ).subscribe((event: ExportSettingOptionSearch) => { - let existingOptions: DefaultDestinationAttribute[] = []; - - switch (event.destinationOptionKey) { - case NetsuiteExportSettingDestinationOptionKey.ACCOUNTS_PAYABLE: - existingOptions = this.accountsPayables; - break; - case NetsuiteExportSettingDestinationOptionKey.BANK_ACCOUNT: - existingOptions = this.bankAccounts; - break; - case NetsuiteExportSettingDestinationOptionKey.CREDIT_CARD_ACCOUNT: - existingOptions = this.cccAccounts; - break; - case NetsuiteExportSettingDestinationOptionKey.VENDOR: - existingOptions = this.creditCardVendors; - break; - } - - let newOptions: DefaultDestinationAttribute[]; - - this.mappingService.getPaginatedDestinationAttributes(event.destinationOptionKey, event.searchTerm).subscribe((response) => { - - // Convert DestinationAttributes to DefaultDestinationAttributes (name, id) - newOptions = response.results.map(NetSuiteExportSettingModel.formatGeneralMappingPayload); - - // Insert new options to existing options - newOptions.forEach((option) => { - if (!existingOptions.find((existingOption) => existingOption.id === option.id)) { - existingOptions.push(option); - } - }); - - - switch (event.destinationOptionKey) { - case NetsuiteExportSettingDestinationOptionKey.ACCOUNTS_PAYABLE: - this.accountsPayables = existingOptions.concat(); - this.accountsPayables.sort((a, b) => (a.name || '').localeCompare(b.name || '')); - break; - case NetsuiteExportSettingDestinationOptionKey.BANK_ACCOUNT: - this.bankAccounts = existingOptions.concat(); - this.bankAccounts.sort((a, b) => (a.name || '').localeCompare(b.name || '')); - break; - case NetsuiteExportSettingDestinationOptionKey.CREDIT_CARD_ACCOUNT: - this.cccAccounts = existingOptions.concat(); - this.cccAccounts.sort((a, b) => (a.name || '').localeCompare(b.name || '')); - break; - case NetsuiteExportSettingDestinationOptionKey.VENDOR: - this.creditCardVendors = existingOptions.concat(); - this.creditCardVendors.sort((a, b) => (a.name || '').localeCompare(b.name || '')); - break; - } - - this.isOptionSearchInProgress = false; - }); - }); - } - - searchOptionsDropdown(event: ExportSettingOptionSearch): void { - if (event.searchTerm) { - this.isOptionSearchInProgress = true; - this.optionSearchUpdate.next(event); - } - } - - private getSettingsAndSetupForm(): void { this.isOnboarding = this.windowReference.location.pathname.includes('onboarding'); const destinationAttributes = ['VENDOR', 'ACCOUNTS_PAYABLE', 'BANK_ACCOUNT', 'CREDIT_CARD_ACCOUNT']; - const groupedAttributes: Observable[]= []; - - destinationAttributes.forEach((destinationAttribute) => { - groupedAttributes.push(this.mappingService.getPaginatedDestinationAttributes(destinationAttribute).pipe(filter(response => !!response))); - }); - - forkJoin([ - this.exportSettingService.getExportSettings(), - ...groupedAttributes - ]).subscribe(([exportSetting, vendors, accountsPayables, bankAccounts, cccAccounts]) => { + forkJoin({ + exportSetting: this.exportSettingService.getExportSettings(), + destinationAttributes: this.mappingService.getGroupedDestinationAttributes(destinationAttributes, 'v2', 'netsuite') + }).subscribe(({exportSetting, destinationAttributes}) => { this.exportSettings = exportSetting; - this.creditCardVendors = vendors.results.map((option) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); - this.accountsPayables = accountsPayables.results.map((option) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); - this.bankAccounts = bankAccounts.results.map((option) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); - this.cccAccounts = cccAccounts.results.map((option) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); - + this.creditCardVendors = destinationAttributes.VENDOR.map((option: DestinationAttribute) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); + this.accountsPayables = destinationAttributes.ACCOUNTS_PAYABLE.map((option: DestinationAttribute) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); + this.bankAccounts = destinationAttributes.BANK_ACCOUNT.map((option: DestinationAttribute) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); + this.cccAccounts = destinationAttributes.CREDIT_CARD_ACCOUNT.map((option: DestinationAttribute) => NetSuiteExportSettingModel.formatGeneralMappingPayload(option)); this.reimbursableExportTypes = NetSuiteExportSettingModel.getReimbursableExportTypeOptions(); this.showNameInJournalOption = this.exportSettings.configuration?.corporate_credit_card_expenses_object === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY ? true : false; @@ -396,7 +314,6 @@ export class NetsuiteExportSettingsComponent implements OnInit { this.exportSettingService.setExportTypeValidatorsAndWatchers(exportModuleRule, this.exportSettingForm); this.exportFieldsWatcher(); - this.optionSearchWatcher(); this.setupCustomWatchers(); this.setupCustomDateOptionWatchers(); this.isLoading = false; diff --git a/src/app/shared/components/configuration/configuration-select-field/configuration-select-field.component.ts b/src/app/shared/components/configuration/configuration-select-field/configuration-select-field.component.ts index 588e16ee9..cca7cb526 100644 --- a/src/app/shared/components/configuration/configuration-select-field/configuration-select-field.component.ts +++ b/src/app/shared/components/configuration/configuration-select-field/configuration-select-field.component.ts @@ -1,8 +1,8 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AbstractControl, FormGroup } from '@angular/forms'; import { QBDExportSettingFormOption } from 'src/app/core/models/qbd/qbd-configuration/export-setting.model'; -import { ExportSettingFormOption } from 'src/app/core/models/intacct/intacct-configuration/export-settings.model'; -import { AppName, IntacctCorporateCreditCardExpensesObject, IntacctExportSettingDestinationOptionKey, NetsuiteExportSettingDestinationOptionKey } from 'src/app/core/models/enum/enum.model'; +import { ExportSettingFormOption, ExportSettingOptionSearch } from 'src/app/core/models/intacct/intacct-configuration/export-settings.model'; +import { AppName, IntacctCorporateCreditCardExpensesObject, IntacctExportSettingDestinationOptionKey } from 'src/app/core/models/enum/enum.model'; import { TrackingService } from 'src/app/core/services/integration/tracking.service'; import { AdvancedSettingFormOption, HourOption } from 'src/app/core/models/intacct/intacct-configuration/advanced-settings.model'; import { SafeHtml } from '@angular/platform-browser'; @@ -15,7 +15,6 @@ import { brandingConfig } from 'src/app/branding/branding-config'; import { DefaultDestinationAttribute, DestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; import { SelectFormOption } from 'src/app/core/models/common/select-form-option.model'; import { TravelperkDestinationAttribuite } from 'src/app/core/models/travelperk/travelperk.model'; -import { ExportSettingOptionSearch } from 'src/app/core/models/common/export-settings.model'; @Component({ selector: 'app-configuration-select-field', @@ -59,7 +58,7 @@ export class ConfigurationSelectFieldComponent implements OnInit { @Input() isDefaultFields: boolean = false; - @Input() destinationOptionKey: IntacctExportSettingDestinationOptionKey | NetsuiteExportSettingDestinationOptionKey; + @Input() destinationOptionKey: IntacctExportSettingDestinationOptionKey; @Input() isOptionSearchInProgress: boolean;