Afip 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5d66fb535901858a9e111987cdc3fa8e5dc14ae01eeb62775f49fa6af7db52f
4
- data.tar.gz: eed5a53a1349c42ca724a4ed22c5705bfa92e8ce0c5e5dc8b9ac6ed7a626051e
3
+ metadata.gz: f38c5d249e07d139a44b89411affbde3b26f350047ec158cb3d40e200e186235
4
+ data.tar.gz: 7c07f89926ae9ca1c62c450586feb6e7ba01caf7bd1b1e62571a548097063cd6
5
5
  SHA512:
6
- metadata.gz: 4c030a14e914dbf6adc749de6ac5770127d1d95568570f8db1363e8936679e395a10f7304bf625a1e40054944e5464dc5b310f7f0e07f5d78232d6be6d081397
7
- data.tar.gz: 4707ae9355a0e42a059316cd4d72b125db1ad09e1273c05362bcd0d4476613d858b215e474d7817fd41cd24f9bc1524e01e7bc25ee233a103c7224aa78ffd281
6
+ metadata.gz: aa409090e458ec9a7b2f77bda111a0b39bd03ff1ee62988a40115df2a756ab02d2051ee56914a0079da3d86141b0137f03efbca60f9cb373d2f4db97e36a6633
7
+ data.tar.gz: 38337f51436a8e0c54b4be71ec7a713d1d46b5068cb99e7112018c8578c40f4f356d3ccd2e6d72309c99b12cae4192b10ab8a384b8d3912e13849a147c755867
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Afip (0.8.5)
4
+ Afip (0.8.6)
5
5
  httpi
6
6
  savon
7
7
 
@@ -18,7 +18,7 @@ GEM
18
18
  rack
19
19
  socksify
20
20
  mini_portile2 (2.4.0)
21
- nokogiri (1.9.1)
21
+ nokogiri (1.10.1)
22
22
  mini_portile2 (~> 2.4.0)
23
23
  nori (2.6.0)
24
24
  rack (2.0.6)
@@ -3,24 +3,29 @@ module Afip
3
3
  attr_reader :cbte_type, :body, :response, :fecha_emision, :total, :client
4
4
  attr_accessor :net, :doc_num, :iva_cond, :documento, :concepto, :moneda,
5
5
  :due_date, :fch_serv_desde, :fch_serv_hasta, :fch_emision,
6
- :ivas, :sale_point
6
+ :ivas, :sale_point, :cant_reg, :no_gravado, :gravado, :exento, :otros_imp
7
7
 
8
8
  def initialize(attrs={})
9
9
  @client = Bill.set_client
10
10
  @sale_point = attrs[:sale_point]
11
11
  @body = { "Auth" => Afip.auth_hash }
12
12
  @net = attrs[:net] || 0
13
- @documento = attrs[:documento] || Afip.default_documento
14
- @moneda = attrs[:moneda] || Afip.default_moneda
15
- @iva_cond = attrs[:iva_cond]
16
- @concepto = attrs[:concepto] || Afip.default_concepto
17
- @ivas = attrs[:ivas] || Array.new # [ 1, 100.00, 10.50 ], [ 2, 100.00, 21.00 ]
18
- @fecha_emision = attrs[:fch_emision] || Time.new
13
+ @documento = attrs[:documento] || Afip.default_documento
14
+ @moneda = attrs[:moneda] || Afip.default_moneda
15
+ @iva_cond = attrs[:iva_cond]
16
+ @concepto = attrs[:concepto] || Afip.default_concepto
17
+ @ivas = attrs[:ivas] || Array.new # [ 1, 100.00, 10.50 ], [ 2, 100.00, 21.00 ]
18
+ @fecha_emision = attrs[:fch_emision] || Time.new
19
19
  @fch_serv_hasta = attrs[:fch_serv_hasta]
20
20
  @fch_serv_desde = attrs[:fch_serv_desde]
