chore(core-flows): apply taxes to items and shipping on RMA flows (#8858)
** What Apply taxes to order line items and shipping methods
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
} from "../../../helpers/create-admin-user"
|
||||
import { setupTaxStructure } from "../../../modules/__tests__/fixtures"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -399,6 +400,8 @@ medusaIntegrationTestRunner({
|
||||
).data.shipping_option
|
||||
|
||||
item = order.items[0]
|
||||
|
||||
await setupTaxStructure(container.resolve(ModuleRegistrationName.TAX))
|
||||
})
|
||||
|
||||
describe("Claims lifecycle", () => {
|
||||
@@ -698,7 +701,7 @@ medusaIntegrationTestRunner({
|
||||
expect(paymentCollections[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
status: "not_paid",
|
||||
amount: 110.5,
|
||||
amount: 109.5,
|
||||
currency_code: "usd",
|
||||
})
|
||||
)
|
||||
@@ -742,7 +745,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create a payment collection successfully & mark as paid", async () => {
|
||||
const paymentDelta = 110.5
|
||||
const paymentDelta = 109.5
|
||||
const orderForPayment = (
|
||||
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
||||
).data.order
|
||||
@@ -1100,9 +1103,9 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(orderCheck.summary).toEqual(
|
||||
expect.objectContaining({
|
||||
pending_difference: -10,
|
||||
current_order_total: 51,
|
||||
original_order_total: 61,
|
||||
pending_difference: -11,
|
||||
current_order_total: 50,
|
||||
original_order_total: 60,
|
||||
temporary_difference: 15,
|
||||
})
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
} from "../../../helpers/create-admin-user"
|
||||
import { setupTaxStructure } from "../../../modules/__tests__/fixtures/tax"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -379,6 +380,8 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await setupTaxStructure(container.resolve(ModuleRegistrationName.TAX))
|
||||
})
|
||||
|
||||
describe("Exchanges lifecycle", () => {
|
||||
@@ -435,7 +438,7 @@ medusaIntegrationTestRunner({
|
||||
expect(response.data).toEqual({
|
||||
type: "invalid_data",
|
||||
message:
|
||||
"Order exchange request should have atleast 1 item inbound and 1 item outbound",
|
||||
"Order exchange request should have at least 1 item inbound and 1 item outbound",
|
||||
})
|
||||
|
||||
await api.post(
|
||||
|
||||
@@ -16,6 +16,7 @@ jest.setTimeout(30000)
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let order
|
||||
let taxLine
|
||||
let shippingOption
|
||||
let shippingProfile
|
||||
let fulfillmentSet
|
||||
@@ -51,6 +52,30 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.customer
|
||||
|
||||
const taxRegion = (
|
||||
await api.post(
|
||||
"/admin/tax-regions",
|
||||
{
|
||||
country_code: "US",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.tax_region
|
||||
|
||||
taxLine = (
|
||||
await api.post(
|
||||
"/admin/tax-rates",
|
||||
{
|
||||
rate: 10,
|
||||
code: "standard",
|
||||
name: "Taxation is theft",
|
||||
is_default: true,
|
||||
tax_region_id: taxRegion.id,
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.tax_rate
|
||||
|
||||
const salesChannel = (
|
||||
await api.post(
|
||||
"/admin/sales-channels",
|
||||
@@ -384,6 +409,12 @@ medusaIntegrationTestRunner({
|
||||
expect(result.summary.original_order_total).toEqual(60)
|
||||
expect(result.items.length).toEqual(2)
|
||||
|
||||
const newItem = result.items.find(
|
||||
(i) => i.variant_id === productExtra.variants[0].id
|
||||
)
|
||||
expect(newItem.tax_lines[0].tax_rate_id).toEqual(taxLine.id)
|
||||
expect(newItem.tax_lines[0].rate).toEqual(10)
|
||||
|
||||
result = (
|
||||
await api.post(
|
||||
`/admin/order-edits/${orderId}/confirm`,
|
||||
@@ -395,7 +426,7 @@ medusaIntegrationTestRunner({
|
||||
result = (await api.get(`/admin/orders/${orderId}`, adminHeaders)).data
|
||||
.order
|
||||
|
||||
expect(result.total).toEqual(34)
|
||||
expect(result.total).toEqual(36.4)
|
||||
expect(result.items.length).toEqual(1)
|
||||
|
||||
result = (
|
||||
|
||||
@@ -226,7 +226,7 @@ medusaIntegrationTestRunner({
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "test-method",
|
||||
option_id: "test-option",
|
||||
shipping_option_id: "test-option",
|
||||
amount: 100,
|
||||
},
|
||||
],
|
||||
@@ -268,7 +268,13 @@ medusaIntegrationTestRunner({
|
||||
value: "3000",
|
||||
}),
|
||||
metadata: {},
|
||||
tax_lines: [],
|
||||
tax_lines: [
|
||||
expect.objectContaining({
|
||||
code: "US_DEF",
|
||||
provider_id: "system",
|
||||
rate: 2,
|
||||
}),
|
||||
],
|
||||
adjustments: [],
|
||||
unit_price: 3000,
|
||||
quantity: 2,
|
||||
@@ -360,9 +366,15 @@ medusaIntegrationTestRunner({
|
||||
value: "100",
|
||||
}),
|
||||
is_tax_inclusive: false,
|
||||
shipping_option_id: null,
|
||||
shipping_option_id: "test-option",
|
||||
data: null,
|
||||
tax_lines: [],
|
||||
tax_lines: [
|
||||
expect.objectContaining({
|
||||
code: "US_DEF",
|
||||
provider_id: "system",
|
||||
rate: 2,
|
||||
}),
|
||||
],
|
||||
adjustments: [],
|
||||
amount: 100,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user