Skip to content

MrmCogsComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-cogs/mrm-cogs.component.ts (line 78)

Part of: Frontend

MrmCogsComponent is an Angular dashboard widget for loading, initializing, aggregating, and saving cost-of-goods data. It responds to component lifecycle changes, checks feature subscription access, calculates totals by year or month, and formats month and price values for display.

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: 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
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
withTaxableboolean
selectedTeamnumber
forecastRuleIdnumber
dataBranchData[]
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
allGroupsTotalSalesnumber
totalPercentageOfAchievedSalesnumber
totalCumulativeSalesnumber
totalDirectSalesnumber
totalTotalDirectSalesnumber
totalDirectServicenumber
totalDirectSalesWithScrapnumber
totalTotalDirectSalesWithScrapnumber
totalCommissionnumber
_totalSalesAfterCommissionnumber
popupany
searchTextstring
pastDiffnumber
urrenFeaturenumber

Where it refuses work

  • MrmCogsComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • 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 AppSettings.calculateMonthsBeforeToday(month.YearId, month.MonthId -1) == 0 || AppSetting….

Diagram

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

Usage

ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MrmCogsComponent } from './mrm-cogs.component';

describe('MrmCogsComponent', () => {
  let fixture: ComponentFixture<MrmCogsComponent>;
  let component: MrmCogsComponent;

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [MrmCogsComponent],
    });

    fixture = TestBed.createComponent(MrmCogsComponent);
    component = fixture.componentInstance;
  });

  it('loads and formats dashboard data', () => {
    component.ngOnInit();

    if (component.checkFeatureSubscription()) {
      component.getDashboardData();
      component.calculateSumByYear();
      component.calculateSumByMonth();

      const formattedPrice = component.getpriceFormatted();
      const monthName = component.translateMonthName();

      expect(formattedPrice).toBeDefined();
      expect(monthName).toBeDefined();
    }
  });
});

AI Coding Instructions

  • Call checkFeatureSubscription() before requesting or displaying dashboard data that depends on subscription access.
  • Keep data loading in getDashboardData() and data setup in initalizingData() so lifecycle methods remain focused on orchestration.
  • Recalculate yearly and monthly sums after dashboard data changes before rendering formatted values.
  • Use translateMonthName() and getpriceFormatted() for display output instead of duplicating formatting logic in templates.
  • Preserve the existing lifecycle flow between ngOnInit(), ngOnChanges(), data initialization, and dashboard persistence.

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)

  • DashboardTabComponentFrontend/src/app/components/dashboard/dashboard-libary/dashboard-tab/dashboard-tab.component.ts:1
  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1
  • ReportsTabComponentFrontend/src/app/components/reports/reports-library/reports-tab/reports-tab.component.ts:1

Was this page helpful?

Download as PDF