initial commit

This commit is contained in:
Patrick Nagurny
2018-10-19 11:28:08 -04:00
commit 5ff09d328d
139 changed files with 23448 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { Pipe, PipeTransform } from '@angular/core';
import { DecimalPipe } from '@angular/common';
@Pipe({name: 'currencyFormat'})
export class CurrencyFormatPipe implements PipeTransform {
constructor(private decimalPipe: DecimalPipe) {
}
transform(amount: number, precision: number, currency = 'USD'): string {
if(amount === null || amount === undefined) {
return '';
}
let prefix = amount < 0 ? '-' : '';
if(currency === 'USD') {
prefix += '$';
}
let minDigits = Math.min(2, precision);
return prefix +
this.decimalPipe.transform(
Math.abs(amount) / Math.pow(10, precision),
'1.' + minDigits + '-' + precision);
}
}