|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LAShowroom\TaxJarBundle\Model\Transaction; |
|
4
|
|
|
|
|
5
|
|
|
use LAShowroom\TaxJarBundle\Model\LineItem as BaseLineItem; |
|
6
|
|
|
use Webmozart\Assert\Assert; |
|
7
|
|
|
|
|
8
|
|
|
class LineItem extends BaseLineItem |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var string |
|
12
|
|
|
*/ |
|
13
|
|
|
private $productIdentifier; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
private $description; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var float |
|
22
|
|
|
*/ |
|
23
|
|
|
private $salesTax; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return string |
|
27
|
|
|
*/ |
|
28
|
4 |
|
public function getDescription() |
|
29
|
|
|
{ |
|
30
|
4 |
|
return $this->description; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $description |
|
35
|
|
|
*/ |
|
36
|
8 |
|
public function setDescription($description) |
|
37
|
|
|
{ |
|
38
|
8 |
|
$this->description = mb_strimwidth($description, 0, 255, '...'); |
|
39
|
8 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return string |
|
43
|
|
|
*/ |
|
44
|
2 |
|
public function getProductIdentifier() |
|
45
|
|
|
{ |
|
46
|
2 |
|
return $this->productIdentifier; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $productIdentifier |
|
51
|
|
|
*/ |
|
52
|
6 |
|
public function setProductIdentifier($productIdentifier) |
|
53
|
|
|
{ |
|
54
|
6 |
|
$this->productIdentifier = $productIdentifier; |
|
55
|
6 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return float |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function getSalesTax() |
|
61
|
|
|
{ |
|
62
|
2 |
|
return $this->salesTax; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param float $salesTax |
|
67
|
|
|
*/ |
|
68
|
6 |
|
public function setSalesTax($salesTax) |
|
69
|
|
|
{ |
|
70
|
6 |
|
Assert::float($salesTax); |
|
71
|
|
|
|
|
72
|
6 |
|
$this->salesTax = $salesTax; |
|
73
|
6 |
|
} |
|
74
|
|
|
|
|
75
|
2 |
|
public function toArray() |
|
76
|
|
|
{ |
|
77
|
2 |
|
$result = parent::toArray(); |
|
78
|
|
|
|
|
79
|
2 |
|
if (!empty($this->description)) { |
|
80
|
2 |
|
$result['description'] = $this->description; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
2 |
|
if (!empty($this->productIdentifier)) { |
|
84
|
2 |
|
$result['product_identifier'] = $this->productIdentifier; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
2 |
|
if (!empty($this->salesTax)) { |
|
88
|
2 |
|
$result['sales_tax'] = $this->salesTax; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
2 |
|
return $result; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|