Skip to content

Commit

Permalink
Merge pull request #9626 from OPEN-DSI/fix_product_margin
Browse files Browse the repository at this point in the history
FIX Product margin tab and credit note
  • Loading branch information
eldy committed Oct 9, 2018
2 parents e165dce + 06fe172 commit 430f833
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/main.lang
Expand Up @@ -455,6 +455,7 @@ Reporting=Reporting
Reportings=Reporting
Draft=Draft
Drafts=Drafts
StatusInterInvoiced=
Validated=Validated
Opened=Open
New=New
Expand Down Expand Up @@ -854,4 +855,4 @@ SearchIntoInterventions=Interventions
SearchIntoContracts=Contracts
SearchIntoCustomerShipments=Customer shipments
SearchIntoExpenseReports=Expense reports
SearchIntoLeaves=Leaves
SearchIntoLeaves=Leaves
6 changes: 3 additions & 3 deletions htdocs/margin/tabs/productMargins.php
Expand Up @@ -138,9 +138,9 @@
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,";
$sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive
$sql.= " sum(d.qty) as qty,";
$sql.= " sum(d.qty * d.buy_price_ht) as buying_price,"; // always positive
$sql.= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // always positive
$sql.= " IF(f.type = 2, -1, 1) * sum(d.qty) as qty,"; // not always positive in case of Credit note
$sql.= " IF(f.type = 2, -1, 1) * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
$sql.= " IF(f.type = 2, -1, 1) * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
Expand Down

0 comments on commit 430f833

Please sign in to comment.