Transfer.php
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace App\Models\Banking;
use App\Models\Model;
use App\Traits\Currencies;
class Transfer extends Model
{
use Currencies;
protected $table = 'transfers';
/**
* Attributes that should be mass-assignable.
*
* @var array
*/
protected $fillable = ['company_id', 'payment_id', 'revenue_id'];
/**
* Sortable columns.
*
* @var array
*/
public $sortable = ['payment.paid_at', 'payment.amount', 'payment.name', 'revenue.name'];
public function payment()
{
return $this->belongsTo('App\Models\Expense\Payment');
}
public function paymentAccount()
{
return $this->belongsTo('App\Models\Banking\Account', 'payment.account_id', 'id');
}
public function revenue()
{
return $this->belongsTo('App\Models\Income\Revenue');
}
public function revenueAccount()
{
return $this->belongsTo('App\Models\Banking\Account', 'revenue.account_id', 'id');
}
public function getDynamicConvertedAmount($format = false)
{
return $this->dynamicConvert($this->default_currency_code, $this->amount, $this->currency_code, $this->currency_rate, $format);
}
public function getReverseConvertedAmount($format = false)
{
return $this->reverseConvert($this->amount, $this->currency_code, $this->currency_rate, $format);
}
public function getDivideConvertedAmount($format = false)
{
return $this->divide($this->amount, $this->currency_code, $this->currency_rate, $format);
}
}