Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
[mandatoryErrorListName]="'export module'"
[label]="'How should the expenses be exported?'"
[subLabel]="'Choose the type of transaction in QuickBooks Online to export your ' + brandingConfig.brandName +' expenses'"
[options]="reimbursableExportTypes"
[options]="getAllReimbursableExportTypeOptions()"
[iconPath]="'list'"
[placeholder]="'Choose the type of transaction in QuickBooks Online to export your ' + brandingConfig.brandName +' expenses'"
[formControllerName]="'reimbursableExportType'"
Expand Down Expand Up @@ -113,7 +113,8 @@
[options]="employeeMappingOptions"
[iconPath]="'user-two'"
[placeholder]="'Select representation'"
[formControllerName]="'employeeMapping'">
[formControllerName]="'employeeMapping'"
[isDisabled]="isEmployeeMappingDisabled()">
</app-configuration-select-field>
<app-configuration-select-field
[form]="employeeSettingForm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,53 @@
this.windowReference = this.windowService.nativeWindow;
}

isEmployeeMappingDisabled(): boolean {
const exportType = this.exportSettingForm.get('reimbursableExportType')?.value;
return exportType === QBOReimbursableExpensesObject.BILL ||

Check failure on line 151 in src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
exportType === QBOReimbursableExpensesObject.CHECK ||
exportType === QBOReimbursableExpensesObject.EXPENSE;
}

setupExportTypeWatcher(): void {
this.exportSettingForm.get('reimbursableExportType')?.valueChanges.subscribe((exportType) => {
const employeeMappingControl = this.employeeSettingForm.get('employeeMapping');

Check failure on line 159 in src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
if (exportType === QBOReimbursableExpensesObject.BILL) {
employeeMappingControl?.patchValue(EmployeeFieldMapping.VENDOR);
employeeMappingControl?.disable();
} else if (exportType === QBOReimbursableExpensesObject.CHECK) {
employeeMappingControl?.patchValue(EmployeeFieldMapping.EMPLOYEE);
employeeMappingControl?.disable();
} else if (exportType === QBOReimbursableExpensesObject.EXPENSE) {
employeeMappingControl?.patchValue(EmployeeFieldMapping.EMPLOYEE);
employeeMappingControl?.enable();
} else if (exportType === QBOReimbursableExpensesObject.JOURNAL_ENTRY) {
employeeMappingControl?.enable();
}
});
}

getAllReimbursableExportTypeOptions(): SelectFormOption[] {
return [
{
label: 'Check',
value: QBOReimbursableExpensesObject.CHECK
},
{
label: 'Bill',
value: QBOReimbursableExpensesObject.BILL
},
{
label: 'Expense',
value: QBOReimbursableExpensesObject.EXPENSE
},
{
label: 'Journal Entry',
value: QBOReimbursableExpensesObject.JOURNAL_ENTRY
}
];
}
Comment on lines +173 to +192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Move export type options to model class

The export type options should be moved to the QBOExportSettingModel class for better organization and maintainability.

Consider moving this logic to the model:

-getAllReimbursableExportTypeOptions(): SelectFormOption[] {
-  return [
-    {
-      label: 'Check',
-      value: QBOReimbursableExpensesObject.CHECK
-    },
-    {
-      label: 'Bill',
-      value: QBOReimbursableExpensesObject.BILL
-    },
-    {
-      label: 'Expense',
-      value: QBOReimbursableExpensesObject.EXPENSE
-    },
-    {
-      label: 'Journal Entry',
-      value: QBOReimbursableExpensesObject.JOURNAL_ENTRY
-    }
-  ];
-}

And in QBOExportSettingModel:

static getAllReimbursableExportTypeOptions(): SelectFormOption[] {
  return Object.values(QBOReimbursableExpensesObject).map(value => ({
    label: value.replace(/_/g, ' ').toLowerCase()
      .replace(/\b\w/g, l => l.toUpperCase()),
    value
  }));
}


constructPayloadAndSave(data: ConfigurationWarningOut): void {
this.isConfirmationDialogVisible = false;
if (data.hasAccepted) {
Expand Down Expand Up @@ -484,10 +531,9 @@

this.isMultilineOption = brandingConfig.brandId !== 'co' ? true : false;

this.setupExportTypeWatcher();
this.setupCustomWatchers();

this.setupCustomDateOptionWatchers();

this.optionSearchWatcher();

this.exportSettingService.setExportTypeValidatorsAndWatchers(exportModuleRule, this.exportSettingForm);
Expand Down
Loading