Skip to content

Commit

Permalink
fix: QBD Dashboard bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Dec 10, 2024
1 parent 1dd10f0 commit 5962b2d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/app/core/models/db/accounting-export.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export interface AccountingExport {
}

export type AccountingExportGetParam = {
type__in: string[],
status__in: string[],
type__in?: string[],
status__in: string[] | string,
id__in?: number[],
limit: number,
offset: number,
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/services/common/accounting-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class AccountingExportService {
}

if (appName === AppName.QBD_DIRECT) {
if (apiParams.status__in?.includes(AccountingExportStatus.FAILED)) {
apiParams.status__in = AccountingExportStatus.ERROR;
}
delete apiParams.type__in;
return this.apiService.get(`/workspaces/${this.workspaceId}/export_logs/`, apiParams);
}
return this.apiService.get(`/workspaces/${this.workspaceId}/accounting_exports/`, apiParams);
Expand Down
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'): Observable<any> {
getExportErrors(version?: string | 'v1', appName?: string): Observable<any> {
if (version === 'v1') {
return this.apiService.get(`/v2/workspaces/${this.workspaceId}/errors/`, {is_resolved: false});
} else if (version === AppName.QBD_DIRECT) {
} else if (appName === AppName.QBD_DIRECT) {
return this.apiService.get(`/workspaces/${this.workspaceId}/export_logs/errors/`, {is_resolved: false});
}

Expand All @@ -63,7 +63,7 @@ export class DashboardService {
}

if (taskType) {
const typeKey = appName===AppName.INTACCT ? 'task_type' : 'type__in';
const typeKey = appName === AppName.INTACCT ? 'task_type' : 'type__in';
apiParams[typeKey] = taskType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<app-dashboard-export-summary-section *ngIf="exportableAccountingExportIds.length || accountingExportSummary"
[appName]="appName"
[exportLogVersion]="'v2'"
[accountingExportType]="accountingExportType"
[accountingExportSummary]="accountingExportSummary">
</app-dashboard-export-summary-section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export class QbdDirectDashboardComponent implements OnInit {

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

accountingExportType: QbdDirectTaskLogType[] = [QbdDirectTaskLogType.BILL, QbdDirectTaskLogType.CREDIT_CARD_PURCHASE, QbdDirectTaskLogType.JOURNAL_ENTRY];

exportLogProcessingStates: TaskLogState[] = [TaskLogState.IN_PROGRESS, TaskLogState.ENQUEUED, TaskLogState.EXPORT_PROCESSED];

isImportItemsEnabled: boolean;
Expand Down Expand Up @@ -97,7 +95,7 @@ export class QbdDirectDashboardComponent implements OnInit {

private pollExportStatus(exportableAccountingExportIds: number[] = []): void {
interval(3000).pipe(
switchMap(() => from(this.dashboardService.getAllTasks([], exportableAccountingExportIds, this.accountingExportType, AppName.QBD_DIRECT))),
switchMap(() => from(this.dashboardService.getAllTasks([], exportableAccountingExportIds, [], AppName.QBD_DIRECT))),
takeWhile((response: QbdDirectTaskResponse) =>
response.results.filter(task =>
(this.exportLogProcessingStates.includes(task.status))
Expand All @@ -120,7 +118,7 @@ export class QbdDirectDashboardComponent implements OnInit {
this.accountingExportSummary = AccountingExportSummaryModel.parseAPIResponseToAccountingSummaryForQbdDirect(responses[1]);
this.failedExpenseGroupCount = res.results.filter(task => task.status === TaskLogState.FAILED || task.status === TaskLogState.FATAL).length;

this.exportableAccountingExportIds = res.results.filter(task => task.status === TaskLogState.FAILED || task.status === TaskLogState.FATAL).map(taskLog => taskLog.expense_group);
this.exportableAccountingExportIds = res.results.filter(task => task.status === TaskLogState.FAILED || task.status === TaskLogState.FATAL).map(taskLog => taskLog.id);

this.isExportInProgress = false;
this.exportProgressPercentage = 0;
Expand All @@ -134,7 +132,7 @@ export class QbdDirectDashboardComponent implements OnInit {
forkJoin([
this.getExportErrors$,
this.getAccountingExportSummary$.pipe(catchError(() => of(null))),
this.dashboardService.getAllTasks(this.exportLogProcessingStates.concat(TaskLogState.ERROR), undefined, this.accountingExportType, AppName.QBD_DIRECT),
this.dashboardService.getAllTasks(this.exportLogProcessingStates.concat(TaskLogState.ERROR), undefined, [], AppName.QBD_DIRECT),
this.dashboardService.getExportableAccountingExportIds('v2'),
this.QbdDirectExportSettingsService.getQbdExportSettings(),
this.importSettingService.getImportSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class DashboardErrorSectionComponent implements OnInit {
}

handleResolvedMappingStat(): void {
this.dashboardService.getExportErrors(this.errorsVersion).subscribe((errors) => {
this.dashboardService.getExportErrors(this.errorsVersion, this.appName).subscribe((errors) => {
const argument = this.errorsVersion === 'v1' ? errors : (errors as ErrorResponse).results;
const newError: AccountingGroupedErrors = this.formatErrors(argument);

Expand Down

0 comments on commit 5962b2d

Please sign in to comment.