Skip to content

MrmCogsComponent

reference
2 min readUpdated

Kind: Class

Source: Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/mrm-cogs/mrm-cogs.component.ts (line 84)

Part of: Pams

MrmCogsComponent is an Angular dashboard widget for displaying and managing MRM cost-of-goods-sold data. It checks authorization access, loads and saves dashboard data, aggregates values 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: MonthData)string
getpriceFormattedgetpriceFormatted(x: undefined)string
onResizeonResize()void
setChachingsetChaching()void
getChachinggetChaching()void
switchWithTaxableHandlerswitchWithTaxableHandler()void
switchChartTypeHandlerswitchChartTypeHandler()void
switchBasedOnTendencyHandlerswitchBasedOnTendencyHandler()void
comparingWithPrevMonthcomparingWithPrevMonth(month: BranchData, bIndex: number, 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
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
withTaxableboolean
selectedTeamnumber
forecastRuleIdnumber
dataBranchData[]
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
subscriptionSubscription
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
allGroupsTotalSalesnumber
totalPercentageOfAchievedSalesnumber
totalCumulativeSalesnumber
totalDirectSalesnumber
totalTotalDirectSalesnumber
totalDirectServicenumber
totalDirectSalesWithScrapnumber
totalTotalDirectSalesWithScrapnumber
totalCommissionnumber
_totalSalesAfterCommissionnumber
popupany
searchTextstring

Where it refuses work

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

Diagram

mermaid
graph LR
    A[Angular Lifecycle] --> B[GetAuthorizationAccess]
    A --> C[ngOnInit]
    A --> D[ngOnChanges]
    A --> E[ngOnDestroy]

    C --> F[getDashboardData]
    C --> G[initalizingData]
    D --> F

    F --> H[calculateSumByYear]
    F --> I[calculateSumByMonth]
    I --> J[translateMonthName]

    G --> K[saveDashboardData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmCogsComponent } from './mrm-cogs.component';

@Component({
  selector: 'app-dashboard-host',
  template: `
    <app-mrm-cogs #mrmCogs></app-mrm-cogs>

    <button type="button" (click)="refreshCogsData()">
      Refresh COGS data
    </button>
  `
})
export class DashboardHostComponent {
  @ViewChild('mrmCogs')
  mrmCogsComponent?: MrmCogsComponent;

  refreshCogsData(): void {
    this.mrmCogsComponent?.getDashboardData();
  }

  saveCogsData(): void {
    this.mrmCogsComponent?.saveDashboardData();
  }
}

AI Coding Instructions

  • Keep data loading inside getDashboardData() and initialize widget state through initalizingData().
  • Run authorization checks through GetAuthorizationAccess() before exposing or updating dashboard data.
  • Preserve Angular lifecycle handling in ngOnInit(), ngOnChanges(), and ngOnDestroy() when adding subscriptions or input-driven refresh behavior.
  • Use calculateSumByYear() and calculateSumByMonth() for aggregation rather than duplicating calculation logic in templates or parent components.
  • Route month labels through translateMonthName() so displayed month names remain consistent with the component’s translation behavior.

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