Incorrect "subtotal_amount" on Fulfillment event when discount is applied

Hello Shopify Team,
We are seeing an issue where in one scenario subtotal_amount under cart_lines → cost is inaccurate when we receive event on order fulfillment.
Here are the steps to repro the issue:

  1. Create an order with a product by adding 5 quantities of it. Say each item is $20 and therefore total amount is $100 pre-tax.

  2. Estimated tax calculated on the order is $10.30. So Total Amount of the order is $110.30

  3. Now add discount to it using the following steps:

    1. Click on add discount → Add custom order discount - > Discount Type as Percentage and add 10% as discount value
    2. Apply discount to order
  4. This discount reduces the total amount to $90 and hence taxes are recalculated. Taxes now comes as $9.27 on discounted price

  5. Total amount post estimated taxes and after discount is now $99.27

  6. Click on Collect Payment → Mark as Paid

  7. Now we will fulfill the order in 2 batches.

  8. Click on FulFill Items button and change quantity to 3 (of total 5). Click on Fulfill Items.

  9. This partially fulfilled the order with 3 quantities. But the event we received has the following data:

                      "cost": {
                        "amount_per_quantity": {
                          "amount": "18.0",
                          "currency_code": "USD"
                        },
                        "subtotal_amount": {
                          "amount": "50.0",
                          "currency_code": "USD"
                        },
                        "total_amount": {
                          "amount": "59.58",
                          "currency_code": "USD"
                        }
                      } 
    

    Please check subtotal_amount above. That seems incorrect.Now let’s fulfill the remaining 2 items as well. For that the event received has following data: (Please see subtotal_amount )

      "cost": {
                        "amount_per_quantity": {
                          "amount": "18.0",
                          "currency_code": "USD"
                        },
                        "subtotal_amount": {
                          "amount": "30.0",
                          "currency_code": "USD"
                        },
                        "total_amount": {
                          "amount": "39.72",
                          "currency_code": "USD"
                        }
                      }
    

    Due to this, we (Avalara) are seeing discrepancy on order amount in Shopify and Avalara Avatax during transaction recording. To me it looks like it applied full discount of $10 on subtotal_amount on each event.

Please suggest!