File

projects/maplander/components/src/lib/pipes/marker-price/marker-price.pipe.ts

Metadata

Name markerPrice

Methods

transform
transform(price: number, currency?: string)
Parameters :
Name Type Optional
price number No
currency string Yes
Returns : string
import {Pipe, PipeTransform} from '@angular/core';
import {ConstantsComponents} from '../../constantsComponents';
import {Utils} from '../../utils';

@Pipe({
  name: 'markerPrice'
})
export class MarkerPricePipe implements PipeTransform {

  transform(price: number, currency?: string): string {
    const locate: {locate: string, currency: string} = ConstantsComponents.LocateList[currency || 'MXN'];
    let outputPrice;
    if (((price / 100000.0) / 10.0) >= 1) {
      outputPrice = Utils.round(Number((price / 100000.0) / 10.0), 2);
      outputPrice = Number(outputPrice).toLocaleString(locate.locate, {
        style: 'currency',
        currency: locate.currency
      }).toString();
      outputPrice += 'M';
    } else if (((price / 100.0) / 10.0) >= 1) {
      outputPrice = Utils.round(Number((price / 100.0) / 10.0), 2);
      outputPrice = Number(outputPrice).toLocaleString(locate.locate, {
        style: 'currency',
        currency: locate.currency
      }).toString();
      outputPrice += 'K';
    } else {
      outputPrice = Number(price).toFixed(2);
      outputPrice = Number(outputPrice).toLocaleString(locate.locate, {
        style: 'currency',
        currency: locate.currency
      }).toString();
    }
    return '' + outputPrice;
  }


}

result-matching ""

    No results matching ""