This commit is contained in:
babak alizadeh 2024-10-25 20:16:26 +03:30
parent 1f97352d2b
commit c417aadee4

View file

@ -96,8 +96,14 @@ class SellController extends AbstractController
$avg = $avg + $last->getBd(); $avg = $avg + $last->getBd();
$count = $count + $last->getCommdityCount(); $count = $count + $last->getCommdityCount();
} }
$price = $avg / $count; if ($count != 0) {
$profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); $price = $avg / $count;
$profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
}
else{
$profit = $profit + $item->getBs();
}
} }
//round output //round output
@ -419,8 +425,13 @@ class SellController extends AbstractController
$avg = $avg + $last->getBd(); $avg = $avg + $last->getBd();
$count = $count + $last->getCommdityCount(); $count = $count + $last->getCommdityCount();
} }
$price = $avg / $count; if ($count != 0) {
$temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); $price = $avg / $count;
$temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
}
else{
$temp['profit'] = $temp['profit'] + $item->getBs();
}
} }
//round output //round output