1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Magento 2 - amounts are not rounded in sales_order_payment table

Discussion in 'Programming/Internet' started by Diego Guerrero, Oct 8, 2018.

  1. I have a payment method, which at the time of doing the place order, is saved in the table sales_order_payment the amounts wrong. I attach an image.

    [​IMG]

    The last 4 decimals of the amount_paid field, is not the same as base_amount_ordered

    In order to save the order, I get this: $ order-> getGrandTotal () = 31.0755 when it should be 31.0800

    I have tried to modify it in this way:

    1)

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $quoteFactory = $objectManager->create('\Magento\Quote\Model\QuoteFactory');
    $quote = $quoteFactory->create()->load($order->getQuoteId());

    $order->setBaseGrandTotal(31.0800);
    $order->setGrandTotal(31.0800);


    2)

    $order->setSubtotal(31.0800)
    ->setBaseSubtotal(31.0800)
    ->setGrandTotal(31.0800)
    ->setBaseGrandTotal(31.0800);
    $quote->setSubtotal(31.0800)
    ->setBaseSubtotal(31.0800)
    ->setGrandTotal(31.0800)
    ->setBaseGrandTotal(31.0800);
    $quote->save();
    $quote->collectTotals()->save();


    3)

    $this->_checkoutSession->getQuote()->setSubtotal(31.0800);
    $this->_checkoutSession->getQuote()->setBaseSubtotal(31.0800);
    $this->_checkoutSession->getQuote()->setGrandTotal(31.0800);
    $this->_checkoutSession->getQuote()->setBaseGrandTotal(31.0800);
    $quote->save($quote->collectTotals());
    $this->_checkoutSession->getQuote()->collectTotals()->save();


    but in no way I have managed to set the correct value, can you give me an idea or help me in how can I do ?

    Login To add answer/comment
     

Share This Page