Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.3.1)
strscan
rexml (3.3.9)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -144,7 +143,6 @@ GEM
nori (~> 2.4)
wasabi (>= 3.7, < 6)
shellany (0.0.1)
strscan (3.1.0)
thor (1.3.1)
timeout (0.4.1)
tzinfo (2.0.6)
Expand Down
11 changes: 7 additions & 4 deletions lib/afipws/wsfe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def autorizar_comprobantes opciones
'FeCAEReq' => {
'FeCabReq' => opciones.select_keys(:cbte_tipo, :pto_vta).merge(cant_reg: comprobantes.size),
'FeDetReq' => {
'FECAEDetRequest' => comprobantes.map { |comprobante| comprobante_to_request comprobante }
'FECAEDetRequest' => comprobantes.map { |comprobante| comprobante_to_request(comprobante, opciones) }
}
}
}
Expand All @@ -83,11 +83,14 @@ def autorizar_comprobantes opciones
x2r r, cae_fch_vto: :date, fch_serv_desde: :date, fch_serv_hasta: :date, fch_vto_pago: :date, cbte_nro: :integer, code: :integer
end

def comprobante_to_request comprobante
def comprobante_to_request(comprobante, opciones)
nro = comprobante.delete :cbte_nro
iva = comprobante.delete :imp_iva
comprobante.delete :tributos if comprobante[:imp_trib] == 0
comprobante.merge cbte_desde: nro, cbte_hasta: nro, 'ImpIVA' => iva
comprobante.merge! cbte_desde: nro, cbte_hasta: nro, 'ImpIVA' => iva
comprobante.merge! periodo_asoc: opciones[:periodo_asoc] if opciones[:periodo_asoc]

comprobante
end

def solicitar_caea
Expand All @@ -111,7 +114,7 @@ def informar_comprobantes_caea opciones
'FeCabReq' => opciones.select_keys(:cbte_tipo, :pto_vta).merge(cant_reg: comprobantes.size),
'FeDetReq' => {
'FECAEADetRequest' => comprobantes.map do |comprobante|
comprobante_to_request comprobante.merge('CAEA' => comprobante.delete(:caea))
comprobante_to_request(comprobante.merge('CAEA' => comprobante.delete(:caea)), opciones)
end
}
}
Expand Down
6 changes: 3 additions & 3 deletions spec/afipws/wsfe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,12 @@ def fecha_inicio_quincena_siguiente fecha
end

context 'comprobante_to_request' do
def c2r comprobante
subject.comprobante_to_request comprobante
def c2r comprobante, opciones
subject.comprobante_to_request comprobante, opciones
end

it 'no debería enviar tag tributos si el impTrib es 0' do
c2r(imp_trib: 0.0, tributos: { tributo: [] }).should_not have_key :tributos
c2r({imp_trib: 0.0, tributos: { tributo: [] }},{}).should_not have_key :tributos
end
end
end
Expand Down