2018-02-25 05:38:25 +08:00
|
|
|
<?php
|
|
|
|
|
2018-03-06 12:49:42 +08:00
|
|
|
namespace App\Services\Finance;
|
2018-02-25 05:38:25 +08:00
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
use App\Events\Expenses as ExpensesEvent;
|
|
|
|
use App\Models\Enums\ExpenseType;
|
2018-02-28 04:29:45 +08:00
|
|
|
use App\Models\Enums\PirepSource;
|
2018-03-02 06:20:13 +08:00
|
|
|
use App\Models\Expense;
|
2018-02-28 04:29:45 +08:00
|
|
|
use App\Models\Pirep;
|
2018-03-02 06:20:13 +08:00
|
|
|
use App\Repositories\ExpenseRepository;
|
|
|
|
use App\Repositories\JournalRepository;
|
2018-03-06 12:49:42 +08:00
|
|
|
use App\Services\BaseService;
|
|
|
|
use App\Services\FareService;
|
|
|
|
use App\Services\PIREPService;
|
2018-02-28 06:16:40 +08:00
|
|
|
use App\Support\Math;
|
2018-03-01 03:34:49 +08:00
|
|
|
use App\Support\Money;
|
2018-03-02 12:00:11 +08:00
|
|
|
use Log;
|
2018-02-28 04:29:45 +08:00
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
/**
|
|
|
|
* Class FinanceService
|
|
|
|
* @package App\Services
|
|
|
|
*
|
|
|
|
*/
|
2018-03-06 12:49:42 +08:00
|
|
|
class PirepFinanceService extends BaseService
|
2018-02-25 05:38:25 +08:00
|
|
|
{
|
2018-03-02 06:20:13 +08:00
|
|
|
private $expenseRepo,
|
|
|
|
$fareSvc,
|
|
|
|
$journalRepo,
|
|
|
|
$pirepSvc;
|
2018-02-25 05:38:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* FinanceService constructor.
|
2018-03-02 06:20:13 +08:00
|
|
|
* @param ExpenseRepository $expenseRepo
|
2018-02-25 05:38:25 +08:00
|
|
|
* @param FareService $fareSvc
|
2018-03-02 06:20:13 +08:00
|
|
|
* @param JournalRepository $journalRepo
|
|
|
|
* @param PIREPService $pirepSvc
|
2018-02-25 05:38:25 +08:00
|
|
|
*/
|
|
|
|
public function __construct(
|
2018-03-02 06:20:13 +08:00
|
|
|
ExpenseRepository $expenseRepo,
|
2018-02-25 05:38:25 +08:00
|
|
|
FareService $fareSvc,
|
2018-03-02 06:20:13 +08:00
|
|
|
JournalRepository $journalRepo,
|
|
|
|
PIREPService $pirepSvc
|
2018-02-25 05:38:25 +08:00
|
|
|
) {
|
2018-03-02 06:20:13 +08:00
|
|
|
$this->expenseRepo = $expenseRepo;
|
2018-02-25 05:38:25 +08:00
|
|
|
$this->fareSvc = $fareSvc;
|
2018-03-02 06:20:13 +08:00
|
|
|
$this->journalRepo = $journalRepo;
|
|
|
|
$this->pirepSvc = $pirepSvc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process all of the finances for a pilot report. This is called
|
|
|
|
* from a listener (FinanceEvents)
|
|
|
|
* @param Pirep $pirep
|
|
|
|
* @return mixed
|
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function processFinancesForPirep(Pirep $pirep)
|
|
|
|
{
|
2018-03-03 03:12:39 +08:00
|
|
|
if(!$pirep->airline->journal) {
|
|
|
|
$pirep->airline->journal = $pirep->airline->initJournal(config('phpvms.currency'));
|
2018-03-02 06:20:13 +08:00
|
|
|
}
|
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
if (!$pirep->user->journal) {
|
|
|
|
$pirep->user->journal = $pirep->user->initJournal(config('phpvms.currency'));
|
|
|
|
}
|
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
# Clean out the expenses first
|
|
|
|
$this->deleteFinancesForPirep($pirep);
|
|
|
|
|
|
|
|
# Now start and pay from scratch
|
2018-03-03 03:12:39 +08:00
|
|
|
$this->payFaresForPirep($pirep);
|
|
|
|
$this->payExpensesForPirep($pirep);
|
2018-03-06 12:49:42 +08:00
|
|
|
$this->payExpensesEventsForPirep($pirep);
|
2018-03-03 03:12:39 +08:00
|
|
|
$this->payGroundHandlingForPirep($pirep);
|
|
|
|
$this->payPilotForPirep($pirep);
|
|
|
|
|
|
|
|
$pirep->airline->journal->refresh();
|
|
|
|
$pirep->user->journal->refresh();
|
|
|
|
|
|
|
|
return $pirep;
|
|
|
|
}
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-03 07:29:11 +08:00
|
|
|
/**
|
|
|
|
* @param Pirep $pirep
|
|
|
|
*/
|
|
|
|
public function deleteFinancesForPirep(Pirep $pirep)
|
|
|
|
{
|
|
|
|
$this->journalRepo->deleteAllForObject($pirep);
|
|
|
|
}
|
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
/**
|
|
|
|
* Collect all of the fares and then post each fare class's profit and
|
|
|
|
* the costs for each seat and post it to the journal
|
|
|
|
* @param $pirep
|
2018-03-03 07:29:11 +08:00
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
2018-03-03 03:12:39 +08:00
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
*/
|
|
|
|
public function payFaresForPirep($pirep): void
|
|
|
|
{
|
2018-03-02 06:20:13 +08:00
|
|
|
$fares = $this->getReconciledFaresForPirep($pirep);
|
2018-03-03 07:29:11 +08:00
|
|
|
/** @var \App\Models\Fare $fare */
|
2018-03-03 03:12:39 +08:00
|
|
|
foreach ($fares as $fare) {
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
Log::info('Finance: PIREP: '.$pirep->id.', fare:', $fare->toArray());
|
2018-03-02 12:00:11 +08:00
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
$credit = Money::createFromAmount($fare->count * $fare->price);
|
|
|
|
$debit = Money::createFromAmount($fare->count * $fare->cost);
|
|
|
|
|
|
|
|
$this->journalRepo->post(
|
2018-03-03 03:12:39 +08:00
|
|
|
$pirep->airline->journal,
|
2018-03-02 06:20:13 +08:00
|
|
|
$credit,
|
|
|
|
$debit,
|
|
|
|
$pirep,
|
2018-03-03 03:12:39 +08:00
|
|
|
'Fares ' . $fare->code . $fare->count
|
2018-03-06 02:21:38 +08:00
|
|
|
.'; price: '.$fare->price.', cost: '.$fare->cost,
|
2018-03-02 06:20:13 +08:00
|
|
|
null,
|
2018-03-06 09:55:48 +08:00
|
|
|
'Fares'
|
2018-03-02 06:20:13 +08:00
|
|
|
);
|
|
|
|
}
|
2018-03-03 03:12:39 +08:00
|
|
|
}
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
/**
|
|
|
|
* Collect all of the expenses and apply those to the journal
|
|
|
|
* @param Pirep $pirep
|
2018-03-03 07:29:11 +08:00
|
|
|
* @throws \UnexpectedValueException
|
2018-03-03 03:12:39 +08:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function payExpensesForPirep(Pirep $pirep): void
|
|
|
|
{
|
2018-03-06 12:49:42 +08:00
|
|
|
$expenses = $this->expenseRepo->getAllForType(
|
|
|
|
ExpenseType::FLIGHT,
|
|
|
|
$pirep->airline_id
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go through the expenses and apply a mulitplier if present
|
|
|
|
*/
|
|
|
|
$expenses->map(function ($expense, $i) use ($pirep)
|
|
|
|
{
|
|
|
|
if ($expense->multiplier) {
|
|
|
|
# TODO: Modify the amount
|
|
|
|
}
|
2018-03-02 12:00:11 +08:00
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
Log::info('Finance: PIREP: ' . $pirep->id . ', expense:', $expense->toArray());
|
2018-03-02 12:00:11 +08:00
|
|
|
|
2018-03-06 12:49:42 +08:00
|
|
|
# Get the transaction group name from the ref_class name
|
|
|
|
# This way it can be more dynamic and don't have to add special
|
|
|
|
# tables or specific expense calls to accomodate all of these
|
|
|
|
$transaction_group = 'Expense';
|
|
|
|
if($expense->ref_class) {
|
|
|
|
$ref = explode('\\', $expense->ref_class);
|
|
|
|
$transaction_group = end($ref);
|
|
|
|
}
|
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
$debit = Money::createFromAmount($expense->amount);
|
|
|
|
$this->journalRepo->post(
|
2018-03-03 03:12:39 +08:00
|
|
|
$pirep->airline->journal,
|
2018-03-02 06:20:13 +08:00
|
|
|
null,
|
|
|
|
$debit,
|
|
|
|
$pirep,
|
|
|
|
'Expense: ' . $expense->name,
|
|
|
|
null,
|
2018-03-06 12:49:42 +08:00
|
|
|
$transaction_group
|
2018-03-02 06:20:13 +08:00
|
|
|
);
|
2018-03-06 12:49:42 +08:00
|
|
|
});
|
2018-03-03 03:12:39 +08:00
|
|
|
}
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
/**
|
2018-03-06 12:49:42 +08:00
|
|
|
* Collect all of the expenses from the listeners and apply those to the journal
|
2018-03-06 02:21:38 +08:00
|
|
|
* @param Pirep $pirep
|
2018-03-06 12:49:42 +08:00
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
2018-03-06 02:21:38 +08:00
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
*/
|
2018-03-06 12:49:42 +08:00
|
|
|
public function payExpensesEventsForPirep(Pirep $pirep): void
|
2018-03-06 02:21:38 +08:00
|
|
|
{
|
2018-03-06 12:49:42 +08:00
|
|
|
/**
|
|
|
|
* Throw an event and collect any expenses returned from it
|
|
|
|
*/
|
|
|
|
$gathered_expenses = event(new ExpensesEvent($pirep));
|
|
|
|
if (!\is_array($gathered_expenses)) {
|
2018-03-06 02:21:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-06 12:49:42 +08:00
|
|
|
foreach ($gathered_expenses as $event_expense) {
|
|
|
|
if (!\is_array($event_expense)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-06 02:21:38 +08:00
|
|
|
|
2018-03-06 12:49:42 +08:00
|
|
|
foreach ($event_expense as $expense) {
|
|
|
|
# Make sure it's of type expense Model
|
|
|
|
if (!($expense instanceof Expense)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-06 02:21:38 +08:00
|
|
|
|
2018-03-06 12:49:42 +08:00
|
|
|
# If an airline_id is filled, then see if it matches
|
|
|
|
if ($expense->airline_id !== $pirep->airline_id) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$debit = Money::createFromAmount($expense->amount);
|
|
|
|
|
|
|
|
$this->journalRepo->post(
|
|
|
|
$pirep->airline->journal,
|
|
|
|
null,
|
|
|
|
$debit,
|
|
|
|
$pirep,
|
|
|
|
'Expense: ' . $expense->name,
|
|
|
|
null,
|
|
|
|
$expense->transaction_group ?? 'Expenses'
|
|
|
|
);
|
|
|
|
}
|
2018-03-06 02:21:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
/**
|
|
|
|
* Collect and apply the ground handling cost
|
|
|
|
* @param Pirep $pirep
|
2018-03-03 07:29:11 +08:00
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
2018-03-03 03:12:39 +08:00
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
*/
|
|
|
|
public function payGroundHandlingForPirep(Pirep $pirep)
|
|
|
|
{
|
2018-03-02 06:20:13 +08:00
|
|
|
$ground_handling_cost = $this->getGroundHandlingCost($pirep);
|
2018-03-06 02:21:38 +08:00
|
|
|
Log::info('Finance: PIREP: '.$pirep->id.'; ground handling: '.$ground_handling_cost);
|
2018-03-02 06:20:13 +08:00
|
|
|
$this->journalRepo->post(
|
2018-03-03 03:12:39 +08:00
|
|
|
$pirep->airline->journal,
|
2018-03-02 06:20:13 +08:00
|
|
|
null,
|
|
|
|
Money::createFromAmount($ground_handling_cost),
|
|
|
|
$pirep,
|
2018-03-06 02:21:38 +08:00
|
|
|
'Ground Handling',
|
2018-03-02 06:20:13 +08:00
|
|
|
null,
|
2018-03-06 09:55:48 +08:00
|
|
|
'Ground Handling'
|
2018-03-02 06:20:13 +08:00
|
|
|
);
|
2018-03-03 03:12:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Figure out what the pilot pay is. Debit it from the airline journal
|
|
|
|
* But also reference the PIREP
|
|
|
|
* @param Pirep $pirep
|
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
|
|
|
*/
|
|
|
|
public function payPilotForPirep(Pirep $pirep)
|
|
|
|
{
|
|
|
|
$pilot_pay = $this->getPilotPay($pirep);
|
|
|
|
$pilot_pay_rate = $this->getPilotPayRateForPirep($pirep);
|
|
|
|
$memo = 'Pilot Payment @ ' . $pilot_pay_rate;
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
Log::info('Finance: PIREP: '.$pirep->id
|
|
|
|
.'; pilot pay: '.$pilot_pay_rate.', total: '.$pilot_pay);
|
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
$this->journalRepo->post(
|
|
|
|
$pirep->airline->journal,
|
|
|
|
null,
|
|
|
|
$pilot_pay,
|
|
|
|
$pirep,
|
|
|
|
$memo,
|
|
|
|
null,
|
2018-03-06 09:55:48 +08:00
|
|
|
'Pilot Pay'
|
2018-03-03 03:12:39 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->journalRepo->post(
|
|
|
|
$pirep->user->journal,
|
|
|
|
$pilot_pay,
|
|
|
|
null,
|
|
|
|
$pirep,
|
|
|
|
$memo,
|
|
|
|
null,
|
2018-03-06 09:55:48 +08:00
|
|
|
'Pilot Pay'
|
2018-03-03 03:12:39 +08:00
|
|
|
);
|
2018-03-02 06:20:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all of the fares for the PIREP. Reconcile the list;
|
|
|
|
* Get the fares that have been filled out for the PIREP, and
|
|
|
|
* then get the fares for the flight and subfleet. Then merge
|
|
|
|
* them together, and return the final list of:
|
|
|
|
* count = number of pax
|
|
|
|
* price = how much each pax unit paid
|
|
|
|
* capacity = max number of pax units
|
|
|
|
*
|
|
|
|
* If count > capacity, count will be adjusted to capacity
|
|
|
|
* @param $pirep
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
*/
|
|
|
|
public function getReconciledFaresForPirep($pirep)
|
|
|
|
{
|
|
|
|
$flight = $this->pirepSvc->findFlight($pirep);
|
|
|
|
|
|
|
|
# Collect all of the fares and prices
|
|
|
|
$flight_fares = $this->fareSvc->getForPirep($pirep);
|
2018-03-06 02:21:38 +08:00
|
|
|
Log::info('Finance: PIREP: ' . $pirep->id . ', flight fares: ', $flight_fares->toArray());
|
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
$all_fares = $this->fareSvc->getAllFares($flight, $pirep->aircraft->subfleet);
|
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
$fares = $all_fares->map(function($fare, $i) use ($flight_fares, $pirep) {
|
2018-03-02 06:20:13 +08:00
|
|
|
|
2018-03-06 02:21:38 +08:00
|
|
|
$fare_count = $flight_fares
|
|
|
|
->where('fare_id', $fare->id)
|
|
|
|
->first();
|
2018-03-02 06:20:13 +08:00
|
|
|
|
|
|
|
if($fare_count) {
|
2018-03-06 02:21:38 +08:00
|
|
|
|
|
|
|
Log::info('Finance: PIREP: ' . $pirep->id . ', fare count: '. $fare_count);
|
|
|
|
|
2018-03-02 06:20:13 +08:00
|
|
|
# If the count is greater than capacity, then just set it
|
|
|
|
# to the maximum amount
|
|
|
|
if($fare_count->count > $fare->capacity) {
|
|
|
|
$fare->count = $fare->capacity;
|
|
|
|
} else {
|
|
|
|
$fare->count = $fare_count->count;
|
|
|
|
}
|
2018-03-06 02:21:38 +08:00
|
|
|
} else {
|
|
|
|
Log::info('Finance: PIREP: ' . $pirep->id . ', no fare count found', $fare->toArray());
|
2018-03-02 06:20:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $fare;
|
|
|
|
});
|
|
|
|
|
|
|
|
return $fares;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the costs for the ground handling, with the multiplier
|
|
|
|
* being applied from the subfleet
|
|
|
|
* @param Pirep $pirep
|
|
|
|
* @return float|null
|
|
|
|
*/
|
|
|
|
public function getGroundHandlingCost(Pirep $pirep)
|
|
|
|
{
|
|
|
|
if(filled($pirep->aircraft->subfleet->ground_handling_multiplier)) {
|
|
|
|
// force into percent mode
|
|
|
|
$multiplier = $pirep->aircraft->subfleet->ground_handling_multiplier.'%';
|
2018-03-06 12:49:42 +08:00
|
|
|
return Math::applyAmountOrPercent(
|
2018-03-02 06:20:13 +08:00
|
|
|
$pirep->arr_airport->ground_handling_cost,
|
|
|
|
$multiplier
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $pirep->arr_airport->ground_handling_cost;
|
|
|
|
}
|
|
|
|
|
2018-02-28 04:29:45 +08:00
|
|
|
/**
|
|
|
|
* Return the pilot's hourly pay for the given PIREP
|
|
|
|
* @param Pirep $pirep
|
2018-02-28 06:16:40 +08:00
|
|
|
* @return float
|
2018-03-01 03:34:49 +08:00
|
|
|
* @throws \InvalidArgumentException
|
2018-02-28 04:29:45 +08:00
|
|
|
*/
|
2018-03-02 06:20:13 +08:00
|
|
|
public function getPilotPayRateForPirep(Pirep $pirep)
|
2018-02-28 04:29:45 +08:00
|
|
|
{
|
|
|
|
# Get the base rate for the rank
|
|
|
|
$rank = $pirep->user->rank;
|
2018-02-28 06:16:40 +08:00
|
|
|
$subfleet_id = $pirep->aircraft->subfleet_id;
|
|
|
|
|
|
|
|
# find the right subfleet
|
|
|
|
$override_rate = $rank->subfleets()
|
|
|
|
->where('subfleet_id', $subfleet_id)
|
2018-03-03 07:29:11 +08:00
|
|
|
->first();
|
|
|
|
|
|
|
|
if($override_rate) {
|
|
|
|
$override_rate = $override_rate->pivot;
|
|
|
|
}
|
2018-02-28 06:16:40 +08:00
|
|
|
|
2018-02-28 04:29:45 +08:00
|
|
|
if($pirep->source === PirepSource::ACARS) {
|
2018-03-03 03:12:39 +08:00
|
|
|
Log::debug('Source is ACARS');
|
2018-02-28 04:29:45 +08:00
|
|
|
$base_rate = $rank->acars_base_pay_rate;
|
2018-03-03 07:29:11 +08:00
|
|
|
|
|
|
|
if($override_rate) {
|
|
|
|
$override_rate = $override_rate->acars_pay;
|
|
|
|
}
|
|
|
|
|
2018-02-28 04:29:45 +08:00
|
|
|
} else {
|
2018-03-03 03:12:39 +08:00
|
|
|
Log::debug('Source is Manual');
|
2018-02-28 04:29:45 +08:00
|
|
|
$base_rate = $rank->manual_base_pay_rate;
|
2018-03-03 07:29:11 +08:00
|
|
|
|
|
|
|
if($override_rate) {
|
|
|
|
$override_rate = $override_rate->manual_pay;
|
|
|
|
}
|
2018-02-28 06:16:40 +08:00
|
|
|
}
|
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
Log::debug('pilot pay: base rate=' . $base_rate . ', override=' . $override_rate);
|
2018-03-06 12:49:42 +08:00
|
|
|
return Math::applyAmountOrPercent(
|
2018-03-02 06:20:13 +08:00
|
|
|
$base_rate,
|
|
|
|
$override_rate
|
|
|
|
);
|
2018-02-28 06:16:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the user's payment amount for a PIREP
|
|
|
|
* @param Pirep $pirep
|
|
|
|
* @return Money
|
2018-03-01 03:54:14 +08:00
|
|
|
* @throws \UnexpectedValueException
|
2018-02-28 06:16:40 +08:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
2018-03-03 03:12:39 +08:00
|
|
|
public function getPilotPay(Pirep $pirep)
|
2018-02-28 06:16:40 +08:00
|
|
|
{
|
2018-03-02 06:20:13 +08:00
|
|
|
$pilot_rate = $this->getPilotPayRateForPirep($pirep) / 60;
|
2018-03-01 03:34:49 +08:00
|
|
|
$payment = round($pirep->flight_time * $pilot_rate, 2);
|
2018-02-28 06:16:40 +08:00
|
|
|
|
2018-03-03 03:12:39 +08:00
|
|
|
Log::info('Pilot Payment: rate='.$pilot_rate);
|
|
|
|
$payment = Money::convertToSubunit($payment);
|
|
|
|
|
|
|
|
return new Money($payment);
|
2018-02-28 04:29:45 +08:00
|
|
|
}
|
2018-02-25 05:38:25 +08:00
|
|
|
}
|