Warenwirtschaft: N-6 — Punkt mit 1-2 Nachkommastellen = Dezimaltrenner (Kundenentscheid 15.07.2026)
Neuer Helper reFormatWawiNumber(): '5.1'/'5.12' werden als 5,1/5,12 gelesen (kommt beim Kopieren von Daten vor); '1.500' bleibt Tausender. Gilt nur für die WaWi-Eingaben (Mengen, Preise, Gewichte, Rezeptur) — reFormatNumber() app-weit unverändert. JS-Parser (parseGerman, parseDeNumber) auf dieselbe Regel vereinheitlicht; parseDeNumber behandelte '1.500' bisher sogar als 1,5. Tests: +1 (Parsing-Matrix). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
9b6c9def97
commit
016e8bbbd8
11 changed files with 60 additions and 31 deletions
|
|
@ -29,7 +29,7 @@ class ReceiveStockEntryRequest extends FormRequest
|
|||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'received_quantity' => reFormatNumber($this->input('received_quantity')),
|
||||
'received_quantity' => reFormatWawiNumber($this->input('received_quantity')),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class StorePackagingItemRequest extends FormRequest
|
|||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
'category' => trim((string) $this->input('category')),
|
||||
'weight_grams' => $this->filled('weight_grams') ? reFormatNumber($this->input('weight_grams')) : null,
|
||||
'weight_grams' => $this->filled('weight_grams') ? reFormatWawiNumber($this->input('weight_grams')) : null,
|
||||
]);
|
||||
|
||||
foreach (['supplier_id', 'product_id', 'min_stock_alert'] as $key) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class StoreProductionRequest extends FormRequest
|
|||
// Audit H-2: Vorzeichen-/Zahlprüfung — negative Zeilen konnten sich
|
||||
// in der Summenprüfung gegenseitig aufheben und Bestand aufblähen.
|
||||
'ingredient_lines.*.quantity_used' => ['required', 'string', function (string $attribute, mixed $value, \Closure $fail) {
|
||||
$n = reFormatNumber((string) $value);
|
||||
$n = reFormatWawiNumber((string) $value);
|
||||
if (! is_numeric($n) || (float) $n <= 0) {
|
||||
$fail(__('Die Menge je Chargen-Zeile muss größer als 0 sein.'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class StoreStockDisposalRequest extends FormRequest
|
|||
}
|
||||
|
||||
$this->merge([
|
||||
'quantity' => reFormatNumber($this->input('quantity')),
|
||||
'quantity' => reFormatWawiNumber($this->input('quantity')),
|
||||
'disposed_at' => $disposedAt,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ class StoreStockEntryRequest extends FormRequest
|
|||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'ordered_quantity' => reFormatNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatNumber($this->input('price_per_kg')) : null,
|
||||
'price_per_kg_gross' => $this->filled('price_per_kg_gross') ? reFormatNumber($this->input('price_per_kg_gross')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatNumber($this->input('price_total')) : null,
|
||||
'ordered_quantity' => reFormatWawiNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatWawiNumber($this->input('price_per_kg')) : null,
|
||||
'price_per_kg_gross' => $this->filled('price_per_kg_gross') ? reFormatWawiNumber($this->input('price_per_kg_gross')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatWawiNumber($this->input('price_total')) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class UpdatePackagingItemRequest extends FormRequest
|
|||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
'category' => trim((string) $this->input('category')),
|
||||
'weight_grams' => $this->filled('weight_grams') ? reFormatNumber($this->input('weight_grams')) : null,
|
||||
'weight_grams' => $this->filled('weight_grams') ? reFormatWawiNumber($this->input('weight_grams')) : null,
|
||||
]);
|
||||
|
||||
foreach (['supplier_id', 'product_id', 'min_stock_alert'] as $key) {
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ class UpdateStockEntryRequest extends FormRequest
|
|||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'ordered_quantity' => reFormatNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatNumber($this->input('price_per_kg')) : null,
|
||||
'price_per_kg_gross' => $this->filled('price_per_kg_gross') ? reFormatNumber($this->input('price_per_kg_gross')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatNumber($this->input('price_total')) : null,
|
||||
'ordered_quantity' => reFormatWawiNumber($this->input('ordered_quantity')),
|
||||
'price_per_kg' => $this->filled('price_per_kg') ? reFormatWawiNumber($this->input('price_per_kg')) : null,
|
||||
'price_per_kg_gross' => $this->filled('price_per_kg_gross') ? reFormatWawiNumber($this->input('price_per_kg_gross')) : null,
|
||||
'price_total' => $this->filled('price_total') ? reFormatWawiNumber($this->input('price_total')) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ class ProductRepository extends BaseRepository
|
|||
if (is_numeric($value)) {
|
||||
return (float) $value;
|
||||
}
|
||||
$normalized = reFormatNumber((string) $value);
|
||||
$normalized = reFormatWawiNumber((string) $value);
|
||||
|
||||
return $normalized !== null && $normalized !== '' ? (float) $normalized : null;
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ class ProductRepository extends BaseRepository
|
|||
if (is_numeric($value)) {
|
||||
return (float) $value;
|
||||
}
|
||||
$normalized = reFormatNumber((string) $value);
|
||||
$normalized = reFormatWawiNumber((string) $value);
|
||||
|
||||
return $normalized !== null && $normalized !== '' ? (float) $normalized : 1.10;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ if (! function_exists('make_old_url')) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('make_old_url')) {
|
||||
function make_old_url($path)
|
||||
{
|
||||
|
|
@ -21,34 +20,40 @@ if (! function_exists('get_file_last_time')) {
|
|||
if (file_exists($value)) {
|
||||
return filemtime($value);
|
||||
}
|
||||
return date("Ymd-is", time());
|
||||
|
||||
return date('Ymd-is', time());
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_user_attr')) {
|
||||
function get_user_attr($key){
|
||||
function get_user_attr($key)
|
||||
{
|
||||
if ($user = Auth::user()) {
|
||||
return $user->getSetting($key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('set_user_attr')) {
|
||||
function set_user_attr($key, $value){
|
||||
function set_user_attr($key, $value)
|
||||
{
|
||||
if ($user = Auth::user()) {
|
||||
return $user->setSetting([$key => $value]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_active_badge')) {
|
||||
function get_active_badge($active, $tooltip = false, $pos = "top")
|
||||
function get_active_badge($active, $tooltip = false, $pos = 'top')
|
||||
{
|
||||
if($tooltip){
|
||||
if ($tooltip) {
|
||||
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.$tooltip.'"';
|
||||
}
|
||||
|
||||
return $active ? '<span class="badge badge-pill badge-success" '.$tooltip.'><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger" '.$tooltip.'><i class="fa fa-times"></i></span>';
|
||||
}
|
||||
}
|
||||
|
|
@ -56,22 +61,39 @@ if (! function_exists('get_active_badge')) {
|
|||
if (! function_exists('formatDate')) {
|
||||
function formatDate($date)
|
||||
{
|
||||
return Carbon::parse($date)->format(\Util::formatDateDB());
|
||||
return Carbon::parse($date)->format(Util::formatDateDB());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatNumber')) {
|
||||
function formatNumber($number, $dec=2)
|
||||
function formatNumber($number, $dec = 2)
|
||||
{
|
||||
return !$number ? $number : Util::formatNumber($number, $dec);
|
||||
return ! $number ? $number : Util::formatNumber($number, $dec);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('reFormatNumber')) {
|
||||
function reFormatNumber($number)
|
||||
{
|
||||
return !$number ? $number : Util::reFormatNumber($number);
|
||||
return ! $number ? $number : Util::reFormatNumber($number);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('reFormatWawiNumber')) {
|
||||
/**
|
||||
* Eingabe-Parsing der Warenwirtschaft (Audit N-6, Kundenentscheid 15.07.2026):
|
||||
* Ein einzelner Punkt mit genau 1–2 Nachkommastellen gilt als Dezimaltrenner
|
||||
* („5.1" = 5,1 · „5.12" = 5,12 — kommt beim Kopieren von Daten vor);
|
||||
* alles andere („1.500", „1.234,56") folgt der deutschen Konvention.
|
||||
*/
|
||||
function reFormatWawiNumber($number)
|
||||
{
|
||||
if (is_string($number) && preg_match('/^-?\d+\.\d{1,2}$/', trim($number))) {
|
||||
return (float) trim($number);
|
||||
}
|
||||
|
||||
return reFormatNumber($number);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,12 +104,9 @@ if (! function_exists('formatPlural')) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('substr_ellipsis')) {
|
||||
function substr_ellipsis($str, $len=100, $clean=false, $ell="...")
|
||||
function substr_ellipsis($str, $len = 100, $clean = false, $ell = '...')
|
||||
{
|
||||
return Util::substr_ellipsis($str, $len, $clean, $ell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue