Set currency exchange rate in Navigation screen

I’m facing with the same problem when at my restaurant set dollar as primary currency and second currency is riel. So the exchange rate have to be 0.00025. In V5, I just manage it to work today by changing ExchangeRate data type to decimal(16, 5) in table ForeignCurrencies and update data direct in table. It does not work if you update data from Edit Foreign Currency Screen it take only 4 decimal point. I don’t think this the correct way to configure but at lease it solve my first step problem. The next problem is the currency exchange rate alway change. we alway update it twice a day.

So, Is there any way to allow cashier update it in navigation screen? and Does this change will affect to samba pos or not?

There is no way to allow for programmatic change of the Exchange Rate in SambaPOS. That is to say, there is no Action we can use to do this natively.

At this time, the only way to accomplish this would be to use some SQL (and maybe JS) that is triggered to update the DB directly, via an Automation Command/Ask Question, or automatically via website query.

@proeftuin even managed to automate this by pulling data from a website daily…

I read this article a lot of time, I can not follow it because, first, there is no Khmer currency exchange rate in JSON result. The way we work here in cambodia is getting exchange rate from government and the government does not have such web service or api like fixer.io to access it. Plus, the owner need update manually, even if there is a way to do it automatically(This sound stupid).

what is I need is too simple, add button in Navigation screen, when user hit on it pop up input box and user click ok save it to system.

I will follow your suggestion by using Automation Command/Ask Question and sql, jscript this evening.
Thank for point me out something.

Hi @QMcKay,

Yes, your suggestion is work perfect for update currency exchange in navigation screen. However, it does not show current rate in the tile button in navigation screen. I use Jscript to get current rate and call it in automation commands button template. bellow are screen shot of jscript and button template that I configure. And also, are there any way to get rate without using script.

command button template

JScript

Use Printer Tag {EXCHANGE RATE:X}. Where X is the Name of the Foreign Currency. For example:

{EXCHANGE RATE:USD}

Above does not seem to work outside of a Ticket.


This works…

Handler: xr
Script:

function getXR() {
  var qry = "SELECT ExchangeRate FROM ForeignCurrencies WHERE Id=1";
  var xr = sql.Query(qry).First;
  return '<size 30><color White>' + xr + '</color></size>';
}

Then in Tile:
{CALL:xr.getXR()}

You could of course remove the formatting tags from the JS and put them in the Tile instead…

Script:

function getXR(FC) {
  var qry = "SELECT ExchangeRate FROM ForeignCurrencies WHERE Name='"+FC+"'";
  var xr = sql.Query(qry).First;
  return xr;
}

Tile:
<size 30><color White>{CALL:xr.getXR('USD')}</color></size>

1 Like

Hi @QMcKay,

It still can not display it in my Tile button. I follow your script every thing by copy and past but still not work. I re-check everything but I don’t know what I miss out. If you don’t mind please have a look again with my automation command setup.

Thanks in advance.
Pheakdey

Show screen shot of the script. Did you defined handler name as xr?

Here it is. This is my first time ever for getting into script.

Name it as something more clear for yourself and move xr to handler.

Hi @emre

I did change it and Yes it works. Thank you very much for helping me.

Just so you know, the Name is arbitrary. The Handler is important, and mandatory.

##ExchangeRate [xr] (Script)##

Script Name: ExchangeRate
Script Handler: xr

Script:

function getXR(FC) {
  var qry = "SELECT ExchangeRate FROM ForeignCurrencies WHERE Name='"+FC+"'";
  var xr = sql.Query(qry).First;
  return xr;
}

{CALL:handler.function(parameters)}

{CALL:xr.getXR('USD')}

Yes sure, I just know about this and how it work. your clear explain here is very informative for me and other newbie. I just have 1 more small issue when I change the rate it does not immediately change in the Tile button. but I think it ok, I can do manual refresh screen.

I was trying to make this… and i figure it out why it didnt work to pheakdey_micronet
The thing is the name has a space and that seems to be the problem.
I decide to write so if someone has the same problem it could fix it easily.
Regards,