Skip to main content
The customers module allows you to maintain a comprehensive database of your business clients, including their contact information, transaction history, and account status.

Customer entity

Customers are stored in the Cliente model with the following fields:
Codclien
string
required
Unique customer code identifier (primary key)
Nombre
string
required
Full name or business name of the customer
Telefono
string
Phone number for customer contact (max 15 characters)
Email
string
Email address for customer communications (max 200 characters)
Direccion
string
Physical address or delivery location (max 300 characters)
Estado
bool
Customer status flag (true = active, false = inactive). Defaults to true
CreatedDate
DateTime
Timestamp when the customer record was created. Automatically set to current date/time

Database schema

CREATE TABLE clientes(
    codclien VARCHAR(50) PRIMARY KEY,
    nombre VARCHAR(200) NOT NULL,
    telefono VARCHAR(15),
    email VARCHAR(200),
    direccion VARCHAR(300),
    estado BIT DEFAULT 1,
    created_date DATETIME DEFAULT GETDATE()
)

Indexes

The customers table includes the following indexes for optimized query performance:
  • IDX_clientes_nombre - Index on customer name for fast name-based searches
  • IDX_clientes_estado - Index on status for filtering active/inactive customers
  • IDX_clientes_email - Index on email for quick email lookups

Relationships

Customers have a one-to-many relationship with sales transactions:
  • Ventas (Sales): A customer can have multiple sales orders. The relationship is established through the codclien foreign key in the ventas table.

User workflows

Adding a new customer

1

Enter customer code

Provide a unique customer identifier in the Codclien field. This code will be used to reference the customer throughout the system.
2

Fill in required information

Enter the customer’s full name or business name in the Nombre field. This is a required field.
3

Add contact details

Optionally provide phone number, email address, and physical address for customer communications and delivery purposes.
4

Save customer record

Save the customer. The system automatically sets the creation date and activates the customer account by default.

Managing customer status

The Estado field controls whether a customer is active in the system:
Instead of deleting customer records, set Estado to false to deactivate them. This preserves historical transaction data while preventing new sales.
  • Active customers (Estado = true) can be selected for new sales transactions
  • Inactive customers (Estado = false) are hidden from active customer lists but their historical data remains accessible

Viewing customer sales history

Each customer record maintains a collection of all associated sales transactions through the Venta navigation property. This allows you to:
  • Track total purchases per customer
  • Monitor payment history and outstanding balances
  • Analyze customer buying patterns
  • Identify high-value customers

Searching for customers

The database indexes enable efficient searching by:
  • Customer name: Quickly find customers by partial or full name matches
  • Email address: Look up customers using their email
  • Status: Filter to show only active or inactive customers
The customer code (Codclien) cannot be changed after creation as it serves as the primary key and is referenced by sales transactions.

Best practices

Establish a consistent naming convention for customer codes, such as:
  • Sequential numbers: CUST001, CUST002
  • Initials + number: JD001 for John Doe
  • Business identifier: ABC-CORP for ABC Corporation
  • Verify email addresses are properly formatted before saving
  • Keep phone numbers in a consistent format
  • Update customer information when notified of changes
  • Use complete addresses including city and postal code for accurate delivery
  • Regularly review inactive customers to identify re-engagement opportunities
  • Merge duplicate customer records to maintain data integrity
  • Archive old customer data according to your data retention policies

Build docs developers (and LLMs) love