diff --git a/src/app/core/models/db/task-log.model.ts b/src/app/core/models/db/task-log.model.ts index d52f04910..eb4c1239d 100644 --- a/src/app/core/models/db/task-log.model.ts +++ b/src/app/core/models/db/task-log.model.ts @@ -23,5 +23,5 @@ export type TaskLogGetParams = { type__in?: string[]; expense_group_ids?: number[]; task_type?: string[]; - export_log__id__in?: number[]; + id__in?: number[]; }; diff --git a/src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model.ts b/src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model.ts index d329c60b6..ba926e848 100644 --- a/src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model.ts +++ b/src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model.ts @@ -26,7 +26,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel { } static defaultTopMemoOptions(): string[] { - return ["employee_name", "Expense/Report ID"]; + return ["employee_name", "expense_key"]; } static topMemoExpenseKeyNameConversion(keys: string[]): string[] { @@ -52,7 +52,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel { return new FormGroup({ expenseMemoStructure: new FormControl(advancedSettings?.line_level_memo_structure && advancedSettings?.line_level_memo_structure.length > 0 ? this.formatMemoStructure(this.defaultMemoFields(), advancedSettings?.line_level_memo_structure) : this.defaultMemoFields(), Validators.required), - topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? this.topMemoExpenseKeyNameConversion(advancedSettings?.top_level_memo_structure) : this.defaultTopMemoOptions(), Validators.required), + topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? advancedSettings?.top_level_memo_structure : this.defaultTopMemoOptions(), Validators.required), exportSchedule: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.schedule_is_enabled : false), email: new FormControl(advancedSettings?.emails_selected ? advancedSettings?.emails_selected : null), exportScheduleFrequency: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.interval_hours : 1), @@ -65,11 +65,6 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel { static constructPayload (advancedSettingForm: FormGroup, adminEmails: EmailOption[]): QbdDirectAdvancedSettingsPost { - const topMemo: string[] = advancedSettingForm.controls.topMemoStructure.value; - - const index = topMemo.indexOf('Expense/Report ID'); - topMemo[index] = 'expense_key'; - const allSelectedEmails: EmailOption[] = advancedSettingForm.get('email')?.value; const selectedEmailsEmails = allSelectedEmails?.filter((email: EmailOption) => adminEmails.includes(email)); @@ -80,7 +75,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel { const advancedSettingPayload: QbdDirectAdvancedSettingsPost = { line_level_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? this.formatMemoStructure(this.defaultMemoFields(), memo) : [], - top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? topMemo : null, + top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? advancedSettingForm.get('topMemoStructure')?.value : null, schedule_is_enabled: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportSchedule')?.value : false, emails_selected: advancedSettingForm.get('exportSchedule')?.value ? selectedEmailsEmails : [], interval_hours: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportScheduleFrequency')?.value : null, diff --git a/src/app/core/services/common/dashboard.service.ts b/src/app/core/services/common/dashboard.service.ts index ae6053df4..ccdc341be 100644 --- a/src/app/core/services/common/dashboard.service.ts +++ b/src/app/core/services/common/dashboard.service.ts @@ -58,7 +58,7 @@ export class DashboardService { } if (expenseGroupIds.length) { - const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'export_log__id__in' : 'expense_group_id__in'; + const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'id__in' : 'expense_group_id__in'; apiParams[expenseKey] = expenseGroupIds; } diff --git a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html index 8795276d4..f5f969547 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html +++ b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html @@ -97,6 +97,8 @@ [options]="reimbursableExpenseGroupingFieldOptions" [iconPath]="'question-square-outline'" [placeholder]="'Select expense grouping'" + [isDisableTextRequired]="isReimbursableExportGroupDisabled()" + [isDisabled]="isReimbursableExportGroupDisabled()" [formControllerName]="'reimbursableExportGroup'"> @@ -239,7 +241,8 @@ [iconPath]="'question-square-outline'" [placeholder]="'Select expense grouping'" [isDisableTextRequired]="true" - [isDisabled]="exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE || exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.JOURNAL_ENTRY ? true : false" + [appName]="appName" + [isDisabled]="isCccExportGroupDisabled()" [formControllerName]="'creditCardExportGroup'"> diff --git a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts index 99fef322a..1fddf738d 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts @@ -101,6 +101,24 @@ export class QbdDirectExportSettingsComponent implements OnInit{ return true; } + isCccExportGroupDisabled(): boolean { + if (this.exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) { + return true; + } + if (this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable') { + return true; + } + return false; + + } + + isReimbursableExportGroupDisabled(): boolean { + if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable' && this.exportSettingsForm.controls.reimbursableExportType.value === QbdDirectReimbursableExpensesObject.JOURNAL_ENTRY) { + return true; + } + return false; + } + reimbursableAccpuntOptions(): DestinationAttribute[] { if (this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE) { return this.destinationOptionsWatcher(['Bank', 'CreditCard', 'OtherCurrentLiability', 'LongTermLiability'], this.destinationAccounts); @@ -182,9 +200,10 @@ export class QbdDirectExportSettingsComponent implements OnInit{ cccExportTypeWatcher(): void { this.exportSettingsForm.controls.creditCardExportType.valueChanges.subscribe((creditCardExportTypeValue) => { + if (creditCardExportTypeValue === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) { this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value); this.exportSettingsForm.controls.creditCardExportGroup.disable(); - this.creditCardExpenseGroupingFieldOptions = [QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1]]; + } }); } @@ -211,6 +230,49 @@ export class QbdDirectExportSettingsComponent implements OnInit{ }); } + defaultAccountsPayableAccountWatcher() { + this.exportSettingsForm.controls.employeeMapping.valueChanges.subscribe((employeeMapping) => { + if (employeeMapping === EmployeeFieldMapping.EMPLOYEE) { + if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') { + this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.patchValue(null); + if (this.exportSettingsForm.controls.nameInJE.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') { + this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null); + } + } + } + }); + } + + defaultCCCAccountsPayableAccountWatcher() { + this.exportSettingsForm.controls.nameInJE.valueChanges.subscribe((nameInJE) => { + if (nameInJE === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') { + this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null); + } + }); + } + + cccExportGroupingWatcher() { + this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.valueChanges.subscribe((defaultCCCAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => { + if (defaultCCCAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') { + this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value); + this.exportSettingsForm.controls.creditCardExportGroup.disable(); + } else { + this.exportSettingsForm.controls.creditCardExportGroup.enable(); + } + }); + } + + reimburesmentExpenseGroupingWatcher() { + this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.valueChanges.subscribe((defaultReimbursableAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => { + if (defaultReimbursableAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') { + this.exportSettingsForm.controls.reimbursableExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value); + this.exportSettingsForm.controls.reimbursableExportGroup.disable(); + } else { + this.exportSettingsForm.controls.reimbursableExportGroup.enable(); + } + }); + } + destinationOptionsWatcher(detailAccountType: string[], destinationOptions: QbdDirectDestinationAttribute[]): DestinationAttribute[] { return destinationOptions.filter((account: QbdDirectDestinationAttribute) => detailAccountType.includes(account.detail.account_type)); } @@ -224,6 +286,14 @@ export class QbdDirectExportSettingsComponent implements OnInit{ this.reimbursableExpenseGroupWatcher(); this.cccExpenseGroupWatcher(); + + this.defaultAccountsPayableAccountWatcher(); + + this.defaultCCCAccountsPayableAccountWatcher(); + + this.cccExportGroupingWatcher(); + + this.reimburesmentExpenseGroupingWatcher(); } private setupCCCExpenseGroupingDateOptions(): void { diff --git a/src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.html b/src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.html index 436fa1e5f..b07ec672d 100644 --- a/src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.html +++ b/src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.html @@ -15,7 +15,7 @@
{{ name | titlecase | snakeCaseToSpaceCase }},
+{{ getMemo(name) }},
{{ memo | titlecase | snakeCaseToSpaceCase }}
+{{ getMemo(memo) }}