The returnCalculate API endpoint is not returning the right tax value

A request for the returnCalculate query was made to calculate the tax on an exchange item. However, the tax is miscalculated on the response because originally it was meant to be 18.06 but instead it’s 16.54. Excluding one of the tax line items on the original order. What might be happening in this case?

Request ID:

2f89622d-eb8a-44b9-83b2-5e5c746145cf-1782411110

Payload:

{
  "input": {
    "exchangeLineItems": [
      {
        "appliedDiscount": {
          "description": "Frate exchange discount",
          "value": {
            "amount": {
              "amount": 13.3,
              "currencyCode": "USD"
            }
          }
        },
        "quantity": 1,
        "variantId": "gid://shopify/ProductVariant/42133411463302"
      }
    ],
    "orderId": "gid://shopify/Order/7315270566022",
    "returnLineItems": [
      {
        "fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/15316229816454",
        "quantity": 1
      }
    ],
    "returnShippingFee": null
  },
  "keys": [
    "frate.frate"
  ],
  "variant_keys": [
    "frate.frate"
  ]
}

Response:

{
  "data": {
    "returnCalculate": {
      "exchangeLineItems": [
        {
          "calculatedDiscountAllocations": [
            {
              "allocatedAmountSet": {
                "presentmentMoney": {
                  "amount": "13.3",
                  "currencyCode": "USD"
                },
                "shopMoney": {
                  "amount": "13.3",
                  "currencyCode": "USD"
                }
              },
              "discountApplication": {
                "allocationMethod": "EACH",
                "appliedTo": "LINE",
                "description": "Frate exchange discount",
                "id": "gid://shopify/CalculatedManualDiscountApplication/5fed3302-ee51-455a-97c9-c1e9262c54ff",
                "targetSelection": "EXPLICIT",
                "targetType": "LINE_ITEM",
                "value": {
                  "amount": "13.3",
                  "currencyCode": "USD"
                }
              }
            }
          ],
          "discountedUnitPriceSet": {
            "presentmentMoney": {
              "amount": "217.7",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "217.7",
              "currencyCode": "USD"
            }
          },
          "id": "gid://shopify/CalculatedExchangeLineItem/67c3ac9a-f467-4288-a09c-e967def67012",
          "originalUnitPriceSet": {
            "presentmentMoney": {
              "amount": "231.0",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "231.0",
              "currencyCode": "USD"
            }
          },
          "quantity": 1,
          "subtotalSet": {
            "presentmentMoney": {
              "amount": "217.7",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "217.7",
              "currencyCode": "USD"
            }
          },
          "totalTaxSet": {
            "presentmentMoney": {
              "amount": "16.54",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "16.54",
              "currencyCode": "USD"
            }
          },
          "variant": {
            "barcode": "",
            "compareAtPrice": "308.00",
            "id": "gid://shopify/ProductVariant/42133411463302",
            "image": {
              "altText": "#color_pebble",
              "id": "gid://shopify/ProductImage/35903326552198",
              "url": "https://cdn.shopify.com/s/files/1/0280/5370/0742/files/FINAL-Pebble-Tote-Pebble-Fanny.jpg?v=1761278512"
            },
            "inventoryItem": {
              "id": "gid://shopify/InventoryItem/44232646656134"
            },
            "inventoryQuantity": 412,
            "metafields": {
              "nodes": []
            },
            "price": "231.00",
            "product": {
              "featuredMedia": {
                "image": {
                  "altText": "#color_black",
                  "id": "gid://shopify/ImageSource/28090058342534",
                  "url": "https://cdn.shopify.com/s/files/1/0280/5370/0742/files/FINAL-Black-Tote-Black-Fanny.jpg?v=1761278512"
                }
              },
              "id": "gid://shopify/Product/7410581307526",
              "metafields": {
                "nodes": []
              },
              "title": "The Traveler Bundle"
            },
            "selectedOptions": [
              {
                "name": "Color",
                "value": "Pebble"
              },
              {
                "name": "Strap Length",
                "value": "Extended 40-60.1 inch length"
              }
            ],
            "sku": "TVB-002-02",
            "title": "Pebble / Extended 40-60.1 inch length"
          }
        }
      ],
      "id": "gid://shopify/CalculatedReturn/b6222b42-06f6-4365-b06c-434dd3c56386",
      "returnLineItems": [
        {
          "fulfillmentLineItem": {
            "id": "gid://shopify/FulfillmentLineItem/15316229816454",
            "lineItem": {
              "id": "gid://shopify/LineItem/17336734515334",
              "name": "The Traveler Bundle - Pebble / Regular 32-46 inch length",
              "variant": {
                "barcode": "",
                "compareAtPrice": "308.00",
                "id": "gid://shopify/ProductVariant/42130053791878",
                "image": {
                  "altText": "#color_pebble",
                  "id": "gid://shopify/ProductImage/35903326552198",
                  "url": "https://cdn.shopify.com/s/files/1/0280/5370/0742/files/FINAL-Pebble-Tote-Pebble-Fanny.jpg?v=1761278512"
                },
                "inventoryItem": {
                  "id": "gid://shopify/InventoryItem/44229310513286"
                },
                "inventoryQuantity": 536,
                "metafields": {
                  "nodes": []
                },
                "price": "231.00",
                "product": {
                  "featuredMedia": {
                    "image": {
                      "altText": "#color_black",
                      "id": "gid://shopify/ImageSource/28090058342534",
                      "url": "https://cdn.shopify.com/s/files/1/0280/5370/0742/files/FINAL-Black-Tote-Black-Fanny.jpg?v=1761278512"
                    }
                  },
                  "id": "gid://shopify/Product/7410581307526",
                  "metafields": {
                    "nodes": []
                  },
                  "title": "The Traveler Bundle"
                },
                "selectedOptions": [
                  {
                    "name": "Color",
                    "value": "Pebble"
                  },
                  {
                    "name": "Strap Length",
                    "value": "Regular 32-46 inch length"
                  }
                ],
                "sku": "TVB-001-02",
                "title": "Pebble / Regular 32-46 inch length"
              }
            }
          },
          "id": "gid://shopify/CalculatedReturnLineItem/2756078b-d015-4860-adc0-52eef180275b",
          "quantity": 1,
          "restockingFee": null,
          "subtotalBeforeOrderDiscountsSet": {
            "presentmentMoney": {
              "amount": "-217.7",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "-217.7",
              "currencyCode": "USD"
            }
          },
          "subtotalSet": {
            "presentmentMoney": {
              "amount": "-217.7",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "-217.7",
              "currencyCode": "USD"
            }
          },
          "totalTaxSet": {
            "presentmentMoney": {
              "amount": "-18.06",
              "currencyCode": "USD"
            },
            "shopMoney": {
              "amount": "-18.06",
              "currencyCode": "USD"
            }
          }
        }
      ],
      "returnShippingFee": null
    }
  },
  "extensions": {
    "cost": {
      "actualQueryCost": 51,
      "requestedQueryCost": 51,
      "throttleStatus": {
        "currentlyAvailable": 19949,
        "maximumAvailable": 20000,
        "restoreRate": 1000
      }
    }
  }
}

