Calculate percentage properly instead of adding to the base value #925 (#942)

* Calculate percentage properly instead of adding to the base value #925
This commit is contained in:
Nabeel S
2020-11-26 16:44:57 -05:00
committed by GitHub
parent 2ecf366670
commit 6b5cf38224
4 changed files with 33 additions and 61 deletions

View File

@@ -147,7 +147,7 @@ class FareService extends Service
{
if (filled($pivot->price)) {
if (strpos($pivot->price, '%', -1) !== false) {
$fare->price = Math::addPercent($fare->price, $pivot->price);
$fare->price = Math::getPercent($fare->price, $pivot->price);
} else {
$fare->price = $pivot->price;
}
@@ -155,7 +155,7 @@ class FareService extends Service
if (filled($pivot->cost)) {
if (strpos($pivot->cost, '%', -1) !== false) {
$fare->cost = Math::addPercent($fare->cost, $pivot->cost);
$fare->cost = Math::getPercent($fare->cost, $pivot->cost);
} else {
$fare->cost = $pivot->cost;
}
@@ -163,7 +163,7 @@ class FareService extends Service
if (filled($pivot->capacity)) {
if (strpos($pivot->capacity, '%', -1) !== false) {
$fare->capacity = floor(Math::addPercent($fare->capacity, $pivot->capacity));
$fare->capacity = floor(Math::getPercent($fare->capacity, $pivot->capacity));
} else {
$fare->capacity = floor($pivot->capacity);
}