All files / projects/requisition-management/src/app/pages/requisition-detail/requisition-summary requisition-summary.component.ts

100% Statements 8/8
83.33% Branches 5/6
100% Functions 3/3
100% Lines 8/8

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 342x   2x   2x             2x   4x           4x         4x       4x          
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
 
import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper';
 
import { Requisition, RequisitionViewer } from '../../../models/requisition/requisition.model';
 
@Component({
  selector: 'ish-requisition-summary',
  templateUrl: './requisition-summary.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RequisitionSummaryComponent implements OnInit {
  @Input({ required: true }) requisition: Requisition;
  @Input() view: RequisitionViewer = 'buyer';
 
  costCenterName: string;
  customerApproverCount: number;
 
  ngOnInit() {
    this.costCenterName = AttributeHelper.getAttributeValueByAttributeName(
      this.requisition?.attributes,
      'BusinessObjectAttributes#Order_CostCenter_Name'
    );
 
    this.customerApproverCount = this.getCustomerApproverCount();
  }
 
  private getCustomerApproverCount() {
    return this.requisition?.approval?.statusCode === 'PENDING'
      ? this.requisition?.approval?.customerApproval.approvers?.length || 1
      : this.requisition?.approval?.approvers?.length || 1;
  }
}