From 2cf7be39c71390a36374751cf57c0c25ca9a199e Mon Sep 17 00:00:00 2001 From: data Date: Tue, 3 Mar 2026 08:48:14 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Preisanzeige=20f=C3=BCr=20Mindestmengen?= =?UTF-8?q?=20in=20Haupttabelle=20(v4.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Haupttabelle zeigte nur Stückpreise statt Preise für Mindestmenge - Kupferzuschlag (75,50€ für 100m) wurde mit Stückpreis (0,86€) addiert - Vergleich war falsch: 0,86€ + 75,50€ = 76,36€ (unsinnig!) Lösung: 1. Beide Preise werden für Mindestmenge angezeigt: - Dolibarr: 0,86€ × 100 + 75,50€ = 161,50€/100 - Datanorm: 46,66€ + 75,50€ = 122,16€/100 2. Stückpreis als sekundäre Info in Klammern 3. Kupferzuschlag wird korrekt für Mindestmenge berechnet Beispiel NYM-J 3x1,5: - Dolibarr: 52,00€/100 + 45,30€ = 97,30€/100 (0,97€/m) - Datanorm: 18,20€/100 + 45,30€ = 63,50€/100 (0,64€/m) - Differenz: -34,7% statt -65% Co-Authored-By: Claude Sonnet 4.5 --- import.php | 67 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/import.php b/import.php index bf7085a..66db65f 100755 --- a/import.php +++ b/import.php @@ -1882,8 +1882,9 @@ if ($action == 'previewdatanorm' && $id > 0) { // Load existing product's copper surcharge for price comparison $productCopperSurcharge = 0; $currentSupplierPriceId = 0; + $currentSupplierMinQty = 1; if ($existingProductId > 0) { - $sqlExisting = "SELECT pf.rowid, pf.fk_soc, pf.unitprice FROM ".MAIN_DB_PREFIX."product_fournisseur_price pf"; + $sqlExisting = "SELECT pf.rowid, pf.fk_soc, pf.unitprice, pf.quantity FROM ".MAIN_DB_PREFIX."product_fournisseur_price pf"; $sqlExisting .= " WHERE pf.fk_product = ".(int)$existingProductId; $resExisting = $db->query($sqlExisting); if ($resExisting) { @@ -1893,6 +1894,7 @@ if ($action == 'previewdatanorm' && $id > 0) { if ($objEx->fk_soc == $import->fk_soc) { $currentDolibarrPrice = (float)$objEx->unitprice; $currentSupplierPriceId = $objEx->rowid; + $currentSupplierMinQty = max(1, $objEx->quantity); } } } @@ -1966,10 +1968,11 @@ if ($action == 'previewdatanorm' && $id > 0) { 'datanorm_price' => $datanorm->price, 'datanorm_price_unit' => $datanorm->price_unit, 'datanorm_ean' => $datanorm->ean, - 'purchase_price' => $currentDolibarrPrice, // Current Dolibarr price for comparison - 'datanorm_purchase_price' => $purchasePrice, // New Datanorm price + 'purchase_price' => $currentDolibarrPrice, // Current Dolibarr unit price + 'purchase_min_qty' => $currentSupplierMinQty, // Dolibarr minimum quantity + 'datanorm_purchase_price' => $purchasePrice, // New Datanorm unit price 'selling_price' => $sellingPrice, - 'copper_surcharge' => $copperSurchargeForPrice, + 'copper_surcharge' => $copperSurchargeForPrice, // Copper surcharge (for price_unit) 'existing_product_id' => $existingProductId, 'action' => $productAction, 'new_ref' => 'NEW-'.$supplierPrefix.'-'.$datanorm->article_number, @@ -3020,22 +3023,56 @@ if ($action == 'edit' && $import->id > 0) { } print ''; - // Invoice price (from ZUGFeRD) + // Current Dolibarr price for minimum quantity print ''; - print ''.price($match['line_unit_price']).''; + if (!empty($match['purchase_price']) && $match['purchase_price'] > 0) { + $dolibarrMinQty = !empty($match['purchase_min_qty']) ? $match['purchase_min_qty'] : 1; + $dolibarrTotalForQty = $match['purchase_price'] * $dolibarrMinQty; + + // Load copper surcharge for this supplier price + $dolibarrCopper = !empty($productCopperSurcharge) ? $productCopperSurcharge : 0; + if ($dolibarrCopper > 0) { + print ''.price($dolibarrTotalForQty).' + '.price($dolibarrCopper).' Cu
'; + $dolibarrTotalForQty += $dolibarrCopper; + } + + print ''.price($dolibarrTotalForQty); + if ($dolibarrMinQty > 1) { + print '/'.$dolibarrMinQty; + } + print ''; + + // Unit price as secondary info + if ($dolibarrMinQty > 1) { + print '
('.price($match['purchase_price']).'/Stk.)'; + } + } else { + print '-'; + } print ''; - // Datanorm price - show original price and calculated unit price + // Datanorm price - show price for minimum quantity print ''; - if ($match['datanorm_price_unit'] > 1) { - // Show original price and price unit - print ''.price($match['datanorm_price']).'/'.$match['datanorm_price_unit'].''; - print '
= '.price($match['purchase_price']).''; - } else { - print ''.price($match['purchase_price']).''; - } + $datanormPriceUnit = max(1, $match['datanorm_price_unit']); + $datanormTotalForUnit = $match['datanorm_price'] + ($match['copper_surcharge'] * $datanormPriceUnit); + + // Show breakdown if copper surcharge exists if ($match['copper_surcharge'] > 0) { - print '
+ '.price($match['copper_surcharge']).' Cu'; + $copperForUnit = $match['copper_surcharge'] * $datanormPriceUnit; + print ''.price($match['datanorm_price']).' + '.price($copperForUnit).' Cu
'; + } + + // Main price for minimum quantity + print ''.price($datanormTotalForUnit); + if ($datanormPriceUnit > 1) { + print '/'.$datanormPriceUnit; + } + print ''; + + // Unit price as secondary info + if ($datanormPriceUnit > 1) { + $datanormUnitPrice = $datanormTotalForUnit / $datanormPriceUnit; + print '
('.price($datanormUnitPrice).'/Stk.)'; } print '';