/** * Check totals of saved (recalculated) order * * @param array $expected * @param int $approach number of order recalculate events starting at 1 * @param oxOrder $order */ protected function checkTotals($expected, $approach, $order) { $expectedTotals = $expected[$approach]['totals']; $articles = $expected[$approach]['articles']; $isNettoMode = $order->isNettoMode(); $orderArticles = $order->getOrderArticles(); foreach ($orderArticles as $article) { /** @var oxOrderArticle $article */ $articleId = $article->oxorderarticles__oxartid->value; if ($isNettoMode) { $unitPrice = $article->getNetPriceFormated(); $totalPrice = $article->getTotalNetPriceFormated(); } else { $unitPrice = $article->getBrutPriceFormated(); $totalPrice = $article->getTotalBrutPriceFormated(); } $this->assertEquals($articles[$articleId][0], $unitPrice, "#{$approach} Unit price of order art no #{$articleId}"); $this->assertEquals($articles[$articleId][1], $totalPrice, "#{$approach} Total price of order art no #{$articleId}"); } $productVats = $order->getProductVats(true); $this->assertEquals($expectedTotals['totalNetto'], $order->getFormattedTotalNetSum(), "Product Net Price #{$approach}"); $this->assertEquals($expectedTotals['discount'], $order->getFormattedDiscount(), "Discount #{$approach}"); if ($productVats) { foreach ($productVats as $vat => $vatPrice) { $this->assertEquals($expectedTotals['vats'][$vat], $vatPrice, "Vat %{$vat} total cost #{$approach}"); } } $this->assertEquals($expectedTotals['totalBrutto'], $order->getFormattedTotalBrutSum(), "Product Gross Price #{$approach}"); if ($expectedTotals['voucher']) { $this->assertEquals($expectedTotals['voucher']['brutto'], $order->getFormattedTotalVouchers(), "Voucher costs #{$approach}"); } if ($expectedTotals['delivery']) { $this->assertEquals($expectedTotals['delivery']['brutto'], $order->getFormattedeliveryCost(), "Shipping costs #{$approach}"); } if ($expectedTotals['wrapping']) { $this->assertEquals($expectedTotals['wrapping']['brutto'], $order->getFormattedWrapCost(), "Wrapping costs #{$approach}"); } if ($expectedTotals['giftcard']) { $this->assertEquals($expectedTotals['giftcard']['brutto'], $order->getFormattedGiftCardCost(), "Giftcard costs #{$approach}"); } if ($expectedTotals['payment']) { $this->assertEquals($expectedTotals['payment']['brutto'], $order->getFormattedPayCost(), "Charge Payment Method #{$approach}"); } $this->assertEquals($expectedTotals['grandTotal'], $order->getFormattedTotalOrderSum(), "Sum total #{$approach}"); }