fix: update SupplierLedger model to use correct enum casing and adjust types

feat: enhance PosAccountsService to include inventoryBankAccount details in responses

refactor: modify PosService to return structured inventory and bank account data

chore: remove isSettled field from CreatePurchaseReceiptDto and adjust related logic

feat: add payments selection in SuppliersService for better payment tracking

chore: apply database migrations to adjust decimal types and enforce constraints

chore: create index on Pos_Accounts for improved query performance

feat: define Supplier and SupplierLedger models in Prisma schema for better data management
This commit is contained in:
2025-12-26 22:09:46 +03:30
parent d59be5995d
commit d98507fc1f
35 changed files with 2670 additions and 2802 deletions
@@ -44,16 +44,20 @@ export class PosAccountsService {
inventoryId,
},
include: {
bankAccount: {
select: {
id: true,
name: true,
accountNumber: true,
branch: {
inventoryBankAccount: {
include: {
bankAccount: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
accountNumber: true,
branch: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
},
},
},
},
},
@@ -64,7 +68,12 @@ export class PosAccountsService {
bankAccountId: true,
},
})
return ResponseMapper.list(items)
return ResponseMapper.list(
items.map(item => ({
...item,
bankAccount: item.inventoryBankAccount?.bankAccount,
})),
)
}
async findOne(inventoryId: number, id: number) {
@@ -74,16 +83,20 @@ export class PosAccountsService {
inventoryId,
},
include: {
bankAccount: {
select: {
id: true,
name: true,
accountNumber: true,
branch: {
inventoryBankAccount: {
include: {
bankAccount: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
accountNumber: true,
branch: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
},
},
},
},
},
@@ -94,7 +107,9 @@ export class PosAccountsService {
bankAccountId: true,
},
})
return ResponseMapper.single(item)
return ResponseMapper.single(
item ? { ...item, bankAccount: item.inventoryBankAccount?.bankAccount } : null,
)
}
async update(inventoryId: number, id: number, dto: UpdatePosAccountDto) {
+21 -14
View File
@@ -28,30 +28,37 @@ export class PosService {
const info = await this.prisma.posAccount.findUniqueOrThrow({
where: { id: posId },
include: {
inventory: {
select: {
id: true,
name: true,
},
},
bankAccount: {
select: {
id: true,
name: true,
accountNumber: true,
branch: {
inventoryBankAccount: {
include: {
bankAccount: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
accountNumber: true,
branch: {
select: {
id: true,
name: true,
bank: { select: { id: true, name: true } },
},
},
},
},
inventory: {
select: { id: true, name: true },
},
},
},
},
})
return ResponseMapper.single({ ...info })
const { inventoryBankAccount, ...rest } = info
return ResponseMapper.single({
...rest,
bankAccount: inventoryBankAccount?.bankAccount,
inventory: inventoryBankAccount?.inventory,
})
}
async getStock(