Skip to content

Commit 0118af2

Browse files
Advance search export log page intacct (#636)
1 parent e7bc266 commit 0118af2

File tree

7 files changed

+75
-53
lines changed

7 files changed

+75
-53
lines changed

src/app/core/services/common/export-log.service.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,13 @@ export class ExportLogService {
5050
return this.apiService.get(`/workspaces/${workspaceId}/fyle/expenses/`, params);
5151
}
5252

53-
getExpenseGroups(state: TaskLogState, limit: number, offset: number, selectedDateFilter: SelectedDateFilter | null, exportedAt?: string | null, query?: string | null, appName?: AppName): Observable<ExpenseGroupResponse> {
53+
getExpenseGroups(state: TaskLogState, limit: number, offset: number, selectedDateFilter: SelectedDateFilter | null, exportedAt?: string | null, query?: string | null): Observable<ExpenseGroupResponse> {
5454
const params: ExpenseGroupParam = {
5555
limit,
5656
offset
5757
};
5858

59-
if (appName === AppName.INTACCT) {
60-
params.state = state;
61-
} else {
62-
params.tasklog__status = state;
63-
}
59+
params.tasklog__status = state;
6460

6561
if (query) {
6662
params.expenses__expense_number = query;
@@ -72,21 +68,8 @@ export class ExportLogService {
7268
if (selectedDateFilter) {
7369
const startDate = selectedDateFilter.startDate.toLocaleDateString().split('/');
7470
const endDate = selectedDateFilter.endDate.toLocaleDateString().split('/');
75-
if (appName === AppName.INTACCT) {
76-
params.start_date = `${startDate[2]}-${startDate[1]}-${startDate[0]}T00:00:00`;
77-
params.end_date = `${endDate[2]}-${endDate[1]}-${endDate[0]}T23:59:59`;
78-
} else {
7971
params.exported_at__gte = `${startDate[2]}-${startDate[1]}-${startDate[0]}T00:00:00`;
8072
params.exported_at__lte = `${endDate[2]}-${endDate[1]}-${endDate[0]}T23:59:59`;
81-
}
82-
}
83-
84-
if (exportedAt) {
85-
if (appName === AppName.INTACCT) {
86-
params.exported_at = exportedAt;
87-
} else {
88-
params.exported_at__gte = exportedAt;
89-
}
9073
}
9174

9275
return this.apiService.get(`/workspaces/${this.workspaceId}/fyle/expense_groups/`, params);

src/app/integrations/intacct/intacct-main/intacct-export-log/intacct-completed-export-log/intacct-completed-export-log.component.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
1+
<div *ngIf="!accountingExports" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
22
<app-loader></app-loader>
33
</div>
44

5-
<div *ngIf="!isLoading" class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-border-tertiary" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
5+
<div class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-border-tertiary" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
66
<div>
7-
<app-export-log-filter *ngIf="totalCount > 0 || selectedDateFilter"
7+
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"
88
[exportLogForm]="exportLogForm"
99
[dateOptions]="dateOptions"
1010
(handleSimpleSearch)="handleSimpleSearch($event)">
1111
</app-export-log-filter>
1212

1313
<app-export-log-table
14+
*ngIf="!isLoading"
1415
[filteredExpenseGroups]="filteredAccountingExports"
1516
[appName]="appName"
1617
[isExportLogTable]="true"
1718
[isDashboardFailed]="false">
1819
</app-export-log-table>
1920

20-
<div *ngIf="filteredAccountingExports.length > 0" class="tw-p-24-px tw-border-t-1-px">
21+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
2122
<app-paginator
2223
[dropDownValue]="limit"
2324
[page]="currentPage"
@@ -27,13 +28,13 @@
2728
</app-paginator>
2829
</div>
2930

30-
<app-zero-state-with-illustration *ngIf="!filteredAccountingExports.length && !selectedDateFilter && totalCount > 0"
31+
<app-zero-state-with-illustration *ngIf="(isDateSelected || searchQuery) && totalCount === 0 && !isLoading"
3132
[mainText]="brandingConfig.brandId === 'fyle' ? 'Sorry, no results found!': 'Sorry, no results found'"
3233
[subText]="'We could not find what you were looking for. Kindly check the keywords again.'">
3334
</app-zero-state-with-illustration>
3435
</div>
3536

36-
<app-zero-state-with-illustration *ngIf="totalCount === 0"
37+
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
3738
[mainText]="brandingConfig.brandId === 'fyle' ? 'No records to show yet!': 'No records to show yet'"
3839
[subText]="brandingConfig.brandId === 'fyle' ? 'All your successful exports and their details will be stored here.': 'All your expenses that are successfully exported will be visible here.'">
3940
</app-zero-state-with-illustration>

src/app/integrations/intacct/intacct-main/intacct-export-log/intacct-completed-export-log/intacct-completed-export-log.component.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { environment } from 'src/environments/environment';
1212
import { brandingConfig, brandingFeatureConfig } from 'src/app/branding/branding-config';
1313
import { AccountingExportList, AccountingExportModel } from 'src/app/core/models/db/accounting-export.model';
1414
import { UserService } from 'src/app/core/services/misc/user.service';
15+
import { Subject } from 'rxjs/internal/Subject';
16+
import { debounceTime } from 'rxjs/internal/operators/debounceTime';
1517

1618
@Component({
1719
selector: 'app-intacct-completed-export-log',
@@ -60,23 +62,34 @@ export class IntacctCompletedExportLogComponent implements OnInit {
6062

6163
readonly brandingConfig = brandingConfig;
6264

65+
searchQuery: string | null;
66+
67+
private searchQuerySubject = new Subject<string>();
68+
6369
constructor(
6470
private formBuilder: FormBuilder,
6571
private trackingService: TrackingService,
6672
private exportLogService: ExportLogService,
6773
private paginatorService: PaginatorService,
6874
private userService: UserService
69-
) { }
75+
) {
76+
this.searchQuerySubject.pipe(
77+
debounceTime(1000)
78+
).subscribe((query: string) => {
79+
this.searchQuery = query;
80+
this.offset = 0;
81+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
82+
this.getAccountingExports(this.limit, this.offset);
83+
});
84+
}
7085

7186
openExpenseinFyle(expense_id: string) {
7287
const url = `${environment.fyle_app_url}/app/admin/#/view_expense/${expense_id}`;
7388
window.open(url, '_blank');
7489
}
7590

7691
public handleSimpleSearch(query: string) {
77-
this.filteredAccountingExports = this.accountingExports.filter((group: AccountingExportList) => {
78-
return AccountingExportModel.getfilteredAccountingExports(query, group);
79-
});
92+
this.searchQuerySubject.next(query);
8093
}
8194

8295
pageSizeChanges(limit: number): void {
@@ -103,10 +116,10 @@ export class IntacctCompletedExportLogComponent implements OnInit {
103116
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
104117
}
105118

106-
this.exportLogService.getExpenseGroups(TaskLogState.COMPLETE, limit, offset, this.selectedDateFilter, null, null, AppName.INTACCT).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
107-
if (!this.isDateSelected) {
108-
this.totalCount = accountingExportResponse.count;
109-
}
119+
this.exportLogService.getExpenseGroups(TaskLogState.COMPLETE, limit, offset, this.selectedDateFilter, null, this.searchQuery).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
120+
121+
this.totalCount = accountingExportResponse.count;
122+
110123
const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: ExpenseGroup) =>
111124
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id, this.appName)
112125
);
@@ -128,13 +141,16 @@ export class IntacctCompletedExportLogComponent implements OnInit {
128141
this.exportLogForm.controls.start.valueChanges.subscribe((dateRange) => {
129142
const paginator: Paginator = this.paginatorService.getPageSize(PaginatorPage.EXPORT_LOG);
130143
if (!dateRange) {
144+
this.dateOptions = AccountingExportModel.getDateOptionsV2();
131145
this.selectedDateFilter = null;
146+
this.isDateSelected = false;
132147
this.getAccountingExports(paginator.limit, paginator.offset);
133148
} else if (dateRange.length && dateRange[1]) {
134149
this.selectedDateFilter = {
135150
startDate: dateRange[0],
136151
endDate: dateRange[1]
137152
};
153+
this.isDateSelected = true;
138154

139155
this.trackDateFilter('existing', this.selectedDateFilter);
140156
this.getAccountingExports(paginator.limit, paginator.offset);

src/app/integrations/intacct/intacct-main/intacct-export-log/intacct-skip-export-log/intacct-skip-export-log.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
1+
<div *ngIf="!expenses" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
22
<app-loader></app-loader>
33
</div>
44

5-
<div *ngIf="!isLoading" class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-separator" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
5+
<div class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-separator" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
66
<div>
7-
<app-export-log-filter *ngIf="totalCount > 0 || selectedDateFilter"
7+
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"
88
[exportLogForm]="skipExportLogForm"
99
[dateOptions]="dateOptions"
1010
(handleSimpleSearch)="handleSimpleSearch($event)">
1111
</app-export-log-filter>
1212

13-
<app-skipped-export-log-table [filteredExpense]="filteredExpenses">
13+
<app-skipped-export-log-table *ngIf="!isLoading" [filteredExpense]="filteredExpenses" >
1414
</app-skipped-export-log-table>
1515

16-
<div *ngIf="filteredExpenses.length > 0" class="tw-p-24-px tw-border-t-1-px">
16+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
1717
<app-paginator
1818
[dropDownValue]="limit"
1919
[page]="currentPage"
@@ -23,14 +23,14 @@
2323
</app-paginator>
2424
</div>
2525

26-
<app-zero-state-with-illustration *ngIf="!filteredExpenses.length && !selectedDateFilter && totalCount > 0"
26+
<app-zero-state-with-illustration *ngIf="(isDateSelected || searchQuery) && totalCount === 0 && !isLoading"
2727
[mainText]="brandingConfig.brandId === 'fyle' ? 'Sorry, no results found!': 'Sorry, no results found'"
2828
[subText]="'We could not find what you were looking for. Kindly check the keywords again.'">
2929
</app-zero-state-with-illustration>
3030

3131
</div>
3232

33-
<app-zero-state-with-illustration *ngIf="totalCount === 0"
33+
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
3434
[mainText]="brandingConfig.brandId === 'fyle' ? 'No records to show yet!': 'No records to show yet'"
3535
[subText]="brandingConfig.brandId === 'fyle' ? 'All your expenses that were skipped from exporting will be stored here.': 'All your expenses that are skipped from exporting will be visible here'">
3636
</app-zero-state-with-illustration>

src/app/integrations/intacct/intacct-main/intacct-export-log/intacct-skip-export-log/intacct-skip-export-log.component.ts

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { ExportLogService } from 'src/app/core/services/common/export-log.servic
99
import { PaginatorService } from 'src/app/core/services/si/si-core/paginator.service';
1010
import { brandingConfig, brandingFeatureConfig } from 'src/app/branding/branding-config';
1111
import { AccountingExportModel, SkippedAccountingExportModel } from 'src/app/core/models/db/accounting-export.model';
12+
import { debounceTime } from 'rxjs/operators';
13+
import { Subject } from 'rxjs';
1214

1315
@Component({
1416
selector: 'app-intacct-skip-export-log',
@@ -57,17 +59,29 @@ export class IntacctSkipExportLogComponent implements OnInit {
5759

5860
readonly brandingConfig = brandingConfig;
5961

62+
searchQuery: string | null;
63+
64+
private searchQuerySubject = new Subject<string>();
65+
66+
6067
constructor(
6168
private formBuilder: FormBuilder,
6269
private trackingService: TrackingService,
6370
private exportLogService: ExportLogService,
6471
private paginatorService: PaginatorService
65-
) { }
72+
) {
73+
this.searchQuerySubject.pipe(
74+
debounceTime(1000)
75+
).subscribe((query: string) => {
76+
this.searchQuery = query;
77+
this.offset = 0;
78+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
79+
this.getSkippedExpenses(this.limit, this.offset);
80+
});
81+
}
6682

6783
public handleSimpleSearch(query: string) {
68-
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
69-
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
70-
});
84+
this.searchQuerySubject.next(query);
7185
}
7286

7387
pageSizeChanges(limit: number): void {
@@ -94,10 +108,8 @@ export class IntacctSkipExportLogComponent implements OnInit {
94108
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
95109
}
96110

97-
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
98-
if (!this.isDateSelected) {
111+
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, this.searchQuery).subscribe((skippedExpenses: SkipExportLogResponse) => {
99112
this.totalCount = skippedExpenses.count;
100-
}
101113

102114
skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
103115
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
@@ -118,18 +130,24 @@ export class IntacctSkipExportLogComponent implements OnInit {
118130
});
119131

120132
this.skipExportLogForm.controls.start.valueChanges.subscribe((dateRange) => {
121-
if (dateRange[1]) {
133+
const paginator: Paginator = this.paginatorService.getPageSize(PaginatorPage.EXPORT_LOG);
134+
if (!dateRange) {
135+
this.dateOptions = AccountingExportModel.getDateOptionsV2();
136+
this.isDateSelected = false;
137+
this.selectedDateFilter = null;
138+
139+
this.getSkippedExpenses(paginator.limit, paginator.offset);
140+
} else if (dateRange.length && dateRange[1]) {
122141
this.selectedDateFilter = {
123142
startDate: dateRange[0],
124143
endDate: dateRange[1]
125144
};
126145

127-
this.trackDateFilter('existing', this.selectedDateFilter);
146+
this.isDateSelected = true;
128147

129-
const paginator: Paginator = this.paginatorService.getPageSize(PaginatorPage.EXPORT_LOG);
130148
this.getSkippedExpenses(paginator.limit, paginator.offset);
131-
}
132-
});
149+
}
150+
});
133151
}
134152

135153
private getSkippedExpensesAndSetupPage(): void {

src/app/integrations/qbo/qbo-main/qbo-export-log/qbo-skipped-export-log/qbo-skipped-export-log.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<div *ngIf="!expenses" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
2+
<app-loader></app-loader>
3+
</div>
4+
15
<div class="tw-rounded-8-px tw-bg-white tw-border-1-px tw-border-separator" [ngClass]="{'tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
26
<div>
37
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"

src/app/shared/components/dashboard/dashboard-export-summary-section/dashboard-export-summary-section.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class DashboardExportSummarySectionComponent implements OnInit {
6060
}
6161

6262
private getExpenseGroups(limit: number, offset: number, status: AccountingExportStatus, lastExportedAt?: string | null): void {
63-
this.exportLogService.getExpenseGroups((status as unknown as TaskLogState), limit, offset, null, lastExportedAt, null, this.appName).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
63+
this.exportLogService.getExpenseGroups((status as unknown as TaskLogState), limit, offset, null, lastExportedAt).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
6464
const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: ExpenseGroup) =>
6565
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id, this.appName)
6666
);

0 commit comments

Comments
 (0)