The Clients module is the foundation of the sales workflow in Tienda Mi Cholo S.A.C. Every sale must be linked to a registered client — for walk-in customers without a formal record, the system provides a seeded Público General client (ID 1) that acts as the default recipient for anonymous Boleta transactions. Named clients can be registered with a DNI or RUC, a phone number, and optional contact details, allowing the system to maintain a full purchase history per customer and issue properly addressed Facturas. All authenticated users can view the client list, while registration is available to Cajeros and above, and editing or deletion is restricted to Administradores and Gerentes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/interezante456-pixel/nuevo-proyecto-viernes/llms.txt
Use this file to discover all available pages before exploring further.
Client Fields
First name(s) of the client. Maximum 50 characters. Must contain only letters, including accented characters (á, é, í, ó, ú, ñ, ü) and spaces — numbers or special characters are rejected.
Last name(s) of the client. Maximum 50 characters. Subject to the same letters-only constraint as
Nombres.Type of identity document. Accepted values are
"DNI" or "RUC". The selected type determines the exact format requirements applied to NumeroDocumento.The document number. Maximum 11 characters. The required format is enforced both by a model-level
RegularExpression attribute and by explicit controller-side length and prefix checks. See Document Validation Rules.Peruvian mobile phone number. Exactly 9 digits, must begin with
9. Repeated-digit patterns (e.g., 999999999) are rejected. See Phone Validation.Optional email address for the client. Maximum 100 characters. The field is nullable (
string?) and the form renders a standard type="email" input.Optional physical address. Maximum 200 characters. Nullable (
string?).Document Validation Rules
Validation is applied in two layers: theNumeroDocumento model property carries a [RegularExpression] attribute, and the ClienteController.Nuevo and ClienteController.Editar POST actions re-validate the combination of TipoDocumento and NumeroDocumento before any database write occurs.
- DNI
- RUC
A DNI (Documento Nacional de Identidad) is issued to natural persons by RENIEC.Rules:Client-side helper text (Nuevo.cshtml):
- Exactly 8 digits — no letters, no special characters.
- The controller rejects the submission with
"El DNI debe tener exactamente 8 dígitos"if the length differs.
Phone Validation
TheTelefono field enforces the standard Peruvian mobile number format via a regular expression defined directly on the Cliente model.
^(?!(\d)\1{8})9\d{8}$ breaks down as follows:
| Component | Meaning |
|---|---|
^ | Start of string |
(?!(\d)\1{8}) | Negative lookahead — rejects strings where all 9 digits are identical (e.g., 999999999, 111111111) |
9 | Number must begin with the digit 9 |
\d{8} | Followed by exactly 8 more digits |
$ | End of string |
validarCliente() function in Nuevo.cshtml applies equivalent JavaScript checks before form submission:
Duplicate Detection
Before inserting a new client record, the controller queries the database withAnyAsync to ensure no existing client already holds the submitted NumeroDocumento:
This duplicate check is performed only on create (
Nuevo). The Editar POST action does not re-run the AnyAsync check, so editing a client’s document number to match an existing record is not blocked at the controller level. Enforce uniqueness at the database layer (unique index on NumeroDocumento) for complete protection.Público General (Default Client)
The database seeder creates a special client record at application startup:| Field | Value |
|---|---|
ID_Cliente | 1 |
Nombres | Público |
Apellidos | General |
TipoDocumento | DNI |
NumeroDocumento | 00000000 |
ID_Cliente = 1.
Access Control
| Action | Roles |
|---|---|
View client list (Lista) | All authenticated users ([Authorize] at controller level) |
Register a new client (Nuevo) | Administrador, Gerente, Cajero |
Edit an existing client (Editar) | Administrador, Gerente |
Delete a client (Eliminar) | Administrador, Gerente |
[Authorize] attribute ensures that unauthenticated visitors are redirected to the login page before they can reach any client action. More granular role restrictions are applied per action: