Add field management module with database schema and validation
- Introduced `FieldModule` to manage cycles and plans, including read and write controllers. - Created database migrations for `company_settings`, `cycles`, `cycle_weekdays`, `cycle_destinations`, `plans`, `plan_destinations`, `plan_invoices`, and `plan_packing_slips` tables, including constraints and unique indexes. - Developed service and repository layers for handling cycle and plan data operations. - Added unit tests for the cycles and plans services, repositories, and controllers to ensure functionality and correctness. - Updated application module to include the new `FieldModule` for better organization.
This commit is contained in:
@@ -78,6 +78,20 @@ export class CustomersRepository {
|
||||
return this.toDomain(row, contacts);
|
||||
}
|
||||
|
||||
async findByCode(code: string): Promise<Customer | null> {
|
||||
const rows: CustomerRow[] = await this.db
|
||||
.select()
|
||||
.from(customers)
|
||||
.where(eq(customers.code, code))
|
||||
.limit(1);
|
||||
const row = rows[0];
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
const contacts = await this.selectContacts(this.db, row.id);
|
||||
return this.toDomain(row, contacts);
|
||||
}
|
||||
|
||||
async create(input: CreateCustomerInput): Promise<Customer> {
|
||||
const now = DateTime.fromUnixMs(Date.now());
|
||||
const status = input.status ?? Status.create(Status.DEFAULT);
|
||||
|
||||
Reference in New Issue
Block a user