Skip to content

Commit

Permalink
Fix export setting dropdown option set for new orgs (#922)
Browse files Browse the repository at this point in the history
* Fix export setting dropdown option set for new orgs

* lint
  • Loading branch information
ashwin1111 authored Aug 21, 2024
1 parent b78cfdf commit 0550917
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,19 @@ export class BusinessCentralExportSettingsComponent implements OnInit {
]).subscribe(([exportSettingsResponse, accounts, vendors]) => {
this.exportSettings = exportSettingsResponse;

this.helperService.addDestinationAttributeIfNotExists({
options: accounts.results,
value: exportSettingsResponse?.default_bank_account_name,
destination_id: exportSettingsResponse?.default_bank_account_id
});

if (exportSettingsResponse) {
this.helperService.addDestinationAttributeIfNotExists({
options: accounts.results,
value: exportSettingsResponse?.default_bank_account_name,
destination_id: exportSettingsResponse?.default_bank_account_id
});

this.helperService.addDestinationAttributeIfNotExists({
options: vendors.results,
value: exportSettingsResponse?.default_vendor_name,
destination_id: exportSettingsResponse?.default_vendor_id
});
this.helperService.addDestinationAttributeIfNotExists({
options: vendors.results,
value: exportSettingsResponse?.default_vendor_name,
destination_id: exportSettingsResponse?.default_vendor_id
});
}

this.exportSettingForm = BusinessCentralExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, accounts.results, vendors.results);
this.helperService.addExportSettingFormValidator(this.exportSettingForm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,12 @@ export class NetsuiteExportSettingsComponent implements OnInit {
}

addMissingOptions() {
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.reimbursable_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.cccAccounts, newOption: this.exportSettings.general_mappings.default_ccc_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.accountsPayables, newOption: this.exportSettings.general_mappings.accounts_payable});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.creditCardVendors, newOption: this.exportSettings.general_mappings.default_ccc_vendor});
if (this.exportSettings.general_mappings) {
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.reimbursable_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.cccAccounts, newOption: this.exportSettings.general_mappings.default_ccc_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.accountsPayables, newOption: this.exportSettings.general_mappings.accounts_payable});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.creditCardVendors, newOption: this.exportSettings.general_mappings.default_ccc_vendor});
}
}

private getSettingsAndSetupForm(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,16 @@ export class QboExportSettingsComponent implements OnInit {
}

private addMissingOptions() {
// Since pagination call doesn't return all results for options, we're making use of the export settings API to fill in options
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.bank_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.expenseAccounts, newOption: this.exportSettings.general_mappings.qbo_expense_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.accountsPayables, newOption: this.exportSettings.general_mappings.accounts_payable});

this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.cccAccounts, newOption: this.exportSettings.general_mappings.default_ccc_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.default_debit_card_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.vendors, newOption: this.exportSettings.general_mappings.default_ccc_vendor});
if (this.exportSettings.general_mappings) {
// Since pagination call doesn't return all results for options, we're making use of the export settings API to fill in options
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.bank_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.expenseAccounts, newOption: this.exportSettings.general_mappings.qbo_expense_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.accountsPayables, newOption: this.exportSettings.general_mappings.accounts_payable});

this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.cccAccounts, newOption: this.exportSettings.general_mappings.default_ccc_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.bankAccounts, newOption: this.exportSettings.general_mappings.default_debit_card_account});
this.helperService.addDefaultDestinationAttributeIfNotExists({options: this.vendors, newOption: this.exportSettings.general_mappings.default_ccc_vendor});
}
}

private getSettingsAndSetupForm(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ export class Sage300ExportSettingsComponent implements OnInit {
this.creditCardAccountOptions = this.debitCardAccountOptions = this.accountsPayableOptions = accounts.results;
this.sage300Jobs = jobs.results;

this.addMissingOptions();
if (exportSettingsResponse) {
this.addMissingOptions();
}
this.exportSettingForm = ExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, vendors.results, accounts.results, jobs.results);

this.helperService.addExportSettingFormValidator(this.exportSettingForm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,13 @@ export class XeroExportSettingsComponent implements OnInit {
this.exportSettings = exportSettings;
this.bankAccounts = bankAccounts.results;

this.helperService.addDestinationAttributeIfNotExists({
options: this.bankAccounts,
destination_id: this.exportSettings.general_mappings.bank_account.id,
value: this.exportSettings.general_mappings.bank_account.name
});
if (this.exportSettings.general_mappings) {
this.helperService.addDestinationAttributeIfNotExists({
options: this.bankAccounts,
destination_id: this.exportSettings.general_mappings.bank_account.id,
value: this.exportSettings.general_mappings.bank_account.name
});
}
this.exportSettingForm = XeroExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, this.bankAccounts);
if (!this.brandingFeatureConfig.featureFlags.exportSettings.reimbursableExpenses) {
this.exportSettingForm.controls.creditCardExpense.patchValue(true);
Expand Down

0 comments on commit 0550917

Please sign in to comment.