siamon123 / warehouse-inventory-system

Open source inventory management system with php and mysql
http://www.oswapp.com
MIT License
379 stars 233 forks source link

Variable profit in includes/function.php #29

Open riyansuryapratama opened 6 years ago

riyansuryapratama commented 6 years ago

function total_price($totals){ $sum = 0; $sub = 0;

foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit); <= not yet defined so if i want to fix it how ?

function total_price($totals){ $sum = 0; $sub = 0; $profit = 0; <= can i change to be like this ? foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit);

marrodeur commented 5 years ago

Hello,

`/--------------------------------------------------------------/ / Function for find out total saleing price, buying price and profit /--------------------------------------------------------------*/ function total_price($totals){ $sum = 0; $sub = 0;

foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } if(empty($profit)) {
$profit = '0';
} else { return array($sum,$profit); }
}`

ghost commented 4 years ago

https://github.com/bitsandbots/inventory