Implement department-specific customer pricing functionality

This commit is contained in:
Jeppe Bundgaard
2026-07-07 17:27:56 +02:00
parent c24428e4c7
commit 172a21c517
21 changed files with 1687 additions and 33 deletions
+3 -3
View File
@@ -1436,7 +1436,7 @@ class orders_o extends db
throw new Exception('No user found matching the customer number in the usage log');
}
if (!products_o::priceResolutionIsCustomMissing($priceResolution)) {
$product_price = $user->applyProductCustomerPricing((int)$order_item->product_id->value(), (int)$product_price);
$product_price = $user->applyProductCustomerPricing((int)$order_item->product_id->value(), (int)$product_price, true, (int)$this->department_id->value());
}
$order_item->notes->set(null); // Set notes for the simulated order item
$order_item->price->set((int)$product_price); // Set the price based on the product price and discount percentage
@@ -1509,7 +1509,7 @@ class orders_o extends db
if (products_o::priceResolutionIsCustomMissing($priceResolution)) {
return $price;
}
return $current_user->applyProductCustomerPricing((int)$product->id, $price);
return $current_user->applyProductCustomerPricing((int)$product->id, $price, true, (int)$this->department_id->value());
}
/**
@@ -1598,7 +1598,7 @@ class orders_o extends db
}
$unitPrice = (int)$department_price_cache[$product_id]['price'];
if (!products_o::priceResolutionIsCustomMissing($department_price_cache[$product_id])) {
$unitPrice = $tmp_user->applyProductCustomerPricing($product_id, $unitPrice, false);
$unitPrice = $tmp_user->applyProductCustomerPricing($product_id, $unitPrice, false, $department_id);
}
$post_discount = $unitPrice * $quantity;
$total += $post_discount;