Skip to content

MrmNetProfitComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-net-profit/mrm-net-profit.component.ts (line 94)

Part of: Frontend

MrmNetProfitComponent is a dashboard widget component for presenting net-profit data. It checks feature subscription access, loads and saves dashboard data, calculates month and year totals, and formats month and price display values.

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
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
totalOthersnumber
totalDepreciationAmountnumber
totalTotalCogsAmountnumber
totalGrossMarginAmountnumber
totalTotalCogsAchievednumber
totalTotalNetProfitAmountnumber
totalTotalNetProfitAchievednumber
totalTotalDepreciationAmountnumber
totalTotalDepreciationAchievednumber
totalTotalFORXAmountnumber
totalTotalFORXAchievednumber
totalTotalEBITAmountnumber
totalIncomeTAXAmountnumber
totalProfitAmountBeforeTaxnumber
totalTotalEBITDAAmountnumber

Where it refuses work

  • MrmNetProfitComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmNetProfitComponent stops the work with an early return when month.MonthId == 12.
  • MrmNetProfitComponent stops the work with an early return when month[propertyName] < this.data[bIndex - 1][propertyName].
  • MrmNetProfitComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].
  • MrmNetProfitComponent 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]
  C --> E[getDashboardData]
  D --> E
  E --> F[initalizingData]
  F --> G[calculateSumByYear]
  F --> H[calculateSumByMonth]
  F --> I[translateMonthName]
  F --> J[getpriceFormatted]
  F --> K[saveDashboardData]

Usage

ts
import { MrmNetProfitComponent } from './mrm-net-profit.component';

// Obtain the component instance through Angular component composition,
// a test fixture, or another supported application integration point.
const netProfitWidget = {} as MrmNetProfitComponent;

if (netProfitWidget.checkFeatureSubscription()) {
  netProfitWidget.getDashboardData();

  netProfitWidget.calculateSumByYear();
  netProfitWidget.calculateSumByMonth();

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

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

AI Coding Instructions

  • Check checkFeatureSubscription() before requesting or displaying net-profit dashboard data.
  • Keep data loading in getDashboardData() and initialization in initalizingData() so lifecycle handlers remain focused.
  • Preserve the existing initalizingData() method name unless all callers are updated together.
  • Recalculate totals through calculateSumByYear() and calculateSumByMonth() after changing the underlying dashboard data.
  • Use translateMonthName() and getpriceFormatted() for display values instead of duplicating formatting logic.

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