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;
|
status?: Status;
|
||||||
|
|
||||||
branchNo: string;
|
|
||||||
legalPersonNo: string;
|
legalPersonNo: string;
|
||||||
|
|
||||||
taxNo: string;
|
taxNo: string;
|
||||||
|
|
@ -62,7 +61,6 @@ type CustomerBranchUpdate = {
|
||||||
|
|
||||||
status?: "ACTIVE" | "INACTIVE";
|
status?: "ACTIVE" | "INACTIVE";
|
||||||
|
|
||||||
branchNo?: string;
|
|
||||||
legalPersonNo?: string;
|
legalPersonNo?: string;
|
||||||
|
|
||||||
taxNo?: string;
|
taxNo?: string;
|
||||||
|
|
@ -228,6 +226,10 @@ 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({
|
||||||
|
where: { customerId },
|
||||||
|
});
|
||||||
|
|
||||||
const record = await prisma.customerBranch.create({
|
const record = await prisma.customerBranch.create({
|
||||||
include: {
|
include: {
|
||||||
province: true,
|
province: true,
|
||||||
|
|
@ -236,6 +238,7 @@ export class CustomerBranchController extends Controller {
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
...rest,
|
...rest,
|
||||||
|
branchNo: `${count + 1}`,
|
||||||
customer: { connect: { id: customerId } },
|
customer: { connect: { id: customerId } },
|
||||||
province: { connect: provinceId ? { id: provinceId } : undefined },
|
province: { connect: provinceId ? { id: provinceId } : undefined },
|
||||||
district: { connect: districtId ? { id: districtId } : undefined },
|
district: { connect: districtId ? { id: districtId } : undefined },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue