colppy 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87bfd991d945eaab9a1b13a8c8b0dd9db3a4f109
4
- data.tar.gz: 6d0183acbe9adebde9380492515bcb5d2f613282
3
+ metadata.gz: 0c1494349b84dc91d119a20764c650f4c244811e
4
+ data.tar.gz: 49379b4d4b21e06108c0b62117e25470fb2c7bb1
5
5
  SHA512:
6
- metadata.gz: 3437be3ea7f1b576ffc047cd7433b14f5c1eac6e899fbae7feb16f0087cbe3f529d526039b9afcd412cd7ef07b997450525b8604bba72f38636ff009cde20160
7
- data.tar.gz: 71b592f8eb709260fd714bac5ac0fff4b54db64de4917da284076c23d02281eebd5cf2c290ddad50510a9775513a01327849ea143a11c9ec44d65222f9990074
6
+ metadata.gz: c6d4302b8d43f6684dccb8f00f9cc0fe4574d4bf451744df86cada7e3e399ccebf27acacc3821b0c1c68359713d2d98ce75ad4ff136621cb7e1550ac022abe46
7
+ data.tar.gz: 8d440d82d6c11b887438901166948a83ef77c82eee995940577d04549fe7fb41cd138e9b0f7ed13fd87146efafa6a81e6b608fd060560ea9314f561933eb3445
@@ -80,6 +80,7 @@ module Colppy
80
80
  Cantidad: :quantity, # required
81
81
  ImporteUnitario: :unit_price,
82
82
  IVA: :tax,
83
+ porcDesc: :discount_percentage,
83
84
  subtotal: :subtotal,
84
85
  idPlanCuenta: :sales_account_id,
85
86
  Comentario: :comment
@@ -130,7 +131,14 @@ module Colppy
130
131
  (@data[:tax] || product.tax || 21).to_f
131
132
  end
132
133
  def charged
133
- (unit_price || product.sell_price || 0).to_f
134
+ if (percentage = discount_percentage.to_f) > 0
135
+ unit_price * ((100 - percentage) / 100)
136
+ else
137
+ unit_price
138
+ end
139
+ end
140
+ def unit_price
141
+ (@data[:unit_price] || product.sell_price || 0).to_f
134
142
  end
135
143
  def quantity
136
144
  @data[:quantity] || 0
@@ -172,8 +180,8 @@ module Colppy
172
180
  almacen: unhandle_data[:almacen] || "",
173
181
  unidadMedida: measure_unit,
174
182
  Cantidad: quantity,
175
- ImporteUnitario: charged,
176
- porcDesc: unhandle_data[:porcDesc] || 0,
183
+ ImporteUnitario: unit_price.round(2),
184
+ porcDesc: discount_percentage || 0,
177
185
  IVA: tax.to_s,
178
186
  subtotal: total_charged,
179
187
  idPlanCuenta: sales_account_id,
@@ -238,7 +238,7 @@ module Colppy
238
238
  idCliente: customer_id,
239
239
  idEmpresa: company_id,
240
240
  idUsuario: @client.username,
241
- descripcion: @data[:descripcion] || "",
241
+ descripcion: @data[:description] || "",
242
242
  fechaFactura: valid_date(@data[:invoice_date]),
243
243
  idCondicionPago: payment_condition_id,
244
244
  fechaPago: valid_date(@data[:payment_date]),
@@ -1,3 +1,3 @@
1
1
  module Colppy
2
- VERSION = "0.3.1".freeze
2
+ VERSION = "0.3.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colppy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Cavilliotti