Hi @lance_frate, thanks for the report! I took a look at the logs for the request ID you shared and yu’re reading the totals correctly, and the difference is expected from how exchange tax is computed rather than a value being lost.

When you call returnCalculate, the tax on an exchange line item is recalculated at request time as a new sale to the destination address. It doesn’t copy the tax lines from the original order, so the result can differ from what was originally charged. The calculated objects also only expose the aggregate totalTaxSet, not a per-line tax breakdown, which is why the 16.54 looks like it’s missing a piece of the original 18.06.

Looking at that request, the exchange tax was computed through a third-party tax service, and the tax lines a provider returns can legitimately differ from the original order’s. To see the specifics, query the original order’s tax lines and compare them against what the exchange produces:

{
  order(id: "gid://shopify/Order/...") {
    lineItems(first: 50) {
      nodes {
        taxLines {
          title
          source
          ratePercentage
          channelLiable
          priceSet { shopMoney { amount currencyCode } }
        }
      }
    }
  }
}

Find the line that accounts for the roughly 1.52 difference and check its source and channelLiable value. A channel-liable tax line is one a sales channel collects and remits, and those can be excluded from a recalculated exchange by design. Whether that line should appear on the exchange comes down to its channelLiable value and how your tax provider handles that destination, which is a tax-determination call rather than something I can confirm from the API behavior alone.

If you confirm the tax configuration hasn’t changed and you believe that line should still be present, let me know and I can take a closer look with the relevant team.