コード例 #1
0
 protected function getAdminSoapOrderRowsFromBuilderOrderRowsUsingVatFlag($builderOrderRows, $priceIncludingVat = NULL)
 {
     $amount = 0;
     $orderRows = array();
     foreach ($builderOrderRows as $orderRow) {
         if (isset($orderRow->vatPercent) && isset($orderRow->amountExVat)) {
             $amount = \Svea\WebService\WebServiceRowFormatter::convertExVatToIncVat($orderRow->amountExVat, $orderRow->vatPercent);
         } elseif (isset($orderRow->vatPercent) && isset($orderRow->amountIncVat)) {
             $amount = $orderRow->amountIncVat;
         } else {
             $amount = $orderRow->amountIncVat;
             $orderRow->vatPercent = \Svea\WebService\WebServiceRowFormatter::calculateVatPercentFromPriceExVatAndPriceIncVat($orderRow->amountIncVat, $orderRow->amountExVat);
         }
         $orderRows[] = new \SoapVar(new AdminSoap\CancellationRow($amount, $this->formatRowNameAndDescription($orderRow), $orderRow->rowNumber, $orderRow->vatPercent), SOAP_ENC_OBJECT, null, null, 'CancellationRow', "http://schemas.datacontract.org/2004/07/DataObjects.Webservice");
     }
     return $orderRows;
 }
コード例 #2
0
 /**
  * Regression test for float to int conversion error, where we lost accuracy
  * on straight cast of 25f (eg. 24.9999999964) to 24i
  * See also test in InvoicePaymentIntegrationTest, Jira issue WEB-193
  */
 public function test_regressiontest_for_float_to_int_conversion_errorS()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config);
     $order->addOrderRow(WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1))->addFee(WebPayItem::shippingFee()->setAmountExVat(0.0)->setVatPercent(0))->addFee(WebPayItem::invoiceFee()->setAmountExVat(23.2)->setVatPercent(25));
     $formatter = new WebServiceRowFormatter($order);
     $resultRows = $formatter->formatRows();
     $testedRow = $resultRows[0];
     $this->assertEquals(100, $testedRow->PricePerUnit);
     $this->assertEquals(25, $testedRow->VatPercent);
     $testedRow = $resultRows[1];
     $this->assertEquals(0, $testedRow->PricePerUnit);
     $this->assertEquals(0, $testedRow->VatPercent);
     $testedRow = $resultRows[2];
     $this->assertEquals(23.2, $testedRow->PricePerUnit);
     $this->assertEquals(25, $testedRow->VatPercent);
 }
コード例 #3
0
 protected function getAdminSoapOrderRowsFromBuilderOrderRowsUsingVatFlag($builderOrderRows, $priceIncludingVat = NULL)
 {
     $amount = 0;
     $orderRows = array();
     //if orderrownumber is set, create an orderrow with dummy values. Will be ignored in WebPay WS
     if (count($this->orderBuilder->rowsToCredit) > 0) {
         foreach ($this->orderBuilder->rowsToCredit as $rownumber) {
             $orderRows[] = new \SoapVar(new AdminSoap\CancellationRow(0.0, "Numbered row", 0, $rownumber), SOAP_ENC_OBJECT, null, null, 'CancellationRow', "http://schemas.datacontract.org/2004/07/DataObjects.Webservice");
         }
     }
     //add orderrows if there are any
     foreach ($builderOrderRows as $orderRow) {
         if (isset($orderRow->vatPercent) && isset($orderRow->amountExVat)) {
             $amount = \Svea\WebService\WebServiceRowFormatter::convertExVatToIncVat($orderRow->amountExVat, $orderRow->vatPercent);
         } elseif (isset($orderRow->vatPercent) && isset($orderRow->amountIncVat)) {
             $amount = $orderRow->amountIncVat;
         } else {
             $amount = $orderRow->amountIncVat;
             $orderRow->vatPercent = \Svea\WebService\WebServiceRowFormatter::calculateVatPercentFromPriceExVatAndPriceIncVat($orderRow->amountIncVat, $orderRow->amountExVat);
         }
         $orderRows[] = new \SoapVar(new AdminSoap\CancellationRow($amount, $this->formatRowNameAndDescription($orderRow), $orderRow->vatPercent), SOAP_ENC_OBJECT, null, null, 'CancellationRow', "http://schemas.datacontract.org/2004/07/DataObjects.Webservice");
     }
     return $orderRows;
 }
コード例 #4
0
 protected function getAdminSoapNumberedOrderRowsFromBuilderOrderRowsUsingVatFlag($builderOrderRows, $priceIncludingVat)
 {
     $amount = 0;
     $numberedOrderRows = array();
     foreach ($builderOrderRows as $orderRow) {
         if (isset($orderRow->vatPercent) && isset($orderRow->amountExVat)) {
             $amount = $priceIncludingVat ? \Svea\WebService\WebServiceRowFormatter::convertExVatToIncVat($orderRow->amountExVat, $orderRow->vatPercent) : $orderRow->amountExVat;
         } elseif (isset($orderRow->vatPercent) && isset($orderRow->amountIncVat)) {
             $amount = $priceIncludingVat ? $orderRow->amountIncVat : \Svea\WebService\WebServiceRowFormatter::convertIncVatToExVat($orderRow->amountIncVat, $orderRow->vatPercent);
         } else {
             $amount = $priceIncludingVat ? $orderRow->amountIncVat : $orderRow->amountExVat;
             $orderRow->vatPercent = \Svea\WebService\WebServiceRowFormatter::calculateVatPercentFromPriceExVatAndPriceIncVat($orderRow->amountIncVat, $orderRow->amountExVat);
         }
         $numberedOrderRows[] = new \SoapVar(new AdminSoap\NumberedOrderRow($orderRow->articleNumber, $this->formatRowNameAndDescription($orderRow), !isset($orderRow->discountPercent) ? 0 : $orderRow->discountPercent, $orderRow->quantity, $amount, $orderRow->unit, $orderRow->vatPercent, $orderRow->creditInvoiceId, $orderRow->invoiceId, $orderRow->rowNumber, $priceIncludingVat), SOAP_ENC_OBJECT, null, null, 'NumberedOrderRow', "http://schemas.datacontract.org/2004/07/DataObjects.Admin.Service");
     }
     return $numberedOrderRows;
 }