refactor ticket

This commit is contained in:
2026-01-31 11:40:28 +03:30
parent 50faf3c92f
commit 1f32b8eb3f
11 changed files with 222 additions and 94 deletions
+20 -1
View File
@@ -32,6 +32,7 @@ import { Product } from 'src/modules/product/entities/product.entity';
import { AdminService } from 'src/modules/admin/providers/admin.service';
import { OrderItem } from '../entities/order-item.entity';
import { UpdateOrderAsAdminDto } from '../dto/update-order.dto';
import { CreatePrintFormDto } from '../dto/create-print-form.dto';
@Injectable()
@@ -161,6 +162,19 @@ export class OrderService {
return updated
}
async createPrintForm(orderId: string, itemId: number, dto: CreatePrintFormDto) {
const orderItem = await this.findOrderItemOrFail(orderId, itemId)
const updated = await this.updateOrderItem(orderItem, dto)
// await this.calculateOrder(undefined, orderId)
// await this.em.flush()
return updated
}
async removeOrderItemAsAdmin(orderId: string, itemId: number) {
const orderItem = await this.findOrderItemOrFail(orderId, itemId)
@@ -206,6 +220,11 @@ export class OrderService {
return orders
}
async findPrints(dto: FindOrdersDto) {
const orders = await this.orderRepository.findAllPaginated({...dto,statuses:[]})
return orders
}
// async calculateOrder(inputOrder?: Order, orderId?: string) {
// let order: undefined | Order = inputOrder
@@ -509,7 +528,7 @@ export class OrderService {
await this.em.transactional(async (em) => {
await this.orderRepository.nativeDelete(order)
await this.orderItemRepository.nativeDelete({ order: { id: orderId } })
await this.ticketRepository.nativeDelete({ order: { id: orderId } })
// await this.ticketRepository.nativeDelete({ orderItemorder: { id: orderId } })
await em.flush()
})