Add comments
This commit is contained in:
parent
c88e63ecc9
commit
2c07d2df22
@ -115,6 +115,7 @@ $sql = "SELECT";
|
||||
if ($agentid > 0) $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
|
||||
$sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge" ;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
@ -164,6 +164,7 @@ $sql = "SELECT";
|
||||
$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
|
||||
if ($client) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
@ -166,6 +166,7 @@ $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"
|
||||
if ($id > 0) $sql.= " d.fk_product,";
|
||||
if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
|
||||
$sql.= " SUM(d.total_ht) as selling_price,";
|
||||
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
|
||||
$sql.= " SUM(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql.= " SUM(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user