feat(customers): add DTOs for individual and legal customer creation
- Created CreateCustomerIndividualDto for individual customer data with fields: first_name, last_name, national_code, postal_code, is_favorite, and economic_code. - Created CreateCustomerLegalDto for legal customer data with fields: company_name, economic_code, registration_number, and postal_code.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `account_id` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `address` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `email` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `first_name` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `is_active` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `last_name` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `mobile_number` on the `customers` table. All the data in the column will be lost.
|
||||
- Added the required column `type` to the `customers` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX `customers_mobile_number_key` ON `customers`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customers` DROP COLUMN `account_id`,
|
||||
DROP COLUMN `address`,
|
||||
DROP COLUMN `email`,
|
||||
DROP COLUMN `first_name`,
|
||||
DROP COLUMN `is_active`,
|
||||
DROP COLUMN `last_name`,
|
||||
DROP COLUMN `mobile_number`,
|
||||
ADD COLUMN `is_favorite` BOOLEAN NULL DEFAULT false,
|
||||
ADD COLUMN `type` ENUM('INDIVIDUAL', 'LEGAL') NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_individuals` (
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`first_name` VARCHAR(255) NOT NULL,
|
||||
`last_name` VARCHAR(255) NOT NULL,
|
||||
`national_id` CHAR(10) NOT NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
`economic_code` CHAR(10) NULL,
|
||||
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_legal` (
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`company_name` VARCHAR(255) NOT NULL,
|
||||
`economic_code` CHAR(10) NOT NULL,
|
||||
`registration_number` CHAR(20) NOT NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_items` ADD COLUMN `discount` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
ADD COLUMN `pricingModel` ENUM('STANDARD', 'GOLD') NOT NULL DEFAULT 'STANDARD';
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `description` on the `sales_invoices` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `customers` MODIFY `type` ENUM('INDIVIDUAL', 'LEGAL', 'UNKNOWN') NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_items` ADD COLUMN `notes` TEXT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_payments` MODIFY `payment_method` ENUM('TERMINAL', 'CASH', 'SET_OFF', 'CARD', 'BANK', 'CHECK', 'OTHER') NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoices` DROP COLUMN `description`,
|
||||
ADD COLUMN `invoice_date` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
ADD COLUMN `notes` TEXT NULL,
|
||||
ADD COLUMN `unknown_customer` JSON NULL;
|
||||
@@ -1,19 +1,44 @@
|
||||
model Customer {
|
||||
id String @id @default(uuid())
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
email String? @db.VarChar(255)
|
||||
mobile_number String @unique @db.Char(11)
|
||||
address String? @db.Text
|
||||
is_active Boolean @default(true)
|
||||
account_id String
|
||||
complex_id String
|
||||
id String @id @default(uuid())
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
type CustomerType
|
||||
complex_id String
|
||||
is_favorite Boolean? @default(false)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
sales_invoices SalesInvoice[]
|
||||
sales_invoices SalesInvoice[]
|
||||
customerIndividuals CustomerIndividual?
|
||||
customerLegals CustomerLegal?
|
||||
|
||||
@@map("customers")
|
||||
}
|
||||
|
||||
model CustomerIndividual {
|
||||
customer_id String @id
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
complex_id String
|
||||
|
||||
customer Customer @relation(fields: [customer_id], references: [id])
|
||||
|
||||
@@unique([complex_id, national_id])
|
||||
@@map("customer_individuals")
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
customer_id String @id
|
||||
company_name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
complex_id String
|
||||
|
||||
customer Customer @relation(fields: [customer_id], references: [id])
|
||||
|
||||
@@unique([complex_id, registration_number])
|
||||
@@map("customer_legal")
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
enum PaymentMethodType {
|
||||
TERMINAL
|
||||
CASH
|
||||
SET_OFF
|
||||
CARD
|
||||
BANK
|
||||
CHECK
|
||||
@@ -25,3 +27,14 @@ enum UnitType {
|
||||
METER
|
||||
HOUR
|
||||
}
|
||||
|
||||
enum CustomerType {
|
||||
INDIVIDUAL
|
||||
LEGAL
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum SalesInvoiceItemPricingModel {
|
||||
STANDARD
|
||||
GOLD
|
||||
}
|
||||
|
||||
+27
-20
@@ -1,31 +1,38 @@
|
||||
model SalesInvoice {
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
description String? @db.Text
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
customer_id String?
|
||||
account_id String
|
||||
complex_id String
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
unknown_customer Json? @db.Json
|
||||
invoice_date DateTime? @default(now()) @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
items SalesInvoiceItem[]
|
||||
sales_invoice_payments SalesInvoicePayment[]
|
||||
customer_id String?
|
||||
account_id String
|
||||
complex_id String
|
||||
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
|
||||
@@map("sales_invoices")
|
||||
}
|
||||
|
||||
model SalesInvoiceItem {
|
||||
id String @id @default(uuid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
id String @id @default(uuid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
unit_type UnitType
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
good_id String?
|
||||
service_id String?
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
pricingModel SalesInvoiceItemPricingModel @default(STANDARD)
|
||||
|
||||
invoice_id String
|
||||
good_id String?
|
||||
service_id String?
|
||||
|
||||
payload Json?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user