fix: Preisanzeige für Mindestmengen in Haupttabelle (v4.3)
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 <noreply@anthropic.com>
This commit is contained in:
parent
70354e824d
commit
2cf7be39c7
1 changed files with 52 additions and 15 deletions
67
import.php
67
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 '</td>';
|
||||
|
||||
// Invoice price (from ZUGFeRD)
|
||||
// Current Dolibarr price for minimum quantity
|
||||
print '<td class="right nowraponall">';
|
||||
print '<strong>'.price($match['line_unit_price']).'</strong>';
|
||||
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 '<span class="small" style="color: #666;">'.price($dolibarrTotalForQty).' + '.price($dolibarrCopper).' Cu</span><br>';
|
||||
$dolibarrTotalForQty += $dolibarrCopper;
|
||||
}
|
||||
|
||||
print '<strong>'.price($dolibarrTotalForQty);
|
||||
if ($dolibarrMinQty > 1) {
|
||||
print '/'.$dolibarrMinQty;
|
||||
}
|
||||
print '</strong>';
|
||||
|
||||
// Unit price as secondary info
|
||||
if ($dolibarrMinQty > 1) {
|
||||
print '<br><span class="small opacitymedium">('.price($match['purchase_price']).'/Stk.)</span>';
|
||||
}
|
||||
} else {
|
||||
print '<span class="opacitymedium">-</span>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Datanorm price - show original price and calculated unit price
|
||||
// Datanorm price - show price for minimum quantity
|
||||
print '<td class="right nowraponall">';
|
||||
if ($match['datanorm_price_unit'] > 1) {
|
||||
// Show original price and price unit
|
||||
print '<span class="small" style="color: #666;">'.price($match['datanorm_price']).'/'.$match['datanorm_price_unit'].'</span>';
|
||||
print '<br><strong>= '.price($match['purchase_price']).'</strong>';
|
||||
} else {
|
||||
print '<strong>'.price($match['purchase_price']).'</strong>';
|
||||
}
|
||||
$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 '<br><span class="small" style="color: #d9534f;">+ '.price($match['copper_surcharge']).' Cu</span>';
|
||||
$copperForUnit = $match['copper_surcharge'] * $datanormPriceUnit;
|
||||
print '<span class="small" style="color: #666;">'.price($match['datanorm_price']).' + '.price($copperForUnit).' Cu</span><br>';
|
||||
}
|
||||
|
||||
// Main price for minimum quantity
|
||||
print '<strong>'.price($datanormTotalForUnit);
|
||||
if ($datanormPriceUnit > 1) {
|
||||
print '/'.$datanormPriceUnit;
|
||||
}
|
||||
print '</strong>';
|
||||
|
||||
// Unit price as secondary info
|
||||
if ($datanormPriceUnit > 1) {
|
||||
$datanormUnitPrice = $datanormTotalForUnit / $datanormPriceUnit;
|
||||
print '<br><span class="small opacitymedium">('.price($datanormUnitPrice).'/Stk.)</span>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue