import { Money } from "bigint-money" ; import { NumberFormatter } from "../NumberFormatter" ; import { Fee } from "./Fee" ; export class VolumeFee implements Fee { constructor ( private volumes ) { } public calculateFor ( amount ) { for ( let volume of this . volumes ) { if ( volume . max === null ) { return volume . fee . calculateFor ( amount ) ; } if ( amount . isLesserThanOrEqual ( volume . max ) ) { return volume . fee . calculateFor ( amount ) ; } } } public describe ( ) { return '' ; } public getExtendedDescription ( ) { const numberFormatter = new NumberFormatter ( ) ; return this . volumes . map ( ( volume ) : string => { if ( volume . max === null ) { return 'daarboven: ' + volume . fee . describe ( ) ; } return 't/m ' + numberFormatter . formatMoney ( volume . max , 0 ) + ': ' + volume . fee . describe ( ) ; } ) ; } } export class Volume { constructor ( public max , public fee ) { } }