# MrmBookingProductTypesComponent

**Kind:** Class

**Source:** `Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/mrm-booking-product-types/mrm-booking-product-types.component.ts` (line 45)

**Part of:** [Pams](subsystem-pams)

`MrmBookingProductTypesComponent` is an Angular dashboard widget that loads and presents booking product-type data. It manages initialization, data refreshes, resize handling, cached state, and display helpers for performance, month names, and formatted prices.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `ngOnInit` | `ngOnInit()` | `void` |
| `ngOnChanges` | `ngOnChanges()` | `void` |
| `ngOnDestroy` | `ngOnDestroy()` | `void` |
| `getDashboardData` | `getDashboardData()` | `void` |
| `initalizingData` | `initalizingData(value: BranchData[])` | `void` |
| `calculatePerformancePer` | `calculatePerformancePer(month: MonthData)` | `number` |
| `translateMonthName` | `translateMonthName(month: MonthData)` | `string` |
| `getpriceFormatted` | `getpriceFormatted(x: undefined)` | `string` |
| `onResize` | `onResize()` | `void` |
| `setChaching` | `setChaching()` | `void` |
| `getChaching` | `getChaching()` | `void` |
| `onValueChanged` | `onValueChanged(e: undefined)` | `void` |
| `onChartInit` | `onChartInit(e: any, index: number)` | `void` |
| `switchChartTypeHandler` | `switchChartTypeHandler()` | `void` |
| `switchBasedOnTendencyHandler` | `switchBasedOnTendencyHandler()` | `void` |
| `comparingWithPrevMonth` | `comparingWithPrevMonth(month: MonthData, bIndex: number, index: number)` | `string` |
| `comparingBookingWithPrevSumm` | `comparingBookingWithPrevSumm(month: TotalBookingMonths, index: number)` | `string` |
| `comparingForecastWithPrevSumm` | `comparingForecastWithPrevSumm(month: TotalBookingMonths, index: number)` | `string` |
| `setValue` | `setValue(value: number)` | `void` |
| `setForecastValue` | `setForecastValue(value: number)` | `void` |
| `setMarginAvarage` | `setMarginAvarage(value: number)` | `void` |
| `isForecast` | `isForecast(month: MonthData)` | `boolean` |
| `isAchievedOrCurrent` | `isAchievedOrCurrent(month: MonthData)` | `boolean` |
| `getpriceForecastAmount` | `getpriceForecastAmount(month: MonthData)` | `number` |
| `expectedCurrencyChange` | `expectedCurrencyChange(e: undefined)` | `void` |
| `sorting` | `sorting(propertyName: string, propertyType: string, monthIndex: number)` | `void` |

## Properties

| Property | Type |
|---|---|
| `_widget` | `Widget` |
| `_widgetType` | `string` |
| `withoutOptionBar` | `boolean` |
| `bookingOrSales` | `number` |
| `withNominal` | `boolean` |
| `selectedTeam` | `number` |
| `forecastRuleId` | `number` |
| `allowedtoEdit` | `boolean` |
| `allowedtoEnableEdting` | `boolean` |
| `forecastRules` | `any[]` |
| `selectedYear` | `number` |
| `numYearsDatasource` | `any[]` |
| `todayWidgetsEnum` | `any` |
| `cachingWidgetData` | `CachingWidgetData` |
| `data` | `BranchData[]` |
| `originalData` | `BranchData[]` |
| `singleMonths` | `MonthData` |
| `branchCurrency` | `any` |
| `basedOnTendency` | `boolean` |
| `subscription` | `Subscription` |
| `SeriseRange` | `any[]` |
| `echartsIntance` | `any` |
| `totalBookingMonths` | `TotalBookingMonths[]` |
| `tempTotalMonth` | `TotalBookingMonths` |
| `totalTargets` | `number` |
| `yearBooking` | `number` |
| `totalForecasts` | `number` |
| `tempTotalTarget` | `TotalTargets` |
| `sortingDirection` | `number` |

## Where it refuses work

- `MrmBookingProductTypesComponent` stops the work with an early return when `a[propertyName] < b[propertyName]`, in 2 places.
- `MrmBookingProductTypesComponent` stops the work with an early return when `a[propertyName] > b[propertyName]`, in 2 places.
- `MrmBookingProductTypesComponent` stops the work with an early return when `month.MonthId == 12`.
- `MrmBookingProductTypesComponent` stops the work with an early return when `month.TotalValue < this.data[bIndex].MrmBooking[index - 1].TotalValue`.
- `MrmBookingProductTypesComponent` stops the work with an early return when `month.TotalBookingMonth < this.totalBookingMonths[index - 1].TotalBookingMonth`.
- `MrmBookingProductTypesComponent` stops the work with an early return when `month.TotalForecastMonth < this.totalBookingMonths[index - 1].TotalForecastMonth`.

## Diagram

```mermaid
graph LR
  Dashboard[Dashboard container] --> Component[MrmBookingProductTypesComponent]

  Component --> Init[ngOnInit]
  Component --> Changes[ngOnChanges]
  Component --> Destroy[ngOnDestroy]

  Init --> Data[getDashboardData]
  Changes --> Data
  Data --> Initialize[initalizingData]
  Initialize --> Cache[setChaching]

  Component --> Performance[calculatePerformancePer]
  Component --> Month[translateMonthName]
  Component --> Price[getpriceFormatted]
  Component --> Resize[onResize]
```

## Usage

```ts
import { Component, ViewChild } from '@angular/core';
import { MrmBookingProductTypesComponent } from
  './widgets/mrm-booking-product-types/mrm-booking-product-types.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <!-- Render the widget according to its configured selector and inputs. -->
    <app-mrm-booking-product-types></app-mrm-booking-product-types>

    <button type="button" (click)="refreshProductTypes()">
      Refresh product types
    </button>
  `
})
export class DashboardPageComponent {
  @ViewChild(MrmBookingProductTypesComponent)
  productTypesWidget?: MrmBookingProductTypesComponent;

  refreshProductTypes(): void {
    this.productTypesWidget?.getDashboardData();
  }

  get performanceLabel(): string {
    return `${this.productTypesWidget?.calculatePerformancePer() ?? 0}%`;
  }
}
```

## AI Coding Instructions

- Keep data loading inside `getDashboardData()` and let Angular lifecycle hooks trigger refreshes when component state changes.
- Preserve the existing `initalizingData()` method name when calling or modifying it, even though its spelling differs from `initializing`.
- Release subscriptions, listeners, and resize-related resources from `ngOnDestroy()`.
- Keep `calculatePerformancePer()`, `translateMonthName()`, and `getpriceFormatted()` focused on display formatting rather than data retrieval.
- Update cached values through `setChaching()` when changing the widget data flow.

## 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)

- `TranslateHandler` — `Pams/Web/Pams.Web/Client/app/app.module.ts`:1
