ngx-swiss-five-rappen-chf-pipe
Version:
This pipe provides the Swiss 5 Rappen CHF rounding functionality.
24 lines (18 loc) • 501 B
text/typescript
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)
*/
({
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;
}
}