correct margin informations when buy_price at zero
This commit is contained in:
parent
8e2fee02df
commit
9a7935075c
@ -194,8 +194,8 @@ if ($result)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):0 ;
|
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ;
|
||||||
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):0 ;
|
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
@ -215,9 +215,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += $objp->buying_price;
|
||||||
@ -228,8 +228,8 @@ if ($result)
|
|||||||
// affichage totaux marges
|
// affichage totaux marges
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$totalMargin = $cumul_vente - $cumul_achat;
|
$totalMargin = $cumul_vente - $cumul_achat;
|
||||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):0 ;
|
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ;
|
||||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):0 ;
|
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
|
||||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||||
if ($client)
|
if ($client)
|
||||||
print '<td colspan=2>';
|
print '<td colspan=2>';
|
||||||
@ -240,9 +240,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
@ -266,8 +266,8 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||||
$("#marginRate").html("<?php echo price($marginRate); ?>%");
|
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||||
$("#markRate").html("<?php echo price($markRate); ?>%");
|
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -201,8 +201,8 @@ if ($result)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):0 ;
|
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ;
|
||||||
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):0 ;
|
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
@ -226,9 +226,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += $objp->buying_price;
|
||||||
@ -239,8 +239,8 @@ if ($result)
|
|||||||
// affichage totaux marges
|
// affichage totaux marges
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$totalMargin = $cumul_vente - $cumul_achat;
|
$totalMargin = $cumul_vente - $cumul_achat;
|
||||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):0 ;
|
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ;
|
||||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):0 ;
|
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
|
||||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||||
if ($client)
|
if ($client)
|
||||||
print '<td colspan=2>';
|
print '<td colspan=2>';
|
||||||
@ -251,9 +251,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
@ -279,8 +279,8 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||||
$("#marginRate").html("<?php echo price($marginRate); ?>%");
|
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||||
$("#markRate").html("<?php echo price($markRate); ?>%");
|
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -205,8 +205,8 @@ if ($result)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):0 ;
|
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ;
|
||||||
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):0 ;
|
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
@ -233,9 +233,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += $objp->buying_price;
|
||||||
@ -246,8 +246,8 @@ if ($result)
|
|||||||
// affichage totaux marges
|
// affichage totaux marges
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$totalMargin = $cumul_vente - $cumul_achat;
|
$totalMargin = $cumul_vente - $cumul_achat;
|
||||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):0 ;
|
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ;
|
||||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):0 ;
|
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
|
||||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
print '<td colspan=2>';
|
print '<td colspan=2>';
|
||||||
@ -258,9 +258,9 @@ if ($result)
|
|||||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||||
print "<td align=\"right\">".price($marginRate)."%</td>\n";
|
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||||
if ($conf->global->DISPLAY_MARK_RATES)
|
if ($conf->global->DISPLAY_MARK_RATES)
|
||||||
print "<td align=\"right\">".price($markRate)."%</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
@ -288,8 +288,8 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||||
$("#marginRate").html("<?php echo price($marginRate); ?>%");
|
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||||
$("#markRate").html("<?php echo price($markRate); ?>%");
|
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -255,7 +255,7 @@ llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $');
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||||
$("#marginRate").html("<?php echo price($marginRate); ?>%");
|
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||||
$("#markRate").html("<?php echo price($markRate); ?>%");
|
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -241,7 +241,7 @@ llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $');
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||||
$("#marginRate").html("<?php echo price($marginRate); ?>%");
|
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||||
$("#markRate").html("<?php echo price($markRate); ?>%");
|
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user