Skip to content

MrmCashPositionComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-cash-position/mrm-cash-position.component.ts (line 89)

Part of: Frontend

MrmCashPositionComponent is an Angular dashboard widget that retrieves and saves cash-position dashboard data, initializes its working state, and calculates monthly totals and performance. It checks feature subscription access, loads currency rates, and translates month names for dashboard display during lifecycle updates.

Extends: BaseWidgetComponent

Methods

MethodSignatureReturns
checkFeatureSubscriptioncheckFeatureSubscription()boolean
ngOnInitngOnInit()void
ngOnChangesngOnChanges()void
getDashboardDatagetDashboardData()void
saveDashboardDatasaveDashboardData()void
initalizingDatainitalizingData(value: BranchData[])void
calculateSumByMonthcalculateSumByMonth(monthIndex: number)void
getCurrencyRatesgetCurrencyRates()void
calculatePerformancePercalculatePerformancePer(month: MonthData)number
translateMonthNametranslateMonthName(month: MonthData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
syncScrollsyncScroll(e: undefined)void
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
onValueChangedonValueChanged(e: undefined)void
onChartInitonChartInit(e: any, index: number)void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
isCurrentMonthisCurrentMonth(month: MonthData)boolean
comparingWithPrevMonthcomparingWithPrevMonth(month: MonthData, bIndex: number, index: number, propertyName: string)string
comparingMonthsWithPrevSummcomparingMonthsWithPrevSumm(month: TotalBookingMonths, index: number, propertyName: string)string
setValuesetValue(value: number)void
setForecastValuesetForecastValue(value: number)void
setMarginAvaragesetMarginAvarage(value: number)void
isForecastisForecast(month: MonthData)boolean
isAchievedOrCurrentisAchievedOrCurrent(month: MonthData)boolean
getpriceForecastAmountgetpriceForecastAmount(month: MonthData)number
expectedCurrencyChangeexpectedCurrencyChange(e: undefined)void
selectTextselectText(e: undefined)void
mouseoverRowSpanmouseoverRowSpan(e: undefined, bIndex: number)void
mouseoutRowSpanmouseoutRowSpan(e: undefined, bIndex: number)void
editSelectedMonthPrepareeditSelectedMonthPrepare(month: MonthData)void
sortingsorting(propertyName: string, propertyType: string, monthIndex: number)void

Properties

PropertyType
scrollOneElementRef
scrollTwoElementRef
scrollThreeElementRef
_widgetWidget
_widgetTypestring
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
selectedDataBranchData[]
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
currencyRateDatacurrencyRatesData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsTotalBookingMonths[]
tempTotalMonthTotalBookingMonths
pastDiffnumber
urrenFeaturenumber
sortingDirectionnumber

Where it refuses work

  • MrmCashPositionComponent stops the work with an early return when a[propertyName] < b[propertyName], in 2 places.
  • MrmCashPositionComponent stops the work with an early return when a[propertyName] > b[propertyName], in 2 places.
  • MrmCashPositionComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmCashPositionComponent stops the work with an early return when month.MonthId == 12.
  • MrmCashPositionComponent stops the work with an early return when AppSettings.calculateMonthsBeforeToday(month.YearId, month.MonthId -1) == 0 || AppSetting….
  • MrmCashPositionComponent stops the work with an early return when month[propertyName] < this.data[bIndex].MrmCashPositions[index - 1][propertyName].

Diagram

mermaid
graph LR
  A[Angular Lifecycle] --> B[MrmCashPositionComponent]
  B --> C[checkFeatureSubscription]
  B --> D[ngOnInit]
  B --> E[ngOnChanges]
  D --> F[getDashboardData]
  D --> G[initalizingData]
  G --> H[getCurrencyRates]
  G --> I[calculateSumByMonth]
  I --> J[calculatePerformancePer]
  B --> K[translateMonthName]
  B --> L[saveDashboardData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmCashPositionComponent } from './mrm-cash-position.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <app-mrm-cash-position></app-mrm-cash-position>

    <button type="button" (click)="refreshCashPosition()">
      Refresh cash position
    </button>
  `,
})
export class DashboardPageComponent {
  @ViewChild(MrmCashPositionComponent)
  cashPositionWidget!: MrmCashPositionComponent;

  refreshCashPosition(): void {
    if (!this.cashPositionWidget.checkFeatureSubscription()) {
      return;
    }

    this.cashPositionWidget.getDashboardData();
    this.cashPositionWidget.calculateSumByMonth();

    const performance = this.cashPositionWidget.calculatePerformancePer();
    console.log('Cash position performance:', performance);
  }
}

AI Coding Instructions

  • Keep subscription checks in place before loading or displaying cash-position data.
  • Preserve the Angular lifecycle flow in ngOnInit and ngOnChanges; avoid duplicating initialization work outside the component lifecycle.
  • Load currency rates before calculations that depend on converted monetary values.
  • Keep the existing initalizingData method name when updating call sites, since changing it can break references.
  • Save dashboard state through saveDashboardData after modifying data that should persist between dashboard updates.

Used by

3 references from 3 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (3)

  • DashboardTabComponentFrontend/src/app/components/dashboard/dashboard-libary/dashboard-tab/dashboard-tab.component.ts:1
  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1
  • ReportsTabComponentFrontend/src/app/components/reports/reports-library/reports-tab/reports-tab.component.ts:1

Was this page helpful?

Download as PDF