mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Fix: the purchase price, manually entered is not taken recovered
This commit is contained in:
@@ -3048,10 +3048,15 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $force_price
|
||||||
|
* @return multitype:number string NULL
|
||||||
|
*/
|
||||||
function getMarginInfos($force_price=false) {
|
function getMarginInfos($force_price=false) {
|
||||||
global $conf;
|
global $conf;
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||||
|
|
||||||
$marginInfos = array(
|
$marginInfos = array(
|
||||||
'pa_products' => 0,
|
'pa_products' => 0,
|
||||||
'pv_products' => 0,
|
'pv_products' => 0,
|
||||||
@@ -3069,8 +3074,9 @@ abstract class CommonObject
|
|||||||
'total_margin_rate' => '',
|
'total_margin_rate' => '',
|
||||||
'total_mark_rate' => ''
|
'total_mark_rate' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($this->lines as $line) {
|
foreach($this->lines as $line) {
|
||||||
if (isset($line->fk_fournprice) && !$force_price) {
|
if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) {
|
||||||
$product = new ProductFournisseur($this->db);
|
$product = new ProductFournisseur($this->db);
|
||||||
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
|
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
|
||||||
$line->pa_ht = $product->fourn_unitprice;
|
$line->pa_ht = $product->fourn_unitprice;
|
||||||
@@ -3130,7 +3136,6 @@ abstract class CommonObject
|
|||||||
if ($marginInfos['pv_services'] > 0)
|
if ($marginInfos['pv_services'] > 0)
|
||||||
$marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5);
|
$marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5);
|
||||||
|
|
||||||
|
|
||||||
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
|
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
|
||||||
if ($marginInfos['pa_total'] > 0)
|
if ($marginInfos['pa_total'] > 0)
|
||||||
$marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5);
|
$marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5);
|
||||||
@@ -3140,9 +3145,15 @@ abstract class CommonObject
|
|||||||
return $marginInfos;
|
return $marginInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $force_price
|
||||||
|
*/
|
||||||
function displayMarginInfos($force_price=false) {
|
function displayMarginInfos($force_price=false) {
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$marginInfo = $this->getMarginInfos($force_price);
|
$marginInfo = $this->getMarginInfos($force_price);
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td width="30%">'.$langs->trans('Margins').'</td>';
|
print '<td width="30%">'.$langs->trans('Margins').'</td>';
|
||||||
@@ -3191,6 +3202,6 @@ abstract class CommonObject
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user