ADD: prisma fix
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import prisma from "./prisma.server";
|
||||
|
||||
export async function generateInvoiceNumber(companyId: string): Promise<string> {
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
const company = await prisma.company.update({
|
||||
where: { id: companyId },
|
||||
data: { invoiceSequence: { increment: 1 } },
|
||||
select: { invoicePrefix: true, invoiceSequence: true },
|
||||
});
|
||||
|
||||
const seq = String(company.invoiceSequence).padStart(3, "0");
|
||||
return `${company.invoicePrefix}-${year}-${seq}`;
|
||||
}
|
||||
Reference in New Issue
Block a user