projects/maplander/components/src/lib/pipes/marker-price/marker-price.pipe.ts
Name | markerPrice |
transform |
transform(price: number, currency?: string)
|
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;
}
}