* Calculate percentage properly instead of adding to the base value #925
This commit is contained in:
@@ -165,37 +165,6 @@ class FinanceTest extends TestCase
|
||||
return [$user, $pirep, $fares];
|
||||
}
|
||||
|
||||
/*public function testFlightFaresNoOverride()
|
||||
{
|
||||
$flight = factory(Flight::class)->create();
|
||||
$fare = factory(Fare::class)->create();
|
||||
|
||||
$this->fareSvc->setForFlight($flight, $fare);
|
||||
$subfleet_fares = $this->fareSvc->get($flight);
|
||||
|
||||
$this->assertCount(1, $subfleet_fares);
|
||||
$this->assertEquals($fare->price, $subfleet_fares->get(0)->price);
|
||||
$this->assertEquals($fare->capacity, $subfleet_fares->get(0)->capacity);
|
||||
|
||||
//
|
||||
// set an override now
|
||||
//
|
||||
$this->fareSvc->setForFlight($flight, $fare, [
|
||||
'price' => 50, 'capacity' => 400,
|
||||
]);
|
||||
|
||||
// look for them again
|
||||
$subfleet_fares = $this->fareSvc->getForFlight($flight);
|
||||
|
||||
$this->assertCount(1, $subfleet_fares);
|
||||
$this->assertEquals(50, $subfleet_fares[0]->price);
|
||||
$this->assertEquals(400, $subfleet_fares[0]->capacity);
|
||||
|
||||
// delete
|
||||
$this->fareSvc->delFareFromFlight($flight, $fare);
|
||||
$this->assertCount(0, $this->fareSvc->getForFlight($flight));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Make sure that the API is returning the fares properly for a subfleet on a flight
|
||||
* https://github.com/nabeelio/phpvms/issues/899
|
||||
@@ -355,13 +324,13 @@ class FinanceTest extends TestCase
|
||||
$subfleet = factory(Subfleet::class)->create();
|
||||
$this->fleetSvc->addSubfleetToFlight($subfleet, $flight);
|
||||
|
||||
$percent_incr = '20%';
|
||||
$percent_decr = '-20%';
|
||||
$percent_incr = '120%';
|
||||
$percent_decr = '80%';
|
||||
$percent_200 = '200%';
|
||||
|
||||
$new_price = Math::addPercent($fare->price, $percent_incr);
|
||||
$new_cost = Math::addPercent($fare->cost, $percent_decr);
|
||||
$new_capacity = Math::addPercent($fare->capacity, $percent_200);
|
||||
$new_price = Math::getPercent($fare->price, $percent_incr);
|
||||
$new_cost = Math::getPercent($fare->cost, $percent_decr);
|
||||
$new_capacity = Math::getPercent($fare->capacity, $percent_200);
|
||||
|
||||
$this->fareSvc->setForFlight($flight, $fare, [
|
||||
'price' => $percent_incr,
|
||||
@@ -455,9 +424,9 @@ class FinanceTest extends TestCase
|
||||
$percent_decr = '-20%';
|
||||
$percent_200 = '200%';
|
||||
|
||||
$new_price = Math::addPercent($fare->price, $percent_incr);
|
||||
$new_cost = Math::addPercent($fare->cost, $percent_decr);
|
||||
$new_capacity = Math::addPercent($fare->capacity, $percent_200);
|
||||
$new_price = Math::getPercent($fare->price, $percent_incr);
|
||||
$new_cost = Math::getPercent($fare->cost, $percent_decr);
|
||||
$new_capacity = Math::getPercent($fare->capacity, $percent_200);
|
||||
|
||||
$this->fareSvc->setForSubfleet($subfleet, $fare, [
|
||||
'price' => $percent_incr,
|
||||
@@ -499,7 +468,7 @@ class FinanceTest extends TestCase
|
||||
'cost' => 250,
|
||||
]);
|
||||
|
||||
$fare3_price = Math::addPercent($fare3->price, 300);
|
||||
$fare3_price = Math::getPercent($fare3->price, 300);
|
||||
|
||||
// Assign another one to the flight, that's not on the subfleet
|
||||
// This one should NOT be returned in the list of fares
|
||||
@@ -623,7 +592,7 @@ class FinanceTest extends TestCase
|
||||
|
||||
// Change to a percentage
|
||||
$manual_pay_rate = '50%';
|
||||
$manual_pay_adjusted = Math::addPercent(
|
||||
$manual_pay_adjusted = Math::getPercent(
|
||||
$rank->manual_base_pay_rate,
|
||||
$manual_pay_rate
|
||||
);
|
||||
@@ -931,7 +900,7 @@ class FinanceTest extends TestCase
|
||||
|
||||
// $this->assertCount(9, $transactions['transactions']);
|
||||
$this->assertEquals(3020, $transactions['credits']->getValue());
|
||||
$this->assertEquals(2060, $transactions['debits']->getValue());
|
||||
$this->assertEquals(2050, $transactions['debits']->getValue());
|
||||
|
||||
// Check that all the different transaction types are there
|
||||
// test by the different groups that exist
|
||||
@@ -987,7 +956,7 @@ class FinanceTest extends TestCase
|
||||
|
||||
// $this->assertCount(9, $transactions['transactions']);
|
||||
$this->assertEquals(3020, $transactions['credits']->getValue());
|
||||
$this->assertEquals(2060, $transactions['debits']->getValue());
|
||||
$this->assertEquals(2050, $transactions['debits']->getValue());
|
||||
|
||||
// Check that all the different transaction types are there
|
||||
// test by the different groups that exist
|
||||
@@ -1026,7 +995,7 @@ class FinanceTest extends TestCase
|
||||
|
||||
$transactions = $journalRepo->getAllForObject($pirep2);
|
||||
$this->assertEquals(3020, $transactions['credits']->getValue());
|
||||
$this->assertEquals(2160, $transactions['debits']->getValue());
|
||||
$this->assertEquals(2150, $transactions['debits']->getValue());
|
||||
|
||||
// Check that all the different transaction types are there
|
||||
// test by the different groups that exist
|
||||
|
||||
Reference in New Issue
Block a user