Skip to content

MrmTotalSalesComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-total-sales/mrm-total-sales.component.ts (line 97)

Part of: Frontend

MrmTotalSalesComponent is an Angular dashboard widget that loads, initializes, and saves total-sales dashboard data. It checks feature subscription access, aggregates sales values by year or month, and formats price and month labels for display.

Extends: BaseWidgetComponent

Implements: OnChanges

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
switchVendorTypeIdHandlerswitchVendorTypeIdHandler()void
onEnumIdChangedonEnumIdChanged(e: undefined)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
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
withTaxableboolean
withTaxableBackupboolean
isPamsDataboolean
enumIdnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
calcMrmSalesByany
selectedYearnumber
viewByDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
allGroupsTotalSalesnumber
totalSalesAfterCommissionnumber
totalPercentageOfAchievedSalesnumber
totalDirectServicenumber
totalDirectSalesWithoutScrapnumber
totalDirectSalesWithScrapnumber
totalTotalDirectSalesWithScrapnumber
totalCommissionnumber
totalCumulativeSalesnumber
popupany

Where it refuses work

  • MrmTotalSalesComponent stops the work with an early return when a[propertyName] < b[propertyName], in 2 places.
  • MrmTotalSalesComponent stops the work with an early return when a[propertyName] > b[propertyName], in 2 places.
  • MrmTotalSalesComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).
  • MrmTotalSalesComponent stops the work with an early return when month.MonthId == 12.
  • MrmTotalSalesComponent stops the work with an early return when month[propertyName] < this.data[bIndex].MrmTotalSalesGroups[monthIndex - 1][propertyName].
  • MrmTotalSalesComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].

Diagram

mermaid
graph LR
  Lifecycle[Angular lifecycle] --> Init[ngOnInit / ngOnChanges]
  Init --> Subscription[checkFeatureSubscription]
  Subscription --> Data[getDashboardData]
  Data --> Initialize[initalizingData]
  Initialize --> Year[calculateSumByYear]
  Initialize --> Month[calculateSumByMonth]
  Year --> Format[getpriceFormatted]
  Month --> Translate[translateMonthName]
  Data --> Save[saveDashboardData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { MrmTotalSalesComponent } from './mrm-total-sales.component';

@Component({
  selector: 'app-dashboard-host',
  template: `
    <app-mrm-total-sales></app-mrm-total-sales>

    <button type="button" (click)="refreshSales()">
      Refresh sales data
    </button>
  `,
})
export class DashboardHostComponent {
  @ViewChild(MrmTotalSalesComponent)
  salesWidget!: MrmTotalSalesComponent;

  refreshSales(): void {
    if (this.salesWidget.checkFeatureSubscription()) {
      this.salesWidget.getDashboardData();
    }
  }
}

AI Coding Instructions

  • Keep subscription checks ahead of dashboard data requests when adding data-loading paths.
  • Preserve the existing initalizingData method name unless all callers are updated together.
  • Recalculate year and month totals after changing the source sales data.
  • Use translateMonthName and getpriceFormatted for display values instead of duplicating formatting logic.
  • Keep lifecycle-triggered loading compatible with both ngOnInit and ngOnChanges.

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