Skip to content

MrmProfitLossComponent

reference
2 min readUpdated

Kind: Class

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

Part of: Pams

MrmProfitLossComponent is an Angular dashboard widget for loading, initializing, saving, and summarizing MRM profit-and-loss 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
totalProfitAndLossAmountnumber
totalOthersnumber
totalTotalSGAndAnumber
totalFORXnumber
totalTotalnumber
totalCumulativenumber
totalPercentageUsedBudgetnumber
popupany
searchTextstring

Where it refuses work

  • MrmProfitLossComponent stops the work with an early return when month.MonthId == 12.
  • MrmProfitLossComponent stops the work with an early return when month[propertyName] < this.data[bIndex - 1][propertyName].
  • MrmProfitLossComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].
  • MrmProfitLossComponent stops the work with an early return when this.allowedtoEnableEdting.
  • MrmProfitLossComponent stops the work with an early return when this.allowedtoEdit.

Diagram

mermaid
graph LR
    A[Angular Lifecycle] --> B[MrmProfitLossComponent]
    B --> C[GetAuthorizationAccess]
    B --> D[getDashboardData]
    D --> E[initalizingData]
    E --> F[calculateSumByYear]
    E --> G[calculateSumByMonth]
    E --> H[translateMonthName]
    B --> I[saveDashboardData]
    A --> J[ngOnDestroy]

Usage

ts
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { MrmProfitLossComponent } from './mrm-profit-loss.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <button type="button" (click)="refreshProfitLoss()">
      Refresh
    </button>

    <button type="button" (click)="saveProfitLoss()">
      Save
    </button>
  `
})
export class DashboardPageComponent implements AfterViewInit {
  @ViewChild(MrmProfitLossComponent)
  profitLossWidget!: MrmProfitLossComponent;

  ngAfterViewInit(): void {
    this.profitLossWidget.getDashboardData();
  }

  refreshProfitLoss(): void {
    this.profitLossWidget.getDashboardData();
  }

  saveProfitLoss(): void {
    this.profitLossWidget.saveDashboardData();
  }
}

AI Coding Instructions

  • Keep authorization checks in GetAuthorizationAccess() before loading or saving dashboard data.
  • Let Angular call ngOnInit(), ngOnChanges(), and ngOnDestroy(); do not invoke lifecycle hooks from application code.
  • Call initalizingData() after dashboard data is loaded and before calculating year or month totals.
  • Keep year and month aggregation logic in calculateSumByYear() and calculateSumByMonth() rather than duplicating calculations in parent components.
  • Use translateMonthName() when rendering month labels instead of formatting month names in templates.

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)

  • TranslateHandlerPams/Web/Pams.Web/Client/app/app.module.ts:1
  • DashboardTabComponentPams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/dashboard-tab/dashboard-tab.component.ts:1
  • ReportsTabComponentPams/Web/Pams.Web/Client/app/components/dashboard/reports-library/reports-tab/reports-tab.component.ts:1

Was this page helpful?

Download as PDF