Skip to content

MrmDepreciationComponent

reference
2 min readUpdated

Kind: Class

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

Part of: Frontend

MrmDepreciationComponent manages depreciation data for a dashboard widget by initializing, retrieving, saving, and calculating totals by year or month. It also checks feature subscription access and prepares 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: 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
yearIdnumber
periodIdnumber
countOfEditablePrevMonthsnumber
withoutOptionBarboolean
editModeboolean
bookingOrSalesnumber
withNominalboolean
selectedTeamnumber
forecastRuleIdnumber
allowedtoEditboolean
allowedtoEnableEdtingboolean
widgetEditRequestany
widgetEditEndany
forecastRulesany[]
selectedYearnumber
numYearsDatasourceany[]
todayWidgetsEnumany
cachingWidgetDataCachingWidgetData
dataBranchData[]
originalDataBranchData[]
selectedDataBranchData[]
singleMonthsMonthData
branchCurrencyany
basedOnTendencyboolean
SeriseRangeany[]
echartsIntanceany
totalBookingMonthsMonthsSum[]
tempMonthSumMonthsSum
totalTargetsnumber
yearBookingnumber
totalForecastsnumber
tempTotalTargetTotalTargets
totalDepreciationAmountnumber
totalOthersnumber
totalTotalSGAndAnumber
totalFORXnumber
totalTotalnumber
totalCumulativenumber
totalPercentageUsedBudgetnumber
popupany
searchTextstring
pastDiffnumber
urrenFeaturenumber

Where it refuses work

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

Diagram

mermaid
graph LR
    Lifecycle[Angular lifecycle] --> Init[ngOnInit]
    Lifecycle --> Changes[ngOnChanges]
    Init --> Subscription[checkFeatureSubscription]
    Subscription --> Load[getDashboardData]
    Load --> Initialize[initalizingData]
    Initialize --> YearSum[calculateSumByYear]
    Initialize --> MonthSum[calculateSumByMonth]
    Initialize --> Save[saveDashboardData]
    YearSum --> Display[getpriceFormatted]
    MonthSum --> MonthLabel[translateMonthName]
    MonthLabel --> Display

Usage

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

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

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

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

  it('loads and formats depreciation dashboard data', () => {
    fixture.detectChanges();

    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

  • Keep data loading and initialization aligned with ngOnInit and ngOnChanges.
  • Check checkFeatureSubscription() before showing or requesting depreciation dashboard data.
  • Run calculateSumByYear() and calculateSumByMonth() only after the required dashboard data is initialized.
  • Use translateMonthName() and getpriceFormatted() for widget display values instead of formatting those values in templates.
  • Save changes through saveDashboardData() after updating the component’s depreciation state.

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