Skip to content

Commit

Permalink
Advance search for ms dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Mar 15, 2024
1 parent 18e8c88 commit d0c6920
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/app/core/services/common/accounting-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class AccountingExportService {
if (selectedDateFilter) {
const exportedAtLte = selectedDateFilter.startDate.toLocaleDateString().split('/');
const exportedAtGte = selectedDateFilter.endDate.toLocaleDateString().split('/');
apiParams.exported_at__lte = `${exportedAtLte[2]}-${exportedAtLte[1]}-${exportedAtLte[0]}T00:00:00`;
apiParams.exported_at__gte = `${exportedAtGte[2]}-${exportedAtGte[1]}-${exportedAtGte[0]}T23:59:59`;
apiParams.exported_at__gte = `${exportedAtLte[2]}-${exportedAtLte[1]}-${exportedAtLte[0]}T00:00:00`;
apiParams.exported_at__lte = `${exportedAtGte[2]}-${exportedAtGte[1]}-${exportedAtGte[0]}T23:59:59`;
}

if (exportedAt) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<div *ngIf="!accountingExports" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<app-loader></app-loader>
</div>

<div *ngIf="!isLoading" class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div>
<app-export-log-filter *ngIf="totalCount > 0 || selectedDateFilter"
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"
[exportLogForm]="exportLogForm"
[dateOptions]="dateOptions"
(handleSimpleSearch)="handleSimpleSearch($event)">
</app-export-log-filter>

<app-export-log-table
<app-export-log-table
*ngIf="!isLoading"
[filteredExpenseGroups]="filteredAccountingExports"
[appName]="appName"
[isExportLogTable]="true"
[isDashboardFailed]="false">
</app-export-log-table>

<div *ngIf="filteredAccountingExports.length > 0" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
(pageOffsetChangeEvent)="pageChanges($event)">
</app-paginator>
</div>

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

</div>

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

</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { WindowService } from 'src/app/core/services/common/window.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
import { UserService } from 'src/app/core/services/misc/user.service';

import { debounceTime } from 'rxjs/operators';
import { Subject } from 'rxjs';

@Component({
selector: 'app-business-central-complete-export-log',
templateUrl: './business-central-complete-export-log.component.html',
Expand Down Expand Up @@ -49,23 +52,35 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {

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

searchQuery: string | null;

private searchQuerySubject = new Subject<string>();


constructor(
private formBuilder: FormBuilder,
private trackingService: TrackingService,
private accountingExportService: AccountingExportService,
private windowService: WindowService,
private paginatorService: PaginatorService,
private userService: UserService
) { }
) {
this.searchQuerySubject.pipe(
debounceTime(1000)
).subscribe((query: string) => {
this.searchQuery = query;
this.offset = 0;
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
this.getAccountingExports(this.limit, this.offset);
});
}

openExpenseinFyle(expenseId: string) {
this.windowService.openInNewTab(AccountingExportModel.getFyleExpenseUrl(expenseId));
}

public handleSimpleSearch(query: string) {
this.filteredAccountingExports = this.accountingExports.filter((group: AccountingExportList) => {
return AccountingExportModel.getfilteredAccountingExports(query, group);
});
this.searchQuerySubject.next(query);
}

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

this.accountingExportService.getAccountingExports([BusinessCentralExportType.PURCHASE_INVOICE, BusinessCentralExportType.JOURNAL_ENTRY], [AccountingExportStatus.COMPLETE], null, limit, offset, this.selectedDateFilter).subscribe(accountingExportResponse => {
if (!this.isDateSelected) {
this.accountingExportService.getAccountingExports([BusinessCentralExportType.PURCHASE_INVOICE, BusinessCentralExportType.JOURNAL_ENTRY], [AccountingExportStatus.COMPLETE], null, limit, offset, this.selectedDateFilter, null, this.searchQuery).subscribe(accountingExportResponse => {
this.totalCount = accountingExportResponse.count;
}

const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: AccountingExport) =>
AccountingExportModel.parseAPIResponseToExportLog(accountingExport, this.org_id)
);
Expand Down Expand Up @@ -123,13 +137,14 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {
if (!dateRange) {
this.dateOptions = AccountingExportModel.getDateOptionsV2();
this.selectedDateFilter = null;
this.isDateSelected = false;
this.getAccountingExports(paginator.limit, paginator.offset);
} else if (dateRange.length && dateRange[1]) {
this.selectedDateFilter = {
startDate: dateRange[0],
endDate: dateRange[1]
};

this.isDateSelected = true;
this.trackDateFilter('existing', this.selectedDateFilter);
this.getAccountingExports(paginator.limit, paginator.offset);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<div *ngIf="!expenses" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<app-loader></app-loader>
</div>

<div *ngIf="!isLoading" class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div>
<app-export-log-filter *ngIf="totalCount > 0 || selectedDateFilter"
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"
[exportLogForm]="skipExportLogForm"
[dateOptions]="dateOptions"
(handleSimpleSearch)="handleSimpleSearch($event)">
</app-export-log-filter>

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

<div *ngIf="filteredExpenses.length > 0" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
(pageOffsetChangeEvent)="pageChanges($event)">
</app-paginator>
</div>

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

</div>

<app-zero-state-with-illustration *ngIf="totalCount === 0"
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
[mainText]="'No records to show yet!'"
[subText]="'All your expenses that were skipped from exporting will be stored here.'">
</app-zero-state-with-illustration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { ExportLogService } from 'src/app/core/services/common/export-log.servic
import { PaginatorService } from 'src/app/core/services/common/paginator.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';


import { debounceTime } from 'rxjs/operators';
import { Subject } from 'rxjs';

@Component({
selector: 'app-business-central-skipped-export-log',
templateUrl: './business-central-skipped-export-log.component.html',
Expand Down Expand Up @@ -38,17 +42,28 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {

selectedDateFilter: SelectedDateFilter | null;

searchQuery: string | null;

private searchQuerySubject = new Subject<string>();

constructor(
private formBuilder: FormBuilder,
private trackingService: TrackingService,
private exportLogService: ExportLogService,
private paginatorService: PaginatorService
) { }
) {
this.searchQuerySubject.pipe(
debounceTime(1000)
).subscribe((query: string) => {
this.searchQuery = query;
this.offset = 0;
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
this.getSkippedExpenses(this.limit, this.offset);
});
}

public handleSimpleSearch(query: string) {
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
});
this.searchQuerySubject.next(query);
}

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

return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
if (!this.isDateSelected) {
this.totalCount = skippedExpenses.count;
}

this.totalCount = skippedExpenses.count;

skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
Expand Down Expand Up @@ -101,13 +115,15 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
if (!dateRange) {
this.dateOptions = AccountingExportModel.getDateOptionsV2();
this.selectedDateFilter = null;
this.isDateSelected = false;
this.getSkippedExpenses(paginator.limit, paginator.offset);
} else if (dateRange.length && dateRange[1]) {
this.selectedDateFilter = {
startDate: dateRange[0],
endDate: dateRange[1]
};

this.isDateSelected = true;
this.trackDateFilter('existing', this.selectedDateFilter);
this.getSkippedExpenses(paginator.limit, paginator.offset);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<div *ngIf="!expenses" class="tw-flex tw-justify-center tw-items-center tw-h-screen">
<app-loader></app-loader>
</div>

<div *ngIf="!isLoading" class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div class="tw-rounded-8-px tw-shadow-app-card tw-bg-white tw-border-1-px tw-border-separator">
<div>
<app-export-log-filter *ngIf="totalCount > 0 || selectedDateFilter"
<app-export-log-filter *ngIf="totalCount > 0 || (isDateSelected || searchQuery)"
[exportLogForm]="skipExportLogForm"
[dateOptions]="dateOptions"
(handleSimpleSearch)="handleSimpleSearch($event)">
</app-export-log-filter>

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

<div *ngIf="filteredExpenses.length > 0" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
<div *ngIf="totalCount > 0 && !isLoading" class="tw-p-24-px tw-border-t-1-px">
<app-paginator
[dropDownValue]="limit"
[page]="currentPage"
[totalCount]="totalCount"
(pageSizeChangeEvent)="pageSizeChanges($event)"
(pageOffsetChangeEvent)="pageChanges($event)">
</app-paginator>
</div>

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

</div>

<app-zero-state-with-illustration *ngIf="totalCount === 0"
<app-zero-state-with-illustration *ngIf="totalCount === 0 && (!isDateSelected && !searchQuery) && !isLoading"
[mainText]="'No records to show yet!'"
[subText]="'All your expenses that were skipped from exporting will be stored here.'">
</app-zero-state-with-illustration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { WindowService } from 'src/app/core/services/common/window.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
import { environment } from 'src/environments/environment';

import { debounceTime } from 'rxjs/operators';
import { Subject } from 'rxjs';

@Component({
selector: 'app-sage300-skipped-export-log',
templateUrl: './sage300-skipped-export-log.component.html',
Expand Down Expand Up @@ -41,19 +44,30 @@ export class Sage300SkippedExportLogComponent implements OnInit {

selectedDateFilter: SelectedDateFilter | null;

searchQuery: string | null;

private searchQuerySubject = new Subject<string>();

constructor(
private formBuilder: FormBuilder,
private trackingService: TrackingService,
private exportLogService: ExportLogService,
private accountingExportService: AccountingExportService,
private windowService: WindowService,
private paginatorService: PaginatorService
) { }
) {
this.searchQuerySubject.pipe(
debounceTime(1000)
).subscribe((query: string) => {
this.searchQuery = query;
this.offset = 0;
this.currentPage = Math.ceil(this.offset / this.limit) + 1;
this.getSkippedExpenses(this.limit, this.offset);
});
}

public handleSimpleSearch(query: string) {
this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
});
this.searchQuerySubject.next(query);
}

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

return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
if (!this.isDateSelected) {
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, this.searchQuery).subscribe((skippedExpenses: SkipExportLogResponse) => {
this.totalCount = skippedExpenses.count;
}


skippedExpenses.results.forEach((skippedExpense: SkipExportLog) => {
skippedExpenseGroup.push(SkippedAccountingExportModel.parseAPIResponseToSkipExportList(skippedExpense));
Expand Down Expand Up @@ -106,12 +119,14 @@ export class Sage300SkippedExportLogComponent implements OnInit {
if (!dateRange) {
this.selectedDateFilter = null;
this.getSkippedExpenses(paginator.limit, paginator.offset);
this.isDateSelected = false;
} else if (dateRange.length && dateRange[1]) {
this.selectedDateFilter = {
startDate: dateRange[0],
endDate: dateRange[1]
};


Check failure on line 128 in src/app/integrations/sage300/sage300-main/sage300-export-log/sage300-skipped-export-log/sage300-skipped-export-log.component.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
this.isDateSelected = true;
this.trackDateFilter('existing', this.selectedDateFilter);
this.getSkippedExpenses(paginator.limit, paginator.offset);
this.dateOptions = AccountingExportModel.getDateOptionsV2();
Expand Down

0 comments on commit d0c6920

Please sign in to comment.