Skip to content

Commit d0c6920

Browse files
Advance search for ms dynamics
1 parent 18e8c88 commit d0c6920

File tree

7 files changed

+109
-62
lines changed

7 files changed

+109
-62
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export class AccountingExportService {
6161
if (selectedDateFilter) {
6262
const exportedAtLte = selectedDateFilter.startDate.toLocaleDateString().split('/');
6363
const exportedAtGte = selectedDateFilter.endDate.toLocaleDateString().split('/');
64-
apiParams.exported_at__lte = `${exportedAtLte[2]}-${exportedAtLte[1]}-${exportedAtLte[0]}T00:00:00`;
65-
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`;
6666
}
6767

6868
if (exportedAt) {
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
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
[dateOptions]="dateOptions"
1010
(handleSimpleSearch)="handleSimpleSearch($event)">
1111
</app-export-log-filter>
1212

13-
<app-export-log-table
13+
<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-
<app-paginator
22-
[dropDownValue]="limit"
23-
[page]="currentPage"
24-
[totalCount]="totalCount"
25-
(pageSizeChangeEvent)="pageSizeChanges($event)"
21+
<div *ngIf="totalCount > 0 && !isLoading" 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)"
2627
(pageOffsetChangeEvent)="pageChanges($event)">
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]="'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

3536
</div>
3637

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

42-
</div>
43+
</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,13 +137,14 @@ 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.selectedDateFilter = {
129144
startDate: dateRange[0],
130145
endDate: dateRange[1]
131146
};
132-
147+
this.isDateSelected = true;
133148
this.trackDateFilter('existing', this.selectedDateFilter);
134149
this.getAccountingExports(paginator.limit, paginator.offset);
135150
}

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,36 +1,36 @@
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
[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">
17-
<app-paginator
18-
[dropDownValue]="limit"
19-
[page]="currentPage"
20-
[totalCount]="totalCount"
21-
(pageSizeChangeEvent)="pageSizeChanges($event)"
16+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
17+
<app-paginator
18+
[dropDownValue]="limit"
19+
[page]="currentPage"
20+
[totalCount]="totalCount"
21+
(pageSizeChangeEvent)="pageSizeChanges($event)"
2222
(pageOffsetChangeEvent)="pageChanges($event)">
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]="'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]="'No records to show yet!'"
3535
[subText]="'All your expenses that were skipped from exporting will be stored here.'">
3636
</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,17 +42,28 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
3842

3943
selectedDateFilter: SelectedDateFilter | null;
4044

45+
searchQuery: string | null;
46+
47+
private searchQuerySubject = new Subject<string>();
48+
4149
constructor(
4250
private formBuilder: FormBuilder,
4351
private trackingService: TrackingService,
4452
private exportLogService: ExportLogService,
4553
private paginatorService: PaginatorService
46-
) { }
54+
) {
55+
this.searchQuerySubject.pipe(
56+
debounceTime(1000)
57+
).subscribe((query: string) => {
58+
this.searchQuery = query;
59+
this.offset = 0;
60+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
61+
this.getSkippedExpenses(this.limit, this.offset);
62+
});
63+
}
4764

4865
public handleSimpleSearch(query: string) {
49-
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
50-
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
51-
});
66+
this.searchQuerySubject.next(query);
5267
}
5368

5469
getSkippedExpenses(limit: number, offset: number) {
@@ -60,9 +75,8 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
6075
}
6176

6277
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
63-
if (!this.isDateSelected) {
64-
this.totalCount = skippedExpenses.count;
65-
}
78+
79+
this.totalCount = skippedExpenses.count;
6680

6781
skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
6882
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
@@ -101,13 +115,15 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
101115
if (!dateRange) {
102116
this.dateOptions = AccountingExportModel.getDateOptionsV2();
103117
this.selectedDateFilter = null;
118+
this.isDateSelected = false;
104119
this.getSkippedExpenses(paginator.limit, paginator.offset);
105120
} else if (dateRange.length && dateRange[1]) {
106121
this.selectedDateFilter = {
107122
startDate: dateRange[0],
108123
endDate: dateRange[1]
109124
};
110125

126+
this.isDateSelected = true;
111127
this.trackDateFilter('existing', this.selectedDateFilter);
112128
this.getSkippedExpenses(paginator.limit, paginator.offset);
113129
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
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
[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">
17-
<app-paginator
18-
[dropDownValue]="limit"
19-
[page]="currentPage"
20-
[totalCount]="totalCount"
21-
(pageSizeChangeEvent)="pageSizeChanges($event)"
16+
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
17+
<app-paginator
18+
[dropDownValue]="limit"
19+
[page]="currentPage"
20+
[totalCount]="totalCount"
21+
(pageSizeChangeEvent)="pageSizeChanges($event)"
2222
(pageOffsetChangeEvent)="pageChanges($event)">
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]="'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]="'No records to show yet!'"
3535
[subText]="'All your expenses that were skipped from exporting will be stored here.'">
3636
</app-zero-state-with-illustration>

src/app/integrations/sage300/sage300-main/sage300-export-log/sage300-skipped-export-log/sage300-skipped-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 { environment } from 'src/environments/environment';
1414

15+
import { debounceTime } from 'rxjs/operators';
16+
import { Subject } from 'rxjs';
17+
1518
@Component({
1619
selector: 'app-sage300-skipped-export-log',
1720
templateUrl: './sage300-skipped-export-log.component.html',
@@ -41,19 +44,30 @@ export class Sage300SkippedExportLogComponent implements OnInit {
4144

4245
selectedDateFilter: SelectedDateFilter | null;
4346

47+
searchQuery: string | null;
48+
49+
private searchQuerySubject = new Subject<string>();
50+
4451
constructor(
4552
private formBuilder: FormBuilder,
4653
private trackingService: TrackingService,
4754
private exportLogService: ExportLogService,
4855
private accountingExportService: AccountingExportService,
4956
private windowService: WindowService,
5057
private paginatorService: PaginatorService
51-
) { }
58+
) {
59+
this.searchQuerySubject.pipe(
60+
debounceTime(1000)
61+
).subscribe((query: string) => {
62+
this.searchQuery = query;
63+
this.offset = 0;
64+
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
65+
this.getSkippedExpenses(this.limit, this.offset);
66+
});
67+
}
5268

5369
public handleSimpleSearch(query: string) {
54-
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
55-
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
56-
});
70+
this.searchQuerySubject.next(query);
5771
}
5872

5973
getSkippedExpenses(limit: number, offset: number) {
@@ -64,10 +78,9 @@ export class Sage300SkippedExportLogComponent implements OnInit {
6478
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
6579
}
6680

67-
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
68-
if (!this.isDateSelected) {
81+
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, this.searchQuery).subscribe((skippedExpenses: SkipExportLogResponse) => {
6982
this.totalCount = skippedExpenses.count;
70-
}
83+
7184

7285
skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
7386
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
@@ -106,12 +119,14 @@ export class Sage300SkippedExportLogComponent implements OnInit {
106119
if (!dateRange) {
107120
this.selectedDateFilter = null;
108121
this.getSkippedExpenses(paginator.limit, paginator.offset);
122+
this.isDateSelected = false;
109123
} else if (dateRange.length && dateRange[1]) {
110124
this.selectedDateFilter = {
111125
startDate: dateRange[0],
112126
endDate: dateRange[1]
113127
};
114-
128+
129+
this.isDateSelected = true;
115130
this.trackDateFilter('existing', this.selectedDateFilter);
116131
this.getSkippedExpenses(paginator.limit, paginator.offset);
117132
this.dateOptions = AccountingExportModel.getDateOptionsV2();

0 commit comments

Comments
 (0)