5.95 dataformat for decimals (german) does not work

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 986
Joined: 2019-05-21 22:42
Location: Germany
Contact:

5.95 dataformat for decimals (german) does not work

Post by onoehring » 2021-04-20 13:50

Hi,

I have an application for the german language where numbers are written like this: 1.234,56 where "." is the thousands seperator and "," the decimal seperator. The number would equal 1234.34.
I have defined the field as decimal (10,2) and set the dataformat to (c:\Program Files (x86)\AppGini\add-ons\dataFormats.cfg)

Code: Select all

FORMAT(%%FIELD%%, 2, 'de_DE')
The data is displayed correct in table and detailview (when I entered data like 1234.56 directly in the database before) - but I am unable to enter the new data in the detailview. AG does not transform the entered data into the data expected by the database.
The error is like this:

Code: Select all

Incorrect decimal value: '28,25' for column 'einzelpreis' at row 1
The field in the insert query held the value `einzelpreis`='28,25',

I think this is a bug, as the user will try to input data as he is used to. German users would try to enter "1234,56" and the attempt to safe will fail.

Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1281
Joined: 2018-04-01 10:12

Re: 5.95 dataformat for decimals (german) does not work

Post by pböttcher » 2021-04-20 19:46

Hi Olaf,

I think that at this point AppGinit only converts the data from the database towards your definition for the output, not vice versa.
If you want to enable the user a german number you need to convert that number in the hook file to the correct db correspondant.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 986
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: 5.95 dataformat for decimals (german) does not work

Post by onoehring » 2021-04-21 06:42

Hi pbötcher,

thank you for your reply. I understand - but I really think the current behavior is misleading for the user - and the developer.
Your suggestion to transform the value in the hooks is good anyways. Jan suggested (by mail) some other solution. When I tested his solution, I will report back.

Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 986
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: 5.95 dataformat for decimals (german) does not work

Post by onoehring » 2021-04-21 07:43

Hi pbötcher,

your suggestion does work .. in a way.
When I add the following code to the _before_insert and _before_update hook functions the value is saved in the format the db expects: instead of 123,45 the value of 123.45 is recorded in the database.

Code: Select all

function ..._before_update(){
  $data('price']) = db_price($data('price']))
}

function ..._before_insert(){
  $data('price']) = db_price($data('price']))
}

// extra function
function db_price($price){
	$price= str_replace(",", ".", $price);
	$price= str_replace(" ", "", $price);
	return $price;
}
BUT: Immediately after saving in the display of the detailview the value is also displayed as "123.45" (and not according to the settings as 123,45).
When I switch back to tableview the value shoes up as 123,45 (with comma as decimal separator). Clicking into the details of the record the value also shows 123,45.

Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1281
Joined: 2018-04-01 10:12

Re: 5.95 dataformat for decimals (german) does not work

Post by pböttcher » 2021-04-21 20:18

Hi Olaf,

agree.

This should be handled in both (tableview and detailview). Unfortunately it is not. DV is taking the plain data from the database.

As a interims solution you could edit the templates/TABLENAME_templateDV.html file.

Look for the value="<%%VALUE(YOURFIELDNAME)%%>"

and change the type="text" to type="number" and add lang="de-DE"

With this setting you do not need to change the data in the before_insert / before_update hooks.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 986
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: 5.95 dataformat for decimals (german) does not work

Post by onoehring » 2021-04-22 12:05

Hi pbötcher,

thank you for your suggestion. Sounds good as an intermediate solution (until AG handles this correct).

Olaf

Post Reply