feat: auto gen branch no
This commit is contained in:
parent
a352b87470
commit
d4cfd138d9
1 changed files with 5 additions and 2 deletions
|
|
@ -34,7 +34,6 @@ type CustomerBranchCreate = {
|
|||
|
||||
status?: Status;
|
||||
|
||||
branchNo: string;
|
||||
legalPersonNo: string;
|
||||
|
||||
taxNo: string;
|
||||
|
|
@ -62,7 +61,6 @@ type CustomerBranchUpdate = {
|
|||
|
||||
status?: "ACTIVE" | "INACTIVE";
|
||||
|
||||
branchNo?: string;
|
||||
legalPersonNo?: string;
|
||||
|
||||
taxNo?: string;
|
||||
|
|
@ -228,6 +226,10 @@ export class CustomerBranchController extends Controller {
|
|||
|
||||
const { provinceId, districtId, subDistrictId, customerId, ...rest } = body;
|
||||
|
||||
const count = await prisma.customerBranch.count({
|
||||
where: { customerId },
|
||||
});
|
||||
|
||||
const record = await prisma.customerBranch.create({
|
||||
include: {
|
||||
province: true,
|
||||
|
|
@ -236,6 +238,7 @@ export class CustomerBranchController extends Controller {
|
|||
},
|
||||
data: {
|
||||
...rest,
|
||||
branchNo: `${count + 1}`,
|
||||
customer: { connect: { id: customerId } },
|
||||
province: { connect: provinceId ? { id: provinceId } : undefined },
|
||||
district: { connect: districtId ? { id: districtId } : undefined },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue