Skip to content

MrmCurrencyRateComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-currency-rate/mrm-currency-rate.component.ts (line 92)

Part of: Frontend

MrmCurrencyRateComponent is a dashboard widget component for loading, initializing, calculating, and saving currency-rate dashboard data. It checks feature subscription access, responds to Angular lifecycle changes, and formats price and month values for display.

Extends: BaseWidgetComponent

Methods

MethodSignatureReturns
checkFeatureSubscriptioncheckFeatureSubscription()boolean
ngOnInitngOnInit()void
ngOnChangesngOnChanges()void
getDashboardDatagetDashboardData()void
initalizingDatainitalizingData(value: BranchData[])void
saveDashboardDatasaveDashboardData()void
calculateSumByYearcalculateSumByYear()void
calculateSumByMonthcalculateSumByMonth(monthIndex: number)void
translateMonthNametranslateMonthName(month: MonthData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
comparingWithPrevMonthcomparingWithPrevMonth(month: BranchData, bIndex: number, monthIndex: number, propertyName: string)string
comparingBookingWithPrevSummcomparingBookingWithPrevSumm(month: MonthsSum, index: number, propertyName: string)string
isCurrentMonthisCurrentMonth(month: MonthData)boolean
getpriceForecastAmountgetpriceForecastAmount(month: MonthData)number
expectedCurrencyChangeexpectedCurrencyChange(e: undefined)void
selectTextselectText(e: undefined)void
editSelectedMonthPrepareeditSelectedMonthPrepare(month: MonthData, supplierId: number)void
openPopupopenPopup(n: string, t: string, i: string, btnTxt: string)void
savePopupsavePopup()void
ClosewithDonotSaveClosewithDonotSave()void
OnOpenedPopupOnOpenedPopup()void
closePopupclosePopup()void

Properties

PropertyType
sharedPopupSharedPopupComponent
_widgetWidget
_widgetTypestring
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
monthsSummeryMonthsSum[]
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
totalPercentageUsedBudgetnumber
popupany
searchTextstring
pastDiffnumber
urrenFeaturenumber

Where it refuses work

  • MrmCurrencyRateComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmCurrencyRateComponent stops the work with an early return when month.MonthId == 12.
  • MrmCurrencyRateComponent stops the work with an early return when month[propertyName] < this.data[bIndex].Details[monthIndex - 1][propertyName].
  • MrmCurrencyRateComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].
  • MrmCurrencyRateComponent stops the work with an early return when AppSettings.calculateMonthsBeforeToday(month.YearId, month.MonthId -1) == 0 || AppSetting….

Diagram

mermaid
graph LR
  A[Angular lifecycle] --> B[ngOnInit]
  A --> C[ngOnChanges]
  B --> D[checkFeatureSubscription]
  D --> E[initalizingData]
  E --> F[getDashboardData]
  F --> G[calculateSumByYear]
  F --> H[calculateSumByMonth]
  G --> I[translateMonthName]
  H --> J[getpriceFormatted]
  E --> K[saveDashboardData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmCurrencyRateComponent } from './mrm-currency-rate/mrm-currency-rate.component';

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

    <button (click)="refreshCurrencyRates()">
      Refresh currency rates
    </button>
  `,
})
export class DashboardPageComponent {
  @ViewChild(MrmCurrencyRateComponent)
  currencyRateComponent?: MrmCurrencyRateComponent;

  refreshCurrencyRates(): void {
    const widget = this.currencyRateComponent;

    if (!widget?.checkFeatureSubscription()) {
      return;
    }

    widget.getDashboardData();

    const formattedPrice = widget.getpriceFormatted();
    console.log('Formatted currency rate:', formattedPrice);
  }
}

AI Coding Instructions

  • Check checkFeatureSubscription() before loading or updating currency-rate dashboard data.
  • Keep initialization work in ngOnInit() and react to Angular input updates through ngOnChanges().
  • Use initalizingData() as the setup path before calculations or persistence when the component state requires initialization.
  • Keep year and month aggregation logic in calculateSumByYear() and calculateSumByMonth() rather than duplicating calculations in parent dashboard components.
  • Use translateMonthName() and getpriceFormatted() for display values so formatting remains consistent with the widget.

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