|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Finance module for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
|
6
|
|
|
* @package hipanel-module-finance |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\models; |
|
12
|
|
|
|
|
13
|
|
|
use hipanel\models\File; |
|
14
|
|
|
use hipanel\modules\client\models\Client; |
|
15
|
|
|
use hipanel\modules\client\models\Contact; |
|
16
|
|
|
use hipanel\modules\document\models\Document; |
|
17
|
|
|
use Yii; |
|
18
|
|
|
|
|
19
|
|
|
class Purse extends \hipanel\base\Model |
|
20
|
|
|
{ |
|
21
|
|
|
use \hipanel\base\ModelTrait; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritdoc} |
|
25
|
|
|
*/ |
|
26
|
|
|
public function rules() |
|
27
|
|
|
{ |
|
28
|
|
|
return [ |
|
29
|
|
|
[['id', 'client_id', 'seller_id'], 'integer'], |
|
30
|
|
|
[['client', 'seller'], 'safe'], |
|
31
|
|
|
[['provided_services'], 'safe'], |
|
32
|
|
|
[['contact_id', 'requisite_id'], 'integer'], |
|
33
|
|
|
[['currency_id'], 'integer'], |
|
34
|
|
|
[['currency'], 'safe'], |
|
35
|
|
|
[['no'], 'integer'], |
|
36
|
|
|
[['credit', 'balance'], 'number'], |
|
37
|
|
|
|
|
38
|
|
|
[['id', 'contact_id'], 'required', 'on' => ['update-contact']], |
|
39
|
|
|
[['id', 'requisite_id'], 'required', 'on' => ['update-requisite']], |
|
40
|
|
|
|
|
41
|
|
|
[['month'], 'date', 'on' => 'generate-and-save-document'], |
|
42
|
|
|
[['type'], 'string', 'on' => 'generate-and-save-document'], |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getFiles() |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->hasMany(File::class, ['object_id' => 'id']); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getDocuments() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->hasMany(Document::class, ['object_id' => 'id']); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getClientModel() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->hasOne(Client::class, ['id' => 'client_id']); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getContact() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->hasOne(Contact::class, ['id' => 'contact_id']); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getRequisite() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->hasOne(Contact::class, ['id' => 'requisite_id']); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritdoc} |
|
73
|
|
|
*/ |
|
74
|
|
|
public function attributeLabels() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->mergeAttributeLabels([ |
|
77
|
|
|
'provided_services' => Yii::t('hipanel:finance', 'Provided services'), |
|
78
|
|
|
'currency' => Yii::t('hipanel:finance', 'Currency'), |
|
79
|
|
|
'invoices' => Yii::t('hipanel:finance', 'Invoices'), |
|
80
|
|
|
'contact_id' => Yii::t('hipanel:finance', 'Contact'), |
|
81
|
|
|
'requisite_id' => Yii::t('hipanel:finance', 'Requisite'), |
|
82
|
|
|
]); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function scenarioActions() |
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
'update-contact' => 'update', |
|
89
|
|
|
'update-requisite' => 'update', |
|
90
|
|
|
]; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|