commit 08-2025
This commit is contained in:
parent
9ae662f63e
commit
480fdc65ed
404 changed files with 65310 additions and 2600431 deletions
|
|
@ -119,11 +119,9 @@ class ShoppingCollectOrder extends Model
|
|||
{
|
||||
$tax_split = $this->tax_split;
|
||||
$add_tax = round($add_tax, 2);
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ? round($tax_split[$tax_rate] += $add_tax, 2) : $add_tax;
|
||||
|
||||
foreach((array)$tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
$existing_value = isset($tax_split[$tax_rate]) ? $this->parseNumericValue($tax_split[$tax_rate]) : 0;
|
||||
$tax_split[$tax_rate] = round($existing_value + $add_tax, 2);
|
||||
|
||||
$this->tax_split = $tax_split;
|
||||
}
|
||||
|
||||
|
|
@ -131,14 +129,43 @@ class ShoppingCollectOrder extends Model
|
|||
{
|
||||
$net_split = $this->net_split;
|
||||
$add_net = round($add_net, 2);
|
||||
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ? round($net_split[$tax_rate] += $add_net, 2) : $add_net;
|
||||
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key] = number_format($value, 2);
|
||||
}
|
||||
$existing_value = isset($net_split[$tax_rate]) ? $this->parseNumericValue($net_split[$tax_rate]) : 0;
|
||||
$net_split[$tax_rate] = round($existing_value + $add_net, 2);
|
||||
|
||||
$this->net_split = $net_split;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parst verschiedene Zahlenformate zu einem float-Wert
|
||||
* Unterstützt: 19.50, 1234.56, 1.234,56, 1,234.56
|
||||
*/
|
||||
private function parseNumericValue($value)
|
||||
{
|
||||
// Bereits eine Zahl? Direkt zurückgeben
|
||||
if (is_numeric($value)) {
|
||||
return (float)$value;
|
||||
}
|
||||
|
||||
// String zu String konvertieren für weitere Verarbeitung
|
||||
$value = (string)$value;
|
||||
|
||||
// Entferne Leerzeichen
|
||||
$value = trim($value);
|
||||
|
||||
// Prüfe verschiedene Formate
|
||||
if (preg_match('/^-?\d{1,3}(\.\d{3})*,\d{2}$/', $value)) {
|
||||
// Deutsches Format: 1.234,56 oder 1.234.567,89
|
||||
return (float)str_replace(',', '.', str_replace('.', '', $value));
|
||||
} elseif (preg_match('/^-?\d{1,3}(,\d{3})*\.\d{2}$/', $value)) {
|
||||
// Amerikanisches Format: 1,234.56 oder 1,234,567.89
|
||||
return (float)str_replace(',', '', $value);
|
||||
} else {
|
||||
// Einfaches Format: 19.50, 123.45, etc.
|
||||
// Nur Kommas durch Punkte ersetzen
|
||||
return (float)str_replace(',', '.', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function addShopItem($shop_item_id, $shop_item)
|
||||
{
|
||||
$numberFields = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue