import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'bookPrice',
})
export class BookPricePipe implements PipeTransform {
  transform(value: number, quantity: number = 1): string {
    if (!!value) {
      const formatedPrice = (+Math.round(value * 100 * quantity) / 100).toFixed(2);
      return formatedPrice.toLocaleString().replace('.', ',');
    } else {
      return '';
    }
  }
}
