feat: add missing field
This commit is contained in:
parent
21aeacfaf3
commit
7627b51a25
4 changed files with 79 additions and 22 deletions
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `latitude` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the column `longitude` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||||
|
- Added the required column `bussinessType` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `employmentOffice` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `jobDescription` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `jobPosition` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `payDate` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `saleEmployee` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `wageDate` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Customer" ADD COLUMN "taxNo" TEXT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "CustomerBranch" DROP COLUMN "latitude",
|
||||||
|
DROP COLUMN "longitude",
|
||||||
|
ADD COLUMN "bussinessType" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "employmentOffice" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "jobDescription" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "jobPosition" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "payDate" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "saleEmployee" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "wageDate" TEXT NOT NULL,
|
||||||
|
ALTER COLUMN "taxNo" DROP NOT NULL;
|
||||||
|
|
@ -335,6 +335,7 @@ model Customer {
|
||||||
customerType CustomerType
|
customerType CustomerType
|
||||||
customerName String
|
customerName String
|
||||||
customerNameEN String
|
customerNameEN String
|
||||||
|
taxNo String?
|
||||||
|
|
||||||
status Status @default(CREATED)
|
status Status @default(CREATED)
|
||||||
|
|
||||||
|
|
@ -357,7 +358,7 @@ model CustomerBranch {
|
||||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
||||||
customerId String
|
customerId String
|
||||||
|
|
||||||
taxNo String
|
taxNo String?
|
||||||
registerName String
|
registerName String
|
||||||
registerDate DateTime
|
registerDate DateTime
|
||||||
authorizedCapital String
|
authorizedCapital String
|
||||||
|
|
@ -379,8 +380,13 @@ model CustomerBranch {
|
||||||
email String
|
email String
|
||||||
telephoneNo String
|
telephoneNo String
|
||||||
|
|
||||||
latitude String
|
employmentOffice String
|
||||||
longitude String
|
bussinessType String
|
||||||
|
jobPosition String
|
||||||
|
jobDescription String
|
||||||
|
saleEmployee String
|
||||||
|
payDate String
|
||||||
|
wageDate String
|
||||||
|
|
||||||
status Status @default(CREATED)
|
status Status @default(CREATED)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,14 @@ export type CustomerBranchCreate = {
|
||||||
registerDate: Date;
|
registerDate: Date;
|
||||||
authorizedCapital: string;
|
authorizedCapital: string;
|
||||||
|
|
||||||
|
employmentOffice: string;
|
||||||
|
bussinessType: string;
|
||||||
|
jobPosition: string;
|
||||||
|
jobDescription: string;
|
||||||
|
saleEmployee: string;
|
||||||
|
payDate: string;
|
||||||
|
wageDate: string;
|
||||||
|
|
||||||
subDistrictId?: string | null;
|
subDistrictId?: string | null;
|
||||||
districtId?: string | null;
|
districtId?: string | null;
|
||||||
provinceId?: string | null;
|
provinceId?: string | null;
|
||||||
|
|
@ -78,6 +86,14 @@ export type CustomerBranchUpdate = {
|
||||||
registerDate?: Date;
|
registerDate?: Date;
|
||||||
authorizedCapital?: string;
|
authorizedCapital?: string;
|
||||||
|
|
||||||
|
employmentOffice?: string;
|
||||||
|
bussinessType?: string;
|
||||||
|
jobPosition?: string;
|
||||||
|
jobDescription?: string;
|
||||||
|
saleEmployee?: string;
|
||||||
|
payDate?: string;
|
||||||
|
wageDate?: string;
|
||||||
|
|
||||||
subDistrictId?: string | null;
|
subDistrictId?: string | null;
|
||||||
districtId?: string | null;
|
districtId?: string | null;
|
||||||
provinceId?: string | null;
|
provinceId?: string | null;
|
||||||
|
|
@ -226,27 +242,32 @@ export class CustomerBranchController extends Controller {
|
||||||
|
|
||||||
const { provinceId, districtId, subDistrictId, customerId, ...rest } = body;
|
const { provinceId, districtId, subDistrictId, customerId, ...rest } = body;
|
||||||
|
|
||||||
const count = await prisma.customerBranch.count({
|
const record = await prisma.$transaction(
|
||||||
where: { customerId },
|
async (tx) => {
|
||||||
});
|
const count = await tx.customerBranch.count({
|
||||||
|
where: { customerId },
|
||||||
|
});
|
||||||
|
|
||||||
const record = await prisma.customerBranch.create({
|
return await tx.customerBranch.create({
|
||||||
include: {
|
include: {
|
||||||
province: true,
|
province: true,
|
||||||
district: true,
|
district: true,
|
||||||
subDistrict: true,
|
subDistrict: true,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
...rest,
|
||||||
|
branchNo: `${count + 1}`,
|
||||||
|
customer: { connect: { id: customerId } },
|
||||||
|
province: { connect: provinceId ? { id: provinceId } : undefined },
|
||||||
|
district: { connect: districtId ? { id: districtId } : undefined },
|
||||||
|
subDistrict: { connect: subDistrictId ? { id: subDistrictId } : undefined },
|
||||||
|
createdBy: req.user.name,
|
||||||
|
updateBy: req.user.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
data: {
|
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||||
...rest,
|
);
|
||||||
branchNo: `${count + 1}`,
|
|
||||||
customer: { connect: { id: customerId } },
|
|
||||||
province: { connect: provinceId ? { id: provinceId } : undefined },
|
|
||||||
district: { connect: districtId ? { id: districtId } : undefined },
|
|
||||||
subDistrict: { connect: subDistrictId ? { id: subDistrictId } : undefined },
|
|
||||||
createdBy: req.user.name,
|
|
||||||
updateBy: req.user.name,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await prisma.customer.updateMany({
|
await prisma.customer.updateMany({
|
||||||
where: { id: customerId, status: Status.CREATED },
|
where: { id: customerId, status: Status.CREATED },
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ export type CustomerCreate = {
|
||||||
customerType: CustomerType;
|
customerType: CustomerType;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerNameEN: string;
|
customerNameEN: string;
|
||||||
|
taxNo?: string;
|
||||||
customerBranch?: Omit<CustomerBranchCreate, "customerId">[];
|
customerBranch?: Omit<CustomerBranchCreate, "customerId">[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -39,6 +40,7 @@ export type CustomerUpdate = {
|
||||||
customerType?: CustomerType;
|
customerType?: CustomerType;
|
||||||
customerName?: string;
|
customerName?: string;
|
||||||
customerNameEN?: string;
|
customerNameEN?: string;
|
||||||
|
taxNo?: string;
|
||||||
customerBranch?: (Omit<CustomerBranchUpdate, "customerId"> & { id: string })[];
|
customerBranch?: (Omit<CustomerBranchUpdate, "customerId"> & { id: string })[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue