Skip to content

Commit

Permalink
fix bugs (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed Dec 12, 2024
1 parent 51694ef commit a9425c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/app/core/models/common/advanced-settings.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { FormControl, FormGroup } from "@angular/forms";
import { JoinOption, Operator } from "../enum/enum.model";
import { AppName, JoinOption, Operator } from "../enum/enum.model";
import { environment } from "src/environments/environment";
import { ExportSettingGet } from "../intacct/intacct-configuration/export-settings.model";
import { QBOExportSettingGet } from "../qbo/qbo-configuration/qbo-export-setting.model";
import { NetSuiteExportSettingGet } from "../netsuite/netsuite-configuration/netsuite-export-setting.model";
import { IntacctConfiguration } from "../db/configuration.model";

export type EmailOption = {
email: string;
Expand Down Expand Up @@ -75,17 +76,19 @@ export class AdvancedSettingsModel {
return ['employee_email', 'employee_name', 'merchant', 'purpose', 'category', 'spent_on', 'report_number', 'expense_link', 'card_number'];
}

static getMemoOptions(exportSettings: ExportSettingGet | NetSuiteExportSettingGet | QBOExportSettingGet, appName: string): string[] {
static getMemoOptions(exportSettings: IntacctConfiguration | ExportSettingGet | NetSuiteExportSettingGet | QBOExportSettingGet, appName: string): string[] {
const defaultOptions = this.getDefaultMemoOptions();
let cccExportType: string | undefined;
// Handle both configurations and configuration properties
if ('configurations' in exportSettings) {
if (appName === AppName.INTACCT) {
cccExportType = (exportSettings as IntacctConfiguration).corporate_credit_card_expenses_object ?? undefined;
} else if ('configurations' in exportSettings) {
cccExportType = exportSettings.configurations?.corporate_credit_card_expenses_object ?? undefined;
} else if ('workspace_general_settings' in exportSettings) {
cccExportType = exportSettings.workspace_general_settings?.corporate_credit_card_expenses_object ?? undefined;
}
// Filter out options based on cccExportType and appName
if (cccExportType && ['netsuite', 'qbo', 'sage intacct'].includes(appName.toLowerCase())) {
if (cccExportType && ['netsuite', 'quickbooks online', 'sage intacct'].includes(appName.toLowerCase())) {
return defaultOptions; // Allow all options including 'card_number'
}
return defaultOptions.filter(option => option !== 'card_number'); // Omit 'card_number' for other apps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class IntacctAdvancedSettingsComponent implements OnInit {

private sessionStartTime = new Date();

defaultMemoFields: string[] = ['employee_email', 'merchant', 'purpose', 'category', 'spent_on', 'report_number', 'expense_link'];
defaultMemoFields: string[] = AdvancedSettingsModel.getDefaultMemoOptions();

paymentSyncOptions: AdvancedSettingFormOption[] = [
{
Expand Down Expand Up @@ -313,6 +313,7 @@ export class IntacctAdvancedSettingsComponent implements OnInit {
if (this.advancedSettings.workspace_schedules?.additional_email_options) {
this.adminEmails = this.adminEmails.concat(this.advancedSettings.workspace_schedules?.additional_email_options);
}
this.defaultMemoFields = AdvancedSettingsModel.getMemoOptions(configuration, AppName.INTACCT);
this.initializeAdvancedSettingsFormWithData(!!expenseFilter.count);
this.initializeSkipExportForm();
this.isLoading = false;
Expand Down

0 comments on commit a9425c7

Please sign in to comment.