Overview
The Anticipos API provides mutation operations to create advances, update their status through the approval workflow, and manage approver assignments. All mutations require proper authentication and authorization.CreateAnticipo
Creates a new advance request in the system.Input Parameters
Email address of the requester
Identification number of the requester
Full name of the requester
Initial state, typically “INGRESADO”
ID of the beneficiary receiving the advance
Optional purchase order ID if the advance is linked to a PO
Currency type ID from catalog (e.g., USD, EUR)
Optional percentage ID if advance is calculated as percentage of PO value
Exchange rate or currency value
Amount of the advance
Description or justification for the advance
Credit-related information
Detailed justification
Supply-related flag (“SI” or “NO”)
Special Payment Condition (CME) ID
SAP document class (e.g., “KA” for supplier advance)
Assignment field (populated after approval)
Text field for SAP (populated after approval)
Response
Returns the created advance object with generated ID and registration timestamp.The
fechaRegistro field is automatically set to the current server time (UTC-5) when the advance is created.UpdateAnticipoEstado
Updates the status of an advance, triggering approval workflow actions including email notifications and SAP integration.Input Parameters
ID of the advance to update
New state for the advance. Valid values:
REVISIÓN: Submit for first-level approvalAPROBADO_T: First-level approval (triggers second-level notification)APROBADO: Final approval (triggers SAP registration)RECHAZADO: First-level rejectionRECHAZADO_T: Second-level rejection
Required when estado is “RECHAZADO” or “RECHAZADO_T”. ID of rejection reason from catalog.
Optional observations, typically used with rejections to provide feedback
Workflow Actions by State
REVISIÓN - Submit for Approval
REVISIÓN - Submit for Approval
When advancing to REVISIÓN state:
- Sets
fechaCambioEstadoto current timestamp - Sends email notification to requester confirming submission
- Retrieves first-level approver
- Sends email notification to approver requesting review
APROBADO_T - First Level Approved
APROBADO_T - First Level Approved
When first-level approver approves:
- Sets
fechaCambioEstadoto current timestamp - Retrieves second-level approver
- Sends email notification to second-level approver
If there is no second-level approver, this state can be skipped directly to APROBADO.
APROBADO - Final Approval
APROBADO - Final Approval
When final approval is granted, the system performs comprehensive SAP integration:
-
Date Calculation: Calculates next business day for payment, excluding:
- Weekends (Saturday/Sunday)
- Company holidays from catalog
-
SAP Document Creation: Builds SAP payment document with:
- Header information (document class, company, dates, currency)
- Creditor information (beneficiary SAP code, CME)
- Position details (amount, base date, assignment, text)
- API Call: Sends document to SAP via ApiAnticipos service
-
Response Processing:
- Stores SAP document number in
codigoRegistroSap - Sets
asignacionwith payment date (format: “PAGDIAdd/MM/yyyy”) - Sets
textowith advance ID and beneficiary code
- Stores SAP document number in
- Email Notification: Sends approval confirmation to requester
RECHAZADO / RECHAZADO_T - Rejection
RECHAZADO / RECHAZADO_T - Rejection
When an advance is rejected (at either level):
- Sets
fechaCambioEstadoto current timestamp - Stores
id_motivo_rechazoandobservaciones - Retrieves rejection reason from catalog
- Sends detailed rejection email to requester including:
- Approver name who rejected
- Rejection reason
- Observations/feedback
SAP Integration Details
ForAPROBADO state, the system creates a document with this structure:
Response
Error Responses
CreateAprobacionAnticipo
Creates an approval record linking an approver to an advance.Input Parameters
User ID of the approver
Advance ID to be approved
Approval level (1 or 2)
System name, should be “Anticipos”
Initial approval status, typically “Pendiente”
Response
UpdateAprobacionAnticipo
Updates an approval record, typically to mark it as completed.Input Parameters
ID of the approval record to update
User ID of the approver
Advance ID
New approval status (e.g., “Aprobado”, “Rechazado”)
DeleteAnticipo
Deletes an advance and all associated approval records.Input Parameters
ID of the advance to delete
Response
Returns the deleted advance(s).DeleteAprobacion
Deletes a specific approval record.Input Parameters
ID of the approval record to delete
Deleting an approval record does not affect the advance itself, only the approval assignment.
Complete Workflow Example
Here’s a complete example of creating and approving an advance:Step 1: Create Advance
Step 2: Assign Approvers
Step 3: Submit for Review
Step 4: First-Level Approval
Step 5: Final Approval (SAP Registration)
Best Practices
Validation
- Validate beneficiary exists and is not blocked
- Check credit limits before creating advance
- Verify purchase order amount vs. advance amount
- Ensure approvers have proper permissions
Error Handling
- Handle SAP integration failures gracefully
- Log all approval actions for audit trail
- Implement retry logic for network failures
- Validate state transitions are valid
Security
- Verify user can only update their own advances
- Check approver has permission for the level
- Validate advance hasn’t been modified by another user
- Audit all status changes
Performance
- Batch approval record creation
- Use transactions for multi-step operations
- Cache catalog data (currencies, CME types)
- Index advances by estado and correo
Email Notifications
The system automatically sends HTML email notifications for:| Event | Recipients | Template |
|---|---|---|
| Submit for review | Requester, Approver 1 | NotificacionAnticipo |
| First-level approval | Approver 2 | NotificacionAnticipo |
| Final approval | Requester | NotificacionAnticipoAprobado |
| Rejection (any level) | Requester | NotificacionAnticipoRechazado |
- Advance ID and details
- Beneficiary information
- Amount and currency
- Approver name (for approvals/rejections)
- Rejection reason and observations (for rejections)
- SAP document number (for final approval)
Related Resources
Query Advances
Learn how to retrieve advance information
Overview
Understand the anticipos module architecture