UNPKG

ngx-swiss-five-rappen-chf-pipe

Version:
24 lines (18 loc) 501 B
import { Pipe, PipeTransform } from '@angular/core'; /* This is an Angular pipe for roudning of CHF decimal currency as per the rules defined in README. Author: Balram Chavan (ultrasonicsoft) */ @Pipe({ name: 'ngxSwissFiveRappenChf', pure: false }) export class NgxSwissFiveRappenChfPipe implements PipeTransform { transform(value: number): number { if (value) { const result = (Math.round(value * 20) / 20).toFixed(2); return parseFloat(result); } return 0; } }