Overview
TheCustomer class represents a client in the App Courier system. It can represent both individual customers and corporate clients, with support for multiple delivery addresses, pricing plans, and billing configurations.
Location: lib/models/customer.dart
Class Definition
Constructor
JSON Serialization
fromJson (Standard List Response)
Parses customer data from list endpoints:fromCustomerByIdJson (Detail Response)
Parses full customer details including addresses:fromSearchJson (Search Response)
Parses minimal customer data from search results:toJson (Create Customer)
Serializes customer for creation:updateToJson (Update Customer)
Serializes customer for updates (includes ID):addDireccionToJson (Add Address)
Serializes customer for adding new addresses:Field Groups
Identification Fields
Identification Fields
- id: Unique customer ID
- nombres: Full name
- nroDocumento: DNI (8 digits) or RUC (11 digits)
- razonSocial: Business name (for corporate clients)
- celular: Phone number
Registration Fields
Registration Fields
Used when customers register through the client app:
- fechaNacimiento: Date of birth
- email: Email address
- password: Account password
Location Fields
Location Fields
- idDepartamento: Department ID
- idProvincia: Province ID
- idDistrito: District ID
- departamentoNombre: Department name
- provinciaNombre: Province name
- distritoNombre: District name
- lat: Latitude coordinate
- lon: Longitude coordinate
Address Management
Address Management
- direcciones: List of
Direccionobjects
Direccion contains:Business Configuration
Business Configuration
- tipoCliente: Customer type (“Natural”, “Juridico”)
- tipoPago: Payment type (“Efectivo”, “Credito”)
- igv: Include IGV (1 = yes, 0 = no)
- idTipoDetraccion: Detraction type ID
- idPlan: Pricing plan ID
- idListaPrecio: Price list ID
- planNombre: Plan name for display
Extra Charges
Extra Charges
Additional charges for different delivery types:
- extraDomDom: Domicilio a Domicilio (Home to Home)
- extraAgeDom: Agencia a Domicilio (Branch to Home)
- extraDomAge: Domicilio a Agencia (Home to Branch)
Usage Examples
Create New Customer
Update Existing Customer
Add New Address
Search Customers
Display Customer Card
Load Customer Details
Customer Types
Natural (Individual)
Juridico (Corporate)
Payment Types
- Efectivo: Cash payment on delivery
- Credito: Credit account (invoiced monthly)
- Deposito: Bank transfer/deposit
IGV Configuration
Extra Charges Example
Related Models
- Direccion - Customer address model
- Plan - Pricing plan configuration
- TipoCliente - Customer type enum
- TipoDetraccion - Tax detraction configuration
- Encomienda Model - Uses Customer as sender/recipient
Service Methods
TheCustomerService provides methods for customer operations:
getCustomers()- List customers by branchgetCustomerById()- Get full customer detailsgetCustomerByDocument()- Search by DNI/RUCcreateCustomer()- Create new customerupdateCustomer()- Update customer infoaddDireccion()- Add new addressgetTiposCliente()- Get customer types