feat: add missing field
This commit is contained in:
parent
21aeacfaf3
commit
7627b51a25
4 changed files with 79 additions and 22 deletions
|
|
@ -51,6 +51,14 @@ export type CustomerBranchCreate = {
|
|||
registerDate: Date;
|
||||
authorizedCapital: string;
|
||||
|
||||
employmentOffice: string;
|
||||
bussinessType: string;
|
||||
jobPosition: string;
|
||||
jobDescription: string;
|
||||
saleEmployee: string;
|
||||
payDate: string;
|
||||
wageDate: string;
|
||||
|
||||
subDistrictId?: string | null;
|
||||
districtId?: string | null;
|
||||
provinceId?: string | null;
|
||||
|
|
@ -78,6 +86,14 @@ export type CustomerBranchUpdate = {
|
|||
registerDate?: Date;
|
||||
authorizedCapital?: string;
|
||||
|
||||
employmentOffice?: string;
|
||||
bussinessType?: string;
|
||||
jobPosition?: string;
|
||||
jobDescription?: string;
|
||||
saleEmployee?: string;
|
||||
payDate?: string;
|
||||
wageDate?: string;
|
||||
|
||||
subDistrictId?: string | null;
|
||||
districtId?: string | null;
|
||||
provinceId?: string | null;
|
||||
|
|
@ -226,27 +242,32 @@ export class CustomerBranchController extends Controller {
|
|||
|
||||
const { provinceId, districtId, subDistrictId, customerId, ...rest } = body;
|
||||
|
||||
const count = await prisma.customerBranch.count({
|
||||
where: { customerId },
|
||||
});
|
||||
const record = await prisma.$transaction(
|
||||
async (tx) => {
|
||||
const count = await tx.customerBranch.count({
|
||||
where: { customerId },
|
||||
});
|
||||
|
||||
const record = await prisma.customerBranch.create({
|
||||
include: {
|
||||
province: true,
|
||||
district: true,
|
||||
subDistrict: true,
|
||||
return await tx.customerBranch.create({
|
||||
include: {
|
||||
province: true,
|
||||
district: 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: {
|
||||
...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,
|
||||
},
|
||||
});
|
||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||
);
|
||||
|
||||
await prisma.customer.updateMany({
|
||||
where: { id: customerId, status: Status.CREATED },
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export type CustomerCreate = {
|
|||
customerType: CustomerType;
|
||||
customerName: string;
|
||||
customerNameEN: string;
|
||||
taxNo?: string;
|
||||
customerBranch?: Omit<CustomerBranchCreate, "customerId">[];
|
||||
};
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ export type CustomerUpdate = {
|
|||
customerType?: CustomerType;
|
||||
customerName?: string;
|
||||
customerNameEN?: string;
|
||||
taxNo?: string;
|
||||
customerBranch?: (Omit<CustomerBranchUpdate, "customerId"> & { id: string })[];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue