Skip to content

Commit

Permalink
qbo prepend code changes (#933)
Browse files Browse the repository at this point in the history
* qbo prepend code changes
  • Loading branch information
DhaaraniCIT authored and Hrishabh17 committed Sep 4, 2024
1 parent 0482202 commit 40759a3
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type QBOImportSettingWorkspaceGeneralSetting = {
import_vendors_as_merchants: boolean,
charts_of_accounts: string[],
import_tax_codes: boolean,
import_code_fields?: string[]
import_code_fields: string[]
}

export type QBOImportSettingGeneralMapping = {
Expand Down Expand Up @@ -54,8 +54,7 @@ export class QBOImportSettingModel extends ImportSettingsModel {
defaultTaxCode: new FormControl(importSettings?.general_mappings?.default_tax_code?.id ? importSettings.general_mappings.default_tax_code : null),
searchOption: new FormControl(''),
importCodeFields: new FormControl( importSettings?.workspace_general_settings?.import_code_fields ? importSettings.workspace_general_settings.import_code_fields : null),
// ImportCategoryCode: new FormControl(this.getImportCodeField(importCode, 'ACCOUNT', qboImportCodeFieldCodeConfig))
importCategoryCode: new FormControl(null)
importCategoryCode: new FormControl(this.getImportCodeField(importCode, 'ACCOUNT', qboImportCodeFieldCodeConfig))
});
}

Expand All @@ -70,8 +69,8 @@ export class QBOImportSettingModel extends ImportSettingsModel {
import_items: importSettingsForm.get('importItems')?.value,
charts_of_accounts: importSettingsForm.get('chartOfAccountTypes')?.value,
import_tax_codes: importSettingsForm.get('taxCode')?.value,
import_vendors_as_merchants: importSettingsForm.get('importVendorsAsMerchants')?.value
// Import_code_fields: importSettingsForm.get('importCodeFields')?.value
import_vendors_as_merchants: importSettingsForm.get('importVendorsAsMerchants')?.value,
import_code_fields: importSettingsForm.get('importCodeFields')?.value
},
mapping_settings: mappingSettings,
general_mappings: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/mapping.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class MappingService {
};

