-
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b2b3605
View financial reports of multiple company together with currency filter
ea571f9
work on balance sheet
92ca2a3
work on trial-balance
6cda4e1
work on profit-loss
b5fecb7
work on filter
f1f23f5
add documentation
9da6c77
conflict resolve
8460411
comflict resolve
b44642f
conflict-resolve
04e3afb
add key
c29a421
set type of function
23c2ec3
conflict resolve
e37b09a
change variable name
92b1bac
otimiza and pr changes
34cd311
Removed unnecessary variables and added CSS classes
05f3d7a
convert scss
8044eb7
work on profit-loss scss
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...eb-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<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)" | ||
(searchChange)="searchChanged($event)" | ||
(expandAllChange)="expandAllEvent()" | ||
[(expandAll)]="expandAll" | ||
></filter-multi-currency> | ||
<giddh-page-loader *ngIf="showLoader | async" [cssClass]="'mt-0 mb-0'"></giddh-page-loader> | ||
<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="text-center tb-pl-bs-data"> | ||
<h2>{{ localeData?.no_data_found }}</h2> | ||
</div> | ||
</ng-container> |
182 changes: 182 additions & 0 deletions
182
.../web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import { | ||
AfterViewInit, | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
Input, | ||
OnDestroy, | ||
ViewChild, | ||
} from '@angular/core'; | ||
import { Observable, ReplaySubject } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
import { BalanceSheetData, ProfitLossRequest } from '../../models/api-models/tb-pl-bs'; | ||
import { BalanceSheetReportGridComponent } from './components/balance-sheet-grid/balance-sheet-report-grid.component'; | ||
import { cloneDeep } 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 { | ||
/** Reference to the balance sheet grid component */ | ||
@ViewChild('bsGrid', { static: true }) public bsGrid: BalanceSheetReportGridComponent; | ||
/** Indicates whether a date has been selected */ | ||
@Input() public isDateSelected: boolean = false; | ||
/** 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> = this.componentStore.inProgressReport$;; | ||
/** 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 = ""; | ||
/** Subject to handle component destruction */ | ||
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1); | ||
|
||
constructor(private changeDetectionRef: ChangeDetectorRef, private componentStore: MultiCurrencyReportsComponentStore) { | ||
this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((response) => { | ||
if (response) { | ||
let data = prepareBalanceSheetData(cloneDeep(response)); | ||
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.changeDetectionRef.detectChanges(); | ||
} else { | ||
this.data = null; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Initializes data for the balance sheet groups | ||
* @returns {void} | ||
* @param {ChildGroup[]} groupList The list of child groups | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public initData(groupList: ChildGroup[]): void { | ||
groupList.forEach((childGroup: ChildGroup) => { | ||
childGroup['isVisible'] = false; | ||
childGroup['isCreated'] = false; | ||
childGroup['isIncludedInSearch'] = true; | ||
childGroup.accounts.forEach((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 | ||
* | ||
* @returns {void} | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public ngAfterViewInit(): void { | ||
this.changeDetectionRef.detectChanges(); | ||
} | ||
|
||
/** | ||
* Filters data based on the given request | ||
* | ||
* @returns {void} | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public filterData(): void { | ||
this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); | ||
} | ||
/** | ||
* Updates the last sync date | ||
* | ||
* @param {any} event The event containing the sync date | ||
* @returns {void} | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public lastDate(event: any): void { | ||
this.lastSyncDate = event; | ||
} | ||
|
||
/** | ||
* Searches and updates data based on the provided criteria | ||
* | ||
* @returns {void} | ||
* @param {any} event The event containing search criteria | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public searchData(event: any): void { | ||
this.componentStore.creatMultiCurrencyReport({ reportType: ReportType.BalanceSheet, payload: event }); | ||
} | ||
|
||
/** | ||
* Cleans up resources when the component is destroyed | ||
* @returns {void} | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public ngOnDestroy(): void { | ||
this.destroyed$.next(true); | ||
this.destroyed$.complete(); | ||
} | ||
|
||
/** | ||
* Expands all items in the balance sheet | ||
* | ||
* @returns {void} | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public expandAllEvent(): void { | ||
setTimeout(() => { | ||
this.changeDetectionRef.detectChanges(); | ||
}, 1); | ||
dvCodeWorld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
* Updates the search text and handles search functionality | ||
* | ||
* @returns {void} | ||
* @param {string} event The new search text | ||
* @memberof BalanceSheetReportComponent | ||
*/ | ||
public searchChanged(event: string): void { | ||
this.search = event; | ||
if (!this.search) { | ||
this.expandAll = false; | ||
} | ||
this.changeDetectionRef.detectChanges(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Remove duplicate event binding
The
searchChange
event is bound twice - once in the filter component and once in the grid component. This could lead to duplicate event handling.Keep only one event binding, preferably in the filter component:
<filter-multi-currency #filter (filterValue)="searchData($event)" (onPropertyChanged)="filterData()" (lastSyncDate)="lastDate($event)" (searchChange)="searchChanged($event)" (expandAllChange)="expandAllEvent()" [(expandAll)]="expandAll" ></filter-multi-currency> <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>
Also applies to: 23-23