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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
br_danfe (2.1.0)
br_danfe (2.2.0)
barby (= 0.6.9)
br_documents (>= 0.1.3)
i18n (>= 0.8.6)
Expand Down
4 changes: 4 additions & 0 deletions lib/br_danfe/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ def self.nfe?(xml)
def self.format_cep(cep)
cep.sub(/(\d{2})(\d{3})(\d{3})/, '\\1.\\2-\\3')
end

def self.address(ender_tag)
"#{ender_tag.css('xLgr').text}, #{ender_tag.css('nro').text}, #{ender_tag.css('xBairro').text}, #{ender_tag.css('xMun').text} - #{ender_tag.css('UF').text}"
end
end
end
2 changes: 1 addition & 1 deletion lib/br_danfe/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BrDanfe
VERSION = '2.1.0'.freeze
VERSION = '2.2.0'.freeze
end
25 changes: 25 additions & 0 deletions spec/br_danfe/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,29 @@
expect(described_class.format_cep('12345678')).to eql '12.345-678'
end
end

describe '.address' do
let(:xml) do
xml = <<~XML
<enderDest>
<xLgr>Rua Tijucas</xLgr>
<nro>99</nro>
<xCpl>dwdwa</xCpl>
<xBairro>Centro</xBairro>
<cMun>4218004</cMun>
<xMun>TIJUCAS</xMun>
<UF>SC</UF>
<CEP>88200000</CEP>
<cPais>1058</cPais>
<xPais>Brasil</xPais>
</enderDest>
XML

BrDanfe::XML.new(xml)
end

it 'returns a formated address string' do
expect(described_class.address(xml)).to eql 'Rua Tijucas, 99, Centro, TIJUCAS - SC'
end
end
end
Loading