21
- @due_date = attrs[:due_date]
22
- @cbte_type = Afip::BILL_TYPE[Afip.own_iva_cond][iva_cond]
23
- @total = net.zero? ? 0 : net + iva_sum
21
+ @due_date = attrs[:due_date]
22
+ @cbte_type = Afip::BILL_TYPE[Afip.own_iva_cond][iva_cond]
23
+ @cant_reg = attrs[:cant_reg] || 1
24
+ @no_gravado = attrs[:no_gravado] || 0.0
25
+ @gravado = attrs[:gravado] || 0.0
26
+ @exento = attrs[:exento] || 0.0
27
+ @otros_imp = attrs[:otros_imp] || 0.0
28
+ @total = net.zero? ? 0 : net + iva_sum
24
29
  end
25
30
 
26
31
  def self.get_ptos_vta
@@ -64,9 +69,25 @@ module Afip
64
69
  array_ivas = Array.new
65
70
  ivas.each{ |i|
66
71
  array_ivas << {
67
- "Id" => i[0],
68
- "BaseImp" => i[1].round(2),
69
- "Importe" => i[2].round(2) }
72
+ "AlicIva" => {
73
+ "Id" => i[0],
74
+ "BaseImp" => i[1].round(2),
75
+ "Importe" => i[2].round(2)
76
+ }
77
+ }
78
+ }
79
+
80
+ array_tributos = Array.new
81
+ tributos.each{ |t|
82
+ array_tributos << {
83
+ "Tributo" => {
84
+ "id" => t[0],
85
+ "Desc" => t[1],
86
+ "BaseImp" => t[2],
87
+ "Alic" => t[3],
88
+ "Importe" => t[4]
89
+ }
90
+ }
70
91
  }
71
92
 
72
93
  fecaereq = {
@@ -78,12 +99,12 @@ module Afip
78
99
  "DocTipo" => Afip::DOCUMENTOS[documento],
79
100
  "DocNro" => doc_num,
80
101
  "CbteFch" => fecha_emision.strftime('%Y%m%d'),
81
- "ImpTotConc" => 0.00,
102
+ "ImpTotConc" => no_gravado,
82
103
  "ImpNeto" => net.to_f,
83
104
  "MonId" => Afip::MONEDAS[moneda][:codigo],
84
105
  "MonCotiz" => exchange_rate,
85
- "ImpOpEx" => 0.00,
86
- "ImpTrib" => 0.00,
106
+ "ImpOpEx" => exento,
107
+ "ImpTrib" => otros_imp,
87
108
  "ImpTotal" => (Afip.own_iva_cond == :responsable_monotributo ? net : total).to_f.round(2),
88
109
  "CbteDesde" => next_bill_number,
89
110
  "CbteHasta" => next_bill_number
@@ -96,9 +117,12 @@ module Afip
96
117
 
97
118
  if (Afip.own_iva_cond == :responsable_inscripto)
98
119
  detail["ImpIVA"] = iva_sum
99
- detail["Iva"] = { "AlicIva" => array_ivas }
120
+ detail["Iva"] = { array_ivas }
100
121
  end
101
122
 
123
+ if !tributos.empty?
124
+ detail["Tributos"] = { array_tributos }
125
+ end
102
126
  unless concepto == "Productos" # En "Productos" ("01"), si se mandan estos parámetros la afip rechaza.
103
127
  detail.merge!({"FchServDesde" => fch_serv_desde.strftime("%Y%m%d"),
104
128
  "FchServHasta" => fch_serv_hasta.strftime("%Y%m%d"),
@@ -109,8 +133,8 @@ module Afip
109
133
  pp body
110
134
  end
111
135
 
112
- def self.header(cbte_type, sale_point)
113
- {"CantReg" => "1", "CbteTipo" => cbte_type, "PtoVta" => sale_point}
136
+ def self.header(cant_reg, cbte_type, sale_point)
137
+ {"CantReg" => cant_reg.to_s, "CbteTipo" => cbte_type, "PtoVta" => sale_point}
114
138
  end
115
139
 
116
140
  def exchange_rate
@@ -1,3 +1,3 @@
1
1
  module Afip
2
- VERSION = "0.8.6"
2
+ VERSION = "0.8.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Afip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Facundo A. Díaz Martínez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon