Unable to log decimals with Tasks

Hello all,

I am unable to log monetary (decimal numbers) value using task. For example, I can log 995 but if a decimal is typed for example 995,35 or 995.35 SambaPos writes NULL value in SQL.

Do you know if is possible to log decimals? or am I doing something wrong?

If you add what it is your tying to achieve it might help with offering sugestions?

Yes it is possible.

I am logging Cashout values (Counts and Money) in Task Custom Fields without issue, though I do it through JScript and GraphQL.

How is the Custom field defined? String or Number?

How are you adding/updating the Task?

The field is set as Number, and the task is added using your tutorial “Method 2: Log using Tasks”. Thanks!

I was able to log the information but only by changing Windows regional setting from Spanish to English, this causes the replacement of the comma for the dot as decimal separator affecting my reports and accounts.

I need to be able to use Spanish regional settings which uses the comma as separator for decimal.

So is this a thing of SambaPos using the comma to separate custom data, or is it standard for SQL server to use dot (.) as decimal separator?

Thanks to anyone who can help!

Does it work if ou set as string rather than number?
Pure number in JSON is unquoted, so perhaps the comma is messing up the json formatting.
You might need to ‘parse’/replace it in some way.
I has similar issue with entity custom data which is stored in json too, mine senario was double quotes and I have to replace on insert and than revers on read.

Neither really. It is a standard of JSON data to use comma to separate elements. So your comma decimal separator is probably breaking the JSON when SambaPOS tries to insert the record.

Try what @JTRTech suggested: set the Custom Field to be a String instead of a Number. That might work.

If it still doesn’t work, you will probably need to escape the comma in the Rule. Best to post a screenshot of your Rule so we can see what you are doing.

But it might look something like this:

Conteo Final=[='{TICKET TOTAL}'.replace(/,/g,'\\,')]

@QMcKay, what you suggested worked for my setup. Thanks!

And how is it that you know or how can I learn things like: .replace(/,/g,’\,’) ?

.replace() is a Javascript method. So if you read about and learn Javascript, then you will know how to use a lot of functions in SambaPOS because it uses a JScript engine for things like that.

1 Like