dont use lines without buying price for margin calculation if ForceBuyPriceIfNull is set
This commit is contained in:
parent
c1859d361a
commit
2b010c9ba4
@ -166,6 +166,8 @@ if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
if ($agentid > 0)
|
||||
$sql.= " GROUP BY s.rowid";
|
||||
else
|
||||
|
||||
@ -141,6 +141,8 @@ if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
if ($agentid > 0)
|
||||
$sql.= " GROUP BY s.rowid";
|
||||
else
|
||||
|
||||
@ -158,6 +158,8 @@ if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
if ($client)
|
||||
$sql.= " GROUP BY f.rowid";
|
||||
else
|
||||
|
||||
@ -162,6 +162,8 @@ if (!empty($startdate))
|
||||
$sql.= " AND f.datef >= '".$startdate."'";
|
||||
if (!empty($enddate))
|
||||
$sql.= " AND f.datef <= '".$enddate."'";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
if ($id > 0)
|
||||
$sql.= " GROUP BY f.rowid";
|
||||
else
|
||||
|
||||
@ -142,6 +142,8 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
$sql.= " AND d.fk_product =".$object->id;
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (! empty($socid)) $sql.= " AND f.fk_soc = $socid";
|
||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||
|
||||
@ -138,6 +138,8 @@ if ($socid > 0)
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
$sql.= " AND f.fk_soc = $socid";
|
||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||
$sql .= " AND d.buy_price_ht <> 0";
|
||||
$sql.= " GROUP BY f.rowid";
|
||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user