diff --git a/packages/modules/order/integration-tests/__tests__/order-exchange.ts b/packages/modules/order/integration-tests/__tests__/order-exchange.ts index be846138a5d47..6707173ba5bba 100644 --- a/packages/modules/order/integration-tests/__tests__/order-exchange.ts +++ b/packages/modules/order/integration-tests/__tests__/order-exchange.ts @@ -103,7 +103,7 @@ moduleIntegrationTestRunner({ customer_id: "joe", } as CreateOrderDTO - it("should exchange an item and add two new items to the order", async function () { + it.only("should exchange an item and add two new items to the order", async function () { const createdOrder = await service.createOrders(input) createdOrder.items = createdOrder.items!.sort((a, b) => a.title.localeCompare(b.title) diff --git a/packages/modules/order/src/models/claim-item.ts b/packages/modules/order/src/models/claim-item.ts index a12c355f62262..71200eb9960f4 100644 --- a/packages/modules/order/src/models/claim-item.ts +++ b/packages/modules/order/src/models/claim-item.ts @@ -8,7 +8,7 @@ const _OrderClaimItem = model id: model.id({ prefix: "claitem" }).primaryKey(), reason: model.enum(ClaimReason).nullable(), quantity: model.bigNumber(), - is_additional_item: model.boolean().default(false), + is_additional_item: model.boolean().default(false).nullable(), note: model.text().nullable(), metadata: model.json().nullable(), claim: model.belongsTo<() => typeof OrderClaim>(() => OrderClaim, { diff --git a/packages/modules/order/src/models/exchange.ts b/packages/modules/order/src/models/exchange.ts index a31f52f15ff8e..e7c2ffa7a00b8 100644 --- a/packages/modules/order/src/models/exchange.ts +++ b/packages/modules/order/src/models/exchange.ts @@ -15,7 +15,7 @@ const _OrderExchange = model display_id: model.autoincrement(), no_notification: model.boolean().nullable(), difference_due: model.bigNumber().nullable(), - allow_backorder: model.boolean().default(false), + allow_backorder: model.boolean().default(false).nullable(), created_by: model.text().nullable(), metadata: model.json().nullable(), canceled_at: model.dateTime().nullable(), diff --git a/packages/modules/order/src/models/line-item.ts b/packages/modules/order/src/models/line-item.ts index df03fc07294e3..0373273fdcb46 100644 --- a/packages/modules/order/src/models/line-item.ts +++ b/packages/modules/order/src/models/line-item.ts @@ -25,12 +25,12 @@ const _OrderLineItem = model variant_barcode: model.text().nullable(), variant_title: model.text().nullable(), variant_option_values: model.json().nullable(), - requires_shipping: model.boolean().default(true), - is_discountable: model.boolean().default(true), - is_tax_inclusive: model.boolean().default(false), + requires_shipping: model.boolean().default(true).nullable(), + is_discountable: model.boolean().default(true).nullable(), + is_tax_inclusive: model.boolean().default(false).nullable(), compare_at_unit_price: model.bigNumber().nullable(), unit_price: model.bigNumber(), - is_custom_price: model.boolean().default(false), + is_custom_price: model.boolean().default(false).nullable(), metadata: model.json().nullable(), tax_lines: model.hasMany<() => typeof OrderLineItemTaxLine>( () => OrderLineItemTaxLine, diff --git a/packages/modules/order/src/models/order-change-action.ts b/packages/modules/order/src/models/order-change-action.ts index b9403a996ab6e..3dd8ab0d4c258 100644 --- a/packages/modules/order/src/models/order-change-action.ts +++ b/packages/modules/order/src/models/order-change-action.ts @@ -16,7 +16,7 @@ const _OrderChangeAction = model details: model.json(), amount: model.bigNumber().nullable(), internal_note: model.text().nullable(), - applied: model.boolean().default(false), + applied: model.boolean().default(false).nullable(), order_change: model.belongsTo<() => typeof OrderChange>(() => OrderChange, { mappedBy: "actions", }), diff --git a/packages/modules/order/src/models/order-change.ts b/packages/modules/order/src/models/order-change.ts index d34d8401e70a1..53e24bcee4d22 100644 --- a/packages/modules/order/src/models/order-change.ts +++ b/packages/modules/order/src/models/order-change.ts @@ -11,7 +11,10 @@ const _OrderChange = model version: model.number(), change_type: model.text().nullable(), description: model.text().nullable(), - status: model.enum(OrderChangeStatus).default(OrderChangeStatus.PENDING), + status: model + .enum(OrderChangeStatus) + .default(OrderChangeStatus.PENDING) + .nullable(), internal_note: model.text().nullable(), created_by: model.text(), requested_by: model.text().nullable(), diff --git a/packages/modules/order/src/models/order-item.ts b/packages/modules/order/src/models/order-item.ts index 8f2ada3db9d96..a027f1a225bf0 100644 --- a/packages/modules/order/src/models/order-item.ts +++ b/packages/modules/order/src/models/order-item.ts @@ -10,13 +10,13 @@ const _OrderItem = model unit_price: model.bigNumber().nullable(), compare_at_unit_price: model.bigNumber().nullable(), quantity: model.bigNumber(), - fulfilled_quantity: model.bigNumber().default(0), - delivered_quantity: model.bigNumber().default(0), - shipped_quantity: model.bigNumber().default(0), - return_requested_quantity: model.bigNumber().default(0), - return_received_quantity: model.bigNumber().default(0), - return_dismissed_quantity: model.bigNumber().default(0), - written_off_quantity: model.bigNumber().default(0), + fulfilled_quantity: model.bigNumber().default(0).nullable(), + delivered_quantity: model.bigNumber().default(0).nullable(), + shipped_quantity: model.bigNumber().default(0).nullable(), + return_requested_quantity: model.bigNumber().default(0).nullable(), + return_received_quantity: model.bigNumber().default(0).nullable(), + return_dismissed_quantity: model.bigNumber().default(0).nullable(), + written_off_quantity: model.bigNumber().default(0).nullable(), metadata: model.json().nullable(), order: model.belongsTo<() => typeof Order>(() => Order, { mappedBy: "items", diff --git a/packages/modules/order/src/models/order-summary.ts b/packages/modules/order/src/models/order-summary.ts index 607d97d8e58c4..f035a6d1491c1 100644 --- a/packages/modules/order/src/models/order-summary.ts +++ b/packages/modules/order/src/models/order-summary.ts @@ -4,7 +4,7 @@ import { Order } from "./order" const _OrderSummary = model .define("OrderSummary", { id: model.id({ prefix: "ordsum" }).primaryKey(), - version: model.number().default(1), + version: model.number().default(1).nullable(), totals: model.json(), order: model.belongsTo<() => typeof Order>(() => Order, { mappedBy: "summary", diff --git a/packages/modules/order/src/models/order.ts b/packages/modules/order/src/models/order.ts index 9940964291a4f..02f66c162dab5 100644 --- a/packages/modules/order/src/models/order.ts +++ b/packages/modules/order/src/models/order.ts @@ -28,13 +28,13 @@ import { OrderTransaction } from "./transaction" type OrderSchema = { id: PrimaryKeyModifier - display_id: AutoIncrementProperty + display_id: NullableModifier region_id: NullableModifier customer_id: NullableModifier - version: NumberProperty + version: NullableModifier sales_channel_id: NullableModifier - status: EnumProperty - is_draft_order: BooleanProperty + status: NullableModifier> + is_draft_order: NullableModifier email: NullableModifier currency_code: TextProperty no_notification: NullableModifier @@ -55,13 +55,13 @@ type OrderSchema = { const _Order = model .define("Order", { id: model.id({ prefix: "order" }).primaryKey(), - display_id: model.autoincrement(), + display_id: model.autoincrement().nullable(), region_id: model.text().nullable(), customer_id: model.text().nullable(), - version: model.number().default(1), + version: model.number().default(1).nullable(), sales_channel_id: model.text().nullable(), - status: model.enum(OrderStatus).default(OrderStatus.PENDING), - is_draft_order: model.boolean().default(false), + status: model.enum(OrderStatus).default(OrderStatus.PENDING).nullable(), + is_draft_order: model.boolean().default(false).nullable(), email: model.text().searchable().nullable(), currency_code: model.text(), no_notification: model.boolean().nullable(), diff --git a/packages/modules/order/src/models/return-item.ts b/packages/modules/order/src/models/return-item.ts index 85a5d72a2b16c..cf478e0da9e6c 100644 --- a/packages/modules/order/src/models/return-item.ts +++ b/packages/modules/order/src/models/return-item.ts @@ -7,8 +7,8 @@ const _ReturnItem = model .define("ReturnItem", { id: model.id({ prefix: "retitem" }).primaryKey(), quantity: model.bigNumber(), - received_quantity: model.bigNumber().default(0), - damaged_quantity: model.bigNumber().default(0), + received_quantity: model.bigNumber().default(0).nullable(), + damaged_quantity: model.bigNumber().default(0).nullable(), note: model.text().nullable(), metadata: model.json().nullable(), reason: model diff --git a/packages/modules/order/src/models/return.ts b/packages/modules/order/src/models/return.ts index f83a847137f89..4048aa630b6e8 100644 --- a/packages/modules/order/src/models/return.ts +++ b/packages/modules/order/src/models/return.ts @@ -12,7 +12,7 @@ const _Return = model id: model.id({ prefix: "return" }).primaryKey(), order_version: model.number(), display_id: model.autoincrement(), - status: model.enum(ReturnStatus).default(ReturnStatus.OPEN), + status: model.enum(ReturnStatus).default(ReturnStatus.OPEN).nullable(), location_id: model.text().nullable(), no_notification: model.boolean().nullable(), refund_amount: model.bigNumber().nullable(), diff --git a/packages/modules/order/src/models/shipping-method.ts b/packages/modules/order/src/models/shipping-method.ts index a6679ebcee372..4dd53f2ec6df2 100644 --- a/packages/modules/order/src/models/shipping-method.ts +++ b/packages/modules/order/src/models/shipping-method.ts @@ -9,8 +9,8 @@ const _OrderShippingMethod = model name: model.text(), description: model.json().nullable(), amount: model.bigNumber(), - is_tax_inclusive: model.boolean().default(false), - is_custom_amount: model.boolean().default(false), + is_tax_inclusive: model.boolean().default(false).nullable(), + is_custom_amount: model.boolean().default(false).nullable(), shipping_option_id: model.text().nullable(), data: model.json().nullable(), metadata: model.json().nullable(), diff --git a/packages/modules/order/src/models/transaction.ts b/packages/modules/order/src/models/transaction.ts index a61c5c43d723c..5637253446754 100644 --- a/packages/modules/order/src/models/transaction.ts +++ b/packages/modules/order/src/models/transaction.ts @@ -11,7 +11,7 @@ import { Return } from "./return" const _OrderTransaction = model .define("OrderTransaction", { id: model.id({ prefix: "ordtrx" }).primaryKey(), - version: model.number().default(1), + version: model.number().default(1).nullable(), amount: model.bigNumber(), currency_code: model.text(), reference: model.text().nullable(), diff --git a/packages/modules/order/src/services/order-module-service.ts b/packages/modules/order/src/services/order-module-service.ts index 0a13831153f4a..25008623afe54 100644 --- a/packages/modules/order/src/services/order-module-service.ts +++ b/packages/modules/order/src/services/order-module-service.ts @@ -1969,7 +1969,7 @@ export default class OrderModuleService return { ...dataMap[order.id], - version: order.version + 1, + version: order.version! + 1, } as any })