Skip to content

Commit

Permalink
vat calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Proske committed Jul 30, 2019
1 parent 83a5755 commit 164dc80
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions version/104/paymentmethod/JTLMollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 164dc80

Please sign in to comment.