From b2b3605a41a66ddd3ba5219d4105bc3fc95d86b3 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 16 Dec 2024 13:09:09 +0530 Subject: [PATCH 01/15] View financial reports of multiple company together with currency filter --- apps/web-giddh/src/app/app.routes.ts | 1 + .../components/filter/filter.component.ts | 8 +- .../trial-balance/trial-balance.component.ts | 11 +- .../src/app/models/api-models/tb-pl-bs.ts | 1 + .../balance-sheet-report.component.html | 147 +++ .../balance-sheet-report.component.scss | 83 ++ .../balance-sheet-report.component.ts | 203 ++++ .../app/multi-currency-reports/balence.json | 607 +++++++++++ .../filter-multi-currency.component.html | 111 ++ .../filter-multi-currency.component.scss | 178 ++++ .../filter/filter-multi-currency.component.ts | 536 ++++++++++ .../multi-currency-reports.component.html | 58 ++ .../multi-currency-reports.component.scss | 8 + .../multi-currency-reports.component.ts | 128 +++ .../multi-currency-reports.module.ts | 125 +++ .../multi-currency-reports.routing.module.ts | 18 + .../multi-currency-reports.store.ts | 89 ++ .../multi-currency.const.ts | 5 + .../profit-loss-reports.component.html | 3 + .../profit-loss-reports.component.scss | 0 .../profit-loss-reports.component.ts | 36 + .../trial-balance-report.component.html | 48 + .../trial-balance-report.component.scss | 0 .../trial-balance-report.component.ts | 353 +++++++ .../src/app/multi-currency-reports/trial.json | 946 ++++++++++++++++++ .../src/app/services/apiurls/tl-pl.api.ts | 1 + .../src/app/services/tl-pl.service.ts | 49 +- .../src/app/store/tl-pl/tl-pl.reducer.ts | 7 +- .../src/assets/locale/sidebar-menu/en.json | 11 + 29 files changed, 3760 insertions(+), 11 deletions(-) create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balence.json create mode 100644 apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.routing.module.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/multi-currency.const.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial.json diff --git a/apps/web-giddh/src/app/app.routes.ts b/apps/web-giddh/src/app/app.routes.ts index 4152047e7e3..38a0fff7332 100644 --- a/apps/web-giddh/src/app/app.routes.ts +++ b/apps/web-giddh/src/app/app.routes.ts @@ -100,6 +100,7 @@ export const ROUTES: Routes = [ { path: 'vouchers', loadChildren: () => import('./vouchers/vouchers.module').then(module => module.VouchersModule), canActivate: [NeedsAuthorization] }, { path: 'group-name', loadChildren: () => import('./group-name/group-name.module').then(module => module.GroupNameModule), canActivate: [NeedsAuthorization] }, { path: 'auth-hmrc', loadChildren: () => import('./auth-hmrc/auth-hmrc.module').then(module => module.AuthHMRCModule), canActivate: [NeedsAuthorization] }, + { path: 'multi-currency-report', loadChildren: () => import('./multi-currency-reports/multi-currency-reports.module').then(module => module.MultiCurrencyReportsModule), canActivate: [NeedsAuthorization] }, { path: '**', redirectTo: 'home', pathMatch: 'full' } ] }, diff --git a/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts b/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts index ac5e070c653..837dbe7ad33 100644 --- a/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts @@ -128,7 +128,7 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { description: [] }); - this.universalDate$ = this.store.pipe(select(p => p.session.applicationDate), distinctUntilChanged(), takeUntil(this.destroyed$)); + this.universalDate$ = this.store.pipe(select(p => p.session.applicationDate), takeUntil(this.destroyed$)); } public get selectedCompany() { @@ -207,6 +207,8 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { this.selectedDateRangeUi = dayjs(a[0]).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(a[1]).format(GIDDH_NEW_DATE_FORMAT_UI); this.fromDate = dayjs(universalDate[0]).format(GIDDH_DATE_FORMAT); this.toDate = dayjs(universalDate[1]).format(GIDDH_DATE_FORMAT); + console.log("selectedDateRangeUi",this.selectedDateRangeUi); + this.filterData(); } }); @@ -311,6 +313,7 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public filterData() { + console.log("1"); this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); this.onPropertyChanged.emit(this.filterForm?.value); // this will clear the search and reset it after we click apply --G0-2745 @@ -319,6 +322,7 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public refreshData() { + console.log("2"); this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); let data = cloneDeep(this.filterForm?.value); data.refresh = true; @@ -367,6 +371,7 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public onTagSelected(ev) { + console.log("3"); this.selectedTag = ev?.value; this.filterForm.get('tagName')?.patchValue(ev?.value); this.filterForm.get('refresh')?.patchValue(true); @@ -392,6 +397,7 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { * @memberof FinancialReportsFilterComponent */ public handleBranchChange(selectedEntity: any): void { + console.log("4"); this.currentBranch.name = selectedEntity?.label; setTimeout(() => { this.expandAllChange.emit(false); diff --git a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts index 16c5c44fc87..8c419e697d0 100644 --- a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts @@ -22,7 +22,7 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { /** This will hold common JSON data */ public commonLocaleData: any = {}; public showLoader: Observable; - public data$: Observable; + public data$: Observable; public request: TrialBalanceRequest; public expandAll: boolean; public search: string; @@ -60,8 +60,10 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { } public ngOnInit() { - this.data$ = this.store.pipe(select(createSelector((p: AppState) => p.tlPl.tb.data, (p: AccountDetails) => { - let d = cloneDeep(p) as AccountDetails; + this.data$ = this.store.pipe(select(createSelector((p: AppState) => p.tlPl.tb.data, (p) => { + console.log("p",p); + + let d = cloneDeep(p); if (d) { if (d.message) { setTimeout(() => { @@ -106,8 +108,9 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { this.from = request.from; this.to = request.to; this.isDateSelected = request && request.selectedDateOption === '1'; + console.log("this.isV2",this.isV2); if (this.isV2) { - this.store.dispatch(this.tlPlActions.GetV2TrialBalance(cloneDeep(request))); + this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); } else { this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); } diff --git a/apps/web-giddh/src/app/models/api-models/tb-pl-bs.ts b/apps/web-giddh/src/app/models/api-models/tb-pl-bs.ts index a4d19a6d710..d2048a73e6e 100644 --- a/apps/web-giddh/src/app/models/api-models/tb-pl-bs.ts +++ b/apps/web-giddh/src/app/models/api-models/tb-pl-bs.ts @@ -76,6 +76,7 @@ export interface AccountDetails { openingBalance: OpeningBalance; groupDetails: ChildGroup[]; message?: string; + response?:any } export interface BalanceSheetRequest extends TrialBalanceRequest { diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html new file mode 100644 index 00000000000..c26341c427a --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html @@ -0,0 +1,147 @@ +___--______-_-_-_ + + + +
+

{{ localeData?.no_data_found }}

