1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
4
|
|
|
* |
5
|
|
|
* NOTICE OF LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* @copyright Copyright (c) 2013-2015 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace eBayEnterprise\RetailOrderManagement\Payload\Checkout; |
17
|
|
|
|
18
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayload; |
19
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap; |
20
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator; |
21
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator; |
22
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\Order\Tax as OrderTax; |
23
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\PayloadFactory; |
24
|
|
|
use Psr\Log\LoggerInterface; |
25
|
|
|
use Psr\Log\NullLogger; |
26
|
|
|
|
27
|
|
|
class Tax extends OrderTax implements ITax |
28
|
|
|
{ |
29
|
|
|
use TInvoiceTextCodeContainer; |
30
|
|
|
|
31
|
|
|
const ROOT_NODE = 'Tax'; |
32
|
|
|
|
33
|
|
|
/** @var float */ |
34
|
|
|
protected $exemptAmount; |
35
|
|
|
/** @var float */ |
36
|
|
|
protected $nonTaxableAmount; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param IValidatorIterator |
40
|
|
|
* @param ISchemaValidator |
41
|
|
|
* @param IPayloadMap |
42
|
|
|
* @param LoggerInterface |
43
|
|
|
* @param IPayload |
44
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
45
|
|
|
*/ |
46
|
|
|
public function __construct( |
47
|
|
|
IValidatorIterator $validators, |
48
|
|
|
ISchemaValidator $schemaValidator, |
49
|
|
|
IPayloadMap $payloadMap, |
50
|
|
|
LoggerInterface $logger, |
51
|
|
|
IPayload $parentPayload = null |
52
|
|
|
) { |
53
|
|
|
parent::__construct($validators, $schemaValidator, $payloadMap, $logger, $parentPayload); |
54
|
|
|
|
55
|
|
|
$this->logger = $logger; |
|
|
|
|
56
|
|
|
$this->payloadMap = $payloadMap; |
57
|
|
|
$this->payloadFactory = new PayloadFactory; |
58
|
|
|
|
59
|
|
|
$this->optionalExtractionPaths = array_merge( |
60
|
|
|
$this->optionalExtractionPaths, |
61
|
|
|
[ |
62
|
|
|
'exemptAmount' => 'x:ExemptAmount', |
63
|
|
|
'nonTaxableAmount' => 'x:NonTaxableAmount', |
64
|
|
|
] |
65
|
|
|
); |
66
|
|
|
$this->subpayloadExtractionPaths = [ |
67
|
|
|
'invoiceTextCodes' => 'x:InvoiceTextCodes', |
68
|
|
|
]; |
69
|
|
|
|
70
|
|
|
$this->invoiceTextCodes = $this->buildPayloadForInterface(self::INVOICE_TEXT_CODE_ITERABLE_INTERFACE); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Amount of item amount not subject to taxes due to tax exempt status. |
75
|
|
|
* |
76
|
|
|
* @return float |
77
|
|
|
*/ |
78
|
|
|
public function getExemptAmount() |
79
|
|
|
{ |
80
|
|
|
return $this->exemptAmount; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param float |
85
|
|
|
* @return self |
86
|
|
|
*/ |
87
|
|
|
public function setExemptAmount($exemptAmount) |
88
|
|
|
{ |
89
|
|
|
$this->exemptAmount = $this->sanitizeAmount($exemptAmount); |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Amount of item amount not subject to taxes due to non-taxable status. |
95
|
|
|
* |
96
|
|
|
* @return float |
97
|
|
|
*/ |
98
|
|
|
public function getNonTaxableAmount() |
99
|
|
|
{ |
100
|
|
|
return $this->nonTaxableAmount; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param float |
105
|
|
|
* @return self |
106
|
|
|
*/ |
107
|
|
|
public function setNonTaxableAmount($nonTaxableAmount) |
108
|
|
|
{ |
109
|
|
|
$this->nonTaxableAmount = $this->sanitizeAmount($nonTaxableAmount); |
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
protected function serializeContents() |
114
|
|
|
{ |
115
|
|
|
return "<Situs>{$this->xmlEncode($this->getSitus())}</Situs>" |
116
|
|
|
. $this->serializeJurisdiction() |
117
|
|
|
. $this->serializeImposition() |
118
|
|
|
. $this->serializeEffectiveRate() |
119
|
|
|
. $this->serializeOptionalAmount('TaxableAmount', $this->getTaxableAmount()) |
120
|
|
|
. $this->serializeOptionalAmount('ExemptAmount', $this->getExemptAmount()) |
121
|
|
|
. $this->serializeOptionalAmount('NonTaxableAmount', $this->getNonTaxableAmount()) |
122
|
|
|
. $this->serializeAmount('CalculatedTax', $this->getCalculatedTax()) |
123
|
|
|
. $this->serializeOptionalXmlEncodedValue('SellerRegistrationId', $this->getSellerRegistrationId()) |
124
|
|
|
. $this->getInvoiceTextCodes()->serialize(); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..