-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ankit | Test | View financial reports of multiple company together with currency filter #14363
Changes from 7 commits
b2b3605
ea571f9
92ca2a3
6cda4e1
b5fecb7
f1f23f5
9da6c77
8460411
b44642f
04e3afb
c29a421
23c2ec3
e37b09a
92b1bac
34cd311
05f3d7a
8044eb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||||||
<ng-container | ||||||||||
appTranslate | ||||||||||
[file]="'trial-profit-balance/balance-sheet'" | ||||||||||
(localeData)="localeData = $event" | ||||||||||
(commonLocaleData)="commonLocaleData = $event" | ||||||||||
> | ||||||||||
<filter-multi-currency | ||||||||||
#filter | ||||||||||
(filterValue)="searchData($event)" | ||||||||||
(onPropertyChanged)="filterData()" | ||||||||||
(lastSyncDate)="lastDate($event)" | ||||||||||
(seachChange)="searchChanged($event)" | ||||||||||
(expandAllChange)="expandAllEvent()" | ||||||||||
[(expandAll)]="expandAll" | ||||||||||
></filter-multi-currency> | ||||||||||
dvCodeWorld marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
<div *ngIf="showLoader | async"> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove div and add condition directly in loader There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||
<giddh-page-loader [cssClass]="'mt-0 mb-0'"></giddh-page-loader> | ||||||||||
</div> | ||||||||||
<div *ngIf="!(showLoader | async) && data"> | ||||||||||
<balance-sheet-report-grid | ||||||||||
#bsGrid | ||||||||||
[search]="search" | ||||||||||
[from]="from" | ||||||||||
[to]="to" | ||||||||||
(searchChange)="searchChanged($event)" | ||||||||||
[expandAll]="expandAll" | ||||||||||
[bsData]="data" | ||||||||||
[lastSyncDate]="lastSyncDate" | ||||||||||
></balance-sheet-report-grid> | ||||||||||
</div> | ||||||||||
<div *ngIf="!(showLoader | async) && !data" class="d-flex align-items-center justify-content-center tb-pl-bs-data"> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||
<div class="d-flex"> | ||||||||||
<h2>{{ localeData?.no_data_found }}</h2> | ||||||||||
</div> | ||||||||||
</div> | ||||||||||
</ng-container> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,245 @@ | ||||||
import { | ||||||
AfterViewInit, | ||||||
ChangeDetectionStrategy, | ||||||
ChangeDetectorRef, | ||||||
Component, | ||||||
EventEmitter, | ||||||
Input, | ||||||
OnDestroy, | ||||||
Output, | ||||||
ViewChild, | ||||||
} from '@angular/core'; | ||||||
import { select, Store } from '@ngrx/store'; | ||||||
import { Observable, ReplaySubject } from 'rxjs'; | ||||||
import { takeUntil } from 'rxjs/operators'; | ||||||
import { CompanyResponse } from '../../models/api-models/Company'; | ||||||
import { BalanceSheetData, ProfitLossRequest } from '../../models/api-models/tb-pl-bs'; | ||||||
import { BalanceSheetReportGridComponent } from './components/balance-sheet-grid/balance-sheet-report-grid.component'; | ||||||
import { AppState } from '../../store'; | ||||||
import { TBPlBsActions } from '../../actions/tl-pl.actions'; | ||||||
import { ToasterService } from '../../services/toaster.service'; | ||||||
import { cloneDeep, each } from '../../lodash-optimized'; | ||||||
import { Account, ChildGroup } from '../../models/api-models/Search'; | ||||||
import { ReportType } from '../multi-currency.const'; | ||||||
import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; | ||||||
import { prepareBalanceSheetData } from '../../store/tl-pl/tl-pl.reducer'; | ||||||
|
||||||
dvCodeWorld marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
@Component({ | ||||||
selector: 'balance-sheet-report', | ||||||
templateUrl: './balance-sheet-report.component.html', | ||||||
changeDetection: ChangeDetectionStrategy.OnPush, | ||||||
providers: [MultiCurrencyReportsComponentStore] | ||||||
}) | ||||||
export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { | ||||||
/** | ||||||
* Retrieves the selected company | ||||||
* | ||||||
* @returns {CompanyResponse} The currently selected company | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public get selectedCompany(): CompanyResponse { | ||||||
return this._selectedCompany; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Sets the selected company and fetches its data | ||||||
* | ||||||
* @param {CompanyResponse} value The company to set | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
@Input() | ||||||
public set selectedCompany(value: CompanyResponse) { | ||||||
this._selectedCompany = value; | ||||||
if (value && value.activeFinancialYear && value.financialYears && !this.isDateSelected) { | ||||||
let index = this.findIndex(value.activeFinancialYear, value.financialYears); | ||||||
this.request = { | ||||||
refresh: false, | ||||||
fy: index, | ||||||
from: value.activeFinancialYear.financialYearStarts, | ||||||
to: value.activeFinancialYear.financialYearEnds | ||||||
}; | ||||||
} | ||||||
} | ||||||
/** Holds the local JSON data */ | ||||||
public localeData: any = {}; | ||||||
/** Holds the common JSON data */ | ||||||
public commonLocaleData: any = {}; | ||||||
/** Observable to indicate if the loader is visible */ | ||||||
public showLoader: Observable<boolean>; | ||||||
/** Stores the balance sheet data */ | ||||||
public data: BalanceSheetData; | ||||||
/** Stores the profit and loss request parameters */ | ||||||
public request: ProfitLossRequest; | ||||||
/** Indicates whether all items are expanded */ | ||||||
public expandAll: boolean; | ||||||
/** Holds the search text */ | ||||||
public search: string; | ||||||
/** Stores the start date of the range */ | ||||||
public from: string; | ||||||
/** Stores the end date of the range */ | ||||||
public to: string; | ||||||
/** Stores the last sync date */ | ||||||
public lastSyncDate: string = ""; | ||||||
/** Indicates whether a date has been selected */ | ||||||
@Input() public isDateSelected: boolean = false; | ||||||
/** Reference to the balance sheet grid component */ | ||||||
@ViewChild('bsGrid', { static: true }) public bsGrid: BalanceSheetReportGridComponent; | ||||||
/** Subject to handle component destruction */ | ||||||
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1); | ||||||
/** Stores the selected company data */ | ||||||
private _selectedCompany: CompanyResponse; | ||||||
|
||||||
constructor(public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService, private componentStore: MultiCurrencyReportsComponentStore) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
this.showLoader = this.componentStore.inProgressReport$; | ||||||
this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((response) => { | ||||||
if (response) { | ||||||
let data = prepareBalanceSheetData(cloneDeep(response)); | ||||||
if (data && data.message) { | ||||||
setTimeout(() => { | ||||||
this.toaster.clearAllToaster(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.toaster.infoToast(data.message); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use showSnackbar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||||||
}, 100); | ||||||
} | ||||||
if (data && data.liabilities) { | ||||||
this.InitData(data.liabilities); | ||||||
data.liabilities.forEach(childGroup => { | ||||||
childGroup['isVisible'] = true; | ||||||
childGroup['isCreated'] = true; | ||||||
childGroup['isIncludedInSearch'] = true; | ||||||
}); | ||||||
} | ||||||
if (data && data.assets) { | ||||||
this.InitData(data.assets); | ||||||
data.assets.forEach(childGroup => { | ||||||
childGroup['isVisible'] = true; | ||||||
childGroup['isCreated'] = true; | ||||||
childGroup['isIncludedInSearch'] = true; | ||||||
}); | ||||||
} | ||||||
this.data = data; | ||||||
this.cd.detectChanges(); | ||||||
} else { | ||||||
this.data = null; | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Initializes data for the balance sheet groups | ||||||
* | ||||||
* @param {ChildGroup[]} groupList The list of child groups | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public InitData(groupList: ChildGroup[]) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also give meaning full name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
each(groupList, (childGroup: ChildGroup) => { | ||||||
childGroup['isVisible'] = false; | ||||||
childGroup['isCreated'] = false; | ||||||
childGroup['isIncludedInSearch'] = true; | ||||||
each(childGroup.accounts, (account: Account) => { | ||||||
account['isIncludedInSearch'] = true; | ||||||
account['isCreated'] = false; | ||||||
account['isVisible'] = false; | ||||||
}); | ||||||
if (childGroup.childGroups) { | ||||||
this.InitData(childGroup.childGroups); | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Detects changes after the view is initialized | ||||||
* | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public ngAfterViewInit() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add return type in over all function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
this.cd.detectChanges(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Filters data based on the given request | ||||||
* | ||||||
* | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public filterData() { | ||||||
this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); | ||||||
} | ||||||
/** | ||||||
* Updates the last sync date | ||||||
* | ||||||
* @param {*} event The event containing the sync date | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public lastDate(event: any){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Format all files in this pr There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
this.lastSyncDate = event ; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Searches and updates data based on the provided criteria | ||||||
* | ||||||
* @param {*} event The event containing search criteria | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public searchData(event: any) { | ||||||
this.componentStore.creatMultiCurrencyReport({ reportType: ReportType.BalanceSheet, payload: event }); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Cleans up resources when the component is destroyed | ||||||
* | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public ngOnDestroy(): void { | ||||||
this.destroyed$.next(true); | ||||||
this.destroyed$.complete(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Finds the index of the active financial year in the list of financial years | ||||||
* | ||||||
* @param {*} activeFY The active financial year | ||||||
* @param {*} financialYears The list of financial years | ||||||
* @returns {number} The index of the active financial year | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public findIndex(activeFY, financialYears) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type of function parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
let tempFYIndex = 0; | ||||||
each(financialYears, (fy: any, index: number) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use forEach loop and remove its import -> each There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
if (fy?.uniqueName === activeFY?.uniqueName) { | ||||||
if (index === 0) { | ||||||
tempFYIndex = index; | ||||||
} else { | ||||||
tempFYIndex = index * -1; | ||||||
} | ||||||
} | ||||||
}); | ||||||
return tempFYIndex; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Expands all items in the balance sheet | ||||||
* | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public expandAllEvent() { | ||||||
setTimeout(() => { | ||||||
this.cd.detectChanges(); | ||||||
}, 1); | ||||||
dvCodeWorld marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
/** | ||||||
* Updates the search text and handles search functionality | ||||||
* | ||||||
* @param {string} event The new search text | ||||||
* @memberof BalanceSheetReportComponent | ||||||
*/ | ||||||
public searchChanged(event: string) { | ||||||
this.search = event; | ||||||
if (!this.search) { | ||||||
this.expandAll = false; | ||||||
} | ||||||
this.cd.detectChanges(); | ||||||
} | ||||||
|
||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.