Completed
Push — master ( ad5f15...06e8c3 )
by Andrii
04:31
created

Purse   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 67
rs 10
c 2
b 0
f 0
ccs 0
cts 49
cp 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getFiles() 0 4 1
A rules() 0 17 1
A getClientModel() 0 4 1
A getContact() 0 4 1
A getRequisite() 0 4 1
A attributeLabels() 0 10 1
A scenarioActions() 0 7 1
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 Yii;
17
18
class Purse extends \hipanel\base\Model
19
{
20
    use \hipanel\base\ModelTrait;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function rules()
26
    {
27
        return [
28
            [['id', 'client_id', 'seller_id'], 'integer'],
29
            [['client', 'seller'], 'safe'],
30
            [['provided_services'], 'safe'],
31
            [['contact_id', 'requisite_id'], 'integer'],
32
            [['currency_id'], 'integer'],
33
            [['currency'], 'safe'],
34
            [['no'], 'integer'],
35
            [['credit', 'balance'], 'number'],
36
37
            [['month'], 'date', 'on' => 'update-monthly-invoice'],
38
            [['id', 'contact_id'], 'required', 'on' => ['update-contact']],
39
            [['id', 'requisite_id'], 'required', 'on' => ['update-requisite']],
40
        ];
41
    }
42
43
    public function getFiles()
44
    {
45
        return $this->hasMany(File::class, ['object_id' => 'id']);
46
    }
47
48
    public function getClientModel()
49
    {
50
        return $this->hasOne(Client::class, ['id' => 'client_id']);
51
    }
52
53
    public function getContact()
54
    {
55
        return $this->hasOne(Contact::class, ['id' => 'contact_id']);
56
    }
57
58
    public function getRequisite()
59
    {
60
        return $this->hasOne(Contact::class, ['id' => 'requisite_id']);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function attributeLabels()
67
    {
68
        return $this->mergeAttributeLabels([
69
            'provided_services' => Yii::t('hipanel:finance', 'Provided services'),
70
            'currency' => Yii::t('hipanel:finance', 'Currency'),
71
            'invoices' => Yii::t('hipanel:finance', 'Invoices'),
72
            'contact_id' => Yii::t('hipanel:finance', 'Contact'),
73
            'requisite_id' => Yii::t('hipanel:finance', 'Requisite'),
74
        ]);
75
    }
76
77
    public function scenarioActions()
78
    {
79
        return [
80
            'update-contact' => 'update',
81
            'update-requisite' => 'update',
82
        ];
83
    }
84
}
85