diff --git a/import.php b/import.php
index 66db65f..2cde227 100755
--- a/import.php
+++ b/import.php
@@ -1970,9 +1970,10 @@ if ($action == 'previewdatanorm' && $id > 0) {
'datanorm_ean' => $datanorm->ean,
'purchase_price' => $currentDolibarrPrice, // Current Dolibarr unit price
'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
'selling_price' => $sellingPrice,
- 'copper_surcharge' => $copperSurchargeForPrice, // Copper surcharge (for price_unit)
+ 'copper_surcharge' => $copperSurchargeForPrice, // Copper surcharge (per unit)
'existing_product_id' => $existingProductId,
'action' => $productAction,
'new_ref' => 'NEW-'.$supplierPrefix.'-'.$datanorm->article_number,
@@ -3027,16 +3028,17 @@ if ($action == 'edit' && $import->id > 0) {
print '
';
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;
+ $dolibarrMaterialTotal = $match['purchase_price'] * $dolibarrMinQty;
+ $dolibarrCopper = !empty($match['purchase_copper_surcharge']) ? $match['purchase_copper_surcharge'] : 0;
- // Load copper surcharge for this supplier price
- $dolibarrCopper = !empty($productCopperSurcharge) ? $productCopperSurcharge : 0;
+ // Show breakdown if copper exists
if ($dolibarrCopper > 0) {
- print ''.price($dolibarrTotalForQty).' + '.price($dolibarrCopper).' Cu ';
- $dolibarrTotalForQty += $dolibarrCopper;
+ print ''.price($dolibarrMaterialTotal).' + '.price($dolibarrCopper).' Cu ';
}
- print ''.price($dolibarrTotalForQty);
+ // Total price for minimum quantity
+ $dolibarrTotal = $dolibarrMaterialTotal + $dolibarrCopper;
+ print ''.price($dolibarrTotal);
if ($dolibarrMinQty > 1) {
print '/'.$dolibarrMinQty;
}
@@ -3044,7 +3046,8 @@ if ($action == 'edit' && $import->id > 0) {
// Unit price as secondary info
if ($dolibarrMinQty > 1) {
- print ' ('.price($match['purchase_price']).'/Stk.)';
+ $dolibarrUnitPrice = $dolibarrTotal / $dolibarrMinQty;
+ print ' ('.price($dolibarrUnitPrice).'/Stk.)';
}
} else {
print '-';
@@ -3054,16 +3057,17 @@ if ($action == 'edit' && $import->id > 0) {
// Datanorm price - show price for minimum quantity
print '';
$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
- if ($match['copper_surcharge'] > 0) {
- $copperForUnit = $match['copper_surcharge'] * $datanormPriceUnit;
- print ''.price($match['datanorm_price']).' + '.price($copperForUnit).' Cu ';
+ // Show breakdown if copper exists
+ if ($datanormCopper > 0) {
+ print ''.price($datanormMaterialTotal).' + '.price($datanormCopper).' Cu ';
}
- // Main price for minimum quantity
- print ''.price($datanormTotalForUnit);
+ // Total price for minimum quantity (Datanorm material + Dolibarr copper)
+ $datanormTotal = $datanormMaterialTotal + $datanormCopper;
+ print ''.price($datanormTotal);
if ($datanormPriceUnit > 1) {
print '/'.$datanormPriceUnit;
}
@@ -3071,7 +3075,7 @@ if ($action == 'edit' && $import->id > 0) {
// Unit price as secondary info
if ($datanormPriceUnit > 1) {
- $datanormUnitPrice = $datanormTotalForUnit / $datanormPriceUnit;
+ $datanormUnitPrice = $datanormTotal / $datanormPriceUnit;
print ' ('.price($datanormUnitPrice).'/Stk.)';
}
print ' | ';
|