beanquery icon indicating copy to clipboard operation
beanquery copied to clipboard

ROUND() function?

Open alensiljak opened this issue 6 months ago • 0 comments
trafficstars

Hi!

select account, CONVERT(sum(position), 'EUR')

will result in

[('Assets:Checking', (353.7500000000000000000000000 EUR)),
 ('Assets:Savings', (166.6666666666666666666666667 EUR)),
 ('Expenses:Groceries', (62.91666666666666666666666666 EUR)),
 ('Expenses:Rent', (666.6666666666666666666666666 EUR)),
 ('Income:Salary', (-1250.000000000000000000000000 EUR))]

Is there a way to limit this to specific N decimals? I know this is for presentation mainly. But also when outputting amounts via an API, I would prefer to be able to limit the decimal spaces at the source.

Regular balances will show like

[('Assets:Checking', (424.50 USD)),
 ('Assets:Old-Account', (-2 EUR)),
 ('Assets:Savings', (200.00 USD)),
 ('Income:Salary', (-1500.00 USD)),
 ('Expenses:Groceries', (75.50 USD, 2 EUR)),
 ('Expenses:Rent', (800.00 USD))]

or, rather, they will not have any decimal spaces for round amounts in EUR. Not sure where exactly this is coming from but it's ok. At least it is consistent. However, after CONVERT(), the amounts have full decimal spaces, even when 0.

Perhaps introducing ROUND() function would be useful for these cases.

alensiljak avatar May 13 '25 20:05 alensiljak