diff --git a/prisma/migrations/20240823033311_add_field/migration.sql b/prisma/migrations/20240823033311_add_field/migration.sql new file mode 100644 index 0000000..ef4b1f7 --- /dev/null +++ b/prisma/migrations/20240823033311_add_field/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5bd46c4..d647a8d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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? diff --git a/src/controllers/customer-branch-controller.ts b/src/controllers/customer-branch-controller.ts index c79502b..1561867 100644 --- a/src/controllers/customer-branch-controller.ts +++ b/src/controllers/customer-branch-controller.ts @@ -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 },