import { Money } from "bigint-money" ; export class Percentage { constructor ( private percentage ) { } public static createFromFraction ( fraction ) { return new Percentage ( fraction * 100 ) ; } public getPercentage ( ) { return this . percentage ; } public getFraction ( ) { return this . percentage / 100 ; } public add ( other ) { return new Percentage ( this . percentage + other . percentage ) ; } public subtract ( other ) { return new Percentage ( this . percentage - other . percentage ) ; } public multiply ( other ) { return new Percentage ( ( this . percentage * other . percentage ) / 100 ) ; } public applyTo ( amount ) { return amount . multiply ( this . getFraction ( ) . toString ( ) ) ; } public equals ( other ) { return this . percentage === other . percentage ; } }