Skip to content

Commit

Permalink
Payment factory - validator cena jednotlivých položek (#58)
Browse files Browse the repository at this point in the history
closes #41
  • Loading branch information
PavelJurasek authored Oct 7, 2019
1 parent 443db31 commit 1042814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Api/Entity/PaymentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static function create($data, $validators = [])
$itemsPrice = 0;
$orderPrice = $payment->getAmount();
foreach ($payment->getItems() as $item) {
$itemsPrice += $item->amount * $item->count;
$itemsPrice += $item->amount;
}
if ($itemsPrice !== $orderPrice) {
if ($validators[self::V_PRICES] === TRUE) {
Expand Down
10 changes: 5 additions & 5 deletions tests/cases/unit/Api/Entity/PaymentFactory.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test(function () {
'order_number' => '001',
'order_description' => 'pojisteni01',
'items' => [
['name' => 'item01', 'amount' => 50, 'count' => 2],
['name' => 'item01', 'amount' => 100, 'count' => 2],
['name' => 'item02', 'amount' => 100],
['name' => 'item03', 'amount' => 150, 'vat_rate' => 21],
['name' => 'item04', 'amount' => 200, 'type' => PaymentType::ITEM],
Expand Down Expand Up @@ -125,7 +125,7 @@ test(function () {
'order_number' => '001',
'order_description' => 'pojisteni01',
'items' => [
['name' => 'item01', 'amount' => 50, 'count' => 2],
['name' => 'item01', 'amount' => 100, 'count' => 2],
['name' => 'item02', 'amount' => 100],
['name' => 'item03', 'amount' => 150, 'vat_rate' => 21],
['name' => 'item04', 'amount' => 200, 'type' => PaymentType::ITEM],
Expand Down Expand Up @@ -154,7 +154,7 @@ test(function () {
'order_number' => 3,
'order_description' => 4,
'items' => [
['name' => 'Item 01', 'amount' => 50, 'count' => 2],
['name' => 'Item 01', 'amount' => 100, 'count' => 2],
['name' => 'Item 01', 'amount' => 50],
],
'return_url' => 6,
Expand Down Expand Up @@ -238,7 +238,7 @@ test(function () {
'order_number' => 3,
'order_description' => 4,
'items' => [
['name' => 'Item 01', 'amount' => 50, 'count' => 3],
['name' => 'Item 01', 'amount' => 150, 'count' => 3],
['name' => 'Item 01', 'amount' => 50],
],
'return_url' => 6,
Expand All @@ -265,7 +265,7 @@ test(function () {
'order_number' => 3,
'order_description' => 4,
'items' => [
['name' => 'Item 01', 'amount' => 50, 'count' => 2],
['name' => 'Item 01', 'amount' => 100, 'count' => 2],
],
'return_url' => 6,
'notify_url' => 7,
Expand Down

0 comments on commit 1042814

Please sign in to comment.