diff --git a/integration-tests/http/__tests__/claims/claims.spec.ts b/integration-tests/http/__tests__/claims/claims.spec.ts index 0eeb158b074e7..b56dc7a90469e 100644 --- a/integration-tests/http/__tests__/claims/claims.spec.ts +++ b/integration-tests/http/__tests__/claims/claims.spec.ts @@ -594,13 +594,17 @@ medusaIntegrationTestRunner({ adminHeaders ) + // shipping Options w/ custom price const { data: { order_preview: { shipping_methods: outboundShippingMethods }, }, } = await api.post( `/admin/claims/${claimId}/outbound/shipping-method`, - { shipping_option_id: outboundShippingOption.id }, + { + shipping_option_id: outboundShippingOption.id, + custom_amount: 12.5, + }, adminHeaders ) @@ -608,9 +612,32 @@ medusaIntegrationTestRunner({ (m) => m.shipping_option_id == outboundShippingOption.id ) + expect(outboundShippingMethod.subtotal).toBe(12.5) + expect(outboundShippingMethod.is_custom_amount).toBe(true) + + // Reset shipping custom price + const { + data: { + order_preview: { shipping_methods: outboundShippingMethods2 }, + }, + } = await api.post( + `/admin/claims/${claimId}/outbound/shipping-method/${outboundShippingMethod.actions[0].id}`, + { + custom_amount: null, + }, + adminHeaders + ) + + const outboundShippingMethodReset = outboundShippingMethods2.find( + (m) => m.shipping_option_id == outboundShippingOption.id + ) + + expect(outboundShippingMethodReset.subtotal).toBe(20) + expect(outboundShippingMethodReset.is_custom_amount).toBe(false) + // Delete & recreate again to ensure it works for both delete and create await api.delete( - `/admin/claims/${claimId}/outbound/shipping-method/${outboundShippingMethod.actions[0].id}`, + `/admin/claims/${claimId}/outbound/shipping-method/${outboundShippingMethodReset.actions[0].id}`, adminHeaders ) diff --git a/integration-tests/http/__tests__/returns/returns.spec.ts b/integration-tests/http/__tests__/returns/returns.spec.ts index 33395702278f0..f7352b7f3c747 100644 --- a/integration-tests/http/__tests__/returns/returns.spec.ts +++ b/integration-tests/http/__tests__/returns/returns.spec.ts @@ -665,7 +665,7 @@ medusaIntegrationTestRunner({ result = await api.post( `/admin/returns/${returnId}/shipping-method/${updateShippingActionId}`, { - custom_price: 1002, + custom_amount: 1002, internal_note: "cx agent note", }, adminHeaders diff --git a/integration-tests/modules/__tests__/order/order.spec.ts b/integration-tests/modules/__tests__/order/order.spec.ts index 33950f648dda6..0338f20270238 100644 --- a/integration-tests/modules/__tests__/order/order.spec.ts +++ b/integration-tests/modules/__tests__/order/order.spec.ts @@ -203,6 +203,7 @@ medusaIntegrationTestRunner({ value: "50", precision: 20, }, + is_custom_price: false, metadata: null, created_at: expect.any(String), updated_at: expect.any(String), diff --git a/integration-tests/modules/__tests__/order/workflows/return/create-return-shipping.spec.ts b/integration-tests/modules/__tests__/order/workflows/return/create-return-shipping.spec.ts index a1ef37accf3dd..7c7c78dd160df 100644 --- a/integration-tests/modules/__tests__/order/workflows/return/create-return-shipping.spec.ts +++ b/integration-tests/modules/__tests__/order/workflows/return/create-return-shipping.spec.ts @@ -95,7 +95,7 @@ medusaIntegrationTestRunner({ input: { return_id: returnOrder.id, shipping_option_id: shippingOptionId, - custom_price: 20, + custom_amount: 20, }, }) diff --git a/packages/admin/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx b/packages/admin/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx index 9e39ca656d9cf..5efb6a070072f 100644 --- a/packages/admin/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx @@ -845,7 +845,7 @@ export const ClaimCreateForm = ({ updateInboundShipping( { actionId, - custom_price: customPrice, + custom_amount: customPrice, }, { onError: (error) => { @@ -916,7 +916,7 @@ export const ClaimCreateForm = ({ updateOutboundShipping( { actionId, - custom_price: customPrice, + custom_amount: customPrice, }, { onError: (error) => { diff --git a/packages/admin/dashboard/src/routes/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx b/packages/admin/dashboard/src/routes/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx index f03d67c48030e..7045ff2167924 100644 --- a/packages/admin/dashboard/src/routes/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx @@ -364,7 +364,7 @@ export const ExchangeCreateForm = ({ updateInboundShipping( { actionId, - custom_price: customPrice, + custom_amount: customPrice, }, { onError: (error) => { @@ -435,7 +435,7 @@ export const ExchangeCreateForm = ({ updateOutboundShipping( { actionId, - custom_price: customPrice, + custom_amount: customPrice, }, { onError: (error) => { diff --git a/packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form/return-create-form.tsx b/packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form/return-create-form.tsx index 732eec88aff95..be2541c963dfa 100644 --- a/packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form/return-create-form.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form/return-create-form.tsx @@ -646,7 +646,7 @@ export const ReturnCreateForm = ({ if (actionId) { updateReturnShipping({ actionId, - custom_price: + custom_amount: typeof customShippingAmount === "string" ? null : customShippingAmount, diff --git a/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts b/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts new file mode 100644 index 0000000000000..a30b8cbe0fab8 --- /dev/null +++ b/packages/core/core-flows/src/order/utils/prepare-shipping-method.ts @@ -0,0 +1,73 @@ +import { OrderChangeActionDTO } from "@medusajs/types" +import { isDefined } from "@medusajs/utils" + +export function prepareShippingMethod(relatedEntityField?: string) { + return function (data) { + const option = data.shippingOptions[0] + const orderChange = data.orderChange + + const isCustomPrice = isDefined(data.customPrice) + const obj = { + shipping_option_id: option.id, + amount: isCustomPrice + ? data.customPrice + : option.calculated_price.calculated_amount, + is_custom_amount: isCustomPrice, + is_tax_inclusive: + !!option.calculated_price.is_calculated_price_tax_inclusive, + data: option.data ?? {}, + name: option.name, + version: orderChange.version, + order_id: data.relatedEntity.order_id, + } as any + + if (relatedEntityField) { + obj.return_id = data.input.return_id + obj[relatedEntityField] = data.relatedEntity.id + + if (relatedEntityField === "return_id") { + obj.claim_id = data.relatedEntity.claim_id + obj.exchange_id = data.relatedEntity.exchange_id + } + } + + return obj + } +} + +export function prepareShippingMethodUpdate({ + input, + orderChange, + shippingOptions, +}) { + const originalAction = (orderChange.actions ?? []).find( + (a) => a.id === input.action_id + ) as OrderChangeActionDTO + + const data = input.data + + const option = shippingOptions?.[0] + + const isCustomPrice = !isDefined(shippingOptions) + const price = isCustomPrice + ? data.custom_amount + : option.calculated_price.calculated_amount + + const action = { + id: originalAction.id, + amount: price, + internal_note: data.internal_note, + } + + const shippingMethod = { + id: originalAction.reference_id, + amount: price, + is_custom_amount: isCustomPrice, + metadata: data.metadata, + } + + return { + action, + shippingMethod, + } +} diff --git a/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts b/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts index 2988bdfd3b01a..8a95d85afec51 100644 --- a/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts @@ -19,6 +19,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethod } from "../../utils/prepare-shipping-method" import { createOrderChangeActionsWorkflow } from "../create-order-change-actions" import { updateOrderTaxLinesWorkflow } from "../update-tax-lines" @@ -53,7 +54,7 @@ export const createClaimShippingMethodWorkflow = createWorkflow( return_id?: string claim_id?: string shipping_option_id: string - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null }): WorkflowResponse { const orderClaim: OrderClaimDTO = useRemoteQueryStep({ entry_point: "order_claim", @@ -65,7 +66,7 @@ export const createClaimShippingMethodWorkflow = createWorkflow( const order: OrderDTO = useRemoteQueryStep({ entry_point: "orders", - fields: ["id", "status", "currency_code", "canceled_at"], + fields: ["id", "status", "region_id", "currency_code", "canceled_at"], variables: { id: orderClaim.order_id }, list: false, throw_if_key_not_found: true, @@ -104,29 +105,13 @@ export const createClaimShippingMethodWorkflow = createWorkflow( const shippingMethodInput = transform( { - orderClaim, + relatedEntity: orderClaim, shippingOptions, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, - (data) => { - const option = data.shippingOptions[0] - const orderChange = data.orderChange - - return { - shipping_option_id: option.id, - amount: data.customPrice ?? option.calculated_price.calculated_amount, - is_tax_inclusive: - !!option.calculated_price.is_calculated_price_tax_inclusive, - data: option.data ?? {}, - name: option.name, - version: orderChange.version, - order_id: data.orderClaim.order_id, - return_id: input.return_id, - claim_id: data.orderClaim.id, - } - } + prepareShippingMethod("claim_id") ) const createdMethods = createOrderShippingMethods({ @@ -155,7 +140,7 @@ export const createClaimShippingMethodWorkflow = createWorkflow( orderClaim, shippingOptions, createdMethods, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, @@ -170,6 +155,7 @@ export const createClaimShippingMethodWorkflow = createWorkflow( }) => { const shippingOption = shippingOptions[0] const createdMethod = createdMethods[0] + const methodPrice = customPrice ?? shippingOption.calculated_price.calculated_amount diff --git a/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts b/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts index 0d8e08b78a337..2a3bc294a116a 100644 --- a/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts @@ -13,6 +13,7 @@ import { createWorkflow, parallelize, transform, + when, } from "@medusajs/workflows-sdk" import { useRemoteQueryStep } from "../../../common" import { @@ -24,6 +25,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethodUpdate } from "../../utils/prepare-shipping-method" /** * This step validates that a claim's shipping method can be updated. @@ -70,7 +72,13 @@ export const updateClaimShippingMethodWorkflow = createWorkflow( ): WorkflowResponse { const orderClaim: OrderClaimDTO = useRemoteQueryStep({ entry_point: "order_claim", - fields: ["id", "status", "order_id", "canceled_at"], + fields: [ + "id", + "status", + "order_id", + "canceled_at", + "order.currency_code", + ], variables: { id: input.claim_id }, list: false, throw_if_key_not_found: true, @@ -89,34 +97,54 @@ export const updateClaimShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - updateClaimShippingMethodValidationStep({ orderClaim, orderChange, input }) + const shippingOptions = when({ input }, ({ input }) => { + return input.data?.custom_amount === null + }).then(() => { + const action = transform( + { orderChange, input, orderClaim }, + ({ orderChange, input, orderClaim }) => { + const originalAction = (orderChange.actions ?? []).find( + (a) => a.id === input.action_id + ) as OrderChangeActionDTO - const updateData = transform( - { orderChange, input }, - ({ input, orderChange }) => { - const originalAction = (orderChange.actions ?? []).find( - (a) => a.id === input.action_id - ) as OrderChangeActionDTO + return { + shipping_method_id: originalAction.reference_id, + currency_code: (orderClaim as any).order.currency_code, + } + } + ) - const data = input.data + const shippingMethod = useRemoteQueryStep({ + entry_point: "order_shipping_method", + fields: ["id", "shipping_option_id"], + variables: { + id: action.shipping_method_id, + }, + list: false, + }).config({ name: "fetch-shipping-method" }) - const action = { - id: originalAction.id, - amount: data.custom_price, - internal_note: data.internal_note, - } + return useRemoteQueryStep({ + entry_point: "shipping_option", + fields: [ + "id", + "name", + "calculated_price.calculated_amount", + "calculated_price.is_calculated_price_tax_inclusive", + ], + variables: { + id: shippingMethod.shipping_option_id, + calculated_price: { + context: { currency_code: action.currency_code }, + }, + }, + }).config({ name: "fetch-shipping-option" }) + }) - const shippingMethod = { - id: originalAction.reference_id, - amount: data.custom_price, - metadata: data.metadata, - } + updateClaimShippingMethodValidationStep({ orderClaim, orderChange, input }) - return { - action, - shippingMethod, - } - } + const updateData = transform( + { orderChange, input, shippingOptions }, + prepareShippingMethodUpdate ) parallelize( diff --git a/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts b/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts index 248bb1ae5adcd..f20f5484415af 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts @@ -19,6 +19,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethod } from "../../utils/prepare-shipping-method" import { createOrderChangeActionsWorkflow } from "../create-order-change-actions" import { updateOrderTaxLinesWorkflow } from "../update-tax-lines" @@ -53,7 +54,7 @@ export const createExchangeShippingMethodWorkflow = createWorkflow( return_id?: string exchange_id?: string shipping_option_id: string - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null }): WorkflowResponse { const orderExchange: OrderExchangeDTO = useRemoteQueryStep({ entry_point: "order_exchange", @@ -108,29 +109,13 @@ export const createExchangeShippingMethodWorkflow = createWorkflow( const shippingMethodInput = transform( { - orderExchange, + relatedEntity: orderExchange, shippingOptions, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, - (data) => { - const option = data.shippingOptions[0] - const orderChange = data.orderChange - - return { - shipping_option_id: option.id, - amount: data.customPrice ?? option.calculated_price.calculated_amount, - is_tax_inclusive: - !!option.calculated_price.is_calculated_price_tax_inclusive, - data: option.data ?? {}, - name: option.name, - version: orderChange.version, - order_id: data.orderExchange.order_id, - return_id: input.return_id, - exchange_id: data.orderExchange.id, - } - } + prepareShippingMethod("exchange_id") ) const createdMethods = createOrderShippingMethods({ @@ -159,7 +144,7 @@ export const createExchangeShippingMethodWorkflow = createWorkflow( orderExchange, shippingOptions, createdMethods, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts index 551ee3fb18d98..5d86f5b9ffce4 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts @@ -13,6 +13,7 @@ import { createWorkflow, parallelize, transform, + when, } from "@medusajs/workflows-sdk" import { useRemoteQueryStep } from "../../../common" import { @@ -24,6 +25,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethodUpdate } from "../../utils/prepare-shipping-method" /** * This step validates that an exchange's shipping method can be updated. @@ -70,7 +72,13 @@ export const updateExchangeShippingMethodWorkflow = createWorkflow( ): WorkflowResponse { const orderExchange: OrderExchangeDTO = useRemoteQueryStep({ entry_point: "order_exchange", - fields: ["id", "status", "order_id", "canceled_at"], + fields: [ + "id", + "status", + "order_id", + "canceled_at", + "order.currency_code", + ], variables: { id: input.exchange_id }, list: false, throw_if_key_not_found: true, @@ -89,6 +97,49 @@ export const updateExchangeShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) + const shippingOptions = when({ input }, ({ input }) => { + return input.data?.custom_amount === null + }).then(() => { + const action = transform( + { orderChange, input, orderExchange }, + ({ orderChange, input, orderExchange }) => { + const originalAction = (orderChange.actions ?? []).find( + (a) => a.id === input.action_id + ) as OrderChangeActionDTO + + return { + shipping_method_id: originalAction.reference_id, + currency_code: (orderExchange as any).order.currency_code, + } + } + ) + + const shippingMethod = useRemoteQueryStep({ + entry_point: "order_shipping_method", + fields: ["id", "shipping_option_id"], + variables: { + id: action.shipping_method_id, + }, + list: false, + }).config({ name: "fetch-shipping-method" }) + + return useRemoteQueryStep({ + entry_point: "shipping_option", + fields: [ + "id", + "name", + "calculated_price.calculated_amount", + "calculated_price.is_calculated_price_tax_inclusive", + ], + variables: { + id: shippingMethod.shipping_option_id, + calculated_price: { + context: { currency_code: action.currency_code }, + }, + }, + }).config({ name: "fetch-shipping-option" }) + }) + updateExchangeShippingMethodValidationStep({ orderExchange, orderChange, @@ -96,31 +147,8 @@ export const updateExchangeShippingMethodWorkflow = createWorkflow( }) const updateData = transform( - { orderChange, input }, - ({ input, orderChange }) => { - const originalAction = (orderChange.actions ?? []).find( - (a) => a.id === input.action_id - ) as OrderChangeActionDTO - - const data = input.data - - const action = { - id: originalAction.id, - amount: data.custom_price, - internal_note: data.internal_note, - } - - const shippingMethod = { - id: originalAction.reference_id, - amount: data.custom_price, - metadata: data.metadata, - } - - return { - action, - shippingMethod, - } - } + { orderChange, input, shippingOptions }, + prepareShippingMethodUpdate ) parallelize( diff --git a/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts b/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts index e397ad928fd2a..610259d35fd1f 100644 --- a/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts @@ -18,6 +18,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethod } from "../../utils/prepare-shipping-method" import { createOrderChangeActionsWorkflow } from "../create-order-change-actions" import { updateOrderTaxLinesWorkflow } from "../update-tax-lines" @@ -48,7 +49,7 @@ export const createOrderEditShippingMethodWorkflow = createWorkflow( function (input: { order_id: string shipping_option_id: string - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null }): WorkflowResponse { const order: OrderDTO = useRemoteQueryStep({ entry_point: "orders", @@ -89,25 +90,11 @@ export const createOrderEditShippingMethodWorkflow = createWorkflow( const shippingMethodInput = transform( { shippingOptions, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, - (data) => { - const option = data.shippingOptions[0] - const orderChange = data.orderChange - - return { - shipping_option_id: option.id, - amount: data.customPrice ?? option.calculated_price.calculated_amount, - is_tax_inclusive: - !!option.calculated_price.is_calculated_price_tax_inclusive, - data: option.data ?? {}, - name: option.name, - version: orderChange.version, - order_id: data.input.order_id, - } - } + prepareShippingMethod() ) const createdMethods = createOrderShippingMethods({ @@ -130,7 +117,7 @@ export const createOrderEditShippingMethodWorkflow = createWorkflow( order, shippingOptions, createdMethods, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, diff --git a/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts b/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts index aee28a81bab9b..344ac9d4d924e 100644 --- a/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts @@ -1,6 +1,7 @@ import { OrderChangeActionDTO, OrderChangeDTO, + OrderDTO, OrderPreviewDTO, OrderWorkflow, } from "@medusajs/types" @@ -12,6 +13,7 @@ import { createWorkflow, parallelize, transform, + when, } from "@medusajs/workflows-sdk" import { useRemoteQueryStep } from "../../../common" import { @@ -20,6 +22,7 @@ import { } from "../../steps" import { previewOrderChangeStep } from "../../steps/preview-order-change" import { throwIfOrderChangeIsNotActive } from "../../utils/order-validation" +import { prepareShippingMethodUpdate } from "../../utils/prepare-shipping-method" /** * This step validates that an order edit's shipping method can be updated. @@ -61,6 +64,14 @@ export const updateOrderEditShippingMethodWorkflow = createWorkflow( function ( input: WorkflowData ): WorkflowResponse { + const order: OrderDTO = useRemoteQueryStep({ + entry_point: "order_claim", + fields: ["id", "currency_code"], + variables: { id: input.order_id }, + list: false, + throw_if_key_not_found: true, + }) + const orderChange: OrderChangeDTO = useRemoteQueryStep({ entry_point: "order_change", fields: ["id", "status", "version", "actions.*"], @@ -73,37 +84,57 @@ export const updateOrderEditShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) + const shippingOptions = when({ input }, ({ input }) => { + return input.data?.custom_amount === null + }).then(() => { + const action = transform( + { orderChange, input, order }, + ({ orderChange, input, order }) => { + const originalAction = (orderChange.actions ?? []).find( + (a) => a.id === input.action_id + ) as OrderChangeActionDTO + + return { + shipping_method_id: originalAction.reference_id, + currency_code: order.currency_code, + } + } + ) + + const shippingMethod = useRemoteQueryStep({ + entry_point: "order_shipping_method", + fields: ["id", "shipping_option_id"], + variables: { + id: action.shipping_method_id, + }, + list: false, + }).config({ name: "fetch-shipping-method" }) + + return useRemoteQueryStep({ + entry_point: "shipping_option", + fields: [ + "id", + "name", + "calculated_price.calculated_amount", + "calculated_price.is_calculated_price_tax_inclusive", + ], + variables: { + id: shippingMethod.shipping_option_id, + calculated_price: { + context: { currency_code: action.currency_code }, + }, + }, + }).config({ name: "fetch-shipping-option" }) + }) + updateOrderEditShippingMethodValidationStep({ orderChange, input, }) const updateData = transform( - { orderChange, input }, - ({ input, orderChange }) => { - const originalAction = (orderChange.actions ?? []).find( - (a) => a.id === input.action_id - ) as OrderChangeActionDTO - - const data = input.data - - const action = { - id: originalAction.id, - amount: data.custom_price, - internal_note: data.internal_note, - } - - const shippingMethod = { - id: originalAction.reference_id, - amount: data.custom_price, - metadata: data.metadata, - } - - return { - action, - shippingMethod, - } - } + { orderChange, input, shippingOptions }, + prepareShippingMethodUpdate ) parallelize( diff --git a/packages/core/core-flows/src/order/workflows/return/create-return-shipping-method.ts b/packages/core/core-flows/src/order/workflows/return/create-return-shipping-method.ts index e6369679d8a15..c2505b6ca1c09 100644 --- a/packages/core/core-flows/src/order/workflows/return/create-return-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/return/create-return-shipping-method.ts @@ -19,6 +19,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethod } from "../../utils/prepare-shipping-method" import { createOrderChangeActionsWorkflow } from "../create-order-change-actions" import { updateOrderTaxLinesWorkflow } from "../update-tax-lines" @@ -54,11 +55,18 @@ export const createReturnShippingMethodWorkflow = createWorkflow( claim_id?: string exchange_id?: string shipping_option_id: string - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null }): WorkflowResponse { const orderReturn: ReturnDTO = useRemoteQueryStep({ entry_point: "return", - fields: ["id", "status", "order_id", "canceled_at"], + fields: [ + "id", + "status", + "order_id", + "claim_id", + "exchange_id", + "canceled_at", + ], variables: { id: input.return_id }, list: false, throw_if_key_not_found: true, @@ -109,30 +117,13 @@ export const createReturnShippingMethodWorkflow = createWorkflow( const shippingMethodInput = transform( { - orderReturn, + relatedEntity: orderReturn, shippingOptions, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, - (data) => { - const option = data.shippingOptions[0] - const orderChange = data.orderChange - - return { - shipping_option_id: option.id, - amount: data.customPrice ?? option.calculated_price.calculated_amount, - is_tax_inclusive: - !!option.calculated_price.is_calculated_price_tax_inclusive, - data: option.data ?? {}, - name: option.name, - version: orderChange.version, - order_id: data.orderReturn.order_id, - return_id: data.orderReturn.id, - claim_id: data.input.claim_id, - exchange_id: data.input.exchange_id, - } - } + prepareShippingMethod("return_id") ) const createdMethods = createOrderShippingMethods({ @@ -157,7 +148,7 @@ export const createReturnShippingMethodWorkflow = createWorkflow( orderReturn, shippingOptions, createdMethods, - customPrice: input.custom_price, + customPrice: input.custom_amount, orderChange, input, }, diff --git a/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts b/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts index d0e6e995749f1..39c58741311fb 100644 --- a/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts @@ -13,6 +13,7 @@ import { createWorkflow, parallelize, transform, + when, } from "@medusajs/workflows-sdk" import { useRemoteQueryStep } from "../../../common" import { @@ -24,6 +25,7 @@ import { throwIfIsCancelled, throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" +import { prepareShippingMethodUpdate } from "../../utils/prepare-shipping-method" /** * This step validates that a return's shipping method can be updated. @@ -70,7 +72,13 @@ export const updateReturnShippingMethodWorkflow = createWorkflow( ): WorkflowResponse { const orderReturn: ReturnDTO = useRemoteQueryStep({ entry_point: "return", - fields: ["id", "status", "order_id", "canceled_at"], + fields: [ + "id", + "status", + "order_id", + "canceled_at", + "order.currency_code", + ], variables: { id: input.return_id }, list: false, throw_if_key_not_found: true, @@ -89,6 +97,49 @@ export const updateReturnShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) + const shippingOptions = when({ input }, ({ input }) => { + return input.data?.custom_amount === null + }).then(() => { + const action = transform( + { orderChange, input, orderReturn }, + ({ orderChange, input, orderReturn }) => { + const originalAction = (orderChange.actions ?? []).find( + (a) => a.id === input.action_id + ) as OrderChangeActionDTO + + return { + shipping_method_id: originalAction.reference_id, + currency_code: (orderReturn as any).order.currency_code, + } + } + ) + + const shippingMethod = useRemoteQueryStep({ + entry_point: "order_shipping_method", + fields: ["id", "shipping_option_id"], + variables: { + id: action.shipping_method_id, + }, + list: false, + }).config({ name: "fetch-shipping-method" }) + + return useRemoteQueryStep({ + entry_point: "shipping_option", + fields: [ + "id", + "name", + "calculated_price.calculated_amount", + "calculated_price.is_calculated_price_tax_inclusive", + ], + variables: { + id: shippingMethod.shipping_option_id, + calculated_price: { + context: { currency_code: action.currency_code }, + }, + }, + }).config({ name: "fetch-shipping-option" }) + }) + updateReturnShippingMethodValidationStep({ orderReturn, orderChange, @@ -96,31 +147,8 @@ export const updateReturnShippingMethodWorkflow = createWorkflow( }) const updateData = transform( - { orderChange, input }, - ({ input, orderChange }) => { - const originalAction = (orderChange.actions ?? []).find( - (a) => a.id === input.action_id - ) as OrderChangeActionDTO - - const data = input.data - - const action = { - id: originalAction.id, - amount: data.custom_price, - internal_note: data.internal_note, - } - - const shippingMethod = { - id: originalAction.reference_id, - amount: data.custom_price, - metadata: data.metadata, - } - - return { - action, - shippingMethod, - } - } + { orderChange, input, shippingOptions }, + prepareShippingMethodUpdate ) parallelize( diff --git a/packages/core/types/src/http/claim/admin/payloads.ts b/packages/core/types/src/http/claim/admin/payloads.ts index e2cf253551125..b5e8f8cdadfd4 100644 --- a/packages/core/types/src/http/claim/admin/payloads.ts +++ b/packages/core/types/src/http/claim/admin/payloads.ts @@ -24,14 +24,14 @@ interface AdminClaimUpdateItem { interface AdminClaimAddShippingMethod { shipping_option_id: string - custom_price?: number + custom_amount?: number description?: string internal_note?: string metadata?: Record | null } interface AdminClaimUpdateShippingMethod { - custom_price?: number | null + custom_amount?: number | null internal_note?: string metadata?: Record | null } diff --git a/packages/core/types/src/http/exchange/admin/payloads.ts b/packages/core/types/src/http/exchange/admin/payloads.ts index 8db33cc1ebc16..d1fb326be62ca 100644 --- a/packages/core/types/src/http/exchange/admin/payloads.ts +++ b/packages/core/types/src/http/exchange/admin/payloads.ts @@ -24,14 +24,14 @@ interface AdminExchangeUpdateItem { interface AdminExchangeAddShippingMethod { shipping_option_id: string - custom_price?: number + custom_amount?: number description?: string internal_note?: string metadata?: Record | null } interface AdminExchangeUpdateShippingMethod { - custom_price?: number | null + custom_amount?: number | null internal_note?: string metadata?: Record | null } diff --git a/packages/core/types/src/http/return/admin/payloads.ts b/packages/core/types/src/http/return/admin/payloads.ts index 6a5ca97d833d4..3c50bd72b5bac 100644 --- a/packages/core/types/src/http/return/admin/payloads.ts +++ b/packages/core/types/src/http/return/admin/payloads.ts @@ -27,14 +27,14 @@ export interface AdminUpdateReturnItems { export interface AdminAddReturnShipping { shipping_option_id: string - custom_price?: number + custom_amount?: number description?: string internal_note?: string metadata?: Record } export interface AdminUpdateReturnShipping { - custom_price?: number + custom_amount?: number internal_note?: string metadata?: Record } @@ -79,4 +79,4 @@ export interface AdminUpdateDismissItems { internal_note?: string reason_id?: string metadata?: Record -} \ No newline at end of file +} diff --git a/packages/core/types/src/workflow/order/shipping-method.ts b/packages/core/types/src/workflow/order/shipping-method.ts index bfef3b58ea493..dc0c75d0f06fc 100644 --- a/packages/core/types/src/workflow/order/shipping-method.ts +++ b/packages/core/types/src/workflow/order/shipping-method.ts @@ -4,7 +4,7 @@ export interface UpdateReturnShippingMethodWorkflowInput { return_id: string action_id: string data: { - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null internal_note?: string | null metadata?: Record | null } @@ -19,7 +19,7 @@ export interface UpdateClaimShippingMethodWorkflowInput { claim_id: string action_id: string data: { - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null internal_note?: string | null metadata?: Record | null } @@ -34,7 +34,7 @@ export interface UpdateExchangeShippingMethodWorkflowInput { exchange_id: string action_id: string data: { - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null internal_note?: string | null metadata?: Record | null } @@ -44,7 +44,7 @@ export interface UpdateOrderEditShippingMethodWorkflowInput { order_id: string action_id: string data: { - custom_price?: BigNumberInput + custom_amount?: BigNumberInput | null internal_note?: string | null metadata?: Record | null } diff --git a/packages/medusa/src/api/admin/claims/validators.ts b/packages/medusa/src/api/admin/claims/validators.ts index 391f093c1d798..e3c836f325521 100644 --- a/packages/medusa/src/api/admin/claims/validators.ts +++ b/packages/medusa/src/api/admin/claims/validators.ts @@ -91,7 +91,7 @@ export type AdminPostCancelClaimReqSchemaType = z.infer< export const AdminPostClaimsShippingReqSchema = z.object({ shipping_option_id: z.string(), - custom_price: z.number().optional(), + custom_amount: z.number().optional(), description: z.string().optional(), internal_note: z.string().optional(), metadata: z.record(z.unknown()).optional(), @@ -102,7 +102,7 @@ export type AdminPostClaimsShippingReqSchemaType = z.infer< > export const AdminPostClaimsShippingActionReqSchema = z.object({ - custom_price: z.number().optional(), + custom_amount: z.number().nullish().optional(), internal_note: z.string().nullish().optional(), metadata: z.record(z.unknown()).nullish().optional(), }) diff --git a/packages/medusa/src/api/admin/exchanges/validators.ts b/packages/medusa/src/api/admin/exchanges/validators.ts index 62965876fecc7..c7e41ecd4177f 100644 --- a/packages/medusa/src/api/admin/exchanges/validators.ts +++ b/packages/medusa/src/api/admin/exchanges/validators.ts @@ -89,7 +89,7 @@ export type AdminPostExchangesRequestItemsReturnActionReqSchemaType = z.infer< export const AdminPostExchangesShippingReqSchema = z.object({ shipping_option_id: z.string(), - custom_price: z.number().optional(), + custom_amount: z.number().optional(), description: z.string().optional(), internal_note: z.string().optional(), metadata: z.record(z.unknown()).optional(), @@ -100,7 +100,7 @@ export type AdminPostExchangesShippingReqSchemaType = z.infer< > export const AdminPostExchangesShippingActionReqSchema = z.object({ - custom_price: z.number().optional(), + custom_amount: z.number().nullish().optional(), internal_note: z.string().nullish().optional(), metadata: z.record(z.unknown()).nullish().optional(), }) diff --git a/packages/medusa/src/api/admin/order-edits/validators.ts b/packages/medusa/src/api/admin/order-edits/validators.ts index be2c623efa89b..bcd7f80a06881 100644 --- a/packages/medusa/src/api/admin/order-edits/validators.ts +++ b/packages/medusa/src/api/admin/order-edits/validators.ts @@ -12,7 +12,7 @@ export type AdminPostOrderEditsReqSchemaType = z.infer< export const AdminPostOrderEditsShippingReqSchema = z.object({ shipping_option_id: z.string(), - custom_price: z.number().optional(), + custom_amount: z.number().optional(), description: z.string().optional(), internal_note: z.string().optional(), metadata: z.record(z.unknown()).optional(), @@ -23,7 +23,7 @@ export type AdminPostOrderEditsShippingReqSchemaType = z.infer< > export const AdminPostOrderEditsShippingActionReqSchema = z.object({ - custom_price: z.number().optional(), + custom_amount: z.number().nullish().optional(), internal_note: z.string().nullish().optional(), metadata: z.record(z.unknown()).nullish().optional(), }) diff --git a/packages/medusa/src/api/admin/returns/validators.ts b/packages/medusa/src/api/admin/returns/validators.ts index b3304878d5fb0..5539ddb20021d 100644 --- a/packages/medusa/src/api/admin/returns/validators.ts +++ b/packages/medusa/src/api/admin/returns/validators.ts @@ -100,7 +100,7 @@ export type AdminPostCancelReturnReqSchemaType = z.infer< export const AdminPostReturnsShippingReqSchema = z.object({ shipping_option_id: z.string(), - custom_price: z.number().optional(), + custom_amount: z.number().optional(), description: z.string().optional(), internal_note: z.string().optional(), metadata: z.record(z.unknown()).optional(), @@ -111,7 +111,7 @@ export type AdminPostReturnsShippingReqSchemaType = z.infer< > export const AdminPostReturnsShippingActionReqSchema = z.object({ - custom_price: z.number().optional(), + custom_amount: z.number().nullish().optional(), internal_note: z.string().nullish().optional(), metadata: z.record(z.unknown()).nullish().optional(), }) diff --git a/packages/modules/order/src/migrations/.snapshot-medusa-order.json b/packages/modules/order/src/migrations/.snapshot-medusa-order.json index a04808ca90f38..c9eec4b51c870 100644 --- a/packages/modules/order/src/migrations/.snapshot-medusa-order.json +++ b/packages/modules/order/src/migrations/.snapshot-medusa-order.json @@ -183,44 +183,17 @@ "nullable": false, "mappedType": "text" }, - "title": { - "name": "title", - "type": "text", - "unsigned": false, - "autoincrement": false, + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, "primary": false, "nullable": false, - "mappedType": "text" - }, - "subtitle": { - "name": "subtitle", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "thumbnail": { - "name": "thumbnail", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "variant_id": { - "name": "variant_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" + "mappedType": "integer" }, - "product_id": { - "name": "product_id", + "region_id": { + "name": "region_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -228,8 +201,8 @@ "nullable": true, "mappedType": "text" }, - "product_title": { - "name": "product_title", + "customer_id": { + "name": "customer_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -237,17 +210,18 @@ "nullable": true, "mappedType": "text" }, - "product_description": { - "name": "product_description", - "type": "text", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "1", + "mappedType": "integer" }, - "product_subtitle": { - "name": "product_subtitle", + "sales_channel_id": { + "name": "sales_channel_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -255,26 +229,36 @@ "nullable": true, "mappedType": "text" }, - "product_type": { - "name": "product_type", + "status": { + "name": "status", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "'pending'", + "enumItems": [ + "pending", + "completed", + "draft", + "archived", + "canceled", + "requires_action" + ], + "mappedType": "enum" }, - "product_collection": { - "name": "product_collection", - "type": "text", + "is_draft_order": { + "name": "is_draft_order", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "false", + "mappedType": "boolean" }, - "product_handle": { - "name": "product_handle", + "email": { + "name": "email", "type": "text", "unsigned": false, "autoincrement": false, @@ -282,17 +266,17 @@ "nullable": true, "mappedType": "text" }, - "variant_sku": { - "name": "variant_sku", + "currency_code": { + "name": "currency_code", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "variant_barcode": { - "name": "variant_barcode", + "shipping_address_id": { + "name": "shipping_address_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -300,8 +284,8 @@ "nullable": true, "mappedType": "text" }, - "variant_title": { - "name": "variant_title", + "billing_address_id": { + "name": "billing_address_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -309,77 +293,14 @@ "nullable": true, "mappedType": "text" }, - "variant_option_values": { - "name": "variant_option_values", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "requires_shipping": { - "name": "requires_shipping", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "boolean" - }, - "is_discountable": { - "name": "is_discountable", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "boolean" - }, - "is_tax_inclusive": { - "name": "is_tax_inclusive", + "no_notification": { + "name": "no_notification", "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "boolean" - }, - "compare_at_unit_price": { - "name": "compare_at_unit_price", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "raw_compare_at_unit_price": { - "name": "raw_compare_at_unit_price", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "unit_price": { - "name": "unit_price", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, "nullable": true, - "mappedType": "decimal" - }, - "raw_unit_price": { - "name": "raw_unit_price", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" + "mappedType": "boolean" }, "metadata": { "name": "metadata", @@ -421,85 +342,173 @@ "nullable": true, "length": 6, "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, - "name": "order_line_item", + "name": "order", "schema": "public", "indexes": [ { - "keyName": "IDX_order_line_item_variant_id", + "keyName": "IDX_order_display_id", "columnNames": [ - "variant_id" + "display_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_display_id\" ON \"order\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_line_item_product_id", + "keyName": "IDX_order_region_id", "columnNames": [ - "product_id" + "region_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_region_id\" ON \"order\" (region_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_line_item_deleted_at", + "keyName": "IDX_order_customer_id", "columnNames": [ - "deleted_at" + "customer_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_line_item_pkey", + "keyName": "IDX_order_customer_id", "columnNames": [ - "id" + "sales_channel_id" ], "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_is_draft_order", + "columnNames": [ + "is_draft_order" + ], + "composite": false, "primary": false, - "nullable": true, - "mappedType": "text" + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (is_draft_order) WHERE deleted_at IS NOT NULL" }, - "promotion_id": { - "name": "promotion_id", - "type": "text", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_currency_code", + "columnNames": [ + "currency_code" + ], + "composite": false, "primary": false, - "nullable": true, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_currency_code\" ON \"order\" (currency_code) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_address_id", + "columnNames": [ + "shipping_address_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_address_id\" ON \"order\" (shipping_address_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_billing_address_id", + "columnNames": [ + "billing_address_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_billing_address_id\" ON \"order\" (billing_address_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_shipping_address_id_foreign": { + "constraintName": "order_shipping_address_id_foreign", + "columnNames": [ + "shipping_address_id" + ], + "localTableName": "public.order", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_address", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_billing_address_id_foreign": { + "constraintName": "order_billing_address_id_foreign", + "columnNames": [ + "billing_address_id" + ], + "localTableName": "public.order", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_address", + "deleteRule": "set null", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, "mappedType": "text" }, - "code": { - "name": "code", + "title": { + "name": "title", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "subtitle": { + "name": "subtitle", "type": "text", "unsigned": false, "autoincrement": false, @@ -507,26 +516,26 @@ "nullable": true, "mappedType": "text" }, - "amount": { - "name": "amount", - "type": "numeric", + "thumbnail": { + "name": "thumbnail", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "variant_id": { + "name": "variant_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "provider_id": { - "name": "provider_id", + "product_id": { + "name": "product_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -534,101 +543,62 @@ "nullable": true, "mappedType": "text" }, - "created_at": { - "name": "created_at", - "type": "timestamptz", + "product_title": { + "name": "product_title", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "nullable": true, + "mappedType": "text" }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", + "product_description": { + "name": "product_description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "nullable": true, + "mappedType": "text" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", + "product_subtitle": { + "name": "product_subtitle", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "length": 6, - "mappedType": "datetime" + "mappedType": "text" }, - "item_id": { - "name": "item_id", + "product_type": { + "name": "product_type", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" - } - }, - "name": "order_line_item_adjustment", - "schema": "public", - "indexes": [ - { - "keyName": "IDX_order_line_item_adjustment_item_id", - "columnNames": [ - "item_id" - ], - "composite": false, + }, + "product_collection": { + "name": "product_collection", + "type": "text", + "unsigned": false, + "autoincrement": false, "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id)" + "nullable": true, + "mappedType": "text" }, - { - "keyName": "order_line_item_adjustment_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_line_item_adjustment_item_id_foreign": { - "constraintName": "order_line_item_adjustment_item_id_foreign", - "columnNames": [ - "item_id" - ], - "localTableName": "public.order_line_item_adjustment", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_line_item", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", + "product_handle": { + "name": "product_handle", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "description": { - "name": "description", + "variant_sku": { + "name": "variant_sku", "type": "text", "unsigned": false, "autoincrement": false, @@ -636,8 +606,8 @@ "nullable": true, "mappedType": "text" }, - "tax_rate_id": { - "name": "tax_rate_id", + "variant_barcode": { + "name": "variant_barcode", "type": "text", "unsigned": false, "autoincrement": false, @@ -645,26 +615,80 @@ "nullable": true, "mappedType": "text" }, - "code": { - "name": "code", + "variant_title": { + "name": "variant_title", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "rate": { - "name": "rate", - "type": "numeric", + "variant_option_values": { + "name": "variant_option_values", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "requires_shipping": { + "name": "requires_shipping", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "boolean" + }, + "is_discountable": { + "name": "is_discountable", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, + "mappedType": "boolean" + }, + "is_tax_inclusive": { + "name": "is_tax_inclusive", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "boolean" + }, + "compare_at_unit_price": { + "name": "compare_at_unit_price", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, "mappedType": "decimal" }, - "raw_rate": { - "name": "raw_rate", + "raw_compare_at_unit_price": { + "name": "raw_compare_at_unit_price", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "unit_price": { + "name": "unit_price", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "decimal" + }, + "raw_unit_price": { + "name": "raw_unit_price", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -672,14 +696,24 @@ "nullable": false, "mappedType": "json" }, - "provider_id": { - "name": "provider_id", - "type": "text", + "is_custom_price": { + "name": "is_custom_price", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -712,32 +746,43 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "item_id": { - "name": "item_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" } }, - "name": "order_line_item_tax_line", + "name": "order_line_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_line_item_tax_line_item_id", + "keyName": "IDX_order_line_item_variant_id", "columnNames": [ - "item_id" + "variant_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (item_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_line_item_tax_line_pkey", + "keyName": "IDX_order_line_item_product_id", + "columnNames": [ + "product_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_line_item_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_line_item_pkey", "columnNames": [ "id" ], @@ -747,21 +792,7 @@ } ], "checks": [], - "foreignKeys": { - "order_line_item_tax_line_item_id_foreign": { - "constraintName": "order_line_item_tax_line_item_id_foreign", - "columnNames": [ - "item_id" - ], - "localTableName": "public.order_line_item_tax_line", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_line_item", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } + "foreignKeys": {} }, { "columns": { @@ -774,124 +805,164 @@ "nullable": false, "mappedType": "text" }, - "display_id": { - "name": "display_id", - "type": "serial", - "unsigned": true, - "autoincrement": true, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, "primary": false, "nullable": false, "mappedType": "integer" }, - "region_id": { - "name": "region_id", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "customer_id": { - "name": "customer_id", - "type": "text", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "decimal" }, - "version": { - "name": "version", - "type": "integer", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "1", - "mappedType": "integer" + "mappedType": "json" }, - "sales_channel_id": { - "name": "sales_channel_id", - "type": "text", + "fulfilled_quantity": { + "name": "fulfilled_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "raw_fulfilled_quantity": { + "name": "raw_fulfilled_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "shipped_quantity": { + "name": "shipped_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "raw_shipped_quantity": { + "name": "raw_shipped_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "return_requested_quantity": { + "name": "return_requested_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "status": { - "name": "status", - "type": "text", + "raw_return_requested_quantity": { + "name": "raw_return_requested_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "'pending'", - "enumItems": [ - "pending", - "completed", - "draft", - "archived", - "canceled", - "requires_action" - ], - "mappedType": "enum" + "mappedType": "json" }, - "is_draft_order": { - "name": "is_draft_order", - "type": "boolean", + "return_received_quantity": { + "name": "return_received_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "default": "0", + "mappedType": "decimal" }, - "email": { - "name": "email", - "type": "text", + "raw_return_received_quantity": { + "name": "raw_return_received_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "currency_code": { - "name": "currency_code", - "type": "text", + "return_dismissed_quantity": { + "name": "return_dismissed_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "default": "0", + "mappedType": "decimal" }, - "shipping_address_id": { - "name": "shipping_address_id", - "type": "text", + "raw_return_dismissed_quantity": { + "name": "raw_return_dismissed_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "billing_address_id": { - "name": "billing_address_id", - "type": "text", + "written_off_quantity": { + "name": "written_off_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "no_notification": { - "name": "no_notification", - "type": "boolean", + "raw_written_off_quantity": { + "name": "raw_written_off_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "boolean" + "nullable": false, + "mappedType": "json" }, "metadata": { "name": "metadata", @@ -933,113 +1004,53 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" } }, - "name": "order", + "name": "order_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_display_id", - "columnNames": [ - "display_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_display_id\" ON \"order\" (display_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_region_id", - "columnNames": [ - "region_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_region_id\" ON \"order\" (region_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_customer_id", - "columnNames": [ - "customer_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_customer_id", - "columnNames": [ - "sales_channel_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_is_draft_order", - "columnNames": [ - "is_draft_order" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (is_draft_order) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_currency_code", + "keyName": "IDX_order_item_order_id", "columnNames": [ - "currency_code" + "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_currency_code\" ON \"order\" (currency_code) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_address_id", + "keyName": "IDX_order_item_version", "columnNames": [ - "shipping_address_id" + "version" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_address_id\" ON \"order\" (shipping_address_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_billing_address_id", + "keyName": "IDX_order_item_item_id", "columnNames": [ - "billing_address_id" + "item_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_billing_address_id\" ON \"order\" (billing_address_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_deleted_at", + "keyName": "IDX_order_item_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_pkey", + "keyName": "order_item_pkey", "columnNames": [ "id" ], @@ -1050,30 +1061,28 @@ ], "checks": [], "foreignKeys": { - "order_shipping_address_id_foreign": { - "constraintName": "order_shipping_address_id_foreign", + "order_item_order_id_foreign": { + "constraintName": "order_item_order_id_foreign", "columnNames": [ - "shipping_address_id" + "order_id" ], - "localTableName": "public.order", + "localTableName": "public.order_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_address", - "deleteRule": "set null", + "referencedTableName": "public.order", "updateRule": "cascade" }, - "order_billing_address_id_foreign": { - "constraintName": "order_billing_address_id_foreign", + "order_item_item_id_foreign": { + "constraintName": "order_item_item_id_foreign", "columnNames": [ - "billing_address_id" + "item_id" ], - "localTableName": "public.order", + "localTableName": "public.order_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_address", - "deleteRule": "set null", + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } @@ -1089,35 +1098,35 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "description": { + "name": "description", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", + "promotion_id": { + "name": "promotion_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "integer" + "nullable": true, + "mappedType": "text" }, - "item_id": { - "name": "item_id", + "code": { + "name": "code", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "quantity": { - "name": "quantity", + "amount": { + "name": "amount", "type": "numeric", "unsigned": false, "autoincrement": false, @@ -1125,8 +1134,8 @@ "nullable": false, "mappedType": "decimal" }, - "raw_quantity": { - "name": "raw_quantity", + "raw_amount": { + "name": "raw_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -1134,113 +1143,146 @@ "nullable": false, "mappedType": "json" }, - "fulfilled_quantity": { - "name": "fulfilled_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "decimal" - }, - "raw_fulfilled_quantity": { - "name": "raw_fulfilled_quantity", - "type": "jsonb", + "provider_id": { + "name": "provider_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "shipped_quantity": { - "name": "shipped_quantity", - "type": "numeric", + "created_at": { + "name": "created_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "0", - "mappedType": "decimal" + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "raw_shipped_quantity": { - "name": "raw_shipped_quantity", - "type": "jsonb", + "updated_at": { + "name": "updated_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "length": 6, + "default": "now()", + "mappedType": "datetime" }, - "return_requested_quantity": { - "name": "return_requested_quantity", - "type": "numeric", + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "0", - "mappedType": "decimal" + "nullable": true, + "length": 6, + "mappedType": "datetime" }, - "raw_return_requested_quantity": { - "name": "raw_return_requested_quantity", - "type": "jsonb", + "item_id": { + "name": "item_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "text" + } + }, + "name": "order_line_item_adjustment", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_line_item_adjustment_item_id", + "columnNames": [ + "item_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id)" }, - "return_received_quantity": { - "name": "return_received_quantity", - "type": "numeric", + { + "keyName": "order_line_item_adjustment_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_line_item_adjustment_item_id_foreign": { + "constraintName": "order_line_item_adjustment_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_line_item_adjustment", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "0", - "mappedType": "decimal" + "mappedType": "text" }, - "raw_return_received_quantity": { - "name": "raw_return_received_quantity", - "type": "jsonb", + "description": { + "name": "description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "return_dismissed_quantity": { - "name": "return_dismissed_quantity", - "type": "numeric", + "tax_rate_id": { + "name": "tax_rate_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "default": "0", - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_return_dismissed_quantity": { - "name": "raw_return_dismissed_quantity", - "type": "jsonb", + "code": { + "name": "code", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "text" }, - "written_off_quantity": { - "name": "written_off_quantity", + "rate": { + "name": "rate", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "0", "mappedType": "decimal" }, - "raw_written_off_quantity": { - "name": "raw_written_off_quantity", + "raw_rate": { + "name": "raw_rate", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -1248,14 +1290,14 @@ "nullable": false, "mappedType": "json" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "provider_id": { + "name": "provider_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, "created_at": { "name": "created_at", @@ -1288,53 +1330,32 @@ "nullable": true, "length": 6, "mappedType": "datetime" + }, + "item_id": { + "name": "item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" } }, - "name": "order_item", + "name": "order_line_item_tax_line", "schema": "public", "indexes": [ { - "keyName": "IDX_order_item_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_item_version", - "columnNames": [ - "version" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_item_item_id", + "keyName": "IDX_order_line_item_tax_line_item_id", "columnNames": [ "item_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_item_deleted_at", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (item_id)" }, { - "keyName": "order_item_pkey", + "keyName": "order_line_item_tax_line_pkey", "columnNames": [ "id" ], @@ -1345,28 +1366,17 @@ ], "checks": [], "foreignKeys": { - "order_item_order_id_foreign": { - "constraintName": "order_item_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "order_item_item_id_foreign": { - "constraintName": "order_item_item_id_foreign", + "order_line_item_tax_line_item_id_foreign": { + "constraintName": "order_line_item_tax_line_item_id_foreign", "columnNames": [ "item_id" ], - "localTableName": "public.order_item", + "localTableName": "public.order_line_item_tax_line", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order_line_item", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -1382,8 +1392,8 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "name": { + "name": "name", "type": "text", "unsigned": false, "autoincrement": false, @@ -1391,23 +1401,78 @@ "nullable": false, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", + "description": { + "name": "description", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "1", - "mappedType": "integer" + "mappedType": "decimal" }, - "totals": { - "name": "totals", + "raw_amount": { + "name": "raw_amount", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "is_tax_inclusive": { + "name": "is_tax_inclusive", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "is_custom_amount": { + "name": "is_custom_amount", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "shipping_option_id": { + "name": "shipping_option_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "data": { + "name": "data", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "metadata": { + "name": "metadata", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, "created_at": { @@ -1443,29 +1508,31 @@ "mappedType": "datetime" } }, - "name": "order_summary", + "name": "order_shipping_method", "schema": "public", "indexes": [ { - "keyName": "IDX_order_summary_deleted_at", + "keyName": "IDX_order_shipping_method_shipping_option_id", "columnNames": [ - "deleted_at" + "shipping_option_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_summary_order_id_version", - "columnNames": [], + "keyName": "IDX_order_shipping_method_deleted_at", + "columnNames": [ + "deleted_at" + ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_summary_pkey", + "keyName": "order_shipping_method_pkey", "columnNames": [ "id" ], @@ -1475,21 +1542,7 @@ } ], "checks": [], - "foreignKeys": { - "order_summary_order_id_foreign": { - "constraintName": "order_summary_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_summary", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } + "foreignKeys": {} }, { "columns": { @@ -1502,17 +1555,8 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "exchange_id": { - "name": "exchange_id", + "description": { + "name": "description", "type": "text", "unsigned": false, "autoincrement": false, @@ -1520,8 +1564,8 @@ "nullable": true, "mappedType": "text" }, - "claim_id": { - "name": "claim_id", + "promotion_id": { + "name": "promotion_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1529,43 +1573,8 @@ "nullable": true, "mappedType": "text" }, - "order_version": { - "name": "order_version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "display_id": { - "name": "display_id", - "type": "serial", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'open'", - "enumItems": [ - "open", - "requested", - "received", - "partially_received", - "canceled" - ], - "mappedType": "enum" - }, - "location_id": { - "name": "location_id", + "code": { + "name": "code", "type": "text", "unsigned": false, "autoincrement": false, @@ -1573,35 +1582,26 @@ "nullable": true, "mappedType": "text" }, - "no_notification": { - "name": "no_notification", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "boolean" - }, - "refund_amount": { - "name": "refund_amount", + "amount": { + "name": "amount", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "decimal" }, - "raw_refund_amount": { - "name": "raw_refund_amount", + "raw_amount": { + "name": "raw_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "json" }, - "created_by": { - "name": "created_by", + "provider_id": { + "name": "provider_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1609,15 +1609,6 @@ "nullable": true, "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -1650,110 +1641,31 @@ "length": 6, "mappedType": "datetime" }, - "requested_at": { - "name": "requested_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "received_at": { - "name": "received_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", + "shipping_method_id": { + "name": "shipping_method_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "text" } }, - "name": "return", + "name": "order_shipping_method_adjustment", "schema": "public", "indexes": [ { + "keyName": "IDX_order_shipping_method_adjustment_shipping_method_id", "columnNames": [ - "exchange_id" - ], - "composite": false, - "keyName": "return_exchange_id_unique", - "primary": false, - "unique": true - }, - { - "columnNames": [ - "claim_id" - ], - "composite": false, - "keyName": "return_claim_id_unique", - "primary": false, - "unique": true - }, - { - "keyName": "IDX_return_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_exchange_id", - "columnNames": [ - "exchange_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_claim_id", - "columnNames": [ - "claim_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_display_id", - "columnNames": [ - "display_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_deleted_at", - "columnNames": [ - "deleted_at" + "shipping_method_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (shipping_method_id)" }, { - "keyName": "return_pkey", + "keyName": "order_shipping_method_adjustment_pkey", "columnNames": [ "id" ], @@ -1763,43 +1675,18 @@ } ], "checks": [], - "foreignKeys": { - "return_order_id_foreign": { - "constraintName": "return_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.return", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "return_exchange_id_foreign": { - "constraintName": "return_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.return", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "return_claim_id_foreign": { - "constraintName": "return_claim_id_foreign", + "foreignKeys": { + "order_shipping_method_adjustment_shipping_method_id_foreign": { + "constraintName": "order_shipping_method_adjustment_shipping_method_id_foreign", "columnNames": [ - "claim_id" + "shipping_method_id" ], - "localTableName": "public.return", + "localTableName": "public.order_shipping_method_adjustment", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", + "referencedTableName": "public.order_shipping_method", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -1815,17 +1702,17 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "description": { + "name": "description", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "return_id": { - "name": "return_id", + "tax_rate_id": { + "name": "tax_rate_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1833,63 +1720,35 @@ "nullable": true, "mappedType": "text" }, - "order_version": { - "name": "order_version", - "type": "integer", + "code": { + "name": "code", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "integer" - }, - "display_id": { - "name": "display_id", - "type": "serial", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "no_notification": { - "name": "no_notification", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "boolean" + "mappedType": "text" }, - "difference_due": { - "name": "difference_due", + "rate": { + "name": "rate", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "decimal" }, - "raw_difference_due": { - "name": "raw_difference_due", + "raw_rate": { + "name": "raw_rate", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" - }, - "allow_backorder": { - "name": "allow_backorder", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "mappedType": "json" }, - "created_by": { - "name": "created_by", + "provider_id": { + "name": "provider_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1897,15 +1756,6 @@ "nullable": true, "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -1938,71 +1788,31 @@ "length": 6, "mappedType": "datetime" }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", + "shipping_method_id": { + "name": "shipping_method_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "mappedType": "text" } }, - "name": "order_exchange", + "name": "order_shipping_method_tax_line", "schema": "public", "indexes": [ { + "keyName": "IDX_order_shipping_method_tax_line_shipping_method_id", "columnNames": [ - "return_id" - ], - "composite": false, - "keyName": "order_exchange_return_id_unique", - "primary": false, - "unique": true - }, - { - "keyName": "IDX_order_exchange_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_exchange_return_id", - "columnNames": [ - "return_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_exchange_display_id", - "columnNames": [ - "display_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (display_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_exchange_deleted_at", - "columnNames": [ - "deleted_at" + "shipping_method_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (shipping_method_id)" }, { - "keyName": "order_exchange_pkey", + "keyName": "order_shipping_method_tax_line_pkey", "columnNames": [ "id" ], @@ -2013,29 +1823,17 @@ ], "checks": [], "foreignKeys": { - "order_exchange_order_id_foreign": { - "constraintName": "order_exchange_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_exchange", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "order_exchange_return_id_foreign": { - "constraintName": "order_exchange_return_id_foreign", + "order_shipping_method_tax_line_shipping_method_id_foreign": { + "constraintName": "order_shipping_method_tax_line_shipping_method_id_foreign", "columnNames": [ - "return_id" + "shipping_method_id" ], - "localTableName": "public.order_exchange", + "localTableName": "public.order_shipping_method_tax_line", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return", - "deleteRule": "set null", + "referencedTableName": "public.order_shipping_method", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -2051,26 +1849,8 @@ "nullable": false, "mappedType": "text" }, - "quantity": { - "name": "quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "exchange_id": { - "name": "exchange_id", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2078,31 +1858,23 @@ "nullable": false, "mappedType": "text" }, - "item_id": { - "name": "item_id", - "type": "text", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" - }, - "note": { - "name": "note", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" + "default": "1", + "mappedType": "integer" }, - "metadata": { - "name": "metadata", + "totals": { + "name": "totals", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "json" }, "created_at": { @@ -2138,41 +1910,29 @@ "mappedType": "datetime" } }, - "name": "order_exchange_item", + "name": "order_summary", "schema": "public", "indexes": [ { - "keyName": "IDX_order_exchange_item_exchange_id", - "columnNames": [ - "exchange_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_exchange_item_item_id", + "keyName": "IDX_order_summary_deleted_at", "columnNames": [ - "item_id" + "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_item_image_deleted_at", - "columnNames": [ - "deleted_at" - ], + "keyName": "IDX_order_summary_order_id_version", + "columnNames": [], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (order_id, version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_exchange_item_pkey", + "keyName": "order_summary_pkey", "columnNames": [ "id" ], @@ -2183,29 +1943,17 @@ ], "checks": [], "foreignKeys": { - "order_exchange_item_exchange_id_foreign": { - "constraintName": "order_exchange_item_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.order_exchange_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "order_exchange_item_item_id_foreign": { - "constraintName": "order_exchange_item_item_id_foreign", + "order_summary_order_id_foreign": { + "constraintName": "order_summary_order_id_foreign", "columnNames": [ - "item_id" + "order_id" ], - "localTableName": "public.order_exchange_item", + "localTableName": "public.order_summary", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_line_item", + "referencedTableName": "public.order", + "deleteRule": "cascade", "updateRule": "cascade" } } @@ -2230,8 +1978,17 @@ "nullable": false, "mappedType": "text" }, - "return_id": { - "name": "return_id", + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2257,19 +2014,32 @@ "nullable": false, "mappedType": "integer" }, - "type": { - "name": "type", + "status": { + "name": "status", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, + "default": "'open'", "enumItems": [ - "refund", - "replace" + "open", + "requested", + "received", + "partially_received", + "canceled" ], "mappedType": "enum" }, + "location_id": { + "name": "location_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "no_notification": { "name": "no_notification", "type": "boolean", @@ -2347,6 +2117,26 @@ "length": 6, "mappedType": "datetime" }, + "requested_at": { + "name": "requested_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "received_at": { + "name": "received_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, "canceled_at": { "name": "canceled_at", "type": "timestamptz", @@ -2358,60 +2148,79 @@ "mappedType": "datetime" } }, - "name": "order_claim", + "name": "return", "schema": "public", "indexes": [ { "columnNames": [ - "return_id" + "exchange_id" ], "composite": false, - "keyName": "order_claim_return_id_unique", + "keyName": "return_exchange_id_unique", "primary": false, "unique": true }, { - "keyName": "IDX_order_claim_order_id", + "columnNames": [ + "claim_id" + ], + "composite": false, + "keyName": "return_claim_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_return_order_id", "columnNames": [ "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_return_id", + "keyName": "IDX_return_exchange_id", "columnNames": [ - "return_id" + "exchange_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_display_id", + "keyName": "IDX_return_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_display_id", "columnNames": [ "display_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (display_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_deleted_at", + "keyName": "IDX_return_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_claim_pkey", + "keyName": "return_pkey", "columnNames": [ "id" ], @@ -2422,28 +2231,41 @@ ], "checks": [], "foreignKeys": { - "order_claim_order_id_foreign": { - "constraintName": "order_claim_order_id_foreign", + "return_order_id_foreign": { + "constraintName": "return_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_claim", + "localTableName": "public.return", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", "updateRule": "cascade" }, - "order_claim_return_id_foreign": { - "constraintName": "order_claim_return_id_foreign", + "return_exchange_id_foreign": { + "constraintName": "return_exchange_id_foreign", "columnNames": [ - "return_id" + "exchange_id" ], - "localTableName": "public.order_claim", + "localTableName": "public.return", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return", + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "return_claim_id_foreign": { + "constraintName": "return_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.return", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", "deleteRule": "set null", "updateRule": "cascade" } @@ -2460,59 +2282,71 @@ "nullable": false, "mappedType": "text" }, - "reason": { - "name": "reason", + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "enumItems": [ - "missing_item", - "wrong_item", - "production_failure", - "other" - ], - "mappedType": "enum" + "mappedType": "text" }, - "quantity": { - "name": "quantity", - "type": "numeric", + "order_version": { + "name": "order_version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "mappedType": "integer" }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "boolean" }, - "claim_id": { - "name": "claim_id", - "type": "text", + "difference_due": { + "name": "difference_due", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "nullable": true, + "mappedType": "decimal" }, - "item_id": { - "name": "item_id", - "type": "text", + "raw_difference_due": { + "name": "raw_difference_due", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "nullable": true, + "mappedType": "json" }, - "is_additional_item": { - "name": "is_additional_item", + "allow_backorder": { + "name": "allow_backorder", "type": "boolean", "unsigned": false, "autoincrement": false, @@ -2521,8 +2355,8 @@ "default": "false", "mappedType": "boolean" }, - "note": { - "name": "note", + "created_by": { + "name": "created_by", "type": "text", "unsigned": false, "autoincrement": false, @@ -2570,43 +2404,72 @@ "nullable": true, "length": 6, "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, - "name": "order_claim_item", + "name": "order_exchange", "schema": "public", "indexes": [ { - "keyName": "IDX_order_claim_item_claim_id", "columnNames": [ - "claim_id" + "return_id" + ], + "composite": false, + "keyName": "order_exchange_return_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_exchange_order_id", + "columnNames": [ + "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_item_item_id", + "keyName": "IDX_order_exchange_return_id", "columnNames": [ - "item_id" + "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_claim_item_deleted_at", + "keyName": "IDX_order_exchange_display_id", + "columnNames": [ + "display_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (display_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_exchange_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_claim_item_pkey", + "keyName": "order_exchange_pkey", "columnNames": [ "id" ], @@ -2617,29 +2480,29 @@ ], "checks": [], "foreignKeys": { - "order_claim_item_claim_id_foreign": { - "constraintName": "order_claim_item_claim_id_foreign", + "order_exchange_order_id_foreign": { + "constraintName": "order_exchange_order_id_foreign", "columnNames": [ - "claim_id" + "order_id" ], - "localTableName": "public.order_claim_item", + "localTableName": "public.order_exchange", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim", - "deleteRule": "cascade", + "referencedTableName": "public.order", "updateRule": "cascade" }, - "order_claim_item_item_id_foreign": { - "constraintName": "order_claim_item_item_id_foreign", + "order_exchange_return_id_foreign": { + "constraintName": "order_exchange_return_id_foreign", "columnNames": [ - "item_id" + "return_id" ], - "localTableName": "public.order_claim_item", + "localTableName": "public.order_exchange", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_line_item", + "referencedTableName": "public.return", + "deleteRule": "set null", "updateRule": "cascade" } } @@ -2655,8 +2518,26 @@ "nullable": false, "mappedType": "text" }, - "claim_item_id": { - "name": "claim_item_id", + "quantity": { + "name": "quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "decimal" + }, + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2664,8 +2545,8 @@ "nullable": false, "mappedType": "text" }, - "url": { - "name": "url", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -2673,6 +2554,15 @@ "nullable": false, "mappedType": "text" }, + "note": { + "name": "note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "metadata": { "name": "metadata", "type": "jsonb", @@ -2715,18 +2605,28 @@ "mappedType": "datetime" } }, - "name": "order_claim_item_image", + "name": "order_exchange_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_claim_item_image_claim_item_id", + "keyName": "IDX_order_exchange_item_exchange_id", "columnNames": [ - "claim_item_id" + "exchange_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_exchange_item_item_id", + "columnNames": [ + "item_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_claim_item_image_deleted_at", @@ -2739,7 +2639,7 @@ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_claim_item_image_pkey", + "keyName": "order_exchange_item_pkey", "columnNames": [ "id" ], @@ -2750,16 +2650,29 @@ ], "checks": [], "foreignKeys": { - "order_claim_item_image_claim_item_id_foreign": { - "constraintName": "order_claim_item_image_claim_item_id_foreign", + "order_exchange_item_exchange_id_foreign": { + "constraintName": "order_exchange_item_exchange_id_foreign", "columnNames": [ - "claim_item_id" + "exchange_id" ], - "localTableName": "public.order_claim_item_image", + "localTableName": "public.order_exchange_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim_item", + "referencedTableName": "public.order_exchange", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_exchange_item_item_id_foreign": { + "constraintName": "order_exchange_item_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_exchange_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } @@ -2793,26 +2706,8 @@ "nullable": true, "mappedType": "text" }, - "claim_id": { - "name": "claim_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "exchange_id": { - "name": "exchange_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "version": { - "name": "version", + "order_version": { + "name": "order_version", "type": "integer", "unsigned": false, "autoincrement": false, @@ -2820,117 +2715,48 @@ "nullable": false, "mappedType": "integer" }, - "change_type": { - "name": "change_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "integer" }, - "status": { - "name": "status", + "type": { + "name": "type", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "'pending'", "enumItems": [ - "confirmed", - "declined", - "requested", - "pending", - "canceled" + "refund", + "replace" ], "mappedType": "enum" }, - "internal_note": { - "name": "internal_note", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "created_by": { - "name": "created_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "requested_at": { - "name": "requested_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "confirmed_by": { - "name": "confirmed_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "declined_by": { - "name": "declined_by", - "type": "text", + "no_notification": { + "name": "no_notification", + "type": "boolean", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "boolean" }, - "declined_reason": { - "name": "declined_reason", - "type": "text", + "refund_amount": { + "name": "refund_amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "decimal" }, - "metadata": { - "name": "metadata", + "raw_refund_amount": { + "name": "raw_refund_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -2938,34 +2764,23 @@ "nullable": true, "mappedType": "json" }, - "declined_at": { - "name": "declined_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "canceled_by": { - "name": "canceled_by", + "created_by": { + "name": "created_by", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, "mappedType": "text" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", + }, + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "length": 6, - "mappedType": "datetime" + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -2998,91 +2813,72 @@ "nullable": true, "length": 6, "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, - "name": "order_change", + "name": "order_claim", "schema": "public", "indexes": [ { - "keyName": "IDX_order_change_order_id", - "columnNames": [ - "order_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_return_id", "columnNames": [ "return_id" ], "composite": false, + "keyName": "order_claim_return_id_unique", "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_claim_id", - "columnNames": [ - "claim_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "unique": true }, { - "keyName": "IDX_order_change_exchange_id", + "keyName": "IDX_order_claim_order_id", "columnNames": [ - "exchange_id" + "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_order_id_version", + "keyName": "IDX_order_claim_return_id", "columnNames": [ - "version" + "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_status", + "keyName": "IDX_order_claim_display_id", "columnNames": [ - "status" + "display_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (display_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_deleted_at", + "keyName": "IDX_order_claim_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_change_order_id_version", - "columnNames": [], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_change_pkey", + "keyName": "order_claim_pkey", "columnNames": [ "id" ], @@ -3093,57 +2889,30 @@ ], "checks": [], "foreignKeys": { - "order_change_order_id_foreign": { - "constraintName": "order_change_order_id_foreign", + "order_claim_order_id_foreign": { + "constraintName": "order_claim_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_change", + "localTableName": "public.order_claim", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", - "deleteRule": "cascade", "updateRule": "cascade" }, - "order_change_return_id_foreign": { - "constraintName": "order_change_return_id_foreign", + "order_claim_return_id_foreign": { + "constraintName": "order_claim_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_change", + "localTableName": "public.order_claim", "referencedColumnNames": [ "id" ], "referencedTableName": "public.return", "deleteRule": "set null", "updateRule": "cascade" - }, - "order_change_claim_id_foreign": { - "constraintName": "order_change_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.order_change", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_exchange_id_foreign": { - "constraintName": "order_change_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.order_change", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", - "updateRule": "cascade" } } }, @@ -3158,22 +2927,13 @@ "nullable": false, "mappedType": "text" }, - "ordering": { - "name": "ordering", - "type": "integer", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, "order_id": { "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, "return_id": { @@ -3185,8 +2945,8 @@ "nullable": true, "mappedType": "text" }, - "claim_id": { - "name": "claim_id", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3194,8 +2954,8 @@ "nullable": true, "mappedType": "text" }, - "exchange_id": { - "name": "exchange_id", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3209,47 +2969,21 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, + "default": "1", "mappedType": "integer" }, - "order_change_id": { - "name": "order_change_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "reference": { - "name": "reference", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "reference_id": { - "name": "reference_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "action": { - "name": "action", - "type": "text", + "amount": { + "name": "amount", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "text" + "mappedType": "decimal" }, - "details": { - "name": "details", + "raw_amount": { + "name": "raw_amount", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -3257,26 +2991,26 @@ "nullable": false, "mappedType": "json" }, - "amount": { - "name": "amount", - "type": "numeric", + "currency_code": { + "name": "currency_code", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "decimal" + "nullable": false, + "mappedType": "text" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "reference": { + "name": "reference", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "internal_note": { - "name": "internal_note", + "reference_id": { + "name": "reference_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3284,16 +3018,6 @@ "nullable": true, "mappedType": "text" }, - "applied": { - "name": "applied", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" - }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -3327,81 +3051,89 @@ "mappedType": "datetime" } }, - "name": "order_change_action", + "name": "order_transaction", "schema": "public", "indexes": [ { - "keyName": "IDX_order_change_action_ordering", + "keyName": "IDX_order_transaction_order_id", "columnNames": [ - "ordering" + "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_order_id", + "keyName": "IDX_order_transaction_return_id", "columnNames": [ - "order_id" + "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_return_id", + "keyName": "IDX_order_transaction_exchange_id", "columnNames": [ - "return_id" + "exchange_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_claim_id", + "keyName": "IDX_order_transaction_claim_id", "columnNames": [ "claim_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_exchange_id", + "keyName": "IDX_order_transaction_currency_code", "columnNames": [ - "exchange_id" + "currency_code" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_order_change_id", + "keyName": "IDX_order_transaction_reference_id", "columnNames": [ - "order_change_id" + "reference_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_deleted_at", + "keyName": "IDX_order_transaction_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_order_id_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (order_id, version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_change_action_pkey", + "keyName": "order_transaction_pkey", "columnNames": [ "id" ], @@ -3412,12 +3144,12 @@ ], "checks": [], "foreignKeys": { - "order_change_action_order_id_foreign": { - "constraintName": "order_change_action_order_id_foreign", + "order_transaction_order_id_foreign": { + "constraintName": "order_transaction_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_change_action", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], @@ -3425,12 +3157,12 @@ "deleteRule": "cascade", "updateRule": "cascade" }, - "order_change_action_return_id_foreign": { - "constraintName": "order_change_action_return_id_foreign", + "order_transaction_return_id_foreign": { + "constraintName": "order_transaction_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_change_action", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], @@ -3438,25 +3170,12 @@ "deleteRule": "set null", "updateRule": "cascade" }, - "order_change_action_claim_id_foreign": { - "constraintName": "order_change_action_claim_id_foreign", - "columnNames": [ - "claim_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_change_action_exchange_id_foreign": { - "constraintName": "order_change_action_exchange_id_foreign", + "order_transaction_exchange_id_foreign": { + "constraintName": "order_transaction_exchange_id_foreign", "columnNames": [ "exchange_id" ], - "localTableName": "public.order_change_action", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], @@ -3464,17 +3183,17 @@ "deleteRule": "set null", "updateRule": "cascade" }, - "order_change_action_order_change_id_foreign": { - "constraintName": "order_change_action_order_change_id_foreign", + "order_transaction_claim_id_foreign": { + "constraintName": "order_transaction_claim_id_foreign", "columnNames": [ - "order_change_id" + "claim_id" ], - "localTableName": "public.order_change_action", + "localTableName": "public.order_transaction", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_change", - "deleteRule": "cascade", + "referencedTableName": "public.order_claim", + "deleteRule": "set null", "updateRule": "cascade" } } @@ -3490,8 +3209,8 @@ "nullable": false, "mappedType": "text" }, - "value": { - "name": "value", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3499,17 +3218,17 @@ "nullable": false, "mappedType": "text" }, - "label": { - "name": "label", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "description": { - "name": "description", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3517,8 +3236,8 @@ "nullable": true, "mappedType": "text" }, - "parent_return_reason_id": { - "name": "parent_return_reason_id", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3526,14 +3245,23 @@ "nullable": true, "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "json" + "nullable": false, + "mappedType": "integer" + }, + "shipping_method_id": { + "name": "shipping_method_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" }, "created_at": { "name": "created_at", @@ -3568,41 +3296,81 @@ "mappedType": "datetime" } }, - "name": "return_reason", + "name": "order_shipping", "schema": "public", "indexes": [ { - "keyName": "IDX_return_reason_value", + "keyName": "IDX_order_shipping_order_id", "columnNames": [ - "value" + "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_return_reason_parent_return_reason_id", + "keyName": "IDX_order_shipping_return_id", "columnNames": [ - "parent_return_reason_id" + "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_return_reason_deleted_at", + "keyName": "IDX_order_shipping_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_version", + "columnNames": [ + "version" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_version\" ON \"order_shipping\" (version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_shipping_method_id", + "columnNames": [ + "shipping_method_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "return_reason_pkey", + "keyName": "order_shipping_pkey", "columnNames": [ "id" ], @@ -3613,18 +3381,68 @@ ], "checks": [], "foreignKeys": { - "return_reason_parent_return_reason_id_foreign": { - "constraintName": "return_reason_parent_return_reason_id_foreign", + "order_shipping_order_id_foreign": { + "constraintName": "order_shipping_order_id_foreign", "columnNames": [ - "parent_return_reason_id" + "order_id" ], - "localTableName": "public.return_reason", + "localTableName": "public.order_shipping", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return_reason", + "referencedTableName": "public.order", + "updateRule": "cascade" + }, + "order_shipping_return_id_foreign": { + "constraintName": "order_shipping_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_exchange_id_foreign": { + "constraintName": "order_shipping_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_claim_id_foreign": { + "constraintName": "order_shipping_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", "deleteRule": "set null", "updateRule": "cascade" + }, + "order_shipping_shipping_method_id_foreign": { + "constraintName": "order_shipping_shipping_method_id_foreign", + "columnNames": [ + "shipping_method_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_shipping_method", + "updateRule": "cascade" } } }, @@ -3639,14 +3457,20 @@ "nullable": false, "mappedType": "text" }, - "reason_id": { - "name": "reason_id", + "reason": { + "name": "reason", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "enumItems": [ + "missing_item", + "wrong_item", + "production_failure", + "other" + ], + "mappedType": "enum" }, "quantity": { "name": "quantity", @@ -3666,46 +3490,8 @@ "nullable": false, "mappedType": "json" }, - "received_quantity": { - "name": "received_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "decimal" - }, - "raw_received_quantity": { - "name": "raw_received_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "damaged_quantity": { - "name": "damaged_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "0", - "mappedType": "decimal" - }, - "raw_damaged_quantity": { - "name": "raw_damaged_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "return_id": { - "name": "return_id", + "claim_id": { + "name": "claim_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3722,6 +3508,16 @@ "nullable": false, "mappedType": "text" }, + "is_additional_item": { + "name": "is_additional_item", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, "note": { "name": "note", "type": "text", @@ -3773,51 +3569,41 @@ "mappedType": "datetime" } }, - "name": "return_item", + "name": "order_claim_item", "schema": "public", "indexes": [ { - "keyName": "IDX_return_item_reason_id", - "columnNames": [ - "reason_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_return_item_return_id", + "keyName": "IDX_order_claim_item_claim_id", "columnNames": [ - "return_id" + "claim_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (return_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_return_item_item_id", + "keyName": "IDX_order_claim_item_item_id", "columnNames": [ "item_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_item_id\" ON \"return_item\" (item_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_return_item_deleted_at", + "keyName": "IDX_order_claim_item_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "return_item_pkey", + "keyName": "order_claim_item_pkey", "columnNames": [ "id" ], @@ -3828,42 +3614,149 @@ ], "checks": [], "foreignKeys": { - "return_item_reason_id_foreign": { - "constraintName": "return_item_reason_id_foreign", + "order_claim_item_claim_id_foreign": { + "constraintName": "order_claim_item_claim_id_foreign", "columnNames": [ - "reason_id" + "claim_id" ], - "localTableName": "public.return_item", + "localTableName": "public.order_claim_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return_reason", - "deleteRule": "set null", + "referencedTableName": "public.order_claim", + "deleteRule": "cascade", "updateRule": "cascade" }, - "return_item_return_id_foreign": { - "constraintName": "return_item_return_id_foreign", + "order_claim_item_item_id_foreign": { + "constraintName": "order_claim_item_item_id_foreign", "columnNames": [ - "return_id" + "item_id" ], - "localTableName": "public.return_item", + "localTableName": "public.order_claim_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.return", - "deleteRule": "cascade", + "referencedTableName": "public.order_line_item", "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" }, - "return_item_item_id_foreign": { - "constraintName": "return_item_item_id_foreign", + "claim_item_id": { + "name": "claim_item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "url": { + "name": "url", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_claim_item_image", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_claim_item_image_claim_item_id", "columnNames": [ - "item_id" + "claim_item_id" ], - "localTableName": "public.return_item", + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_claim_item_image_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_claim_item_image_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_claim_item_image_claim_item_id_foreign": { + "constraintName": "order_claim_item_image_claim_item_id_foreign", + "columnNames": [ + "claim_item_id" + ], + "localTableName": "public.order_claim_item_image", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_line_item", + "referencedTableName": "public.order_claim_item", "updateRule": "cascade" } } @@ -3879,8 +3772,8 @@ "nullable": false, "mappedType": "text" }, - "name": { - "name": "name", + "order_id": { + "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -3888,45 +3781,79 @@ "nullable": false, "mappedType": "text" }, - "description": { - "name": "description", - "type": "jsonb", + "return_id": { + "name": "return_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "amount": { - "name": "amount", - "type": "numeric", + "claim_id": { + "name": "claim_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_amount": { - "name": "raw_amount", - "type": "jsonb", + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "version": { + "name": "version", + "type": "integer", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "integer" }, - "is_tax_inclusive": { - "name": "is_tax_inclusive", - "type": "boolean", + "change_type": { + "name": "change_type", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "status": { + "name": "status", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "false", - "mappedType": "boolean" + "default": "'pending'", + "enumItems": [ + "confirmed", + "declined", + "requested", + "pending", + "canceled" + ], + "mappedType": "enum" }, - "shipping_option_id": { - "name": "shipping_option_id", + "internal_note": { + "name": "internal_note", "type": "text", "unsigned": false, "autoincrement": false, @@ -3934,48 +3861,45 @@ "nullable": true, "mappedType": "text" }, - "data": { - "name": "data", - "type": "jsonb", + "created_by": { + "name": "created_by", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "metadata": { - "name": "metadata", - "type": "jsonb", + "requested_by": { + "name": "requested_by", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "json" + "mappedType": "text" }, - "created_at": { - "name": "created_at", + "requested_at": { + "name": "requested_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "length": 6, - "default": "now()", "mappedType": "datetime" }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", + "confirmed_by": { + "name": "confirmed_by", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" + "nullable": true, + "mappedType": "text" }, - "deleted_at": { - "name": "deleted_at", + "confirmed_at": { + "name": "confirmed_at", "type": "timestamptz", "unsigned": false, "autoincrement": false, @@ -3983,84 +3907,46 @@ "nullable": true, "length": 6, "mappedType": "datetime" - } - }, - "name": "order_shipping_method", - "schema": "public", - "indexes": [ - { - "keyName": "IDX_order_shipping_method_shipping_option_id", - "columnNames": [ - "shipping_option_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_shipping_method_deleted_at", - "columnNames": [ - "deleted_at" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (deleted_at) WHERE deleted_at IS NOT NULL" }, - { - "keyName": "order_shipping_method_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {} - }, - { - "columns": { - "id": { - "name": "id", + "declined_by": { + "name": "declined_by", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "declined_reason": { + "name": "declined_reason", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "return_id": { - "name": "return_id", - "type": "text", + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "mappedType": "json" }, - "exchange_id": { - "name": "exchange_id", - "type": "text", + "declined_at": { + "name": "declined_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "mappedType": "text" + "length": 6, + "mappedType": "datetime" }, - "claim_id": { - "name": "claim_id", + "canceled_by": { + "name": "canceled_by", "type": "text", "unsigned": false, "autoincrement": false, @@ -4068,23 +3954,15 @@ "nullable": true, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "text" + "nullable": true, + "length": 6, + "mappedType": "datetime" }, "created_at": { "name": "created_at", @@ -4119,81 +3997,89 @@ "mappedType": "datetime" } }, - "name": "order_shipping", + "name": "order_change", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_order_id", + "keyName": "IDX_order_change_order_id", "columnNames": [ "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_return_id", + "keyName": "IDX_order_change_return_id", "columnNames": [ "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_exchange_id", + "keyName": "IDX_order_change_claim_id", "columnNames": [ - "exchange_id" + "claim_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_claim_id", + "keyName": "IDX_order_change_exchange_id", "columnNames": [ - "claim_id" + "exchange_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_version", + "keyName": "IDX_order_change_order_id_version", "columnNames": [ "version" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_version\" ON \"order_shipping\" (version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_shipping_method_id", + "keyName": "IDX_order_change_status", "columnNames": [ - "shipping_method_id" + "status" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_shipping_deleted_at", + "keyName": "IDX_order_change_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_shipping_pkey", + "keyName": "IDX_order_change_order_id_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_change_pkey", "columnNames": [ "id" ], @@ -4204,24 +4090,25 @@ ], "checks": [], "foreignKeys": { - "order_shipping_order_id_foreign": { - "constraintName": "order_shipping_order_id_foreign", + "order_change_order_id_foreign": { + "constraintName": "order_change_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_change", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_shipping_return_id_foreign": { - "constraintName": "order_shipping_return_id_foreign", + "order_change_return_id_foreign": { + "constraintName": "order_change_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_change", "referencedColumnNames": [ "id" ], @@ -4229,59 +4116,101 @@ "deleteRule": "set null", "updateRule": "cascade" }, - "order_shipping_exchange_id_foreign": { - "constraintName": "order_shipping_exchange_id_foreign", + "order_change_claim_id_foreign": { + "constraintName": "order_change_claim_id_foreign", "columnNames": [ - "exchange_id" + "claim_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_change", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_exchange", + "referencedTableName": "public.order_claim", "deleteRule": "set null", "updateRule": "cascade" }, - "order_shipping_claim_id_foreign": { - "constraintName": "order_shipping_claim_id_foreign", + "order_change_exchange_id_foreign": { + "constraintName": "order_change_exchange_id_foreign", "columnNames": [ - "claim_id" + "exchange_id" ], - "localTableName": "public.order_shipping", + "localTableName": "public.order_change", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim", + "referencedTableName": "public.order_exchange", "deleteRule": "set null", "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "ordering": { + "name": "ordering", + "type": "integer", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" }, - "order_shipping_shipping_method_id_foreign": { - "constraintName": "order_shipping_shipping_method_id_foreign", - "columnNames": [ - "shipping_method_id" - ], - "localTableName": "public.order_shipping", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_shipping_method", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", + "exchange_id": { + "name": "exchange_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "description": { - "name": "description", + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "integer" + }, + "order_change_id": { + "name": "order_change_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -4289,8 +4218,8 @@ "nullable": true, "mappedType": "text" }, - "promotion_id": { - "name": "promotion_id", + "reference": { + "name": "reference", "type": "text", "unsigned": false, "autoincrement": false, @@ -4298,8 +4227,8 @@ "nullable": true, "mappedType": "text" }, - "code": { - "name": "code", + "reference_id": { + "name": "reference_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -4307,13 +4236,31 @@ "nullable": true, "mappedType": "text" }, + "action": { + "name": "action", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "details": { + "name": "details", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, "amount": { "name": "amount", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "decimal" }, "raw_amount": { @@ -4322,11 +4269,11 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "json" }, - "provider_id": { - "name": "provider_id", + "internal_note": { + "name": "internal_note", "type": "text", "unsigned": false, "autoincrement": false, @@ -4334,6 +4281,16 @@ "nullable": true, "mappedType": "text" }, + "applied": { + "name": "applied", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -4365,32 +4322,83 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" } }, - "name": "order_shipping_method_adjustment", + "name": "order_change_action", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_method_adjustment_shipping_method_id", + "keyName": "IDX_order_change_action_ordering", "columnNames": [ - "shipping_method_id" + "ordering" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (shipping_method_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_shipping_method_adjustment_pkey", + "keyName": "IDX_order_change_action_order_id", + "columnNames": [ + "order_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_return_id", + "columnNames": [ + "return_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_order_change_id", + "columnNames": [ + "order_change_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_action_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_change_action_pkey", "columnNames": [ "id" ], @@ -4401,16 +4409,68 @@ ], "checks": [], "foreignKeys": { - "order_shipping_method_adjustment_shipping_method_id_foreign": { - "constraintName": "order_shipping_method_adjustment_shipping_method_id_foreign", + "order_change_action_order_id_foreign": { + "constraintName": "order_change_action_order_id_foreign", "columnNames": [ - "shipping_method_id" + "order_id" ], - "localTableName": "public.order_shipping_method_adjustment", + "localTableName": "public.order_change_action", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_shipping_method", + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_change_action_return_id_foreign": { + "constraintName": "order_change_action_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_claim_id_foreign": { + "constraintName": "order_change_action_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_exchange_id_foreign": { + "constraintName": "order_change_action_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_order_change_id_foreign": { + "constraintName": "order_change_action_order_change_id_foreign", + "columnNames": [ + "order_change_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_change", "deleteRule": "cascade", "updateRule": "cascade" } @@ -4427,53 +4487,35 @@ "nullable": false, "mappedType": "text" }, - "description": { - "name": "description", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "tax_rate_id": { - "name": "tax_rate_id", + "value": { + "name": "value", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "code": { - "name": "code", + "label": { + "name": "label", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, "mappedType": "text" - }, - "rate": { - "name": "rate", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_rate": { - "name": "raw_rate", - "type": "jsonb", + }, + "description": { + "name": "description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, - "provider_id": { - "name": "provider_id", + "parent_return_reason_id": { + "name": "parent_return_reason_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -4481,6 +4523,15 @@ "nullable": true, "mappedType": "text" }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -4512,32 +4563,43 @@ "nullable": true, "length": 6, "mappedType": "datetime" - }, - "shipping_method_id": { - "name": "shipping_method_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" } }, - "name": "order_shipping_method_tax_line", + "name": "return_reason", "schema": "public", "indexes": [ { - "keyName": "IDX_order_shipping_method_tax_line_shipping_method_id", + "keyName": "IDX_return_reason_value", "columnNames": [ - "shipping_method_id" + "value" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (shipping_method_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_shipping_method_tax_line_pkey", + "keyName": "IDX_return_reason_parent_return_reason_id", + "columnNames": [ + "parent_return_reason_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_reason_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "return_reason_pkey", "columnNames": [ "id" ], @@ -4548,17 +4610,17 @@ ], "checks": [], "foreignKeys": { - "order_shipping_method_tax_line_shipping_method_id_foreign": { - "constraintName": "order_shipping_method_tax_line_shipping_method_id_foreign", + "return_reason_parent_return_reason_id_foreign": { + "constraintName": "return_reason_parent_return_reason_id_foreign", "columnNames": [ - "shipping_method_id" + "parent_return_reason_id" ], - "localTableName": "public.order_shipping_method_tax_line", + "localTableName": "public.return_reason", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_shipping_method", - "deleteRule": "cascade", + "referencedTableName": "public.return_reason", + "deleteRule": "set null", "updateRule": "cascade" } } @@ -4574,63 +4636,64 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "reason_id": { + "name": "reason_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "return_id": { - "name": "return_id", - "type": "text", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "decimal" }, - "exchange_id": { - "name": "exchange_id", - "type": "text", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "claim_id": { - "name": "claim_id", - "type": "text", + "received_quantity": { + "name": "received_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "version": { - "name": "version", - "type": "integer", + "raw_received_quantity": { + "name": "raw_received_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "1", - "mappedType": "integer" + "mappedType": "json" }, - "amount": { - "name": "amount", + "damaged_quantity": { + "name": "damaged_quantity", "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, + "default": "0", "mappedType": "decimal" }, - "raw_amount": { - "name": "raw_amount", + "raw_damaged_quantity": { + "name": "raw_damaged_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -4638,8 +4701,8 @@ "nullable": false, "mappedType": "json" }, - "currency_code": { - "name": "currency_code", + "return_id": { + "name": "return_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -4647,17 +4710,17 @@ "nullable": false, "mappedType": "text" }, - "reference": { - "name": "reference", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "reference_id": { - "name": "reference_id", + "note": { + "name": "note", "type": "text", "unsigned": false, "autoincrement": false, @@ -4665,6 +4728,15 @@ "nullable": true, "mappedType": "text" }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -4698,89 +4770,51 @@ "mappedType": "datetime" } }, - "name": "order_transaction", + "name": "return_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_transaction_order_id", + "keyName": "IDX_return_item_reason_id", "columnNames": [ - "order_id" + "reason_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_return_id", + "keyName": "IDX_return_item_return_id", "columnNames": [ "return_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_transaction_exchange_id", - "columnNames": [ - "exchange_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_transaction_claim_id", - "columnNames": [ - "claim_id" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_transaction_currency_code", - "columnNames": [ - "currency_code" - ], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (return_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_reference_id", + "keyName": "IDX_return_item_item_id", "columnNames": [ - "reference_id" + "item_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_item_id\" ON \"return_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_transaction_deleted_at", + "keyName": "IDX_return_item_deleted_at", "columnNames": [ "deleted_at" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NOT NULL" - }, - { - "keyName": "IDX_order_transaction_order_id_version", - "columnNames": [], - "composite": false, - "primary": false, - "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (order_id, version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_transaction_pkey", + "keyName": "return_item_pkey", "columnNames": [ "id" ], @@ -4791,56 +4825,42 @@ ], "checks": [], "foreignKeys": { - "order_transaction_order_id_foreign": { - "constraintName": "order_transaction_order_id_foreign", + "return_item_reason_id_foreign": { + "constraintName": "return_item_reason_id_foreign", "columnNames": [ - "order_id" + "reason_id" ], - "localTableName": "public.order_transaction", + "localTableName": "public.return_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order", - "deleteRule": "cascade", + "referencedTableName": "public.return_reason", + "deleteRule": "set null", "updateRule": "cascade" }, - "order_transaction_return_id_foreign": { - "constraintName": "order_transaction_return_id_foreign", + "return_item_return_id_foreign": { + "constraintName": "return_item_return_id_foreign", "columnNames": [ "return_id" ], - "localTableName": "public.order_transaction", + "localTableName": "public.return_item", "referencedColumnNames": [ "id" ], "referencedTableName": "public.return", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_transaction_exchange_id_foreign": { - "constraintName": "order_transaction_exchange_id_foreign", - "columnNames": [ - "exchange_id" - ], - "localTableName": "public.order_transaction", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order_exchange", - "deleteRule": "set null", + "deleteRule": "cascade", "updateRule": "cascade" }, - "order_transaction_claim_id_foreign": { - "constraintName": "order_transaction_claim_id_foreign", + "return_item_item_id_foreign": { + "constraintName": "return_item_item_id_foreign", "columnNames": [ - "claim_id" + "item_id" ], - "localTableName": "public.order_transaction", + "localTableName": "public.return_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_claim", - "deleteRule": "set null", + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } diff --git a/packages/modules/order/src/migrations/Migration20240902195921.ts b/packages/modules/order/src/migrations/Migration20240902195921.ts new file mode 100644 index 0000000000000..4bb69822566e4 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20240902195921.ts @@ -0,0 +1,17 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20240902195921 extends Migration { + + async up(): Promise { + this.addSql('alter table if exists "order_line_item" add column if not exists "is_custom_price" boolean not null default false;'); + + this.addSql('alter table if exists "order_shipping_method" add column if not exists "is_custom_amount" boolean not null default false;'); + } + + async down(): Promise { + this.addSql('alter table if exists "order_line_item" drop column if exists "is_custom_price";'); + + this.addSql('alter table if exists "order_shipping_method" drop column if exists "is_custom_amount";'); + } + +} diff --git a/packages/modules/order/src/models/line-item.ts b/packages/modules/order/src/models/line-item.ts index 2e30fcd4db6db..c9f1edb80b15e 100644 --- a/packages/modules/order/src/models/line-item.ts +++ b/packages/modules/order/src/models/line-item.ts @@ -128,6 +128,9 @@ export default class OrderLineItem { @Property({ columnType: "jsonb" }) raw_unit_price: BigNumberRawValue + @Property({ columnType: "boolean", default: false }) + is_custom_price: boolean = false + @OneToMany(() => OrderLineItemTaxLine, (taxLine) => taxLine.item, { cascade: [Cascade.PERSIST, "soft-remove" as Cascade], }) diff --git a/packages/modules/order/src/models/shipping-method.ts b/packages/modules/order/src/models/shipping-method.ts index ffa05ab8aa1f9..88cd338773d93 100644 --- a/packages/modules/order/src/models/shipping-method.ts +++ b/packages/modules/order/src/models/shipping-method.ts @@ -54,6 +54,9 @@ export default class OrderShippingMethod { @Property({ columnType: "boolean" }) is_tax_inclusive: boolean = false + @Property({ columnType: "boolean", default: false }) + is_custom_amount: boolean = false + @Property({ columnType: "text", nullable: true,