invoicing_payments_processing 1.1.65 → 1.1.66

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/movement.rb +15 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6c823ecb08c6b06064463c50e00f8a392d31db4
4
- data.tar.gz: 019aad76d9430a5e5ca28a960de182dd03956e3a
3
+ metadata.gz: 03f105a212299b603c5141bf1d86ade1acca82fa
4
+ data.tar.gz: 43ddbb50a0fcbee4d4ae106a24d8696011924413
5
5
  SHA512:
6
- metadata.gz: c82e69dc914a4ccf5a84dcaa55ebedb065aef47405bb99b83c9546f6ced35d95b12fe88c0efc608a49c4c721225555282952baa2126b0a1d55df47b912bcfafa
7
- data.tar.gz: ec65bbcc0118e99f08299bea1e71b3a663bbd91068a02c2cd14b87db5e91c7ae6de0db5ce9fe7b4dfcbf45c0265dc916ee27958601126ad031623d499035a94b
6
+ metadata.gz: 1b6ffbe7aa139fe61da64f82afc6655ea19d2212d66045b9d3f64ac3ea7eab39db713380f19edcbb02acb85ac5e1ffc185c2274b8743a0be0c807d8867a90c56
7
+ data.tar.gz: 90f23ff431761cbf2717c52970168a8856c67cd925a8d52fedd20561eed9495e0ca5eea15816ae5cec6d7be00c98389c4517d49ed5aeb982f85f5b21dad94f5f
@@ -137,22 +137,23 @@ module BlackStack
137
137
  # the movment must be a payment or a bonus
138
138
  raise 'Movement must be either a payment or a bonus' if self.type != MOVEMENT_TYPE_ADD_PAYMENT && self.type != MOVEMENT_TYPE_ADD_BONUS
139
139
  #puts
140
+ #puts "id:#{self.id.to_guid}:."
140
141
  #puts "product_code:#{self.product_code}:."
141
-
142
142
  # itero los pagos y bonos hechos por este mismo producto, desde el primer dia hasta este movimiento.
143
143
  =begin
144
- paid = 0
144
+ paid1 = 0
145
145
  self.client.movements.select { |o|
146
146
  (o.type == MOVEMENT_TYPE_ADD_PAYMENT || o.type == MOVEMENT_TYPE_ADD_BONUS) &&
147
147
  o.credits.to_f < 0 &&
148
148
  o.product_code.upcase == self.product_code.upcase &&
149
149
  o.create_time.to_time < registraton_time.to_time
150
150
  }.sort_by { |o| o.create_time }.each { |o|
151
- paid += (0.to_f - o.credits.to_f)
151
+ paid1 += (0.to_f - o.credits.to_f)
152
152
  break if o.id.to_guid == self.id.to_guid
153
153
  }
154
+ #puts "paid1:#{paid1.to_s}:."
154
155
  =end
155
- paid = 0 - DB[
156
+ q =
156
157
  "select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
157
158
  "from movement m with (nolock) " +
158
159
  "where isnull(m.type, #{BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT.to_s}) in (#{BlackStack::Movement::MOVEMENT_TYPE_ADD_PAYMENT.to_s}, #{BlackStack::Movement::MOVEMENT_TYPE_ADD_BONUS.to_s}) " +
@@ -160,27 +161,29 @@ module BlackStack
160
161
  "and isnull(m.credits,0) < 0 " +
161
162
  "and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
162
163
  "and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " +
163
- "and m.id <> '#{self.id.to_guid}' "
164
- ].first[:n]
164
+ "and m.create_time <= (select m2.create_time from movement m2 with (nolock) where m2.id='#{self.id.to_guid}') "
165
+ paid = 0 - DB[q].first[:n]
166
+ #puts "q:#{q.to_s}:."
165
167
  #puts "paid:#{paid.to_s}:."
166
-
167
168
  =begin
168
169
  # calculo los credito para este producto, desde el primer dia; incluyendo cosumo, expiraciones, ajustes.
169
- consumed = self.client.movements.select { |o|
170
+ consumed1 = self.client.movements.select { |o|
170
171
  o.credits.to_f > 0 &&
171
172
  o.product_code.upcase == self.product_code.upcase &&
172
173
  o.create_time.to_time < registraton_time.to_time
173
174
  }.inject(0) { |sum, o| sum.to_f + o.credits.to_f }.to_f
175
+ #puts "consumed1:#{consumed1.to_s}:."
174
176
  =end
175
- consumed = DB[
177
+ q =
176
178
  "select ISNULL(SUM(ISNULL(m.credits,0)),0) AS n " +
177
179
  "from movement m with (nolock) " +
178
180
  "where m.id_client='#{self.client.id.to_guid}' " +
179
181
  "and isnull(m.credits,0) > 0 " +
180
182
  "and upper(isnull(m.product_code, '')) = '#{self.product_code.upcase}' " +
181
- "and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " +
182
- "and m.id <> '#{self.id.to_guid}' "
183
- ].first[:n]
183
+ "and m.create_time < '#{registraton_time.to_time.strftime('%Y-%m-%d')}' " #+
184
+ # "and m.id <> '#{self.id.to_guid}' "
185
+ consumed = DB[q].first[:n]
186
+ #puts "q:#{q.to_s}:."
184
187
  #puts "consumed:#{consumed.to_s}:."
185
188
 
186
189
  # calculo los creditos de este movimiento que voy a cancelar
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoicing_payments_processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.65
4
+ version: 1.1.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi