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

fix: QBD direct bug fixes #1101

Merged
merged 10 commits into from
Dec 10, 2024
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
6 changes: 3 additions & 3 deletions src/app/core/services/common/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export class DashboardService {
return this.apiService.post(url, {});
}

getExportErrors(version?: string | 'v1', appName?: string): Observable<any> {
if (!appName && version === 'v1') {
getExportErrors(version?: string | 'v1'): Observable<any> {
if (version === 'v1') {
return this.apiService.get(`/v2/workspaces/${this.workspaceId}/errors/`, {is_resolved: false});
} else if (appName === AppName.QBD_DIRECT) {
} else if (version === AppName.QBD_DIRECT) {
return this.apiService.get(`/workspaces/${this.workspaceId}/export_logs/errors/`, {is_resolved: false});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class QbdDirectDashboardComponent implements OnInit {
[AccountingErrorType.CATEGORY_MAPPING]: null
};

getExportErrors$: Observable<ErrorResponse> = this.dashboardService.getExportErrors(undefined, AppName.QBD_DIRECT);
getExportErrors$: Observable<ErrorResponse> = this.dashboardService.getExportErrors(AppName.QBD_DIRECT);

getAccountingExportSummary$: Observable<AccountingExportSummary> = this.accountingExportService.getAccountingExportSummary(AppName.QBD_DIRECT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
[appName]="AppName.QBD_DIRECT"
[isCategoryMappingGeneric]="sourceField === FyleField.CATEGORY ? true : false"
[displayName]="displayName"
[detailAccountType] = "detailAccountType"
[isMultiLineOption]="sourceField === FyleField.CATEGORY && brandingConfig.brandId !== 'co' ? true : false">
</app-generic-mapping-v2>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class QbdDirectBaseMappingComponent implements OnInit {

chartOfAccounts: string[];

detailAccountType: string[] | undefined;

constructor(
private route: ActivatedRoute,
private mappingService: MappingService,
Expand All @@ -72,6 +74,7 @@ export class QbdDirectBaseMappingComponent implements OnInit {
}

destinationOptionsWatcher(detailAccountType?: string[]): void {
this.detailAccountType = detailAccountType;
this.mappingService.getPaginatedDestinationAttributes(this.destinationField, undefined, this.displayName, '', detailAccountType).subscribe((responses) => {
this.destinationOptions = responses.results as QbdDirectDestinationAttribute[];
this.isLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
(searchOptionsDropdown)="searchOptionsDropdown($event)"
[optionLabel]="'value'"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'accounts payable'"
Copy link
Contributor

Choose a reason for hiding this comment

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

revert back

[mandatoryErrorListName]="'default credit card account'"
[label]="brandingContent.reimbursable.defaultReimbursableAccountPayableLabel + (exportSettingsForm.get('reimbursableExportType')?.value | snakeCaseToSpaceCase | titlecase)"
[subLabel]="brandingContent.reimbursable.defaultReimbursableAccountPayableSubLabel + (exportSettingsForm.get('reimbursableExportType')?.value | snakeCaseToSpaceCase | titlecase) + ' ,while debit lines will reflect the category chosen by the employee for each respective expense'"
[iconPath]="'list'"
[placeholder]="'Select accounts payable'"
Copy link
Contributor

Choose a reason for hiding this comment

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

revert back

[placeholder]="'Select default credit card account'"
[isMultiLineOption]="true"
[formControllerName]="'defaultReimbursableAccountsPayableAccountName'">
</app-configuration-select-field>
Expand Down Expand Up @@ -203,11 +203,11 @@
(searchOptionsDropdown)="searchOptionsDropdown($event)"
[optionLabel]="'value'"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'accounts payable'"
Copy link
Contributor

Choose a reason for hiding this comment

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

same

[mandatoryErrorListName]="'default credit card account'"
[label]="brandingContent.corporateCard.defaultCCCAccountPayableLabel + (exportSettingsForm.get('creditCardExportType')?.value | snakeCaseToSpaceCase | titlecase)"
[subLabel]="brandingContent.corporateCard.defaultCCCAccountPayableSubLabel + (exportSettingsForm.get('creditCardExportType')?.value | snakeCaseToSpaceCase | titlecase) + ' ,while debit lines will reflect the category chosen by the employee for each respective expense'"
[iconPath]="'list'"
[placeholder]="'Select accounts payable'"
Copy link
Contributor

Choose a reason for hiding this comment

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

same

[placeholder]="'Select default credit card account'"
[isMultiLineOption]="true"
[formControllerName]="'defaultCCCAccountsPayableAccountName'">
</app-configuration-select-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-10-px !tw-font-400 !tw-leadin
<h4 class="tw-text-14-px !tw-font-500 tw-text-text-secondary tw-w-600-px">{{ error.error_title | snakeCaseToSpaceCase | titlecase }}</h4>
<div class="flex-wrapper">
<h5 class="!tw-text-text-muted tw-text-12-px tw-pt-10-px !tw-font-400 !tw-leading-4 tw-w-600-px tw-flex tw-items-center tw-justify-start">
<p>{{ error.error_detail }}.
<p>{{ error.error_detail }}
<a *ngIf="error.article_link && brandingFeatureConfig.allowIntacctHelperDoc" class=" tw-pr-4-px tw-text-link-primary tw-w-fit tw-cursor-pointer tw-inline-flex tw-items-center"
(click)="windowService.openInNewTab(error.article_link)">
{{ helper.sentenseCaseConversion('Read More') }}
Expand Down Expand Up @@ -135,6 +135,6 @@ <h3 class="dialog-sub-header">
<p class="tw-text-text-primary tw-text-20-px tw-line-height-20">{{ brandingConfig.brandId === 'co' ? (errorType | snakeCaseToSpaceCase | sentenceCase) : (errorType | snakeCaseToSpaceCase | titlecase) }} {{brandingContentCommon.errors}}</p>
<p class="dialog-sub-header">Resolve the following mapping errors to export your failed expenses successfully to {{appName}}</p>
</p-header>
<app-generic-mapping-table *ngIf="isMappingResolveVisible && !isLoading" [employeeFieldMapping]="employeeFieldMapping" [isLoading]="isLoading" [appName]="appName" [isDashboardMappingResolve]="true" [destinationField]="destinationField" [filteredMappings]="filteredMappings" [sourceField]="sourceField" [destinationOptions]="destinationOptions" [displayName]="displayName" [isMultiLineOption]="isMultiLineOption"></app-generic-mapping-table>
<app-generic-mapping-table *ngIf="isMappingResolveVisible && !isLoading" [employeeFieldMapping]="employeeFieldMapping" [isLoading]="isLoading" [appName]="appName" [isDashboardMappingResolve]="true" [destinationField]="destinationField" [filteredMappings]="filteredMappings" [sourceField]="sourceField" [destinationOptions]="destinationOptions" [displayName]="displayName" [isMultiLineOption]="isMultiLineOption" [detailAccountType]="detailAccountType"></app-generic-mapping-table>
</p-dialog>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export class DashboardErrorSectionComponent implements OnInit {

isMultiLineOption: boolean;

detailAccountType: string[] | undefined;

constructor(
private dashboardService: DashboardService,
private mappingService: MappingService,
Expand Down Expand Up @@ -145,10 +147,12 @@ export class DashboardErrorSectionComponent implements OnInit {
this.mappingService.getGroupedDestinationAttributes([this.destinationField], 'v2').subscribe(groupedDestinationResponse => {
if (this.sourceField === 'EMPLOYEE') {
this.destinationOptions = this.destinationField === FyleField.EMPLOYEE ? groupedDestinationResponse.EMPLOYEE : groupedDestinationResponse.VENDOR;
this.detailAccountType = undefined;
} else if (this.sourceField === 'CATEGORY') {
if (this.destinationField === 'EXPENSE_TYPE') {
this.destinationOptions = groupedDestinationResponse.EXPENSE_TYPE;
} else {
this.detailAccountType = this.chartOfAccounts;
this.destinationOptions = this.appName !== AppName.QBD_DIRECT ? groupedDestinationResponse.ACCOUNT : this.destinationOptionsWatcher( this.chartOfAccounts, groupedDestinationResponse.ACCOUNT as QbdDirectDestinationAttribute[]);
}
}
Expand Down Expand Up @@ -210,8 +214,9 @@ export class DashboardErrorSectionComponent implements OnInit {
}

handleResolvedMappingStat(): void {
this.dashboardService.getExportErrors(this.errorsVersion, this.appName).subscribe((errors) => {
const argument = this.errorsVersion === 'v1' ? errors : (errors as ErrorResponse).results;
const errorVersion = this.appName === AppName.QBD_DIRECT ? this.appName : this.errorsVersion;
this.dashboardService.getExportErrors(errorVersion).subscribe((errors) => {
const argument = errorVersion === 'v1' ? errors : (errors as ErrorResponse).results;
Comment on lines +219 to +221
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for export errors retrieval.

The service call to getExportErrors lacks error handling, which could lead to unhandled exceptions.

-    this.dashboardService.getExportErrors(errorVersion).subscribe((errors) => {
+    this.dashboardService.getExportErrors(errorVersion).subscribe({
+      next: (errors) => {
       const argument = errorVersion === 'v1' ? errors : (errors as ErrorResponse).results;
       const newError: AccountingGroupedErrors = this.formatErrors(argument);
+      },
+      error: (error) => {
+        console.error('Failed to fetch export errors:', error);
+        // Consider showing an error message to the user
+      }
+    });

Committable suggestion skipped: line range outside the PR's diff.

const newError: AccountingGroupedErrors = this.formatErrors(argument);

if (this.errors.CATEGORY_MAPPING.length !== newError.CATEGORY_MAPPING.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class GenericMappingTableComponent implements OnInit {

@Input() isMultiLineOption: boolean = false;

@Input() detailAccountType: string[] | undefined;

private searchSubject = new Subject<string>();

searchQuery: string;
Expand Down Expand Up @@ -132,7 +134,7 @@ export class GenericMappingTableComponent implements OnInit {
const existingOptions = this.destinationOptions.concat();
const newOptions: DestinationAttribute[] = [];

this.mappingService.getPaginatedDestinationAttributes(this.destinationField, event.searchTerm, this.displayName, this.appName).subscribe((response) => {
this.mappingService.getPaginatedDestinationAttributes(this.destinationField, event.searchTerm, this.displayName, this.appName, this.detailAccountType).subscribe((response) => {
response.results.forEach((option) => {
// If option is not already present in the list, add it
if (!this.optionsMap[option.id.toString()]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div *ngIf="!isLoading">
<div *ngIf="filteredMappingCount">
<app-generic-mapping-table [isLoading]="isLoading" [appName]="appName" [isDashboardMappingResolve]="false" [destinationField]="destinationField" [filteredMappings]="filteredMappings" [sourceField]="sourceField" [mappingStats]="mappingStats" [employeeFieldMapping]="employeeFieldMapping" [destinationOptions]="destinationOptions" [displayName]="displayName" [isMultiLineOption]="isMultiLineOption"></app-generic-mapping-table>
<app-generic-mapping-table [isLoading]="isLoading" [appName]="appName" [isDashboardMappingResolve]="false" [destinationField]="destinationField" [filteredMappings]="filteredMappings" [sourceField]="sourceField" [mappingStats]="mappingStats" [employeeFieldMapping]="employeeFieldMapping" [destinationOptions]="destinationOptions" [displayName]="displayName" [isMultiLineOption]="isMultiLineOption" [detailAccountType]="detailAccountType"></app-generic-mapping-table>
</div>
<div class="tw-p-24-px tw-border-t-separator" *ngIf="filteredMappingCount && !isLoading" >
<app-paginator [totalCount]="totalCount" [pageType]="PaginatorPage.MAPPING" [page]="currentPage" [dropDownValue]="limit" (pageSizeChangeEvent)="pageSizeChanges($event)" (pageOffsetChangeEvent)="pageOffsetChanges($event)"></app-paginator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class GenericMappingV2Component implements OnInit {

@Input() isMultiLineOption: boolean = false;

@Input() detailAccountType: string[] | undefined;

isInitialSetupComplete: boolean = false;

mappingStats: MappingStats;
Expand Down
Loading