change ref_class to ref_model

This commit is contained in:
Nabeel Shahzad
2018-04-01 14:32:01 -05:00
parent 0bed38c78b
commit 793b3e7134
31 changed files with 211 additions and 211 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ $factory->define(App\Models\Award::class, function (Faker $faker) {
'id' => null, 'id' => null,
'name' => $faker->name, 'name' => $faker->name,
'description' => $faker->text(10), 'description' => $faker->text(10),
'ref_class' => null, 'ref_model' => null,
'ref_class_params' => null, 'ref_model_params' => null,
]; ];
}); });
+2 -2
View File
@@ -11,8 +11,8 @@ $factory->define(App\Models\Expense::class, function (Faker $faker) {
'amount' => $faker->randomFloat(2, 100, 1000), 'amount' => $faker->randomFloat(2, 100, 1000),
'type' => ExpenseType::FLIGHT, 'type' => ExpenseType::FLIGHT,
'multiplier' => false, 'multiplier' => false,
'ref_class' => \App\Models\Expense::class, 'ref_model' => \App\Models\Expense::class,
'ref_class_id' => null, 'ref_model_id' => null,
'active' => true, 'active' => true,
]; ];
}); });
@@ -21,13 +21,13 @@ class CreateAwardsTable extends Migration
# ref fields are expenses tied to some model object # ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs # EG, the airports has an internal expense for gate costs
$table->string('ref_class')->nullable(); $table->string('ref_model')->nullable();
$table->text('ref_class_params')->nullable(); $table->text('ref_model_params')->nullable();
#$table->string('ref_class_id', 36)->nullable(); #$table->string('ref_model_id', 36)->nullable();
$table->timestamps(); $table->timestamps();
$table->index(['ref_class']); $table->index(['ref_model']);
}); });
Schema::create('user_awards', function (Blueprint $table) { Schema::create('user_awards', function (Blueprint $table) {
@@ -21,12 +21,12 @@ class CreateExpensesTable extends Migration
# ref fields are expenses tied to some model object # ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs # EG, the airports has an internal expense for gate costs
$table->string('ref_class')->nullable(); $table->string('ref_model')->nullable();
$table->string('ref_class_id', 36)->nullable(); $table->string('ref_model_id', 36)->nullable();
$table->timestamps(); $table->timestamps();
$table->index(['ref_class', 'ref_class_id']); $table->index(['ref_model', 'ref_model_id']);
}); });
} }
@@ -22,15 +22,15 @@ class CreateJournalTransactionsTable extends Migration
$table->char('currency', 5); $table->char('currency', 5);
$table->text('memo')->nullable(); $table->text('memo')->nullable();
$table->string('tags')->nullable(); $table->string('tags')->nullable();
$table->string('ref_class', 50)->nullable(); $table->string('ref_model', 50)->nullable();
$table->string('ref_class_id', 36)->nullable(); $table->string('ref_model_id', 36)->nullable();
$table->timestamps(); $table->timestamps();
$table->date('post_date'); $table->date('post_date');
$table->primary('id'); $table->primary('id');
$table->index('journal_id'); $table->index('journal_id');
$table->index('transaction_group'); $table->index('transaction_group');
$table->index(['ref_class', 'ref_class_id']); $table->index(['ref_model', 'ref_model_id']);
}); });
} }
+35 -35
View File
@@ -98,8 +98,8 @@ awards:
name: Pilot 50 flights name: Pilot 50 flights
description: When a pilot has 50 flights, give this award description: When a pilot has 50 flights, give this award
image_url: image_url:
ref_class: App\Awards\PilotFlightAwards ref_model: App\Awards\PilotFlightAwards
ref_class_params: 50 ref_model_params: 50
created_at: now created_at: now
updated_at: now updated_at: now
@@ -194,52 +194,52 @@ expenses:
amount: 100 amount: 100
type: 0 type: 0
active: 1 active: 1
ref_class: App\Models\Expense ref_model: App\Models\Expense
- name: Per-Flight (multiplier) - name: Per-Flight (multiplier)
amount: 100 amount: 100
type: 0 type: 0
multiplier: 1 multiplier: 1
active: 1 active: 1
ref_class: App\Models\Expense ref_model: App\Models\Expense
- name: Per-Flight (multiplier, on airline) - name: Per-Flight (multiplier, on airline)
airline_id: 1 airline_id: 1
amount: 200 amount: 200
type: 0 type: 0
multiplier: 1 multiplier: 1
active: 1 active: 1
ref_class: App\Models\Expense ref_model: App\Models\Expense
- name: A daily fee - name: A daily fee
amount: 800 amount: 800
type: 1 type: 1
active: 1 active: 1
ref_class: App\Models\Expense ref_model: App\Models\Expense
- name: A monthly fee - name: A monthly fee
amount: 5000 amount: 5000
type: 2 type: 2
active: 1 active: 1
ref_class: App\Models\Expense ref_model: App\Models\Expense
- name: Catering - name: Catering
amount: 1000 amount: 1000
type: 0 type: 0
active: 1 active: 1
ref_class: App\Models\Subfleet ref_model: App\Models\Subfleet
ref_class_id: 1 ref_model_id: 1
created_at: now created_at: now
updated_at: now updated_at: now
- name: Catering Staff - name: Catering Staff
amount: 1000 amount: 1000
type: 1 type: 1
active: 1 active: 1
ref_class: App\Models\Subfleet ref_model: App\Models\Subfleet
ref_class_id: 1 ref_model_id: 1
created_at: now created_at: now
updated_at: now updated_at: now
- name: Maintenance - name: Maintenance
amount: 1000 amount: 1000
type: 1 type: 1
active: 1 active: 1
ref_class: App\Models\Aircraft ref_model: App\Models\Aircraft
ref_class_id: 1 ref_model_id: 1
created_at: now created_at: now
updated_at: now updated_at: now
@@ -519,8 +519,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Pilot Payment @ 50' memo: 'Pilot Payment @ 50'
tags: '"pilot_pay"' tags: '"pilot_pay"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -533,8 +533,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Expense: Per-Flight (no muliplier)' memo: 'Expense: Per-Flight (no muliplier)'
tags: '"expense"' tags: '"expense"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -547,8 +547,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Fares Y300; price: 200, cost: 0' memo: 'Fares Y300; price: 200, cost: 0'
tags: '"fare"' tags: '"fare"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -561,8 +561,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Expense: Per-Flight (multiplier, on airline)' memo: 'Expense: Per-Flight (multiplier, on airline)'
tags: '"expense"' tags: '"expense"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -575,8 +575,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Expense: Per-Flight (multiplier)' memo: 'Expense: Per-Flight (multiplier)'
tags: '"expense"' tags: '"expense"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -589,8 +589,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Subfleet Expense: Catering (747-43X RB211-524G)' memo: 'Subfleet Expense: Catering (747-43X RB211-524G)'
tags: '"subfleet"' tags: '"subfleet"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -603,8 +603,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Fares F10; price: 1000, cost: 0' memo: 'Fares F10; price: 1000, cost: 0'
tags: '"fare"' tags: '"fare"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: '2018-03-06 12:34:15' created_at: '2018-03-06 12:34:15'
updated_at: '2018-03-06 12:34:15' updated_at: '2018-03-06 12:34:15'
post_date: '2018-03-06 12:34:15' post_date: '2018-03-06 12:34:15'
@@ -617,8 +617,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Pilot Payment @ 50' memo: 'Pilot Payment @ 50'
tags: '"pilot_pay"' tags: '"pilot_pay"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: now created_at: now
updated_at: now updated_at: now
post_date: now post_date: now
@@ -631,8 +631,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Fares B10; price: 1100, cost: 0' memo: 'Fares B10; price: 1100, cost: 0'
tags: '"fare"' tags: '"fare"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: now created_at: now
updated_at: now updated_at: now
post_date: now post_date: now
@@ -645,8 +645,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Ground Handling' memo: 'Ground Handling'
tags: '"ground_handling"' tags: '"ground_handling"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: now created_at: now
updated_at: now updated_at: now
post_date: now post_date: now
@@ -660,8 +660,8 @@ journal_transactions:
currency: USD currency: USD
memo: 'Subfleet 744-3X-RB211: Block Time Cost' memo: 'Subfleet 744-3X-RB211: Block Time Cost'
tags: '"subfleet"' tags: '"subfleet"'
ref_class: App\Models\Pirep ref_model: App\Models\Pirep
ref_class_id: pirepid_1 ref_model_id: pirepid_1
created_at: now created_at: now
updated_at: now updated_at: now
post_date: now post_date: now
@@ -247,8 +247,8 @@ class AircraftController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$expense = new Expense($request->post()); $expense = new Expense($request->post());
$expense->ref_class = Aircraft::class; $expense->ref_model = Aircraft::class;
$expense->ref_class_id = $aircraft->id; $expense->ref_model_id = $aircraft->id;
$expense->save(); $expense->save();
} elseif ($request->isMethod('put')) { } elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id')); $expense = Expense::findOrFail($request->input('expense_id'));
@@ -255,8 +255,8 @@ class AirportController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$expense = new Expense($request->post()); $expense = new Expense($request->post());
$expense->ref_class = Airport::class; $expense->ref_model = Airport::class;
$expense->ref_class_id = $airport->id; $expense->ref_model_id = $airport->id;
$expense->save(); $expense->save();
} elseif ($request->isMethod('put')) { } elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id')); $expense = Expense::findOrFail($request->input('expense_id'));
@@ -53,7 +53,7 @@ class ExpenseController extends Controller
{ {
$this->expenseRepo->pushCriteria(new RequestCriteria($request)); $this->expenseRepo->pushCriteria(new RequestCriteria($request));
$expenses = $this->expenseRepo->findWhere([ $expenses = $this->expenseRepo->findWhere([
'ref_class' => Expense::class 'ref_model' => Expense::class
]); ]);
return view('admin.expenses.index', [ return view('admin.expenses.index', [
@@ -81,7 +81,7 @@ class ExpenseController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$input = $request->all(); $input = $request->all();
$input['ref_class'] = Expense::class; $input['ref_model'] = Expense::class;
$this->expenseRepo->create($input); $this->expenseRepo->create($input);
Flash::success('Expense saved successfully.'); Flash::success('Expense saved successfully.');
@@ -395,8 +395,8 @@ class SubfleetController extends Controller
*/ */
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$expense = new Expense($request->post()); $expense = new Expense($request->post());
$expense->ref_class = Subfleet::class; $expense->ref_model = Subfleet::class;
$expense->ref_class_id = $subfleet->id; $expense->ref_model_id = $subfleet->id;
$expense->save(); $expense->save();
} elseif ($request->isMethod('put')) { } elseif ($request->isMethod('put')) {
$expense = Expense::findOrFail($request->input('expense_id')); $expense = Expense::findOrFail($request->input('expense_id'));
+3 -3
View File
@@ -56,9 +56,9 @@ abstract class Award
final public function handle(): void final public function handle(): void
{ {
# Check if the params are a JSON object or array # Check if the params are a JSON object or array
$param = $this->award->ref_class_params; $param = $this->award->ref_model_params;
if (Utils::isObject($this->award->ref_class_params)) { if (Utils::isObject($this->award->ref_model_params)) {
$param = json_decode($this->award->ref_class_params); $param = json_decode($this->award->ref_model_params);
} }
if ($this->check($param)) { if ($this->check($param)) {
+8 -8
View File
@@ -7,8 +7,8 @@ use App\Interfaces\Model;
/** /**
* The Award model * The Award model
* @property mixed id * @property mixed id
* @property mixed ref_class * @property mixed ref_model
* @property mixed|null ref_class_params * @property mixed|null ref_model_params
* @package Award\Models * @package Award\Models
*/ */
class Award extends Model class Award extends Model
@@ -19,16 +19,16 @@ class Award extends Model
'name', 'name',
'description', 'description',
'image_url', 'image_url',
'ref_class', 'ref_model',
'ref_class_params', 'ref_model_params',
]; ];
public static $rules = [ public static $rules = [
'name' => 'required', 'name' => 'required',
'description' => 'nullable', 'description' => 'nullable',
'image_url' => 'nullable', 'image_url' => 'nullable',
'ref_class' => 'required', 'ref_model' => 'required',
'ref_class_params' => 'nullable' 'ref_model_params' => 'nullable'
]; ];
/** /**
@@ -39,12 +39,12 @@ class Award extends Model
*/ */
public function getReference(Award $award = null, User $user = null) public function getReference(Award $award = null, User $user = null)
{ {
if (!$this->ref_class) { if (!$this->ref_model) {
return null; return null;
} }
try { try {
return new $this->ref_class($award, $user); return new $this->ref_model($award, $user);
} catch (\Exception $e) { } catch (\Exception $e) {
return null; return null;
} }
+8 -8
View File
@@ -8,8 +8,8 @@ use App\Interfaces\Model;
* @property int airline_id * @property int airline_id
* @property float amount * @property float amount
* @property string name * @property string name
* @property string ref_class * @property string ref_model
* @property string ref_class_id * @property string ref_model_id
* @package App\Models * @package App\Models
*/ */
class Expense extends Model class Expense extends Model
@@ -23,8 +23,8 @@ class Expense extends Model
'type', 'type',
'multiplier', 'multiplier',
'charge_to_user', 'charge_to_user',
'ref_class', 'ref_model',
'ref_class_id', 'ref_model_id',
'active', 'active',
]; ];
@@ -42,18 +42,18 @@ class Expense extends Model
*/ */
public function getReference() public function getReference()
{ {
if (!$this->ref_class || !$this->ref_class_id) { if (!$this->ref_model || !$this->ref_model_id) {
return null; return null;
} }
if ($this->ref_class === __CLASS__) { if ($this->ref_model === __CLASS__) {
return $this; return $this;
} }
try { try {
$klass = new $this->ref_class; $klass = new $this->ref_model;
return $klass->find($this->ref_class_id); return $klass->find($this->ref_model_id);
} catch (\Exception $e) { } catch (\Exception $e) {
return null; return null;
} }
+2 -2
View File
@@ -130,8 +130,8 @@ class Journal extends Model
{ {
return $this return $this
->transactions() ->transactions()
->where('ref_class', \get_class($object)) ->where('ref_model', \get_class($object))
->where('ref_class_id', $object->id); ->where('ref_model_id', $object->id);
} }
/** /**
+9 -9
View File
@@ -16,8 +16,8 @@ use App\Interfaces\Model;
* @property string post_date * @property string post_date
* @property integer credit * @property integer credit
* @property integer debit * @property integer debit
* @property string ref_class * @property string ref_model
* @property integer ref_class_id * @property integer ref_model_id
* @property Journal journal * @property Journal journal
*/ */
class JournalTransaction extends Model class JournalTransaction extends Model
@@ -34,8 +34,8 @@ class JournalTransaction extends Model
'currency', 'currency',
'memo', 'memo',
'tags', 'tags',
'ref_class', 'ref_model',
'ref_class_id', 'ref_model_id',
'post_date' 'post_date'
]; ];
@@ -67,8 +67,8 @@ class JournalTransaction extends Model
*/ */
public function referencesObject($object) public function referencesObject($object)
{ {
$this->ref_class = \get_class($object); $this->ref_model = \get_class($object);
$this->ref_class_id = $object->id; $this->ref_model_id = $object->id;
$this->save(); $this->save();
return $this; return $this;
@@ -79,10 +79,10 @@ class JournalTransaction extends Model
*/ */
public function getReferencedObject() public function getReferencedObject()
{ {
if ($classname = $this->ref_class) { if ($classname = $this->ref_model) {
$klass = new $this->ref_class; $klass = new $this->ref_model;
return $klass->find($this->ref_class_id); return $klass->find($this->ref_model_id);
} }
return false; return false;
+2 -2
View File
@@ -375,8 +375,8 @@ class Pirep extends Model
public function transactions() public function transactions()
{ {
return $this->hasMany(JournalTransaction::class, 'ref_class_id') return $this->hasMany(JournalTransaction::class, 'ref_model_id')
->where('ref_class', __CLASS__) ->where('ref_model', __CLASS__)
->orderBy('credit', 'desc') ->orderBy('credit', 'desc')
->orderBy('debit', 'desc'); ->orderBy('debit', 'desc');
} }
+2 -2
View File
@@ -19,8 +19,8 @@ trait ExpensableTrait
return $this->morphMany( return $this->morphMany(
Expense::class, Expense::class,
'expenses', # overridden by the next two anyway 'expenses', # overridden by the next two anyway
'ref_class', 'ref_model',
'ref_class_id' 'ref_model_id'
); );
} }
} }
+6 -6
View File
@@ -26,18 +26,18 @@ class ExpenseRepository extends Repository implements CacheableInterface
* include expenses for a given airline ID * include expenses for a given airline ID
* @param $type * @param $type
* @param null $airline_id * @param null $airline_id
* @param null $ref_class * @param null $ref_model
* @return Collection * @return Collection
*/ */
public function getAllForType($type, $airline_id = null, $ref_class = null) public function getAllForType($type, $airline_id = null, $ref_model = null)
{ {
$where = [ $where = [
'type' => $type, 'type' => $type,
['airline_id', '=', null] ['airline_id', '=', null]
]; ];
if ($ref_class) { if ($ref_model) {
$where['ref_class'] = $ref_class; $where['ref_model'] = $ref_model;
} }
$expenses = $this->findWhere($where); $expenses = $this->findWhere($where);
@@ -48,8 +48,8 @@ class ExpenseRepository extends Repository implements CacheableInterface
'airline_id' => $airline_id 'airline_id' => $airline_id
]; ];
if ($ref_class) { if ($ref_model) {
$where['ref_class'] = $ref_class; $where['ref_model'] = $ref_model;
} }
$airline_expenses = $this->findWhere($where); $airline_expenses = $this->findWhere($where);
+6 -6
View File
@@ -113,8 +113,8 @@ class JournalRepository extends Repository implements CacheableInterface
]; ];
if ($reference !== null) { if ($reference !== null) {
$attrs['ref_class'] = \get_class($reference); $attrs['ref_model'] = \get_class($reference);
$attrs['ref_class_id'] = $reference->id; $attrs['ref_model_id'] = $reference->id;
} }
try { try {
@@ -238,8 +238,8 @@ class JournalRepository extends Repository implements CacheableInterface
public function getAllForObject($object, $journal = null, Carbon $date = null) public function getAllForObject($object, $journal = null, Carbon $date = null)
{ {
$where = [ $where = [
'ref_class' => \get_class($object), 'ref_model' => \get_class($object),
'ref_class_id' => $object->id, 'ref_model_id' => $object->id,
]; ];
if ($journal) { if ($journal) {
@@ -272,8 +272,8 @@ class JournalRepository extends Repository implements CacheableInterface
public function deleteAllForObject($object, $journal = null) public function deleteAllForObject($object, $journal = null)
{ {
$where = [ $where = [
'ref_class' => \get_class($object), 'ref_model' => \get_class($object),
'ref_class_id' => $object->id, 'ref_model_id' => $object->id,
]; ];
if ($journal) { if ($journal) {
+5 -5
View File
@@ -200,19 +200,19 @@ class PirepFinanceService extends Service
Log::info('Finance: PIREP: '.$pirep->id.', expense:', $expense->toArray()); Log::info('Finance: PIREP: '.$pirep->id.', expense:', $expense->toArray());
# Get the transaction group name from the ref_class name # Get the transaction group name from the ref_model name
# This way it can be more dynamic and don't have to add special # This way it can be more dynamic and don't have to add special
# tables or specific expense calls to accomodate all of these # tables or specific expense calls to accomodate all of these
$klass = 'Expense'; $klass = 'Expense';
if ($expense->ref_class) { if ($expense->ref_model) {
$ref = explode('\\', $expense->ref_class); $ref = explode('\\', $expense->ref_model);
$klass = end($ref); $klass = end($ref);
} }
# Form the memo, with some specific ones depending on the group # Form the memo, with some specific ones depending on the group
if ($klass === 'Airport') { if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_class_id})"; $memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_class_id}"; $transaction_group = "Airport: {$expense->ref_model_id}";
} elseif ($klass === 'Subfleet') { } elseif ($klass === 'Subfleet') {
$memo = "Subfleet Expense: {$expense->name} ({$pirep->aircraft->subfleet->name})"; $memo = "Subfleet Expense: {$expense->name} ({$pirep->aircraft->subfleet->name})";
$transaction_group = "Subfleet: {$expense->name} ({$pirep->aircraft->subfleet->name})"; $transaction_group = "Subfleet: {$expense->name} ({$pirep->aircraft->subfleet->name})";
@@ -57,15 +57,15 @@ class RecurringFinanceService extends Service
protected function getMemoAndGroup(Expense $expense): array protected function getMemoAndGroup(Expense $expense): array
{ {
$klass = 'Expense'; $klass = 'Expense';
if ($expense->ref_class) { if ($expense->ref_model) {
$ref = explode('\\', $expense->ref_class); $ref = explode('\\', $expense->ref_model);
$klass = end($ref); $klass = end($ref);
$obj = $expense->getReference(); $obj = $expense->getReference();
} }
if ($klass === 'Airport') { if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_class_id})"; $memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_class_id}"; $transaction_group = "Airport: {$expense->ref_model_id}";
} elseif ($klass === 'Subfleet') { } elseif ($klass === 'Subfleet') {
$memo = "Subfleet Expense: {$expense->name}"; $memo = "Subfleet Expense: {$expense->name}";
$transaction_group = "Subfleet: {$expense->name}"; $transaction_group = "Subfleet: {$expense->name}";
@@ -111,8 +111,8 @@ class RecurringFinanceService extends Service
# against this specific journal, on today # against this specific journal, on today
$w = [ $w = [
'journal_id' => $journal->id, 'journal_id' => $journal->id,
'ref_class' => Expense::class, 'ref_model' => Expense::class,
'ref_class_id' => $expense->id, 'ref_model_id' => $expense->id,
]; ];
$found = JournalTransaction::where($w) $found = JournalTransaction::where($w)
+11 -11
View File
@@ -48,26 +48,26 @@ class ExpenseExporter extends ImportExport
// For the different expense types, instead of exporting // For the different expense types, instead of exporting
// the ID, export a specific column // the ID, export a specific column
if ($expense->ref_class === Expense::class) { if ($expense->ref_model === Expense::class) {
$ret['ref_class'] = ''; $ret['ref_model'] = '';
$ret['ref_class_id'] = ''; $ret['ref_model_id'] = '';
} else { } else {
$obj = $expense->getReference(); $obj = $expense->getReference();
if(!$obj) { // bail out if(!$obj) { // bail out
return $ret; return $ret;
} }
if ($expense->ref_class === Aircraft::class) { if ($expense->ref_model === Aircraft::class) {
$ret['ref_class_id'] = $obj->registration; $ret['ref_model_id'] = $obj->registration;
} elseif ($expense->ref_class === Airport::class) { } elseif ($expense->ref_model === Airport::class) {
$ret['ref_class_id'] = $obj->icao; $ret['ref_model_id'] = $obj->icao;
} elseif ($expense->ref_class === Subfleet::class) { } elseif ($expense->ref_model === Subfleet::class) {
$ret['ref_class_id'] = $obj->type; $ret['ref_model_id'] = $obj->type;
} }
} }
// And convert the ref_class into the shorter name // And convert the ref_model into the shorter name
$ret['ref_class'] = str_replace('App\Models\\', '', $ret['ref_class']); $ret['ref_model'] = str_replace('App\Models\\', '', $ret['ref_model']);
return $ret; return $ret;
} }
+11 -11
View File
@@ -30,8 +30,8 @@ class ExpenseImporter extends ImportExport
'charge_to_user' => 'nullable|boolean', 'charge_to_user' => 'nullable|boolean',
'multiplier' => 'nullable|numeric', 'multiplier' => 'nullable|numeric',
'active' => 'nullable|boolean', 'active' => 'nullable|boolean',
'ref_class' => 'nullable', 'ref_model' => 'nullable',
'ref_class_id' => 'nullable', 'ref_model_id' => 'nullable',
]; ];
/** /**
@@ -70,27 +70,27 @@ class ExpenseImporter extends ImportExport
} }
/** /**
* See if this expense refers to a ref_class * See if this expense refers to a ref_model
* @param array $row * @param array $row
* @return array * @return array
*/ */
protected function getRefClassInfo(array $row) protected function getRefClassInfo(array $row)
{ {
$row['ref_class'] = trim($row['ref_class']); $row['ref_model'] = trim($row['ref_model']);
// class from import is being saved as the name of the model only // class from import is being saved as the name of the model only
// prepend the full class path so we can search it out // prepend the full class path so we can search it out
if (\strlen($row['ref_class']) > 0) { if (\strlen($row['ref_model']) > 0) {
if (substr_count($row['ref_class'], 'App\Models\\') === 0) { if (substr_count($row['ref_model'], 'App\Models\\') === 0) {
$row['ref_class'] = 'App\Models\\'.$row['ref_class']; $row['ref_model'] = 'App\Models\\'.$row['ref_model'];
} }
} else { } else {
$row['ref_class'] = Expense::class; $row['ref_model'] = Expense::class;
return $row; return $row;
} }
$class = $row['ref_class']; $class = $row['ref_model'];
$id = $row['ref_class_id']; $id = $row['ref_model_id'];
$obj = null; $obj = null;
if ($class === Aircraft::class) { if ($class === Aircraft::class) {
@@ -110,7 +110,7 @@ class ExpenseImporter extends ImportExport
return $row; return $row;
} }
$row['ref_class_id'] = $obj->id; $row['ref_model_id'] = $obj->id;
return $row; return $row;
} }
} }
Generated
+56 -56
View File
@@ -168,7 +168,7 @@
"Arrilot\\Widgets\\": "src/" "Arrilot\\Widgets\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -223,7 +223,7 @@
"Cache\\Adapter\\Common\\": "" "Cache\\Adapter\\Common\\": ""
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -291,7 +291,7 @@
"/Tests/" "/Tests/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -353,7 +353,7 @@
"/Tests/" "/Tests/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -408,7 +408,7 @@
"Cache\\TagInterop\\": "" "Cache\\TagInterop\\": ""
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -527,7 +527,7 @@
"Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -643,7 +643,7 @@
"Cron\\": "src/Cron/" "Cron\\": "src/Cron/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -703,7 +703,7 @@
"Egulias\\EmailValidator\\": "EmailValidator" "Egulias\\EmailValidator\\": "EmailValidator"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -868,7 +868,7 @@
"src/functions_include.php" "src/functions_include.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -923,7 +923,7 @@
"src/functions_include.php" "src/functions_include.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -985,7 +985,7 @@
"Hashids\\": "src/" "Hashids\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1120,7 +1120,7 @@
"Irazasyed\\LaravelGAMP\\": "src/" "Irazasyed\\LaravelGAMP\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1167,7 +1167,7 @@
"Jackiedo\\Timezonelist\\": "src/Jackiedo/Timezonelist" "Jackiedo\\Timezonelist\\": "src/Jackiedo/Timezonelist"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1220,7 +1220,7 @@
"stubs/" "stubs/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1271,7 +1271,7 @@
"Joshbrw\\LaravelModuleInstaller\\": "src/" "Joshbrw\\LaravelModuleInstaller\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1304,7 +1304,7 @@
"Traitor\\": "src/" "Traitor\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1363,7 +1363,7 @@
"src/Laracasts/Flash/functions.php" "src/Laracasts/Flash/functions.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1378,16 +1378,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.6.14", "version": "v5.6.15",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "fba33e59fd43661933e9cecb84dfb0a64c5323ce" "reference": "baa42cf6bdd942523fafece21ec16a1843c6db0f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/fba33e59fd43661933e9cecb84dfb0a64c5323ce", "url": "https://api.github.com/repos/laravel/framework/zipball/baa42cf6bdd942523fafece21ec16a1843c6db0f",
"reference": "fba33e59fd43661933e9cecb84dfb0a64c5323ce", "reference": "baa42cf6bdd942523fafece21ec16a1843c6db0f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1512,7 +1512,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2018-03-28T14:17:03+00:00" "time": "2018-03-30T13:29:58+00:00"
}, },
{ {
"name": "laravelcollective/html", "name": "laravelcollective/html",
@@ -1839,7 +1839,7 @@
"League\\ISO3166\\": "src" "League\\ISO3166\\": "src"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2032,7 +2032,7 @@
"VaCentral\\": "src/" "VaCentral\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2189,7 +2189,7 @@
"src/helpers.php" "src/helpers.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2298,7 +2298,7 @@
"Http\\Discovery\\": "src/" "Http\\Discovery\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2351,7 +2351,7 @@
"PhpUnitsOfMeasure\\": "source/" "PhpUnitsOfMeasure\\": "source/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2474,7 +2474,7 @@
"PragmaRX\\Yaml\\Tests\\": "tests/" "PragmaRX\\Yaml\\Tests\\": "tests/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2535,7 +2535,7 @@
"Prettus\\Repository\\": "src/Prettus/Repository/" "Prettus\\Repository\\": "src/Prettus/Repository/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2624,7 +2624,7 @@
"Psr\\Cache\\": "src/" "Psr\\Cache\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -2888,7 +2888,7 @@
"Ramsey\\Uuid\\": "src/" "Ramsey\\Uuid\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -3171,7 +3171,7 @@
"Spatie\\Pjax\\": "src" "Spatie\\Pjax\\": "src"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -3822,7 +3822,7 @@
"bootstrap.php" "bootstrap.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -3878,7 +3878,7 @@
"bootstrap.php" "bootstrap.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -4397,7 +4397,7 @@
"TheIconic\\Tracking\\GoogleAnalytics\\": "src/" "TheIconic\\Tracking\\GoogleAnalytics\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -4442,7 +4442,7 @@
"TijsVerkoyen\\CssToInlineStyles\\": "src" "TijsVerkoyen\\CssToInlineStyles\\": "src"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -4483,7 +4483,7 @@
"Tivie\\OS\\": "src/" "Tivie\\OS\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"APACHE 2.0" "APACHE 2.0"
], ],
@@ -4601,7 +4601,7 @@
"src/vierbergenlars/SemVer/internal.php" "src/vierbergenlars/SemVer/internal.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -4706,7 +4706,7 @@
"Webpatser\\Uuid": "src/" "Webpatser\\Uuid": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -4762,7 +4762,7 @@
"/Tests/" "/Tests/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -4833,7 +4833,7 @@
"Barryvdh\\LaravelIdeHelper\\": "src" "Barryvdh\\LaravelIdeHelper\\": "src"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5041,7 +5041,7 @@
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5098,7 +5098,7 @@
"Whoops\\": "src/Whoops/" "Whoops\\": "src/Whoops/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5303,7 +5303,7 @@
"JakubOnderka\\PhpConsoleColor": "src/" "JakubOnderka\\PhpConsoleColor": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-2-Clause" "BSD-2-Clause"
], ],
@@ -5347,7 +5347,7 @@
"JakubOnderka\\PhpConsoleHighlighter": "src/" "JakubOnderka\\PhpConsoleHighlighter": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5456,7 +5456,7 @@
"src/DeepCopy/deep_copy.php" "src/DeepCopy/deep_copy.php"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5726,7 +5726,7 @@
] ]
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5822,7 +5822,7 @@
"Prophecy\\": "src/" "Prophecy\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -5892,7 +5892,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -5940,7 +5940,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6031,7 +6031,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6081,7 +6081,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6215,7 +6215,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6312,7 +6312,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6375,7 +6375,7 @@
"src/" "src/"
] ]
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
@@ -6925,7 +6925,7 @@
"Webmozart\\Assert\\": "src/" "Webmozart\\Assert\\": "src/"
} }
}, },
"notification-url": "http://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -46,20 +46,20 @@
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
<div> <div>
{{ Form::label('ref_class', 'Award Class:') }} {{ Form::label('ref_model', 'Award Class:') }}
{{ Form::select('ref_class', $award_classes, null , [ {{ Form::select('ref_model', $award_classes, null , [
'class' => 'form-control select2', 'class' => 'form-control select2',
'id' => 'award_class_select', 'id' => 'award_class_select',
]) }} ]) }}
<p class="text-danger">{{ $errors->first('ref_class') }}</p> <p class="text-danger">{{ $errors->first('ref_model') }}</p>
</div> </div>
<div> <div>
{{ Form::label('ref_class_params', 'Award Class parameters') }} {{ Form::label('ref_model_params', 'Award Class parameters') }}
{{ Form::text('ref_class_params', null, ['class' => 'form-control']) }} {{ Form::text('ref_model_params', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('ref_class_params') }}</p> <p class="text-danger">{{ $errors->first('ref_model_params') }}</p>
<p id="ref_class_param_description"> <p id="ref_model_param_description">
</p> </p>
</div> </div>
@@ -9,7 +9,7 @@
const changeParamDescription = (award_class) => { const changeParamDescription = (award_class) => {
const descrip = award_descriptions[award_class]; const descrip = award_descriptions[award_class];
console.log('Found description: ', descrip); console.log('Found description: ', descrip);
$("p#ref_class_param_description").text(descrip); $("p#ref_model_param_description").text(descrip);
}; };
$(document).ready(() => { $(document).ready(() => {
+2 -2
View File
@@ -30,8 +30,8 @@ class AwardsTest extends TestCase
{ {
// Create one award that's given out with one flight // Create one award that's given out with one flight
$award = factory(App\Models\Award::class)->create([ $award = factory(App\Models\Award::class)->create([
'ref_class' => App\Awards\PilotFlightAwards::class, 'ref_model' => App\Awards\PilotFlightAwards::class,
'ref_class_params' => 1, 'ref_model_params' => 1,
]); ]);
$user = factory(App\Models\User::class)->create([ $user = factory(App\Models\User::class)->create([
+3 -3
View File
@@ -101,8 +101,8 @@ class FinanceTest extends TestCase
# Add a subfleet expense # Add a subfleet expense
factory(App\Models\Expense::class)->create([ factory(App\Models\Expense::class)->create([
'ref_class' => \App\Models\Subfleet::class, 'ref_model' => \App\Models\Subfleet::class,
'ref_class_id' => $subfleet['subfleet']->id, 'ref_model_id' => $subfleet['subfleet']->id,
'amount' => 200 'amount' => 200
]); ]);
@@ -605,7 +605,7 @@ class FinanceTest extends TestCase
factory(App\Models\Expense::class)->create([ factory(App\Models\Expense::class)->create([
'airline_id' => null, 'airline_id' => null,
'ref_class' => \App\Models\Subfleet::class, 'ref_model' => \App\Models\Subfleet::class,
]); ]);
$expenses = $this->expenseRepo->getAllForType( $expenses = $this->expenseRepo->getAllForType(
+4 -4
View File
@@ -386,12 +386,12 @@ class ImporterTest extends TestCase
$catering = $expenses->where('name', 'Catering Staff')->first(); $catering = $expenses->where('name', 'Catering Staff')->first();
$this->assertEquals(1000, $catering->amount); $this->assertEquals(1000, $catering->amount);
$this->assertEquals(\App\Models\Enums\ExpenseType::DAILY, $catering->type); $this->assertEquals(\App\Models\Enums\ExpenseType::DAILY, $catering->type);
$this->assertEquals(\App\Models\Subfleet::class, $catering->ref_class); $this->assertEquals(\App\Models\Subfleet::class, $catering->ref_model);
$this->assertEquals($subfleet->id, $catering->ref_class_id); $this->assertEquals($subfleet->id, $catering->ref_model_id);
$mnt = $expenses->where('name', 'Maintenance')->first(); $mnt = $expenses->where('name', 'Maintenance')->first();
$this->assertEquals(\App\Models\Aircraft::class, $mnt->ref_class); $this->assertEquals(\App\Models\Aircraft::class, $mnt->ref_model);
$this->assertEquals($aircraft->id, $mnt->ref_class_id); $this->assertEquals($aircraft->id, $mnt->ref_model_id);
} }
/** /**
+1 -1
View File
@@ -1,4 +1,4 @@
airline,name,amount,type,charge_to_user,multiplier,active,ref_class,ref_class_id airline,name,amount,type,charge_to_user,multiplier,active,ref_model,ref_model_id
,"Per-Flight (no muliplier)",100,F,0,0,1,, ,"Per-Flight (no muliplier)",100,F,0,0,1,,
,"Per-Flight (multiplier)",100,F,0,1,1,, ,"Per-Flight (multiplier)",100,F,0,1,1,,
VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,, VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,,
1 airline name amount type charge_to_user multiplier active ref_class ref_model ref_class_id ref_model_id
2 Per-Flight (no muliplier) 100 F 0 0 1
3 Per-Flight (multiplier) 100 F 0 1 1
4 VMS Per-Flight (multiplier, on airline) 200 F 0 1 1
+1 -1
View File
@@ -1,4 +1,4 @@
airline,name,amount,type,charge_to_user,multiplier,active,ref_class,ref_class_id airline,name,amount,type,charge_to_user,multiplier,active,ref_model,ref_model_id
,"Per-Flight (no muliplier)",100,F,0,0,1,, ,"Per-Flight (no muliplier)",100,F,0,0,1,,
,"Per-Flight (multiplier)",100,F,0,1,1,, ,"Per-Flight (multiplier)",100,F,0,1,1,,
VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,, VMS,"Per-Flight (multiplier, on airline)",200,F,0,1,1,,
1 airline name amount type charge_to_user multiplier active ref_class ref_model ref_class_id ref_model_id
2 Per-Flight (no muliplier) 100 F 0 0 1
3 Per-Flight (multiplier) 100 F 0 1 1
4 VMS Per-Flight (multiplier, on airline) 200 F 0 1 1