@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
34 lines (33 loc) • 1.25 kB
TypeScript
import { Currency, CurrencyCode } from './Currency';
import { Big } from 'big.js';
export type CurrencySource = string | CurrencyCode | Currency;
export declare class Money {
private readonly _amount;
private readonly _currency;
private constructor();
get amount(): Big;
get currency(): Currency;
static of(amount: number | string | Big, currency: CurrencySource): Money;
static USD(amount: number | string | Big): Money;
toNumber(): number;
/**
* Rounds the amount down to match the currency's defined scale.
* This method could be used when converting an amount to its final monetary value.
*
* @returns {Money} A new Money instance with the amount rounded down to the currency's scale.
*/
roundToCurrencyScale(): Money;
multiply(multiplier: number | string | Big): Money;
add(money: Money): Money;
subtract(money: Money): Money;
equals(money: Money): boolean;
greaterThan(money: Money): boolean;
greaterThanOrEqual(money: Money): boolean;
lessThan(money: Money): boolean;
lessThanOrEqual(money: Money): boolean;
isZero(): boolean;
isPositive(): boolean;
isNegative(): boolean;
private withAmount;
private requireSameCurrency;
}