invoicing_payments_processing 1.1.62 → 1.1.63
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 +4 -4
- data/lib/movement.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff9dee57e2b7e6dc8635871fe89ec8dbe98278e8
|
4
|
+
data.tar.gz: dc3a121367f28260594a13f3996adec7b0335df9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104338f6525e2c8b45a0b120cd6e5ac2ee71573b2c95f7885c6c6da11236ed25e89d766f8528ea19f6c92d89b0ce765b5f6eeb76579e69fc5507d33d6d6b9590
|
7
|
+
data.tar.gz: 0a8d4411793c7dc01c02cd0e642487193d35eca8f22ea27985da375d5f63a1f43e866206b80ff0ea1e30c9bd25d18805c3a7c0d359aafa16fa9a75fa54a1bf66
|
data/lib/movement.rb
CHANGED
@@ -126,7 +126,14 @@ module BlackStack
|
|
126
126
|
#
|
127
127
|
def credits_consumed(registraton_time=nil)
|
128
128
|
# le agrego 365 dias a la fecha actual, para abarcar todas las fechas ocurridas hasta hoy seguro
|
129
|
-
|
129
|
+
if registraton_time.nil?
|
130
|
+
registraton_time = (Time.now() + 365*24*60*60)
|
131
|
+
else
|
132
|
+
registraton_time = registraton_time.to_time if registraton_time.class != Time
|
133
|
+
end
|
134
|
+
# move time to the first second of the next day.
|
135
|
+
# example: '2020-11-12 15:49:43 -0300' will be converted to '2020-11-13 00:00:00 -0300'
|
136
|
+
registraton_time = (Date.strptime(registraton_time.strftime("%Y-%m-%d"), "%Y-%m-%d").to_time + 24*60*60)
|
130
137
|
# the movment must be a payment or a bonus
|
131
138
|
raise 'Movement must be either a payment or a bonus' if self.type != MOVEMENT_TYPE_ADD_PAYMENT && self.type != MOVEMENT_TYPE_ADD_BONUS
|
132
139
|
#puts
|
@@ -137,7 +144,7 @@ module BlackStack
|
|
137
144
|
(o.type == MOVEMENT_TYPE_ADD_PAYMENT || o.type == MOVEMENT_TYPE_ADD_BONUS) &&
|
138
145
|
o.credits.to_f < 0 &&
|
139
146
|
o.product_code.upcase == self.product_code.upcase &&
|
140
|
-
o.create_time.to_time
|
147
|
+
o.create_time.to_time < registraton_time.to_time
|
141
148
|
}.sort_by { |o| o.create_time }.each { |o|
|
142
149
|
paid += (0.to_f - o.credits.to_f)
|
143
150
|
break if o.id.to_guid == self.id.to_guid
|
@@ -147,7 +154,7 @@ module BlackStack
|
|
147
154
|
consumed = self.client.movements.select { |o|
|
148
155
|
o.credits.to_f > 0 &&
|
149
156
|
o.product_code.upcase == self.product_code.upcase &&
|
150
|
-
o.create_time.to_time
|
157
|
+
o.create_time.to_time < registraton_time.to_time
|
151
158
|
}.inject(0) { |sum, o| sum.to_f + o.credits.to_f }.to_f
|
152
159
|
#puts "consumed:#{consumed.to_s}:."
|
153
160
|
# calculo los creditos de este movimiento que voy a cancelar
|