diff --git a/version/104/paymentmethod/JTLMollie.php b/version/104/paymentmethod/JTLMollie.php index 8f8107f..f859893 100644 --- a/version/104/paymentmethod/JTLMollie.php +++ b/version/104/paymentmethod/JTLMollie.php @@ -241,11 +241,18 @@ protected function getOrderData(Bestellung $order, $hash) /** @var WarenkorbPos $oPosition */ foreach ($order->Positionen as $oPosition) { - //$unitPrice = berechneBrutto($order->Waehrung->fFaktor * $oPosition->fPreis, $oPosition->fMwSt); - $unitPriceNetto = round(((float)$order->Waehrung->fFaktor * round($oPosition->fPreis,2)), 2); - $unitPrice = round($unitPriceNetto * (1 + (float)$oPosition->fMwSt / 100), 2); - - $totalAmount = round($oPosition->nAnzahl * $unitPrice, 2); + + $_currencyFactor = (float)$order->Waehrung->fFaktor; // EUR => 1 + $_netto = round($oPosition->fPreis,2); // 13.45378 => 13.45 + $_vatRate = (float)$oPosition->fMwSt / 100; // 0.19 + $_amount = (float)$oPosition->nAnzahl; // 3 + + $unitPriceNetto = round(($_currencyFactor * $_netto), 2); // => 13.45 + $unitPrice = round($unitPriceNetto * (1 + $_vatRate), 2); // 13.45 * 1.19 => 16.01 + + $totalAmount = round($_amount * $unitPrice, 2); // 16.01 * 3 => 48.03 + //$vatAmount = ($unitPrice - $unitPriceNetto) * $_amount; // (16.01 - 13.45) * 3 => 7.68 + $vatAmount = round($totalAmount - ($totalAmount / (1+$_vatRate)), 2); // 48.03 - (48.03 / 1.19) => 7.67 $line = new stdClass(); $line->name = utf8_encode($oPosition->cName); @@ -260,8 +267,6 @@ protected function getOrderData(Bestellung $order, $hash) ]; $line->vatRate = "{$oPosition->fMwSt}"; - $vatAmount = $totalAmount - ($unitPriceNetto * $oPosition->nAnzahl); - $line->vatAmount = (object)[ 'value' => number_format($vatAmount, 2, '.', ''), 'currency' => $order->Waehrung->cISO,