Add field to charge an expense to a user #130
This commit is contained in:
@@ -16,6 +16,7 @@ class CreateExpensesTable extends Migration
|
|||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->unsignedInteger('amount');
|
$table->unsignedInteger('amount');
|
||||||
$table->unsignedTinyInteger('type');
|
$table->unsignedTinyInteger('type');
|
||||||
|
$table->boolean('charge_to_user')->nullable()->default(false);
|
||||||
$table->boolean('multiplier')->nullable()->default(0);
|
$table->boolean('multiplier')->nullable()->default(0);
|
||||||
$table->boolean('active')->nullable()->default(true);
|
$table->boolean('active')->nullable()->default(true);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ExpenseListener
|
|||||||
'type' => ExpenseType::FLIGHT,
|
'type' => ExpenseType::FLIGHT,
|
||||||
'amount' => 15000, # $150
|
'amount' => 15000, # $150
|
||||||
'transaction_group' => '',
|
'transaction_group' => '',
|
||||||
|
'charge_to_user' => true|false
|
||||||
]);*/
|
]);*/
|
||||||
|
|
||||||
return $expenses;
|
return $expenses;
|
||||||
|
|||||||
@@ -18,17 +18,19 @@ class Expense extends BaseModel
|
|||||||
'amount',
|
'amount',
|
||||||
'type',
|
'type',
|
||||||
'multiplier',
|
'multiplier',
|
||||||
|
'charge_to_user',
|
||||||
'ref_class',
|
'ref_class',
|
||||||
'ref_class_id',
|
'ref_class_id',
|
||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $rules = [
|
public static $rules = [
|
||||||
'active' => 'boolean',
|
'active' => 'boolean',
|
||||||
'airline_id' => 'integer',
|
'airline_id' => 'integer',
|
||||||
'amount' => 'float',
|
'amount' => 'float',
|
||||||
'multiplier' => 'bool',
|
'type' => 'integer',
|
||||||
'type' => 'integer',
|
'multiplier' => 'bool',
|
||||||
|
'charge_to_user' => 'bool',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,8 +173,16 @@ class PirepFinanceService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$debit = Money::createFromAmount($expense->amount);
|
$debit = Money::createFromAmount($expense->amount);
|
||||||
|
|
||||||
|
# If the expense is marked to charge it to a user (only applicable to Flight)
|
||||||
|
# then change the journal to the user's to debit there
|
||||||
|
$journal = $pirep->airline->journal;
|
||||||
|
if ($expense->charge_to_user) {
|
||||||
|
$journal = $pirep->user->journal;
|
||||||
|
}
|
||||||
|
|
||||||
$this->journalRepo->post(
|
$this->journalRepo->post(
|
||||||
$pirep->airline->journal,
|
$journal,
|
||||||
null,
|
null,
|
||||||
$debit,
|
$debit,
|
||||||
$pirep,
|
$pirep,
|
||||||
|
|||||||
Reference in New Issue
Block a user