1 {"slug":"/references/tax/getTaxLines","title":"getTaxLines - Tax Module Reference","frontmatter":{"displayed_sidebar":"taxReference","slug":"/references/tax/getTaxLines","sidebar_label":"getTaxLines"},"toc":[{"title":"Example","id":"example","level":2},{"title":"Parameters","id":"gettaxlines-parameters","level":2},{"title":"Returns","id":"gettaxlines-returns","level":2}],"blocks":[{"kind":"markdown","html":"This documentation provides a reference to the `getTaxLines` method. This belongs to the Tax Module."},{"kind":"note","variant":"note","html":"You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](/medusa-workflows-reference)."},{"kind":"markdown","html":"This method retrieves tax lines for taxable items and shipping methods in a cart.\n\nLearn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-calculation-with-provider)."},{"kind":"heading","level":2,"text":"Example","id":"example"},{"kind":"markdown","html":"```ts\nconst taxLines = await taxModuleService.getTaxLines(\n [\n {\n id: \"cali_123\",\n product_id: \"prod_123\",\n unit_price: 1000,\n quantity: 1,\n },\n {\n id: \"casm_123\",\n shipping_option_id: \"so_123\",\n unit_price: 2000,\n },\n ],\n {\n address: {\n country_code: \"us\",\n },\n }\n)\n```"},{"kind":"heading","level":2,"text":"Parameters","id":"gettaxlines-parameters"},{"kind":"typeList","sectionTitle":"getTaxLines","types":[{"name":"items","type":"([TaxableItemDTO](/references/tax/interfaces/tax.TaxableItemDTO) \\| [TaxableShippingDTO](/references/tax/interfaces/tax.TaxableShippingDTO))[]","description":"The items and shipping methods to retrieve their tax lines.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the taxable item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of the type of the item's product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](/references/tax/types/tax.BigNumberInput)","description":"The quantity of the taxable item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](/references/tax/types/tax.BigNumberRawValue)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](/references/tax/types/tax.BigNumberInput)","description":"The unit price of the taxable item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](/references/tax/types/tax.BigNumberRawValue)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"currency_code","type":"`string`","description":"The ISO 3 character currency code of the taxable item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"calculationContext","type":"[TaxCalculationContext](/references/tax/interfaces/tax.TaxCalculationContext)","description":"The context to pass to the underlying tax provider. It provides more\ndetails that are useful to provide accurate tax lines.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"locale","type":"`string`","description":"The locale of the tax calculation.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"`object`","description":"The customer's address","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"country_code","type":"`string`","description":"The ISO 2 character currency code.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"The lower-case [ISO 3166-2](https://en.wikipedia.org/wiki/ISO\\_3166-2) province or state code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The second line of the address","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Address metadata.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer","type":"`object`","description":"The customer's details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"The groups that the customer belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Customer metadata.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_return","type":"`boolean`","description":"Whether the tax lines are calculated for an order return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"`object`[]","description":"The shipping method details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The associated shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`string`","description":"The associated shipping options's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_context","type":"`Record<string, unknown>`","description":"Additional context to pass to the underlying tax provider.\n\nUse this to forward custom data that isn't part of the framework-provided\nfields but that your tax provider needs to calculate tax lines accurately.\nIn cart and order tax workflows, this is populated by the `setTaxLineContext` hook.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sharedContext","type":"[Context](/references/tax/interfaces/tax.Context)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"transactionManager","type":"TManager","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manager","type":"TManager","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enableNestedTransactions","type":"`boolean`","description":"A boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"A string indicating the ID of the group to aggregate the events to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionId","type":"`string`","description":"A string indicating the ID of the current transaction.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"runId","type":"`string`","description":"A string indicating the ID of the current run.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"messageAggregator","type":"[IMessageAggregator](/references/tax/interfaces/tax.IMessageAggregator)","description":"An instance of a message aggregator, which is used to aggregate messages to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requestId","type":"`string`","description":"A string indicating the ID of the current request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"idempotencyKey","type":"`string`","description":"A string indicating the idempotencyKey of the current workflow execution.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parentStepIdempotencyKey","type":"`string`","description":"A string indicating the idempotencyKey of the parent workflow execution.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"preventReleaseEvents","type":"`boolean`","description":"preventReleaseEvents","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isCancelling","type":"`boolean`","description":"A boolean value indicating whether the current workflow execution is being cancelled.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cancelingFromParentStep","type":"`boolean`","description":"Weither or not a sub workflow cancellation is being triggered from a parent step.\nIf true, the parent step will not be triggered by the sub workflow.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"kind":"heading","level":2,"text":"Returns","id":"gettaxlines-returns"},{"kind":"typeList","sectionTitle":"getTaxLines","types":[{"name":"Promise","type":"Promise&#60;([ItemTaxLineDTO](/references/tax/interfaces/tax.ItemTaxLineDTO) \\| [ShippingTaxLineDTO](/references/tax/interfaces/tax.ShippingTaxLineDTO))[]&#62;","optional":false,"defaultValue":"","description":"The item and shipping methods' tax lines.","expandable":false,"children":[{"name":"(ItemTaxLineDTO \\| ShippingTaxLineDTO)[]","type":"([ItemTaxLineDTO](/references/tax/interfaces/tax.ItemTaxLineDTO) \\| [ShippingTaxLineDTO](/references/tax/interfaces/tax.ShippingTaxLineDTO))[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ItemTaxLineDTO \\| ShippingTaxLineDTO","type":"[ItemTaxLineDTO](/references/tax/interfaces/tax.ItemTaxLineDTO) \\| [ShippingTaxLineDTO](/references/tax/interfaces/tax.ShippingTaxLineDTO)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]}]}]}