My civicrm instance has been running for a few years now. Since a couple of weeks ago I cannot add contributions anymore if their total amount contains decimal points. Due to my German locales I use the comma characters as a decimal delimiter.
Adding a contribution of 20,00 Euros works fine.
Adding a contribution of 20,99 Euros does not work.
When adding contributions over the standard civi frontend
If a add a contribution of 20,99 over the standard gui and click "save", then the hourglass appears and will never disappear. Nothing else happens. Nothing gets written to the db and no php or javascript errors get reported.
When adding contributions over API v3
My API Call (PHP Style):
$result = civicrm_api3('Contribution', 'create', [
'financial_type_id' => "Spende",
'receive_date' => "2022-03-20",
'total_amount' => "20,99",
'contact_id' => 399,
]);
After exection an error message appears: "DB Error: value count on row". Nothing is written to the database. The underlying sql:
INSERT INTO `civicrm_contribution` (`contact_id` , `financial_type_id` , `payment_instrument_id` ,
`receive_date` , `total_amount` , `fee_amount` , `net_amount` ,
`currency` , `contribution_status_id` , `check_number` , `tax_amount` )
VALUES ( 399 , 1 , 5 , 20220320000000 , 20.99 , 0 , 20,99 , 'EUR' , 1 ,
NULL , 0 );
The SQL error is fairly obvious: the value of net_amount is basically a copy of total_amount. But while total_amount has been correctly formatted to "20.99" in the sql, the value of net_amount has been formatted as "20,99", so the comma is interpreted as an sql value delimiter. But why is a wrong formatting used?
When adding contributions over API v4
The call
$results = civicrm_api4('Contribution', 'create', [
'values' => [
'contact_id' => 399,
'financial_type_id' => 1,
'receive_date' => '2022-03-01',
'total_amount' => '20,99',
],
]);
results in a warning: "Formatting non-numeric values is no longer supported: 20,99 Caller: CRM_Utils_Money::format". The contribution is written to the db - but as "20.00", so the 99 Cents are missing.
Localization and system setup
- CiviCrm 5.47.2
as a wordpress plugin
Formatting locale: Deutsch (German)
Thousands Separator: .
Decimal Delimiter: , - Plugin for Wordpress 5.8.3
language: German - Php 7.4
- Nginx 1.14
- ubuntu 18.04
set to de_DE.UTF-8
Any advice on how to fix this would be greatly appreciated!