initial: standalone repo from monorepo split
This commit is contained in:
25
src/billing/billing.service.ts
Normal file
25
src/billing/billing.service.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { UpdateBillingSettingsDto } from './dto/update-billing-settings.dto';
|
||||
|
||||
@Injectable()
|
||||
export class BillingService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async getSettings(tenantId: string) {
|
||||
let settings = await this.prisma.billingSetting.findUnique({ where: { tenantId } });
|
||||
if (!settings) {
|
||||
settings = await this.prisma.billingSetting.create({ data: { tenantId } });
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
async updateSettings(tenantId: string, dto: UpdateBillingSettingsDto) {
|
||||
await this.prisma.billingSetting.upsert({
|
||||
where: { tenantId },
|
||||
create: { tenantId, ...dto },
|
||||
update: dto,
|
||||
});
|
||||
return this.getSettings(tenantId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user