1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LAShowroom\TaxJarBundle\Model\Response; |
4
|
|
|
|
5
|
|
|
class TaxResponse |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var float |
9
|
|
|
*/ |
10
|
|
|
private $totalAmount; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var float |
14
|
|
|
*/ |
15
|
|
|
private $shipping; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var float |
19
|
|
|
*/ |
20
|
|
|
private $taxableAmount; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var float |
24
|
|
|
*/ |
25
|
|
|
private $amountToCollect; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var float |
29
|
|
|
*/ |
30
|
|
|
private $rate; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var bool |
34
|
|
|
*/ |
35
|
|
|
private $hasNexus; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
private $freightTaxable; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $taxSource; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var TaxBreakdown |
49
|
|
|
*/ |
50
|
|
|
private $taxBreakdown; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $userId; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var \DateTime(); |
59
|
|
|
*/ |
60
|
|
|
private $transactionDate; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
private $transactionReferenceId; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var float |
69
|
|
|
*/ |
70
|
|
|
private $salesTax; |
71
|
|
|
|
72
|
14 |
|
public function __construct(\stdClass $response) |
73
|
|
|
{ |
74
|
14 |
|
if (!empty($response->order_total_amount)) { |
75
|
8 |
|
$this->totalAmount = $response->order_total_amount; |
76
|
8 |
|
} elseif(!empty($response->amount)) { |
77
|
4 |
|
$this->totalAmount = $response->amount; |
78
|
|
|
} |
79
|
|
|
|
80
|
14 |
|
if (!empty($response->shipping)) { |
81
|
8 |
|
$this->shipping = $response->shipping; |
82
|
|
|
} |
83
|
|
|
|
84
|
14 |
|
if (!empty($response->taxable_amount)) { |
85
|
6 |
|
$this->taxableAmount = $response->taxable_amount; |
86
|
|
|
} |
87
|
|
|
|
88
|
14 |
|
if (!empty($response->amount_to_collect)) { |
89
|
6 |
|
$this->amountToCollect = $response->amount_to_collect; |
90
|
|
|
} |
91
|
|
|
|
92
|
14 |
|
if (!empty($response->rate)) { |
93
|
6 |
|
$this->rate = $response->rate; |
94
|
|
|
} |
95
|
|
|
|
96
|
14 |
|
if (!empty($response->has_nexus)) { |
97
|
6 |
|
$this->hasNexus = (bool) $response->has_nexus; |
98
|
|
|
} |
99
|
|
|
|
100
|
14 |
|
if (!empty($response->freight_taxable)) { |
101
|
2 |
|
$this->freightTaxable = (bool) $response->freight_taxable; |
102
|
|
|
} |
103
|
|
|
|
104
|
14 |
|
if (!empty($response->tax_source)) { |
105
|
6 |
|
$this->taxSource = $response->tax_source; |
106
|
|
|
} |
107
|
|
|
|
108
|
14 |
|
if (!empty($response->breakdown)) { |
109
|
6 |
|
$this->taxBreakdown = new TaxBreakdown($response->breakdown); |
110
|
|
|
} |
111
|
|
|
|
112
|
14 |
|
if (!empty($response->user_id)) { |
113
|
2 |
|
$this->userId = $response->user_id; |
114
|
|
|
} |
115
|
|
|
|
116
|
14 |
|
if (!empty($response->transaction_date)) { |
117
|
2 |
|
$this->transactionDate = new \DateTime($response->transaction_date); |
118
|
|
|
} |
119
|
|
|
|
120
|
14 |
|
if (!empty($response->transaction_reference_id)) { |
121
|
2 |
|
$this->transactionReferenceId = $response->transaction_reference_id; |
122
|
|
|
} |
123
|
|
|
|
124
|
14 |
|
if (!empty($response->sales_tax)) { |
125
|
2 |
|
$this->salesTax = $response->sales_tax; |
126
|
|
|
} |
127
|
14 |
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return float |
131
|
|
|
*/ |
132
|
6 |
|
public function getTotalAmount() |
133
|
|
|
{ |
134
|
6 |
|
return $this->totalAmount; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return float |
139
|
|
|
*/ |
140
|
4 |
|
public function getShipping() |
141
|
|
|
{ |
142
|
4 |
|
return $this->shipping; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return float |
147
|
|
|
*/ |
148
|
2 |
|
public function getTaxableAmount() |
149
|
|
|
{ |
150
|
2 |
|
return $this->taxableAmount; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return float |
155
|
|
|
*/ |
156
|
2 |
|
public function getAmountToCollect() |
157
|
|
|
{ |
158
|
2 |
|
return $this->amountToCollect; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return float |
163
|
|
|
*/ |
164
|
2 |
|
public function getRate() |
165
|
|
|
{ |
166
|
2 |
|
return $this->rate; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return bool |
171
|
|
|
*/ |
172
|
2 |
|
public function hasNexus() |
173
|
|
|
{ |
174
|
2 |
|
return $this->hasNexus; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return bool |
179
|
|
|
*/ |
180
|
4 |
|
public function isFreightTaxable() |
181
|
|
|
{ |
182
|
4 |
|
return $this->freightTaxable; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return string |
187
|
|
|
*/ |
188
|
2 |
|
public function getTaxSource() |
189
|
|
|
{ |
190
|
2 |
|
return $this->taxSource; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return TaxBreakdown |
195
|
|
|
*/ |
196
|
2 |
|
public function getTaxBreakdown() |
197
|
|
|
{ |
198
|
2 |
|
return $this->taxBreakdown; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
2 |
|
public function getUserId() |
205
|
|
|
{ |
206
|
2 |
|
return $this->userId; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return \DateTime |
211
|
|
|
*/ |
212
|
2 |
|
public function getTransactionDate() |
213
|
|
|
{ |
214
|
2 |
|
return $this->transactionDate; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return string |
219
|
|
|
*/ |
220
|
4 |
|
public function getTransactionReferenceId() |
221
|
|
|
{ |
222
|
4 |
|
return $this->transactionReferenceId; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return float |
227
|
|
|
*/ |
228
|
2 |
|
public function getSalesTax() |
229
|
|
|
{ |
230
|
2 |
|
return $this->salesTax; |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|