feat(cardex): implement cardex controller, service, and DTO for stock movements

feat(pos): add POS controller and service for order creation and stock retrieval
refactor(pos): enhance stock and product category retrieval with pagination and mapping
This commit is contained in:
2025-12-21 19:09:41 +03:30
parent d514267f58
commit c6a86719dd
42 changed files with 3769 additions and 119 deletions
+76 -1
View File
@@ -18,7 +18,82 @@ export class SuppliersService {
async findOne(id: number) {
const item = await this.prisma.supplier.findUnique({ where: { id } })
if (!item) return null
return ResponseMapper.single(item)
const receiptsInfo = await this.prisma.purchaseReceipt.aggregate({
where: {
supplierId: id,
},
_count: true,
_sum: {
totalAmount: true,
},
})
return ResponseMapper.single({
...item,
receiptsOverview: {
totalPayment: receiptsInfo._sum.totalAmount,
count: receiptsInfo._count,
},
})
}
async getInvoices(supplierId: number) {
const items = await this.prisma.purchaseReceipt.findMany({
where: {
supplierId,
},
include: {
inventory: {
select: {
id: true,
name: true,
},
},
items: {
select: {
id: true,
count: true,
fee: true,
total: true,
product: {
select: {
id: true,
name: true,
sku: true,
},
},
},
},
},
omit: {
inventoryId: true,
supplierId: true,
},
})
return ResponseMapper.list(items)
}
async getInvoice(supplierId: number, invoiceId: number) {
const invoice = await this.prisma.purchaseReceipt.findUnique({
where: {
id: invoiceId,
supplierId,
},
include: {
inventory: {
select: {
id: true,
name: true,
},
},
items: true,
},
omit: {
inventoryId: true,
supplierId: true,
},
})
return ResponseMapper.single(invoice)
}
async update(id: number, data: any) {