refactor: customer create and update process

This commit is contained in:
Methapon Metanipat 2024-08-20 15:41:48 +07:00
parent b167a612b4
commit 5bb8da818c
6 changed files with 261 additions and 462 deletions

View file

@ -0,0 +1,56 @@
/*
Warnings:
- You are about to drop the column `customerName` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `customerNameEN` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `personName` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `personNameEN` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `taxNo` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `branchNo` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `bussinessType` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `bussinessTypeEN` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `name` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `nameEN` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `taxNo` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `zipCode` on the `CustomerBranch` table. All the data in the column will be lost.
- Added the required column `birthDate` to the `Customer` table without a default value. This is not possible if the table is not empty.
- Added the required column `firstName` to the `Customer` table without a default value. This is not possible if the table is not empty.
- Added the required column `gender` to the `Customer` table without a default value. This is not possible if the table is not empty.
- Added the required column `lastName` to the `Customer` table without a default value. This is not possible if the table is not empty.
- Added the required column `businessType` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `businessTypeEN` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `workplace` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `workplaceEN` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Customer" DROP COLUMN "customerName",
DROP COLUMN "customerNameEN",
DROP COLUMN "personName",
DROP COLUMN "personNameEN",
DROP COLUMN "taxNo",
ADD COLUMN "birthDate" TIMESTAMP(3) NOT NULL,
ADD COLUMN "firstName" TEXT NOT NULL,
ADD COLUMN "firstNameEN" TEXT,
ADD COLUMN "gender" TEXT NOT NULL,
ADD COLUMN "lastName" TEXT NOT NULL,
ADD COLUMN "lastNameEN" TEXT,
ADD COLUMN "namePrefix" TEXT;
-- AlterTable
ALTER TABLE "CustomerBranch" DROP COLUMN "branchNo",
DROP COLUMN "bussinessType",
DROP COLUMN "bussinessTypeEN",
DROP COLUMN "name",
DROP COLUMN "nameEN",
DROP COLUMN "taxNo",
DROP COLUMN "zipCode",
ADD COLUMN "businessType" TEXT NOT NULL,
ADD COLUMN "businessTypeEN" TEXT NOT NULL,
ADD COLUMN "citizenId" TEXT,
ADD COLUMN "workplace" TEXT NOT NULL,
ADD COLUMN "workplaceEN" TEXT NOT NULL,
ALTER COLUMN "legalPersonNo" DROP NOT NULL,
ALTER COLUMN "registerName" DROP NOT NULL,
ALTER COLUMN "registerDate" DROP NOT NULL,
ALTER COLUMN "authorizedCapital" DROP NOT NULL;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "CustomerBranch" ADD COLUMN "legalPersonName" TEXT;

View file

@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `code` on the `Customer` table. All the data in the column will be lost.
- You are about to drop the column `legalPersonName` on the `CustomerBranch` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Customer" DROP COLUMN "code";
-- AlterTable
ALTER TABLE "CustomerBranch" DROP COLUMN "legalPersonName",
ADD COLUMN "registerNameEN" TEXT;

View file

@ -403,14 +403,17 @@ enum CustomerType {
}
model Customer {
id String @id @default(uuid())
code String
personName String
personNameEN String?
customerType CustomerType
customerName String
customerNameEN String
taxNo String?
id String @id @default(uuid())
customerType CustomerType
namePrefix String?
firstName String
firstNameEN String?
lastName String
lastNameEN String?
gender String
birthDate DateTime
status Status @default(CREATED)
statusOrder Int @default(0)
@ -430,24 +433,25 @@ model Customer {
}
model CustomerBranch {
id String @id @default(uuid())
branchNo Int
code String
legalPersonNo String
name String
nameEN String
id String @id @default(uuid())
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
customerId String
taxNo String?
registerName String
registerDate DateTime
authorizedCapital String
code String
address String
addressEN String
// NOTE: About (Natural Person)
citizenId String?
// NOTE: About (Legal Entity)
legalPersonNo String?
registerName String?
registerNameEN String?
registerDate DateTime?
authorizedCapital String?
workplace String
workplaceEN String
address String
addressEN String
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
provinceId String?
@ -458,14 +462,12 @@ model CustomerBranch {
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
subDistrictId String?
zipCode String
email String
telephoneNo String
employmentOffice String
bussinessType String
bussinessTypeEN String
businessType String
businessTypeEN String
jobPosition String
jobPositionEN String
jobDescription String