feat: add more quotation status
This commit is contained in:
parent
f5df3332b5
commit
1e8453e99f
3 changed files with 32 additions and 11 deletions
|
|
@ -0,0 +1,13 @@
|
||||||
|
-- AlterEnum
|
||||||
|
-- This migration adds more than one value to an enum.
|
||||||
|
-- With PostgreSQL versions 11 and earlier, this is not possible
|
||||||
|
-- in a single migration. This can be worked around by creating
|
||||||
|
-- multiple migrations, each migration adding only one value to
|
||||||
|
-- the enum.
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TYPE "QuotationStatus" ADD VALUE 'Accepted';
|
||||||
|
ALTER TYPE "QuotationStatus" ADD VALUE 'Invoice';
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "WorkProduct" ADD COLUMN "attributes" JSONB;
|
||||||
|
|
@ -1083,6 +1083,8 @@ model WorkProduct {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum QuotationStatus {
|
enum QuotationStatus {
|
||||||
|
Accepted
|
||||||
|
Invoice
|
||||||
PaymentPending
|
PaymentPending
|
||||||
PaymentInProcess // For Installments / Split Payment
|
PaymentInProcess // For Installments / Split Payment
|
||||||
PaymentSuccess
|
PaymentSuccess
|
||||||
|
|
|
||||||
|
|
@ -134,19 +134,25 @@ export class InvoiceController extends Controller {
|
||||||
if (!quotation) throw notFoundError("Quotation");
|
if (!quotation) throw notFoundError("Quotation");
|
||||||
await permissionCheck(req.user, quotation.registeredBranch);
|
await permissionCheck(req.user, quotation.registeredBranch);
|
||||||
|
|
||||||
return await prisma.invoice.create({
|
return await prisma.$transaction(async (tx) => {
|
||||||
data: {
|
await tx.quotation.update({
|
||||||
productServiceList: { connect: productServiceList.map((v) => ({ id: v.id })) },
|
where: { id: body.quotationId },
|
||||||
quotationId: body.quotationId,
|
data: { quotationStatus: "PaymentInProcess" },
|
||||||
amount: body.amount,
|
});
|
||||||
payment: {
|
return await tx.invoice.create({
|
||||||
create: {
|
data: {
|
||||||
paymentStatus: "PaymentWait",
|
productServiceList: { connect: productServiceList.map((v) => ({ id: v.id })) },
|
||||||
amount: body.amount,
|
quotationId: body.quotationId,
|
||||||
|
amount: body.amount,
|
||||||
|
payment: {
|
||||||
|
create: {
|
||||||
|
paymentStatus: "PaymentWait",
|
||||||
|
amount: body.amount,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
createdByUserId: req.user.sub,
|
||||||
},
|
},
|
||||||
createdByUserId: req.user.sub,
|
});
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue