feat: add code customer field

This commit is contained in:
Methapon Metanipat 2024-08-23 10:33:53 +07:00
parent 03d25219c1
commit fffd20ea0f
3 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `codeCustomer` to the `CustomerBranch` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "CustomerBranch" ADD COLUMN "codeCustomer" TEXT NOT NULL;

View file

@ -437,7 +437,8 @@ model CustomerBranch {
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
customerId String
code String
code String
codeCustomer String
// NOTE: About (Natural Person)
citizenId String?

View file

@ -376,6 +376,7 @@ export class CustomerBranchController extends Controller {
data: {
...rest,
code: `${runningKey.replace("CUSTOMER_BRANCH_", "")}-${`${last.value - 1}`.padStart(2, "0")}`,
codeCustomer: runningKey.replace("CUSTOMER_BRANCH_", ""),
customer: { connect: { id: customerId } },
province: { connect: provinceId ? { id: provinceId } : undefined },
district: { connect: districtId ? { id: districtId } : undefined },