Skip to content

MrmDepreciationComponent

reference
2 min readUpdated

Kind: Class

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

Part of: Pams

MrmDepreciationComponent is an Angular dashboard widget that checks authorization, loads and saves dashboard data, and calculates depreciation totals by year and month. It responds to initialization and change events, translates month names for display, and releases resources during destruction.

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
totalDepreciationAmountnumber
totalOthersnumber
totalTotalSGAndAnumber
totalFORXnumber
totalTotalnumber
totalCumulativenumber
totalPercentageUsedBudgetnumber
popupany
searchTextstring

Where it refuses work

  • MrmDepreciationComponent stops the work with an early return when month.MonthId == 12.
  • MrmDepreciationComponent stops the work with an early return when month[propertyName] < this.data[bIndex - 1][propertyName].
  • MrmDepreciationComponent stops the work with an early return when month[propertyName] < this.totalBookingMonths[index - 1][propertyName].
  • MrmDepreciationComponent stops the work with an early return when this.allowedtoEnableEdting.
  • MrmDepreciationComponent 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]
    C --> E[getDashboardData]
    E --> F[initalizingData]
    F --> G[calculateSumByYear]
    F --> H[calculateSumByMonth]
    H --> I[translateMonthName]
    F --> J[saveDashboardData]
    D --> E
    A --> K[ngOnDestroy]

Usage

ts
import { TestBed } from '@angular/core/testing';
import { MrmDepreciationComponent } from './mrm-depreciation.component';

describe('MrmDepreciationComponent', () => {
  it('loads and calculates dashboard depreciation data', async () => {
    await TestBed.configureTestingModule({
      declarations: [MrmDepreciationComponent],
    }).compileComponents();

    const fixture = TestBed.createComponent(MrmDepreciationComponent);
    fixture.detectChanges();

    const widget = fixture.componentInstance;

    widget.getDashboardData();
    widget.calculateSumByYear();
    widget.calculateSumByMonth();

    fixture.destroy();
  });
});

AI Coding Instructions

  • Let Angular invoke ngOnInit, ngOnChanges, and ngOnDestroy; do not call lifecycle methods from production feature code.
  • Run authorization checks through GetAuthorizationAccess() before exposing or saving dashboard data.
  • Keep data preparation in initalizingData() and keep yearly and monthly aggregation logic in their respective calculation methods.
  • Preserve the month-label conversion path through translateMonthName() when adding chart labels or date-based display values.
  • Release subscriptions, timers, or other retained resources from ngOnDestroy().

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