Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -11,10 +11,6 @@ const routes: Routes = [
path: '',
component: QboConfigurationComponent,
children: [
{
path: 'employee_settings',
component: QboEmployeeSettingsComponent
},
{
path: 'export_settings',
component: QboExportSettingsComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class QboConfigurationComponent implements OnInit {
readonly brandingContent = brandingContent.configuration;

modules: MenuItem[] = [
{label: 'Map Employees', routerLink: '/integrations/qbo/main/configuration/employee_settings'},
{label: this.brandingContent.exportSetting.stepName, routerLink: '/integrations/qbo/main/configuration/export_settings'},
{label: this.brandingContent.importSetting.stepName, routerLink: '/integrations/qbo/main/configuration/import_settings'},
{label: this.brandingContent.advancedSettings.stepName, routerLink: '/integrations/qbo/main/configuration/advanced_settings'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
(refreshDimension)="refreshDimensions()">
</app-configuration-step-header>
</div>
<form [formGroup]="employeeSettingForm">
<div class="tw-p-24-px">
<app-configuration-select-field
[form]="employeeSettingForm"
[isFieldMandatory]="true"
[formControllerName]="'employeeMapping'"
[options]="employeeMappingOptions"
[label]="'How are your Employees represented in QuickBooks Online?'"
[placeholder]="'Select representation'"
[tooltipText]="'Select how you represent your employees in QuickBooks Online'">
</app-configuration-select-field>

<app-configuration-select-field
[form]="employeeSettingForm"
[formControllerName]="'autoMapEmployee'"
[options]="autoMapEmployeeOptions"
[label]="'How should Employees in ' + brandingConfig.brandName + ' be matched to Employees/Vendors in QuickBooks Online?'"
[placeholder]="'Select matching preference'"
[tooltipText]="'Automatically map employees based on a unique parameter'">
</app-configuration-select-field>
</div>
</form>
<form [formGroup]="exportSettingForm">
<div class="tw-p-24-px" [ngClass]="{'tw-pt-0': !brandingFeatureConfig.featureFlags.exportSettings.reimbursableExpenses}">
<div *ngIf="brandingFeatureConfig.featureFlags.exportSettings.reimbursableExpenses" class="tw-mb-16-px">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Observable, Subject, debounceTime, filter, forkJoin } from 'rxjs';
import { brandingConfig, brandingContent, brandingFeatureConfig, brandingKbArticles } from 'src/app/branding/branding-config';
import { ExportSettingModel, ExportSettingOptionSearch } from 'src/app/core/models/common/export-settings.model';
import { SelectFormOption } from 'src/app/core/models/common/select-form-option.model';
import { DefaultDestinationAttribute, PaginatedDestinationAttribute } from 'src/app/core/models/db/destination-attribute.model';
import { AppName, ConfigurationCta, ConfigurationWarningEvent, EmployeeFieldMapping, ExpenseGroupingFieldOption, QBOCorporateCreditCardExpensesObject, QBOOnboardingState, QBOReimbursableExpensesObject, QboExportSettingDestinationOptionKey, ToastSeverity } from 'src/app/core/models/enum/enum.model';
import { DefaultDestinationAttribute, DestinationAttribute, PaginatedDestinationAttribute } from 'src/app/core/models/db/destination-attribute.model';
import { AppName, ConfigurationCta, ConfigurationWarningEvent, EmployeeFieldMapping, ExpenseGroupingFieldOption, FyleField, QBOCorporateCreditCardExpensesObject, QBOOnboardingState, QBOReimbursableExpensesObject, QboExportSettingDestinationOptionKey, ToastSeverity } from 'src/app/core/models/enum/enum.model';
import { ConfigurationWarningOut } from 'src/app/core/models/misc/configuration-warning.model';
import { QBOExportSettingGet, QBOExportSettingModel } from 'src/app/core/models/qbo/qbo-configuration/qbo-export-setting.model';
import { HelperService } from 'src/app/core/services/common/helper.service';
Expand All @@ -16,6 +16,10 @@
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { QboExportSettingsService } from 'src/app/core/services/qbo/qbo-configuration/qbo-export-settings.service';
import { QboHelperService } from 'src/app/core/services/qbo/qbo-core/qbo-helper.service';
// Add to existing imports
import { EmployeeSettingModel } from 'src/app/core/models/common/employee-settings.model';
import { QBOEmployeeSettingGet, QBOEmployeeSettingModel } from 'src/app/core/models/qbo/qbo-configuration/qbo-employee-setting.model';
import { QboEmployeeSettingsService } from 'src/app/core/services/qbo/qbo-configuration/qbo-employee-settings.service';

@Component({
selector: 'app-qbo-export-settings',
Expand Down Expand Up @@ -114,6 +118,14 @@
readonly brandingContent = brandingContent.configuration.exportSetting;

isMultilineOption: boolean;

Check failure on line 121 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
//Employee settings

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

View workflow job for this annotation

GitHub Actions / lint

Expected space or tab after '//' in comment
employeeSettingForm: FormGroup;
employeeMappingOptions: SelectFormOption[] = EmployeeSettingModel.getEmployeeFieldMappingOptions();

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

View workflow job for this annotation

GitHub Actions / lint

Expected blank line between class members
autoMapEmployeeOptions: SelectFormOption[] = QBOEmployeeSettingModel.getAutoMapEmployeeOptions();

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

View workflow job for this annotation

GitHub Actions / lint

Expected blank line between class members
employeeSetting: QBOEmployeeSettingGet;

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

View workflow job for this annotation

GitHub Actions / lint

Expected blank line between class members
existingEmployeeFieldMapping: EmployeeFieldMapping;

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

View workflow job for this annotation

GitHub Actions / lint

Expected blank line between class members
liveEntityExample: {[FyleField.EMPLOYEE]: string | undefined, [FyleField.VENDOR]: string | undefined};

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

View workflow job for this annotation

GitHub Actions / lint

Expected blank line between class members

constructor(
private exportSettingService: QboExportSettingsService,
Expand All @@ -123,7 +135,8 @@
private router: Router,
private toastService: IntegrationsToastService,
private windowService: WindowService,
private workspaceService: WorkspaceService
private workspaceService: WorkspaceService,
private employeeSettingService: QboEmployeeSettingsService
) {
this.windowReference = this.windowService.nativeWindow;
}
Expand All @@ -133,23 +146,31 @@
if (data.hasAccepted) {
this.isSaveInProgress = true;
const exportSettingPayload = QBOExportSettingModel.constructPayload(this.exportSettingForm);
this.exportSettingService.postExportSettings(exportSettingPayload).subscribe((response: QBOExportSettingGet) => {
const employeeSettingPayload = QBOEmployeeSettingModel.constructPayload(this.employeeSettingForm);
forkJoin([
this.employeeSettingService.postEmployeeSettings(employeeSettingPayload),
this.exportSettingService.postExportSettings(exportSettingPayload)
]).subscribe(() => {
this.isSaveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Export settings saved successfully');

this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Settings saved successfully');
if (this.isOnboarding) {
this.workspaceService.setOnboardingState(QBOOnboardingState.IMPORT_SETTINGS);
this.router.navigate([`/integrations/qbo/onboarding/import_settings`]);
} else if (this.isAdvancedSettingAffected()) {
this.router.navigate(['/integrations/qbo/main/configuration/advanced_settings']);
this.router.navigate(['/integrations/qbo/onboarding/import_settings']);
}
}, () => {
this.isSaveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Error saving export settings, please try again later');
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Error saving settings, please try again later');
});
}
}

private setLiveEntityExample(destinationAttributes: DestinationAttribute[]): void {
this.liveEntityExample = {
[FyleField.EMPLOYEE]: destinationAttributes.find((attribute: DestinationAttribute) => attribute.attribute_type === FyleField.EMPLOYEE)?.value,
[FyleField.VENDOR]: destinationAttributes.find((attribute: DestinationAttribute) => attribute.attribute_type === FyleField.VENDOR)?.value
};
}

navigateToPreviousStep(): void {
if (brandingFeatureConfig.featureFlags.mapEmployees) {
this.router.navigate([`/integrations/qbo/onboarding/employee_settings`]);
Expand Down Expand Up @@ -410,12 +431,14 @@
forkJoin([
this.exportSettingService.getExportSettings(),
this.workspaceService.getWorkspaceGeneralSettings(),
...groupedAttributes
]).subscribe(([exportSetting, workspaceGeneralSettings, bankAccounts, cccAccounts, accountsPayables, vendors]) => {
this.employeeSettingService.getEmployeeSettings(),
this.employeeSettingService.getDistinctQBODestinationAttributes([FyleField.EMPLOYEE, FyleField.VENDOR]),
...groupedAttributes,

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma
]).subscribe(([exportSetting, workspaceGeneralSettings, employeeSettings, destinationAttributes, bankAccounts, cccAccounts, accountsPayables, vendors]) => {

this.exportSettings = exportSetting;
this.employeeFieldMapping = workspaceGeneralSettings.employee_field_mapping;

this.employeeFieldMapping = employeeSettings.workspace_general_settings.employee_field_mapping;
this.setLiveEntityExample(destinationAttributes);
this.bankAccounts = bankAccounts.results.map((option) => QBOExportSettingModel.formatGeneralMappingPayload(option));
this.cccAccounts = cccAccounts.results.map((option) => QBOExportSettingModel.formatGeneralMappingPayload(option));
this.accountsPayables = accountsPayables.results.map((option) => QBOExportSettingModel.formatGeneralMappingPayload(option));
Expand All @@ -429,7 +452,11 @@

this.addMissingOptions();
this.exportSettingForm = QBOExportSettingModel.mapAPIResponseToFormGroup(this.exportSettings, this.employeeFieldMapping);

this.employeeSettingForm = new FormGroup({
employeeMapping: new FormControl(this.existingEmployeeFieldMapping, Validators.required),
autoMapEmployee: new FormControl(employeeSettings.workspace_general_settings?.auto_map_employees),
searchOption: new FormControl('')
});
if (!this.brandingFeatureConfig.featureFlags.exportSettings.reimbursableExpenses) {
this.exportSettingForm.controls.creditCardExpense.patchValue(true);
}
Expand Down
Loading