Files
psp_api/src/common/queryConstants/consumer.ts
T

83 lines
1.4 KiB
TypeScript
Raw Normal View History

import { ConsumerSelect, ConsumerWhereInput } from '@/generated/prisma/models'
const now = new Date()
export const infoSelect: ConsumerSelect = {
2026-05-05 10:14:48 +03:30
type: true,
legal: {
select: {
name: true,
registration_code: true,
partner: {
select: {
id: true,
name: true,
code: true,
},
},
},
},
individual: {
select: {
first_name: true,
last_name: true,
mobile_number: true,
partner: {
select: {
id: true,
name: true,
code: true,
},
},
},
},
}
export const activeBusinessCount: ConsumerSelect = {
_count: {
select: {
business_activities: {
where: {
license_activation: {
OR: [
{
expires_at: {
gt: now,
},
},
{
license_renews: {
some: {
expires_at: {
gt: now,
},
},
},
},
],
},
},
},
},
},
}
export const consumerRelatedPartner = (partner_id: string): ConsumerWhereInput => ({
OR: [
{
legal: {
is: {
partner_id,
},
},
},
{
individual: {
is: {
partner_id,
},
},
},
],
})