# Using functions e.g. round in GnuCash Scheduled Transaction

I use scheduled transactions in GnuCash and it works, even with user input. What I am missing, that when I enter a user input for a scheduled transaction and use this value in a calculation then I would like to have the result rounded to .05 values. For example I have a scheduled transaction for the salary and taxes, I can enter some value for additional income like tip, then I add the tip to the normal fix salary and then I calculate the tax based on these two. The result is calculated for two decimal places e.g. 10.63 but in the reality I need to round this value to 10.65. I use a formula in the Scheduled Transaction similar like this:

`(1234+tip)*0.011`

What I would need is something like this:

`round((1234+tip)*0.011)`

How can it be solved in GnuCash Scheduled Transaction editor?

If I understand your situation correctly, you are using the scheduler to produce template transactions in the register, then manually updating the amounts to reflect the actual specifics (tips and so on) before recording the updated transaction to the register. The problem is how to efficiently calculate the updated amounts before saving the transaction.

One of the GnuCash Tips of the Day says:

As you enter amounts in the register, you can use the GnuCash calculator to add, subtract, multiply and divide. Simply type the first value, then select '+', '-','*', or '/'. Type the second value and press Enter to record the calculated amount.

As you have discovered, you can group operands together using brackets as well as using the 4 basic arithmetic operators. However, I don't think that GnuCash allows for higher mathematics in the register. I think that GnuCash is intended as a coordinated system to store transactions created with input by the user or transactions imported using the Import wizards. With some exceptions (eg. the Loan Repayment Calculator), GnuCash isn't intended to perform complex calculations, it's meant to store your numbers.

Given the limited functionality available in the data entry fields of the account register, I can't offer you an elegant solution where GnuCash does all of the work. I can, however, suggest 3 workarounds:

1. You can eyeball the result of the calculation that Gnucash performs based on the limited formula that you can enter into the amount fields of the register. If the calculated result is 10.63, but you know that the taxation authority requires the amount rounded to a multiple of 5 cents, you can just manually overtype the calculated result with your own figure (10.65). You will probably need to correct an imbalance split as well. (You are probably already doing this.)

2. You could use an external spreadsheet program to perform all of the rounding and other mathematical functions required, to the point where the spreadsheet finalises the numbers in the correct format. You then either (a) manually transcribe those spreadsheet-calculated figures into your template transaction, or (b) save the worksheet as CSV data and import it into GnuCash as a complete transaction.

3. If you really, really want GnuCash to do all of the calculations, you can effectively force it to produce a number rounded to the nearest 5 cents by

a. enter your formula into the register AND DIVIDE BY FIVE; eg `(1234+tip)*0.011/5`

b. press ENTER or TAB to force GnuCash to calculate a RESULT rounded to the nearest cent

c. go back to the previous field and without over-writing multiply RESULT by 5

d. press ENTER or TAB to force GnuCash to calculate the answer to your original calculation, rounded to the nearest 5 cents.

Remember, I warned you up front that this was not going to be an elegant solution!