refactor: change installments data
This commit is contained in:
parent
e80e2f725b
commit
f4efa45fdc
4 changed files with 24 additions and 5 deletions
|
|
@ -0,0 +1,9 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `date` on the `QuotationPaySplit` table. All the data in the column will be lost.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "QuotationPaySplit" DROP COLUMN "date",
|
||||||
|
ADD COLUMN "invoice" BOOLEAN NOT NULL DEFAULT false;
|
||||||
|
|
@ -1167,8 +1167,8 @@ model QuotationPaySplit {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
|
|
||||||
no Int
|
no Int
|
||||||
date DateTime @db.Date
|
|
||||||
amount Float
|
amount Float
|
||||||
|
invoice Boolean @default(false)
|
||||||
|
|
||||||
quotation Quotation? @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
quotation Quotation? @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
||||||
quotationId String?
|
quotationId String?
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,17 @@ export class InvoiceController extends Controller {
|
||||||
return await prisma.$transaction(async (tx) => {
|
return await prisma.$transaction(async (tx) => {
|
||||||
await tx.quotation.update({
|
await tx.quotation.update({
|
||||||
where: { id: body.quotationId },
|
where: { id: body.quotationId },
|
||||||
data: { quotationStatus: "PaymentInProcess" },
|
data: {
|
||||||
|
quotationStatus: "PaymentInProcess",
|
||||||
|
paySplit: body.installmentNo
|
||||||
|
? {
|
||||||
|
updateMany: {
|
||||||
|
where: { no: { in: body.installmentNo } },
|
||||||
|
data: { invoice: true },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return await tx.invoice.create({
|
return await tx.invoice.create({
|
||||||
data: {
|
data: {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ type QuotationUpdate = {
|
||||||
payCondition?: PayCondition;
|
payCondition?: PayCondition;
|
||||||
|
|
||||||
paySplitCount?: number;
|
paySplitCount?: number;
|
||||||
paySplit?: { date: Date; amount: number }[];
|
paySplit?: { amount: number }[];
|
||||||
|
|
||||||
payBillDate?: Date;
|
payBillDate?: Date;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue