import { getDateStr } from './misc' ; export function evaluateArithmeticExpression ( expression ) { return Number ( eval ( expression ) ) ; } export class Balance { date : Date ; account : string ; amount : number ; commodity : string ; constructor ( options ) { this . date = new Date ( options . date ) ; this . account = options . account ; this . amount = evaluateArithmeticExpression ( options . amount ) ; this . commodity = options . commodity ; } toBeancount ( ) { const dateStr = getDateStr ( this . date ) ; return `${ dateStr } balance ${ this . account } ${ this . amount } ${ this . commodity }\n` ; } }