colppy 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 56924725187f03b328b0305020b7acee209863df
4
- data.tar.gz: d22d27f9c912065931f93142177e2ce38eb6b3fc
3
+ metadata.gz: a5494e30413da3d4e1b029c852be3889550792c8
4
+ data.tar.gz: 00b64d152ae5ec21ed41c3b00b7e43a7951584f0
5
5
  SHA512:
6
- metadata.gz: 474bfe2dbb9a742e729752bad31a3aa99c240529bb9c86d5a956f3e6159cc21c3a9e7ed1de8f7d7f575e6429fd4928aa6809c76e592844713a754287ee387742
7
- data.tar.gz: 823a5176e7bc75a6dc83f0d2e9eaff0227e1399f08be15408a40898fa430f1bb3e5ddc1e006fdc48e5e3763125241c4fe5d446b6eea266452e79fad3355f4596
6
+ metadata.gz: 2c028c1cd1cb953ba6576fee5180a7087ff84b50ca755052351bf0f504273d8b61fddbfb9683ef72b4c089508a4e5d0c3c12f6632f1a365395d7406b527d7cdf
7
+ data.tar.gz: 72640f3f583805b0a04f572909402a69ea2831e55c047abcb997375319c1e3c87de2cf827f9734d4577cf3df5ce7f1567c079661e450354939af444f12b03037
@@ -3,9 +3,26 @@ module Colppy
3
3
  extend self
4
4
 
5
5
  def companies
6
- @companies ||= Company.all(self)
6
+ return @companies if @companies
7
+ _companies = Company.all(self)
8
+ if _companies[:results]
9
+ @companies = _companies[:results]
10
+ else
11
+ _companies
12
+ end
7
13
  end
8
14
 
15
+ def company_by_id(id)
16
+ if @companies
17
+ @companies.detect do |company|
18
+ company.id == id
19
+ end
20
+ else
21
+ Company.get(self, id)
22
+ end
23
+ end
24
+ alias :company :company_by_id
25
+
9
26
  end
10
27
 
11
28
  class Company < Resource
@@ -38,6 +55,20 @@ module Colppy
38
55
  response
39
56
  end
40
57
  end
58
+
59
+ def get(client, id)
60
+ response = client.call(
61
+ :company,
62
+ :read,
63
+ client.session_params.merge({ idEmpresa: id })
64
+ )
65
+ if response[:success]
66
+ new(response[:data].merge(client: client))
67
+ else
68
+ response
69
+ end
70
+ end
71
+
41
72
  end
42
73
 
43
74
  def initialize(client: nil, **params)
@@ -21,6 +21,7 @@ module Colppy
21
21
  idCondicionPago: :payment_condition_id,
22
22
  idCondicionIva: :tax_condition_id,
23
23
  CUIT: :cuit,
24
+ dni: :dni,
24
25
  idTipoPercepcion: :tax_perception_id,
25
26
  NroCuenta: :account_number,
26
27
  CBU: :cbu,
@@ -154,31 +155,32 @@ module Colppy
154
155
  idUsuario: @client.username,
155
156
  idCliente: id || "",
156
157
  idEmpresa: @company.id,
157
- NombreFantasia: @data[:NombreFantasia] || "",
158
- RazonSocial: name || "",
159
- CUIT: @data[:CUIT] || "",
160
- DirPostal: @data[:DirPostal] || "",
161
- DirPostalCiudad: @data[:DirPostalCiudad] || "",
162
- DirPostalCodigoPostal: @data[:DirPostalCodigoPostal] || "",
163
- DirPostalProvincia: @data[:DirPostalProvincia] || "",
164
- DirPostalPais: @data[:DirPostalPais] || "Argentina",
165
- Telefono: @data[:Telefono] || "",
166
- Email: @data[:Email] || ""
158
+ NombreFantasia: @data[:fantasy_name] || "",
159
+ RazonSocial: @name || "",
160
+ CUIT: @data[:cuit] || "",
161
+ dni: @data[:dni] || "",
162
+ DirPostal: @data[:address] || "",
163
+ DirPostalCiudad: @data[:address_city] || "",
164
+ DirPostalCodigoPostal: @data[:address_zipcode] || "",
165
+ DirPostalProvincia: @data[:address_state] || "",
166
+ DirPostalPais: @data[:address_country] || "Argentina",
167
+ Telefono: @data[:phone_number] || "",
168
+ Email: @data[:email] || ""
167
169
  }
168
170
  end
169
171
 
170
172
  def other_info_params
171
173
  {
172
- Activo: @data[:Activo] || "1",
174
+ Activo: @data[:active] || "1",
173
175
  FechaAlta: @data[:FechaAlta] || "",
174
- DirFiscal: @data[:DirFiscal] || "",
175
- DirFiscalCiudad: @data[:DirFiscalCiudad] || "",
176
- DirFiscalCodigoPostal: @data[:DirFiscalCodigoPostal] || "",
177
- DirFiscalProvincia: @data[:DirFiscalProvincia] || "",
178
- DirFiscalPais: @data[:DirFiscalPais] || "",
179
- idCondicionPago: @data[:idCondicionPago] || "",
180
- idCondicionIva: @data[:idCondicionIva] || "",
181
- porcentajeIVA: @data[:porcentajeIVA] || "21",
176
+ DirFiscal: @data[:legal_address] || "",
177
+ DirFiscalCiudad: @data[:legal_address_city] || "",
178
+ DirFiscalCodigoPostal: @data[:legal_address_zipcode] || "",
179
+ DirFiscalProvincia: @data[:legal_address_state] || "",
180
+ DirFiscalPais: @data[:legal_address_country] || "Argentina",
181
+ idCondicionPago: @data[:payment_condition_id] || "0",
182
+ idCondicionIva: @data[:tax_condition_id] || "",
183
+ porcentajeIVA: @data[:tax] || "21",
182
184
  idPlanCuenta: @data[:idPlanCuenta] || "",
183
185
  CuentaCredito: @data[:CuentaCredito] || "",
184
186
  DirEnvio: @data[:DirEnvio] || "",
@@ -127,7 +127,7 @@ module Colppy
127
127
  end
128
128
 
129
129
  def tax
130
- (@data[:tax] || product.tax || 0).to_f
130
+ (@data[:tax] || product.tax || 21).to_f
131
131
  end
132
132
  def charged
133
133
  (unit_price || product.sell_price || 0).to_f
@@ -181,7 +181,9 @@ module Colppy
181
181
  }
182
182
  end
183
183
 
184
- def inspect; end
184
+ def inspect
185
+ "#<#{self.class.name} product_id:#{@data[:product_id]} >"
186
+ end
185
187
  end
186
188
  class Invoice::Payment
187
189
  include Utils
@@ -1,3 +1,3 @@
1
1
  module Colppy
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colppy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Cavilliotti
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday