Skip to content

MrmSgAComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-sg-a/mrm-sg-a.component.ts (line 80)

Part of: Frontend

MrmSgAComponent is an Angular dashboard widget component for managing MRM SG&A dashboard data. It checks feature subscription access, initializes and saves data, calculates monthly and yearly sums, and formats month and price 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: BranchData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
comparingWithPrevMonthcomparingWithPrevMonth(month: BranchData, bIndex: 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
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalBudgetnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
totalSalariesnumber
totalOthersnumber
totalTotalSGAndAnumber
totalFORXnumber
totalTotalnumber
totalCumulativenumber
totalPercentageUsedBudgetnumber
popupany
searchTextstring
pastDiffnumber
urrenFeaturenumber

Where it refuses work

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

Diagram

mermaid
graph LR
  Component[MrmSgAComponent]

  Component --> Lifecycle[Lifecycle methods]
  Lifecycle --> Init[ngOnInit]
  Lifecycle --> Changes[ngOnChanges]

  Component --> Access[Feature access]
  Access --> Subscription[checkFeatureSubscription]

  Component --> Data[Dashboard data]
  Data --> Load[getDashboardData]
  Data --> Initialize[initalizingData]
  Data --> Save[saveDashboardData]

  Component --> Calculations[Calculations]
  Calculations --> Year[calculateSumByYear]
  Calculations --> Month[calculateSumByMonth]

  Component --> Formatting[Display formatting]
  Formatting --> MonthName[translateMonthName]
  Formatting --> Price[getpriceFormatted]

Usage

ts
import { MrmSgAComponent } from './mrm-sg-a.component';

// Access the component instance after Angular creates it.
const component: MrmSgAComponent = fixture.componentInstance;

component.ngOnInit();

if (component.checkFeatureSubscription()) {
  component.getDashboardData();
  component.calculateSumByYear();
  component.calculateSumByMonth();

  const monthName = component.translateMonthName();
  const formattedPrice = component.getpriceFormatted();

  console.log({ monthName, formattedPrice });
}

AI Coding Instructions

  • Keep data initialization and refresh behavior aligned with ngOnInit and ngOnChanges.
  • Check checkFeatureSubscription() before loading or displaying subscription-dependent dashboard content.
  • Keep monthly calculations in calculateSumByMonth() and yearly calculations in calculateSumByYear().
  • Use translateMonthName() and getpriceFormatted() for display formatting instead of duplicating formatting logic.
  • Preserve the existing initalizingData() method name when calling it, including its current spelling.

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