123 lines
2.6 KiB
TypeScript
123 lines
2.6 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PrismaService } from '../../../common/database/prisma.service';
|
|
|
|
@Injectable()
|
|
export class PrePopulateService {
|
|
constructor(private prisma: PrismaService) { }
|
|
|
|
async getAllBankDetails() {
|
|
return await this.prisma.banks.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
include: {
|
|
BankBranches: {
|
|
select: {
|
|
id: true,
|
|
branchAddress: true,
|
|
ifscCode: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
async getBankBranchesByBankId(bankXid: number) {
|
|
return await this.prisma.bankBranches.findMany({
|
|
where: {
|
|
bankXid,
|
|
isActive: true,
|
|
deletedAt: null
|
|
},
|
|
select: {
|
|
id: true,
|
|
branchAddress: true,
|
|
ifscCode: true,
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
async getCityByStateId(stateXid: number) {
|
|
return await this.prisma.cities.findMany({
|
|
where: {
|
|
stateXid,
|
|
isActive: true,
|
|
deletedAt: null
|
|
},
|
|
select: {
|
|
id: true,
|
|
cityName: true,
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
async getAllCurrencyDetails() {
|
|
return await this.prisma.currencies.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
});
|
|
}
|
|
|
|
async getAllPQQQuesAndAns() {
|
|
return await this.prisma.pQQCategories.findMany({
|
|
where: { isActive: true },
|
|
include: {
|
|
pqqsubCategories: {
|
|
include: {
|
|
questions: {
|
|
include: {
|
|
PQQAnswers: {
|
|
orderBy: {
|
|
displayOrder: 'asc'
|
|
}
|
|
}
|
|
},
|
|
orderBy: {
|
|
displayOrder: 'asc'
|
|
}
|
|
}
|
|
},
|
|
orderBy: { displayOrder: 'asc' }
|
|
}
|
|
},
|
|
orderBy: { displayOrder: 'asc' }
|
|
});
|
|
}
|
|
|
|
async getAllDocumentTypeWithCountryStateCity() {
|
|
const [documentDetails, countryDetails, stateDetails] =
|
|
await this.prisma.$transaction([
|
|
this.prisma.documentType.findMany({
|
|
where: { isActive: true, isVisible: true },
|
|
orderBy: { displayOrder: 'asc' },
|
|
}),
|
|
this.prisma.countries.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.states.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
]);
|
|
|
|
return { documentDetails, countryDetails, stateDetails };
|
|
}
|
|
|
|
async getAllFrequencies() {
|
|
return await this.prisma.frequencies.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
select: {
|
|
id: true,
|
|
frequencyName: true,
|
|
},
|
|
});
|
|
}
|
|
}
|