Q: Override tax rate on programmatically created order I'm building an extension which imports orders created on a third-party system into Magento. The third-party system should be the single source of truth for the order's prices, tax rate, tax paid, etc. 
When creating a quote item for each order line to be imported, I can successfully override the product's price with setOriginalCustomPrice and setCustomPrice. Essentially, I'm looking for a way to do the equivalent for the tax rate (or even just the tax paid).
I've attempted using setTaxPercent, setTaxAmount, setBaseTaxAmount, etc. to no avail. I've seen suggestion of hooking into sales_quote_collect_totals_before, but I don't want to effect any orders created on the front-end of the Magento store (i.e. orders not from the third-party system).
Can someone please point me in the right direction!

A: You can use the event 'sales_model_service_quote_submit_success'
and add the custom value in quote to check the Quote data, and Apply Condition there, So It Won't Effect the frontend orders.
app/code/Vendor/ModuleName/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_success">
        <observer name="vendor_modulename_order_save_quote" instance="Vendor\Modulename\Observer\Order\SaveQuote" />
    </event>
</config>

app/code/Vendor/ModuleName/Observer/Order/SaveQuote.php
<?php
namespace Vendor\ModuelName\Observer\Order;

use Magento\Framework\Event\ObserverInterface;

class SaveQuote implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $tax = '67.99'; // tax amount
            $price = '107.99'; // price
            $quote = $observer->getEvent()->getData('quote');
            $customOrderFlag = $quote->getData('custom_order'); // This Is the Check For the Custom order
            if (!$customOrderFlag) {
                foreach ($quote->getAllItems() as $item) {
                    $sku = $item->getProduct()->getSku();
                    $item->setTaxAmount($tax); // Setting Custom Tax amount
                    $item->setBaseTaxAmount($tax);
                    $item->save();
                }
            }
        } catch (\Exception $e) {
            // Silence
        }
    }
}

