|
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-2014 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\OrderEvents; |
|
17
|
|
|
|
|
18
|
|
|
trait TSummaryAmounts |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var float */ |
|
21
|
|
|
protected $totalAmount; |
|
22
|
|
|
/** @var float */ |
|
23
|
|
|
protected $taxAmount; |
|
24
|
|
|
/** @var float */ |
|
25
|
|
|
protected $subtotalAmount; |
|
26
|
|
|
/** @var float */ |
|
27
|
|
|
protected $dutyAmount; |
|
28
|
|
|
/** @var float */ |
|
29
|
|
|
protected $feesAmount; |
|
30
|
|
|
/** @var float */ |
|
31
|
|
|
protected $discountAmount; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Grand total |
|
35
|
|
|
* |
|
36
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
37
|
|
|
* @return float |
|
38
|
|
|
*/ |
|
39
|
|
|
public function getTotalAmount() |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->totalAmount; |
|
42
|
|
|
} |
|
43
|
|
|
/** |
|
44
|
|
|
* @param float |
|
45
|
|
|
* @return self |
|
46
|
|
|
*/ |
|
47
|
|
|
public function setTotalAmount($totalAmount) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->totalAmount = $this->sanitizeAmount($totalAmount); |
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
/** |
|
53
|
|
|
* Tax amount for the order |
|
54
|
|
|
* |
|
55
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
56
|
|
|
* @return float |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getTaxAmount() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->taxAmount; |
|
61
|
|
|
} |
|
62
|
|
|
/** |
|
63
|
|
|
* @param float |
|
64
|
|
|
* @return self |
|
65
|
|
|
*/ |
|
66
|
|
|
public function setTaxAmount($taxAmount) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->taxAmount = $this->sanitizeAmount($taxAmount); |
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
/** |
|
72
|
|
|
* Order subtotal |
|
73
|
|
|
* |
|
74
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
75
|
|
|
* @return float |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getSubtotalAmount() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->subtotalAmount; |
|
80
|
|
|
} |
|
81
|
|
|
/** |
|
82
|
|
|
* @param float |
|
83
|
|
|
* @return self |
|
84
|
|
|
*/ |
|
85
|
|
|
public function setSubtotalAmount($subtotalAmount) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->subtotalAmount = $this->sanitizeAmount($subtotalAmount); |
|
88
|
|
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
/** |
|
91
|
|
|
* Duty amount for the order |
|
92
|
|
|
* |
|
93
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
94
|
|
|
* @return float |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getDutyAmount() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->dutyAmount; |
|
99
|
|
|
} |
|
100
|
|
|
/** |
|
101
|
|
|
* @param float |
|
102
|
|
|
* @return self |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setDutyAmount($dutyAmount) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->dutyAmount = $this->sanitizeAmount($dutyAmount); |
|
107
|
|
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
/** |
|
110
|
|
|
* Fees amount for the order |
|
111
|
|
|
* |
|
112
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
113
|
|
|
* @return float |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getFeesAmount() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->feesAmount; |
|
118
|
|
|
} |
|
119
|
|
|
/** |
|
120
|
|
|
* @param float |
|
121
|
|
|
* @return self |
|
122
|
|
|
*/ |
|
123
|
|
|
public function setFeesAmount($feesAmount) |
|
124
|
|
|
{ |
|
125
|
|
|
$this->feesAmount = $this->sanitizeAmount($feesAmount); |
|
126
|
|
|
return $this; |
|
127
|
|
|
} |
|
128
|
|
|
/** |
|
129
|
|
|
* Discount amount for the order. |
|
130
|
|
|
* |
|
131
|
|
|
* xsd restriction: 2 decimal, non-negative |
|
132
|
|
|
* @return float |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getDiscountAmount() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->discountAmount; |
|
137
|
|
|
} |
|
138
|
|
|
/** |
|
139
|
|
|
* @param float |
|
140
|
|
|
* @return self |
|
141
|
|
|
*/ |
|
142
|
|
|
public function setDiscountAmount($discountAmount) |
|
143
|
|
|
{ |
|
144
|
|
|
$this->discountAmount = $this->sanitizeAmount($discountAmount); |
|
145
|
|
|
return $this; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* ensure the amount is rounded to two decimal places. |
|
150
|
|
|
* |
|
151
|
|
|
* @param mixed any numeric value |
|
152
|
|
|
* @return float|null rounded to 2 places, null if amount is not numeric |
|
153
|
|
|
*/ |
|
154
|
|
|
abstract protected function sanitizeAmount($amount); |
|
155
|
|
|
} |
|
156
|
|
|
|