Skip to content

Commit

Permalink
fix: qbd back end fixes (#1049)
Browse files Browse the repository at this point in the history
* fix: qbd back end fixes

* fix: qbd back end fixes

* dashboard successfull export view changes

* dashboard successfull export view changes

* PR commit fix
  • Loading branch information
DhaaraniCIT authored Oct 30, 2024
1 parent a81b687 commit 0186a44
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/app/core/models/db/task-log.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export type TaskLogGetParams = {
type__in?: string[];
expense_group_ids?: number[];
task_type?: string[];
export_log_id__in?: number[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
return ["employee_name", "expense_key"];
}

static formatMemoStructure(memoStructure: string[], defaultMemoOptions: string[]): string[] {
const originMemo: string[] = [];
defaultMemoOptions.forEach((field, index) => {
const defaultIndex = memoStructure.indexOf(field);
originMemo[defaultIndex] = field;
});

return originMemo.filter((item: string) => item !== null);
}

static mapAPIResponseToFormGroup(advancedSettings: QbdDirectAdvancedSettingsGet | null, isSkipExportEnabled: boolean): FormGroup {

return new FormGroup({
expenseMemoStructure: new FormControl(advancedSettings?.line_level_memo_structure && advancedSettings?.line_level_memo_structure.length > 0 ? advancedSettings?.line_level_memo_structure : this.defaultMemoFields(), Validators.required),
expenseMemoStructure: new FormControl(advancedSettings?.line_level_memo_structure && advancedSettings?.line_level_memo_structure.length > 0 ? this.formatMemoStructure(this.defaultMemoFields(), advancedSettings?.line_level_memo_structure) : this.defaultMemoFields(), Validators.required),
topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? advancedSettings?.top_level_memo_structure : this.defaultTopMemoOptions(), Validators.required),
exportSchedule: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.schedule_is_enabled : false),
email: new FormControl(advancedSettings?.emails_selected ? advancedSettings?.emails_selected : null),
Expand All @@ -54,8 +64,10 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {

const additionalEmails = allSelectedEmails?.filter((email: EmailOption) => !adminEmails.includes(email));

const memo = advancedSettingForm.get('expenseMemoStructure')?.value ? advancedSettingForm.get('expenseMemoStructure')?.value : [];

const advancedSettingPayload: QbdDirectAdvancedSettingsPost = {
line_level_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? advancedSettingForm.get('expenseMemoStructure')?.value : null,
line_level_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? this.formatMemoStructure(this.defaultMemoFields(), memo) : [],
top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? topMemo : null,
schedule_is_enabled: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportSchedule')?.value : false,
emails_selected: advancedSettingForm.get('exportSchedule')?.value ? selectedEmailsEmails : [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface QbdDirectImportSettingGet extends QbdDirectImportSettingPost {}
export class QbdDirectImportSettingModel extends ImportSettingsModel {
static getChartOfAccountTypesList(): string[] {
const typeList = [
'Other Expense', 'Cost of Goods Sold', 'Fixed Asset', 'Other Asset', 'Other Current Asset',
'Other Expense', 'Cost Of Goods Sold', 'Fixed Asset', 'Other Asset', 'Other Current Asset',
'Long Term Liability', 'Other Current Liability', 'Income', 'Other Income', 'Equity'
].sort((a, b) => a.localeCompare(b));

Expand All @@ -33,7 +33,7 @@ export class QbdDirectImportSettingModel extends ImportSettingsModel {
return new FormGroup({
importCategories: new FormControl(importSettings?.import_settings?.import_account_as_category ?? false),
expenseFields: new FormArray(expenseFieldsArray),
chartOfAccountTypes: new FormControl(importSettings?.import_settings?.chart_of_accounts ? importSettings.import_settings.chart_of_accounts : ['Expense']),
chartOfAccountTypes: new FormControl(importSettings?.import_settings?.chart_of_accounts ? importSettings.import_settings.chart_of_accounts.map(item => item.replace(/([a-z])([A-Z])/g, '$1 $2')) : ['Expense']),
importVendorsAsMerchants: new FormControl(importSettings?.import_settings?.import_vendor_as_merchant ?? false),
searchOption: new FormControl(''),
importCodeFields: new FormControl( importSettings?.import_settings?.import_code_fields ? importSettings.import_settings.import_code_fields : null),
Expand Down
8 changes: 6 additions & 2 deletions src/app/core/services/common/accounting-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AccountingExportService {
return this.apiService.get(`/workspaces/${this.workspaceId}/accounting_exports/count/`, apiParams);
}

getAccountingExports(type: string[], status: string[], exportableAccountingExportIds: number[] | null, limit: number, offset: number, selectedDateFilter? : SelectedDateFilter | null, exportedAt?: string | null, searchQuery?: string | null): Observable<any> {
getAccountingExports(type: string[], status: string[], exportableAccountingExportIds: number[] | null, limit: number, offset: number, selectedDateFilter? : SelectedDateFilter | null, exportedAt?: string | null, searchQuery?: string | null, appName?: string): Observable<any> {
const apiParams: AccountingExportGetParam = {
type__in: type,
status__in: status,
Expand Down Expand Up @@ -71,7 +71,11 @@ export class AccountingExportService {
apiParams.exported_at__gte = exportedAt;
}

return this.apiService.get(`/workspaces/${this.workspaceId}/accounting_exports/`, apiParams);
if (appName === AppName.QBD_DIRECT) {
return this.apiService.get(`/workspaces/${this.workspaceId}/export_logs/`, apiParams);
}
return this.apiService.get(`/workspaces/${this.workspaceId}/accounting_exports/`, apiParams);

}

@Cacheable()
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DashboardService {
}

if (expenseGroupIds.length) {
const expenseKey = appName===AppName.INTACCT ? 'expense_group_ids' : 'expense_group_id__in';
const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'export_log_id__in' : 'expense_group_id__in';
apiParams[expenseKey] = expenseGroupIds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<app-dashboard-export-summary-section *ngIf="exportableAccountingExportIds.length || accountingExportSummary"
[appName]="appName"
[exportLogVersion]="'v1'"
[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 @@ -3,12 +3,13 @@ import { Component, Inject, OnInit } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { Subject, debounceTime } from 'rxjs';
import { brandingConfig } from 'src/app/branding/c1-contents-config';
import { AccountingExportModel, AccountingExportList } from 'src/app/core/models/db/accounting-export.model';
import { AccountingExportModel, AccountingExportList, AccountingExport } from 'src/app/core/models/db/accounting-export.model';
import { ExpenseGroupResponse, ExpenseGroup } from 'src/app/core/models/db/expense-group.model';
import { AppName, PaginatorPage, TaskLogState } from 'src/app/core/models/enum/enum.model';
import { Expense } from 'src/app/core/models/intacct/db/expense.model';
import { Paginator } from 'src/app/core/models/misc/paginator.model';
import { DateFilter, SelectedDateFilter } from 'src/app/core/models/qbd/misc/qbd-date-filter.model';
import { AccountingExportService } from 'src/app/core/services/common/accounting-export.service';
import { ExportLogService } from 'src/app/core/services/common/export-log.service';
import { PaginatorService } from 'src/app/core/services/common/paginator.service';
import { WindowService } from 'src/app/core/services/common/window.service';
Expand Down Expand Up @@ -65,7 +66,8 @@ export class QbdDirectCompleteExportLogComponent implements OnInit {
private exportLogService: ExportLogService,
private windowService: WindowService,
private paginatorService: PaginatorService,
private userService: UserService
private userService: UserService,
private accountingExportService: AccountingExportService
) {
this.searchQuerySubject.pipe(
debounceTime(1000)
Expand Down Expand Up @@ -106,11 +108,11 @@ export class QbdDirectCompleteExportLogComponent implements OnInit {
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
}

this.exportLogService.getExpenseGroups(TaskLogState.COMPLETE, limit, offset, this.selectedDateFilter, null, this.searchQuery, this.appName).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
this.accountingExportService.getAccountingExports([], [TaskLogState.COMPLETE], null, limit, offset, this.selectedDateFilter, null, this.searchQuery, this.appName).subscribe((accountingExportResponse) => {
this.totalCount = accountingExportResponse.count;

const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: ExpenseGroup) =>
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id, AppName.QBO)
const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: AccountingExport) =>
AccountingExportModel.parseAPIResponseToExportLog(accountingExport, this.org_id)
);
this.filteredAccountingExports = accountingExports;
this.accountingExports = [...this.filteredAccountingExports];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class QbdDirectAdvancedSettingsComponent implements OnInit {
const skipExportRank1: ExpenseFilterPayload = SkipExportModel.constructExportFilterPayload(valueField);
const payload1 = SkipExportModel.constructSkipExportPayload(skipExportRank1, this.skipExportForm.value.value1);
this.skipExportService.postExpenseFilter(payload1).subscribe(() => {
if (valueField.condition2 && valueField.operator2) {
if (valueField.condition2 && valueField.operator2 && valueField.value2) {
valueField.rank = 2;
const skipExportRank2: ExpenseFilterPayload = SkipExportModel.constructExportFilterPayload(valueField);
const payload2 = SkipExportModel.constructSkipExportPayload(skipExportRank2, this.skipExportForm.value.value2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MappingService } from 'src/app/core/services/common/mapping.service';
import { WorkspaceService } from 'src/app/core/services/common/workspace.service';
import { QbdDirectAdvancedSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.service';
import { QbdDirectImportSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.service';
import { QbdDirectHelperService } from 'src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-helper.service';
import { SharedModule } from 'src/app/shared/shared.module';

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/app/integrations/qbd-direct/qbd-direct.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class QbdDirectComponent implements OnInit {
this.workspace = workspace;
this.storageService.set('workspaceId', this.workspace.id);
this.storageService.set('onboarding-state', this.workspace.onboarding_state);
this.qbdDirectHelperService.importAttribuites(true);
this.qbdDirectHelperService.importAttribuites(false);
this.isLoading = false;
this.navigate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class DashboardExportSummarySectionComponent implements OnInit {

isExportLogVisible: boolean;

AppName = AppName;

private org_id: string = this.userService.getUserProfile().org_id;

readonly brandingConfig = brandingConfig;
Expand Down Expand Up @@ -77,7 +79,7 @@ export class DashboardExportSummarySectionComponent implements OnInit {
startDate: lastExportedAt ? new Date(lastExportedAt) : new Date(),
endDate: new Date()
};
this.accountingExportService.getAccountingExports(this.accountingExportType, [status], null, limit, offset, lastExportedAt ? dateFilter : null, lastExportedAt).subscribe(accountingExportResponse => {
this.accountingExportService.getAccountingExports(this.accountingExportType, [status], null, limit, offset, lastExportedAt ? dateFilter : null, lastExportedAt, null, this.appName).subscribe(accountingExportResponse => {
const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: AccountingExport) =>
AccountingExportModel.parseAPIResponseToExportLog(accountingExport, this.org_id)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<th *ngIf="isExportLogTable && brandingFeatureConfig.featureFlags.exportLog.expenseType">{{brandingContent.tableHeaders.expenseType}}</th>
<th>Reference ID</th>
<th *ngIf="!isDashboardFailed">{{brandingContent.tableHeaders.exportedAs}}</th>
<th *ngIf="!isDashboardFailed && appName !== AppName.SAGE300">Link to {{appName}}</th>
<th *ngIf="!isDashboardFailed && appName !== AppName.SAGE300 && appName !== AppName.QBD_DIRECT">Link to {{appName}}</th>
<th class="tw-min-w-120-px" *ngIf="isDashboardFailed">Link to {{ brandingConfig.brandName }}</th>
</tr>
</ng-template>
Expand Down Expand Up @@ -40,7 +40,7 @@
{{brandingConfig.brandId === 'co' ? (rowData.exportedAs | snakeCaseToSpaceCase | sentenceCase) : (rowData.exportedAs | snakeCaseToSpaceCase | titlecase)}}
</span>
</td>
<td *ngIf="!isDashboardFailed && appName !== AppName.SAGE300">
<td *ngIf="!isDashboardFailed && appName !== AppName.SAGE300 && appName !== AppName.QBD_DIRECT">
<div>
<button (click)="openUrl(rowData.integrationUrl)" [pTooltip]="brandingConfig.brandId === 'co' ? 'Open in new tab' : 'Open in New Tab'" tooltipPosition="top">
<app-svg-icon [styleClasses]="'tw-pt-5-px'" [svgSource]="'open-in-new-tab-standard'" [width]="'24px'" [height]="'24px'"></app-svg-icon>
Expand Down

0 comments on commit 0186a44

Please sign in to comment.