+ +
+ +
+
+
+ + +
+
+
+ + + + + + + + +
+
+
+ {{ localeData?.particular }} + +
+
+ +
+
+
+ {{ commonLocaleData?.app_as_of }} + + {{ + dayjs(bsData?.dates?.to, giddhDateFormat)?.toString() + | date: "dd MMMM yyyy" + }} + + {{ commonLocaleData?.app_as_of }} + + {{ + dayjs(bsData?.dates?.from, giddhDateFormat) + .add(-1, "day") + ?.toString() | date: "dd MMMM yyyy" + }} +
+ +
+
+ {{ localeData?.equity_liabilities }} +
+
+ + {{ list | json}} 4--------5 + + {{ grp | json}} 2--------3 + + + + + + +
+
+ {{ localeData?.total_liabilities }} +
+
+ + + + + + +
+
+ + + + + + +
+
+
+
+ + + +
+ +
+
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss new file mode 100644 index 00000000000..f3cb5a024ac --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss @@ -0,0 +1,83 @@ +.bs-table-grid { + th { + border: none !important; + border-bottom: 1px solid var(--color-table-primary-header-bar-border) !important; + padding: 13px 8px 14px 0 !important; + &:first-child { + padding: 0 !important; + } + i.glyphicon-search { + position: relative; + z-index: 1; + font-size: 13px; + color: var(--color-abbey); + padding-right: 8px; + cursor: pointer; + display: flex; + align-items: center; + } + input { + height: 47px; + } + } +} +.tb-wrapper { + width: 70%; + margin: auto; +} +@media (max-width: 1024px) { + .tb-wrapper { + width: 100%; + margin: auto; + .table-container { + overflow-x: auto; + } + } +} +@media screen and (max-width: 767px) { + .table-container { + .profit-loss { + tr { + th { + width: 100%; + white-space: nowrap !important; + word-break: normal; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + } + .table-container section div .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + .pl-grid-row, + .profit-loss { + .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + .top-bar { + &.row { + flex-wrap: nowrap; + overflow: initial; + } + .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts new file mode 100644 index 00000000000..4c4c43ca584 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts @@ -0,0 +1,203 @@ +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + Input, + NgZone, + OnChanges, + OnDestroy, + OnInit, + Output, + SimpleChanges, + ViewChild, +} from '@angular/core'; +import { UntypedFormControl } from '@angular/forms'; +import { each } from 'apps/web-giddh/src/app/lodash-optimized'; +import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; +import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; +import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; +import * as dayjs from 'dayjs'; +import { ReplaySubject } from 'rxjs'; +import { debounceTime, takeUntil } from 'rxjs/operators'; +import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; +import { ReportType } from '../multi-currency.const'; + +@Component({ + selector: 'balance-sheet-report', + templateUrl: './balance-sheet-report.component.html', + styleUrls: [`./balance-sheet-report.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush, + providers: [MultiCurrencyReportsComponentStore] +}) +export class BalanceSheetReportComponent implements OnInit, OnChanges, OnDestroy { + public noData: boolean = false; + public showClearSearch: boolean = false; + @Input() public search: string = ''; + public bsData: BalanceSheetData; + public synced_date:string=""; + public initFormData:any={}; + @Input() public padding: string; + public dayjs = dayjs; + @Input() public expandAll: boolean; + @Input() public searchInput: string = ''; + @Input() public from: string = ''; + @Input() public to: string = ''; + @Output() public searchChange = new EventEmitter(); + @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + public bsSearchControl: UntypedFormControl = new UntypedFormControl(); + /** This holds giddh date format */ + public giddhDateFormat: string = GIDDH_DATE_FORMAT; + /** Observable to unsubscribe all the store listeners to avoid memory leaks */ + private destroyed$: ReplaySubject = new ReplaySubject(1); + /* This will hold local JSON data */ + public localeData: any = {}; + /* This will hold common JSON data */ + public commonLocaleData: any = {}; + /** Hides the data while a new search is made to refresh the virtual list */ + public hideData: boolean; + /** True, when expand all button is toggled while search is enabled */ + public isExpandToggledDuringSearch: boolean; + + constructor(private cd: ChangeDetectorRef, private zone: NgZone, private componentStore: MultiCurrencyReportsComponentStore) { + + } + + public ngOnChanges(changes: SimpleChanges) { + if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { + this.isExpandToggledDuringSearch = true; + if (this.bsData) { + this.zone.run(() => { + if (this.bsData) { + this.toggleVisibility(this.bsData.assets, changes.expandAll.currentValue); + this.toggleVisibility(this.bsData.liabilities, changes.expandAll.currentValue); + // always make first level visible .... + if (this.bsData.liabilities) { + each(this.bsData.liabilities, (grp: any) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + each(grp.accounts, (acc: any) => { + if (acc.isIncludedInSearch) { + acc.isVisible = true; + } + }); + } + }); + } + if (this.bsData.assets) { + each(this.bsData.assets, (grp: any) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + each(grp.accounts, (acc: any) => { + if (acc.isIncludedInSearch) { + acc.isVisible = true; + } + }); + } + }); + } + + } + this.cd.detectChanges(); + }); + } + } + } + + public ngOnInit() { + this.bsSearchControl.valueChanges.pipe( + debounceTime(700), takeUntil(this.destroyed$)) + .subscribe((newValue) => { + this.searchInput = newValue; + this.hideData = true; + this.searchChange.emit(this.searchInput); + this.isExpandToggledDuringSearch = false; + if (newValue === '') { + this.showClearSearch = false; + } + setTimeout(() => { + this.hideData = false; + this.cd.detectChanges(); + }, 10); + }); + this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((data) => { + if(data){ + this.bsData = data.response; + this.synced_date = data.date; + this.initFormData = data.request; + console.log("reportDataList",data); + + this.cd.detectChanges(); + } + }); + + } + + public toggleSearch() { + this.showClearSearch = true; + + setTimeout(() => { + if (this.searchInputEl && this.searchInputEl.nativeElement) { + this.searchInputEl.nativeElement.focus(); + } + }, 200); + } + + public clickedOutside(event, el) { + if (this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') { + return; + } + + if (this.childOf(event.target, el)) { + return; + } else { + this.showClearSearch = false; + } + } + + /* tslint:disable */ + public childOf(c, p) { + while ((c = c.parentNode) && c !== p) { + } + return !!c; + } + + private toggleVisibility = (data: ChildGroup[], isVisible: boolean) => { + each(data, (grp: ChildGroup) => { + if (grp.isIncludedInSearch) { + grp.isCreated = true; + grp.isVisible = isVisible; + grp.isOpen = isVisible; + each(grp.accounts, (acc: Account) => { + if (acc.isIncludedInSearch) { + acc.isCreated = true; + acc.isVisible = isVisible; + } + }); + this.toggleVisibility(grp.childGroups, isVisible); + } + }); + } + + /** + * This will destroy all the memory used by this component + * + * @memberof BalanceSheetGridComponent + */ + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public searchData(event: any){ + console.log('creatMultiCurrencyReport', event); + this.componentStore.creatMultiCurrencyReport({reportType: ReportType.BalanceSheet,payload: event}); + } + + public getProfitLossReport(){ + console.log("getMultiCurrencyReport"); + + this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balence.json b/apps/web-giddh/src/app/multi-currency-reports/balence.json new file mode 100644 index 00000000000..61bdccb6567 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balence.json @@ -0,0 +1,607 @@ +{ + "status": "success", + "body": { + "response": { + "message": null, + "forwardedBalance": { + "amount": 1.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1.0, + "type": "DEBIT" + }, + "groupDetails": [ + { + "forwardedBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "openingBalance": { + "amount": 1261466.46, + "type": "CREDIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "General Reserves", + "uniqueName": "generalreserves", + "groupName": "Reserves & Surplus" + } + ], + "uniqueName": "reservessurplus", + "category": null, + "groupName": "Reserves & Surplus" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "profitandloss", + "category": "assets", + "groupName": "Profit and Loss" + } + ], + "accounts": [], + "uniqueName": "shareholdersfunds", + "category": "liabilities", + "groupName": "Shareholders’ Funds" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "noncurrentliabilities", + "category": "liabilities", + "groupName": "Non Current Liabilities" + }, + { + "forwardedBalance": { + "amount": 20918.46, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 20918.46, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "loanandoverdraft", + "category": null, + "groupName": "Loan and Overdraft" + }, + { + "forwardedBalance": { + "amount": 44552.54, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 44552.54, + "type": "CREDIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "gstcess", + "category": null, + "groupName": "GST CESS" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tcspayable", + "category": null, + "groupName": "TCS payable" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tdspayable", + "category": null, + "groupName": "TDS payable" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "utgst", + "category": null, + "groupName": "UTGST" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "igst", + "category": null, + "groupName": "IGST" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "cgst", + "category": null, + "groupName": "CGST" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sgst", + "category": null, + "groupName": "SGST" + }, + { + "forwardedBalance": { + "amount": 44552.54, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 44552.54, + "type": "CREDIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "salestax", + "category": null, + "groupName": "Sales Tax" + } + ], + "accounts": [], + "uniqueName": "dutiestaxes", + "category": null, + "groupName": "Duties & Taxes" + }, + { + "forwardedBalance": { + "amount": 65471.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 65471.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sundrycreditors", + "category": null, + "groupName": "Sundry Creditors" + } + ], + "accounts": [], + "uniqueName": "currentliabilities", + "category": "liabilities", + "groupName": "Current Liabilities" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "fixedassets", + "category": "assets", + "groupName": "Fixed Assets" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "noncurrentassets", + "category": "assets", + "groupName": "Non Current Assets" + }, + { + "forwardedBalance": { + "amount": 1240549.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1240549.0, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 1238968.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1238968.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sundrydebtors", + "category": null, + "groupName": "Sundry Debtors" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Tax On Export", + "uniqueName": "taxonexport", + "groupName": "Tax On Export" + } + ], + "uniqueName": "taxonexport", + "category": null, + "groupName": "Tax On Export" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Tax On Advance", + "uniqueName": "taxonadvance", + "groupName": "Tax On Advance" + } + ], + "uniqueName": "taxonadvance", + "category": null, + "groupName": "Tax On Advance" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tcsreceivable", + "category": null, + "groupName": "TCS receivable" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tdsreceivable", + "category": null, + "groupName": "TDS receivable" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Reverse Charge", + "uniqueName": "reversecharge", + "groupName": "Reverse Charge" + } + ], + "uniqueName": "reversecharge", + "category": null, + "groupName": "Reverse Charge" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "bankaccounts", + "category": null, + "groupName": "Bank Accounts" + }, + { + "forwardedBalance": { + "amount": 1580.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1580.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1580.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 1580.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Cash", + "uniqueName": "cash", + "groupName": "Cash" + } + ], + "uniqueName": "cash", + "category": null, + "groupName": "Cash" + } + ], + "accounts": [], + "uniqueName": "currentassets", + "category": "assets", + "groupName": "Current Assets" + } + ] + }, + "date": "14-12-2024", + "request": { + "reportCurrency": "INR", + "companiesList": [ + { + "name": "Ankit", + "uniqueName": "ankitin172647646628106m1q5", + "from": "14-12-2024", + "to": "14-12-2024" + }, + { + "name": "Ankit123", + "uniqueName": "ankit1in1726484360480050fed", + "from": "14-12-2024", + "to": "14-12-2024" + }, + { + "name": "AnshiUSAComp", + "uniqueName": "anshiuus17195562098160dxttu", + "from": "14-12-2024", + "to": "14-12-2024" + } + ] + } + } +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html new file mode 100644 index 00000000000..4fea6110c2c --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html @@ -0,0 +1,111 @@ + +
+
+
+
+
+
+
+ +
+
+
+
+ + Company List + + {{ company?.name }} + + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ {{initdata | json}} +
+
+ + + + + + + + + +
+ +
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss new file mode 100644 index 00000000000..39a9b0bf974 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss @@ -0,0 +1,178 @@ +.daterange-picker-tb-pl-bs { + background-color: var(--color-white) !important; + text-decoration: none; + text-align: left; + border: 1px solid var(--color-iron); + vertical-align: middle; + height: 36px; + font-size: var(--font-size-15); +} +.tb-btn-apply { + margin-top: 5px; +} +.liabilities-assets { + max-width: 760px; + width: 100%; +} +.input-wrapper:before { + position: absolute; + content: ""; + display: block; + height: 36px; + width: 1px; + background-color: var(--color-iron); + left: 37px !important; + z-index: 100; + top: 0; +} +.expand-icon { + height: 36px; + display: flex; + align-items: flex-end; +} +.expand-icon span { + display: flex; + width: 36px; + height: 36px; + justify-content: center; + align-items: center; + background-color: var(--color-white); + font-size: var(--font-size-16); + color: var(--color-giddh-blue) !important; + border: 1px solid var(--color-secondary-input-bar-border); + border-radius: 5px; +} +.download-data-icon { + display: flex; + align-items: center; + justify-content: flex-end; + a { + display: flex; + width: 36px; + height: 36px; + justify-content: center; + align-items: center; + background-color: var(--color-white); + font-size: var(--font-size-15); + color: var(--color-giddh-blue) !important; + border: 1px solid var(--color-secondary-input-bar-border); + border-radius: 5px; + } +} +.d-inline-flex { + display: inline-flex; +} +.glyphicon-triangle-bottom { + z-index: 1; + position: absolute; + left: 152px; + font-size: 9px; + color: var(--color-iron); + top: 14px; +} +.company-branch-dropdown { + width: 178px; +} +.linked-entities { + .list-item { + .entity-icon { + padding: 4px; + } + .entity-details { + margin-left: 6px; + flex: 1; + .item { + font-family: var(--font-semibold); + } + } + .default-entity { + align-items: center; + display: flex; + &:hover:after { + color: var(--color-blue); + } + .icon-favorite-selected { + color: var(--color-blue); + } + } + } +} +.icon-calender { + position: absolute; + z-index: 1; + height: 32px; + width: 36px; + display: inline-flex; + justify-content: center; + align-items: center; + height: 36px !important; + cursor: pointer; +} +@media (max-width: 1099px) and (min-width: 1019px) { + .financial-select-year { + margin-bottom: 15px; + .company-branch-dropdown { + width: 158px; + } + .expand-collapse-icon { + position: absolute; + bottom: -36px; + right: 15px; + } + } + .download-data-icon { + padding-right: 60px !important; + } +} +@media (min-width: 768px) { + .form-inline.financial-select-year .form-group { + min-width: auto !important; + } +} +@media (max-width: 991px) { + .datepicker-field { + min-width: 220px !important; + width: 220px !important; + } + .download-data-icon { + a { + width: 36px; + height: 36px; + } + } + .form-inline.financial-select-year { + flex-flow: row nowrap !important; + } + .download-data-icon { + margin: 10px 0 2px; + } +} +@media screen and (max-width: 767px) { + .tb-mobile-header { + .datepicker-field, + .custom-datepicker { + min-width: 100% !important; + width: 100% !important; + input { + min-width: 100% !important; + width: 100% !important; + text-align: center; + padding: 0 10px; + } + } + .refresh-btn { + display: flex; + width: 36px; + height: 36px; + justify-content: center; + align-items: center; + background-color: var(--color-white); + font-size: var(--font-size-15); + color: var(--color-giddh-blue) !important; + border: 1px solid var(--color-iron); + } + } + .list-inline > li { + font-size: var(--font-size-12); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts new file mode 100644 index 00000000000..781657384ee --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts @@ -0,0 +1,536 @@ +import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; +import { FormControl, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; +import { IOption } from '../../theme/ng-virtual-select/sh-options.interface'; +import * as dayjs from 'dayjs'; +import { Observable, ReplaySubject, of as observableOf } from 'rxjs'; +import { TagRequest } from '../../models/api-models/settingsTags'; +import { BsModalRef, BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; +import { GIDDH_DATE_FORMAT, GIDDH_NEW_DATE_FORMAT_UI } from '../../shared/helpers/defaultDateFormat'; +import { GIDDH_DATE_RANGE_PICKER_RANGES } from '../../app.constant'; +import { GeneralService } from '../../services/general.service'; +import { OrganizationType } from '../../models/user-login-state'; +import { BreakpointObserver } from '@angular/cdk/layout'; +import { cloneDeep, map, orderBy } from '../../lodash-optimized'; +import { SettingsTagService } from '../../services/settings.tag.service'; +import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; +import { ToasterService } from '../../services/toaster.service'; +import { select, Store } from '@ngrx/store'; +import { AppState } from '../../store'; + +@Component({ + selector: 'filter-multi-currency', + templateUrl: './filter-multi-currency.component.html', + styleUrls: [`./filter-multi-currency.component.scss`], + providers: [MultiCurrencyReportsComponentStore], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { + public today: Date = new Date(); + public selectedDateOption: string = '0'; + public filterForm: UntypedFormGroup; + public search: string = ''; + public financialOptions: IOption[] = []; + public accountSearchControl: UntypedFormControl = new UntypedFormControl(); + public tags: TagRequest[] = []; + public selectedTag: string; + @Input() public tbExportXLS: boolean = false; + @Input() public tbExportCsv: boolean = false; + @Input() public plBsExportXLS: boolean = false; + @Input() public BsExportXLS: boolean = false; + @Output() public seachChange = new EventEmitter(); + @Output() public tbExportXLSEvent = new EventEmitter(); + @Output() public tbExportCsvEvent = new EventEmitter(); + @Output() public plBsExportXLSEvent = new EventEmitter(); + /** True, when expand all operation is performed */ + @Input() public expandAll: boolean; + public expandAllChange: EventEmitter = new EventEmitter(); + public showClearSearch: boolean; + public request: any = {}; + public dateOptions: IOption[] = []; + public imgPath: string; + public universalDateICurrent: boolean = false; + /** Observable to store the branches of current company */ + public currentCompanyBranches$: Observable; + /** Stores the branch list of a company */ + public currentCompanyBranches: Array; + /** Stores the current branch */ + public currentBranch: any = { name: '', uniqueName: '' }; + /** Stores the current company */ + public activeCompany: any; + /** True, if mobile screen size is detected */ + public isMobileScreen: boolean = true; + @Input() public initdata : any = {}; + @Input() public showLoader: boolean = true; + @Input() public showLabels: boolean = false; + // @Output() public onPropertyChanged = new EventEmitter(); + @ViewChild('createTagModal', { static: true }) public createTagModal: ModalDirective; + public universalDate$: Observable; + public newTagForm: UntypedFormGroup; + /** Date format type */ + public giddhDateFormat: string = GIDDH_DATE_FORMAT; + /** directive to get reference of element */ + @ViewChild('datepickerTemplate') public datepickerTemplate: TemplateRef; + /** This will store modal reference */ + public modalRef: BsModalRef; + /** This will store selected date range to use in api */ + public selectedDateRange: any; + /** This will store selected date range to show on UI */ + public selectedDateRangeUi: any; + /** This will store available date ranges */ + public datePickerOption: any = GIDDH_DATE_RANGE_PICKER_RANGES; + /** dayjs object */ + public dayjs = dayjs; + /** Selected from date */ + public fromDate: string; + /** Selected to date */ + public toDate: string; + /** Selected range label */ + public selectedRangeLabel: any = ""; + /** This will store the x/y position of the field to show datepicker under it */ + public dateFieldPosition: any = { x: 0, y: 0 }; + /** Stores the current organization type */ + public currentOrganizationType: OrganizationType; + private destroyed$: ReplaySubject = new ReplaySubject(1); + // private _selectedCompany: CompanyResponse; + /** This will hold local JSON data */ + public localeData: any = {}; + /** This will hold common JSON data */ + public commonLocaleData: any = {}; + public companyList: any; + public currencyList: any; + @Output() public filterData: EventEmitter = new EventEmitter(); + @Output() public onPropertyChanged: EventEmitter = new EventEmitter(); + /* This will clear the select value in sh-select */ + // public forceClear$: Observable = observableOf({ status: false }); + + constructor(private fb: UntypedFormBuilder, + private cd: ChangeDetectorRef, + private componentStore: MultiCurrencyReportsComponentStore, + private settingsTagService: SettingsTagService, + private generalService: GeneralService, + private modalService: BsModalService, + private store: Store, + private breakPointObservar: BreakpointObserver, + private toaster: ToasterService + ) { + this.filterForm = this.fb.group({ + from: [''], + to: [''], + shareCompanyList: [null], + selectCurrency: [null] + }); + + this.universalDate$ = this.store.pipe(select(p => p.session.applicationDate), distinctUntilChanged(), takeUntil(this.destroyed$));; + this.componentStore.companyList$.pipe(takeUntil(this.destroyed$)).subscribe(companies => { + if (!companies || companies?.length === 0) { + return; + } + + let orderedCompanies = _.orderBy(companies, 'name'); + this.companyList = orderedCompanies; + console.log("orderedCompanies", orderedCompanies, "companies", companies); + + }); + this.componentStore.currencyList$.pipe(takeUntil(this.destroyed$)).subscribe(currency => { + if (currency) { + let currencyList = []; + currency.forEach((res) => { + currencyList.push({ label: res.code, value: res.code, additional: { symbol: res.symbol } }); + }) + this.currencyList = currencyList; + + console.log("currency-------------", this.currencyList); + } + + }); + this.componentStore.activeCompany$.pipe(takeUntil(this.destroyed$)).subscribe(response => { + if (response && this.activeCompany?.uniqueName !== response?.uniqueName) { + this.activeCompany = response; + } + + }); + } + + /** + * init form and other properties from input company + * + * @memberof FinancialReportsFilterComponent + */ + @Input() + // public set selectedCompany(value: CompanyResponse) { + // if (!value) { + // return; + // } + // this._selectedCompany = value; + // this.financialOptions = value.financialYears.map(q => { + // return { label: q?.uniqueName, value: q?.uniqueName }; + // }); + + // if (this.filterForm.get('selectedDateOption')?.value === '0' && value.activeFinancialYear) { + // this.filterForm?.patchValue({ + // to: value.activeFinancialYear.financialYearEnds, + // from: value.activeFinancialYear.financialYearStarts, + // selectedFinancialYearOption: value.activeFinancialYear?.uniqueName + // }); + // } + // } + + public ngOnInit() { + this.getTags(); + this.assignValueEditForm(); + + this.currentOrganizationType = this.generalService.currentOrganizationType; + // if (!this.showLabels) { + // this.filterForm?.patchValue({ selectedDateOption: '0' }); + // } + // this.accountSearchControl.valueChanges.pipe( + // debounceTime(700), takeUntil(this.destroyed$)) + // .subscribe((newValue) => { + // this.search = newValue; + // this.seachChange.emit(this.search); + // this.cd.detectChanges(); + // }); + + this.universalDate$.subscribe((a) => { + if (a) { + this.universalDateICurrent = false; + // assign dates + + this.filterForm?.patchValue({ + from: dayjs(a[0]).format(GIDDH_DATE_FORMAT), + to: dayjs(a[1]).format(GIDDH_DATE_FORMAT) + }); + + // if filter type is not date picker then set filter as datepicker + // if (this.filterForm.get('selectedDateOption')?.value === '0') { + // this.filterForm?.patchValue({ + // selectedDateOption: '1' + // }); + // } + + if (!this.cd['destroyed']) { + this.cd.detectChanges(); + } + /** To set local datepicker */ + let universalDate = cloneDeep(a); + this.selectedDateRange = { startDate: dayjs(a[0]), endDate: dayjs(a[1]) }; + this.selectedDateRangeUi = dayjs(a[0]).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(a[1]).format(GIDDH_NEW_DATE_FORMAT_UI); + this.fromDate = dayjs(universalDate[0]).format(GIDDH_DATE_FORMAT); + this.toDate = dayjs(universalDate[1]).format(GIDDH_DATE_FORMAT); + this.onPropertyChanged.emit(); + } + }); + // this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { + // if(activeCompany?.uniqueName !== this.activeCompany?.uniqueName) { + // this.activeCompany = activeCompany; + // } + // }); + // this.currentCompanyBranches$ = this.store.pipe(select(appStore => appStore.settings.branches), takeUntil(this.destroyed$)); + // this.currentCompanyBranches$.subscribe(response => { + // if (response?.length) { + // this.filterForm.get('branchUniqueName').setValue(""); + // this.forceClear$ = observableOf({ status: true }); + // this.currentCompanyBranches = []; + // this.currentCompanyBranches = response.map(branch => ({ + // label: branch.name, + // value: branch?.uniqueName, + // name: branch.name, + // parentBranch: branch.parentBranch + // })); + // this.currentCompanyBranches.unshift({ + // label: this.activeCompany ? this.activeCompany.name : '', + // name: this.activeCompany ? this.activeCompany.name : '', + // value: this.activeCompany ? this.activeCompany?.uniqueName : '', + // isCompany: true + // }); + // let currentBranchUniqueName; + // if (!this.currentBranch?.uniqueName) { + // // Assign the current branch only when it is not selected. This check is necessary as + // // opening the branch switcher would reset the current selected branch as this subscription is run everytime + // // branches are loaded + // if (this.currentOrganizationType === OrganizationType.Branch) { + // currentBranchUniqueName = this.generalService.currentBranchUniqueName; + // this.currentBranch = cloneDeep(response.find(branch => branch?.uniqueName === currentBranchUniqueName)) || this.currentBranch; + // } else { + // currentBranchUniqueName = this.activeCompany ? this.activeCompany?.uniqueName : ''; + // this.currentBranch = { + // name: this.activeCompany ? this.activeCompany.name : '', + // alias: this.activeCompany ? this.activeCompany.nameAlias : '', + // uniqueName: this.activeCompany ? this.activeCompany?.uniqueName : '', + // }; + // } + // } + // this.filterForm.get('branchUniqueName').setValue(this.currentBranch?.uniqueName); + // this.filterForm.updateValueAndValidity(); + // this.cd.detectChanges(); + // } else { + // if (this.generalService.companyUniqueName) { + // // Avoid API call if new user is onboarded + // this.store.dispatch(this.settingsBranchAction.GetALLBranches({ from: '', to: '', hierarchyType: BranchHierarchyType.Flatten })); + // } + // } + // }); + } + private assignValueEditForm(): void { + // this.getForm('name').setValue(planInfo?.name); + if (this.getForm('selectCurrencyList')) { + // this.getForm('selectCurrencyList').patchValue(this.currencyList); + } + if (this.getForm('shareCompanyList')) { + //this.getForm('shareCompanyList').patchValue(this.companyList); + } + } + + public getForm(controlName: string): FormControl { + return this.filterForm.get(controlName) as FormControl; + } + + public selectModule(event: any) { + let co = this.getForm('shareCompanyList').value; + console.log("co", co); + } + + public onSubmit() { + console.log("submit", this.filterForm); + let data = { + companiesList:[], + reportCurrency:'' + }; + this.getForm('shareCompanyList').value?.forEach(control => { + console.log("control", control); + + if (control) { + data.companiesList.push({from: this.getForm('from').value, to: this.getForm('to').value, uniqueName: control }); + } + }); + data.reportCurrency = this.getForm('selectCurrency').value || this.activeCompany?.baseCurrency; + console.log("DATA----",data); + + this.filterData.emit(data); + } + + public setCurrentFY() { + // set financial years based on company financial year + // this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { + // if (activeCompany && this.universalDateICurrent) { + // let activeFinancialYear = activeCompany.activeFinancialYear; + // if (activeFinancialYear) { + // // assign dates + // this.filterForm?.patchValue({ + // from: dayjs(activeFinancialYear.financialYearStarts, GIDDH_DATE_FORMAT).startOf('day').format(GIDDH_DATE_FORMAT), + // to: dayjs().format(GIDDH_DATE_FORMAT) + // }); + // } + // } + // }); + } + + public ngOnDestroy() { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public selectedDate(value: any) { + this.filterForm.controls['from'].setValue(dayjs(value.picker.startDate).format(GIDDH_DATE_FORMAT)); + this.filterForm.controls['to'].setValue(dayjs(value.picker.endDate).format(GIDDH_DATE_FORMAT)); + + } + + // public selectFinancialYearOption(v: IOption) { + // if (v.value) { + // let financialYear = this._selectedCompany.financialYears.find(p => p?.uniqueName === v.value); + // let index = this._selectedCompany.financialYears?.findIndex(p => p?.uniqueName === v.value); + // if (financialYear) { + // this.filterForm?.patchValue({ + // to: financialYear.financialYearEnds, + // from: financialYear.financialYearStarts, + // fy: index === 0 ? 0 : index * -1 + // }); + // } + // } else { + // this.filterForm?.patchValue({ + // to: '', + // from: '', + // fy: '' + // }); + // } + // this.filterData(); + // } + + // public filterData() { + // // this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); + // // this.onPropertyChanged.emit(this.filterForm?.value); + // // // this will clear the search and reset it after we click apply --G0-2745 + // // let a = this.search = ''; + // // this.seachChange.emit(a); + // } + + // public refreshData() { + // this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); + // let data = cloneDeep(this.filterForm?.value); + // data.refresh = true; + // this.onPropertyChanged.emit(data); + // this.emitExpand(false); + // } + + // public setFYFirstTime(selectedFY: string) { + // if (selectedFY) { + // let inx = this._selectedCompany.financialYears?.findIndex(p => p?.uniqueName === selectedFY); + // if (inx !== -1) { + // this.filterForm?.patchValue({ + // fy: inx === 0 ? 0 : inx * -1 + // }); + // } + // } + // } + + // public toggleTagsModal() { + // this.createTagModal.toggle(); + // } + + // public createTag() { + // this.settingsTagService.CreateTag(this.newTagForm.getRawValue()).pipe(takeUntil(this.destroyed$)).subscribe(response => { + // this.toaster.clearAllToaster(); + // if (response?.status === "success") { + // this.getTags(); + // this.toaster.successToast(this.commonLocaleData?.app_messages?.tag_created, this.commonLocaleData?.app_success); + // } else { + // this.toaster.errorToast(response?.message, response?.code); + // } + // }); + // this.toggleTagsModal(); + // } + + /** + * Emit Expand + * + * @param {boolean} event + * @memberof FinancialReportsFilterComponent + */ + // public emitExpand(event: boolean) { + // setTimeout(() => { + // this.expandAllChange.emit(event); + // }, 10); + // } + + // public onTagSelected(ev) { + // this.selectedTag = ev?.value; + // this.filterForm.get('tagName')?.patchValue(ev?.value); + // this.filterForm.get('refresh')?.patchValue(true); + // this.onPropertyChanged.emit(this.filterForm?.value); + // } + + // public dateOptionIsSelected(ev) { + // if (ev) { + // if (ev.value === '0') { + // this.selectFinancialYearOption(this.financialOptions[0]); + // } else { + // this.filterForm?.patchValue({ + // from: dayjs(this.datePickerOption.startDate).format(GIDDH_DATE_FORMAT), + // to: dayjs(this.datePickerOption.endDate).format(GIDDH_DATE_FORMAT) + // }); + // } + // } + // } + + // /** + // * Branch change handler + // * + // * @memberof FinancialReportsFilterComponent + // */ + // public handleBranchChange(selectedEntity: any): void { + // this.currentBranch.name = selectedEntity?.label; + // setTimeout(() => { + // this.expandAllChange.emit(false); + // }, 10); + // this.onPropertyChanged.emit(this.filterForm?.value); + // } + + /** + * To show the datepicker + * + * @param {*} element + * @memberof FinancialReportsFilterComponent + */ + public showGiddhDatepicker(element: any): void { + if (element) { + this.dateFieldPosition = this.generalService.getPosition(element.target); + } + this.modalRef = this.modalService.show( + this.datepickerTemplate, + Object.assign({}, { class: 'modal-lg giddh-datepicker-modal', backdrop: false, ignoreBackdropClick: false }) + ); + } + + /** + * This will hide the datepicker + * + * @memberof FinancialReportsFilterComponent + */ + public hideGiddhDatepicker(): void { + this.modalRef.hide(); + } + + /** + * Call back function for date/range selection in datepicker + * + * @param {*} value + * @memberof FinancialReportsFilterComponent + */ + public dateSelectedCallback(value?: any): void { + if (value && value.event === "cancel") { + this.hideGiddhDatepicker(); + return; + } + this.selectedRangeLabel = ""; + + if (value && value.name) { + this.selectedRangeLabel = value.name; + } + this.hideGiddhDatepicker(); + if (value && value.startDate && value.endDate) { + this.selectedDateRange = { startDate: dayjs(value.startDate), endDate: dayjs(value.endDate) }; + this.selectedDateRangeUi = dayjs(value.startDate).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(value.endDate).format(GIDDH_NEW_DATE_FORMAT_UI); + this.fromDate = dayjs(value.startDate).format(GIDDH_DATE_FORMAT); + this.toDate = dayjs(value.endDate).format(GIDDH_DATE_FORMAT); + this.filterForm.controls['from'].setValue(this.fromDate); + this.filterForm.controls['to'].setValue(this.toDate); + + } + } + + /** + * Callback for translation response complete + * + * @param {boolean} event + * @memberof FinancialReportsFilterComponent + */ + public translationComplete(event: boolean): void { + // if (event) { + // this.dateOptions = [ + // { label: this.commonLocaleData?.app_date_range, value: '1' }, + // { label: this.commonLocaleData?.app_financial_year, value: '0' } + // ]; + // } + } + + /** + * Fetching list of tags + * + * @memberof FinancialReportsFilterComponent + */ + public getTags(): void { + this.settingsTagService.GetAllTags().pipe(takeUntil(this.destroyed$)).subscribe(response => { + if (response?.status === "success" && response?.body?.length > 0) { + map(response?.body, (tag) => { + tag.value = tag.name; + tag.label = tag.name; + }); + this.tags = orderBy(response?.body, 'name'); + console.log("this.tags", this.tags); + + } + }); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html new file mode 100644 index 00000000000..378a7162f56 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html @@ -0,0 +1,58 @@ +
+ + + +
+ -----------__________----------________ + +
+
+ +
+ ________--------_______ + +
+
+ +
+ +
+
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss new file mode 100644 index 00000000000..0ca834489a5 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss @@ -0,0 +1,8 @@ +.tb-pl-bs-header-tab { + padding-top: 55px; +} +@media only screen and (max-width: 767px) { + .tb-pl-bs-header-tab { + padding-top: 15px; + } +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts new file mode 100644 index 00000000000..c2c28a0c0d1 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts @@ -0,0 +1,128 @@ +import { BreakpointObserver } from '@angular/cdk/layout'; +import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { select, Store } from '@ngrx/store'; +import { TabsetComponent } from 'ngx-bootstrap/tabs'; +import { ReplaySubject } from 'rxjs'; +import { takeUntil } from 'rxjs/operators'; +import { CompanyResponse } from '../models/api-models/Company'; +import { AppState } from '../store'; + +@Component({ + selector: 'multi-currency-report', + templateUrl: './multi-currency-reports.component.html', + styleUrls: ['./multi-currency-reports.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { + public selectedCompany: CompanyResponse; + public CanTBLoad: boolean = true; + public CanPLLoad: boolean = false; + public CanBSLoad: boolean = false; + public CanNewTBLoadOnThisEnv: boolean = false; + public isWalkoverCompany: boolean = false; + /** This will hold active tab */ + public activeTab: string = 'trial-balance'; + /** This will hold active tab index */ + public activeTabIndex: number = 0; + /** True, when tabs are navigated with the help of routing, done to prevent redundant routing as + * tab changed event is triggered on setting any tab as active which leads to a second navigation to the + * same route which cancels the previous route with route ID and doesn't highlight the menu item + */ + public preventTabChangeWithRoute: boolean; + /** This will store screen size */ + public isMobileScreen: boolean = false; + @ViewChild('staticTabsTBPL', { static: true }) public staticTabs: TabsetComponent; + private destroyed$: ReplaySubject = new ReplaySubject(1); + /** This will hold local JSON data */ + public localeData: any = {}; + /** This will hold common JSON data */ + public commonLocaleData: any = {}; + + constructor( + private store: Store, + private route: ActivatedRoute, + private router: Router, + private breakPointObservar: BreakpointObserver) { + this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { + if (activeCompany) { + this.selectedCompany = activeCompany; + } + }); + } + + /** + * This will return page heading based on active tab + * + * @param {boolean} event + * @memberof InvoiceComponent + */ + public getPageHeading(): string { + if(this.isMobileScreen){ + if(this.CanTBLoad) { + return this.localeData?.tabs?.trial_balance; + } + else if(this.CanPLLoad) { + return this.localeData?.tabs?.profit_loss; + } + else if(this.CanBSLoad) { + return this.localeData?.tabs?.balance_sheet; + } + } + else { + return " "; + } + } + + public ngOnInit() { + this.breakPointObservar.observe([ + '(max-width: 767px)' + ]).pipe(takeUntil(this.destroyed$)).subscribe(result => { + this.isMobileScreen = result.matches; + }); + + if (TEST_ENV) { + this.CanNewTBLoadOnThisEnv = true; + } else { + this.CanNewTBLoadOnThisEnv = false; + } + + this.route.queryParams.pipe(takeUntil(this.destroyed$)).subscribe((val) => { + if (val && val.tab && val.tabIndex) { + this.activeTab = val.tab; + this.activeTabIndex = val.tabIndex; + this.preventTabChangeWithRoute = true; + this.selectTab(val.tabIndex); + } + }); + } + + public selectTab(id: number) { + if (this.staticTabs && this.staticTabs.tabs && this.staticTabs.tabs[id]) { + this.staticTabs.tabs[id].active = true; + } + } + + /** + * This will destroy all the memory used by this component + * + * @memberof FinancialReportsComponent + */ + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + /** + * This will navigate to selected tab + * + * @param {string} tab + * @param {number} tabIndex + * @memberof FinancialReportsComponent + */ + public tabChanged(tab: string, tabIndex: number): void { + if (!this.preventTabChangeWithRoute) { + this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); + } + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts new file mode 100644 index 00000000000..da450131a9b --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts @@ -0,0 +1,125 @@ +import { ScrollingModule } from '@angular/cdk/scrolling'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { LaddaModule } from 'angular2-ladda'; +import { ClickOutsideModule } from 'ng-click-outside'; +import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; +import { ModalModule } from 'ngx-bootstrap/modal'; +import { PopoverModule } from 'ngx-bootstrap/popover'; +import { TabsModule } from 'ngx-bootstrap/tabs'; +import { TooltipModule } from 'ngx-bootstrap/tooltip'; + +import { AmountFieldComponentModule } from '../shared/amount-field/amount-field.module'; +import { AsideMenuAccountModule } from '../shared/aside-menu-account/aside.menu.account.module'; +import { DatepickerWrapperModule } from '../shared/datepicker-wrapper/datepicker.wrapper.module'; +import { GiddhPageLoaderModule } from '../shared/giddh-page-loader/giddh-page-loader.module'; +import { HamburgerMenuModule } from '../shared/header/components/hamburger-menu/hamburger-menu.module'; +// import { FinancialSearchPipe } from '../shared/header/pipe/financial-search.pipe'; +import { CurrencyModule } from '../shared/helpers/pipes/currencyPipe/currencyType.module'; +import { HighlightModule } from '../shared/helpers/pipes/highlightPipe/highlight.module'; +import { RecTypeModule } from '../shared/helpers/pipes/recType/recType.module'; +import { AccountDetailModalModule } from '../theme/account-detail-modal/account-detail-modal.module'; +import { ShSelectModule } from '../theme/ng-virtual-select/sh-select.module'; +import { Daterangepicker } from '../theme/ng2-daterangepicker/daterangepicker.module'; +import { TranslateDirectiveModule } from '../theme/translate/translate.directive.module'; +// import { BalanceSheetComponent } from './components/balance-sheet/balance-sheet.component'; +// import { +// BalanceSheetGridComponent, +// } from './components/balance-sheet/components/balance-sheet-grid/balance-sheet-grid.component'; +// import { +// BalanceSheetGridRowComponent, +// } from './components/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-grid-row.component'; +// import { BalanceSheetExportXlsComponent } from './components/export/balance-sheet/export-xls/export-xls.component'; +// import { ProfitLossExportXlsComponent } from './components/export/profit-loss/export-xls/export-xls.component'; +// import { TrialBalanceExportCsvComponent } from './components/export/trial-balance/export-csv/export-csv.component'; +// import { TrialBalanceExportXlsComponent } from './components/export/trial-balance/export-xls/export-xls.component'; +// import { FinancialReportsFilterComponent } from './components/filter/filter.component'; +// import { GridRowComponent } from './components/grid-row/grid-row.component'; +// import { +// ProfitLossGridRowComponent, +// } from './components/profit-loss/components/profit-loss-grid/components/profit-loss-grid-row/profit-loss-grid-row.component'; +// import { ProfitLossGridComponent } from './components/profit-loss/components/profit-loss-grid/profit-loss-grid.component'; +// import { ProfitLossComponent } from './components/profit-loss/profit-loss.component'; +// import { +// TrialBalanceGridComponent, +// } from './components/trial-balance/components/trial-balance-grid/trial-balance-grid.component'; +// import { TrialBalanceComponent } from './components/trial-balance/trial-balance.component'; +// import { FinancialAccordionDirective } from './directives/financial-accordion.directive'; +// import { AccountsFilterPipe } from './pipes/accounts-filter.pipe'; +import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; +import { MultiCurrencyReportsRoutingModule } from './multi-currency-reports.routing.module'; +import { ProfitLossReportsComponent } from './profit-loss-multi-currency/profit-loss-reports.component'; +import { FilterMultiCurrencyComponent } from './filter/filter-multi-currency.component'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTableModule } from '@angular/material/table'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatSelectModule } from '@angular/material/select'; +import { FormFieldsModule } from '../theme/form-fields/form-fields.module'; +import { BalanceSheetReportComponent } from './balance-sheet-multi-currency/balance-sheet-report.component'; + +@NgModule({ + declarations: [ + MultiCurrencyReportsComponent, + ProfitLossReportsComponent, + FilterMultiCurrencyComponent, + BalanceSheetReportComponent + // GridRowComponent, + // TrialBalanceComponent, + // ProfitLossComponent, + // ProfitLossGridComponent, + // ProfitLossGridRowComponent, + // ProfitLossExportXlsComponent, + // TrialBalanceExportCsvComponent, + // TrialBalanceExportXlsComponent, + // BalanceSheetExportXlsComponent, + // BalanceSheetComponent, + // BalanceSheetGridComponent, + // BalanceSheetGridRowComponent, + // FinancialAccordionDirective, + // FinancialSearchPipe, + // AccountsFilterPipe + ], + exports: [ + MultiCurrencyReportsComponent, CurrencyModule + ], + providers: [], + imports: [ + CommonModule, + ModalModule.forRoot(), + FormsModule, + ReactiveFormsModule, + Daterangepicker, + MultiCurrencyReportsRoutingModule, + TabsModule.forRoot(), + LaddaModule.forRoot({ + style: 'slide-left', + spinnerSize: 30 + }), + HighlightModule, + RecTypeModule, + ShSelectModule, + ClickOutsideModule, + BsDropdownModule.forRoot(), + CurrencyModule, + TooltipModule.forRoot(), + AccountDetailModalModule, + ScrollingModule, + TranslateDirectiveModule, + HamburgerMenuModule, + GiddhPageLoaderModule, + AmountFieldComponentModule, + DatepickerWrapperModule, + PopoverModule.forRoot(), + AsideMenuAccountModule, + MatTooltipModule, + MatButtonModule, + MatTableModule, + MatFormFieldModule, + MatSelectModule, + FormFieldsModule + ], +}) +export class MultiCurrencyReportsModule { +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.routing.module.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.routing.module.ts new file mode 100644 index 00000000000..ca51501958e --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.routing.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { NeedsAuthentication } from '../decorators/needsAuthentication'; +import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: '', component: MultiCurrencyReportsComponent, canActivate: [NeedsAuthentication] + } + ]) + ], + exports: [RouterModule] +}) +export class MultiCurrencyReportsRoutingModule { +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts new file mode 100644 index 00000000000..0703492d902 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts @@ -0,0 +1,89 @@ +import { Injectable } from "@angular/core"; +import { ComponentStore, tapResponse } from "@ngrx/component-store"; +import { Observable, switchMap, catchError, EMPTY, of, mergeMap } from "rxjs"; +import { AppState } from "../store"; +import { Store } from "@ngrx/store"; +import { ToasterService } from "../services/toaster.service"; +import { TlPlService } from "../services/tl-pl.service"; + +export interface MultiCurrencyReportsState { + reportDataList: any; + inProgressReport: boolean; +} + +const DEFAULT_STATE: MultiCurrencyReportsState = { + reportDataList: null, + inProgressReport: false +}; + +@Injectable() +export class MultiCurrencyReportsComponentStore extends ComponentStore { + + constructor( + private store: Store, + private toaster: ToasterService, + private TlPlService: TlPlService + ) { + super(DEFAULT_STATE); + } + public reportDataList$: Observable = this.select(state => state.reportDataList); + public universalDate$: Observable = this.select(this.store.select(state => state.session.applicationDate), (response) => response); + public companyList$: Observable = this.select(this.store.select((state) => state.session.companies), (response) => response); + public currencyList$: Observable = this.select(this.store.select(state => state.session.currencies), (response) => response); + public activeCompany$: Observable = this.select(this.store.select(state => state.session.activeCompany), (response) => response); + + /** + * Save list of Payment Liability + * + * @memberof VatReportComponentStore + */ + readonly getMultiCurrencyReport = this.effect((data: Observable) => { + return data.pipe( + switchMap((req) => { + console.log("req------",req); + + this.patchState({ reportDataList: null, inProgressReport: true }); + return this.TlPlService.getMultiCurrencyReport(req).pipe( + tapResponse( + (res: any) => { + if (res?.status === "success" && res.body) { + return this.patchState({ reportDataList: res.body, inProgressReport: false }); + } else { + res?.message && this.toaster.showSnackBar("error", res.message); + return this.patchState({ reportDataList: null, inProgressReport: false }); + } + }, + (error: any) => { + this.toaster.showSnackBar("error", error); + return this.patchState({ reportDataList: null, inProgressReport: false }); + } + ), + catchError((err) => EMPTY) + ); + }) + ); + }); + + readonly creatMultiCurrencyReport = this.effect((data: Observable) => { + return data.pipe( + switchMap((req) => { + console.log("req------",req); + return this.TlPlService.creatMultiCurrencyReport(req.reportType, req.payload).pipe( + tapResponse( + (res: any) => { + if (res?.status === "success" && res.body?.file) { + this.toaster.showSnackBar("success", res.body.file); + } else { + res?.message && this.toaster.showSnackBar("error", res.message); + } + }, + (error: any) => { + this.toaster.showSnackBar("error", error); + } + ), + catchError((err) => EMPTY) + ); + }) + ); + }); +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency.const.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency.const.ts new file mode 100644 index 00000000000..0f67bfcb17d --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency.const.ts @@ -0,0 +1,5 @@ +export enum ReportType { + TrialBalance = "trial-balance", + ProfitLoss = "profit-loss", + BalanceSheet = "balance-sheet" +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.html b/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.html new file mode 100644 index 00000000000..ebfcc6167d1 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.scss b/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.ts b/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.ts new file mode 100644 index 00000000000..4e8dd3cd8ca --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.ts @@ -0,0 +1,36 @@ +import { AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; +import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; +import { ReportType } from '../multi-currency.const'; +import { Observable } from 'rxjs'; +import { EventEmitter } from 'stream'; + + +@Component({ + selector: 'profit-loss-reports', + templateUrl: './profit-loss-reports.component.html', + providers: [MultiCurrencyReportsComponentStore] +}) + +export class ProfitLossReportsComponent { + public showLoader$: Observable; + public data$: Observable; + @Input() public isV2: boolean = false; + @Input() public isDateSelected: boolean = false; + constructor(private cd: ChangeDetectorRef, private componentStore: MultiCurrencyReportsComponentStore) { + + } + + public ngOnInit() { + + } + public searchData(event: any){ + console.log('creatMultiCurrencyReport', event); + this.componentStore.creatMultiCurrencyReport({reportType: ReportType.ProfitLoss,payload: event}); + } + + public getProfitLossReport(){ + console.log("getMultiCurrencyReport"); + + this.componentStore.getMultiCurrencyReport(ReportType.ProfitLoss); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.html new file mode 100644 index 00000000000..7bb7c5f49c4 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.html @@ -0,0 +1,48 @@ + + +
+ +
+
+ ________--------_______ + +
+
+
+

{{ localeData?.no_data_found }}

+
+
+
+ + + + + + diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.scss b/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.ts new file mode 100644 index 00000000000..9ebb2f4b9bf --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.ts @@ -0,0 +1,353 @@ +import { trigger, state, style, transition, animate } from '@angular/animations'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + Input, + NgZone, + OnChanges, + OnDestroy, + OnInit, + Output, + SimpleChanges, + ViewChild, +} from '@angular/core'; +import { UntypedFormControl } from '@angular/forms'; +import { cloneDeep, each } from 'apps/web-giddh/src/app/lodash-optimized'; +import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; +import { AccountDetails, TrialBalanceRequest } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; +import { Observable, ReplaySubject } from 'rxjs'; +import { debounceTime, takeUntil } from 'rxjs/operators'; +import { AppState } from '../../store'; +import { createSelector, select, Store } from '@ngrx/store'; +import { TBPlBsActions } from '../../actions/tl-pl.actions'; +import { ToasterService } from '../../services/toaster.service'; +import { CompanyResponse } from '../../models/api-models/Company'; + +@Component({ + selector: 'trial-balance-report', + templateUrl: './trial-balance-report.component.html', + styleUrls: [`./trial-balance-report.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush, + animations: [ + trigger("slideInOut", [ + state("in", style({ + transform: "translate3d(0, 0, 0)", + })), + state("out", style({ + transform: "translate3d(100%, 0, 0)", + })), + transition("in => out", animate("400ms ease-in-out")), + transition("out => in", animate("400ms ease-in-out")), + ]), + ], +}) +export class TrialBalanceReportComponent implements OnInit, OnChanges, OnDestroy { + + public noData: boolean; + public accountSearchControl: UntypedFormControl = new UntypedFormControl(); + @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + public showClearSearch: boolean = false; + public search: string = ''; + public from: string = ''; + public to: string = ''; + public searchInput: string = ''; + public padLeft: number = 30; + @Input() public showLoader: boolean; + @Input() public data: AccountDetails; + @Input() public expandAll: boolean; + public searchChange = new EventEmitter(); + /** Observable to unsubscribe all the store listeners to avoid memory leaks */ + private destroyed$: ReplaySubject = new ReplaySubject(1); + /* This will hold local JSON data */ + public localeData: any = {}; + /* This will hold common JSON data */ + public commonLocaleData: any = {}; + /** Hides the data while a new search is made to refresh the virtual list */ + public hideData: boolean; + /** True, when expand all button is toggled while search is enabled */ + public isExpandToggledDuringSearch: boolean; + /** Account update modal state */ + public accountAsideMenuState: string = "out"; + /** Account group unique name */ + public activeGroupUniqueName: string = ""; + /** Holds account details */ + public accountDetails: any; + public showLoader$: Observable; + public data$: Observable; + public request: TrialBalanceRequest; + @ViewChild('tbGrid', { static: true }) public tbGrid: TrialBalanceReportComponent; + @Input() public isV2: boolean = false; + @Input() public isDateSelected: boolean = false; + private _selectedCompany: CompanyResponse; + + constructor(private cd: ChangeDetectorRef, private zone: NgZone, + private store: Store, + public tlPlActions: TBPlBsActions, + private toaster: ToasterService) { + this.showLoader$ = this.store.pipe(select(p => p.tlPl.tb.showLoader), takeUntil(this.destroyed$)); + + + } + + public get selectedCompany(): CompanyResponse { + return this._selectedCompany; + } + + // set company and fetch data... + @Input() + public set selectedCompany(value: CompanyResponse) { + this._selectedCompany = value; + if (value && value.activeFinancialYear && !this.isDateSelected) { + this.request = { + refresh: false, + from: value.activeFinancialYear.financialYearStarts, + to: this.selectedCompany.activeFinancialYear.financialYearEnds + }; + } + } + + public ngOnInit() { + this.accountSearchControl.valueChanges.pipe( + debounceTime(700), takeUntil(this.destroyed$)) + .subscribe((newValue) => { + this.searchInput = newValue; + this.hideData = true; + this.searchChange.emit(this.searchInput); + this.isExpandToggledDuringSearch = false; + if (newValue === '') { + this.showClearSearch = false; + } + setTimeout(() => { + this.hideData = false; + this.cd.detectChanges(); + }, 10); + }); + + this.data$ = this.store.pipe(select(createSelector((p: AppState) => p.tlPl.tb.data, (p: AccountDetails) => { + let d = cloneDeep(p) as AccountDetails; + if (d) { + if (d.message) { + setTimeout(() => { + this.toaster.clearAllToaster(); + this.toaster.infoToast(d.message); + }, 100); + } + this.InitData(d.groupDetails); + d.groupDetails.forEach(g => { + g.isVisible = true; + g.isCreated = true; + }); + } + return d; + })), takeUntil(this.destroyed$)); + this.data$.pipe(takeUntil(this.destroyed$)).subscribe(() => { + this.cd.markForCheck(); + }); + } + + ///**** + + public InitData(d: ChildGroup[]) { + each(d, (grp: ChildGroup) => { + grp.isVisible = false; + grp.isCreated = false; + grp.isIncludedInSearch = true; + each(grp.accounts, (acc: Account) => { + acc.isIncludedInSearch = true; + acc.isCreated = false; + acc.isVisible = false; + }); + if (grp.childGroups) { + this.InitData(grp.childGroups); + } + }); + } + + public ngAfterViewInit() { + this.cd.detectChanges(); + } + + public filterData(request: TrialBalanceRequest) { + this.from = request.from; + this.to = request.to; + this.isDateSelected = request && request.selectedDateOption === '1'; + if (this.isV2) { + this.store.dispatch(this.tlPlActions.GetV2TrialBalance(cloneDeep(request))); + } else { + this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); + } + } + + + public expandAllEvent() { + setTimeout(() => { + this.cd.detectChanges(); + }, 1); + } + + public searchChanged(event: string) { + this.search = event; + if (!this.search) { + this.expandAll = false; + } + this.cd.detectChanges(); + } + + + + + + ////**** + + + + public ngOnChanges(changes: SimpleChanges) { + if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { + this.isExpandToggledDuringSearch = true; + if (this.data$) { + this.zone.runOutsideAngular(() => { + this.toggleGroupVisibility(this.data.groupDetails, changes.expandAll.currentValue); + if (this.data$) { + // always make first level visible .... + each(this.data.groupDetails, (grp: ChildGroup) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + grp.isCreated = true; + grp.isOpen = false; + each(grp.accounts, (acc: Account) => { + if (acc.isIncludedInSearch) { + acc.isVisible = false; + acc.isCreated = false; + } + }); + } + }); + } + }); + } + } + } + + /** + * This will destroy all the memory used by this component + * + * @memberof TrialBalanceGridComponent + */ + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public markForCheck() { + this.cd.markForCheck(); + } + + public trackByFn(index, item: ChildGroup) { + return item?.uniqueName; + } + + public toggleSearch() { + this.showClearSearch = true; + + setTimeout(() => { + if (this.searchInputEl && this.searchInputEl.nativeElement) { + this.searchInputEl.nativeElement.focus(); + } + }, 200); + } + + public clickedOutside(event, el) { + if (this.accountSearchControl?.value !== null && this.accountSearchControl?.value !== '') { + return; + } + + if (this.childOf(event.target, el)) { + return; + } else { + this.showClearSearch = false; + } + } + + /* tslint:disable */ + public childOf(c, p) { + while ((c = c.parentNode) && c !== p) { + } + return !!c; + } + + /** + * Toggles group visibility + * + * @param {Array} group Groups received + * @param {boolean} isVisible Current visibility status + * @memberof TrialBalanceGridComponent + */ + public toggleGroupVisibility(group: Array, isVisible: boolean): void { + for (let groupIndex = 0; groupIndex < group?.length; groupIndex++) { + const currentGroup: ChildGroup = group[groupIndex]; + if (currentGroup.isIncludedInSearch) { + currentGroup.isCreated = isVisible; + currentGroup.isVisible = isVisible; + currentGroup.isOpen = isVisible; + for (let accountIndex = 0; accountIndex < currentGroup.accounts?.length; accountIndex++) { + const currentAccount: Account = currentGroup.accounts[accountIndex]; + if (currentAccount.isIncludedInSearch) { + currentAccount.isCreated = isVisible; + currentAccount.isVisible = isVisible; + } + } + if (currentGroup.childGroups?.length) { + this.toggleGroupVisibility(currentGroup.childGroups, isVisible); + } + } + } + } + + /** + * Shows the account update modal + * + * @param {*} account + * @memberof TrialBalanceGridComponent + */ + public openAccountModal(account: any): void { + this.accountDetails = account; + this.activeGroupUniqueName = account?.parentGroups[account?.parentGroups?.length - 1]?.uniqueName; + this.toggleAccountAsidePane(); + } + + /** + * Toggle's account update modal + * + * @memberof TrialBalanceGridComponent + */ + public toggleAccountAsidePane(): void { + this.accountAsideMenuState = this.accountAsideMenuState === "out" ? "in" : "out"; + this.toggleBodyClass(); + } + + /** + * Toggle's fixed class in body + * + * @memberof TrialBalanceGridComponent + */ + public toggleBodyClass() { + if (this.accountAsideMenuState === "in") { + document.querySelector("body").classList.add("fixed"); + } else { + document.querySelector("body").classList.remove("fixed"); + } + } + + /** + * Callback function on account modal close + * + * @param {*} event + * @memberof TrialBalanceGridComponent + */ + public getUpdatedList(event: any): void { + this.toggleAccountAsidePane(); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial.json b/apps/web-giddh/src/app/multi-currency-reports/trial.json new file mode 100644 index 00000000000..c64f6284084 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial.json @@ -0,0 +1,946 @@ +{ + "status": "success", + "body": { + "response": { + "message": null, + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "groupDetails": [ + { + "forwardedBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "openingBalance": { + "amount": 44025.18, + "type": "CREDIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "General Reserves", + "uniqueName": "generalreserves", + "groupName": "Reserves & Surplus" + } + ], + "uniqueName": "reservessurplus", + "groupName": "Reserves & Surplus", + "category": null + } + ], + "accounts": [], + "uniqueName": "shareholdersfunds", + "groupName": "Shareholders’ Funds", + "category": "liabilities" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "noncurrentliabilities", + "groupName": "Non Current Liabilities", + "category": "liabilities" + }, + { + "forwardedBalance": { + "amount": 730.05, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 730.05, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "loanandoverdraft", + "groupName": "Loan and Overdraft", + "category": null + }, + { + "forwardedBalance": { + "amount": 1554.88, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1554.88, + "type": "CREDIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "gstcess", + "groupName": "GST CESS", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tcspayable", + "groupName": "TCS payable", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tdspayable", + "groupName": "TDS payable", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "utgst", + "groupName": "UTGST", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "igst", + "groupName": "IGST", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "cgst", + "groupName": "CGST", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sgst", + "groupName": "SGST", + "category": null + }, + { + "forwardedBalance": { + "amount": 1554.88, + "type": "CREDIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 1554.88, + "type": "CREDIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "salestax", + "groupName": "Sales Tax", + "category": null + } + ], + "accounts": [], + "uniqueName": "dutiestaxes", + "groupName": "Duties & Taxes", + "category": null + }, + { + "forwardedBalance": { + "amount": 2284.94, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 2284.94, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sundrycreditors", + "groupName": "Sundry Creditors", + "category": null + } + ], + "accounts": [], + "uniqueName": "currentliabilities", + "groupName": "Current Liabilities", + "category": "liabilities" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "fixedassets", + "groupName": "Fixed Assets", + "category": "assets" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "noncurrentassets", + "groupName": "Non Current Assets", + "category": "assets" + }, + { + "forwardedBalance": { + "amount": 43295.13, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 43295.13, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Tax On Export", + "uniqueName": "taxonexport", + "groupName": "Tax On Export" + } + ], + "uniqueName": "taxonexport", + "groupName": "Tax On Export", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Tax On Advance", + "uniqueName": "taxonadvance", + "groupName": "Tax On Advance" + } + ], + "uniqueName": "taxonadvance", + "groupName": "Tax On Advance", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tcsreceivable", + "groupName": "TCS receivable", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "tdsreceivable", + "groupName": "TDS receivable", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Reverse Charge", + "uniqueName": "reversecharge", + "groupName": "Reverse Charge" + } + ], + "uniqueName": "reversecharge", + "groupName": "Reverse Charge", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "bankaccounts", + "groupName": "Bank Accounts", + "category": null + }, + { + "forwardedBalance": { + "amount": 55.14, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 55.14, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 55.14, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 55.14, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Cash", + "uniqueName": "cash", + "groupName": "Cash" + } + ], + "uniqueName": "cash", + "groupName": "Cash", + "category": null + }, + { + "forwardedBalance": { + "amount": 43239.98, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 43239.98, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "sundrydebtors", + "groupName": "Sundry Debtors", + "category": null + } + ], + "accounts": [], + "uniqueName": "currentassets", + "groupName": "Current Assets", + "category": "assets" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Sales", + "uniqueName": "sales", + "groupName": "Sales" + } + ], + "uniqueName": "sales", + "groupName": "Sales", + "category": null + } + ], + "accounts": [], + "uniqueName": "revenuefromoperations", + "groupName": "Revenue From Operations", + "category": "income" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "dividendincome", + "groupName": "Dividend Income", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "interestincome", + "groupName": "Interest Income", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Exchange Gain", + "uniqueName": "exchangegain", + "groupName": "Exchange Gain" + } + ], + "uniqueName": "exchangegain", + "groupName": "Exchange Gain", + "category": null + } + ], + "accounts": [], + "uniqueName": "otherincome", + "groupName": "Other Income", + "category": "income" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Purchases", + "uniqueName": "purchases", + "groupName": "Purchases" + } + ], + "uniqueName": "purchases", + "groupName": "Purchases", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Discount", + "uniqueName": "discount", + "groupName": "Discount" + } + ], + "uniqueName": "discount", + "groupName": "Discount", + "category": null + } + ], + "accounts": [], + "uniqueName": "operatingcost", + "groupName": "Operating Cost", + "category": "expenses" + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [ + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "dividendexpense", + "groupName": "Dividend Expense", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [], + "uniqueName": "interestexpense", + "groupName": "Interest Expense", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Exchange Loss", + "uniqueName": "exchangeloss", + "groupName": "Exchange Loss" + } + ], + "uniqueName": "exchangeloss", + "groupName": "Exchange Loss", + "category": null + }, + { + "forwardedBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "childGroups": [], + "accounts": [ + { + "creditTotal": 0.0, + "debitTotal": 0.0, + "closingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "openingBalance": { + "amount": 0.0, + "type": "DEBIT" + }, + "currency": { + "code": "INR", + "symbol": null + }, + "name": "Round Off", + "uniqueName": "roundoff", + "groupName": "Other Indirect Expenses" + } + ], + "uniqueName": "otherindirectexpenses", + "groupName": "Other Indirect Expenses", + "category": null + } + ], + "accounts": [], + "uniqueName": "indirectexpenses", + "groupName": "Indirect Expenses", + "category": "expenses" + } + ] + }, + "date": "14-12-2024", + "request": { + "reportCurrency": "LTL", + "companiesList": [ + { + "name": null, + "uniqueName": "ankit1in1726484360480050fed", + "from": "14-11-2024", + "to": "14-12-2024" + }, + { + "name": null, + "uniqueName": "anshiuus17195562098160dxttu", + "from": "14-11-2024", + "to": "14-12-2024" + } + ] + } + } +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/services/apiurls/tl-pl.api.ts b/apps/web-giddh/src/app/services/apiurls/tl-pl.api.ts index a1b97d6f1dd..28cfafb58bf 100644 --- a/apps/web-giddh/src/app/services/apiurls/tl-pl.api.ts +++ b/apps/web-giddh/src/app/services/apiurls/tl-pl.api.ts @@ -7,5 +7,6 @@ export const TB_PL_BS_API = { DOWNLOAD_TRIAL_BALANCE_EXCEL: 'company/:companyUniqueName/trial-balance-export', DOWNLOAD_BALANCE_SHEET_EXCEL: 'company/:companyUniqueName/v2/balance-sheet-collapsed-download', DOWNLOAD_PROFIT_LOSS_EXCEL: 'company/:companyUniqueName/v2/profit-loss-collapsed-download', + GET_MULTI_CURRENCY_REPORT: 'v2/company/:companyUniqueName/multicompany/:reportType' }; diff --git a/apps/web-giddh/src/app/services/tl-pl.service.ts b/apps/web-giddh/src/app/services/tl-pl.service.ts index fdd25696601..e9b31b8d538 100644 --- a/apps/web-giddh/src/app/services/tl-pl.service.ts +++ b/apps/web-giddh/src/app/services/tl-pl.service.ts @@ -32,8 +32,9 @@ export class TlPlService { } else { params.branchUniqueName = ''; } - return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_TRIAL_BALANCE - ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)), params).pipe( + return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT + ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) + ?.replace(':reportType', ("trial-balance")) ).pipe( map((res) => { let data: BaseResponse = res; data.request = request; @@ -119,8 +120,9 @@ export class TlPlService { ?.filter(p => request[p] != null) .reduce((r, i) => ({ ...r, [i]: request[i] }), {})); - return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_BALANCE_SHEET - ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)), filteredRequest).pipe( + return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT + ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) + ?.replace(':reportType', ("balance-sheet"))).pipe( map((res) => { let data: BaseResponse = res; data.request = request; @@ -179,4 +181,43 @@ export class TlPlService { }), catchError((e) => this.errorHandler.HandleCatch(e))); } + + /** + * Get V2 Trial Balance + */ + public getMultiCurrencyReport(reportType: string): Observable> { + this.companyUniqueName = this.generalService.companyUniqueName; + return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT + ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) + ?.replace(':reportType', (reportType)) ).pipe( + map((res) => { + let data: BaseResponse = res; + data.request = ''; + console.log("data",data); + + return data; + }), + catchError((e) => this.errorHandler.HandleCatch(e, ''))); + } + + + /** + * Get V2 Trial Balance + */ + public creatMultiCurrencyReport(reportType: string, payload: any): Observable> { + this.companyUniqueName = this.generalService.companyUniqueName; + return this.http.post(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT + ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) + ?.replace(':reportType', (reportType)), payload ).pipe( + map((res) => { + let data: BaseResponse = res; + data.request = ''; + console.log("data",data); + + return data; + }), + catchError((e) => this.errorHandler.HandleCatch(e, ''))); + } + + } diff --git a/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts b/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts index 80bf3390404..1d5cc50647e 100644 --- a/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts +++ b/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts @@ -64,7 +64,10 @@ export function tbPlBsReducer(state = initialState, action: CustomActions): TBPl case COMMON_ACTIONS.RESET_APPLICATION_DATA: { return Object.assign({}, state, initialState); } - case TBPlBsActions.GET_TRIAL_BALANCE_RESPONSE: + case TBPlBsActions.GET_TRIAL_BALANCE_RESPONSE:{ + console.log("GET_TRIAL_BALANCE_RESPONSE"); + + } case TBPlBsActions.GET_V2_TRIAL_BALANCE_RESPONSE: { // no payload means error from server if (action.payload) { @@ -120,7 +123,7 @@ export function tbPlBsReducer(state = initialState, action: CustomActions): TBPl } case TBPlBsActions.GET_BALANCE_SHEET_RESPONSE: { - let data: BalanceSheetData = prepareBalanceSheetData(cloneDeep(action.payload)); + let data: BalanceSheetData = prepareBalanceSheetData(cloneDeep(action.payload.response)); if (data) { if (state?.bs?.data) { data.dates = cloneDeep(state.bs.data.dates); diff --git a/apps/web-giddh/src/assets/locale/sidebar-menu/en.json b/apps/web-giddh/src/assets/locale/sidebar-menu/en.json index 53387906572..e3c3897f22e 100644 --- a/apps/web-giddh/src/assets/locale/sidebar-menu/en.json +++ b/apps/web-giddh/src/assets/locale/sidebar-menu/en.json @@ -615,6 +615,17 @@ "label": "Import", "link": "/pages/import/select-type", "icon": "icon-tally-import1" + }, + { + "label": "Multi-currency Report", + "link": "/pages/multi-currency-report", + "icon": "icon-tally-import1", + "description": "Multi-currency report", + "additional": { + "queryParams": { + "voucherVersion": 2 + } + } } ] } From ea571f916df22b96767be7dcbc4afd6e838f80b2 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 16 Dec 2024 16:35:23 +0530 Subject: [PATCH 02/15] work on balance sheet --- .../trial-balance/trial-balance.component.ts | 16 +- .../balance-sheet-report.component.html | 27 ++ .../balance-sheet-report.component.ts | 170 +++++++++++++ .../balance-sheet-report-grid.component.html | 233 ++++++++++++++++++ .../balance-sheet-report-grid.component.scss | 83 +++++++ .../balance-sheet-report-grid.component.ts | 180 ++++++++++++++ ...lance-sheet-report-grid-row.component.html | 100 ++++++++ ...lance-sheet-report-grid-row.component.scss | 20 ++ ...balance-sheet-report-grid-row.component.ts | 59 +++++ .../multi-currency-reports.component.html | 8 +- .../multi-currency-reports.component.ts | 134 +++++++++- .../multi-currency-reports.module.ts | 25 +- .../src/app/services/tl-pl.service.ts | 5 +- 13 files changed, 1037 insertions(+), 23 deletions(-) create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts diff --git a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts index 8c419e697d0..4045edfd2f3 100644 --- a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts @@ -11,10 +11,13 @@ import { AccountDetails, TrialBalanceRequest } from '../../../models/api-models/ import { ToasterService } from '../../../services/toaster.service'; import { AppState } from '../../../store'; import { TrialBalanceGridComponent } from './components/trial-balance-grid/trial-balance-grid.component'; +import { MultiCurrencyReportsComponentStore } from '../../../multi-currency-reports/multi-currency-reports.store'; +import { ReportType } from '../../../multi-currency-reports/multi-currency.const'; @Component({ selector: 'trial-balance', - templateUrl: './trial-balance.component.html' + templateUrl: './trial-balance.component.html', + providers: [MultiCurrencyReportsComponentStore] }) export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { /** This will hold local JSON data */ @@ -38,7 +41,8 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { private store: Store, private cd: ChangeDetectorRef, public tlPlActions: TBPlBsActions, - private toaster: ToasterService) { + private toaster: ToasterService, + private componentStore: MultiCurrencyReportsComponentStore) { this.showLoader = this.store.pipe(select(p => p.tlPl.tb.showLoader), takeUntil(this.destroyed$)); } @@ -110,10 +114,16 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { this.isDateSelected = request && request.selectedDateOption === '1'; console.log("this.isV2",this.isV2); if (this.isV2) { - this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); + this.store.dispatch(this.tlPlActions.GetV2TrialBalance(cloneDeep(request))); } else { this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); } + //this.getTrialBalanceReport(); + } + public getTrialBalanceReport(){ + console.log("getMultiCurrencyReport"); + + this.componentStore.getMultiCurrencyReport(ReportType.TrialBalance); } public ngOnDestroy(): void { diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html new file mode 100644 index 00000000000..bb885974561 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html @@ -0,0 +1,27 @@ + + +
+ +
+
+ +
+
+
+

{{ localeData?.no_data_found }}

+
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts new file mode 100644 index 00000000000..891b8f013b7 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts @@ -0,0 +1,170 @@ +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + Input, + OnDestroy, + 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 { TBPlBsActions } from '../../../actions/tl-pl.actions'; +// import { cloneDeep, each } from '../../../lodash-optimized'; +// import { CompanyResponse } from '../../../models/api-models/Company'; +// import { Account, ChildGroup } from '../../../models/api-models/Search'; +// import { BalanceSheetData, ProfitLossRequest } from '../../../models/api-models/tb-pl-bs'; +// import { ToasterService } from '../../../services/toaster.service'; +// import { AppState } from '../../../store/roots'; +// import { BalanceSheetGridComponent } from './components/balance-sheet-grid/balance-sheet-report-grid.component'; + + +@Component({ + selector: 'balance-sheet-report', + templateUrl: './balance-sheet-report.component.html', + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { + /** This will hold local JSON data */ + public localeData: any = {}; + /** This will hold common JSON data */ + public commonLocaleData: any = {}; + + public get selectedCompany(): CompanyResponse { + return this._selectedCompany; + } + + /** + * set company and fetch data + * + * @memberof BalanceSheetComponent + */ + @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 + }; + } + } + + public showLoader: Observable; + public data: BalanceSheetData; + public request: ProfitLossRequest; + public expandAll: boolean; + public search: string; + public from: string; + public to: string; + @Input() public isDateSelected: boolean = false; + @ViewChild('bsGrid', { static: true }) public bsGrid: BalanceSheetReportGridComponent; + private destroyed$: ReplaySubject = new ReplaySubject(1); + private _selectedCompany: CompanyResponse; + + constructor(private store: Store, public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService) { + this.showLoader = this.store.pipe(select(p => p.tlPl.bs.showLoader), takeUntil(this.destroyed$)); + this.store.pipe(select(s => s.tlPl.bs.data), takeUntil(this.destroyed$)).subscribe((p) => { + if (p) { + let data = cloneDeep(p) as BalanceSheetData; + if (data && data.message) { + setTimeout(() => { + this.toaster.clearAllToaster(); + this.toaster.infoToast(data.message); + }, 100); + } + if (data && data.liabilities) { + this.InitData(data.liabilities); + data.liabilities.forEach(g => { + g.isVisible = true; + g.isCreated = true; + g.isIncludedInSearch = true; + }); + } + if (data && data.assets) { + this.InitData(data.assets); + data.assets.forEach(g => { + g.isVisible = true; + g.isCreated = true; + g.isIncludedInSearch = true; + }); + } + this.data = data; + } else { + this.data = null; + } + }); + } + + public InitData(d: ChildGroup[]) { + each(d, (grp: ChildGroup) => { + grp.isVisible = false; + grp.isCreated = false; + grp.isIncludedInSearch = true; + each(grp.accounts, (acc: Account) => { + acc.isIncludedInSearch = true; + acc.isCreated = false; + acc.isVisible = false; + }); + if (grp.childGroups) { + this.InitData(grp.childGroups); + } + }); + } + + public ngAfterViewInit() { + this.cd.detectChanges(); + } + + public filterData(request: ProfitLossRequest) { + this.from = request.from; + this.to = request.to; + this.isDateSelected = request && request.selectedDateOption === '1'; + this.store.dispatch(this.tlPlActions.GetBalanceSheet(cloneDeep(request))); + } + + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public findIndex(activeFY, financialYears) { + let tempFYIndex = 0; + each(financialYears, (fy: any, index: number) => { + if (fy?.uniqueName === activeFY?.uniqueName) { + if (index === 0) { + tempFYIndex = index; + } else { + tempFYIndex = index * -1; + } + } + }); + return tempFYIndex; + } + + public expandAllEvent() { + setTimeout(() => { + this.cd.detectChanges(); + }, 1); + } + + public searchChanged(event: string) { + this.search = event; + if (!this.search) { + this.expandAll = false; + } + this.cd.detectChanges(); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html new file mode 100644 index 00000000000..eef58bff7e9 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html @@ -0,0 +1,233 @@ + + +
+

{{ localeData?.no_data_found }}

+ +
+ +
+
+
+ + +
+
+
+ + + + + + + + +
+
+
+ {{ localeData?.particular }} + +
+
+ +
+
+
+ {{ commonLocaleData?.app_as_of }} + + {{ + dayjs(bsData?.dates?.to, giddhDateFormat)?.toString() + | date: "dd MMMM yyyy" + }} + + {{ commonLocaleData?.app_as_of }} + + {{ + dayjs(bsData?.dates?.from, giddhDateFormat) + .add(-1, "day") + ?.toString() | date: "dd MMMM yyyy" + }} +
+ +
+
+ {{ localeData?.equity_liabilities }} +
+
+ + +
+ + +
+
+
+ + + + +
+
+ {{ localeData?.total_liabilities }} +
+
+ + + + + + +
+
+ + + + + + +
+
+
+
+ +
+
+ +
+
+ {{ localeData?.ii_assets }} +
+
+ + +
+ + +
+
+
+ + + +
+
+ +
+
+ {{ localeData?.total_assets }} +
+
+ + + + + + +
+
+ + + + + + +
+
+ +
+ +
+
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss new file mode 100644 index 00000000000..f3cb5a024ac --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss @@ -0,0 +1,83 @@ +.bs-table-grid { + th { + border: none !important; + border-bottom: 1px solid var(--color-table-primary-header-bar-border) !important; + padding: 13px 8px 14px 0 !important; + &:first-child { + padding: 0 !important; + } + i.glyphicon-search { + position: relative; + z-index: 1; + font-size: 13px; + color: var(--color-abbey); + padding-right: 8px; + cursor: pointer; + display: flex; + align-items: center; + } + input { + height: 47px; + } + } +} +.tb-wrapper { + width: 70%; + margin: auto; +} +@media (max-width: 1024px) { + .tb-wrapper { + width: 100%; + margin: auto; + .table-container { + overflow-x: auto; + } + } +} +@media screen and (max-width: 767px) { + .table-container { + .profit-loss { + tr { + th { + width: 100%; + white-space: nowrap !important; + word-break: normal; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + } + .table-container section div .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + .pl-grid-row, + .profit-loss { + .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + .top-bar { + &.row { + flex-wrap: nowrap; + overflow: initial; + } + .group { + white-space: nowrap; + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; + } + } + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts new file mode 100644 index 00000000000..41e3603c828 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts @@ -0,0 +1,180 @@ +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + Input, + NgZone, + OnChanges, + OnDestroy, + OnInit, + Output, + SimpleChanges, + ViewChild, +} from '@angular/core'; +import { UntypedFormControl } from '@angular/forms'; +import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; +import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; +import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; +// import { each } from 'apps/web-giddh/src/app/lodash-optimized'; +// import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; +// import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; +// import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; +import * as dayjs from 'dayjs'; +import { each } from 'apps/web-giddh/src/app/lodash-optimized'; +import { ReplaySubject } from 'rxjs'; +import { debounceTime, takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'balance-sheet-report-grid', + templateUrl: './balance-sheet-report-grid.component.html', + styleUrls: [`./balance-sheet-report-grid.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDestroy { + public noData: boolean; + public showClearSearch: boolean = false; + @Input() public search: string = ''; + @Input() public bsData: BalanceSheetData; + @Input() public padding: string; + public dayjs = dayjs; + @Input() public expandAll: boolean; + @Input() public searchInput: string = ''; + @Input() public from: string = ''; + @Input() public to: string = ''; + @Output() public searchChange = new EventEmitter(); + @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + public bsSearchControl: UntypedFormControl = new UntypedFormControl(); + /** This holds giddh date format */ + public giddhDateFormat: string = GIDDH_DATE_FORMAT; + /** Observable to unsubscribe all the store listeners to avoid memory leaks */ + private destroyed$: ReplaySubject = new ReplaySubject(1); + /* This will hold local JSON data */ + public localeData: any = {}; + /* This will hold common JSON data */ + public commonLocaleData: any = {}; + /** Hides the data while a new search is made to refresh the virtual list */ + public hideData: boolean; + /** True, when expand all button is toggled while search is enabled */ + public isExpandToggledDuringSearch: boolean; + + constructor(private cd: ChangeDetectorRef, private zone: NgZone) { + + } + + public ngOnChanges(changes: SimpleChanges) { + if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { + this.isExpandToggledDuringSearch = true; + if (this.bsData) { + this.zone.run(() => { + if (this.bsData) { + this.toggleVisibility(this.bsData.assets, changes.expandAll.currentValue); + this.toggleVisibility(this.bsData.liabilities, changes.expandAll.currentValue); + // always make first level visible .... + if (this.bsData.liabilities) { + each(this.bsData.liabilities, (grp: any) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + each(grp.accounts, (acc: any) => { + if (acc.isIncludedInSearch) { + acc.isVisible = true; + } + }); + } + }); + } + if (this.bsData.assets) { + each(this.bsData.assets, (grp: any) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + each(grp.accounts, (acc: any) => { + if (acc.isIncludedInSearch) { + acc.isVisible = true; + } + }); + } + }); + } + + } + this.cd.detectChanges(); + }); + } + } + } + + public ngOnInit() { + this.bsSearchControl.valueChanges.pipe( + debounceTime(700), takeUntil(this.destroyed$)) + .subscribe((newValue) => { + this.searchInput = newValue; + this.hideData = true; + this.searchChange.emit(this.searchInput); + this.isExpandToggledDuringSearch = false; + if (newValue === '') { + this.showClearSearch = false; + } + setTimeout(() => { + this.hideData = false; + this.cd.detectChanges(); + }, 10); + }); + } + + public toggleSearch() { + this.showClearSearch = true; + + setTimeout(() => { + if (this.searchInputEl && this.searchInputEl.nativeElement) { + this.searchInputEl.nativeElement.focus(); + } + }, 200); + } + + public clickedOutside(event, el) { + if (this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') { + return; + } + + if (this.childOf(event.target, el)) { + return; + } else { + this.showClearSearch = false; + } + } + + /* tslint:disable */ + public childOf(c, p) { + while ((c = c.parentNode) && c !== p) { + } + return !!c; + } + + private toggleVisibility = (data: ChildGroup[], isVisible: boolean) => { + each(data, (grp: ChildGroup) => { + if (grp.isIncludedInSearch) { + grp.isCreated = true; + grp.isVisible = isVisible; + grp.isOpen = isVisible; + each(grp.accounts, (acc: Account) => { + if (acc.isIncludedInSearch) { + acc.isCreated = true; + acc.isVisible = isVisible; + } + }); + this.toggleVisibility(grp.childGroups, isVisible); + } + }); + } + + /** + * This will destroy all the memory used by this component + * + * @memberof BalanceSheetGridComponent + */ + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html new file mode 100644 index 00000000000..c22da9d6320 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html @@ -0,0 +1,100 @@ +
+
+
+ + + + + + {{ groupDetail.closingBalance | recType }} + +
+
+ + + + + + {{ groupDetail.forwardedBalance | recType }} + +
+
+ + + + + + + + + + + + + + diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.scss b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.scss new file mode 100644 index 00000000000..3f4e93a6d39 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.scss @@ -0,0 +1,20 @@ +.pl-grid-row { + flex-wrap: nowrap; +} +.group { + width: 30%; + max-width: 30%; + white-space: nowrap; + min-width: 150px; +} +.account { + div { + -webkit-line-clamp: 1; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } +} +.trial-balance-viewport { + background-color: var(--color-common-quinary-background-for-all-components); +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts new file mode 100644 index 00000000000..f39ceabb82e --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts @@ -0,0 +1,59 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { TRIAL_BALANCE_VIEWPORT_LIMIT } from 'apps/web-giddh/src/app/financial-reports/constants/trial-balance-profit.constant'; +import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; + +@Component({ + selector: '[balance-sheet-report-grid-row]', + templateUrl: './balance-sheet-report-grid-row.component.html', + styleUrls: [`./balance-sheet-report-grid-row.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class BalanceSheetReportGridRowComponent implements OnChanges { + @Input() public groupDetail: ChildGroup; + @Input() public search: string; + @Input() public padding: string; + @Input() public from: string = ''; + @Input() public to: string = ''; + /** True, if all items are expanded */ + @Input() public expandAll: boolean; + /** Minimum limit on which Trial balance viewport enables */ + public minimumViewportLimit = TRIAL_BALANCE_VIEWPORT_LIMIT; + /** True, when expand all button is toggled while search is enabled */ + @Input() public isExpandToggledDuringSearch: boolean; + + constructor(private cd: ChangeDetectorRef) { + } + + public ngOnChanges(changes: SimpleChanges) { + if (changes.groupDetail && !changes.groupDetail.firstChange && changes.groupDetail.currentValue !== changes.groupDetail.previousValue) { + this.cd.detectChanges(); + } + if (changes.search && !changes.search.firstChange && changes.search.currentValue !== changes.search.previousValue) { + this.cd.detectChanges(); + } + } + + public entryClicked(acc) { + let url = location.href + '?returnUrl=ledger/' + acc?.uniqueName + '/' + this.from + '/' + this.to; + if (isElectron) { + let ipcRenderer = (window as any).require('electron').ipcRenderer; + url = location.origin + location.pathname + '#./pages/ledger/' + acc?.uniqueName + '/' + this.from + '/' + this.to; + console.log(ipcRenderer.send('open-url', url)); + } else { + (window as any).open(url); + } + + } + + /** + * Track by function for balance sheet item + * + * @param {*} index Index of the item + * @param {Account} item Current item + * @return {string} Item uniquename + * @memberof BalanceSheetGridRowComponent + */ + public trackByFn(index, item: Account): string { + return item?.uniqueName; + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html index 378a7162f56..a6fd89a2499 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html @@ -19,8 +19,7 @@ [id]="CanTBLoad ? 'giddh-page-heading' : ''" >
- -----------__________----------________ - +
- ________--------_______ - +
- +
diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts index c2c28a0c0d1..11ec60d9967 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts @@ -1,3 +1,132 @@ +// import { BreakpointObserver } from '@angular/cdk/layout'; +// import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; +// import { ActivatedRoute, Router } from '@angular/router'; +// import { select, Store } from '@ngrx/store'; +// import { TabsetComponent } from 'ngx-bootstrap/tabs'; +// import { ReplaySubject } from 'rxjs'; +// import { takeUntil } from 'rxjs/operators'; +// import { CompanyResponse } from '../models/api-models/Company'; +// import { AppState } from '../store'; + +// @Component({ +// selector: 'multi-currency-report', +// templateUrl: './multi-currency-reports.component.html', +// styleUrls: ['./multi-currency-reports.component.scss'], +// changeDetection: ChangeDetectionStrategy.OnPush +// }) +// export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { +// public selectedCompany: CompanyResponse; +// public CanTBLoad: boolean = true; +// public CanPLLoad: boolean = false; +// public CanBSLoad: boolean = false; +// public CanNewTBLoadOnThisEnv: boolean = false; +// public isWalkoverCompany: boolean = false; +// /** This will hold active tab */ +// public activeTab: string = 'trial-balance'; +// /** This will hold active tab index */ +// public activeTabIndex: number = 0; +// /** True, when tabs are navigated with the help of routing, done to prevent redundant routing as +// * tab changed event is triggered on setting any tab as active which leads to a second navigation to the +// * same route which cancels the previous route with route ID and doesn't highlight the menu item +// */ +// public preventTabChangeWithRoute: boolean; +// /** This will store screen size */ +// public isMobileScreen: boolean = false; +// @ViewChild('staticTabsTBPL', { static: true }) public staticTabs: TabsetComponent; +// private destroyed$: ReplaySubject = new ReplaySubject(1); +// /** This will hold local JSON data */ +// public localeData: any = {}; +// /** This will hold common JSON data */ +// public commonLocaleData: any = {}; + +// constructor( +// private store: Store, +// private route: ActivatedRoute, +// private router: Router, +// private breakPointObservar: BreakpointObserver) { +// this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { +// if (activeCompany) { +// this.selectedCompany = activeCompany; +// } +// }); +// } + +// /** +// * This will return page heading based on active tab +// * +// * @param {boolean} event +// * @memberof InvoiceComponent +// */ +// public getPageHeading(): string { +// if(this.isMobileScreen){ +// if(this.CanTBLoad) { +// return this.localeData?.tabs?.trial_balance; +// } +// else if(this.CanPLLoad) { +// return this.localeData?.tabs?.profit_loss; +// } +// else if(this.CanBSLoad) { +// return this.localeData?.tabs?.balance_sheet; +// } +// } +// else { +// return " "; +// } +// } + +// public ngOnInit() { +// this.breakPointObservar.observe([ +// '(max-width: 767px)' +// ]).pipe(takeUntil(this.destroyed$)).subscribe(result => { +// this.isMobileScreen = result.matches; +// }); + +// if (TEST_ENV) { +// this.CanNewTBLoadOnThisEnv = true; +// } else { +// this.CanNewTBLoadOnThisEnv = false; +// } + +// this.route.queryParams.pipe(takeUntil(this.destroyed$)).subscribe((val) => { +// if (val && val.tab && val.tabIndex) { +// this.activeTab = val.tab; +// this.activeTabIndex = val.tabIndex; +// this.preventTabChangeWithRoute = true; +// this.selectTab(val.tabIndex); +// } +// }); +// } + +// public selectTab(id: number) { +// if (this.staticTabs && this.staticTabs.tabs && this.staticTabs.tabs[id]) { +// this.staticTabs.tabs[id].active = true; +// } +// } + +// /** +// * This will destroy all the memory used by this component +// * +// * @memberof FinancialReportsComponent +// */ +// public ngOnDestroy(): void { +// this.destroyed$.next(true); +// this.destroyed$.complete(); +// } + +// /** +// * This will navigate to selected tab +// * +// * @param {string} tab +// * @param {number} tabIndex +// * @memberof FinancialReportsComponent +// */ +// public tabChanged(tab: string, tabIndex: number): void { +// if (!this.preventTabChangeWithRoute) { +// this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); +// } +// } +// } + import { BreakpointObserver } from '@angular/cdk/layout'; import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; @@ -8,6 +137,8 @@ import { takeUntil } from 'rxjs/operators'; import { CompanyResponse } from '../models/api-models/Company'; import { AppState } from '../store'; + + @Component({ selector: 'multi-currency-report', templateUrl: './multi-currency-reports.component.html', @@ -122,7 +253,8 @@ export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { */ public tabChanged(tab: string, tabIndex: number): void { if (!this.preventTabChangeWithRoute) { - this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); + this.router.navigate(['/pages/trial-balance-and-profit-loss'], { queryParams: { tab, tabIndex } }); } } } + diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts index da450131a9b..2d8d409af90 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts @@ -47,10 +47,7 @@ import { TranslateDirectiveModule } from '../theme/translate/translate.directive // import { TrialBalanceComponent } from './components/trial-balance/trial-balance.component'; // import { FinancialAccordionDirective } from './directives/financial-accordion.directive'; // import { AccountsFilterPipe } from './pipes/accounts-filter.pipe'; -import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; -import { MultiCurrencyReportsRoutingModule } from './multi-currency-reports.routing.module'; -import { ProfitLossReportsComponent } from './profit-loss-multi-currency/profit-loss-reports.component'; -import { FilterMultiCurrencyComponent } from './filter/filter-multi-currency.component'; + import { MatTooltipModule } from '@angular/material/tooltip'; import { MatButtonModule } from '@angular/material/button'; import { MatTableModule } from '@angular/material/table'; @@ -58,13 +55,19 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; import { FormFieldsModule } from '../theme/form-fields/form-fields.module'; import { BalanceSheetReportComponent } from './balance-sheet-multi-currency/balance-sheet-report.component'; +import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; +import { BalanceSheetReportGridComponent } from './balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component'; +import { BalanceSheetReportGridRowComponent } from './balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component'; +import { MultiCurrencyReportsRoutingModule } from './multi-currency-reports.routing.module'; +import { FinancialSearchPipe } from '../shared/header/pipe/financial-search.pipe'; +import { AccountsFilterPipe } from '../financial-reports/pipes/accounts-filter.pipe'; +import { FinancialAccordionDirective } from '../financial-reports/directives/financial-accordion.directive'; @NgModule({ declarations: [ - MultiCurrencyReportsComponent, - ProfitLossReportsComponent, - FilterMultiCurrencyComponent, - BalanceSheetReportComponent + BalanceSheetReportComponent, + BalanceSheetReportGridComponent, + BalanceSheetReportGridRowComponent, // GridRowComponent, // TrialBalanceComponent, // ProfitLossComponent, @@ -77,9 +80,9 @@ import { BalanceSheetReportComponent } from './balance-sheet-multi-currency/bala // BalanceSheetComponent, // BalanceSheetGridComponent, // BalanceSheetGridRowComponent, - // FinancialAccordionDirective, - // FinancialSearchPipe, - // AccountsFilterPipe + FinancialAccordionDirective, + FinancialSearchPipe, + AccountsFilterPipe ], exports: [ MultiCurrencyReportsComponent, CurrencyModule diff --git a/apps/web-giddh/src/app/services/tl-pl.service.ts b/apps/web-giddh/src/app/services/tl-pl.service.ts index e9b31b8d538..aa536d1881e 100644 --- a/apps/web-giddh/src/app/services/tl-pl.service.ts +++ b/apps/web-giddh/src/app/services/tl-pl.service.ts @@ -32,9 +32,8 @@ export class TlPlService { } else { params.branchUniqueName = ''; } - return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT - ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) - ?.replace(':reportType', ("trial-balance")) ).pipe( + return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_TRIAL_BALANCE + ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)), params).pipe( map((res) => { let data: BaseResponse = res; data.request = request; From 92ca2a3cb9d7b1ebf0c82e073348cb09e7faf462 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 17 Dec 2024 12:07:20 +0530 Subject: [PATCH 03/15] work on trial-balance --- .../balance-sheet/balance-sheet.component.ts | 2 + .../financial-reports.module.ts | 4 +- .../balance-sheet-report.component.html | 0 .../balance-sheet-report.component.scss | 0 .../balance-sheet-report.component.ts | 4 +- .../balance-sheet-report.component.html | 6 +- .../balance-sheet-report.component.ts | 27 +- .../filter-multi-currency.component.html | 2 +- .../filter/filter-multi-currency.component.ts | 2 +- .../multi-currency-reports.component.ts | 2 +- .../multi-currency-reports.module.ts | 49 ++-- .../multi-currency-reports.store.ts | 2 +- .../pipes/accounts-filter.pipe.ts | 24 ++ .../trial-balance-report-grid.component.html | 235 +++++++++++++++++ .../trial-balance-report-grid.component.scss | 73 ++++++ .../trial-balance-report-grid.component.ts | 242 ++++++++++++++++++ .../trial-balance-report.component.html | 30 +++ .../trial-balance-report.component.ts | 147 +++++++++++ .../src/app/services/tl-pl.service.ts | 2 + .../header/pipe/financial-search.pipe.ts | 3 +- .../src/app/store/tl-pl/tl-pl.reducer.ts | 2 +- 21 files changed, 816 insertions(+), 42 deletions(-) rename apps/web-giddh/src/app/multi-currency-reports/{balance-sheet-multi-currency => asdfghjhgfdsdfghjhgfd}/balance-sheet-report.component.html (100%) rename apps/web-giddh/src/app/multi-currency-reports/{balance-sheet-multi-currency => asdfghjhgfdsdfghjhgfd}/balance-sheet-report.component.scss (100%) rename apps/web-giddh/src/app/multi-currency-reports/{balance-sheet-multi-currency => asdfghjhgfdsdfghjhgfd}/balance-sheet-report.component.ts (98%) create mode 100644 apps/web-giddh/src/app/multi-currency-reports/pipes/accounts-filter.pipe.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.ts diff --git a/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts b/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts index 4bd9c883295..bb64383b92c 100644 --- a/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts @@ -69,6 +69,8 @@ export class BalanceSheetComponent implements AfterViewInit, OnDestroy { this.showLoader = this.store.pipe(select(p => p.tlPl.bs.showLoader), takeUntil(this.destroyed$)); this.store.pipe(select(s => s.tlPl.bs.data), takeUntil(this.destroyed$)).subscribe((p) => { if (p) { + console.log("s.tlPl.bs.data",p); + let data = cloneDeep(p) as BalanceSheetData; if (data && data.message) { setTimeout(() => { diff --git a/apps/web-giddh/src/app/financial-reports/financial-reports.module.ts b/apps/web-giddh/src/app/financial-reports/financial-reports.module.ts index 7131d7f708d..425e64f3dfd 100644 --- a/apps/web-giddh/src/app/financial-reports/financial-reports.module.ts +++ b/apps/web-giddh/src/app/financial-reports/financial-reports.module.ts @@ -68,7 +68,6 @@ import { AccountsFilterPipe } from './pipes/accounts-filter.pipe'; BalanceSheetGridComponent, BalanceSheetGridRowComponent, FinancialAccordionDirective, - FinancialSearchPipe, AccountsFilterPipe ], exports: [ @@ -102,7 +101,8 @@ import { AccountsFilterPipe } from './pipes/accounts-filter.pipe'; AmountFieldComponentModule, DatepickerWrapperModule, PopoverModule.forRoot(), - AsideMenuAccountModule + AsideMenuAccountModule, + FinancialSearchPipe ], }) export class FinancialReportsModule { diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html similarity index 100% rename from apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.html rename to apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss similarity index 100% rename from apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.scss rename to apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts similarity index 98% rename from apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts rename to apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts index 4c4c43ca584..a1c17ec087e 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet-multi-currency/balance-sheet-report.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts @@ -25,13 +25,13 @@ import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.st import { ReportType } from '../multi-currency.const'; @Component({ - selector: 'balance-sheet-report', + selector: 'balance-sheet-reportsdfghfds', templateUrl: './balance-sheet-report.component.html', styleUrls: [`./balance-sheet-report.component.scss`], changeDetection: ChangeDetectionStrategy.OnPush, providers: [MultiCurrencyReportsComponentStore] }) -export class BalanceSheetReportComponent implements OnInit, OnChanges, OnDestroy { +export class BalanceSheetReportdfgfdComponent implements OnInit, OnChanges, OnDestroy { public noData: boolean = false; public showClearSearch: boolean = false; @Input() public search: string = ''; diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html index bb885974561..f1470ec2dc2 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html @@ -4,11 +4,11 @@ (localeData)="localeData = $event" (commonLocaleData)="commonLocaleData = $event" > - +
-
+
-
+

{{ localeData?.no_data_found }}

diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts index 891b8f013b7..ebecbcd5536 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts @@ -18,6 +18,9 @@ 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'; // import { TBPlBsActions } from '../../../actions/tl-pl.actions'; // import { cloneDeep, each } from '../../../lodash-optimized'; // import { CompanyResponse } from '../../../models/api-models/Company'; @@ -31,7 +34,8 @@ import { Account, ChildGroup } from '../../models/api-models/Search'; @Component({ selector: 'balance-sheet-report', templateUrl: './balance-sheet-report.component.html', - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + providers: [MultiCurrencyReportsComponentStore] }) export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { /** This will hold local JSON data */ @@ -42,7 +46,7 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { public get selectedCompany(): CompanyResponse { return this._selectedCompany; } - + /** * set company and fetch data * @@ -74,11 +78,16 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { private destroyed$: ReplaySubject = new ReplaySubject(1); private _selectedCompany: CompanyResponse; - constructor(private store: Store, public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService) { + + constructor(private store: Store, public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService, private componentStore: MultiCurrencyReportsComponentStore) { this.showLoader = this.store.pipe(select(p => p.tlPl.bs.showLoader), takeUntil(this.destroyed$)); - this.store.pipe(select(s => s.tlPl.bs.data), takeUntil(this.destroyed$)).subscribe((p) => { + this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((p) => { if (p) { - let data = cloneDeep(p) as BalanceSheetData; + + + let data = prepareBalanceSheetData(cloneDeep(p)); + console.log('prepareBalanceSheetData',data); + if (data && data.message) { setTimeout(() => { this.toaster.clearAllToaster(); @@ -132,9 +141,12 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { this.from = request.from; this.to = request.to; this.isDateSelected = request && request.selectedDateOption === '1'; - this.store.dispatch(this.tlPlActions.GetBalanceSheet(cloneDeep(request))); + this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); + } + public searchData(event: any) { + console.log('creatMultiCurrencyReport', event); + this.componentStore.creatMultiCurrencyReport({ reportType: ReportType.BalanceSheet, payload: event }); } - public ngOnDestroy(): void { this.destroyed$.next(true); this.destroyed$.complete(); @@ -167,4 +179,5 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { } this.cd.detectChanges(); } + } diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html index 4fea6110c2c..29fbfc56714 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html @@ -74,7 +74,7 @@
- {{initdata | json}} +
diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts index 781657384ee..3714fe21e1e 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts @@ -218,7 +218,7 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { this.selectedDateRangeUi = dayjs(a[0]).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(a[1]).format(GIDDH_NEW_DATE_FORMAT_UI); this.fromDate = dayjs(universalDate[0]).format(GIDDH_DATE_FORMAT); this.toDate = dayjs(universalDate[1]).format(GIDDH_DATE_FORMAT); - this.onPropertyChanged.emit(); + this.onPropertyChanged.emit({from:this.fromDate,to:this.toDate}); } }); // this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts index 11ec60d9967..aadc17181b1 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts @@ -253,7 +253,7 @@ export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { */ public tabChanged(tab: string, tabIndex: number): void { if (!this.preventTabChangeWithRoute) { - this.router.navigate(['/pages/trial-balance-and-profit-loss'], { queryParams: { tab, tabIndex } }); + this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); } } } diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts index 2d8d409af90..6b2cdf7c1ff 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts @@ -10,19 +10,6 @@ import { PopoverModule } from 'ngx-bootstrap/popover'; import { TabsModule } from 'ngx-bootstrap/tabs'; import { TooltipModule } from 'ngx-bootstrap/tooltip'; -import { AmountFieldComponentModule } from '../shared/amount-field/amount-field.module'; -import { AsideMenuAccountModule } from '../shared/aside-menu-account/aside.menu.account.module'; -import { DatepickerWrapperModule } from '../shared/datepicker-wrapper/datepicker.wrapper.module'; -import { GiddhPageLoaderModule } from '../shared/giddh-page-loader/giddh-page-loader.module'; -import { HamburgerMenuModule } from '../shared/header/components/hamburger-menu/hamburger-menu.module'; -// import { FinancialSearchPipe } from '../shared/header/pipe/financial-search.pipe'; -import { CurrencyModule } from '../shared/helpers/pipes/currencyPipe/currencyType.module'; -import { HighlightModule } from '../shared/helpers/pipes/highlightPipe/highlight.module'; -import { RecTypeModule } from '../shared/helpers/pipes/recType/recType.module'; -import { AccountDetailModalModule } from '../theme/account-detail-modal/account-detail-modal.module'; -import { ShSelectModule } from '../theme/ng-virtual-select/sh-select.module'; -import { Daterangepicker } from '../theme/ng2-daterangepicker/daterangepicker.module'; -import { TranslateDirectiveModule } from '../theme/translate/translate.directive.module'; // import { BalanceSheetComponent } from './components/balance-sheet/balance-sheet.component'; // import { // BalanceSheetGridComponent, @@ -53,21 +40,39 @@ import { MatButtonModule } from '@angular/material/button'; import { MatTableModule } from '@angular/material/table'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; -import { FormFieldsModule } from '../theme/form-fields/form-fields.module'; -import { BalanceSheetReportComponent } from './balance-sheet-multi-currency/balance-sheet-report.component'; -import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; +import { BalanceSheetReportComponent } from './balance-sheet/balance-sheet-report.component'; import { BalanceSheetReportGridComponent } from './balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component'; import { BalanceSheetReportGridRowComponent } from './balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component'; +import { MultiCurrencyReportsComponent } from './multi-currency-reports.component'; +import { CurrencyModule } from '../shared/helpers/pipes/currencyPipe/currencyType.module'; +import { Daterangepicker } from '../theme/ng2-daterangepicker/daterangepicker.module'; import { MultiCurrencyReportsRoutingModule } from './multi-currency-reports.routing.module'; +import { HighlightModule } from '../shared/helpers/pipes/highlightPipe/highlight.module'; +import { RecTypeModule } from '../shared/helpers/pipes/recType/recType.module'; +import { ShSelectModule } from '../theme/ng-virtual-select/sh-select.module'; +import { AccountDetailModalModule } from '../theme/account-detail-modal/account-detail-modal.module'; +import { TranslateDirectiveModule } from '../theme/translate/translate.directive.module'; +import { HamburgerMenuModule } from '../shared/header/components/hamburger-menu/hamburger-menu.module'; +import { GiddhPageLoaderModule } from '../shared/giddh-page-loader/giddh-page-loader.module'; +import { AmountFieldComponentModule } from '../shared/amount-field/amount-field.module'; +import { DatepickerWrapperModule } from '../shared/datepicker-wrapper/datepicker.wrapper.module'; +import { AsideMenuAccountModule } from '../shared/aside-menu-account/aside.menu.account.module'; +import { FormFieldsModule } from '../theme/form-fields/form-fields.module'; import { FinancialSearchPipe } from '../shared/header/pipe/financial-search.pipe'; -import { AccountsFilterPipe } from '../financial-reports/pipes/accounts-filter.pipe'; -import { FinancialAccordionDirective } from '../financial-reports/directives/financial-accordion.directive'; +import { FilterMultiCurrencyComponent } from './filter/filter-multi-currency.component'; +import { AccountsFilterPipe } from './pipes/accounts-filter.pipe'; +import { TrialBalanceReportComponent } from './trial-balance-multi-currency/trial-balance-report.component'; + @NgModule({ declarations: [ + MultiCurrencyReportsComponent, BalanceSheetReportComponent, BalanceSheetReportGridComponent, BalanceSheetReportGridRowComponent, + FilterMultiCurrencyComponent, + AccountsFilterPipe, + TrialBalanceReportComponent // GridRowComponent, // TrialBalanceComponent, // ProfitLossComponent, @@ -80,9 +85,6 @@ import { FinancialAccordionDirective } from '../financial-reports/directives/fin // BalanceSheetComponent, // BalanceSheetGridComponent, // BalanceSheetGridRowComponent, - FinancialAccordionDirective, - FinancialSearchPipe, - AccountsFilterPipe ], exports: [ MultiCurrencyReportsComponent, CurrencyModule @@ -121,7 +123,10 @@ import { FinancialAccordionDirective } from '../financial-reports/directives/fin MatTableModule, MatFormFieldModule, MatSelectModule, - FormFieldsModule + FormFieldsModule, + FinancialSearchPipe + + ], }) export class MultiCurrencyReportsModule { diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts index 0703492d902..02277274585 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.store.ts @@ -47,7 +47,7 @@ export class MultiCurrencyReportsComponentStore extends ComponentStore { if (res?.status === "success" && res.body) { - return this.patchState({ reportDataList: res.body, inProgressReport: false }); + return this.patchState({ reportDataList: res.body.response, inProgressReport: false }); } else { res?.message && this.toaster.showSnackBar("error", res.message); return this.patchState({ reportDataList: null, inProgressReport: false }); diff --git a/apps/web-giddh/src/app/multi-currency-reports/pipes/accounts-filter.pipe.ts b/apps/web-giddh/src/app/multi-currency-reports/pipes/accounts-filter.pipe.ts new file mode 100644 index 00000000000..6a632d3e30f --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/pipes/accounts-filter.pipe.ts @@ -0,0 +1,24 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +import { Account } from '../../models/api-models/Search'; + +@Pipe({ + name: 'accountsFilter', + pure: true +}) +export class AccountsFilterPipe implements PipeTransform { + + /** + * Filters the array of accounts based on opening, closing balance and account name + * + * @param {*} accounts Array of accounts to be filtered + * @param {boolean} showOnlyVisible True, if only visible accounts should be returned + * @memberof AccountsFilterPipe + */ + transform(accounts: Array, showOnlyVisible?: boolean): Array { + if (showOnlyVisible) { + return accounts?.filter(account => account.isVisible); + } + return accounts?.filter(account => (account.isVisible && account.name && (account.closingBalance?.amount !== 0 || account.openingBalance?.amount !== 0 || account.debitTotal || account.creditTotal))); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.html b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.html new file mode 100644 index 00000000000..c61ef5f8cbf --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.html @@ -0,0 +1,235 @@ + + +
+

{{ localeData?.no_data_found }}

+ +
+ +
+
+ +
+
+
    +
  • + + {{ commonLocaleData?.app_liabilities }} +
  • +
  • + + {{ commonLocaleData?.app_assets }} +
  • +
  • + + {{ commonLocaleData?.app_income }} +
  • +
  • + + {{ commonLocaleData?.app_expenses }} +
  • +
+
+ +
+
+
+
+
+ + {{ localeData?.particular }} + + + + + +
+
+ {{ localeData?.opening_balance }} +
+
+ {{ commonLocaleData?.app_debit }} +
+
+ {{ commonLocaleData?.app_credit }} +
+
+ {{ localeData?.closing_balance }} +
+
+
+ +
+ + + +
+ + +
+
+
+ + +
+ + +
+
+
+
+ + +
+
+
+ + + + + + + + + + + +
+
+
+ +
+
+
+
+
+ +
diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.scss b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.scss new file mode 100644 index 00000000000..7a50f78d2c8 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.scss @@ -0,0 +1,73 @@ +.liabilities-assets { + max-width: 760px; + width: 100%; +} +.trial-balance { + span { + i.glyphicon-search { + position: relative; + z-index: 1; + font-size: 13px; + color: var(--color-abbey); + padding-right: 8px; + cursor: pointer; + display: flex; + align-items: center; + } + } + input { + height: 47px; + } +} +.tb-wrapper { + width: 70%; + margin: auto; +} +.list-inline { + padding-left: 0; + list-style: none; + > li { + display: inline-block; + padding-right: 5px; + } +} +.table-footer th { + border-top: none !important; +} +.tb-section { + padding-left: 7px; + background-color: var(--color-white); + .search-container { + padding: 0; + display: flex; + align-items: center; + .show-clear-search { + width: 103%; + margin-left: -7px; + display: flex; + } + } + .table-th { + padding: 14px 8px 14px 0; + } + + .table-th-closing { + padding: 14px 20px 14px 0; + } +} +@media (max-width: 1024px) { + .tb-wrapper { + width: 100%; + margin: auto; + .table-container { + overflow-x: auto; + } + } +} +@media screen and (max-width: 767px) { + .list-inline { + > li { + font-size: var(--font-size-12); + } + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.ts b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.ts new file mode 100644 index 00000000000..b60e446d6ee --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/components/trial-balance-grid/trial-balance-report-grid.component.ts @@ -0,0 +1,242 @@ +import { trigger, state, style, transition, animate } from '@angular/animations'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + Input, + NgZone, + OnChanges, + OnDestroy, + OnInit, + Output, + SimpleChanges, + ViewChild, +} from '@angular/core'; +import { UntypedFormControl } from '@angular/forms'; +import { each } from 'apps/web-giddh/src/app/lodash-optimized'; +import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; +import { AccountDetails } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; +import { ReplaySubject } from 'rxjs'; +import { debounceTime, takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'trial-balance-report-grid', + templateUrl: './trial-balance-report-grid.component.html', + styleUrls: [`./trial-balance-report-grid.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush, + animations: [ + trigger("slideInOut", [ + state("in", style({ + transform: "translate3d(0, 0, 0)", + })), + state("out", style({ + transform: "translate3d(100%, 0, 0)", + })), + transition("in => out", animate("400ms ease-in-out")), + transition("out => in", animate("400ms ease-in-out")), + ]), + ], +}) +export class TrialBalanceReportGridComponent implements OnInit, OnChanges, OnDestroy { + + public noData: boolean; + public accountSearchControl: UntypedFormControl = new UntypedFormControl(); + @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + public showClearSearch: boolean = false; + @Input() public search: string = ''; + @Input() public from: string = ''; + @Input() public to: string = ''; + @Input() public searchInput: string = ''; + @Input() public padLeft: number = 30; + @Input() public showLoader: boolean; + @Input() public data$: AccountDetails; + @Input() public expandAll: boolean; + @Output() public searchChange = new EventEmitter(); + /** Observable to unsubscribe all the store listeners to avoid memory leaks */ + private destroyed$: ReplaySubject = new ReplaySubject(1); + /* This will hold local JSON data */ + public localeData: any = {}; + /* This will hold common JSON data */ + public commonLocaleData: any = {}; + /** Hides the data while a new search is made to refresh the virtual list */ + public hideData: boolean; + /** True, when expand all button is toggled while search is enabled */ + public isExpandToggledDuringSearch: boolean; + /** Account update modal state */ + public accountAsideMenuState: string = "out"; + /** Account group unique name */ + public activeGroupUniqueName: string = ""; + /** Holds account details */ + public accountDetails: any; + + constructor(private cd: ChangeDetectorRef, private zone: NgZone) { + + } + + public ngOnInit() { + this.accountSearchControl.valueChanges.pipe( + debounceTime(700), takeUntil(this.destroyed$)) + .subscribe((newValue) => { + this.searchInput = newValue; + this.hideData = true; + this.searchChange.emit(this.searchInput); + this.isExpandToggledDuringSearch = false; + if (newValue === '') { + this.showClearSearch = false; + } + setTimeout(() => { + this.hideData = false; + this.cd.detectChanges(); + }, 10); + }); + } + + public ngOnChanges(changes: SimpleChanges) { + if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { + this.isExpandToggledDuringSearch = true; + if (this.data$) { + this.zone.runOutsideAngular(() => { + this.toggleGroupVisibility(this.data$.groupDetails, changes.expandAll.currentValue); + if (this.data$) { + // always make first level visible .... + each(this.data$.groupDetails, (grp: ChildGroup) => { + if (grp.isIncludedInSearch) { + grp.isVisible = true; + grp.isCreated = true; + grp.isOpen = false; + each(grp.accounts, (acc: Account) => { + if (acc.isIncludedInSearch) { + acc.isVisible = false; + acc.isCreated = false; + } + }); + } + }); + } + }); + } + } + } + + /** + * This will destroy all the memory used by this component + * + * @memberof TrialBalanceGridComponent + */ + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public markForCheck() { + this.cd.markForCheck(); + } + + public trackByFn(index, item: ChildGroup) { + return item?.uniqueName; + } + + public toggleSearch() { + this.showClearSearch = true; + + setTimeout(() => { + if (this.searchInputEl && this.searchInputEl.nativeElement) { + this.searchInputEl.nativeElement.focus(); + } + }, 200); + } + + public clickedOutside(event, el) { + if (this.accountSearchControl?.value !== null && this.accountSearchControl?.value !== '') { + return; + } + + if (this.childOf(event.target, el)) { + return; + } else { + this.showClearSearch = false; + } + } + + /* tslint:disable */ + public childOf(c, p) { + while ((c = c.parentNode) && c !== p) { + } + return !!c; + } + + /** + * Toggles group visibility + * + * @param {Array} group Groups received + * @param {boolean} isVisible Current visibility status + * @memberof TrialBalanceGridComponent + */ + public toggleGroupVisibility(group: Array, isVisible: boolean): void { + for (let groupIndex = 0; groupIndex < group?.length; groupIndex++) { + const currentGroup: ChildGroup = group[groupIndex]; + if (currentGroup.isIncludedInSearch) { + currentGroup.isCreated = isVisible; + currentGroup.isVisible = isVisible; + currentGroup.isOpen = isVisible; + for (let accountIndex = 0; accountIndex < currentGroup.accounts?.length; accountIndex++) { + const currentAccount: Account = currentGroup.accounts[accountIndex]; + if (currentAccount.isIncludedInSearch) { + currentAccount.isCreated = isVisible; + currentAccount.isVisible = isVisible; + } + } + if (currentGroup.childGroups?.length) { + this.toggleGroupVisibility(currentGroup.childGroups, isVisible); + } + } + } + } + + /** + * Shows the account update modal + * + * @param {*} account + * @memberof TrialBalanceGridComponent + */ + public openAccountModal(account: any): void { + this.accountDetails = account; + this.activeGroupUniqueName = account?.parentGroups[account?.parentGroups?.length - 1]?.uniqueName; + this.toggleAccountAsidePane(); + } + + /** + * Toggle's account update modal + * + * @memberof TrialBalanceGridComponent + */ + public toggleAccountAsidePane(): void { + this.accountAsideMenuState = this.accountAsideMenuState === "out" ? "in" : "out"; + this.toggleBodyClass(); + } + + /** + * Toggle's fixed class in body + * + * @memberof TrialBalanceGridComponent + */ + public toggleBodyClass() { + if (this.accountAsideMenuState === "in") { + document.querySelector("body").classList.add("fixed"); + } else { + document.querySelector("body").classList.remove("fixed"); + } + } + + /** + * Callback function on account modal close + * + * @param {*} event + * @memberof TrialBalanceGridComponent + */ + public getUpdatedList(event: any): void { + this.toggleAccountAsidePane(); + } +} diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html new file mode 100644 index 00000000000..fc42a73b140 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html @@ -0,0 +1,30 @@ + + +
+ +
+
+ +
+
+
+

{{ localeData?.no_data_found }}

+
+
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.ts new file mode 100644 index 00000000000..2fee2164b77 --- /dev/null +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.ts @@ -0,0 +1,147 @@ +import { AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { select, Store } from '@ngrx/store'; +import { createSelector } from 'reselect'; +import { Observable, ReplaySubject } from 'rxjs'; +import { takeUntil } from 'rxjs/operators'; +import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; +import { TrialBalanceRequest } from '../../models/api-models/tb-pl-bs'; +import { CompanyResponse } from '../../models/api-models/Company'; +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 { TrialBalanceReportGridComponent } from './components/trial-balance-grid/trial-balance-report-grid.component'; + +@Component({ + selector: 'trial-balance-report', + templateUrl: './trial-balance-report.component.html', + providers: [MultiCurrencyReportsComponentStore] +}) +export class TrialBalanceReportComponent implements OnInit, AfterViewInit, OnDestroy { + /** This will hold local JSON data */ + public localeData: any = {}; + /** This will hold common JSON data */ + public commonLocaleData: any = {}; + public showLoader: Observable; + public data$: Observable; + public request: TrialBalanceRequest; + public expandAll: boolean; + public search: string; + public from: string; + public to: string; + @ViewChild('tbGrid', { static: true }) public tbGrid: TrialBalanceReportGridComponent; + @Input() public isV2: boolean = false; + @Input() public isDateSelected: boolean = false; + private destroyed$: ReplaySubject = new ReplaySubject(1); + private _selectedCompany: CompanyResponse; + + constructor( + private store: Store, + private cd: ChangeDetectorRef, + public tlPlActions: TBPlBsActions, + private toaster: ToasterService, + private componentStore: MultiCurrencyReportsComponentStore) { + this.showLoader = this.store.pipe(select(p => p.tlPl.tb.showLoader), takeUntil(this.destroyed$)); + } + + public get selectedCompany(): CompanyResponse { + return this._selectedCompany; + } + + // set company and fetch data... + @Input() + public set selectedCompany(value: CompanyResponse) { + this._selectedCompany = value; + if (value && value.activeFinancialYear && !this.isDateSelected) { + this.request = { + refresh: false, + from: value.activeFinancialYear.financialYearStarts, + to: this.selectedCompany.activeFinancialYear.financialYearEnds + }; + } + } + + public ngOnInit() { + this.data$ = this.store.pipe(select(createSelector((p: AppState) => p.tlPl.tb.data, (p) => { + console.log("p",p); + + let d = cloneDeep(p); + if (d) { + if (d.message) { + setTimeout(() => { + this.toaster.clearAllToaster(); + this.toaster.infoToast(d.message); + }, 100); + } + this.InitData(d.groupDetails); + d.groupDetails.forEach(g => { + g.isVisible = true; + g.isCreated = true; + }); + } + return d; + })), takeUntil(this.destroyed$)); + this.data$.pipe(takeUntil(this.destroyed$)).subscribe(() => { + this.cd.markForCheck(); + }); + } + + public InitData(d: ChildGroup[]) { + each(d, (grp: ChildGroup) => { + grp.isVisible = false; + grp.isCreated = false; + grp.isIncludedInSearch = true; + each(grp.accounts, (acc: Account) => { + acc.isIncludedInSearch = true; + acc.isCreated = false; + acc.isVisible = false; + }); + if (grp.childGroups) { + this.InitData(grp.childGroups); + } + }); + } + + public ngAfterViewInit() { + this.cd.detectChanges(); + } + + public filterData(request: TrialBalanceRequest) { + this.from = request.from; + this.to = request.to; + this.isDateSelected = request && request.selectedDateOption === '1'; + console.log("this.isV2",this.isV2); + if (this.isV2) { + this.store.dispatch(this.tlPlActions.GetV2TrialBalance(cloneDeep(request))); + } else { + this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); + } + //this.getTrialBalanceReport(); + } + public getTrialBalanceReport(){ + console.log("getMultiCurrencyReport"); + + this.componentStore.getMultiCurrencyReport(ReportType.TrialBalance); + } + + public ngOnDestroy(): void { + this.destroyed$.next(true); + this.destroyed$.complete(); + } + + public expandAllEvent() { + setTimeout(() => { + this.cd.detectChanges(); + }, 1); + } + + public searchChanged(event: string) { + this.search = event; + if (!this.search) { + this.expandAll = false; + } + this.cd.detectChanges(); + } +} diff --git a/apps/web-giddh/src/app/services/tl-pl.service.ts b/apps/web-giddh/src/app/services/tl-pl.service.ts index aa536d1881e..e5b537c5d13 100644 --- a/apps/web-giddh/src/app/services/tl-pl.service.ts +++ b/apps/web-giddh/src/app/services/tl-pl.service.ts @@ -186,6 +186,8 @@ export class TlPlService { */ public getMultiCurrencyReport(reportType: string): Observable> { this.companyUniqueName = this.generalService.companyUniqueName; + console.log("getMultiCurrencyReport"); + return this.http.get(this.config.apiUrl + TB_PL_BS_API.GET_MULTI_CURRENCY_REPORT ?.replace(':companyUniqueName', encodeURIComponent(this.companyUniqueName)) ?.replace(':reportType', (reportType)) ).pipe( diff --git a/apps/web-giddh/src/app/shared/header/pipe/financial-search.pipe.ts b/apps/web-giddh/src/app/shared/header/pipe/financial-search.pipe.ts index 65e8f6296ea..7b756061771 100644 --- a/apps/web-giddh/src/app/shared/header/pipe/financial-search.pipe.ts +++ b/apps/web-giddh/src/app/shared/header/pipe/financial-search.pipe.ts @@ -5,7 +5,8 @@ import { ChildGroup } from '../../../models/api-models/Search'; @Pipe({ // tslint:disable-next-line:pipe-naming name: 'financialSearch', - pure: true + pure: true, + standalone: true }) export class FinancialSearchPipe implements PipeTransform { diff --git a/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts b/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts index 1d5cc50647e..707c33f79b1 100644 --- a/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts +++ b/apps/web-giddh/src/app/store/tl-pl/tl-pl.reducer.ts @@ -344,7 +344,7 @@ const filterBalanceSheetData = data => { return filterPlData; }; -const prepareBalanceSheetData = (data) => { +export const prepareBalanceSheetData = (data) => { let bsData: BalanceSheetData = filterBalanceSheetData(data.groupDetails); bsData.assetTotal = calCulateTotalAssets(bsData.assets); bsData.assetTotalEnd = calCulateTotalAssetsEnd(bsData.assets); From 6cda4e114189fdd031b0a9fd7cd42cab4eb51fa4 Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 19 Dec 2024 18:43:50 +0530 Subject: [PATCH 04/15] work on profit-loss --- .../balance-sheet/balance-sheet.component.ts | 2 - .../components/filter/filter.component.ts | 6 - .../profit-loss-grid.component.html | 1 + .../trial-balance/trial-balance.component.ts | 6 - .../balance-sheet-report.component.html | 147 ----- .../balance-sheet-report.component.scss | 83 --- .../balance-sheet-report.component.ts | 203 ------- .../balance-sheet-report.component.html | 23 +- .../balance-sheet-report.component.ts | 137 +++-- .../balance-sheet-report-grid.component.html | 26 +- .../balance-sheet-report-grid.component.ts | 77 ++- ...balance-sheet-report-grid-row.component.ts | 35 +- .../filter-multi-currency.component.html | 24 +- .../filter/filter-multi-currency.component.ts | 561 +++++++++--------- .../grid-row/grid-report-row.component.html | 140 +++++ .../grid-row/grid-report-row.component.scss | 76 +++ .../grid-row/grid-report-row.component.ts | 133 +++++ .../multi-currency-reports.component.html | 4 +- .../multi-currency-reports.component.ts | 31 +- .../multi-currency-reports.module.ts | 16 +- .../multi-currency-reports.store.ts | 117 ++-- .../profit-loss-reports.component.html | 3 - .../profit-loss-reports.component.scss | 0 .../profit-loss-reports.component.ts | 36 -- ...profit-loss-report-grid-row.component.html | 155 +++++ ...profit-loss-report-grid-row.component.scss | 11 + .../profit-loss-report-grid-row.component.ts | 80 +++ .../profit-loss-report-grid.component.html | 353 +++++++++++ .../profit-loss-report-grid.component.scss | 68 +++ .../profit-loss-report-grid.component.ts | 258 ++++++++ .../profit-loss-report.component.html} | 43 +- .../profit-loss-report.component.ts | 325 ++++++++++ .../app/multi-currency-reports/profit.json | 455 ++++++++++++++ .../trial-balance-report.component.scss | 0 .../trial-balance-report.component.ts | 353 ----------- .../trial-balance-report-grid.component.html | 8 +- .../trial-balance-report-grid.component.ts | 50 +- .../trial-balance-report.component.html | 21 +- .../trial-balance-report.component.ts | 163 +++-- .../src/app/services/tl-pl.service.ts | 8 +- .../src/app/store/tl-pl/tl-pl.reducer.ts | 7 +- 41 files changed, 2899 insertions(+), 1346 deletions(-) delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/grid-row/grid-report-row.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/grid-row/grid-report-row.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/grid-row/grid-report-row.component.ts delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.html delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.scss delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss-multi-currency/profit-loss-reports.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/components/profit-loss-grid-row/profit-loss-report-grid-row.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/components/profit-loss-grid-row/profit-loss-report-grid-row.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/components/profit-loss-grid-row/profit-loss-report-grid-row.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/profit-loss-report-grid.component.html create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/profit-loss-report-grid.component.scss create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/components/profit-loss-grid/profit-loss-report-grid.component.ts rename apps/web-giddh/src/app/multi-currency-reports/{trial-balance-multi-currency/trial-balance-report.component.html => profit-loss/profit-loss-report.component.html} (54%) create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit-loss/profit-loss-report.component.ts create mode 100644 apps/web-giddh/src/app/multi-currency-reports/profit.json delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.scss delete mode 100644 apps/web-giddh/src/app/multi-currency-reports/trial-balance-multi-currency/trial-balance-report.component.ts diff --git a/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts b/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts index bb64383b92c..4bd9c883295 100644 --- a/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/balance-sheet/balance-sheet.component.ts @@ -69,8 +69,6 @@ export class BalanceSheetComponent implements AfterViewInit, OnDestroy { this.showLoader = this.store.pipe(select(p => p.tlPl.bs.showLoader), takeUntil(this.destroyed$)); this.store.pipe(select(s => s.tlPl.bs.data), takeUntil(this.destroyed$)).subscribe((p) => { if (p) { - console.log("s.tlPl.bs.data",p); - let data = cloneDeep(p) as BalanceSheetData; if (data && data.message) { setTimeout(() => { diff --git a/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts b/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts index 837dbe7ad33..61532a5e642 100644 --- a/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/filter/filter.component.ts @@ -207,8 +207,6 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { this.selectedDateRangeUi = dayjs(a[0]).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(a[1]).format(GIDDH_NEW_DATE_FORMAT_UI); this.fromDate = dayjs(universalDate[0]).format(GIDDH_DATE_FORMAT); this.toDate = dayjs(universalDate[1]).format(GIDDH_DATE_FORMAT); - console.log("selectedDateRangeUi",this.selectedDateRangeUi); - this.filterData(); } }); @@ -313,7 +311,6 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public filterData() { - console.log("1"); this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); this.onPropertyChanged.emit(this.filterForm?.value); // this will clear the search and reset it after we click apply --G0-2745 @@ -322,7 +319,6 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public refreshData() { - console.log("2"); this.setFYFirstTime(this.filterForm.controls['selectedFinancialYearOption']?.value); let data = cloneDeep(this.filterForm?.value); data.refresh = true; @@ -371,7 +367,6 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { } public onTagSelected(ev) { - console.log("3"); this.selectedTag = ev?.value; this.filterForm.get('tagName')?.patchValue(ev?.value); this.filterForm.get('refresh')?.patchValue(true); @@ -397,7 +392,6 @@ export class FinancialReportsFilterComponent implements OnInit, OnDestroy { * @memberof FinancialReportsFilterComponent */ public handleBranchChange(selectedEntity: any): void { - console.log("4"); this.currentBranch.name = selectedEntity?.label; setTimeout(() => { this.expandAllChange.emit(false); diff --git a/apps/web-giddh/src/app/financial-reports/components/profit-loss/components/profit-loss-grid/profit-loss-grid.component.html b/apps/web-giddh/src/app/financial-reports/components/profit-loss/components/profit-loss-grid/profit-loss-grid.component.html index 72db0e33031..dff150db7d8 100644 --- a/apps/web-giddh/src/app/financial-reports/components/profit-loss/components/profit-loss-grid/profit-loss-grid.component.html +++ b/apps/web-giddh/src/app/financial-reports/components/profit-loss/components/profit-loss-grid/profit-loss-grid.component.html @@ -145,6 +145,7 @@

{{ localeData?.no_data_found }}

+ {{plData | json}}
diff --git a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts index 4045edfd2f3..6be85ad6a26 100644 --- a/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts +++ b/apps/web-giddh/src/app/financial-reports/components/trial-balance/trial-balance.component.ts @@ -65,8 +65,6 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { public ngOnInit() { this.data$ = this.store.pipe(select(createSelector((p: AppState) => p.tlPl.tb.data, (p) => { - console.log("p",p); - let d = cloneDeep(p); if (d) { if (d.message) { @@ -112,17 +110,13 @@ export class TrialBalanceComponent implements OnInit, AfterViewInit, OnDestroy { this.from = request.from; this.to = request.to; this.isDateSelected = request && request.selectedDateOption === '1'; - console.log("this.isV2",this.isV2); if (this.isV2) { this.store.dispatch(this.tlPlActions.GetV2TrialBalance(cloneDeep(request))); } else { this.store.dispatch(this.tlPlActions.GetTrialBalance(cloneDeep(request))); } - //this.getTrialBalanceReport(); } public getTrialBalanceReport(){ - console.log("getMultiCurrencyReport"); - this.componentStore.getMultiCurrencyReport(ReportType.TrialBalance); } diff --git a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html deleted file mode 100644 index c26341c427a..00000000000 --- a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.html +++ /dev/null @@ -1,147 +0,0 @@ -___--______-_-_-_ - - - -
-

{{ localeData?.no_data_found }}

- -
- -
-
-
- - -
-
-
- - - - - - - - -
-
-
- {{ localeData?.particular }} - -
-
- -
-
-
- {{ commonLocaleData?.app_as_of }} - - {{ - dayjs(bsData?.dates?.to, giddhDateFormat)?.toString() - | date: "dd MMMM yyyy" - }} - - {{ commonLocaleData?.app_as_of }} - - {{ - dayjs(bsData?.dates?.from, giddhDateFormat) - .add(-1, "day") - ?.toString() | date: "dd MMMM yyyy" - }} -
- -
-
- {{ localeData?.equity_liabilities }} -
-
- - {{ list | json}} 4--------5 - - {{ grp | json}} 2--------3 - - - - - - -
-
- {{ localeData?.total_liabilities }} -
-
- - - - - - -
-
- - - - - - -
-
-
-
- - - -
- -
-
-
-
diff --git a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss deleted file mode 100644 index f3cb5a024ac..00000000000 --- a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.scss +++ /dev/null @@ -1,83 +0,0 @@ -.bs-table-grid { - th { - border: none !important; - border-bottom: 1px solid var(--color-table-primary-header-bar-border) !important; - padding: 13px 8px 14px 0 !important; - &:first-child { - padding: 0 !important; - } - i.glyphicon-search { - position: relative; - z-index: 1; - font-size: 13px; - color: var(--color-abbey); - padding-right: 8px; - cursor: pointer; - display: flex; - align-items: center; - } - input { - height: 47px; - } - } -} -.tb-wrapper { - width: 70%; - margin: auto; -} -@media (max-width: 1024px) { - .tb-wrapper { - width: 100%; - margin: auto; - .table-container { - overflow-x: auto; - } - } -} -@media screen and (max-width: 767px) { - .table-container { - .profit-loss { - tr { - th { - width: 100%; - white-space: nowrap !important; - word-break: normal; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - } - .table-container section div .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - .pl-grid-row, - .profit-loss { - .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - .top-bar { - &.row { - flex-wrap: nowrap; - overflow: initial; - } - .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - } -} diff --git a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts deleted file mode 100644 index a1c17ec087e..00000000000 --- a/apps/web-giddh/src/app/multi-currency-reports/asdfghjhgfdsdfghjhgfd/balance-sheet-report.component.ts +++ /dev/null @@ -1,203 +0,0 @@ -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - ElementRef, - EventEmitter, - Input, - NgZone, - OnChanges, - OnDestroy, - OnInit, - Output, - SimpleChanges, - ViewChild, -} from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { each } from 'apps/web-giddh/src/app/lodash-optimized'; -import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; -import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; -import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; -import * as dayjs from 'dayjs'; -import { ReplaySubject } from 'rxjs'; -import { debounceTime, takeUntil } from 'rxjs/operators'; -import { MultiCurrencyReportsComponentStore } from '../multi-currency-reports.store'; -import { ReportType } from '../multi-currency.const'; - -@Component({ - selector: 'balance-sheet-reportsdfghfds', - templateUrl: './balance-sheet-report.component.html', - styleUrls: [`./balance-sheet-report.component.scss`], - changeDetection: ChangeDetectionStrategy.OnPush, - providers: [MultiCurrencyReportsComponentStore] -}) -export class BalanceSheetReportdfgfdComponent implements OnInit, OnChanges, OnDestroy { - public noData: boolean = false; - public showClearSearch: boolean = false; - @Input() public search: string = ''; - public bsData: BalanceSheetData; - public synced_date:string=""; - public initFormData:any={}; - @Input() public padding: string; - public dayjs = dayjs; - @Input() public expandAll: boolean; - @Input() public searchInput: string = ''; - @Input() public from: string = ''; - @Input() public to: string = ''; - @Output() public searchChange = new EventEmitter(); - @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; - public bsSearchControl: UntypedFormControl = new UntypedFormControl(); - /** This holds giddh date format */ - public giddhDateFormat: string = GIDDH_DATE_FORMAT; - /** Observable to unsubscribe all the store listeners to avoid memory leaks */ - private destroyed$: ReplaySubject = new ReplaySubject(1); - /* This will hold local JSON data */ - public localeData: any = {}; - /* This will hold common JSON data */ - public commonLocaleData: any = {}; - /** Hides the data while a new search is made to refresh the virtual list */ - public hideData: boolean; - /** True, when expand all button is toggled while search is enabled */ - public isExpandToggledDuringSearch: boolean; - - constructor(private cd: ChangeDetectorRef, private zone: NgZone, private componentStore: MultiCurrencyReportsComponentStore) { - - } - - public ngOnChanges(changes: SimpleChanges) { - if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { - this.isExpandToggledDuringSearch = true; - if (this.bsData) { - this.zone.run(() => { - if (this.bsData) { - this.toggleVisibility(this.bsData.assets, changes.expandAll.currentValue); - this.toggleVisibility(this.bsData.liabilities, changes.expandAll.currentValue); - // always make first level visible .... - if (this.bsData.liabilities) { - each(this.bsData.liabilities, (grp: any) => { - if (grp.isIncludedInSearch) { - grp.isVisible = true; - each(grp.accounts, (acc: any) => { - if (acc.isIncludedInSearch) { - acc.isVisible = true; - } - }); - } - }); - } - if (this.bsData.assets) { - each(this.bsData.assets, (grp: any) => { - if (grp.isIncludedInSearch) { - grp.isVisible = true; - each(grp.accounts, (acc: any) => { - if (acc.isIncludedInSearch) { - acc.isVisible = true; - } - }); - } - }); - } - - } - this.cd.detectChanges(); - }); - } - } - } - - public ngOnInit() { - this.bsSearchControl.valueChanges.pipe( - debounceTime(700), takeUntil(this.destroyed$)) - .subscribe((newValue) => { - this.searchInput = newValue; - this.hideData = true; - this.searchChange.emit(this.searchInput); - this.isExpandToggledDuringSearch = false; - if (newValue === '') { - this.showClearSearch = false; - } - setTimeout(() => { - this.hideData = false; - this.cd.detectChanges(); - }, 10); - }); - this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((data) => { - if(data){ - this.bsData = data.response; - this.synced_date = data.date; - this.initFormData = data.request; - console.log("reportDataList",data); - - this.cd.detectChanges(); - } - }); - - } - - public toggleSearch() { - this.showClearSearch = true; - - setTimeout(() => { - if (this.searchInputEl && this.searchInputEl.nativeElement) { - this.searchInputEl.nativeElement.focus(); - } - }, 200); - } - - public clickedOutside(event, el) { - if (this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') { - return; - } - - if (this.childOf(event.target, el)) { - return; - } else { - this.showClearSearch = false; - } - } - - /* tslint:disable */ - public childOf(c, p) { - while ((c = c.parentNode) && c !== p) { - } - return !!c; - } - - private toggleVisibility = (data: ChildGroup[], isVisible: boolean) => { - each(data, (grp: ChildGroup) => { - if (grp.isIncludedInSearch) { - grp.isCreated = true; - grp.isVisible = isVisible; - grp.isOpen = isVisible; - each(grp.accounts, (acc: Account) => { - if (acc.isIncludedInSearch) { - acc.isCreated = true; - acc.isVisible = isVisible; - } - }); - this.toggleVisibility(grp.childGroups, isVisible); - } - }); - } - - /** - * This will destroy all the memory used by this component - * - * @memberof BalanceSheetGridComponent - */ - public ngOnDestroy(): void { - this.destroyed$.next(true); - this.destroyed$.complete(); - } - - public searchData(event: any){ - console.log('creatMultiCurrencyReport', event); - this.componentStore.creatMultiCurrencyReport({reportType: ReportType.BalanceSheet,payload: event}); - } - - public getProfitLossReport(){ - console.log("getMultiCurrencyReport"); - - this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); - } -} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html index f1470ec2dc2..8b8d49f5f45 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html @@ -4,11 +4,27 @@ (localeData)="localeData = $event" (commonLocaleData)="commonLocaleData = $event" > - + +
-
+
-
+

{{ localeData?.no_data_found }}

diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts index ebecbcd5536..533a65dea1e 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts @@ -3,8 +3,10 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + EventEmitter, Input, OnDestroy, + Output, ViewChild, } from '@angular/core'; import { select, Store } from '@ngrx/store'; @@ -21,14 +23,6 @@ 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'; -// import { TBPlBsActions } from '../../../actions/tl-pl.actions'; -// import { cloneDeep, each } from '../../../lodash-optimized'; -// import { CompanyResponse } from '../../../models/api-models/Company'; -// import { Account, ChildGroup } from '../../../models/api-models/Search'; -// import { BalanceSheetData, ProfitLossRequest } from '../../../models/api-models/tb-pl-bs'; -// import { ToasterService } from '../../../services/toaster.service'; -// import { AppState } from '../../../store/roots'; -// import { BalanceSheetGridComponent } from './components/balance-sheet-grid/balance-sheet-report-grid.component'; @Component({ @@ -38,19 +32,21 @@ import { prepareBalanceSheetData } from '../../store/tl-pl/tl-pl.reducer'; providers: [MultiCurrencyReportsComponentStore] }) export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { - /** This will hold local JSON data */ - public localeData: any = {}; - /** This will hold common JSON data */ - public commonLocaleData: any = {}; - + /** + * Retrieves the selected company + * + * @returns {CompanyResponse} The currently selected company + * @memberof BalanceSheetReportComponent + */ public get selectedCompany(): CompanyResponse { return this._selectedCompany; } - + /** - * set company and fetch data + * Sets the selected company and fetches its data * - * @memberof BalanceSheetComponent + * @param {CompanyResponse} value The company to set + * @memberof BalanceSheetReportComponent */ @Input() public set selectedCompany(value: CompanyResponse) { @@ -65,29 +61,40 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { }; } } - + /** 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; + /** 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 = new ReplaySubject(1); + /** Stores the selected company data */ private _selectedCompany: CompanyResponse; - constructor(private store: Store, public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService, private componentStore: MultiCurrencyReportsComponentStore) { - this.showLoader = this.store.pipe(select(p => p.tlPl.bs.showLoader), takeUntil(this.destroyed$)); + this.showLoader = this.componentStore.inProgressReport$; this.componentStore.reportDataList$.pipe(takeUntil(this.destroyed$)).subscribe((p) => { if (p) { - - let data = prepareBalanceSheetData(cloneDeep(p)); - console.log('prepareBalanceSheetData',data); - if (data && data.message) { setTimeout(() => { this.toaster.clearAllToaster(); @@ -97,35 +104,42 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { if (data && data.liabilities) { this.InitData(data.liabilities); data.liabilities.forEach(g => { - g.isVisible = true; - g.isCreated = true; - g.isIncludedInSearch = true; + g['isVisible'] = true; + g['isCreated'] = true; + g['isIncludedInSearch'] = true; }); } if (data && data.assets) { this.InitData(data.assets); data.assets.forEach(g => { - g.isVisible = true; - g.isCreated = true; - g.isIncludedInSearch = true; + g['isVisible'] = true; + g['isCreated'] = true; + g['isIncludedInSearch'] = true; }); } this.data = data; + this.cd.detectChanges(); } else { this.data = null; } }); } + /** + * Initializes data for the balance sheet groups + * + * @param {ChildGroup[]} d The list of child groups + * @memberof BalanceSheetReportComponent + */ public InitData(d: ChildGroup[]) { each(d, (grp: ChildGroup) => { - grp.isVisible = false; - grp.isCreated = false; - grp.isIncludedInSearch = true; + grp['isVisible'] = false; + grp['isCreated'] = false; + grp['isIncludedInSearch'] = true; each(grp.accounts, (acc: Account) => { - acc.isIncludedInSearch = true; - acc.isCreated = false; - acc.isVisible = false; + acc['isIncludedInSearch'] = true; + acc['isCreated'] = false; + acc['isVisible'] = false; }); if (grp.childGroups) { this.InitData(grp.childGroups); @@ -133,25 +147,65 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { }); } + /** + * Detects changes after the view is initialized + * + * @memberof BalanceSheetReportComponent + */ public ngAfterViewInit() { this.cd.detectChanges(); } + /** + * Filters data based on the given request + * + * @param {ProfitLossRequest} request The request parameters + * @memberof BalanceSheetReportComponent + */ public filterData(request: ProfitLossRequest) { this.from = request.from; this.to = request.to; this.isDateSelected = request && request.selectedDateOption === '1'; this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); } + /** + * Updates the last sync date + * + * @param {*} event The event containing the sync date + * @memberof BalanceSheetReportComponent + */ + public lastDate(event: any){ + 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) { - console.log('creatMultiCurrencyReport', event); 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) { let tempFYIndex = 0; each(financialYears, (fy: any, index: number) => { @@ -166,12 +220,23 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { return tempFYIndex; } + /** + * Expands all items in the balance sheet + * + * @memberof BalanceSheetReportComponent + */ public expandAllEvent() { setTimeout(() => { this.cd.detectChanges(); }, 1); } + /** + * 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) { diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html index eef58bff7e9..6c1fe15568c 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html @@ -50,32 +50,12 @@

{{ localeData?.no_data_found }}

{{ commonLocaleData?.app_as_of }} {{ - dayjs(bsData?.dates?.to, giddhDateFormat)?.toString() - | date: "dd MMMM yyyy" - }} - - - {{ commonLocaleData?.app_as_of }} - - {{ - dayjs(bsData?.dates?.from, giddhDateFormat) - .add(-1, "day") - ?.toString() | date: "dd MMMM yyyy" + lastSyncDate + }} diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts index 41e3603c828..af6dc50a77e 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts @@ -17,10 +17,6 @@ import { UntypedFormControl } from '@angular/forms'; import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; -// import { each } from 'apps/web-giddh/src/app/lodash-optimized'; -// import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; -// import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; -// import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; import * as dayjs from 'dayjs'; import { each } from 'apps/web-giddh/src/app/lodash-optimized'; import { ReplaySubject } from 'rxjs'; @@ -33,36 +29,57 @@ import { debounceTime, takeUntil } from 'rxjs/operators'; changeDetection: ChangeDetectionStrategy.OnPush }) export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDestroy { + /** Indicates if there is no data available */ public noData: boolean; + /** Determines if the clear search button should be shown */ public showClearSearch: boolean = false; + /** Holds the search query */ @Input() public search: string = ''; + /** Holds the balance sheet data */ @Input() public bsData: BalanceSheetData; + /** Padding for the report grid */ @Input() public padding: string; + /** Day.js instance for date formatting */ public dayjs = dayjs; + /** Determines if all items should be expanded */ @Input() public expandAll: boolean; + /** Holds the search input text */ @Input() public searchInput: string = ''; + /** Holds the start date */ @Input() public from: string = ''; + /** Holds the end date */ @Input() public to: string = ''; + /** Stores the last synchronization date */ + @Input() public lastSyncDate: string = ''; + /** Emits an event when the search input changes */ @Output() public searchChange = new EventEmitter(); + /** Reference to the search input element */ @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + /** Form control for the search input */ public bsSearchControl: UntypedFormControl = new UntypedFormControl(); - /** This holds giddh date format */ + /** Stores the Giddh date format */ public giddhDateFormat: string = GIDDH_DATE_FORMAT; - /** Observable to unsubscribe all the store listeners to avoid memory leaks */ + /** Observable to manage memory leaks */ private destroyed$: ReplaySubject = new ReplaySubject(1); - /* This will hold local JSON data */ + /** Stores local JSON data */ public localeData: any = {}; - /* This will hold common JSON data */ + /** Stores common JSON data */ public commonLocaleData: any = {}; - /** Hides the data while a new search is made to refresh the virtual list */ + /** Indicates whether data should be hidden during search */ public hideData: boolean; - /** True, when expand all button is toggled while search is enabled */ + /** Indicates if expand all was toggled during search */ public isExpandToggledDuringSearch: boolean; constructor(private cd: ChangeDetectorRef, private zone: NgZone) { - + } + /** + * Handles changes to the component's input properties + * + * @param {SimpleChanges} changes The changes object + * @memberof BalanceSheetReportGridComponent + */ public ngOnChanges(changes: SimpleChanges) { if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { this.isExpandToggledDuringSearch = true; @@ -104,7 +121,13 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes } } + /** + * Initializes the component + * + * @memberof BalanceSheetReportGridComponent + */ public ngOnInit() { + this.lastSyncDate = dayjs(this.lastSyncDate, 'DD-MM-YYYY').format('DD MMMM YYYY'); this.bsSearchControl.valueChanges.pipe( debounceTime(700), takeUntil(this.destroyed$)) .subscribe((newValue) => { @@ -122,6 +145,11 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes }); } + /** + * Toggles the visibility of the search bar + * + * @memberof BalanceSheetReportGridComponent + */ public toggleSearch() { this.showClearSearch = true; @@ -132,6 +160,13 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes }, 200); } + /** + * Handles click events outside the search input + * + * @param {*} event The click event + * @param {*} el The element to check + * @memberof BalanceSheetReportGridComponent + */ public clickedOutside(event, el) { if (this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') { return; @@ -144,13 +179,27 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes } } - /* tslint:disable */ + /** + * Checks if an element is a child of another + * + * @param {*} c The child element + * @param {*} p The parent element + * @returns {boolean} True if the element is a child, false otherwise + * @memberof BalanceSheetReportGridComponent + */ public childOf(c, p) { while ((c = c.parentNode) && c !== p) { } return !!c; } + /** + * Toggles the visibility of child groups and accounts + * + * @param {ChildGroup[]} data The data to toggle visibility for + * @param {boolean} isVisible Indicates whether the items should be visible + * @memberof BalanceSheetReportGridComponent + */ private toggleVisibility = (data: ChildGroup[], isVisible: boolean) => { each(data, (grp: ChildGroup) => { if (grp.isIncludedInSearch) { @@ -169,9 +218,9 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes } /** - * This will destroy all the memory used by this component + * Cleans up resources used by the component * - * @memberof BalanceSheetGridComponent + * @memberof BalanceSheetReportGridComponent */ public ngOnDestroy(): void { this.destroyed$.next(true); diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts index f39ceabb82e..b2e6dbd1297 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.ts @@ -9,21 +9,33 @@ import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Se changeDetection: ChangeDetectionStrategy.OnPush }) export class BalanceSheetReportGridRowComponent implements OnChanges { + /** Holds the details of the group */ @Input() public groupDetail: ChildGroup; + /** Holds the search query */ @Input() public search: string; + /** Holds the padding value for the row */ @Input() public padding: string; + /** Start date for the data range */ @Input() public from: string = ''; + /** End date for the data range */ @Input() public to: string = ''; - /** True, if all items are expanded */ + /** Indicates if all items should be expanded */ @Input() public expandAll: boolean; - /** Minimum limit on which Trial balance viewport enables */ + /** Minimum limit at which the Trial Balance viewport is enabled */ public minimumViewportLimit = TRIAL_BALANCE_VIEWPORT_LIMIT; - /** True, when expand all button is toggled while search is enabled */ + /** Indicates if expand-all is toggled during a search */ @Input() public isExpandToggledDuringSearch: boolean; + constructor(private cd: ChangeDetectorRef) { } + /** + * Lifecycle hook called when input properties change + * + * @param {SimpleChanges} changes Changes detected in input properties + * @memberof BalanceSheetReportGridRowComponent + */ public ngOnChanges(changes: SimpleChanges) { if (changes.groupDetail && !changes.groupDetail.firstChange && changes.groupDetail.currentValue !== changes.groupDetail.previousValue) { this.cd.detectChanges(); @@ -33,6 +45,12 @@ export class BalanceSheetReportGridRowComponent implements OnChanges { } } + /** + * Handles the click event on an entry and navigates to the corresponding ledger page + * + * @param {Account} acc The account object clicked + * @memberof BalanceSheetReportGridRowComponent + */ public entryClicked(acc) { let url = location.href + '?returnUrl=ledger/' + acc?.uniqueName + '/' + this.from + '/' + this.to; if (isElectron) { @@ -45,13 +63,14 @@ export class BalanceSheetReportGridRowComponent implements OnChanges { } + /** - * Track by function for balance sheet item + * Track by function for balance sheet item to optimize DOM rendering * - * @param {*} index Index of the item - * @param {Account} item Current item - * @return {string} Item uniquename - * @memberof BalanceSheetGridRowComponent + * @param {number} index The index of the current item + * @param {Account} item The account item + * @return {string} The unique name of the item + * @memberof BalanceSheetReportGridRowComponent */ public trackByFn(index, item: Account): string { return item?.uniqueName; diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html index 29fbfc56714..fb1e1465def 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.html @@ -43,7 +43,6 @@ {{ company?.name }} @@ -64,6 +63,29 @@
+ +
+ +
diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss index 39a9b0bf974..c5a1357f314 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.scss @@ -14,6 +14,19 @@ max-width: 760px; width: 100%; } +::ng-deep .custom-placeholder .mat-form-field-label { + color: red !important; +} + +::ng-deep .custom-placeholder.mat-focused .mat-form-field-label { + color: red !important; +} + +::ng-deep .custom-placeholder .mat-form-field-label.mat-error { + color: red !important; +} + + .input-wrapper:before { position: absolute; content: ""; diff --git a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts index 43d744c0f7b..f4b2ff784cc 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/filter/filter-multi-currency.component.ts @@ -29,93 +29,78 @@ import { SettingsBranchActions } from '../../actions/settings/branch/settings.br changeDetection: ChangeDetectionStrategy.OnPush }) export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { + /** The current date object representing today's date */ public today: Date = new Date(); + /** The selected date option, initialized to '0' */ public selectedDateOption: string = '0'; + /** The reactive form group for managing filter inputs */ public filterForm: UntypedFormGroup; + /** The string used for searching items */ public search: string = ''; + /** The list of financial options available for selection */ public financialOptions: IOption[] = []; + /** The form control for managing account search input */ public accountSearchControl: UntypedFormControl = new UntypedFormControl(); + /** The list of tags associated with the component */ public tags: TagRequest[] = []; + /** The currently selected tag */ public selectedTag: string; - @Input() public tbExportXLS: boolean = false; - @Input() public tbExportCsv: boolean = false; - @Input() public plBsExportXLS: boolean = false; - @Input() public BsExportXLS: boolean = false; - @Output() public seachChange = new EventEmitter(); - @Output() public tbExportXLSEvent = new EventEmitter(); - @Output() public tbExportCsvEvent = new EventEmitter(); - @Output() public plBsExportXLSEvent = new EventEmitter(); - /** True, when expand all operation is performed */ - @Input() public expandAll: boolean; - @Output() - public expandAllChange: EventEmitter = new EventEmitter(); - public showClearSearch: boolean; - public request: TrialBalanceRequest = {}; - public dateOptions: IOption[] = []; - public imgPath: string; + /** A boolean indicating the current state of the universal date picker */ public universalDateICurrent: boolean = false; - /** Observable to store the branches of current company */ - public currentCompanyBranches$: Observable; - /** Stores the branch list of a company */ - public currentCompanyBranches: Array; - /** Stores the current branch */ - public currentBranch: any = { name: '', uniqueName: '' }; - /** Stores the current company */ + /** Stores the currently active company information */ public activeCompany: any; - /** True, if mobile screen size is detected */ - public isMobileScreen: boolean = true; - @Input() public showLoader: Observable; - @Output() public lastSyncDate = new EventEmitter(); ; - @Input() public showLabels: boolean = false; + /** Event emitter for sending the last synchronization date */ + @Output() public lastSyncDate = new EventEmitter(); + /** Event emitter for notifying property changes */ @Output() public onPropertyChanged = new EventEmitter(); + /** Event emitter for sending the filter value */ @Output() public filterValue = new EventEmitter(); + /** Event emitter for notifying search changes */ + @Output() public seachChange = new EventEmitter(); + /** A boolean indicating whether all elements are expanded */ + @Input() public expandAll: boolean; + /** Event emitter for toggling the expand/collapse state of all elements */ + @Output() public expandAllChange: EventEmitter = new EventEmitter(); + /** Reference to the modal used for creating tags */ @ViewChild('createTagModal', { static: true }) public createTagModal: ModalDirective; - public universalDate$: Observable; - public newTagForm: UntypedFormGroup; - /** Date format type */ - public giddhDateFormat: string = GIDDH_DATE_FORMAT; - /** directive to get reference of element */ + /** Template reference for the date picker directive */ @ViewChild('datepickerTemplate') public datepickerTemplate: TemplateRef; - /** This will store modal reference */ + /** Reference to the modal for managing its state */ public modalRef: BsModalRef; - /** This will store selected date range to use in api */ + /** The selected date range used in API requests */ public selectedDateRange: any; - /** This will store selected date range to show on UI */ + /** The selected date range displayed on the user interface */ public selectedDateRangeUi: any; - /** This will store available date ranges */ - public datePickerOption: any = GIDDH_DATE_RANGE_PICKER_RANGES; - /** dayjs object */ + /** Instance of the dayjs library for date manipulation */ public dayjs = dayjs; - /** Selected from date */ + /** The selected "from" date in string format */ public fromDate: string; - /** Selected to date */ + /** The selected "to" date in string format */ public toDate: string; - /** Selected range label */ + /** The label for the selected date range */ public selectedRangeLabel: any = ""; - /** This will store the x/y position of the field to show datepicker under it */ + /** The x and y position of the date field used to position the date picker */ public dateFieldPosition: any = { x: 0, y: 0 }; - /** Stores the current organization type */ - public currentOrganizationType: OrganizationType; + /** ReplaySubject used to handle cleanup and prevent memory leaks */ private destroyed$: ReplaySubject = new ReplaySubject(1); - private _selectedCompany: CompanyResponse; - /** This will hold local JSON data */ + /** Stores the local JSON data for the component */ public localeData: any = {}; - /** This will hold common JSON data */ + /** Stores the common JSON data for the application */ public commonLocaleData: any = {}; + /** List of companies available for selection */ public companyList: any; + /** List of currencies available for selection */ public currencyList: any; - /* This will clear the select value in sh-select */ - public forceClear$: Observable = observableOf({ status: false }); + public dateOptions: IOption[] = []; + /** This will store available date ranges */ + public datePickerOption: any = GIDDH_DATE_RANGE_PICKER_RANGES; + constructor(private fb: UntypedFormBuilder, private cd: ChangeDetectorRef, private store: Store, - private settingsTagService: SettingsTagService, private generalService: GeneralService, private modalService: BsModalService, - private breakPointObservar: BreakpointObserver, - private settingsBranchAction: SettingsBranchActions, - private toaster: ToasterService, private componentStore: MultiCurrencyReportsComponentStore ) { this.filterForm = this.fb.group({ @@ -131,57 +116,9 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { selectCurrency: [null] }); - this.newTagForm = this.fb.group({ - name: ['', Validators.required], - description: [] - }); - - this.universalDate$ = this.store.pipe(select(p => p.session.applicationDate),distinctUntilChanged(), takeUntil(this.destroyed$)); - - } - - public get selectedCompany() { - return this._selectedCompany; - } - - /** - * init form and other properties from input company - * - * @memberof FinancialReportsFilterComponent - */ - @Input() - public set selectedCompany(value: CompanyResponse) { - if (!value) { - return; - } - this._selectedCompany = value; - this.financialOptions = value.financialYears.map(q => { - return { label: q?.uniqueName, value: q?.uniqueName }; - }); - - if (this.filterForm.get('selectedDateOption')?.value === '0' && value.activeFinancialYear) { - this.filterForm?.patchValue({ - to: value.activeFinancialYear.financialYearEnds, - from: value.activeFinancialYear.financialYearStarts, - selectedFinancialYearOption: value.activeFinancialYear?.uniqueName - }); - } } public ngOnInit() { - this.getTags(); - - this.breakPointObservar.observe([ - '(max-width: 767px)' - ]).pipe(takeUntil(this.destroyed$)).subscribe(result => { - this.isMobileScreen = result.matches; - }); - - this.currentOrganizationType = this.generalService.currentOrganizationType; - this.imgPath = isElectron ? 'assets/icon/' : AppUrl + APP_FOLDER + 'assets/icon/'; - if (!this.showLabels) { - this.filterForm?.patchValue({ selectedDateOption: '0' }); - } this.accountSearchControl.valueChanges.pipe( debounceTime(700), takeUntil(this.destroyed$)) .subscribe((newValue) => { @@ -190,7 +127,7 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { this.cd.detectChanges(); }); - this.universalDate$.subscribe((a) => { + this.componentStore.universalDate$.pipe(distinctUntilChanged(), takeUntil(this.destroyed$)).subscribe((a) => { if (a) { this.universalDateICurrent = false; // assign dates @@ -216,60 +153,10 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { this.selectedDateRangeUi = dayjs(a[0]).format(GIDDH_NEW_DATE_FORMAT_UI) + " - " + dayjs(a[1]).format(GIDDH_NEW_DATE_FORMAT_UI); this.fromDate = dayjs(universalDate[0]).format(GIDDH_DATE_FORMAT); this.toDate = dayjs(universalDate[1]).format(GIDDH_DATE_FORMAT); - + this.filterData(); } }); - this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { - if(activeCompany?.uniqueName !== this.activeCompany?.uniqueName) { - this.activeCompany = activeCompany; - } - }); - this.currentCompanyBranches$ = this.store.pipe(select(appStore => appStore.settings.branches), takeUntil(this.destroyed$)); - this.currentCompanyBranches$.subscribe(response => { - if (response?.length) { - this.filterForm.get('branchUniqueName').setValue(""); - this.forceClear$ = observableOf({ status: true }); - this.currentCompanyBranches = []; - this.currentCompanyBranches = response.map(branch => ({ - label: branch.name, - value: branch?.uniqueName, - name: branch.name, - parentBranch: branch.parentBranch - })); - this.currentCompanyBranches.unshift({ - label: this.activeCompany ? this.activeCompany.name : '', - name: this.activeCompany ? this.activeCompany.name : '', - value: this.activeCompany ? this.activeCompany?.uniqueName : '', - isCompany: true - }); - let currentBranchUniqueName; - if (!this.currentBranch?.uniqueName) { - // Assign the current branch only when it is not selected. This check is necessary as - // opening the branch switcher would reset the current selected branch as this subscription is run everytime - // branches are loaded - if (this.currentOrganizationType === OrganizationType.Branch) { - currentBranchUniqueName = this.generalService.currentBranchUniqueName; - this.currentBranch = cloneDeep(response.find(branch => branch?.uniqueName === currentBranchUniqueName)) || this.currentBranch; - } else { - currentBranchUniqueName = this.activeCompany ? this.activeCompany?.uniqueName : ''; - this.currentBranch = { - name: this.activeCompany ? this.activeCompany.name : '', - alias: this.activeCompany ? this.activeCompany.nameAlias : '', - uniqueName: this.activeCompany ? this.activeCompany?.uniqueName : '', - }; - } - } - this.filterForm.get('branchUniqueName').setValue(this.currentBranch?.uniqueName); - this.filterForm.updateValueAndValidity(); - this.cd.detectChanges(); - } else { - if (this.generalService.companyUniqueName) { - // Avoid API call if new user is onboarded - this.store.dispatch(this.settingsBranchAction.GetALLBranches({ from: '', to: '', hierarchyType: BranchHierarchyType.Flatten })); - } - } - }); this.componentStore.currencyList$.pipe(takeUntil(this.destroyed$)).subscribe(currency => { if (currency) { @@ -279,43 +166,24 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { }) this.currencyList = currencyList; } - }); + this.componentStore.companyList$.pipe(takeUntil(this.destroyed$)).subscribe(companies => { - if (!companies || companies?.length === 0) { - return; + if (companies) { + let orderedCompanies = _.orderBy(companies, 'name'); + this.companyList = orderedCompanies; } - let orderedCompanies = _.orderBy(companies, 'name'); - this.companyList = orderedCompanies; }); this.componentStore.filterRequestData$.pipe(takeUntil(this.destroyed$)).subscribe(filterRequestData => { - if(filterRequestData){ - this.getForm('selectCurrency').patchValue(filterRequestData.request.reportCurrency); - let selectCompany = []; - filterRequestData.request.companiesList.forEach((company)=>{ + if (filterRequestData) { + this.getForm('selectCurrency').patchValue(filterRequestData.request.reportCurrency); + let selectCompany = []; + filterRequestData.request.companiesList.forEach((company) => { selectCompany.push(company.uniqueName) - }); - this.getForm('shareCompanyList').patchValue(selectCompany); - this.lastSyncDate.emit(filterRequestData.lastFetchedAt); - this.cd.detectChanges(); - } - }); - } - - - - public setCurrentFY() { - // set financial years based on company financial year - this.store.pipe(select(state => state.session.activeCompany), takeUntil(this.destroyed$)).subscribe(activeCompany => { - if (activeCompany && this.universalDateICurrent) { - let activeFinancialYear = activeCompany.activeFinancialYear; - if (activeFinancialYear) { - // assign dates - this.filterForm?.patchValue({ - from: dayjs(activeFinancialYear.financialYearStarts, GIDDH_DATE_FORMAT).startOf('day').format(GIDDH_DATE_FORMAT), - to: dayjs().format(GIDDH_DATE_FORMAT) - }); - } + }); + this.getForm('shareCompanyList').patchValue(selectCompany); + this.lastSyncDate.emit(filterRequestData.lastFetchedAt); + this.cd.detectChanges(); } }); } @@ -344,55 +212,25 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { this.seachChange.emit(a); } - // public refreshData() { - // let data = cloneDeep(this.filterForm?.value); - // data.refresh = true; - // this.onPropertyChanged.emit(data); - // this.emitExpand(false); - // } - public onSubmit() { let data = { - companiesList:[], - reportCurrency:'' + companiesList: [], + reportCurrency: '' }; this.getForm('shareCompanyList').value?.forEach(control => { if (control) { - data.companiesList.push({from: this.getForm('from').value, to: this.getForm('to').value, uniqueName: control }); + data.companiesList.push({ from: this.getForm('from').value, to: this.getForm('to').value, uniqueName: control }); } }); data.reportCurrency = this.getForm('selectCurrency').value || this.activeCompany?.baseCurrency; this.filterValue.emit(data); } - public setFYFirstTime(selectedFY: string) { - if (selectedFY) { - let inx = this._selectedCompany.financialYears?.findIndex(p => p?.uniqueName === selectedFY); - if (inx !== -1) { - this.filterForm?.patchValue({ - fy: inx === 0 ? 0 : inx * -1 - }); - } - } - } public toggleTagsModal() { this.createTagModal.toggle(); } - public createTag() { - this.settingsTagService.CreateTag(this.newTagForm.getRawValue()).pipe(takeUntil(this.destroyed$)).subscribe(response => { - this.toaster.clearAllToaster(); - if (response?.status === "success") { - this.getTags(); - this.toaster.successToast(this.commonLocaleData?.app_messages?.tag_created, this.commonLocaleData?.app_success); - } else { - this.toaster.errorToast(response?.message, response?.code); - } - }); - this.toggleTagsModal(); - } - /** * Emit Expand * @@ -405,26 +243,6 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { }, 10); } - // public onTagSelected(ev) { - // this.selectedTag = ev?.value; - // this.filterForm.get('tagName')?.patchValue(ev?.value); - // this.filterForm.get('refresh')?.patchValue(true); - // this.onPropertyChanged.emit(); - // } - - /** - * Branch change handler - * - * @memberof FinancialReportsFilterComponent - */ - // public handleBranchChange(selectedEntity: any): void { - // this.currentBranch.name = selectedEntity?.label; - // setTimeout(() => { - // this.expandAllChange.emit(false); - // }, 10); - // this.onPropertyChanged.emit(this.filterForm?.value); - // } - /** * To show the datepicker * @@ -476,36 +294,4 @@ export class FilterMultiCurrencyComponent implements OnInit, OnDestroy { this.filterForm.controls['to'].setValue(this.toDate); } } - - /** - * Callback for translation response complete - * - * @param {boolean} event - * @memberof FinancialReportsFilterComponent - */ - public translationComplete(event: boolean): void { - if (event) { - this.dateOptions = [ - { label: this.commonLocaleData?.app_date_range, value: '1' }, - { label: this.commonLocaleData?.app_financial_year, value: '0' } - ]; - } - } - - /** - * Fetching list of tags - * - * @memberof FinancialReportsFilterComponent - */ - public getTags(): void { - this.settingsTagService.GetAllTags().pipe(takeUntil(this.destroyed$)).subscribe(response => { - if (response?.status === "success" && response?.body?.length > 0) { - map(response?.body, (tag) => { - tag.value = tag.name; - tag.label = tag.name; - }); - this.tags = orderBy(response?.body, 'name'); - } - }); - } } diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html index 2108ea60302..8245dbebdbd 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.html @@ -6,51 +6,32 @@ (commonLocaleData)="commonLocaleData = $event" > - - + + +
- +
-
- + + + +
- +
-
- + + + +
- +
-
-
+ +
diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss index 0ca834489a5..a8dae93090a 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.scss @@ -1,5 +1,5 @@ .tb-pl-bs-header-tab { - padding-top: 55px; + padding-top: 10px; } @media only screen and (max-width: 767px) { .tb-pl-bs-header-tab { diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts index 16a82329c65..dd681e4ba31 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.component.ts @@ -174,6 +174,8 @@ export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { public localeData: any = {}; /** Holds the common JSON data for the component */ public commonLocaleData: any = {}; + /** Holds active selected Tab Index */ + public selectedTabIndex: number = 2; constructor( private store: Store, @@ -262,10 +264,10 @@ export class MultiCurrencyReportsComponent implements OnInit, OnDestroy { * @param {number} tabIndex * @memberof FinancialReportsComponent */ - public tabChanged(tab: string, tabIndex: number): void { - if (!this.preventTabChangeWithRoute) { - this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); - } + public tabChanged(selectedTabIndex: any): void { + this.selectedTabIndex = selectedTabIndex; + //this.router.navigate(['/pages/multi-currency-report'], { queryParams: { tab, tabIndex } }); + } } diff --git a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts index 7cd9b103aa6..479aa42d50d 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/multi-currency-reports.module.ts @@ -67,6 +67,7 @@ import { GridReportRowComponent } from './grid-row/grid-report-row.component'; import { ProfitLossReportComponent } from './profit-loss/profit-loss-report.component'; import { ProfitLossReportGridComponent } from './profit-loss/components/profit-loss-grid/profit-loss-report-grid.component'; import { ProfitLossReportGridRowComponent } from './profit-loss/components/profit-loss-grid/components/profit-loss-grid-row/profit-loss-report-grid-row.component'; +import { MatTabsModule } from '@angular/material/tabs'; @NgModule({ @@ -135,7 +136,8 @@ import { ProfitLossReportGridRowComponent } from './profit-loss/components/profi MatFormFieldModule, MatSelectModule, FormFieldsModule, - FinancialSearchPipe + FinancialSearchPipe, + MatTabsModule ], }) diff --git a/apps/web-giddh/src/app/multi-currency-reports/profit-loss/profit-loss-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/profit-loss/profit-loss-report.component.html index 9019c4505a2..db51d4914af 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/profit-loss/profit-loss-report.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/profit-loss/profit-loss-report.component.html @@ -6,18 +6,12 @@ >
diff --git a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html index 3cb03a0f85f..f5e7f264d1a 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/trial-balance/trial-balance-report.component.html @@ -6,17 +6,11 @@ >
diff --git a/apps/web-giddh/src/assets/locale/trial-profit-balance/en.json b/apps/web-giddh/src/assets/locale/trial-profit-balance/en.json index 812c455ec58..c53b7b70e75 100644 --- a/apps/web-giddh/src/assets/locale/trial-profit-balance/en.json +++ b/apps/web-giddh/src/assets/locale/trial-profit-balance/en.json @@ -3,5 +3,7 @@ "trial_balance": "Trial Balance", "profit_loss": "Profit & Loss", "balance_sheet": "Balance Sheet" - } + }, + "company_list": "Company List", + "currency_list": "Currency List" } From b44642fc48e5492662a46530f0c66b5d443ad743 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 23 Dec 2024 17:54:54 +0530 Subject: [PATCH 07/15] conflict-resolve --- .../balance-sheet-report.component.html | 12 +- .../balance-sheet-report.component.ts | 115 ++-- .../balance-sheet-report-grid.component.html | 351 ++++++------ .../balance-sheet-report-grid.component.scss | 59 +- .../balance-sheet-report-grid.component.ts | 105 ++-- ...lance-sheet-report-grid-row.component.html | 11 +- ...lance-sheet-report-grid-row.component.scss | 8 - ...balance-sheet-report-grid-row.component.ts | 16 +- .../filter-multi-currency.component.html | 113 ++-- .../filter-multi-currency.component.scss | 71 +-- .../filter/filter-multi-currency.component.ts | 187 +++--- .../grid-row/grid-report-row.component.html | 19 +- .../grid-row/grid-report-row.component.ts | 81 ++- .../multi-currency-reports.component.html | 14 +- .../multi-currency-reports.component.scss | 8 - .../multi-currency-reports.component.ts | 236 +------- .../multi-currency-reports.module.ts | 48 +- .../multi-currency-reports.routing.module.ts | 1 - .../multi-currency-reports.store.ts | 5 +- .../pipes/accounts-filter.pipe.ts | 20 +- ...profit-loss-report-grid-row.component.html | 7 +- .../profit-loss-report-grid-row.component.ts | 23 +- .../profit-loss-report-grid.component.html | 536 +++++++++--------- .../profit-loss-report-grid.component.scss | 14 +- .../profit-loss-report-grid.component.ts | 143 +++-- .../profit-loss-report.component.html | 12 +- .../profit-loss-report.component.ts | 201 +++---- .../trial-balance-report-grid.component.html | 113 ++-- .../trial-balance-report-grid.component.scss | 23 - .../trial-balance-report-grid.component.ts | 174 +++--- .../trial-balance-report.component.html | 18 +- .../trial-balance-report.component.ts | 135 ++--- .../src/app/services/tl-pl.service.ts | 20 +- .../app/shared/helpers/defaultDateFormat.ts | 1 + .../locale/trial-profit-balance/hi.json | 6 +- .../locale/trial-profit-balance/mr.json | 6 +- 36 files changed, 1163 insertions(+), 1749 deletions(-) diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html index 95109ad8e9c..79b580cf142 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.html @@ -9,13 +9,11 @@ (filterValue)="searchData($event)" (onPropertyChanged)="filterData()" (lastSyncDate)="lastDate($event)" - (seachChange)="searchChanged($event)" + (searchChange)="searchChanged($event)" (expandAllChange)="expandAllEvent()" [(expandAll)]="expandAll" > -
- -
+
-
-
-

{{ localeData?.no_data_found }}

-
+
+

{{ localeData?.no_data_found }}

diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts index 6187b96dfe4..3c5728e783f 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/balance-sheet-report.component.ts @@ -3,28 +3,20 @@ import { 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 { 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'; - @Component({ selector: 'balance-sheet-report', templateUrl: './balance-sheet-report.component.html', @@ -32,41 +24,16 @@ import { prepareBalanceSheetData } from '../../store/tl-pl/tl-pl.reducer'; 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 - }; - } - } + /** 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; + public showLoader: Observable = this.componentStore.inProgressReport$;; /** Stores the balance sheet data */ public data: BalanceSheetData; /** Stores the profit and loss request parameters */ @@ -81,28 +48,15 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { 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 = new ReplaySubject(1); - /** Stores the selected company data */ - private _selectedCompany: CompanyResponse; - constructor(public tlPlActions: TBPlBsActions, private cd: ChangeDetectorRef, private toaster: ToasterService, private componentStore: MultiCurrencyReportsComponentStore) { - this.showLoader = this.componentStore.inProgressReport$; + 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.message) { - setTimeout(() => { - this.toaster.clearAllToaster(); - this.toaster.infoToast(data.message); - }, 100); - } + let data = prepareBalanceSheetData(cloneDeep(response)); if (data && data.liabilities) { - this.InitData(data.liabilities); + this.initData(data.liabilities); data.liabilities.forEach(childGroup => { childGroup['isVisible'] = true; childGroup['isCreated'] = true; @@ -110,7 +64,7 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { }); } if (data && data.assets) { - this.InitData(data.assets); + this.initData(data.assets); data.assets.forEach(childGroup => { childGroup['isVisible'] = true; childGroup['isCreated'] = true; @@ -118,7 +72,7 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { }); } this.data = data; - this.cd.detectChanges(); + this.changeDetectionRef.detectChanges(); } else { this.data = null; } @@ -127,22 +81,22 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { /** * Initializes data for the balance sheet groups - * + * @returns {void} * @param {ChildGroup[]} groupList The list of child groups * @memberof BalanceSheetReportComponent */ - public InitData(groupList: ChildGroup[]) { - each(groupList, (childGroup: ChildGroup) => { + public initData(groupList: ChildGroup[]): void { + groupList.forEach((childGroup: ChildGroup) => { childGroup['isVisible'] = false; childGroup['isCreated'] = false; childGroup['isIncludedInSearch'] = true; - each(childGroup.accounts, (account: Account) => { + childGroup.accounts.forEach((account: Account) => { account['isIncludedInSearch'] = true; account['isCreated'] = false; account['isVisible'] = false; }); if (childGroup.childGroups) { - this.InitData(childGroup.childGroups); + this.initData(childGroup.childGroups); } }); } @@ -150,44 +104,47 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { /** * Detects changes after the view is initialized * + * @returns {void} * @memberof BalanceSheetReportComponent */ - public ngAfterViewInit() { - this.cd.detectChanges(); + public ngAfterViewInit(): void { + this.changeDetectionRef.detectChanges(); } /** * Filters data based on the given request * - * + * @returns {void} * @memberof BalanceSheetReportComponent */ - public filterData() { + public filterData(): void { this.componentStore.getMultiCurrencyReport(ReportType.BalanceSheet); } /** * Updates the last sync date * * @param {*} event The event containing the sync date + * @returns {void} * @memberof BalanceSheetReportComponent */ - public lastDate(event: any){ - this.lastSyncDate = event ; + public lastDate(event: any): void { + this.lastSyncDate = event; } /** * Searches and updates data based on the provided criteria * + * @returns {void} * @param {*} event The event containing search criteria * @memberof BalanceSheetReportComponent */ - public searchData(event: any) { + 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 { @@ -198,14 +155,14 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { /** * 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 + * @param {any} activeFY The active financial year + * @param {any} financialYears The list of financial years * @returns {number} The index of the active financial year * @memberof BalanceSheetReportComponent */ - public findIndex(activeFY, financialYears) { + public findIndex(activeFY: any, financialYears: any): number { let tempFYIndex = 0; - each(financialYears, (fy: any, index: number) => { + financialYears.forEach((fy: any, index: number) => { if (fy?.uniqueName === activeFY?.uniqueName) { if (index === 0) { tempFYIndex = index; @@ -220,26 +177,28 @@ export class BalanceSheetReportComponent implements AfterViewInit, OnDestroy { /** * Expands all items in the balance sheet * + * @returns {void} * @memberof BalanceSheetReportComponent */ - public expandAllEvent() { + public expandAllEvent(): void { setTimeout(() => { - this.cd.detectChanges(); + this.changeDetectionRef.detectChanges(); }, 1); } /** * Updates the search text and handles search functionality * + * @returns {void} * @param {string} event The new search text * @memberof BalanceSheetReportComponent */ - public searchChanged(event: string) { + public searchChanged(event: string): void { this.search = event; if (!this.search) { this.expandAll = false; } - this.cd.detectChanges(); + this.changeDetectionRef.detectChanges(); } } diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html index 6c1fe15568c..9651f80e4ac 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.html @@ -10,204 +10,191 @@

{{ localeData?.no_data_found }}

-
-
-
- - -
-
-
- - - - + + + +
+
+
+ + +
+
+
+ + + + - - - -
+
-
- {{ localeData?.particular }} - -
-
- -
+ {{ localeData?.particular }} +
-
- {{ commonLocaleData?.app_as_of }} - - {{ - lastSyncDate - - }} -
- -
-
- {{ localeData?.equity_liabilities }} -
-
- - -
- + +
+
+
+ {{ commonLocaleData?.app_as_of }} + + {{ lastSyncDate }} - - - - - - - - -
-
- {{ localeData?.total_liabilities }} -
-
- - - - - - -
-
- - - - - - -
-
+
+ +
+ {{ localeData?.equity_liabilities }}
-
+ + +
+ + +
+
+
-
-
- -
-
- {{ localeData?.ii_assets }} -
+ + + +
+
+ {{ localeData?.total_liabilities }}
- - -
- + + + - -
-
-
- - - + + + +
+
+ + + + + + +
+
-
-
- {{ localeData?.total_assets }} -
-
- - - - - - +
+
+ +
+ {{ localeData?.ii_assets }}
-
- - - + +
+ - - - -
+ + + + + + + +
+
+ +
+
+ {{ localeData?.total_assets }} +
+
+ + + + + + +
+
+ + + + + +
-
- +
+
diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss index f3cb5a024ac..92c6e104d0f 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.scss @@ -6,16 +6,6 @@ &:first-child { padding: 0 !important; } - i.glyphicon-search { - position: relative; - z-index: 1; - font-size: 13px; - color: var(--color-abbey); - padding-right: 8px; - cursor: pointer; - display: flex; - align-items: center; - } input { height: 47px; } @@ -33,51 +23,4 @@ overflow-x: auto; } } -} -@media screen and (max-width: 767px) { - .table-container { - .profit-loss { - tr { - th { - width: 100%; - white-space: nowrap !important; - word-break: normal; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - } - .table-container section div .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - .pl-grid-row, - .profit-loss { - .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - .top-bar { - &.row { - flex-wrap: nowrap; - overflow: initial; - } - .group { - white-space: nowrap; - width: 30%; - max-width: 30%; - white-space: nowrap; - min-width: 150px; - } - } - } -} +} \ No newline at end of file diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts index f5ac93472c7..bfcd47f8003 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/balance-sheet-report-grid.component.ts @@ -13,12 +13,11 @@ import { SimpleChanges, ViewChild, } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; +import { FormControl } from '@angular/forms'; import { Account, ChildGroup } from 'apps/web-giddh/src/app/models/api-models/Search'; import { BalanceSheetData } from 'apps/web-giddh/src/app/models/api-models/tb-pl-bs'; -import { GIDDH_DATE_FORMAT } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; +import { GIDDH_DATE_FORMAT, GIDDH_DATE_FORMAT_DD_MMMM_YYYY } from 'apps/web-giddh/src/app/shared/helpers/defaultDateFormat'; import * as dayjs from 'dayjs'; -import { each } from 'apps/web-giddh/src/app/lodash-optimized'; import { ReplaySubject } from 'rxjs'; import { debounceTime, takeUntil } from 'rxjs/operators'; @@ -29,18 +28,14 @@ import { debounceTime, takeUntil } from 'rxjs/operators'; changeDetection: ChangeDetectionStrategy.OnPush }) export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDestroy { - /** Indicates if there is no data available */ - public noData: boolean; - /** Determines if the clear search button should be shown */ - public showClearSearch: boolean = false; + /** Reference to the search input element */ + @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; /** Holds the search query */ @Input() public search: string = ''; /** Holds the balance sheet data */ @Input() public bsData: BalanceSheetData; /** Padding for the report grid */ @Input() public padding: string; - /** Day.js instance for date formatting */ - public dayjs = dayjs; /** Determines if all items should be expanded */ @Input() public expandAll: boolean; /** Holds the search input text */ @@ -52,15 +47,17 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes /** Stores the last synchronization date */ @Input() public lastSyncDate: string = ''; /** Emits an event when the search input changes */ - @Output() public searchChange = new EventEmitter(); - /** Reference to the search input element */ - @ViewChild('searchInputEl', { static: true }) public searchInputEl: ElementRef; + @Output() public searchChange: EventEmitter = new EventEmitter(); + /** Day.js instance for date formatting */ + public dayjs: any = dayjs; + /** Indicates if there is no data available */ + public noData: boolean; + /** Determines if the clear search button should be shown */ + public showClearSearch: boolean = false; /** Form control for the search input */ - public bsSearchControl: UntypedFormControl = new UntypedFormControl(); + public bsSearchControl: FormControl = new FormControl(); /** Stores the Giddh date format */ public giddhDateFormat: string = GIDDH_DATE_FORMAT; - /** Observable to manage memory leaks */ - private destroyed$: ReplaySubject = new ReplaySubject(1); /** Stores local JSON data */ public localeData: any = {}; /** Stores common JSON data */ @@ -69,9 +66,11 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes public hideData: boolean; /** Indicates if expand all was toggled during search */ public isExpandToggledDuringSearch: boolean; + /** Observable to manage memory leaks */ + private destroyed$: ReplaySubject = new ReplaySubject(1); + + constructor(private changeDetectionRef: ChangeDetectorRef, private zone: NgZone) { - constructor(private cd: ChangeDetectorRef, private zone: NgZone) { - } /** @@ -81,7 +80,7 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes * @memberof BalanceSheetReportGridComponent */ public ngOnChanges(changes: SimpleChanges) { - if (changes.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { + if (changes?.expandAll && !changes.expandAll.firstChange && changes.expandAll.currentValue !== changes.expandAll.previousValue) { this.isExpandToggledDuringSearch = true; if (this.bsData) { this.zone.run(() => { @@ -90,10 +89,10 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes this.toggleVisibility(this.bsData.liabilities, changes.expandAll.currentValue); // always make first level visible .... if (this.bsData.liabilities) { - each(this.bsData.liabilities, (childGroup: any) => { + this.bsData.liabilities.forEach((childGroup: any) => { if (childGroup.isIncludedInSearch) { childGroup.isVisible = true; - each(childGroup.accounts, (account: any) => { + childGroup.accounts.forEach((account: any) => { if (account.isIncludedInSearch) { account.isVisible = true; } @@ -102,10 +101,10 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes }); } if (this.bsData.assets) { - each(this.bsData.assets, (childGroup: any) => { + this.bsData.assets.forEach((childGroup: any) => { if (childGroup.isIncludedInSearch) { childGroup.isVisible = true; - each(childGroup.accounts, (account: any) => { + childGroup.accounts.forEach((account: any) => { if (account.isIncludedInSearch) { account.isVisible = true; } @@ -113,9 +112,8 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes } }); } - } - this.cd.detectChanges(); + this.changeDetectionRef.detectChanges(); }); } } @@ -127,53 +125,51 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes * @memberof BalanceSheetReportGridComponent */ public ngOnInit() { - this.lastSyncDate = dayjs(this.lastSyncDate, 'DD-MM-YYYY').format('DD MMMM YYYY'); + this.lastSyncDate = dayjs(this.lastSyncDate, GIDDH_DATE_FORMAT).format(GIDDH_DATE_FORMAT_DD_MMMM_YYYY); this.bsSearchControl.valueChanges.pipe( debounceTime(700), takeUntil(this.destroyed$)) .subscribe((newValue) => { - this.searchInput = newValue; - this.hideData = true; - this.searchChange.emit(this.searchInput); - this.isExpandToggledDuringSearch = false; - if (newValue === '') { - this.showClearSearch = false; + if (newValue) { + this.searchInput = newValue; + this.hideData = true; + this.searchChange.emit(this.searchInput); + this.isExpandToggledDuringSearch = false; + if (newValue === '') { + this.showClearSearch = false; + } + setTimeout(() => { + this.hideData = false; + this.changeDetectionRef.detectChanges(); + }, 10); } - setTimeout(() => { - this.hideData = false; - this.cd.detectChanges(); - }, 10); }); } /** * Toggles the visibility of the search bar - * + * + * @returns {void} * @memberof BalanceSheetReportGridComponent */ - public toggleSearch() : void { + public toggleSearch(): void { this.showClearSearch = true; - - setTimeout(() => { - if (this.searchInputEl && this.searchInputEl.nativeElement) { + if (this.searchInputEl && this.searchInputEl.nativeElement) { + setTimeout(() => { this.searchInputEl.nativeElement.focus(); - } - }, 200); + }, 200); + } } /** * Handles click events outside the search input * - * @param {*} event The click event - * @param {*} el The element to check + * @param {any} event The click event + * @param {ElementRef} element The element to check * @returns {void} * @memberof BalanceSheetReportGridComponent */ - public clickedOutside(event, el) : void { - if (this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') { - return; - } - - if (this.childOf(event.target, el)) { + public clickedOutside(event: any, element: ElementRef): void { + if ((this.bsSearchControl?.value !== null && this.bsSearchControl?.value !== '') || this.childOf(event.target, element)) { return; } else { this.showClearSearch = false; @@ -201,13 +197,13 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes * @param {boolean} isVisible Indicates whether the items should be visible * @memberof BalanceSheetReportGridComponent */ - private toggleVisibility = (data: ChildGroup[], isVisible: boolean) => { - each(data, (childGroup: ChildGroup) => { + private toggleVisibility(data: ChildGroup[], isVisible: boolean): void { + data.forEach((childGroup: ChildGroup) => { if (childGroup.isIncludedInSearch) { childGroup.isCreated = true; childGroup.isVisible = isVisible; childGroup.isOpen = isVisible; - each(childGroup.accounts, (account: Account) => { + childGroup.accounts.forEach((account: Account) => { if (account.isIncludedInSearch) { account.isCreated = true; account.isVisible = isVisible; @@ -220,7 +216,8 @@ export class BalanceSheetReportGridComponent implements OnInit, OnChanges, OnDes /** * Cleans up resources used by the component - * + * + * @returns {void} * @memberof BalanceSheetReportGridComponent */ public ngOnDestroy(): void { diff --git a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html index c22da9d6320..b70d2633e39 100644 --- a/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html +++ b/apps/web-giddh/src/app/multi-currency-reports/balance-sheet/components/balance-sheet-grid/components/balance-sheet-grid-row/balance-sheet-report-grid-row.component.html @@ -2,7 +2,7 @@ class="row pl-grid-row" [financial-accordion]="groupDetail" *ngIf="groupDetail.groupName && (groupDetail.isVisible || groupDetail.isCreated)" - [ngClass]="{ 'isHidden': !groupDetail.isVisible }" + [ngClass]="{ 'd-none': !groupDetail.isVisible }" >
- -