fix(core-flows,order): return damaged items (#8818)
This commit is contained in:
1 parent
0c4f4c8a11
commit
ff6fcfb139
5 files changed
+56
No files matched your search
@@ -973,6 +973,7 @@ medusaIntegrationTestRunner({
|
|||||||
items: [
|
items: [
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
received_quantity: 2,
|
received_quantity: 2,
|
||||||
|
damaged_quantity: 1,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -237,12 +237,24 @@ export const confirmReturnReceiveWorkflow = createWorkflow(
|
|||||||
itemUpdates[itemId].received_quantity,
|
itemUpdates[itemId].received_quantity,
|
||||||
act.details!.quantity as BigNumberInput
|
act.details!.quantity as BigNumberInput
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (act.action === ChangeActionType.RECEIVE_DAMAGED_RETURN_ITEM) {
|
||||||
|
itemUpdates[itemId].damaged_quantity = MathBN.add(
|
||||||
|
itemUpdates[itemId].damaged_quantity,
|
||||||
|
act.details!.quantity as BigNumberInput
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
itemUpdates[itemId] = {
|
itemUpdates[itemId] = {
|
||||||
id: itemMap[itemId],
|
id: itemMap[itemId],
|
||||||
received_quantity: act.details!.quantity,
|
received_quantity: act.details!.quantity,
|
||||||
|
damaged_quantity:
|
||||||
|
act.action === ChangeActionType.RECEIVE_DAMAGED_RETURN_ITEM
|
||||||
|
? act.details!.quantity
|
||||||
|
: 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3685,6 +3685,25 @@
|
|||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "json"
|
"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": {
|
"return_id": {
|
||||||
"name": "return_id",
|
"name": "return_id",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20240827133639 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "return_item" add column if not exists "damaged_quantity" numeric not null default 0, add column if not exists "raw_damaged_quantity" jsonb not null;'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "return_item" drop column if exists "damaged_quantity";'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "return_item" drop column if exists "raw_damaged_quantity";'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,12 @@ export default class ReturnItem {
|
|||||||
@Property({ columnType: "jsonb" })
|
@Property({ columnType: "jsonb" })
|
||||||
raw_received_quantity: BigNumberRawValue
|
raw_received_quantity: BigNumberRawValue
|
||||||
|
|
||||||
|
@MikroOrmBigNumberProperty()
|
||||||
|
damaged_quantity: Number | number = 0
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb" })
|
||||||
|
raw_damaged_quantity: BigNumberRawValue
|
||||||
|
|
||||||
@ManyToOne(() => Return, {
|
@ManyToOne(() => Return, {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
fieldName: "return_id",
|
fieldName: "return_id",
|
||||||
|
|||||||
Reference in new issue
Block a user