Skip to content

MrmNetProfitComponent

reference
2 min readUpdated

Kind: Class

Source: Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/mrm-net-profit/mrm-net-profit.component.ts (line 93)

Part of: Pams

MrmNetProfitComponent is a dashboard widget component for loading, initializing, saving, and summarizing MRM net-profit data. It checks authorization access, responds to Angular lifecycle events, calculates totals by year or month, and translates month names for display.

Methods

MethodSignatureReturns
GetAuthorizationAccessGetAuthorizationAccess(url: string)void
ngOnInitngOnInit()void
ngOnChangesngOnChanges()void
ngOnDestroyngOnDestroy()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
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
subscriptionSubscription
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
totalOthersnumber
totalDepreciationAmountnumber
totalTotalCogsAmountnumber
totalTotalCogsAchievednumber
totalTotalNetProfitAmountnumber
totalTotalNetProfitAchievednumber
totalTotalDepreciationAmountnumber
totalTotalDepreciationAchievednumber
totalTotalFORXAmountnumber
totalTotalFORXAchievednumber
totalTotalEBITAmountnumber
totalIncomeTAXAmountnumber
totalTotalEBITDAAmountnumber
totalTotalEBITAchievednumber
totalTotalEBITDAAchievednumber
totalTotalSalesAmountnumber
totalTotalSalesAchievednumber

Where it refuses work

  • 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 this.allowedtoEnableEdting.
  • MrmNetProfitComponent stops the work with an early return when this.allowedtoEdit.

Diagram

mermaid
graph LR
  Angular[Angular lifecycle] --> Init[ngOnInit]
  Angular --> Changes[ngOnChanges]
  Angular --> Destroy[ngOnDestroy]

  Init --> Access[GetAuthorizationAccess]
  Access --> Load[getDashboardData]
  Load --> Initialize[initalizingData]

  Initialize --> YearTotal[calculateSumByYear]
  Initialize --> MonthTotal[calculateSumByMonth]
  Initialize --> MonthLabel[translateMonthName]

  Widget[Dashboard interaction] --> Save[saveDashboardData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmNetProfitComponent } from './mrm-net-profit.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <app-mrm-net-profit #netProfitWidget></app-mrm-net-profit>

    <button type="button" (click)="refreshNetProfit()">
      Refresh net profit
    </button>

    <button type="button" (click)="saveNetProfit()">
      Save dashboard settings
    </button>
  `
})
export class DashboardPageComponent {
  @ViewChild('netProfitWidget')
  netProfitWidget!: MrmNetProfitComponent;

  refreshNetProfit(): void {
    this.netProfitWidget.getDashboardData();
  }

  saveNetProfit(): void {
    this.netProfitWidget.saveDashboardData();
  }
}

AI Coding Instructions

  • Let Angular invoke ngOnInit, ngOnChanges, and ngOnDestroy; do not call lifecycle hooks from feature code.
  • Check GetAuthorizationAccess() before adding data-loading behavior that exposes dashboard values.
  • Keep data preparation in initalizingData() after getDashboardData() so calculated values use loaded data.
  • Use calculateSumByYear() and calculateSumByMonth() for dashboard totals rather than duplicating aggregation logic in templates.
  • Keep month display formatting in translateMonthName() so month labels remain consistent across the widget.

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)

  • TranslateHandlerPams/Web/Pams.Web/Client/app/app.module.ts:1

Was this page helpful?

Download as PDF