Implement events for cron expenses; add processing of daily/monthly expenses #136
This commit is contained in:
@@ -4,8 +4,11 @@ namespace App\Models;
|
||||
|
||||
/**
|
||||
* Class Expense
|
||||
* @property int airline_id
|
||||
* @property float amount
|
||||
* @property string name
|
||||
* @property string ref_class
|
||||
* @property string ref_class_id
|
||||
* @package App\Models
|
||||
*/
|
||||
class Expense extends BaseModel
|
||||
@@ -33,6 +36,27 @@ class Expense extends BaseModel
|
||||
'charge_to_user' => 'bool',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the referring object
|
||||
*/
|
||||
public function getReference()
|
||||
{
|
||||
if (!$this->ref_class || !$this->ref_class_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($this->ref_class === __CLASS__) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
try {
|
||||
$klass = new $this->ref_class;
|
||||
return $klass->find($this->ref_class_id);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Foreign Keys
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class Journal
|
||||
* @package Scottlaurent\Accounting
|
||||
* @property mixed id
|
||||
* @property Money $balance
|
||||
* @property string $currency
|
||||
* @property Carbon $updated_at
|
||||
|
||||
@@ -41,6 +41,13 @@ class JournalTransaction extends BaseModel
|
||||
'tags' => 'array',
|
||||
];
|
||||
|
||||
protected $dateFormat = 'Y-m-d';
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'post_date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Callbacks
|
||||
* @throws \UnexpectedValueException
|
||||
|
||||
Reference in New Issue
Block a user