refactor!: customer (employer) fields

This commit is contained in:
Methapon Metanipat 2024-09-16 11:03:34 +07:00
parent 00776151c5
commit 86888ed512
4 changed files with 95 additions and 40 deletions

View file

@ -0,0 +1,33 @@
/*
Warnings:
- You are about to drop the column `businessTypeEN` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `jobPositionEN` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `saleEmployee` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `workplace` on the `CustomerBranch` table. All the data in the column will be lost.
- You are about to drop the column `workplaceEN` on the `CustomerBranch` table. All the data in the column will be lost.
- Added the required column `agent` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `contactTel` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `employmentOfficeEN` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `homeCode` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `officeTel` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `payDateEN` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
- Added the required column `wageRateText` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "CustomerBranch" DROP COLUMN "businessTypeEN",
DROP COLUMN "jobPositionEN",
DROP COLUMN "saleEmployee",
DROP COLUMN "workplace",
DROP COLUMN "workplaceEN",
ADD COLUMN "agent" TEXT NOT NULL,
ADD COLUMN "authorizedName" TEXT,
ADD COLUMN "authorizedNameEN" TEXT,
ADD COLUMN "contactTel" TEXT NOT NULL,
ADD COLUMN "employmentOfficeEN" TEXT NOT NULL,
ADD COLUMN "homeCode" TEXT NOT NULL,
ADD COLUMN "officeTel" TEXT NOT NULL,
ADD COLUMN "payDateEN" TEXT NOT NULL,
ADD COLUMN "wageRateText" TEXT NOT NULL,
ALTER COLUMN "payDate" SET DATA TYPE TEXT;

View file

@ -466,11 +466,15 @@ model CustomerBranch {
registerNameEN String? registerNameEN String?
registerDate DateTime? @db.Date registerDate DateTime? @db.Date
authorizedCapital String? authorizedCapital String?
authorizedName String?
authorizedNameEN String?
workplace String // NOTE: Address
workplaceEN String homeCode String
address String employmentOffice String
addressEN String employmentOfficeEN String
address String
addressEN String
soi String? soi String?
soiEN String? soiEN String?
@ -488,18 +492,21 @@ model CustomerBranch {
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull) subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
subDistrictId String? subDistrictId String?
// NOTE: contact
email String email String
contactTel String
officeTel String
contactName String contactName String
agent String
employmentOffice String // NOTE: Business
businessType String businessType String
businessTypeEN String jobPosition String
jobPosition String jobDescription String
jobPositionEN String payDate String
jobDescription String payDateEN String
saleEmployee String wageRate Int
payDate DateTime @db.Date wageRateText String
wageRate Int
status Status @default(CREATED) status Status @default(CREATED)
statusOrder Int @default(0) statusOrder Int @default(0)

View file

@ -71,14 +71,19 @@ export type CustomerBranchCreate = (
registerNameEN: string; registerNameEN: string;
registerDate: Date; registerDate: Date;
authorizedCapital: string; authorizedCapital: string;
authorizedName: string;
authorizedNameEN: string;
} }
) & { ) & {
customerId: string; customerId: string;
telephoneNo: string;
status?: Status; status?: Status;
workplace: string; homeCode: string;
workplaceEN: string; employmentOffice: string;
employmentOfficeEN: string;
address: string; address: string;
addressEN: string; addressEN: string;
soi?: string | null; soi?: string | null;
@ -89,18 +94,18 @@ export type CustomerBranchCreate = (
streetEN?: string | null; streetEN?: string | null;
email: string; email: string;
contactTel: string;
officeTel: string;
contactName: string; contactName: string;
telephoneNo: string; agent: string;
employmentOffice: string;
businessType: string; businessType: string;
businessTypeEN: string;
jobPosition: string; jobPosition: string;
jobPositionEN: string;
jobDescription: string; jobDescription: string;
saleEmployee: string; payDate: string;
payDate: Date; payDateEN: string;
wageRate: number; wageRate: number;
wageRateText: string;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -119,16 +124,19 @@ export type CustomerBranchUpdate = (
registerNameEN?: string; registerNameEN?: string;
registerDate?: Date; registerDate?: Date;
authorizedCapital?: string; authorizedCapital?: string;
authorizedName: string;
authorizedNameEN: string;
} }
) & { ) & {
customerId?: string; customerId?: string;
telephoneNo: string;
status?: "ACTIVE" | "INACTIVE"; status?: "ACTIVE" | "INACTIVE";
workplace: string; homeCode?: string;
workplaceEN: string; address?: string;
address: string; addressEN?: string;
addressEN: string;
soi?: string | null; soi?: string | null;
soiEN?: string | null; soiEN?: string | null;
moo?: string | null; moo?: string | null;
@ -137,18 +145,18 @@ export type CustomerBranchUpdate = (
streetEN?: string | null; streetEN?: string | null;
email?: string; email?: string;
contactTel?: string;
officeTel?: string;
contactName?: string; contactName?: string;
telephoneNo?: string; agent?: string;
employmentOffice?: string;
businessType?: string; businessType?: string;
businessTypeEN?: string;
jobPosition?: string; jobPosition?: string;
jobPositionEN?: string;
jobDescription?: string; jobDescription?: string;
saleEmployee?: string; payDate?: string;
payDate?: Date; payDateEN?: string;
wageRate?: number; wageRate?: number;
wageRateText?: string;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;

View file

@ -63,12 +63,19 @@ export type CustomerCreate = {
registerNameEN: string; registerNameEN: string;
registerDate: Date; registerDate: Date;
authorizedCapital: string; authorizedCapital: string;
authorizedName: string;
authorizedNameEN: string;
} }
) & { ) & {
customerId: string;
telephoneNo: string;
status?: Status; status?: Status;
workplace: string; homeCode: string;
workplaceEN: string; employmentOffice: string;
employmentOfficeEN: string;
address: string; address: string;
addressEN: string; addressEN: string;
soi?: string | null; soi?: string | null;
@ -79,18 +86,18 @@ export type CustomerCreate = {
streetEN?: string | null; streetEN?: string | null;
email: string; email: string;
contactTel: string;
officeTel: string;
contactName: string; contactName: string;
telephoneNo: string; agent: string;
employmentOffice: string;
businessType: string; businessType: string;
businessTypeEN: string;
jobPosition: string; jobPosition: string;
jobPositionEN: string;
jobDescription: string; jobDescription: string;
saleEmployee: string; payDate: string;
payDate: Date; payDateEN: string;
wageRate: number; wageRate: number;
wageRateText: string;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -170,7 +177,7 @@ export class CustomerController extends Controller {
district: true, district: true,
subDistrict: true, subDistrict: true,
}, },
orderBy: { createdAt: "asc" }, orderBy: [{ statusOrder: "asc" }, { createdAt: "asc" }],
} }
: { : {
include: { include: {