/** * split mean vat given by shop (i.e. when using a coupon in OpenCart) into two fixedDiscountRows */ public function test_splitMeanToTwoTaxRatesToFormatFixedDiscountRows_OneRateInOrder() { $config = Svea\SveaConfig::getDefaultConfig(); $order = WebPay::createOrder($config); $order->addOrderRow(WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(2)); $discountExVatFromShop = 100; $meanVatRateFromShop = 25.0; $titleFromShop = "Coupon (1112)"; $descriptionFromShop = "Value 100"; $taxRates = Svea\Helper::getTaxRatesInOrder($order); $discountRows = Svea\Helper::splitMeanToTwoTaxRates($discountExVatFromShop, $meanVatRateFromShop, $titleFromShop, $descriptionFromShop, $taxRates); foreach ($discountRows as $row) { $order = $order->addDiscount($row); } $formatter = new Svea\WebService\WebServiceRowFormatter($order); $newRows = $formatter->formatRows(); $newRow = $newRows[1]; $this->assertEquals("Coupon (1112): Value 100", $newRow->Description); $this->assertEquals(-100, $newRow->PricePerUnit); $this->assertEquals(25, $newRow->VatPercent); }