|
1
|
--- |
|
2
|
sidebar_label: "Tax Lines" |
|
3
|
products: |
|
4
|
- tax |
|
5
|
--- |
|
6
|
|
|
7
|
export const metadata = { |
|
8
|
title: `Tax Lines in Order Module`, |
|
9
|
} |
|
10
|
|
|
11
|
# {metadata.title} |
|
12
|
|
|
13
|
In this document, you’ll learn about tax lines in an order. |
|
14
|
|
|
15
|
## What are Tax Lines? |
|
16
|
|
|
17
|
A tax line indicates the tax rate of a line item or a shipping method. |
|
18
|
|
|
19
|
The [OrderLineItemTaxLine data model](/references/order/models/OrderLineItemTaxLine) represents a line item’s tax line, and the [OrderShippingMethodTaxLine data model](/references/order/models/OrderShippingMethodTaxLine) represents a shipping method’s tax line. |
|
20
|
|
|
21
|
 |
|
22
|
|
|
23
|
--- |
|
24
|
|
|
25
|
## Tax Inclusivity |
|
26
|
|
|
27
|
By default, the tax amount is calculated by taking the tax rate from the line item or shipping method’s amount and then adding it to the item/method’s subtotal. |
|
28
|
|
|
29
|
However, line items and shipping methods have an `is_tax_inclusive` property that, when enabled, indicates that the item or method’s price already includes taxes. |
|
30
|
|
|
31
|
So, instead of calculating the tax rate and adding it to the item/method’s subtotal, it’s calculated as part of the subtotal. |
|
32
|
|
|
33
|
<Note> |
|
34
|
|
|
35
|
The following diagram is a simplified showcase of how a subtotal is calculated from the tax perspective. |
|
36
|
|
|
37
|
</Note> |
|
38
|
|
|
39
|
 |
|
40
|
|
|
41
|
For example, if a line item's amount is `5000`, the tax rate is `10`, and `is_tax_inclusive` is enabled, the tax amount is 10% of `5000`, which is `500`. The item's unit price becomes `4500`. |
|
42
|
|
|
43
|
--- |
|
44
|
|
|
45
|
## When Are Tax Lines Recalculated? |
|
46
|
|
|
47
|
Unlike cart tax lines, which Medusa recalculates automatically as the customer builds their cart, order tax lines are only recomputed in specific situations. |
|
48
|
|
|
49
|
### Regular Orders |
|
50
|
|
|
51
|
For regular orders, Medusa does not automatically recompute tax lines when you update an order. For example, updating the order's shipping or billing address using the `updateOrderWorkflow` does not trigger a tax recomputation. The existing tax lines are preserved as-is. |
|
52
|
|
|
53
|
To recompute a regular order's tax lines, use the [updateOrderTaxLinesWorkflow](/references/medusa-workflows/updateOrderTaxLinesWorkflow). |
|
54
|
|
|
55
|
### Draft Orders |
|
56
|
|
|
57
|
For draft orders, Medusa recomputes tax lines in two situations: |
|
58
|
|
|
59
|
- When you update the draft order's shipping or billing address using the [updateDraftOrderWorkflow](/references/medusa-workflows/updateDraftOrderWorkflow), Medusa recomputes the tax lines to reflect the correct tax jurisdiction. |
|
60
|
- When you convert a draft order to a regular order using the [convertDraftOrderWorkflow](/references/medusa-workflows/convertDraftOrderWorkflow), Medusa recomputes the tax lines before placing the order. This prevents stale tax lines from carrying over to the new order. |
|
61
|
|
|
62
|
In both cases, whether Medusa recomputes the tax lines depends on the region's `automatic_taxes` setting: |
|
63
|
|
|
64
|
- If `automatic_taxes` is enabled, Medusa recomputes the tax lines from the tax provider. |
|
65
|
- If `automatic_taxes` is disabled, the tax lines are not recomputed. |
|
66
|
|
|
67
|
<Note> |
|
68
|
|
|
69
|
The automatic tax recomputation for draft orders is available since Medusa [v2.19.0](https://github.com/medusajs/medusa/releases/tag/v2.19.0). |
|
70
|
|
|
71
|
</Note> |