Skip to content

Commit

Permalink
fix: add missing options to bank accounts on page init
Browse files Browse the repository at this point in the history
  • Loading branch information
JustARatherRidiculouslyLongUsername committed Dec 11, 2024
1 parent 3e5bb9e commit c3e870b
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,29 @@ export class BusinessCentralExportSettingsComponent implements OnInit {
}
}

addMissingOptions() {
// Since pagination API response is a subset of all options, we're making use of the export settings response to fill in options

if (this.exportSettings) {
this.helperService.addDestinationAttributeIfNotExists({
options: this.bankAccountOptions,
value: this.exportSettings.default_CCC_bank_account_name,
destination_id: this.exportSettings.default_CCC_bank_account_id
});
this.helperService.addDestinationAttributeIfNotExists({
options: this.bankAccountOptions,
value: this.exportSettings.default_bank_account_name,
destination_id: this.exportSettings.default_bank_account_id
});

this.helperService.addDestinationAttributeIfNotExists({
options: this.vendorOptions,
value: this.exportSettings.default_vendor_name,
destination_id: this.exportSettings.default_vendor_id
});
}
}

private setupPage(): void {
this.isOnboarding = this.router.url.includes('onboarding');
const exportSettingValidatorRule: ExportSettingValidatorRule = {
Expand Down Expand Up @@ -308,7 +331,9 @@ export class BusinessCentralExportSettingsComponent implements OnInit {
this.vendorOptions = vendors.results;
this.bankAccountOptions = [...reimbursableBankAccounts.results, ...reimbursableAccounts.results];
this.bankAccountOptions.sort((a, b) => (a.value || '').localeCompare(b.value || ''));
this.exportSettingForm = BusinessCentralExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, accounts.results, vendors.results);
this.addMissingOptions();
this.exportSettingForm = BusinessCentralExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, this.bankAccountOptions, vendors.results);

this.helperService.addExportSettingFormValidator(this.exportSettingForm);
this.helper.setConfigurationSettingValidatorsAndWatchers(exportSettingValidatorRule, this.exportSettingForm);
this.helper.setExportTypeValidatorsAndWatchers(exportModuleRule, this.exportSettingForm, commonFormFields);
Expand Down

0 comments on commit c3e870b

Please sign in to comment.