Skip to content

MrmGrossMarginComponent

reference
2 min readUpdated

Kind: Class

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

Part of: Pams

MrmGrossMarginComponent is an Angular dashboard widget that retrieves, initializes, displays, and saves gross-margin dashboard data. It responds to component lifecycle events, calculates totals by year or month, and translates month names for dashboard output.

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: MonthData, 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
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
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
withTaxableboolean
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
allGroupsTotalSalesnumber
totalSalesAfterCommissionnumber
totalSalesSummarynumber
totalDirectServicenumber
totalDirectSalesWithoutScrapnumber
totalDirectSalesWithScrapnumber
totalTotalDirectSalesWithScrapnumber
totalCommissionnumber
totalCumulativeSalesnumber
popupany
searchTextstring
fixedColumnLeftNumOnenumber
fixedColumnLeftNumTwonumber
fixedColumnLeftNumThreenumber
sortingDirectionnumber

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 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.totalBookingMonths[index - 1][propertyName].
  • MrmGrossMarginComponent stops the work with an early return when this.allowedtoEnableEdting.

Diagram

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

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmGrossMarginComponent } from './mrm-gross-margin.component';

@Component({
  selector: 'app-dashboard-host',
  template: `
    <app-mrm-gross-margin></app-mrm-gross-margin>
  `,
})
export class DashboardHostComponent {
  @ViewChild(MrmGrossMarginComponent)
  grossMarginWidget?: MrmGrossMarginComponent;

  refreshGrossMargin(): void {
    this.grossMarginWidget?.GetAuthorizationAccess();
    this.grossMarginWidget?.getDashboardData();
  }

  saveGrossMarginSettings(): void {
    this.grossMarginWidget?.saveDashboardData();
  }
}

AI Coding Instructions

  • Keep data loading inside getDashboardData() and initialization logic inside initalizingData().
  • Run authorization checks through GetAuthorizationAccess() before requesting or saving dashboard data.
  • Preserve lifecycle behavior in ngOnInit(), ngOnChanges(), and ngOnDestroy() when adding subscriptions or input-driven updates.
  • Use calculateSumByYear() and calculateSumByMonth() for aggregate values instead of duplicating sum logic in the template.
  • Keep month display formatting in translateMonthName() so dashboard labels use one translation path.

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