if (value) {
if (appName && ([AppName.SAGE300] as string[]).includes(appName)) {
if (appName && ([AppName.SAGE300, AppName.QBO] as string[]).includes(appName)) {
params.value = value;
} else {
params.value__icontains = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
[isCategoryMappingGeneric]="true"
[isImportItemsEnabled]="isImportItemsEnabled"
[destinationOptionsVersion]="'v1'"
[importCodeFields]="importCodeFields"
[errorsVersion]="'v1'">
</app-dashboard-error-section>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class QboDashboardComponent implements OnInit {

this.isLoading = false;

this.importCodeFields = responses[6].workspace_general_settings?.import_code_fields;
this.importCodeFields = responses[6].workspace_general_settings.import_code_fields;

const queuedTasks: QBOTaskLog[] = responses[2].results.filter((task: QBOTaskLog) => task.status === TaskLogState.ENQUEUED || task.status === TaskLogState.IN_PROGRESS);
this.failedExpenseGroupCount = responses[2].results.filter((task: QBOTaskLog) => task.status === TaskLogState.FAILED || task.status === TaskLogState.FATAL).length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
[appName]="AppName.QBO"
[isCategoryMappingGeneric]="sourceField === FyleField.CATEGORY ? true : false"
[displayName]="displayName"
[isMultiLineOption]="sourceField === FyleField.CATEGORY && brandingConfig.brandId !== 'co' ? true : false"
(triggerAutoMapEmployee)="triggerAutoMapEmployees()">
</app-generic-mapping-v2>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { forkJoin } from 'rxjs';
import { brandingConfig } from 'src/app/branding/branding-config';
import { DestinationAttribute } from 'src/app/core/models/db/destination-attribute.model';
import { MappingSetting } from 'src/app/core/models/db/mapping-setting.model';
import { AccountingDisplayName, AccountingField, AppName, FyleField, QBOCorporateCreditCardExpensesObject, QBOReimbursableExpensesObject, ToastSeverity } from 'src/app/core/models/enum/enum.model';
Expand Down Expand Up @@ -41,6 +42,8 @@ export class QboBaseMappingComponent implements OnInit {

isMultiLineOption: boolean;

brandingConfig = brandingConfig;

constructor(
private route: ActivatedRoute,
private mappingService: MappingService,
Expand Down Expand Up @@ -84,7 +87,7 @@ export class QboBaseMappingComponent implements OnInit {

this.destinationField = this.getDestinationField(responses[0], responses[1].results);

// This.isMultiLineOption = responses[2].workspace_general_settings.import_code_fields?.includes(this.destinationField);
this.isMultiLineOption = responses[2].workspace_general_settings.import_code_fields?.includes(this.destinationField);

if (this.destinationField === AccountingField.ACCOUNT) {
this.displayName = responses[0].import_items ? `${AccountingDisplayName.ITEM},${AccountingDisplayName.ACCOUNT}` : AccountingDisplayName.ACCOUNT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
[tooltipText]="'By default expense will be selected. Open the dropdown to select more as per your requirements'">
</app-clone-setting-field>
</div>
<!-- <div class="clone-setting--dependent-field" *ngIf="brandingFeatureConfig.featureFlags.importSettings.allowImportCode && importSettingForm.value.importCategories && qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT]">
<div class="clone-setting--dependent-field" *ngIf="brandingFeatureConfig.featureFlags.importSettings.allowImportCode && importSettingForm.value.importCategories && qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT]">
<app-clone-setting-field
[form]="importSettingForm"
[options]="importCodeSelectorOptions[DefaultImportFields.ACCOUNT]"
Expand All @@ -323,7 +323,7 @@
[dropdownDisplayKey]="'label'"
[formControllerName]="'importCategoryCode'">
</app-clone-setting-field>
</div> -->
</div>
</div>

<div class="clone-setting--field" *ngIf="cloneSetting.export_settings.workspace_general_settings.reimbursable_expenses_object !== QBOReimbursableExpensesObject.JOURNAL_ENTRY && cloneSetting.export_settings.workspace_general_settings.corporate_credit_card_expenses_object !== QBOCorporateCreditCardExpensesObject.JOURNAL_ENTRY">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,10 @@ export class QboCloneSettingsComponent implements OnInit {
if (!isImportCategoriesEnabled) {
this.importSettingForm.controls.chartOfAccountTypes.setValue(['Expense']);
this.importSettingForm.controls.importCategoryCode.clearValidators();
// This.importSettingForm.controls.importCategoryCode.setValue(ImportSettingsModel.getImportCodeField(this.cloneSetting.import_settings.workspace_general_settings.import_code_fields, DefaultImportFields.ACCOUNT, this.cloneQboImportCodeFieldCodeConfig));
this.importSettingForm.controls.importCategoryCode.setValue(ImportSettingsModel.getImportCodeField(this.cloneSetting.import_settings.workspace_general_settings.import_code_fields, DefaultImportFields.ACCOUNT, this.cloneQboImportCodeFieldCodeConfig));
} if (isImportCategoriesEnabled) {
this.helperService.markControllerAsRequired(this.importSettingForm, 'importCategoryCode');
}
// If (isImportCategoriesEnabled) {
// This.helperService.markControllerAsRequired(this.importSettingForm, 'importCategoryCode');
// }
});
}

Expand Down Expand Up @@ -434,14 +433,14 @@ export class QboCloneSettingsComponent implements OnInit {
this.mappingService.getFyleFields('v1'),
this.qboConnectorService.getQBOCredentials(),
this.configurationService.getAdditionalEmails(),
this.qboImportSettingsService.getQBOFields()
// This.qboImportSettingsService.getImportCodeFieldConfig()
]).subscribe(([cloneSetting, destinationAttributes, fyleFieldsResponse, qboCredentials, adminEmails, qboFields]) => {
this.qboImportSettingsService.getQBOFields(),
this.qboImportSettingsService.getImportCodeFieldConfig()
]).subscribe(([cloneSetting, destinationAttributes, fyleFieldsResponse, qboCredentials, adminEmails, qboFields, qboImportCodeFieldCodeConfig]) => {

const workspaceId = +this.workspaceService.getWorkspaceId();
this.workspaceService.setWorkspaceId(cloneSetting.workspace_id);

// This.qboImportSettingsService.getImportCodeFieldConfig().subscribe((cloneQboImportCodeFieldCodeConfig) => {
this.qboImportSettingsService.getImportCodeFieldConfig().subscribe((cloneQboImportCodeFieldCodeConfig) => {
this.cloneSetting = cloneSetting;
this.workspaceService.setWorkspaceId(workspaceId);

Expand Down Expand Up @@ -488,9 +487,9 @@ export class QboCloneSettingsComponent implements OnInit {
if (qboCredentials && qboCredentials.country !== 'US') {
this.isTaxGroupSyncAllowed = true;
}
// This.qboImportCodeFieldCodeConfig = qboImportCodeFieldCodeConfig;
// This.cloneQboImportCodeFieldCodeConfig = cloneQboImportCodeFieldCodeConfig;
this.importSettingForm = QBOImportSettingModel.mapAPIResponseToFormGroup(cloneSetting.import_settings, this.qboFields, this.cloneQboImportCodeFieldCodeConfig);
this.qboImportCodeFieldCodeConfig = qboImportCodeFieldCodeConfig;
this.cloneQboImportCodeFieldCodeConfig = cloneQboImportCodeFieldCodeConfig;
this.importSettingForm = QBOImportSettingModel.mapAPIResponseToFormGroup(cloneSetting.import_settings, this.qboFields, cloneQboImportCodeFieldCodeConfig);
this.fyleFields = fyleFieldsResponse;
this.fyleFields.push({ attribute_type: 'custom_field', display_name: 'Create a Custom Field', is_dependent: false });
this.setupImportSettingFormWatcher();
Expand All @@ -509,7 +508,7 @@ export class QboCloneSettingsComponent implements OnInit {

this.isLoading = false;
});
// });
});
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
(searchOptionsDropdown)="searchOptionsDropdown($event)"
[optionLabel]="'name'"
[iconPath]="'list'"
[isMultiLineOption]="isMultilineOption"
[placeholder]="'Select bank account'"
[formControllerName]="'bankAccount'">
</app-configuration-select-field>
Expand All @@ -74,6 +75,7 @@
(searchOptionsDropdown)="searchOptionsDropdown($event)"
[optionLabel]="'name'"
[iconPath]="'list'"
[isMultiLineOption]="isMultilineOption"
[placeholder]="'Select Expense Account'"
[formControllerName]="'qboExpenseAccount'">
</app-configuration-select-field>
Expand All @@ -94,6 +96,7 @@
[subLabel]="'The integration will post the offset credit entry in ' + (exportSettingForm.value.reimbursableExportType | snakeCaseToSpaceCase | titlecase) + ' to the selected accounts payable account.'"
[iconPath]="'list'"
[placeholder]="'Select accounts payable'"
[isMultiLineOption]="isMultilineOption"
[formControllerName]="'accountsPayable'">
</app-configuration-select-field>
</div>
Expand Down Expand Up @@ -202,6 +205,7 @@
[label]="brandingContent.corporateCard.defaultCCCAccountLabel"
[subLabel]="'Post all your company corporate card transactions to a default credit card account.'"
[placeholder]="brandingContent.corporateCard.defaultCCCAccountPlaceholder"
[isMultiLineOption]="isMultilineOption"
[formControllerName]="'defaultCCCAccount'">
</app-configuration-select-field>
</div>
Expand All @@ -221,6 +225,7 @@
[label]="brandingContent.corporateCard.defaultDebitCardAccountLabel"
[subLabel]="'Post all your company debit card transactions to a default debit card account.'"
[placeholder]="brandingContent.corporateCard.defaultDebitCardAccountPlaceholder"
[isMultiLineOption]="isMultilineOption"
[formControllerName]="'defaultDebitCardAccount'">
</app-configuration-select-field>
</div>
Expand Down Expand Up @@ -259,6 +264,7 @@
[label]="brandingContent.corporateCard.accountsPayableLabel + (exportSettingForm.value.creditCardExportType | snakeCaseToSpaceCase | titlecase) + ' be posted to?'"
[subLabel]="'The integration will post the offset credit entry in ' + (exportSettingForm.value.creditCardExportType | snakeCaseToSpaceCase | titlecase) + brandingContent.corporateCard.accountsPayableSubLabel"
[placeholder]="'Select accounts payable'"
[isMultiLineOption]="isMultilineOption"
[formControllerName]="'accountsPayable'">
</app-configuration-select-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export class QboExportSettingsComponent implements OnInit {

readonly brandingContent = brandingContent.configuration.exportSetting;

isMultilineOption: boolean;

constructor(
private exportSettingService: QboExportSettingsService,
public helperService: HelperService,
Expand Down Expand Up @@ -448,6 +450,8 @@ export class QboExportSettingsComponent implements OnInit {
this.helperService.setOrClearValidators(this.exportSettings.workspace_general_settings.corporate_credit_card_expenses_object, exportSettingValidatorRule.creditCardExpense, this.exportSettingForm);
}

this.isMultilineOption = brandingConfig.brandId !== 'co' ? true : false;

this.setupCustomWatchers();

this.setupCustomDateOptionWatchers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[iconPath]="'arrow-tail-down'">
</app-configuration-toggle-field>

<div class="tw-pr-24-px tw-pl-64-px tw-pt-0 tw-pb-24-px" *ngIf="importSettingForm.value.importCategories">
<div class="tw-pr-24-px tw-pl-64-px tw-py-0" *ngIf="importSettingForm.value.importCategories" [ngClass]="{'tw-pb-24-px': !(brandingFeatureConfig.featureFlags.importSettings.allowImportCode && importSettingForm.value.importCategories && qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT])}">
<div class="tw-flex tw-justify-between tw-items-center">
<h5 class="lg:tw-w-3/5 md:tw-w-1/2 tw-text-slightly-normal-text-color tw-text-14-px !tw-font-500">
{{brandingContent.chartOfAccountTypes}}
Expand All @@ -43,7 +43,7 @@ <h5 class="lg:tw-w-3/5 md:tw-w-1/2 tw-text-slightly-normal-text-color tw-text-14
</div>
</div>

<!-- <div *ngIf="brandingFeatureConfig.featureFlags.importSettings.allowImportCode && importSettingForm.value.importCategories && qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT]">
<div *ngIf="brandingFeatureConfig.featureFlags.importSettings.allowImportCode && importSettingForm.value.importCategories && qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT]">
<app-configuration-select-field
[appName]="appName"
[form]="importSettingForm"
Expand All @@ -58,7 +58,7 @@ <h5 class="lg:tw-w-3/5 md:tw-w-1/2 tw-text-slightly-normal-text-color tw-text-14
[isDisabled]="!qboImportCodeFieldCodeConfig[DefaultImportFields.ACCOUNT]"
[formControllerName]="'importCategoryCode'">
</app-configuration-select-field>
</div> -->
</div>
</div>

<div class="tw-rounded-lg tw-border-border-tertiary tw-border tw-mt-24-px" *ngIf="workspaceGeneralSettings.reimbursable_expenses_object !== QBOReimbursableExpensesObject.JOURNAL_ENTRY && workspaceGeneralSettings.corporate_credit_card_expenses_object !== QBOCorporateCreditCardExpensesObject.JOURNAL_ENTRY">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class QboImportSettingsComponent implements OnInit {
this.importSettingService.postImportSettings(importSettingPayload).subscribe(() => {
this.isSaveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Import settings saved successfully');
// This.updateImportCodeFieldConfig();
this.updateImportCodeFieldConfig();
if (this.isOnboarding) {
this.workspaceService.setOnboardingState(QBOOnboardingState.ADVANCED_CONFIGURATION);
this.router.navigate([`/integrations/qbo/onboarding/advanced_settings`]);
Expand Down Expand Up @@ -220,11 +220,10 @@ export class QboImportSettingsComponent implements OnInit {
if (!isImportCategoriesEnabled) {
this.importSettingForm.controls.chartOfAccountTypes.setValue(['Expense']);
this.importSettingForm.controls.importCategoryCode.clearValidators();
// This.importSettingForm.controls.importCategoryCode.setValue(ImportSettingsModel.getImportCodeField(this.importSettings.workspace_general_settings.import_code_fields, DefaultImportFields.ACCOUNT, this.qboImportCodeFieldCodeConfig));
this.importSettingForm.controls.importCategoryCode.setValue(ImportSettingsModel.getImportCodeField(this.importSettings.workspace_general_settings.import_code_fields, DefaultImportFields.ACCOUNT, this.qboImportCodeFieldCodeConfig));
} if (isImportCategoriesEnabled) {
this.helper.markControllerAsRequired(this.importSettingForm, 'importCategoryCode');
}
// If (isImportCategoriesEnabled) {
// This.helper.markControllerAsRequired(this.importSettingForm, 'importCategoryCode');
// }
});
}

Expand Down Expand Up @@ -269,9 +268,9 @@ export class QboImportSettingsComponent implements OnInit {
this.workspaceService.getWorkspaceGeneralSettings(),
this.qboConnectorService.getQBOCredentials(),
this.mappingService.getDestinationAttributes(QBOField.TAX_CODE, 'v1', 'qbo'),
this.importSettingService.getQBOFields()
// This.importSettingService.getImportCodeFieldConfig()
]).subscribe(([importSettingsResponse, fyleFieldsResponse, workspaceGeneralSettings, qboCredentials, taxCodes, qboFields]) => {
this.importSettingService.getQBOFields(),
this.importSettingService.getImportCodeFieldConfig()
]).subscribe(([importSettingsResponse, fyleFieldsResponse, workspaceGeneralSettings, qboCredentials, taxCodes, qboFields, importCodeFieldConfig]) => {
this.qboFields = qboFields;
this.importSettings = importSettingsResponse;
this.workspaceGeneralSettings = workspaceGeneralSettings;
Expand All @@ -282,11 +281,11 @@ export class QboImportSettingsComponent implements OnInit {
this.isTaxGroupSyncAllowed = true;
}

// This.qboImportCodeFieldCodeConfig = importCodeFieldConfig;
this.qboImportCodeFieldCodeConfig = importCodeFieldConfig;
this.importSettingForm = QBOImportSettingModel.mapAPIResponseToFormGroup(this.importSettings, this.qboFields, this.qboImportCodeFieldCodeConfig);
this.fyleFields = fyleFieldsResponse;
this.fyleFields.push({ attribute_type: 'custom_field', display_name: 'Create a Custom Field', is_dependent: false });
// This.updateImportCodeFieldConfig();
this.updateImportCodeFieldConfig();
this.setupFormWatchers();
this.initializeCustomFieldForm(false);
this.isLoading = false;
Expand Down
Loading

0 comments on commit 40759a3

Please sign in to comment.