feat: implement partner licenses module with pagination and filtering capabilities
This commit is contained in:
+5
-5
@@ -20,10 +20,10 @@ export class SalesInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
const pageSize = 10
|
||||
const perPage = 10
|
||||
const page = 1
|
||||
|
||||
const [items, count] = await this.prisma.$transaction([
|
||||
const [items, total] = await this.prisma.$transaction([
|
||||
this.prisma.salesInvoice.findMany({
|
||||
where: defaultWhere,
|
||||
select: {
|
||||
@@ -91,14 +91,14 @@ export class SalesInvoicesService {
|
||||
},
|
||||
unknown_customer: true,
|
||||
},
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
}),
|
||||
this.prisma.salesInvoice.count({
|
||||
where: defaultWhere,
|
||||
}),
|
||||
])
|
||||
return ResponseMapper.paginate(items, { count, page, pageSize })
|
||||
return ResponseMapper.paginate(items, { total, page, perPage })
|
||||
}
|
||||
|
||||
findOne(complex_id: string, pos_id: string, id: string) {
|
||||
|
||||
@@ -60,19 +60,19 @@ export class consumerCustomersService {
|
||||
}
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, page = 1, pageSize = 10) {
|
||||
const [customers, count] = await this.prisma.$transaction(async tx => [
|
||||
async findAll(consumer_id: string, page = 1, perPage = 10) {
|
||||
const [customers, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.customer.findMany({
|
||||
where: this.defaultWhere(consumer_id),
|
||||
select: this.defaultSelect,
|
||||
skip: (page - 1) * pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: 10,
|
||||
}),
|
||||
await tx.customer.count({
|
||||
where: this.defaultWhere(consumer_id),
|
||||
}),
|
||||
])
|
||||
return ResponseMapper.paginate(customers, { count, page, pageSize })
|
||||
return ResponseMapper.paginate(customers, { total, page, perPage })
|
||||
}
|
||||
|
||||
async findOne(consumer_id: string, customer_id: string) {
|
||||
|
||||
@@ -50,7 +50,7 @@ export class CustomerSaleInvoicesService {
|
||||
created_at: true,
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, customer_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(consumer_id: string, customer_id: string, page = 1, perPage = 10) {
|
||||
const salesWhere: SalesInvoiceWhereInput = {
|
||||
customer_id,
|
||||
pos: {
|
||||
@@ -62,7 +62,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
const [accounts, count] = await this.prisma.$transaction(async tx => [
|
||||
const [accounts, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.salesInvoice.findMany({
|
||||
where: salesWhere,
|
||||
select: {
|
||||
@@ -73,7 +73,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
},
|
||||
},
|
||||
skip: (page - 1) * pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: 10,
|
||||
}),
|
||||
await tx.salesInvoice.count({
|
||||
@@ -90,9 +90,9 @@ export class CustomerSaleInvoicesService {
|
||||
})
|
||||
|
||||
return ResponseMapper.paginate(mappedAccounts, {
|
||||
count,
|
||||
total,
|
||||
page,
|
||||
pageSize,
|
||||
perPage,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -47,22 +47,22 @@ export class SaleInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(consumer_id: string, page = 1, perPage = 10) {
|
||||
const invoicesWhere: SalesInvoiceWhereInput = {
|
||||
consumer_account: {
|
||||
consumer_id,
|
||||
},
|
||||
}
|
||||
const [invoices, count] = await this.prisma.$transaction(async tx => [
|
||||
const [invoices, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.salesInvoice.findMany({
|
||||
where: invoicesWhere,
|
||||
select: this.defaultSelect,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
}),
|
||||
await tx.salesInvoice.count({ where: invoicesWhere }),
|
||||
])
|
||||
return ResponseMapper.paginate(invoices, { page, pageSize, count })
|
||||
return ResponseMapper.paginate(invoices, { page, perPage, total })
|
||||
}
|
||||
|
||||
async findOne(consumer_id: string, id: string) {
|
||||
|
||||
Reference in New Issue
Block a user