dont use lines without buying price for margin calculation if ForceBuyPriceIfNull is set

This commit is contained in:
Christophe Battarel 2012-09-06 13:49:39 +02:00
parent c1859d361a
commit 2b010c9ba4
6 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ";

View File

@ -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);