-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to fm_informacion_cfdi for cfdi 3.3
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- encoding : utf-8 -*- | ||
require 'nokogiri' | ||
require 'fm_timbrado_cfdi/fm_cfdi_parser' | ||
|
||
module FmTimbradoCfdi | ||
class FmInformacionCfdi3_3 < FmCfdiParser | ||
attr_reader :total, :subtotal, :descuento | ||
|
||
private | ||
def atributos | ||
[ 'total', | ||
'subtotal', | ||
'descuento', | ||
] | ||
end | ||
|
||
def obtener_total(xml,ns) | ||
xml.xpath("//cfdi:Comprobante",ns).attribute('Total').value rescue nil | ||
end | ||
|
||
def obtener_subtotal(xml,ns) | ||
xml.xpath("//cfdi:Comprobante",ns).attribute('SubTotal').value rescue nil | ||
end | ||
|
||
def obtener_descuento(xml,ns) | ||
xml.xpath("//cfdi:Comprobante",ns).attribute('Descuento').value rescue nil | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# encoding: utf-8 | ||
require 'spec_helper' | ||
|
||
describe FmTimbradoCfdi::FmInformacionCfdi do | ||
context "debe crear un objeto válido" do | ||
let(:plantilla){File.open('spec/fixtures/layout_example3_3.txt').read} | ||
let(:layout){ plantilla.gsub('--fecha-comprobante--', 'asignarFecha' )} | ||
let(:respuesta){ FmTimbradoCfdi.timbrar3_3 'ESI920427886', layout } | ||
let(:informacion) { FmTimbradoCfdi::FmInformacionCfdi3_3.new(respuesta.xml)} | ||
it { expect(informacion.total).to_not be_nil } | ||
it { expect(informacion.total).to eq "1943.00" } | ||
it { expect(informacion.subtotal).to_not be_nil } | ||
it { expect(informacion.subtotal).to eq "1850.00" } | ||
it { expect(informacion.descuento).to_not be_nil } | ||
it { expect(informacion.descuento).to eq "175.00" } | ||
end | ||
end |