feat: credit note (#8)
* feat: add db table and structure * chore: migration * createCreditNote * add check conditions quotationId before create credit note and add fn delete data * feat: add query list of credit note * feat: add get stats of credit ntoe * update * feat: add get by id * add permission * delete console log * chore: cleanup --------- Co-authored-by: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Co-authored-by: Kanjana <taii.kanjana@gmail.com>
This commit is contained in:
parent
b5cdb24228
commit
f673f2c953
4 changed files with 428 additions and 2 deletions
45
prisma/migrations/20241218094507_credit_note/migration.sql
Normal file
45
prisma/migrations/20241218094507_credit_note/migration.sql
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "RequestWork" ADD COLUMN "creditNoteId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "_NotificationToNotificationGroup" ADD CONSTRAINT "_NotificationToNotificationGroup_AB_pkey" PRIMARY KEY ("A", "B");
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "_NotificationToNotificationGroup_AB_unique";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "_NotificationToUser" ADD CONSTRAINT "_NotificationToUser_AB_pkey" PRIMARY KEY ("A", "B");
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "_NotificationToUser_AB_unique";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "_UserToUserResponsibleArea" ADD CONSTRAINT "_UserToUserResponsibleArea_AB_pkey" PRIMARY KEY ("A", "B");
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "_UserToUserResponsibleArea_AB_unique";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CreditNote" (
|
||||
"id" TEXT NOT NULL,
|
||||
"quotationId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "CreditNote_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "DebitNote" (
|
||||
"id" TEXT NOT NULL,
|
||||
"quotationId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "DebitNote_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RequestWork" ADD CONSTRAINT "RequestWork_creditNoteId_fkey" FOREIGN KEY ("creditNoteId") REFERENCES "CreditNote"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CreditNote" ADD CONSTRAINT "CreditNote_quotationId_fkey" FOREIGN KEY ("quotationId") REFERENCES "Quotation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DebitNote" ADD CONSTRAINT "DebitNote_quotationId_fkey" FOREIGN KEY ("quotationId") REFERENCES "Quotation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -1283,7 +1283,9 @@ model Quotation {
|
|||
updatedBy User? @relation(name: "QuotationUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
invoice Invoice[]
|
||||
invoice Invoice[]
|
||||
creditNote CreditNote[]
|
||||
debitNote DebitNote[]
|
||||
}
|
||||
|
||||
model QuotationPaySplit {
|
||||
|
|
@ -1449,6 +1451,9 @@ model RequestWork {
|
|||
attributes Json?
|
||||
|
||||
stepStatus RequestWorkStepStatus[]
|
||||
|
||||
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id])
|
||||
creditNoteId String?
|
||||
}
|
||||
|
||||
model RequestWorkStepStatus {
|
||||
|
|
@ -1555,3 +1560,22 @@ model UserTask {
|
|||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
}
|
||||
|
||||
model CreditNote {
|
||||
id String @id @default(cuid())
|
||||
|
||||
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
||||
quotationId String
|
||||
|
||||
// NOTE: only status cancel
|
||||
requestWork RequestWork[]
|
||||
}
|
||||
|
||||
model DebitNote {
|
||||
id String @id @default(cuid())
|
||||
|
||||
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
||||
quotationId String
|
||||
|
||||
// NOTE: create quotation but with flag debit note?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue