Skip to content

Commit

Permalink
Fix: EET validation zakl_nepodl_dph
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrHudik authored and f3l1x committed May 9, 2017
1 parent edb7378 commit 33afec9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/Api/Entity/PaymentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,20 @@ public static function create($data, $validators = [])
], $data['eet']);

$eetSum = $eet->getSum();
$eetTotal = $eet->calcTotal();
$eetTaxSum = $eet->getTax()
$eetTotal = $eet->getTax()
+ $eet->getTaxBaseNoVat()
+ $eet->getTaxBase()
+ $eet->getTaxBaseReducedRateFirst()
+ $eet->getTaxReducedRateFirst()
+ $eet->getTaxBaseReducedRateSecond()
+ $eet->getTaxReducedRateSecond();

if ($validators[self::V_PRICES] === TRUE) {
if (number_format($eetSum, 8) !== number_format($eetTaxSum, 8)) {
throw new ValidationException(sprintf('EET sum (%s) and EET tax sum (%s) do not match', $eetSum, $eetTaxSum));
if (number_format($eetSum, 8) !== number_format($eetTotal, 8)) {
throw new ValidationException(sprintf('EET sum (%s) and EET tax sum (%s) do not match', $eetSum, $eetTotal));
}

if (number_format($eetTotal, 8) !== number_format($orderPrice, 8)) {
if (number_format($eetSum, 8) !== number_format($orderPrice, 8)) {
throw new ValidationException(sprintf('EET sum (%s) and order sum (%s) do not match', $eetSum, $orderPrice));
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/Api/Objects/Eet.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,6 @@ public function setTaxBaseNoVat($taxBaseNoVat)
* HELPERS *****************************************************************
*/

/**
* @return float
*/
public function calcTotal()
{
$sum = $this->getSum();

if ($this->getTaxBaseNoVat()) {
$sum += $this->getTaxBaseNoVat();
}

return $sum;
}

/**
* ABSTRACT ****************************************************************
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/unit/Api/Entity/PaymentFactory.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ test(function () {
'return_url' => 6,
'notify_url' => 7,
'eet' => [
'celk_trzba' => 174.0,
'celk_trzba' => 274.0,
'zakl_nepodl_dph' => 100.0,
'zakl_dan1' => 143.80165289256,
'dan1' => 30.198347107438,
Expand Down

0 comments on commit 33afec9

Please sign in to comment.