Skip to content

MrmGrossMarginComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-gross-margin/mrm-gross-margin.component.ts (line 98)

Part of: Frontend

MrmGrossMarginComponent is an Angular dashboard widget for loading, initializing, calculating, formatting, and saving MRM gross-margin data. It checks feature-subscription access, responds to Angular lifecycle changes, and prepares monthly and yearly totals 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
switchWithTaxableHandlerswitchWithTaxableHandler()void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
comparingWithPrevMonthcomparingWithPrevMonth(month: MonthData, bIndex: number, monthIndex: number, propertyName: string)string
comparingMonthlySummaryWithPrevMonthcomparingMonthlySummaryWithPrevMonth(month: MonthData, monthIndex: number, propertyName: string)string
comparingMonthlyComulativeWithPrevMonthcomparingMonthlyComulativeWithPrevMonth(month: MonthData, 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
mouseoverRowSpanmouseoverRowSpan(e: undefined, bIndex: number)void
mouseoutRowSpanmouseoutRowSpan(e: undefined, bIndex: number)void
editSelectedMonthPrepareeditSelectedMonthPrepare(month: MonthData, supplierId: number)void
sortingsorting(propertyName: string, propertyType: string, monthIndex: number)void
syncScrollsyncScroll(e: undefined)void
openPopupopenPopup(n: string, t: string, i: string, btnTxt: string)void
savePopupsavePopup()void
ClosewithDonotSaveClosewithDonotSave()void
OnOpenedPopupOnOpenedPopup()void
closePopupclosePopup()void

Properties

PropertyType
sharedPopupSharedPopupComponent
scrollOneElementRef
_widgetWidget
_widgetTypestring
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
withTaxableboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
newResponseNewResponse
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
allGroupsTotalSalesnumber
totalSalesAfterCommissionnumber
totalSalesSummarynumber
totalDirectServicenumber
totalDirectSalesWithoutScrapnumber
totalDirectSalesWithScrapnumber
totalTotalDirectSalesWithScrapnumber
totalCommissionnumber
totalCumulativeSalesnumber
popupany
searchTextstring
fixedColumnLeftNumOnenumber

Where it refuses work

  • MrmGrossMarginComponent stops the work with an early return when a[propertyName] < b[propertyName], in 2 places.
  • MrmGrossMarginComponent stops the work with an early return when a[propertyName] > b[propertyName], in 2 places.
  • MrmGrossMarginComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmGrossMarginComponent stops the work with an early return when month.MonthId == 12.
  • MrmGrossMarginComponent stops the work with an early return when month[propertyName] < this.data[bIndex].MrmCogsGroups[monthIndex - 1][propertyName].
  • MrmGrossMarginComponent stops the work with an early return when month[propertyName] < this.newResponse.MonthlySummary[monthIndex - 1][propertyName].

Diagram

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

Usage

ts
import { MrmGrossMarginComponent } from './mrm-gross-margin.component';

const component = new MrmGrossMarginComponent();

// Angular calls lifecycle hooks when the component is rendered or updated.
component.ngOnInit();
component.ngOnChanges();

if (component.checkFeatureSubscription()) {
  component.getDashboardData();
  component.initalizingData();

  component.calculateSumByYear();
  component.calculateSumByMonth();

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

  component.saveDashboardData();

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

AI Coding Instructions

  • Call checkFeatureSubscription() before loading or saving gross-margin dashboard data.
  • Keep data-loading logic in getDashboardData() and data preparation in initalizingData().
  • Recalculate monthly and yearly totals after changing the underlying gross-margin data.
  • Use translateMonthName() for displayed month labels instead of duplicating month-name conversion logic.
  • Use getpriceFormatted() when rendering gross-margin values in the widget UI.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1

Was this page helpful?

Download as PDF