All files / src/app/shared/components/basket/basket-cost-center-view basket-cost-center-view.component.ts

100% Statements 4/4
75% Branches 3/4
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 354x   4x                             4x   1x                              
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
 
import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper';
import { Basket } from 'ish-core/models/basket/basket.model';
import { CostCenter } from 'ish-core/models/cost-center/cost-center.model';
import { Order } from 'ish-core/models/order/order.model';
import { RecurringOrder } from 'ish-core/models/recurring-order/recurring-order.model';
 
/**
 * The Basket Cost Center View Component displays the cost center related information for a basket/order or recurring order
 *
 */
@Component({
  selector: 'ish-basket-cost-center-view',
  templateUrl: './basket-cost-center-view.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BasketCostCenterViewComponent {
  @Input({ required: true }) set data(val: Basket | Order | RecurringOrder) {
    this.costCenter = val?.costCenter
      ? {
          costCenterId: val.costCenter,
          name:
            AttributeHelper.getAttributeValueByAttributeName<string>(
              val.attributes,
              'BusinessObjectAttributes#Order_CostCenter_Name'
            ) || // fallback for RecurringOrder
            (val as RecurringOrder).costCenterName,
        }
      : undefined;
  }
 
  costCenter: Partial<CostCenter>;
}