Skip to content

Commit ef58e84

Browse files
Advance export log search for ms-dynamics and sage300 (#674)
* Advance Search for Export log page * Advance search for ms dynamics * linting fix * Resolved comments * removing isLoading
1 parent f8e406a commit ef58e84

File tree

11 files changed

+161
-85
lines changed

11 files changed

+161
-85
lines changed

src/app/core/models/db/accounting-export.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ export type AccountingExportGetParam = {
5454
limit: number,
5555
offset: number,
5656
exported_at__lte?: string,
57-
exported_at__gte?: string
57+
exported_at__gte?: string,
58+
expenses__expense_number?: string;
59+
expenses__employee_name?: string;
60+
expenses__employee_email?: string;
61+
expenses__claim_number?: string;
62+
5863
}
5964

6065
export class AccountingExportModel {

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,30 @@ export class AccountingExportService {
3939
return this.apiService.get(`/workspaces/${this.workspaceId}/accounting_exports/count/`, apiParams);
4040
}
4141

42-
getAccountingExports(type: string[], status: string[], exportableAccountingExportIds: number[] | null, limit: number, offset: number, selectedDateFilter? : SelectedDateFilter | null, exportedAt?: string | null): Observable<any> {
42+
getAccountingExports(type: string[], status: string[], exportableAccountingExportIds: number[] | null, limit: number, offset: number, selectedDateFilter? : SelectedDateFilter | null, exportedAt?: string | null, searchQuery?: string | null): Observable<any> {
4343
const apiParams: AccountingExportGetParam = {
4444
type__in: type,
4545
status__in: status,
4646
limit: limit,
4747
offset: offset
4848
};
4949

50+
if (searchQuery){
51+
apiParams.expenses__claim_number = searchQuery;
52+
apiParams.expenses__employee_email = searchQuery;
53+
apiParams.expenses__employee_name = searchQuery;
54+
apiParams.expenses__expense_number = searchQuery;
55+
}
56+
5057
if (exportableAccountingExportIds?.length) {
5158
apiParams.id__in = exportableAccountingExportIds;
5259
}
5360

5461
if (selectedDateFilter) {
5562
const exportedAtLte = selectedDateFilter.startDate.toLocaleDateString().split('/');
5663
const exportedAtGte = selectedDateFilter.endDate.toLocaleDateString().split('/');
57-
apiParams.exported_at__lte = `${exportedAtLte[2]}-${exportedAtLte[1]}-${exportedAtLte[0]}T00:00:00`;
58-
apiParams.exported_at__gte = `${exportedAtGte[2]}-${exportedAtGte[1]}-${exportedAtGte[0]}T23:59:59`;
64+
apiParams.exported_at__gte = `${exportedAtLte[2]}-${exportedAtLte[1]}-${exportedAtLte[0]}T00:00:00`;
65+
apiParams.exported_at__lte = `${exportedAtGte[2]}-${exportedAtGte[1]}-${exportedAtGte[0]}T23:59:59`;
5966
}
6067

6168
if (exportedAt) {

src/app/integrations/business-central/business-central-main/business-central-dashboard/business-central-dashboard.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
>
4343
</app-dashboard-error-section>
4444
</div>
45-
</div>
45+
</div>
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
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-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
5+
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
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
[hideCalendar]="hideCalendar"
1010
[dateOptions]="dateOptions"
1111
(handleSimpleSearch)="handleSimpleSearch($event)">
1212
</app-export-log-filter>
1313

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

21-
<div *ngIf="filteredAccountingExports.length > 0" class="tw-p-24-px tw-border-t-1-px">
22-
<app-paginator
23-
[dropDownValue]="limit"
24-
[page]="currentPage"
25-
[totalCount]="totalCount"
26-
(pageSizeChangeEvent)="pageSizeChanges($event)"
22+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
23+
<app-paginator
24+
[dropDownValue]="limit"
25+
[page]="currentPage"
26+
[totalCount]="totalCount"
27+
(pageSizeChangeEvent)="pageSizeChanges($event)"
2728
(pageOffsetChangeEvent)="pageChanges($event)">
2829
</app-paginator>
2930
</div>
3031

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

3637
</div>
3738

38-
<app-zero-state-with-illustration *ngIf="totalCount === 0"
39+
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
3940
[mainText]="'No records to show yet!'"
4041
[subText]="'All your successful exports and their details will be stored here.'">
4142
</app-zero-state-with-illustration>
4243

43-
</div>
44+
</div>

src/app/integrations/business-central/business-central-main/business-central-export-log/business-central-complete-export-log/business-central-complete-export-log.component.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { WindowService } from 'src/app/core/services/common/window.service';
1212
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
1313
import { UserService } from 'src/app/core/services/misc/user.service';
1414

15+
import { debounceTime } from 'rxjs/operators';
16+
import { Subject } from 'rxjs';
17+
1518
@Component({
1619
selector: 'app-business-central-complete-export-log',
1720
templateUrl: './business-central-complete-export-log.component.html',
@@ -49,23 +52,35 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {
4952

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

55+
searchQuery: string | null;
56+
57+
private searchQuerySubject = new Subject<string>();
58+
59+
5260
constructor(
5361
private formBuilder: FormBuilder,
5462
private trackingService: TrackingService,
5563
private accountingExportService: AccountingExportService,
5664
private windowService: WindowService,
5765
private paginatorService: PaginatorService,
5866
private userService: UserService
59-
) { }
67+
) {
68+
this.searchQuerySubject.pipe(
69+
debounceTime(1000)
70+
).subscribe((query: string) => {
71+
this.searchQuery = query;
72+
this.offset = 0;
73+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
74+
this.getAccountingExports(this.limit, this.offset);
75+
});
76+
}
6077

6178
openExpenseinFyle(expenseId: string) {
6279
this.windowService.openInNewTab(AccountingExportModel.getFyleExpenseUrl(expenseId));
6380
}
6481

6582
public handleSimpleSearch(query: string) {
66-
this.filteredAccountingExports = this.accountingExports.filter((group: AccountingExportList) => {
67-
return AccountingExportModel.getfilteredAccountingExports(query, group);
68-
});
83+
this.searchQuerySubject.next(query);
6984
}
7085

7186
pageSizeChanges(limit: number): void {
@@ -89,10 +104,9 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {
89104
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
90105
}
91106

92-
this.accountingExportService.getAccountingExports([BusinessCentralExportType.PURCHASE_INVOICE, BusinessCentralExportType.JOURNAL_ENTRY], [AccountingExportStatus.COMPLETE], null, limit, offset, this.selectedDateFilter).subscribe(accountingExportResponse => {
93-
if (!this.isDateSelected) {
107+
this.accountingExportService.getAccountingExports([BusinessCentralExportType.PURCHASE_INVOICE, BusinessCentralExportType.JOURNAL_ENTRY], [AccountingExportStatus.COMPLETE], null, limit, offset, this.selectedDateFilter, null, this.searchQuery).subscribe(accountingExportResponse => {
94108
this.totalCount = accountingExportResponse.count;
95-
}
109+
96110
const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: AccountingExport) =>
97111
AccountingExportModel.parseAPIResponseToExportLog(accountingExport, this.org_id)
98112
);
@@ -123,14 +137,15 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {
123137
if (!dateRange) {
124138
this.dateOptions = AccountingExportModel.getDateOptionsV2();
125139
this.selectedDateFilter = null;
140+
this.isDateSelected = false;
126141
this.getAccountingExports(paginator.limit, paginator.offset);
127142
} else if (dateRange.length && dateRange[1]) {
128143
this.hideCalendar = true;
129144
this.selectedDateFilter = {
130145
startDate: dateRange[0],
131146
endDate: dateRange[1]
132147
};
133-
148+
this.isDateSelected = true;
134149
this.trackDateFilter('existing', this.selectedDateFilter);
135150

136151
setTimeout(() => {

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
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-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
5+
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
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
[hideCalendar]="hideCalendar"
1010
[dateOptions]="dateOptions"
1111
(handleSimpleSearch)="handleSimpleSearch($event)">
1212
</app-export-log-filter>
1313

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

17-
<div *ngIf="filteredExpenses.length > 0" class="tw-p-24-px tw-border-t-1-px">
18-
<app-paginator
19-
[dropDownValue]="limit"
20-
[page]="currentPage"
21-
[totalCount]="totalCount"
22-
(pageSizeChangeEvent)="pageSizeChanges($event)"
17+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
18+
<app-paginator
19+
[dropDownValue]="limit"
20+
[page]="currentPage"
21+
[totalCount]="totalCount"
22+
(pageSizeChangeEvent)="pageSizeChanges($event)"
2323
(pageOffsetChangeEvent)="pageChanges($event)">
2424
</app-paginator>
2525
</div>
2626

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

3232
</div>
3333

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

src/app/integrations/business-central/business-central-main/business-central-export-log/business-central-skipped-export-log/business-central-skipped-export-log.component.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { ExportLogService } from 'src/app/core/services/common/export-log.servic
99
import { PaginatorService } from 'src/app/core/services/common/paginator.service';
1010
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
1111

12+
13+
import { debounceTime } from 'rxjs/operators';
14+
import { Subject } from 'rxjs';
15+
1216
@Component({
1317
selector: 'app-business-central-skipped-export-log',
1418
templateUrl: './business-central-skipped-export-log.component.html',
@@ -38,19 +42,30 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
3842

3943
selectedDateFilter: SelectedDateFilter | null;
4044

45+
searchQuery: string | null;
46+
47+
private searchQuerySubject = new Subject<string>();
48+
4149
hideCalendar: boolean;
4250

4351
constructor(
4452
private formBuilder: FormBuilder,
4553
private trackingService: TrackingService,
4654
private exportLogService: ExportLogService,
4755
private paginatorService: PaginatorService
48-
) { }
56+
) {
57+
this.searchQuerySubject.pipe(
58+
debounceTime(1000)
59+
).subscribe((query: string) => {
60+
this.searchQuery = query;
61+
this.offset = 0;
62+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
63+
this.getSkippedExpenses(this.limit, this.offset);
64+
});
65+
}
4966

5067
public handleSimpleSearch(query: string) {
51-
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
52-
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
53-
});
68+
this.searchQuerySubject.next(query);
5469
}
5570

5671
getSkippedExpenses(limit: number, offset: number) {
@@ -62,9 +77,8 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
6277
}
6378

6479
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
65-
if (!this.isDateSelected) {
66-
this.totalCount = skippedExpenses.count;
67-
}
80+
81+
this.totalCount = skippedExpenses.count;
6882

6983
skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
7084
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
@@ -103,6 +117,7 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
103117
if (!dateRange) {
104118
this.dateOptions = AccountingExportModel.getDateOptionsV2();
105119
this.selectedDateFilter = null;
120+
this.isDateSelected = false;
106121
this.getSkippedExpenses(paginator.limit, paginator.offset);
107122
} else if (dateRange.length && dateRange[1]) {
108123
this.hideCalendar = true;
@@ -111,6 +126,7 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
111126
endDate: dateRange[1]
112127
};
113128

129+
this.isDateSelected = true;
114130
this.trackDateFilter('existing', this.selectedDateFilter);
115131

116132
setTimeout(() => {
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
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-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
5+
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
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
[hideCalendar]="hideCalendar"
1010
[dateOptions]="dateOptions"
1111
(handleSimpleSearch)="handleSimpleSearch($event)">
1212
</app-export-log-filter>
1313

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

21-
<div *ngIf="filteredAccountingExports.length > 0" class="tw-p-24-px tw-border-t-1-px">
22-
<app-paginator
23-
[dropDownValue]="limit"
24-
[page]="currentPage"
25-
[totalCount]="totalCount"
26-
(pageSizeChangeEvent)="pageSizeChanges($event)"
22+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
23+
<app-paginator
24+
[dropDownValue]="limit"
25+
[page]="currentPage"
26+
[totalCount]="totalCount"
27+
(pageSizeChangeEvent)="pageSizeChanges($event)"
2728
(pageOffsetChangeEvent)="pageChanges($event)">
2829
</app-paginator>
2930
</div>
3031

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

3637
</div>
3738

38-
<app-zero-state-with-illustration *ngIf="totalCount === 0"
39+
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
3940
[mainText]="'No records to show yet!'"
4041
[subText]="'All your successful exports and their details will be stored here.'">
4142
</app-zero-state-with-illustration>
4243

43-
</div>
44+
</div>

0 commit comments

Comments
 (0)