Skip to content

Commit

Permalink
update models
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Nov 27, 2024
1 parent 60d1d24 commit 8bb3f15
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/claim-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions packages/modules/order/src/models/line-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/order-change-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}),
Expand Down
5 changes: 4 additions & 1 deletion packages/modules/order/src/models/order-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
14 changes: 7 additions & 7 deletions packages/modules/order/src/models/order-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/order-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions packages/modules/order/src/models/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import { OrderTransaction } from "./transaction"

type OrderSchema = {
id: PrimaryKeyModifier<string, IdProperty>
display_id: AutoIncrementProperty
display_id: NullableModifier<number, AutoIncrementProperty>
region_id: NullableModifier<string, TextProperty>
customer_id: NullableModifier<string, TextProperty>
version: NumberProperty
version: NullableModifier<number, NumberProperty>
sales_channel_id: NullableModifier<string, TextProperty>
status: EnumProperty<typeof OrderStatus>
is_draft_order: BooleanProperty
status: NullableModifier<string, EnumProperty<typeof OrderStatus>>
is_draft_order: NullableModifier<boolean, BooleanProperty>
email: NullableModifier<string, TextProperty>
currency_code: TextProperty
no_notification: NullableModifier<boolean, BooleanProperty>
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/order/src/models/return-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/return.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/order/src/models/shipping-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/order/src/models/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ export default class OrderModuleService

return {
...dataMap[order.id],
version: order.version + 1,
version: order.version! + 1,
} as any
})

Expand Down

0 comments on commit 8bb3f15

Please sign in to comment.