br_invoices_pdf 0.2.18 → 0.2.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/br_invoices_pdf.rb +2 -0
- data/lib/br_invoices_pdf/cfe/parser/access_key.rb +2 -0
- data/lib/br_invoices_pdf/cfe/parser/fisco_obs.rb +1 -0
- data/lib/br_invoices_pdf/cfe/parser/payments.rb +1 -0
- data/lib/br_invoices_pdf/nfce/parser/payments.rb +28 -4
- data/lib/br_invoices_pdf/nfce/renderer/procon_info.rb +1 -0
- data/lib/br_invoices_pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9789280a8f99b22f164b17335efc48fa5072a39b
|
4
|
+
data.tar.gz: 11546516680254d6b9502f55f7e813bd2a97077d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb34a40c5de90ac81f2fb6bb622832cee19f1c5a006e33f3e43af16d2f7e4bdce8c7835ed55d6439e826fb99fbbf7beec940e3d96351cceb1dd2af19e76b9a19
|
7
|
+
data.tar.gz: 0f6065d4951a1b3573cdc7ef9ba0062d743b542af4e153698115c817f01351de5fc33bafa236e02571bbb78fe5f28b72e184a034f7b367e8d44f88778e3057cb
|
data/lib/br_invoices_pdf.rb
CHANGED
@@ -26,11 +26,13 @@ module BrInvoicesPdf
|
|
26
26
|
def generate(type, xml, options = {})
|
27
27
|
generator = @generators[type]
|
28
28
|
raise(Errors::InvalidDocumentType, type) unless generator
|
29
|
+
|
29
30
|
generator.generate(xml, options)
|
30
31
|
end
|
31
32
|
|
32
33
|
def register(type, renderer, parser)
|
33
34
|
raise(ArgumentError, "Expected Symbol or String to type. Received #{type.class}") unless valid_type?(type)
|
35
|
+
|
34
36
|
@generators[type.to_sym] = Generator.new(renderer, parser)
|
35
37
|
end
|
36
38
|
|
@@ -9,16 +9,40 @@ module BrInvoicesPdf
|
|
9
9
|
module_function
|
10
10
|
|
11
11
|
def execute(xml)
|
12
|
-
|
12
|
+
xml_version = xml.locate(root_path(xml).to_s)[0].attributes[:versao]
|
13
|
+
|
14
|
+
return payments_new_version(xml) if xml_version[0] == '4'
|
15
|
+
|
16
|
+
payments_old_version(xml)
|
17
|
+
end
|
13
18
|
|
19
|
+
def payments_old_version(xml)
|
20
|
+
node_payments = xml.locate("#{root_path(xml)}/pag")
|
14
21
|
node_payments.map(&method(:payment_by))
|
15
22
|
end
|
16
23
|
|
17
|
-
def
|
24
|
+
def payments_new_version(xml)
|
25
|
+
node_payments = xml.locate("#{root_path(xml)}/pag/detPag")
|
26
|
+
cashback = cashback_for(xml)
|
27
|
+
|
28
|
+
node_payments.map do |payment|
|
29
|
+
payment_by(payment, cashback: cashback)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def cashback_for(xml)
|
34
|
+
locate_element(xml.locate("#{root_path(xml)}/pag")[0], 'vTroco')
|
35
|
+
end
|
36
|
+
|
37
|
+
def payment_by(element, cashback: nil)
|
38
|
+
payment = locate_element(element, 'tPag')
|
39
|
+
|
40
|
+
cashback_amount = cashback if payment == '01'
|
41
|
+
|
18
42
|
{
|
19
|
-
type: Util::Enum::PAYMENT_TYPES[
|
43
|
+
type: Util::Enum::PAYMENT_TYPES[payment],
|
20
44
|
amount: locate_element(element, 'vPag'),
|
21
|
-
cashback: locate_element(element, 'vTroco')
|
45
|
+
cashback: cashback_amount || locate_element(element, 'vTroco')
|
22
46
|
}
|
23
47
|
end
|
24
48
|
private_class_method :payment_by
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_invoices_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Ribeiro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: barby
|