Skip to content

Commit

Permalink
bug fix and skipped export improved search
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Feb 13, 2024
1 parent 95df041 commit 08287f1
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/app/core/models/db/expense-group.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ export type SkipExportParam = {
is_skipped: boolean;
updated_at__gte?: string;
updated_at__lte?: string;
expense_number?: string;
employee_name?: string;
employee_email?: string;
claim_number?: string;
}
10 changes: 9 additions & 1 deletion src/app/core/services/common/export-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@ export class ExportLogService {
private workspaceService: WorkspaceService
) { }

getSkippedExpenses(limit: number, offset: number, selectedDateFilter: SelectedDateFilter | null): Observable<SkipExportLogResponse> {
getSkippedExpenses(limit: number, offset: number, selectedDateFilter: SelectedDateFilter | null, query: string | null): Observable<SkipExportLogResponse> {
const workspaceId = this.workspaceService.getWorkspaceId();
const params: SkipExportParam = {
limit,
offset,
org_id: this.userService.getUserProfile().org_id,
is_skipped: true
};

if (query){
params.expense_number = query;
params.employee_email = query;
params.employee_name = query;
params.claim_number = query;
}

params.org_id = this.userService.getUserProfile().org_id;

if (selectedDateFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
}

return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter).subscribe((skippedExpenses: SkipExportLogResponse) => {
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
if (!this.isDateSelected) {
this.totalCount = skippedExpenses.count;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</app-paginator>
</div>

<app-zero-state-with-illustration *ngIf="!filteredAccountingExports.length && !selectedDateFilter && totalCount > 0"
<app-zero-state-with-illustration *ngIf="!filteredAccountingExports.length && (selectedDateFilter || searchedQuery) && totalCount > 0"
[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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class QboCompleteExportLogComponent implements OnInit {

isDateSelected: boolean = false;

searchedQuery: string | null;

private searchQuerySubject = new Subject<string>();

private org_id: string = this.userService.getUserProfile().org_id;
Expand All @@ -63,8 +65,9 @@ export class QboCompleteExportLogComponent implements OnInit {
this.searchQuerySubject.pipe(
debounceTime(1000)
).subscribe((query: string) => {
this.searchedQuery = query;
const paginator: Paginator = this.paginatorService.getPageSize(PaginatorPage.EXPORT_LOG);
this.getAccountingExports(paginator.limit, paginator.offset, query);
this.getAccountingExports(paginator.limit, paginator.offset);
});
}

Expand All @@ -91,17 +94,18 @@ export class QboCompleteExportLogComponent implements OnInit {
this.getAccountingExports(this.limit, offset);
}

private getAccountingExports(limit: number, offset:number, query? : string | null) {
private getAccountingExports(limit: number, offset:number) {
this.isLoading = true;

if (this.limit !== limit) {
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
}

this.exportLogService.getExpenseGroups(TaskLogState.COMPLETE, limit, offset, this.selectedDateFilter, null, query).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
if (!this.isDateSelected && !query) {
this.exportLogService.getExpenseGroups(TaskLogState.COMPLETE, limit, offset, this.selectedDateFilter, null, this.searchedQuery).subscribe((accountingExportResponse: ExpenseGroupResponse) => {
if (!this.isDateSelected && !this.searchedQuery) {
this.totalCount = accountingExportResponse.count;
}

const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: ExpenseGroup) =>
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</app-paginator>
</div>

<app-zero-state-with-illustration *ngIf="!filteredExpenses.length && !selectedDateFilter && totalCount > 0"
<app-zero-state-with-illustration *ngIf="!filteredExpenses.length && (selectedDateFilter || searchedQuery) && totalCount > 0"
[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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { ExportLogService } from 'src/app/core/services/common/export-log.servic
import { PaginatorService } from 'src/app/core/services/common/paginator.service';
import { WindowService } from 'src/app/core/services/common/window.service';

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

@Component({
selector: 'app-qbo-skipped-export-log',
templateUrl: './qbo-skipped-export-log.component.html',
Expand Down Expand Up @@ -39,20 +42,29 @@ export class QboSkippedExportLogComponent implements OnInit {

selectedDateFilter: SelectedDateFilter | null;

searchedQuery: string | null;

private searchQuerySubject = new Subject<string>();

constructor(
private formBuilder: FormBuilder,
private exportLogService: ExportLogService,
private accountingExportService: AccountingExportService,
private windowService: WindowService,
private paginatorService: PaginatorService
) { }
) {
this.searchQuerySubject.pipe(
debounceTime(1000)
).subscribe((query: string) => {
this.searchedQuery = query;
const paginator: Paginator = this.paginatorService.getPageSize(PaginatorPage.EXPORT_LOG);
this.getSkippedExpenses(paginator.limit, paginator.offset);
});
}

public handleSimpleSearch(event: any) {
const query = event.target.value.toLowerCase();

this.filteredExpenses = this.expenses.filter((group: SkipExportList) => {
return SkippedAccountingExportModel.getfilteredSkippedAccountingExports(query, group);
});
const query = event.target.value;
this.searchQuerySubject.next(query);
}

getSkippedExpenses(limit: number, offset: number) {
Expand All @@ -63,8 +75,8 @@ export class QboSkippedExportLogComponent implements OnInit {
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Sage300SkippedExportLogComponent implements OnInit {
this.paginatorService.storePageSize(PaginatorPage.EXPORT_LOG, limit);
}

return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter).subscribe((skippedExpenses: SkipExportLogResponse) => {
return this.exportLogService.getSkippedExpenses(limit, offset, this.selectedDateFilter, null).subscribe((skippedExpenses: SkipExportLogResponse) => {
if (!this.isDateSelected) {
this.totalCount = skippedExpenses.count;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { brandingConfig } from 'src/app/branding/branding-config';
import { AccountingExportModel } from 'src/app/core/models/db/accounting-export.model';
import { DateFilter, SelectedDateFilter } from 'src/app/core/models/qbd/misc/date-filter.model';
import { ExportLogService } from 'src/app/core/services/common/export-log.service';
import { isClassDeclaration } from 'typescript';

@Component({
selector: 'app-export-log-filter',
Expand Down Expand Up @@ -60,8 +61,6 @@ export class ExportLogFilterComponent implements OnInit {
this.exportLogForm.controls.dateRange.patchValue(this.dateOptions[3]);
}

ngOnInit(): void {
console.log(this.exportLogForm.value);
}
ngOnInit(): void {}

}

0 comments on commit 08287f1

Please sign in to comment.