Calculate the Tax

How could I Apply this tax calculation??!
I have bought one item its price is 113400 this price is inclusive of tax Y which is 5%
and I have another tax but the price is exclusive tax X which is 4%
when I calculate the tax manually I get this result
price 113400
tax Y is 5400
113400 - (113400 / (100% + 5%))
tax X is 4320
(113400 / (100% + 5%) ) * 4%
I want the Grand total to be 103680
113400 - 5400 - 4320

Steps to calculate:

  1. Price excluding tax Y:
    Price excluding tax Y= Price / (1+Tax Y rate)
    Price excluding tax Y= 113,400/(1+0.05) =108,000
  2. Calculate Tax Y:

Tax Y=113,400−108,000=5,400

  1. Calculate Tax X (exclusive):
    Tax X=Price excluding tax Y×Tax X rate
    Tax X=108,000×0.04=4,320

  2. Calculate the Grand Total:
    Grand Total=113,400−5,400−4,320=103,680

so if you need client script try this:

function calculateGrandTotal(price) {
    let taxY_rate = 0.05; // 5% inclusive tax
    let taxX_rate = 0.04; // 4% exclusive tax

    // Step 1: Calculate the price excluding Tax Y
    let price_excluding_taxY = price / (1 + taxY_rate);

    // Step 2: Calculate Tax Y
    let taxY = price - price_excluding_taxY;

    // Step 3: Calculate Tax X (applied to the price excluding Tax Y)
    let taxX = price_excluding_taxY * taxX_rate;

    // Step 4: Calculate Grand Total
    let grand_total = price - taxY - taxX;

    return {
        price_excluding_taxY: price_excluding_taxY,
        taxY: taxY,
        taxX: taxX,
        grand_total: grand_total
    };
}

I understand this calculation does not support ERPnext app i must add my script to calculate it