Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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 @@ -137,7 +137,7 @@ export class NetsuiteAdvancedSettingModel extends HelperUtility {
netsuiteClass: new FormControl(advancedSettings?.general_mappings.netsuite_class?.id ? advancedSettings?.general_mappings.netsuite_class : null),
netsuiteClassLevel: new FormControl(advancedSettings?.general_mappings.netsuite_class_level ? findObjectByDestinationId(advancedSettings?.general_mappings.netsuite_class_level) : this.getDefaultLevelOptions()[0]),
useEmployeeClass: new FormControl(advancedSettings?.general_mappings.use_employee_class ? advancedSettings?.general_mappings.use_employee_class : false),
changeAccountingPeriod: new FormControl(advancedSettings?.configuration.change_accounting_period),
changeAccountingPeriod: new FormControl(shouldEnableAccountingPeriod ? true : advancedSettings?.configuration.change_accounting_period),
autoCreateVendors: new FormControl(advancedSettings?.configuration.auto_create_destination_entity),
singleCreditLineJE: new FormControl(advancedSettings?.configuration.je_single_credit_line),
exportSchedule: new FormControl(advancedSettings?.workspace_schedules?.enabled ? true : false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class QBOAdvancedSettingModel extends HelperUtility {
return new FormGroup({
paymentSync: new FormControl(advancedSettings?.workspace_general_settings.sync_fyle_to_qbo_payments ? QBOPaymentSyncDirection.FYLE_TO_QBO : advancedSettings?.workspace_general_settings.sync_qbo_to_fyle_payments ? QBOPaymentSyncDirection.QBO_TO_FYLE : null),
billPaymentAccount: new FormControl(advancedSettings?.general_mappings.bill_payment_account?.id ? advancedSettings?.general_mappings.bill_payment_account : null),
changeAccountingPeriod: new FormControl(advancedSettings?.workspace_general_settings.change_accounting_period),
changeAccountingPeriod: new FormControl(shouldEnableAccountingPeriod ? true : advancedSettings?.workspace_general_settings.change_accounting_period),
singleCreditLineJE: new FormControl(advancedSettings?.workspace_general_settings.je_single_credit_line),
autoCreateVendors: new FormControl(advancedSettings?.workspace_general_settings.auto_create_destination_entity),
autoCreateMerchantsAsVendors: new FormControl(advancedSettings?.workspace_general_settings.auto_create_merchants_as_vendors),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class XeroAdvancedSettingModel extends HelperUtility{
});
}

static mapAPIResponseToFormGroup(advancedSettings: XeroAdvancedSettingGet, adminEmails: EmailOption[], destinationAttribute: DestinationAttribute[]): FormGroup {
static mapAPIResponseToFormGroup(advancedSettings: XeroAdvancedSettingGet, adminEmails: EmailOption[], destinationAttribute: DestinationAttribute[], shouldEnableAccountingPeriod: boolean): FormGroup {
let paymentSync = '';
if (advancedSettings.workspace_general_settings.sync_fyle_to_xero_payments) {
paymentSync = PaymentSyncDirection.FYLE_TO_XERO;
Expand All @@ -106,7 +106,7 @@ export class XeroAdvancedSettingModel extends HelperUtility{
return new FormGroup({
paymentSync: new FormControl(paymentSync),
billPaymentAccount: new FormControl(advancedSettings.general_mappings.payment_account.id ? findObjectByDestinationId(destinationAttribute, advancedSettings.general_mappings.payment_account.id) : null),
changeAccountingPeriod: new FormControl(advancedSettings.workspace_general_settings.change_accounting_period),
changeAccountingPeriod: new FormControl(shouldEnableAccountingPeriod ? true : advancedSettings.workspace_general_settings.change_accounting_period),
autoCreateVendors: new FormControl(advancedSettings.workspace_general_settings.auto_create_destination_entity),
exportSchedule: new FormControl(advancedSettings.workspace_schedules?.enabled ? true : false),
exportScheduleFrequency: new FormControl(advancedSettings.workspace_schedules?.enabled ? advancedSettings.workspace_schedules.interval_hours : 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { ConditionField, ExpenseFilterResponse } from 'src/app/core/models/commo
import { EmailOption, SelectFormOption } from 'src/app/core/models/common/select-form-option.model';
import { DestinationAttribute } from 'src/app/core/models/db/destination-attribute.model';
import { AppName, ConfigurationCta, ToastSeverity, XeroFyleField, XeroOnboardingState } from 'src/app/core/models/enum/enum.model';
import { Org } from 'src/app/core/models/org/org.model';
import { XeroWorkspaceGeneralSetting } from 'src/app/core/models/xero/db/xero-workspace-general-setting.model';
import { XeroAdvancedSettingGet, XeroAdvancedSettingModel } from 'src/app/core/models/xero/xero-configuration/xero-advanced-settings.model';
import { HelperService } from 'src/app/core/services/common/helper.service';
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
import { MappingService } from 'src/app/core/services/common/mapping.service';
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { OrgService } from 'src/app/core/services/org/org.service';
import { XeroAdvancedSettingsService } from 'src/app/core/services/xero/xero-configuration/xero-advanced-settings.service';
import { XeroHelperService } from 'src/app/core/services/xero/xero-core/xero-helper.service';

Expand Down Expand Up @@ -46,6 +49,8 @@ export class XeroAdvancedSettingsComponent implements OnInit {

paymentSyncOptions: SelectFormOption[] = XeroAdvancedSettingModel.getPaymentSyncOptions();

org: Org = this.orgService.getCachedOrg();

hours: SelectFormOption[] = [...Array(24).keys()].map(day => {
return {
label: (day + 1).toString(),
Expand All @@ -68,7 +73,9 @@ export class XeroAdvancedSettingsComponent implements OnInit {
private workspaceService: WorkspaceService,
private xeroHelperService: XeroHelperService,
private mappingService: MappingService,
private toastService: IntegrationsToastService
private toastService: IntegrationsToastService,
private orgService: OrgService,
private helperService: HelperService
) { }

navigateToPreviousStep(): void {
Expand Down Expand Up @@ -114,8 +121,7 @@ export class XeroAdvancedSettingsComponent implements OnInit {
this.billPaymentAccounts = response[1];
this.workspaceGeneralSettings = response[2];
this.adminEmails = this.advancedSettings.workspace_schedules?.additional_email_options ? this.advancedSettings.workspace_schedules?.additional_email_options.concat(response[3]).flat() : response[3];

this.advancedSettingForm = XeroAdvancedSettingModel.mapAPIResponseToFormGroup(this.advancedSettings, this.adminEmails, this.billPaymentAccounts);
this.advancedSettingForm = XeroAdvancedSettingModel.mapAPIResponseToFormGroup(this.advancedSettings, this.adminEmails, this.billPaymentAccounts, this.helperService.shouldAutoEnableAccountingPeriod(this.org.created_at));

this.setupFormWatchers();
this.isLoading = false;
Expand Down
Loading