Skip to content

Errors incoming from AFIP are not in the response hash #9

@mauro-oto

Description

@mauro-oto

I was wondering why my bill was being rejected, and it turns out that Savon's response is being overwritten by Bravo in the Bravo::Bill#setup_response method. In this method, the errors key is discarded, instead of being added as one more key/value.

This is the response we get from AFIP, in the Savon response:

=> {"fecae_solicitar_response"=>{"fecae_solicitar_result"=>{"fe_cab_resp"=>{"cuit"=>"30XXXXXXXX4", "pto_vta"=>"5", "cbte_tipo"=>"6", "fch_proceso"=>"20161012102344", "cant_reg"=>"1", "resultado"=>"R", "reproceso"=>"N"}, "fe_det_resp"=>{"fecae_det_response"=>{"concepto"=>"2", "doc_tipo"=>"80", "doc_nro"=>"27XXXXXXXX5", "cbte_desde"=>"127", "cbte_hasta"=>"127", "cbte_fch"=>"20161012", "resultado"=>"R", "cae"=>nil, "cae_fch_vto"=>nil}}, "events"=>{"evt"=>{"code"=>"4", "msg"=>"IMPORTANTE: El 01/11/2016 se renovaran los certificados SSL utilizados por los webservices de AFIP. Los nuevos certificados utilizaran el algoritmo de encriptacion SHA-2. Para mas informacion http://www.afip.gob.ar/ws/comoAfectaElCambio.asp"}}, "errors"=>{"err"=>{"code"=>"10005", "msg"=>"NO AUTORIZADO A EMITIR COMPROBANTES - EL PUNTO DE VENTA INFORMADO DEBE ESTAR DADO DE ALTA Y SER DEL TIPO RECE"}}}, "@xmlns"=>"http://ar.gov.afip.dif.FEV1/"}}

This is the response set up by Bravo:

=> {"header_result"=>"R", "authorized_on"=>"20161011162910", "detail_result"=>"R", "cae_due_date"=>nil, "cae"=>nil, "iva_id"=>"03", "iva_importe"=>0.0, "moneda"=>"PES", "cotizacion"=>1, "iva_base_imp"=>300.0, "doc_num"=>"27XXXXXXXX5", "cant_reg"=>"1", "cbte_tipo"=>"06", "pto_vta"=>"0005", "concepto"=>"02", "doc_tipo"=>"80", "cbte_fch"=>"20161011", "imp_tot_conc"=>0.0, "imp_op_ex"=>0.0, "imp_trib"=>0.0, "imp_neto"=>300.0, "imp_iva"=>0.0, "imp_total"=>300.0, "cbte_hasta"=>127, "cbte_desde"=>127, "fch_serv_desde"=>"20161001", "fch_serv_hasta"=>"20161031", "fch_vto_pago"=>"20161011"}

As you can see, the events value is also discarded, though it's not as important as the errors value, which is not provided by Bravo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions