| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function calculateReceiptLine(CustomerInterface $customer, ReceiptLine $receiptLine): void |
||
| 29 | { |
||
| 30 | $money = Money::ofMinor($receiptLine->getTotal(), strtoupper($receiptLine->getCurrency())); |
||
| 31 | $rawRate = $this->rules->getDigitalVatPercentage($customer->getBillingAddress()); |
||
| 32 | |||
| 33 | $rate = ($rawRate / 100) + 1; |
||
| 34 | |||
| 35 | $subTotal = $money->dividedBy($rate, RoundingMode::HALF_UP); |
||
| 36 | $vat = $money->minus($subTotal, RoundingMode::HALF_DOWN); |
||
| 37 | |||
| 38 | $receiptLine->setVatPercentage(floatval($rawRate)); |
||
| 39 | $receiptLine->setSubTotal($subTotal->getMinorAmount()->toInt()); |
||
| 40 | $receiptLine->setVatTotal($vat->getMinorAmount()->toInt()); |
||
| 41 | } |
||
| 43 |