Completed
Push — master ( 67e324...0b8c6e )
by Andrii
09:22
created

Purse::scenarioCommands()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
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\Contact;
15
use Yii;
16
17
class Purse extends \hipanel\base\Model
18
{
19
    use \hipanel\base\ModelTrait;
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function rules()
25
    {
26
        return [
27
            [['id', 'client_id', 'seller_id'], 'integer'],
28
            [['client', 'seller'], 'safe'],
29
            [['provided_services'], 'safe'],
30
            [['contact_id', 'requisite_id'], 'integer'],
31
            [['currency_id'], 'integer'],
32
            [['currency'], 'safe'],
33
            [['no'], 'integer'],
34
            [['credit', 'balance'], 'number'],
35
36
            [['month'], 'date', 'on' => 'update-monthly-invoice'],
37
            [['id', 'contact_id'], 'required', 'on' => ['update-contact']],
38
            [['id', 'requisite_id'], 'required', 'on' => ['update-requisite']],
39
        ];
40
    }
41
42
    public function getFiles()
43
    {
44
        return $this->hasMany(File::class, ['object_id' => 'id']);
45
    }
46
47
    public function getContact()
48
    {
49
        return $this->hasOne(Contact::class, ['id' => 'contact_id']);
50
    }
51
52
    public function getRequisite()
53
    {
54
        return $this->hasOne(Contact::class, ['id' => 'requisite_id']);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function attributeLabels()
61
    {
62
        return $this->mergeAttributeLabels([
63
            'provided_services' => Yii::t('hipanel:finance', 'Provided services'),
64
            'currency' => Yii::t('hipanel:finance', 'Currency'),
65
            'invoices' => Yii::t('hipanel:finance', 'Invoices'),
66
            'contact_id' => Yii::t('hipanel:finance', 'Contact'),
67
            'requisite_id' => Yii::t('hipanel:finance', 'Requisite'),
68
        ]);
69
    }
70
71
    public function scenarioActions()
72
    {
73
        return [
74
            'update-contact' => 'update',
75
            'update-requisite' => 'update',
76
        ];
77
    }
78
}
79