This commit is contained in:
2026-01-27 11:46:07 +03:30
parent 75f2c4b73e
commit 935f905e29
4 changed files with 25 additions and 24 deletions
+7 -7
View File
@@ -80,7 +80,7 @@ export class OrderService {
}
}
const order = await this.em.transactional(async (em) => {
return this.em.transactional(async (em) => {
const order = this.orderRepository.create({
creator: admin,
@@ -96,6 +96,7 @@ export class OrderService {
em.persist(order)
const productIds = items.map(item => item.productId)
const products = await this.productRepository.find({
id: { $in: productIds }
})
@@ -104,19 +105,18 @@ export class OrderService {
}
for (const item of items) {
this.persistOrderItem(order, item)
await this.persistOrderItem(order, item)
}
// TODO : calculation must be done after create order
// await this.calculateOrder(order)
// await em.flush()
await em.flush()
return order
})
return order
}
@@ -154,7 +154,7 @@ export class OrderService {
order.attachments = attachments
}
if (enableTax != undefined) {
if (enableTax != undefined) {
order.enableTax = enableTax
}
@@ -178,7 +178,7 @@ export class OrderService {
async updateOrderAsAdmin(orderId: string, dto: IUpdateOrder) {
const order = await this.findOneOrFail(orderId)
const updateOrder= await this.updateOrder(order, dto)
const updateOrder = await this.updateOrder(order, dto)
// const updateOrder = await this.calculateOrder(order)
@@ -230,7 +230,7 @@ export class OrderService {
if (found) {
throw new BadRequestException(`Product already exists`)
}
console.log(productId)
const product = await this.productRepository.findOne({ id: productId })
if (!product) {
throw new BadRequestException(`Product not found`)