feat(customers): enhance customer retrieval with filtering options
- Updated `findAll` method in `CustomersController` to accept filtering parameters. - Implemented filtering logic in `CustomersService` to retrieve customers based on type and search query. - Added `PosCustomerFilterDto` for query validation. - Updated customer-related DTOs to make fields optional and added length validation where necessary. - Modified customer-related logic in `sales-invoice-tsp.utils.ts` to accommodate new DTO structure. - Added unique constraints to `customer_individuals` and `customer_legal` tables in the database migration. - Removed commented-out code in `PosMiddleware` for cleaner codebase. - Set default value for `is_default_guild_good` to false in `OwnedGoodsService`.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[business_activity_id,postal_code,national_id]` on the table `customer_individuals` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[business_activity_id,postal_code,registration_number]` on the table `customer_legal` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `customer_individuals` MODIFY `first_name` VARCHAR(255) NULL,
|
||||
MODIFY `last_name` VARCHAR(255) NULL,
|
||||
MODIFY `national_id` CHAR(10) NULL,
|
||||
MODIFY `mobile_number` CHAR(15) NULL,
|
||||
MODIFY `postal_code` CHAR(10) NULL,
|
||||
MODIFY `economic_code` CHAR(14) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customer_legal` MODIFY `name` VARCHAR(255) NULL,
|
||||
MODIFY `economic_code` CHAR(11) NULL,
|
||||
MODIFY `postal_code` CHAR(10) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `customer_individuals_business_activity_id_postal_code_nation_key` ON `customer_individuals`(`business_activity_id`, `postal_code`, `national_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `customer_legal_business_activity_id_postal_code_registration_key` ON `customer_legal`(`business_activity_id`, `postal_code`, `registration_number`);
|
||||
@@ -13,33 +13,35 @@ model Customer {
|
||||
}
|
||||
|
||||
model CustomerIndividual {
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
mobile_number String @db.Char(15)
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
first_name String? @db.VarChar(255)
|
||||
last_name String? @db.VarChar(255)
|
||||
national_id String? @db.Char(10)
|
||||
mobile_number String? @db.Char(15)
|
||||
postal_code String? @db.Char(10)
|
||||
economic_code String? @db.Char(14)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, national_id])
|
||||
@@unique([business_activity_id, postal_code, national_id])
|
||||
@@index([business_activity_id])
|
||||
@@map("customer_individuals")
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
name String? @db.VarChar(255)
|
||||
economic_code String? @db.Char(11)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
postal_code String? @db.Char(10)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, economic_code])
|
||||
@@unique([business_activity_id, postal_code, registration_number])
|
||||
@@index([business_activity_id])
|
||||
@@map("customer_legal")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user