<?php

namespace Leadlion\SalesOrder\Block\Adminhtml\Order\Edit;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Model\Session\Quote;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Quote\Model\QuoteFactory;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Method\Form;
use Magento\Sales\Model\AdminOrder\Create;
use Magento\Tax\Helper\Data;
use Magento\Checkout\Model\Session as checkoutSession;

/**
 * Class ShippingMethod
 * @package Mageplaza\EditOrder\Block\Adminhtml\Order\Edit
 */
class ShippingMethod extends \Mageplaza\EditOrder\Block\Adminhtml\Order\Edit\ShippingMethod
{
    /**
     * @param $_rate
     *
     * @return array
     */
    public function getBaseShippingData($_rate)
    {
        // if ($this->isMethodActive($_rate->getCode())) {
        //     return [
        //         'ship_amount'          => $this->getBaseShippingAmount(),
        //         'ship_tax_percent'     => $this->getBaseShippingTaxPercent(),
        //         'ship_discount_amount' => $this->getBaseShippingDiscountAmount(),
        //         'total_fee'            => $this->getBaseTotalShippingFee()
        //     ];
        // }

        $ratePrice = round( ($_rate->getPrice() / ($this->getBaseShippingTaxPercent()+100)) * 100, 2);

        return [
            'ship_amount'          => $ratePrice,
            'ship_tax_percent'     => $this->getBaseShippingTaxPercent(),
            'ship_discount_amount' => $this->getBaseShippingDiscountAmount(),
            'total_fee'            => $_rate->getPrice()
        ];
    }
}
