Autofactura.importar
Receives a list of tickets, with their details, and validates each one.
Returns a list with the status of the attempt to import each ticket.
- Parameters:
-
Name Description Required clientId xs:string
Username registered for this WebService.
Yes password xs:string
User's password
Yes file xs:base64Binary
Byte array of the Document to be imported, in base64 encoding. The file must be in plain text.
The file must be of type Autofactura connector string in plain text.Yes
This method receives 3 parameters, 2 of them being located in the header of the SOAP request.
Request example
Download this example.
Returns
- The method returns a complex type: Importacion. It's attributes are described below:
-
Importacion's attributesName Description Required status xs:int
Operation status' code. Response codes
Yes mensaje xs:string
The response message: a string detailing the operation's status.
Yes idTransaccion xs:string
Identifier of the transaction in which the ticket was processed. It may be absent if the ticket could not be processed.
No resultados Array of type tns:resultadoImportacion
Details of the result of every ticket imported.
No -
tns:resultadoImportacion
Name Description Required status xs:int
Ticket's status
Yes mensaje xs:string
Ticket's Message
No noTicket xs:string
Ticket's number
No
Response Example - importar (import)
Download this example
Connector string
-
The connector string is the representation of each element in the importation file used by the importar (import) method of the WebService.
Name Type Required Description Example TICKET_NO String R Ticket identifier, it can be a composite. 02OTR0010558223088D FECHA_HORA String R Date and time. It's format can be specified by the client. 08/13/2012T11:43:18 SUBTOTAL_FACTURA BigDecimal R Ticket's subtotal amount, with a maximum of 6 digits. 449.5441 TOTAL_FACTURA BigDecimal R Ticket's total amount, with a maximum of 6 digits. 535.1716 NOTAS String O Additional notes. "No notes" MONEDA_NOMBRE String O Currency's name. Mexican Peso MONEDA_SIMBOLO String O Currency's Symbol, if ommited, 'MXN' is used. USD TIPO_CAMBIO BigDecimal O Currency's exchange rate to Mexican Pesos at the moment of using this method. 1.00 FORMA_PAGO String O System's code for the form of payment (cash, credit card, etc). It can be predefined at the moment of configuring the client's account. 03, 02, 99 METODO_PAGO String O System's code for the method of payment (PUE: Single payment, PPD: several payments). PUE, PPD VALOR_UNITARIO BigDecimal O Unit price, if omitted the value SUBTOTAL_FACTURA will be used. 160.45 CLAVE_UNIDAD String R Unit of measurement's code of item, as taken from the SAT catalogues. The code must coincide with the product's description. (GLI=Gallon, etc) GLI UNIDAD String O Unit of measurement of item, as defined by the client. Pounds CLAVE_PROD_SERV_SAT String R Product or Service's code, as taken from the SAT catalogues. (10101506=Horses, 70131506=Soil improvement, etc). 78111900 CODIGO String O Item code a-113 CONCEPTO String O Product or service description. "Gift package number 4" CANTIDAD BigDecimal O Product or Service's quantity, if omitted the value 1.000000 will be used. 1.00 IMPORTE BigDecimal O Product or Service amount, if omitted the value SUBTOTAL_FACTURA will be used. 140.45 IMPORTE_DESCUENTO BigDecimal O Product or service discount amount. Must be equal or less than IMPORTE and negative values are not allowed. 34.00 TASA_IVA_LINEA BigDecimal O Product or service IVA tax (VAT) rate. Must be in percentage. 16.00 BASE_IVA BigDecimal O Base amount for the IVA tax (VAT) calculation. Negative values are not allowed. 140.45 MONTO_IVA BigDecimal O Product or service IVA tax amount (VAT amount). 22.472 TASA_IEPS_LINEA BigDecimal O Product or service's IEPS tax rate. Must be in percentage and negative values are not allowed. If this value is specified, CUOTA_IEPS must be left in blank. 3.00 CUOTA_IEPS BigDecimal O Product or service's IEPS tax quota. If this value is specified, TASA_IEPS_LINEA must be left in blank. BASE_IEPS BigDecimal O Base amount for the IEPS tax calculation. Negative values are not allowed. 140.45 MONTO_IEPS BigDecimal O Product or service IEPS tax amount. 4.2135 TASA_RET_IVA BigDecimal O IVA tax withholdings rate, must be in percentage 10.667. BASE_RET_IVA BigDecimal O Base amount for the IVA tax withholdings, negative values are not allowed. 140.45 MONTO_RET_IVA BigDecimal O IVA tax withholdings amount. 14.9818015 RE_IMPORTAR Boolean O If True a previous generated ticket may be re-imported, if False it will not be re-imported. true, false USO_CFDI String R Code of usage of the invoice-to-be-created out of this ticket, as taken from the SAT catalogues. (G03=General expenses, D04=Donations, etc) P01 O = Optional
C = Conditional
R = RequiredThe connector string must have the following order:
TICKET_NO|FECHA_HORA|SUBTOTAL_FACTURA|TOTAL_FACTURA|NOTAS|MONEDA_NOMBRE|MONEDA_SIMBOLO|TIPO_CAMBIO|FORMA_PAGO|METODO_PAGO|VALOR_UNITARIO|CLAVE_UNIDAD|UNIDAD|CLAVE_PROD_SERV_SAT|CODIGO|CONCEPTO|CANTIDAD|IMPORTE|IMPORTE_DESCUENTO|TASA_IVA|BASE_IVA|MONTO_IVA|TASA_IEPS|CUOTA_IEPS|BASE_IEPS|MONTO_IEPS|TASA_RET_IVA|BASE_RET_IVA|MONTO_RET_IVA|RE_IMPORTAR|USO_CFDI|Example of a connector string for autofactura
Verifier digit
Generation
The Verifier digit is formed by the first 2 digits of the string generated by applying a hash SHA-1 to the ticket number.
Let's take for example the following ticket number: 02OTR0010558223088D
02 The ticket issuer's ID (alphanumeric).
OTR The local branch/subsidiary's ID from where the ticket will be issued (alphanumeric).
00105582 Ticket number.
The last 6 character long segment 23088d is composed by:
2 = Number of characters of the issuer's ID, in this case: 02.
3 = Number of characters of the local branch/subsidiary's ID, in this case: OTR.
08 = Number of characters of the ticket number, 2 digits are mandatory, in this case: 00105582.
8d = first 2 digits of the SHA-1 result of 02OTR001055822308
In other words:
Issuer | Local branch/subsidiary | Ticket | Issuer no. of characters | Local branch/subsidiary no. of characters | Ticket no. of characters | Verifier digit |
02 | OTR | 00105582 | 2 | 3 | 08 | 8D |
Alphanumeric | Alphanumeric | Alphanumeric | 1 to 9 | 1 to 9 |
1 to 99 2 digits mandatory |
Alphanumeric 2 digits mandatory |
The hash is generated with the first 6 elements of the ticket:
02 | OTR | 00105582 | 2 | 3 | 08 |
Hashing 02OTR001055822308 with SHA-1 results in::
8D811497A8A289C1351646AA73161AC0967AAC78 |
Hash's first 2 digits:
8D | 811497A8A289C1351646AA73161AC0967AAC78 |
TICKET_NO with the verifier digit:
02OTR001055822308 | 8D |
Response Codes
-
200 — Successful access:
The client authenticated correctly and the method returned the results
In other words: any process which terminated without errors. -
201 — Successful access:
The client authenticated correctly and the method returned the results
In other words: any process which terminated without errors. -
202 — This ticket had already been processed in a past import-transaction,
this ticket already exists in a past transaction.
-
204 — There are errors regarding the validation of the ticket's verifier digit.
The verifier digit validation failed, this happened because either the ticket number does not comply with the verifier digit specifications or the generated SHA-1 hash is different. - 206 — An invoice has already been created with this ticket.
-
208 — The ticket could not be stored and marked as an invoice.
The storage process found a problem and hence could not continue. -
500 — Error found attempting to process the tickets.
Error found attempting to read the tickets' data. - 601 — Client's authentication error.
Username / password incorrect.