From e7635e9eb54001f26cfb88083d71ec9b43ecfeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Schwanck=20dos=20Santos?= Date: Thu, 7 Mar 2019 17:32:40 -0300 Subject: [PATCH 1/3] FIX Invalid date on XML --- CHANGELOG.md | 3 +++ lib/br_invoices_pdf/nfce/parser/emission_details.rb | 6 +++++- lib/br_invoices_pdf/version.rb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1201056..94c33b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## CHANGELOG +## 0.2.24 [2019-03-07] +- [Corrigido] Data bugada no XML + ## 0.2.21 [2018-11-15] - [Atualizando] versão da gem ox diff --git a/lib/br_invoices_pdf/nfce/parser/emission_details.rb b/lib/br_invoices_pdf/nfce/parser/emission_details.rb index c529e10..441931b 100644 --- a/lib/br_invoices_pdf/nfce/parser/emission_details.rb +++ b/lib/br_invoices_pdf/nfce/parser/emission_details.rb @@ -63,7 +63,11 @@ def check_url(xml) private_class_method :check_url def locate_element_to_date(xml, path) - Time.parse(locate_element(xml, path)).utc + begin + Time.parse(locate_element(xml, path)).utc + rescue StandardError => e + Time.parse("#{locate_element(xml, path)[0..18]}-03:00").utc + end end private_class_method :locate_element_to_date end diff --git a/lib/br_invoices_pdf/version.rb b/lib/br_invoices_pdf/version.rb index 629ce18..9e1006c 100644 --- a/lib/br_invoices_pdf/version.rb +++ b/lib/br_invoices_pdf/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module BrInvoicesPdf - VERSION = '0.2.23' + VERSION = '0.2.24' end From 7dd37c99a6024ad7c2443aeb382e8c18532af8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Schwanck=20dos=20Santos?= Date: Thu, 7 Mar 2019 17:38:01 -0300 Subject: [PATCH 2/3] Rubocop --- lib/br_invoices_pdf/nfce/parser/emission_details.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/br_invoices_pdf/nfce/parser/emission_details.rb b/lib/br_invoices_pdf/nfce/parser/emission_details.rb index 441931b..ace8ff5 100644 --- a/lib/br_invoices_pdf/nfce/parser/emission_details.rb +++ b/lib/br_invoices_pdf/nfce/parser/emission_details.rb @@ -63,11 +63,9 @@ def check_url(xml) private_class_method :check_url def locate_element_to_date(xml, path) - begin - Time.parse(locate_element(xml, path)).utc - rescue StandardError => e - Time.parse("#{locate_element(xml, path)[0..18]}-03:00").utc - end + Time.parse(locate_element(xml, path)).utc + rescue StandardError => _e + Time.parse("#{locate_element(xml, path)[0..18]}-03:00").utc end private_class_method :locate_element_to_date end From d3e24b932ed29842a34a2c8488725dc848033a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Schwanck=20dos=20Santos?= Date: Thu, 7 Mar 2019 17:48:17 -0300 Subject: [PATCH 3/3] Reek --- lib/br_invoices_pdf/nfce/parser/emission_details.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/br_invoices_pdf/nfce/parser/emission_details.rb b/lib/br_invoices_pdf/nfce/parser/emission_details.rb index ace8ff5..96f92ae 100644 --- a/lib/br_invoices_pdf/nfce/parser/emission_details.rb +++ b/lib/br_invoices_pdf/nfce/parser/emission_details.rb @@ -63,9 +63,11 @@ def check_url(xml) private_class_method :check_url def locate_element_to_date(xml, path) - Time.parse(locate_element(xml, path)).utc + element = locate_element(xml, path) + + Time.parse(element).utc rescue StandardError => _e - Time.parse("#{locate_element(xml, path)[0..18]}-03:00").utc + Time.parse("#{element[0..18]}-03:00").utc end private_class_method :locate_element_to_date end