Overview
The SRI (Servicio de Rentas Internas) integration provides access to Ecuador’s tax authority database, enabling validation and retrieval of taxpayer information, including RUC (Registro Único de Contribuyentes) details, tax status, and compliance information.GraphQL Query
GetApiSriByRuc
Retrieves comprehensive tax information for a taxpayer by their RUC (tax identification number).Schema/Query/Query.cs:1139-1154
Parameters
Tax identification number (RUC). Can be provided in 10-digit or 13-digit format. If 10 digits are provided, the system automatically appends “001” to form the complete RUC.
Response Fields
Unique identifier for the SRI record
Complete RUC number (13 digits)
Legal business name or taxpayer name
Current taxpayer status (Active, Inactive, Suspended, etc.)
Primary economic activity classification
Taxpayer type classification
Tax regime type
Taxpayer category
Indicates if required to maintain accounting records (“SI”/“NO”)
Withholding agent status
Special taxpayer designation
Date when business activities started
Date of cessation if applicable
Date of activity resumption if applicable
Last update date of taxpayer information
JSON string containing legal representatives information
Reason for cancellation or suspension if applicable
Ghost taxpayer flag indicator
Non-existent transactions flag
JSON string with establishment information
Person type (Natural/Legal)
Internal person code
Tax status date timestamp
Tax status description text
Indicates if there are firm debts
JSON string with debt reasons
JSON string with pending obligations
JSON string with pending filing obligations
JSON string with pending payment obligations
Record creation timestamp
Record last update timestamp
Implementation Details
Repository
TheApiSriRepository class provides data access operations:
Location: Services/ApiSri/ApiSriRepository.cs
Methods
Create(ApiSriDTO)- Creates a new SRI recordUpdate(ApiSriDTO)- Updates an existing SRI recordGetByRuc(string)- Retrieves the most recent record by RUCGetById(int)- Retrieves a record by ID
Data Storage
SRI data is stored in theind_ac_apisri database table with automatic timestamp tracking.
RUC Format Handling
The query automatically handles both RUC formats:- 10-digit format: Automatically appends “001” to create the 13-digit RUC
- 13-digit format: Used as provided
Error Handling
APISRIDTO_NOT_FOUND
Thrown when no SRI record exists for the provided RUC.Example Usage
Query with 10-digit RUC
Query with 13-digit RUC
Response Example
Best Practices
- Cache Management: SRI data is relatively static. Consider caching results appropriately.
- RUC Validation: Validate RUC format before querying to ensure proper structure.
- Error Handling: Always handle the
APISRIDTO_NOT_FOUNDerror for non-existent RUCs. - Timestamp Tracking: Use
updatedAtto determine data freshness.