1 | <?php |
||
42 | class Invoice |
||
43 | { |
||
44 | /** |
||
45 | * Index of added invoice items |
||
46 | * |
||
47 | * @var integer |
||
48 | */ |
||
49 | protected $iIndex = 1; |
||
50 | |||
51 | /** |
||
52 | * Invoice amount |
||
53 | * |
||
54 | * @var integer |
||
55 | */ |
||
56 | protected $dAmount = 0; |
||
57 | |||
58 | /** |
||
59 | * Vat rate for following entities which may not have the vat attached to it |
||
60 | * |
||
61 | * @var double |
||
62 | */ |
||
63 | protected $dTax = false; |
||
64 | |||
65 | /** |
||
66 | * PAYONE toolkit helper |
||
67 | * |
||
68 | * @var \Payone\Core\Helper\Toolkit |
||
69 | */ |
||
70 | protected $toolkitHelper; |
||
71 | |||
72 | /** |
||
73 | * Request object |
||
74 | * |
||
75 | * @var Base |
||
76 | */ |
||
77 | protected $oRequest; |
||
78 | |||
79 | /** |
||
80 | * Constructor |
||
81 | * |
||
82 | * @param \Payone\Core\Helper\Toolkit $toolkitHelper Toolkit helper |
||
83 | */ |
||
84 | public function __construct(\Payone\Core\Helper\Toolkit $toolkitHelper) |
||
88 | |||
89 | /** |
||
90 | * Add parameters for a invoice position |
||
91 | * |
||
92 | * @param string $sId item identification |
||
93 | * @param double $dPrice item price |
||
94 | * @param string $sItemType item type |
||
95 | * @param int $iAmount item amount |
||
96 | * @param string $sDesc item description |
||
97 | * @param double $dVat item tax rate |
||
98 | * @return void |
||
99 | */ |
||
100 | protected function addInvoicePosition($sId, $dPrice, $sItemType, $iAmount, $sDesc, $dVat) |
||
111 | |||
112 | /** |
||
113 | * Add invoicing data to the request and return the summed invoicing amount |
||
114 | * |
||
115 | * @param Base $oRequest Request object |
||
116 | * @param Order $oOrder Order object |
||
117 | * @param array $aPositions Is given with non-complete captures or debits |
||
118 | * @param bool $blDebit Is the call coming from a debit request |
||
119 | * @return integer |
||
120 | */ |
||
121 | public function addProductInfo(Base $oRequest, Order $oOrder, $aPositions = false, $blDebit = false) |
||
142 | |||
143 | /** |
||
144 | * Add invoicing item for a product |
||
145 | * |
||
146 | * @param \Magento\Sales\Model\Order\Item $oItem |
||
147 | * @param array $aPositions |
||
148 | * @return void |
||
149 | */ |
||
150 | protected function addProductItem($oItem, $aPositions) |
||
151 | { |
||
152 | if ($aPositions === false || array_key_exists($oItem->getProductId(), $aPositions) !== false) { // full or single-invoice? |
||
153 | $dItemAmount = $oItem->getQtyOrdered(); // get ordered item amount |
||
154 | if ($aPositions !== false && array_key_exists($oItem->getProductId(), $aPositions) !== false) { // product existing in single-invoice? |
||
155 | $dItemAmount = $aPositions[$oItem->getProductId()]['amount']; // use amount from single-invoice |
||
156 | } |
||
157 | $iAmount = $this->convertItemAmount($dItemAmount); |
||
158 | $this->addInvoicePosition($oItem->getSku(), $oItem->getPriceInclTax(), 'goods', $iAmount, $oItem->getName(), $oItem->getTaxPercent()); // add invoice params to request |
||
159 | if ($this->dTax === false) { // is dTax not set yet? |
||
160 | $this->dTax = $oItem->getTaxPercent(); // set the tax for following entities which dont have the vat attached to it |
||
161 | } |
||
162 | } |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Add invoicing item for shipping |
||
167 | * |
||
168 | * @param Order $oOrder |
||
169 | * @param array $aPositions |
||
170 | * @param bool $blDebit |
||
171 | * @return void |
||
172 | */ |
||
173 | protected function addShippingItem(Order $oOrder, $aPositions, $blDebit) |
||
185 | |||
186 | /** |
||
187 | * Add invoicing item for discounts |
||
188 | * |
||
189 | * @param Order $oOrder |
||
190 | * @param array $aPositions |
||
191 | * @param bool $blDebit |
||
192 | * @return void |
||
193 | */ |
||
194 | protected function addDiscountItem(Order $oOrder, $aPositions, $blDebit) |
||
214 | |||
215 | /** |
||
216 | * @param double $dItemAmount |
||
217 | * @throws \InvalidArgumentException |
||
218 | * @return integer |
||
219 | */ |
||
220 | private function convertItemAmount($dItemAmount) |
||
229 | } |
||
230 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.