Zend certified PHP/Magento developer

How to Override MagentoSalesBlockAdminhtmlTotals.php?

I want to override MagentoSalesBlockAdminhtmlTotals this block I did but I don’t know what I’m doing wrong.

app/code/[Vendor]/[Module]/etc/adminhtml/di.xml

< ?xml version="1.0"?>

  

app/code/[Vendor]/[Vendor]/Block/Adminhtml/Totals.php

< ?php

namespace [Vendor][Vendor]BlockAdminhtml;

class Totals extends MagentoSalesBlockAdminhtmlTotals
{
    /**
     * Initialize order totals array
     *
     * @return $this
     */
    protected function _initTotals()
    {
        $this->_totals = [];
        $this->_totals['subtotal'] = new MagentoFrameworkDataObject(
            [
                'code' => 'subtotal',
                'value' => $this->getSource()->getSubtotal(),
                'base_value' => $this->getSource()->getBaseSubtotal(),
                'label' => __('Subtotal'),
            ]
        );

        /**
         * Add shipping
         */
        if (!$this->getSource()->getIsVirtual() && ((double)$this->getSource()->getShippingAmount() ||
            $this->getSource()->getShippingDescription())
        ) {
            $shippingLabel = __('Shipping & Handling');
            if ($this->isFreeShipping($this->getOrder()) && $this->getSource()->getDiscountDescription()) {
                $shippingLabel .= sprintf(' (%s)', $this->getSource()->getDiscountDescription());
            }
            $this->_totals['shipping'] = new MagentoFrameworkDataObject(
                [
                    'code' => 'shipping',
                    'value' => $this->getSource()->getShippingAmount(),
                    'base_value' => $this->getSource()->getBaseShippingAmount(),
                    'label' => $shippingLabel,
                ]
            );
        }

        /**
         * Add discount
         */
        if ((double)$this->getSource()->getDiscountAmount() != 0) {
            if ($this->getSource()->getDiscountDescription()) {
                $discountLabel = __('Discount (%1)', $this->getSource()->getDiscountDescription());
            } else {
                $discountLabel = __('Discount');
            }
            $this->_totals['discount'] = new MagentoFrameworkDataObject(
                [
                    'code' => 'discount',
                    'value' => $this->getSource()->getDiscountAmount(),
                    'base_value' => $this->getSource()->getBaseDiscountAmount(),
                    'label' => $discountLabel,
                ]
            );
        }

        if($this->getOrder()->getShippingMethod() == 'flatrate_flatrate'){
            $this->_totals['grand_total'] = new MagentoFrameworkDataObject(
                [
                    'code' => 'grand_total',
                    'strong' => true,
                    'value' => $this->getOrder()->getGrandTotal(),
                    'base_value' => $this->getOrder()->getBaseGrandTotal(),
                    'label' => __('Grand Total'),
                    'area' => 'footer',
                ]
            );
        }else{
            $this->_totals['grand_total'] = new MagentoFrameworkDataObject(
                [
                    'code' => 'grand_total',
                    'strong' => true,
                    'value' => $this->getSource()->getGrandTotal(),
                    'base_value' => $this->getSource()->getBaseGrandTotal(),
                    'label' => __('Grand Total'),
                    'area' => 'footer',
                ]
            );
        }

        return $this;
    }
}

Also I also override MagentoSalesBlockAdminhtmlOrderViewItemsRendererDefaultRenderer block, it’s working but I know why another block is not.