fix: Einfache Preisberechnung mit Kupferzuschlag aus Dolibarr (v4.3)
Problem: - Komplizierte Logik mit copper_surcharge aus Datanorm (immer 0) - Kupferzuschlag wurde nicht korrekt aus Dolibarr-Extrafields geladen Lösung - EINFACH: 1. Dolibarr-Preis = unitprice × quantity + kupferzuschlag 2. Datanorm-Preis = price + kupferzuschlag (aus Dolibarr!) 3. Beide Preise für Mindestmenge anzeigen Beispiel NYM-J 3x1,5: - Dolibarr: 0,52€ × 100 + 45,30€ = 97,30€/100 - Datanorm: 18,20€ + 45,30€ = 63,50€/100 - Differenz: -34,7% Beispiel Klemme: - Dolibarr: 0,08€ × 100 = 8,00€/100 - Datanorm: 94,25€/100 - Differenz: +1.078% Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2cf7be39c7
commit
66cdff2104
1 changed files with 20 additions and 16 deletions
36
import.php
36
import.php
|
|
@ -1970,9 +1970,10 @@ if ($action == 'previewdatanorm' && $id > 0) {
|
||||||
'datanorm_ean' => $datanorm->ean,
|
'datanorm_ean' => $datanorm->ean,
|
||||||
'purchase_price' => $currentDolibarrPrice, // Current Dolibarr unit price
|
'purchase_price' => $currentDolibarrPrice, // Current Dolibarr unit price
|
||||||
'purchase_min_qty' => $currentSupplierMinQty, // Dolibarr minimum quantity
|
'purchase_min_qty' => $currentSupplierMinQty, // Dolibarr minimum quantity
|
||||||
|
'purchase_copper_surcharge' => $productCopperSurcharge, // Dolibarr copper surcharge (for min qty)
|
||||||
'datanorm_purchase_price' => $purchasePrice, // New Datanorm unit price
|
'datanorm_purchase_price' => $purchasePrice, // New Datanorm unit price
|
||||||
'selling_price' => $sellingPrice,
|
'selling_price' => $sellingPrice,
|
||||||
'copper_surcharge' => $copperSurchargeForPrice, // Copper surcharge (for price_unit)
|
'copper_surcharge' => $copperSurchargeForPrice, // Copper surcharge (per unit)
|
||||||
'existing_product_id' => $existingProductId,
|
'existing_product_id' => $existingProductId,
|
||||||
'action' => $productAction,
|
'action' => $productAction,
|
||||||
'new_ref' => 'NEW-'.$supplierPrefix.'-'.$datanorm->article_number,
|
'new_ref' => 'NEW-'.$supplierPrefix.'-'.$datanorm->article_number,
|
||||||
|
|
@ -3027,16 +3028,17 @@ if ($action == 'edit' && $import->id > 0) {
|
||||||
print '<td class="right nowraponall">';
|
print '<td class="right nowraponall">';
|
||||||
if (!empty($match['purchase_price']) && $match['purchase_price'] > 0) {
|
if (!empty($match['purchase_price']) && $match['purchase_price'] > 0) {
|
||||||
$dolibarrMinQty = !empty($match['purchase_min_qty']) ? $match['purchase_min_qty'] : 1;
|
$dolibarrMinQty = !empty($match['purchase_min_qty']) ? $match['purchase_min_qty'] : 1;
|
||||||
$dolibarrTotalForQty = $match['purchase_price'] * $dolibarrMinQty;
|
$dolibarrMaterialTotal = $match['purchase_price'] * $dolibarrMinQty;
|
||||||
|
$dolibarrCopper = !empty($match['purchase_copper_surcharge']) ? $match['purchase_copper_surcharge'] : 0;
|
||||||
|
|
||||||
// Load copper surcharge for this supplier price
|
// Show breakdown if copper exists
|
||||||
$dolibarrCopper = !empty($productCopperSurcharge) ? $productCopperSurcharge : 0;
|
|
||||||
if ($dolibarrCopper > 0) {
|
if ($dolibarrCopper > 0) {
|
||||||
print '<span class="small" style="color: #666;">'.price($dolibarrTotalForQty).' + '.price($dolibarrCopper).' Cu</span><br>';
|
print '<span class="small" style="color: #666;">'.price($dolibarrMaterialTotal).' + '.price($dolibarrCopper).' Cu</span><br>';
|
||||||
$dolibarrTotalForQty += $dolibarrCopper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<strong>'.price($dolibarrTotalForQty);
|
// Total price for minimum quantity
|
||||||
|
$dolibarrTotal = $dolibarrMaterialTotal + $dolibarrCopper;
|
||||||
|
print '<strong>'.price($dolibarrTotal);
|
||||||
if ($dolibarrMinQty > 1) {
|
if ($dolibarrMinQty > 1) {
|
||||||
print '/'.$dolibarrMinQty;
|
print '/'.$dolibarrMinQty;
|
||||||
}
|
}
|
||||||
|
|
@ -3044,7 +3046,8 @@ if ($action == 'edit' && $import->id > 0) {
|
||||||
|
|
||||||
// Unit price as secondary info
|
// Unit price as secondary info
|
||||||
if ($dolibarrMinQty > 1) {
|
if ($dolibarrMinQty > 1) {
|
||||||
print '<br><span class="small opacitymedium">('.price($match['purchase_price']).'/Stk.)</span>';
|
$dolibarrUnitPrice = $dolibarrTotal / $dolibarrMinQty;
|
||||||
|
print '<br><span class="small opacitymedium">('.price($dolibarrUnitPrice).'/Stk.)</span>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print '<span class="opacitymedium">-</span>';
|
print '<span class="opacitymedium">-</span>';
|
||||||
|
|
@ -3054,16 +3057,17 @@ if ($action == 'edit' && $import->id > 0) {
|
||||||
// Datanorm price - show price for minimum quantity
|
// Datanorm price - show price for minimum quantity
|
||||||
print '<td class="right nowraponall">';
|
print '<td class="right nowraponall">';
|
||||||
$datanormPriceUnit = max(1, $match['datanorm_price_unit']);
|
$datanormPriceUnit = max(1, $match['datanorm_price_unit']);
|
||||||
$datanormTotalForUnit = $match['datanorm_price'] + ($match['copper_surcharge'] * $datanormPriceUnit);
|
$datanormMaterialTotal = $match['datanorm_price']; // Material price for price_unit
|
||||||
|
$datanormCopper = !empty($match['purchase_copper_surcharge']) ? $match['purchase_copper_surcharge'] : 0;
|
||||||
|
|
||||||
// Show breakdown if copper surcharge exists
|
// Show breakdown if copper exists
|
||||||
if ($match['copper_surcharge'] > 0) {
|
if ($datanormCopper > 0) {
|
||||||
$copperForUnit = $match['copper_surcharge'] * $datanormPriceUnit;
|
print '<span class="small" style="color: #666;">'.price($datanormMaterialTotal).' + '.price($datanormCopper).' Cu</span><br>';
|
||||||
print '<span class="small" style="color: #666;">'.price($match['datanorm_price']).' + '.price($copperForUnit).' Cu</span><br>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main price for minimum quantity
|
// Total price for minimum quantity (Datanorm material + Dolibarr copper)
|
||||||
print '<strong>'.price($datanormTotalForUnit);
|
$datanormTotal = $datanormMaterialTotal + $datanormCopper;
|
||||||
|
print '<strong>'.price($datanormTotal);
|
||||||
if ($datanormPriceUnit > 1) {
|
if ($datanormPriceUnit > 1) {
|
||||||
print '/'.$datanormPriceUnit;
|
print '/'.$datanormPriceUnit;
|
||||||
}
|
}
|
||||||
|
|
@ -3071,7 +3075,7 @@ if ($action == 'edit' && $import->id > 0) {
|
||||||
|
|
||||||
// Unit price as secondary info
|
// Unit price as secondary info
|
||||||
if ($datanormPriceUnit > 1) {
|
if ($datanormPriceUnit > 1) {
|
||||||
$datanormUnitPrice = $datanormTotalForUnit / $datanormPriceUnit;
|
$datanormUnitPrice = $datanormTotal / $datanormPriceUnit;
|
||||||
print '<br><span class="small opacitymedium">('.price($datanormUnitPrice).'/Stk.)</span>';
|
print '<br><span class="small opacitymedium">('.price($datanormUnitPrice).'/Stk.)</span>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue