Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: intacct code prepend fixes #965

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -41,6 +41,7 @@
[destinationFieldMap]="destinationFieldMap"
[isCategoryMappingGeneric]="false"
[destinationOptionsVersion]="'v1'"
[importCodeFields]="acceptedCodeField"
[errorsVersion]="'v1'">
</app-dashboard-error-section>
</div>
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { Observable, catchError, forkJoin, from, interval, map, of, switchMap, takeWhile } from 'rxjs';
import { Observable, catchError, forkJoin, from, interval, of, switchMap, takeWhile } from 'rxjs';
import { brandingConfig, brandingFeatureConfig } from 'src/app/branding/branding-config';
import { AccountingErrorType, AppName, AppUrl, CCCImportState, ClickEvent, ExpenseState, ExportState, FyleField, FyleReferenceType, IntacctCategoryDestination, IntacctCorporateCreditCardExpensesObject, IntacctErrorType, IntacctReimbursableExpensesObject, RefinerSurveyType, ReimbursableImportState, TaskLogState, TaskLogType, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { ExpenseGroupSetting } from 'src/app/core/models/db/expense-group-setting.model';
import { ExpenseGroup, ExpenseGroupList, ExportableExpenseGroup } from 'src/app/core/models/intacct/db/expense-group.model';
import { AccountingErrorType, AppName, AppUrl, CCCImportState, ExpenseState, ExportState, FyleReferenceType, IntacctCategoryDestination, IntacctCorporateCreditCardExpensesObject, IntacctErrorType, IntacctReimbursableExpensesObject, MappingSourceField, ReimbursableImportState, SageIntacctField, TaskLogState, TaskLogType } from 'src/app/core/models/enum/enum.model';
import { ExpenseGroupList } from 'src/app/core/models/intacct/db/expense-group.model';
import { Expense } from 'src/app/core/models/intacct/db/expense.model';
import { LastExport } from 'src/app/core/models/intacct/db/last-export.model';
import { IntacctTaskLog, IntacctTaskResponse } from 'src/app/core/models/intacct/db/task-log.model';
import { RefinerService } from 'src/app/core/services/integration/refiner.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
import { UserService } from 'src/app/core/services/misc/user.service';
import { ExportLogService } from 'src/app/core/services/si/export-log/export-log.service';
import { SiWorkspaceService } from 'src/app/core/services/si/si-core/si-workspace.service';
import { environment } from 'src/environments/environment';
import { AccountingExportSummary, AccountingExportSummaryModel } from 'src/app/core/models/db/accounting-export-summary.model';
import { AccountingGroupedErrorStat, AccountingGroupedErrors, Error } from 'src/app/core/models/db/error.model';
import { DashboardModel, DestinationFieldMap } from 'src/app/core/models/db/dashboard.model';
Expand Down Expand Up @@ -91,6 +86,8 @@ export class IntacctDashboardComponent implements OnInit {

destinationFieldMap : DestinationFieldMap;

acceptedCodeField: string[] = [SageIntacctField.ACCOUNT, SageIntacctField.DEPARTMENT, MappingSourceField.PROJECT, IntacctCategoryDestination.EXPENSE_TYPE];

readonly dummyExpenseGroupList: ExpenseGroupList[] = [{
index: 0,
exportedAt: new Date(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class IntacctBaseMappingComponent implements OnInit {

cccExpenseObject: IntacctCorporateCreditCardExpensesObject | null;

acceptedCodeField: string[] = [SageIntacctField.ACCOUNT, SageIntacctField.DEPARTMENT, MappingSourceField.PROJECT];
acceptedCodeField: string[] = [SageIntacctField.ACCOUNT, SageIntacctField.DEPARTMENT, MappingSourceField.PROJECT, IntacctCategoryDestination.EXPENSE_TYPE];

brandingConfig = brandingConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ export class IntacctC1ImportSettingsComponent implements OnInit {
costTypes: [importSettings.dependent_field_settings?.cost_type_field_name ? this.dependentFieldFormValue(importSettings.dependent_field_settings.cost_type_field_name, importSettings.dependent_field_settings.cost_type_placeholder, 'costTypes') : null],
isDependentImportEnabled: [importSettings.dependent_field_settings?.is_import_enabled || false],
sageIntacctTaxCodes: [importSettings.general_mappings.default_tax_code.id || null],
expenseFields: this.formBuilder.array(this.constructFormArray())
expenseFields: this.formBuilder.array(this.constructFormArray()),
importCodeField: [importSettings.configurations.import_code_fields],
importCodeFields: this.formBuilder.array([])
});

this.importSettingWatcher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Component, Inject, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { RxwebValidators } from '@rxweb/reactive-form-validators';
import { InputSwitchChangeEvent } from 'primeng/inputswitch';
import { forkJoin } from 'rxjs';
import { brandingConfig, brandingFeatureConfig, brandingKbArticles } from 'src/app/branding/branding-config';
import { ImportSettingsModel } from 'src/app/core/models/common/import-settings.model';
import { IntacctCategoryDestination, ConfigurationCta, IntacctOnboardingState, IntacctUpdateEvent, Page, ProgressPhase, ToastSeverity, MappingSourceField, AppName, TrackingApp, DefaultImportFields, SageIntacctField } from 'src/app/core/models/enum/enum.model';
import { IntacctCategoryDestination, ConfigurationCta, IntacctOnboardingState, IntacctUpdateEvent, Page, ProgressPhase, ToastSeverity, MappingSourceField, AppName, TrackingApp, SageIntacctField, IntacctReimbursableExpensesObject, IntacctCorporateCreditCardExpensesObject } from 'src/app/core/models/enum/enum.model';
import { IntacctDestinationAttribute } from 'src/app/core/models/intacct/db/destination-attribute.model';
import { ExpenseField } from 'src/app/core/models/intacct/db/expense-field.model';
import { LocationEntityMapping } from 'src/app/core/models/intacct/db/location-entity-mapping.model';
Expand Down Expand Up @@ -260,7 +259,7 @@ export class IntacctImportSettingsComponent implements OnInit {
const defaultFieldData: MappingSetting = {
source_field: '',
destination_field: '',
import_to_fyle: true,
import_to_fyle: false,
is_custom: false,
source_placeholder: null
};
Expand Down Expand Up @@ -299,6 +298,7 @@ export class IntacctImportSettingsComponent implements OnInit {
this.customFieldControl.disable();
this.customFieldForDependentField = false;
} else {
this.addImportCodeField({checked: true}, this.customFieldControl.get('destination_field')?.value);
this.customField = {
attribute_type: this.customFieldForm.value.attribute_type.split(' ').join('_').toUpperCase(),
display_name: this.customFieldForm.value.attribute_type,
Expand Down Expand Up @@ -506,6 +506,9 @@ export class IntacctImportSettingsComponent implements OnInit {

// Get the 'import_to_fyle' control at the specified index and disable it
(this.importSettingsForm.get('expenseFields') as FormArray).at(index)?.get('import_to_fyle')?.disable();
} else {
(this.importSettingsForm.get('expenseFields') as FormArray).at(index)?.get('import_to_fyle')?.setValue(true);
this.addImportCodeField({checked: true}, (this.importSettingsForm.get('expenseFields') as FormArray).at(index)?.get('destination_field')?.value);
}

if (selectedValue === 'custom_field') {
Expand Down Expand Up @@ -552,7 +555,12 @@ export class IntacctImportSettingsComponent implements OnInit {
this.fyleFields = this.fyleFields.filter(field => !field.is_dependent);
}

if (this.importSettings.configurations.import_code_fields.length > 0 && !this.importSettings.configurations.import_code_fields.includes(this.intacctCategoryDestination) && this.intacctImportCodeConfig[this.intacctCategoryDestination] && this.importSettings.configurations.import_categories) {
let sourceField = this.intacctCategoryDestination;
if (sourceField === IntacctCategoryDestination.GL_ACCOUNT) {
sourceField = IntacctCategoryDestination.ACCOUNT;
}

if (this.importSettings.configurations.import_code_fields && this.importSettings.configurations.import_code_fields.length > 0 && !this.importSettings.configurations.import_code_fields.includes(sourceField) && this.intacctImportCodeConfig[sourceField] && this.importSettings.configurations.import_categories) {
this.addImportCodeField({checked: true}, this.intacctCategoryDestination);
}

Expand Down Expand Up @@ -634,7 +642,7 @@ export class IntacctImportSettingsComponent implements OnInit {
}
}

if (configuration.employee_field_mapping==='EMPLOYEE') {
if (configuration.reimbursable_expenses_object === IntacctReimbursableExpensesObject.EXPENSE_REPORT || configuration.corporate_credit_card_expenses_object === IntacctCorporateCreditCardExpensesObject.EXPENSE_REPORT) {
this.intacctCategoryDestination = IntacctCategoryDestination.EXPENSE_TYPE;
} else {
this.intacctCategoryDestination = IntacctCategoryDestination.GL_ACCOUNT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div>
<div>
<app-card-mapping-header *ngIf="mappings" (triggerAutoMapEmployee)="triggerAutoMapEmployees()" [sourceField]="sourceField" [showAutoMapEmployee]="showAutoMapEmployee" [mappingStats]="mappingStats" (triggerAutoMapEmployee)="triggerAutoMapEmployees"></app-card-mapping-header>
<app-card-mapping-header *ngIf="mappings" (triggerAutoMapEmployee)="triggerAutoMapEmployees()" [sourceField]="sourceType" [showAutoMapEmployee]="showAutoMapEmployee" [mappingStats]="mappingStats" (triggerAutoMapEmployee)="triggerAutoMapEmployees()"></app-card-mapping-header>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

affects all app, please test mapping page for every integration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, tested @ashwin1111 all are working fine

</div>

<div class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-border-tertiary tw-mt-16-px" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export class MappingCardHeaderComponent implements OnInit {
destinationField = new SnakeCaseToSpaceCasePipe().transform(destinationField).toLowerCase();
const lastChar = destinationField.slice(-1).toLowerCase();
const lastTwoChars = destinationField.slice(-2).toLowerCase();
const pattern = new RegExp('[^a-zA-Z\d\s:]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are we doing here?


if (lastChar === 'y') {
return destinationField.slice(0, -1) + 'ies';
} else if (['s', 'x', 'z'].includes(lastChar) || ['sh', 'ch'].includes(lastTwoChars)) {
return destinationField + 'es';
} else if (pattern.test(lastChar)) {
return destinationField;
}
return destinationField + 's';
}
Expand Down
Loading