|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* SaaS Link plugin for Craft CMS 3.x |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://workingconcept.com |
|
6
|
|
|
* @copyright Copyright (c) 2018 Working Concept Inc. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace workingconcept\saaslink\models\harvest; |
|
10
|
|
|
|
|
11
|
|
|
use craft\base\Model; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Harvest Invoice Line Item Model |
|
15
|
|
|
* https://help.getharvest.com/api-v2/invoices-api/invoices/invoices/#the-invoice-line-item-object |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
class HarvestInvoiceLineItem extends Model |
|
19
|
|
|
{ |
|
20
|
|
|
// Properties |
|
21
|
|
|
// ========================================================================= |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var int Unique ID for the line item. |
|
25
|
|
|
*/ |
|
26
|
|
|
public $id; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var object An object containing the associated project’s id, name, and code. |
|
30
|
|
|
*/ |
|
31
|
|
|
private $_project; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string The name of an invoice item category. |
|
35
|
|
|
*/ |
|
36
|
|
|
public $kind; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string Text description of the line item. |
|
40
|
|
|
*/ |
|
41
|
|
|
public $description; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var int The unit quantity of the item. |
|
45
|
|
|
*/ |
|
46
|
|
|
public $quantity; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var float The individual price per unit. |
|
50
|
|
|
*/ |
|
51
|
|
|
public $unit_price; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var float The line item subtotal (quantity * unit_price). |
|
55
|
|
|
*/ |
|
56
|
|
|
public $amount; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var bool Whether the invoice’s tax percentage applies to this line item. |
|
60
|
|
|
*/ |
|
61
|
|
|
public $taxed; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var bool Whether the invoice’s tax2 percentage applies to this line item. |
|
65
|
|
|
*/ |
|
66
|
|
|
public $taxed2; |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
// Public Methods |
|
70
|
|
|
// ========================================================================= |
|
71
|
|
|
|
|
72
|
|
|
public function getProject() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->_project; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function setProject($project) |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->_project = $project; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @inheritdoc |
|
84
|
|
|
*/ |
|
85
|
|
|
public function rules(): array |
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
[[ |
|
89
|
|
|
'id', |
|
90
|
|
|
'quantity', |
|
91
|
|
|
], 'number', 'integerOnly' => true], |
|
92
|
|
|
[['id'], 'required'], |
|
93
|
|
|
[[ |
|
94
|
|
|
'unit_price', |
|
95
|
|
|
'amount', |
|
96
|
|
|
], 'number', 'integerOnly' => false], |
|
97
|
|
|
[[ |
|
98
|
|
|
'kind', |
|
99
|
|
|
'description', |
|
100
|
|
|
], 'string'], |
|
101
|
|
|
[[ |
|
102
|
|
|
'taxed', |
|
103
|
|
|
'taxed2', |
|
104
|
|
|
], 'boolean'], |
|
105
|
|
|
]; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|