snappler_contable 0.1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +28 -1
- data/app/models/ledger_account.rb +148 -41
- data/app/models/ledger_account_activo.rb +3 -1
- data/app/models/ledger_account_pasivo.rb +1 -1
- data/app/models/ledger_account_patrimonio_neto.rb +1 -1
- data/app/models/ledger_account_resultado_negativo.rb +1 -1
- data/app/models/ledger_account_resultado_positivo.rb +1 -1
- data/app/models/ledger_currency.rb +1 -1
- data/app/models/ledger_move.rb +53 -7
- data/lib/generators/snappler_contable/templates/snappler_contable_migrate.rb +7 -3
- data/lib/snappler_contable/snappler_contable.rb +5 -2
- data/lib/snappler_contable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjEzYjJkMzE4ZjE2N2FlMWNkZmRiNmY5MGY2NDJkZmUxOTcyNDU2MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTUxMzdmYzM1MTVjYTVjYWQ2ZTc4MzcxZTAwY2ZhODc0YTQ3MDNjYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTc3M2NiYzA0YjI4OGQ1N2Q2ZGVmZDA0MzYwMjI1YmM5Nzk2YTA4ZjIzNjBj
|
10
|
+
NGM5MTI4MjNhMzViMTRjZGQ2ZGZkMThhZGE1YWJjYTM3NDkzYWQzZWEyMWNk
|
11
|
+
YTQ4YWVmYzBjMzk4MmU1ZDZmMWU1ODYxMmEyZmM5NWM2ZDc4ZDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2QyZmRiNDE3YjUxZTRmN2E1NWUxYjc4MzZhYjEzNDIxMjE3NDc3ZWU1MzZi
|
14
|
+
Y2UzMWMzNzBiNDk4Zjk3MzMzM2IyODY2YjZhNzI0MDc0NzQyNGNkZTJlZTQ1
|
15
|
+
NDI4MjJjNmViYWFiYjJkOWRiNDU0ZTk5YTNjMjczNzM3NGIwYTQ=
|
data/README.rdoc
CHANGED
@@ -269,6 +269,8 @@ Devuelve el sub árbol de cuentas que baja desde la cuenta sobre la que se ejecu
|
|
269
269
|
- objeto_act_as_snp_contable.ledger_accounts
|
270
270
|
Devuelve un array con las cuentas contables (las crea si es necesario) vinculadas con el objeto.
|
271
271
|
|
272
|
+
- objeto_act_as_snp_contable.get_ledger_account_by_code_name(:symbol)
|
273
|
+
Devuelve la cuenta contable asocidada (las crea si es necesario) vinculadas con el objeto.
|
272
274
|
|
273
275
|
= Operación contable
|
274
276
|
|
@@ -302,7 +304,32 @@ Por último, respecto a las operaciones, si dentro de alguno las colecciones de
|
|
302
304
|
|
303
305
|
|
304
306
|
|
305
|
-
|
307
|
+
------------------------------------------------------------------------------------------------------------------------------
|
308
|
+
------------------------------------------------------------------------------------------------------------------------------
|
309
|
+
------------------------------------------------------------------------------------------------------------------------------
|
310
|
+
------------------------------------------------------------------------------------------------------------------------------
|
311
|
+
------------------------------------------------------------------------------------------------------------------------------
|
312
|
+
------------------------------------------------------------------------------------------------------------------------------
|
313
|
+
------------------------------------------------------------------------------------------------------------------------- v1.1
|
314
|
+
FIXES
|
315
|
+
* El calculo ahora las operaciones se hacen en enteros Y DESPUES se transforman
|
316
|
+
* La funcion 'unformat_value(value)' de LedgerMove hace un round antes de tl .to_i, elimina el bug del flotante
|
317
|
+
|
318
|
+
FEATURES / CHANGES
|
319
|
+
* Currencies ahora tiene un campo para el simbolo 'sym', ($, u$s, etc)
|
320
|
+
* Agregado monedas dolar y euro
|
321
|
+
* Ahora la gema es multicurrency funcional:
|
322
|
+
El método 'balance' ahora devuelve un hash {ID_CURRENCY => AMOUNT, ID_CURRENCY => AMOUNT}
|
323
|
+
* IMPORTANTE!!! El método 'SnapplerContable.op' en versiones viejas va a fallar, ya que en esta Version cambia como recive
|
324
|
+
los parámetros
|
325
|
+
Ejemplo:
|
326
|
+
Version Vieja:
|
327
|
+
SnapplerContable.op(array_debe, array_haber, operation_debe = nil, operation_haber = nil)
|
328
|
+
|
329
|
+
Version Actual:
|
330
|
+
SnapplerContable.op(array_debe, array_haber, params_hash => {:operation_debe => nil, :operation_haber => nil, :date => nil})
|
331
|
+
|
332
|
+
Agregado el campo date a la operacion para buscar entre esa fecha y no con el 'created_at' de antes
|
306
333
|
|
307
334
|
|
308
335
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
class LedgerAccount < ActiveRecord::Base
|
2
2
|
#--------------------------------------------- RELATIION
|
3
|
+
has_many :ledger_moves, :dependent => :destroy
|
3
4
|
belongs_to :contable, polymorphic: true
|
4
|
-
has_many :child_ledger_accounts, :class_name => "LedgerAccount", :foreign_key => "master_ledger_account_id", :order => 'order_column'
|
5
|
+
has_many :child_ledger_accounts, :class_name => "LedgerAccount", :foreign_key => "master_ledger_account_id", :order => 'order_column', :dependent => :destroy
|
5
6
|
belongs_to :master_ledger_account, :class_name => "LedgerAccount"
|
6
7
|
#--------------------------------------------- MISC
|
7
8
|
attr_accessible :name, :code, :code_name, :master_ledger_account_id, :master_ledger_account, :contable, :balance_sum
|
@@ -11,10 +12,22 @@ class LedgerAccount < ActiveRecord::Base
|
|
11
12
|
#--------------------------------------------- CALLBACK
|
12
13
|
before_save :set_code
|
13
14
|
after_create :set_order_column
|
15
|
+
#before_destroy :has_no_ledger_moves?
|
14
16
|
#--------------------------------------------- SCOPES
|
15
17
|
default_scope order('order_column ASC')
|
16
18
|
#--------------------------------------------- METHODS
|
17
19
|
|
20
|
+
#Valida q no tenga operaciones de gasto relacionadas
|
21
|
+
def has_no_ledger_moves?
|
22
|
+
if self.ledger_moves.any?
|
23
|
+
self.errors[:base] << "No se pudo borrar porque tiene Movimientos asociados"
|
24
|
+
return false
|
25
|
+
else
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
18
31
|
def self.account(value)
|
19
32
|
where(:code_name => value.to_s.snp_underscore).first
|
20
33
|
end
|
@@ -30,6 +43,17 @@ class LedgerAccount < ActiveRecord::Base
|
|
30
43
|
end
|
31
44
|
end
|
32
45
|
|
46
|
+
def add_child_with_contable(name, code_name, contable)
|
47
|
+
if self.persisted?
|
48
|
+
self.class.create(name: name, master_ledger_account: self, contable: contable, code_name: "#{code_name}_#{contable.class.name.underscore}_#{contable.id}" )
|
49
|
+
else
|
50
|
+
if self.errors.count > 0
|
51
|
+
errores = " La cuenta '#{name}' no se pudo persistir porque sus campos no cumplen la validacion de LedgerAccount."
|
52
|
+
end
|
53
|
+
raise "La instancia debe estar persistida para poder agregar una cuenta hija." + errores.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
33
57
|
def set_code
|
34
58
|
unless self.master_ledger_account_id == 0
|
35
59
|
unless self.order_column.nil?
|
@@ -80,72 +104,155 @@ class LedgerAccount < ActiveRecord::Base
|
|
80
104
|
balance
|
81
105
|
end
|
82
106
|
|
83
|
-
|
84
|
-
|
85
|
-
|
107
|
+
#Mejora la logica
|
108
|
+
def special_balance(params)
|
109
|
+
from_date = params[:from_date]
|
110
|
+
to_date = params[:to_date]
|
111
|
+
format_value = (params[:format_value].nil?)? true : params[:format_value]
|
112
|
+
|
113
|
+
if((from_date.nil?) && (to_date.nil?))
|
114
|
+
return balance(format_value)
|
115
|
+
else
|
116
|
+
if((! from_date.nil?) && (! to_date.nil?))
|
117
|
+
return balance_from_to(from_date, to_date, format_value)
|
118
|
+
else
|
119
|
+
if(! from_date.nil?)
|
120
|
+
return balance_from(from_date, format_value)
|
121
|
+
else
|
122
|
+
return balance_to(to_date, format_value)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def balance_zero?
|
130
|
+
hash_balance = self.balance
|
131
|
+
zero = true
|
132
|
+
LedgerCurrency.all.each{|x| zero &&= (hash_balance[x.id.to_s].nil?)||(hash_balance[x.id.to_s].zero?) }
|
133
|
+
return zero
|
134
|
+
end
|
135
|
+
|
136
|
+
def balance_zero_or_minor?
|
137
|
+
hash_balance = self.balance
|
138
|
+
zero = true
|
139
|
+
LedgerCurrency.all.each{|x| zero &&= (hash_balance[x.id.to_s].nil?)||(hash_balance[x.id.to_s] <= 0) }
|
140
|
+
return zero
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
def balance(format_value=true)
|
145
|
+
bal = {}
|
146
|
+
LedgerAccount.where(:id => children_accounts_ids).each do |account|
|
147
|
+
bal.merge!(eval(account.balance_sum)){|key, oldval, newval| newval + oldval} if(! account.balance_sum.blank?)
|
148
|
+
end
|
149
|
+
|
150
|
+
#Proceso la info para mostrarla en flotante
|
151
|
+
bal.reject!{|x,y| y.zero?}
|
152
|
+
bal.each{|x,y| bal[x] = LedgerMove::format_value(y) } if(format_value)
|
153
|
+
bal_sorted = {}
|
154
|
+
bal.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
155
|
+
return bal_sorted
|
86
156
|
end
|
87
157
|
|
88
158
|
|
89
|
-
def balance_to(to_date)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
159
|
+
def balance_to(to_date, format_value=true)
|
160
|
+
bal_debe = {}
|
161
|
+
bal_haber = {}
|
162
|
+
LedgerCurrency.all.each{|x| bal_debe[x.id] = 0; bal_haber[x.id] = 0}
|
163
|
+
bal = {}
|
164
|
+
|
165
|
+
dh_array = LedgerMove.where(:ledger_account_id => children_accounts_ids).where('date <= ?', to_date)
|
166
|
+
dh_array.each do |dh|
|
167
|
+
bal_debe.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'D')
|
168
|
+
bal_haber.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'H')
|
169
|
+
end
|
170
|
+
|
171
|
+
bal = process_balance(bal_debe, bal_haber)
|
172
|
+
bal.reject!{|x,y| y.zero?}
|
173
|
+
bal.each{|x,y| bal[x] = LedgerMove::format_value(y) } if(format_value)
|
174
|
+
|
175
|
+
bal_sorted = {}
|
176
|
+
bal.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
177
|
+
return bal_sorted
|
94
178
|
end
|
95
179
|
|
96
|
-
def balance_from(from_date)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
180
|
+
def balance_from(from_date, format_value=true)
|
181
|
+
bal_debe = {}
|
182
|
+
bal_haber = {}
|
183
|
+
LedgerCurrency.all.each{|x| bal_debe[x.id] = 0; bal_haber[x.id] = 0}
|
184
|
+
bal = {}
|
185
|
+
|
186
|
+
dh_array = LedgerMove.where(:ledger_account_id => children_accounts_ids).where('date >= ?', from_date)
|
187
|
+
dh_array.each do |dh|
|
188
|
+
bal_debe.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'D')
|
189
|
+
bal_haber.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'H')
|
190
|
+
end
|
191
|
+
|
192
|
+
bal = process_balance(bal_debe, bal_haber)
|
193
|
+
bal.reject!{|x,y| y.zero?}
|
194
|
+
bal.each{|x,y| bal[x] = LedgerMove::format_value(y) } if(format_value)
|
195
|
+
|
196
|
+
bal_sorted = {}
|
197
|
+
bal.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
198
|
+
return bal_sorted
|
101
199
|
end
|
102
200
|
|
103
|
-
def balance_from_to(from_date, to_date)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
201
|
+
def balance_from_to(from_date, to_date, format_value=true)
|
202
|
+
bal_debe = {}
|
203
|
+
bal_haber = {}
|
204
|
+
LedgerCurrency.all.each{|x| bal_debe[x.id] = 0; bal_haber[x.id] = 0}
|
205
|
+
bal = {}
|
206
|
+
|
207
|
+
dh_array = LedgerMove.where(:ledger_account_id => children_accounts_ids).where('date >= ? AND date <= ?', from_date, to_date)
|
208
|
+
dh_array.each do |dh|
|
209
|
+
bal_debe.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'D')
|
210
|
+
bal_haber.merge!({dh.ledger_currency_id => dh.raw_value}){|key, oldval, newval| newval + oldval} if(dh.dh == 'H')
|
211
|
+
end
|
212
|
+
bal = process_balance(bal_debe, bal_haber)
|
213
|
+
bal.reject!{|x,y| y.zero?}
|
214
|
+
bal.each{|x,y| bal[x] = LedgerMove::format_value(y) } if(format_value)
|
215
|
+
|
216
|
+
bal_sorted = {}
|
217
|
+
bal.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
218
|
+
return bal_sorted
|
108
219
|
end
|
109
220
|
|
221
|
+
|
222
|
+
|
110
223
|
def process_balance
|
111
224
|
raise "Este metodo solo se tiene que implementar en las subclases"
|
112
225
|
end
|
113
226
|
|
114
|
-
def update_balance(value, dh)
|
227
|
+
def update_balance(value, dh, ledger_currency)
|
115
228
|
case dh.upcase
|
116
229
|
when 'D'
|
117
|
-
update_balance = process_balance(value, 0)
|
230
|
+
update_balance = process_balance({ledger_currency.id.to_s => value}, {ledger_currency.id.to_s => 0})
|
118
231
|
when 'H'
|
119
|
-
update_balance = process_balance(0, value)
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
|
232
|
+
update_balance = process_balance({ledger_currency.id.to_s => 0}, {ledger_currency.id.to_s => value})
|
233
|
+
end
|
234
|
+
|
235
|
+
#Obtengo el Hash
|
236
|
+
balance_sum = (self.balance_sum.blank?)? {} : eval(self.balance_sum)
|
237
|
+
bal = (balance_sum[ledger_currency.id.to_s].nil?)? 0 : balance_sum[ledger_currency.id.to_s]
|
238
|
+
balance_sum[ledger_currency.id.to_s] = (update_balance[ledger_currency.id.to_s] + bal)
|
239
|
+
|
240
|
+
#Elimino las q son zero asi no queda basura
|
241
|
+
balance_sum.reject!{|x,y| y.zero?}
|
242
|
+
self.balance_sum = balance_sum.to_s
|
243
|
+
self.save
|
124
244
|
end
|
125
245
|
|
126
|
-
def update_balance_destroy(value, dh)
|
246
|
+
def update_balance_destroy(value, dh, ledger_currency)
|
127
247
|
#inverse operation
|
128
248
|
ops = {'D' => 'H', 'H' => 'D'}
|
129
|
-
update_balance(value, ops[dh])
|
249
|
+
update_balance(value, ops[dh], ledger_currency)
|
130
250
|
end
|
131
251
|
|
132
252
|
def accounts_tree
|
133
253
|
SnapplerContable.account_sub_tree(self)
|
134
254
|
end
|
135
255
|
|
136
|
-
def balance_sum=(val)
|
137
|
-
if val.is_a? Numeric
|
138
|
-
write_attribute :balance_sum, LedgerMove.unformat_value(val)
|
139
|
-
else
|
140
|
-
raise "El valor debe ser un numero"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def balance_sum
|
145
|
-
value_formated = read_attribute :balance_sum
|
146
|
-
LedgerMove.format_value(value_formated)
|
147
|
-
end
|
148
|
-
|
149
256
|
end
|
150
257
|
|
151
258
|
|
data/app/models/ledger_move.rb
CHANGED
@@ -4,8 +4,8 @@ class LedgerMove < ActiveRecord::Base
|
|
4
4
|
belongs_to :ledger_account
|
5
5
|
belongs_to :ledger_currency
|
6
6
|
#--------------------------------------------- MISC
|
7
|
-
attr_accessible :currency_ratio, :dh, :value, :ledger_account, :ledger_currency, :currency_ratio
|
8
|
-
DIVISOR = 100.0
|
7
|
+
attr_accessible :currency_ratio, :dh, :value, :ledger_account, :ledger_currency, :currency_ratio, :date
|
8
|
+
DIVISOR = 100.0
|
9
9
|
#--------------------------------------------- VALIDATION
|
10
10
|
|
11
11
|
#--------------------------------------------- CALLBACK
|
@@ -14,29 +14,60 @@ class LedgerMove < ActiveRecord::Base
|
|
14
14
|
after_update :update_balance_update
|
15
15
|
|
16
16
|
#--------------------------------------------- SCOPES
|
17
|
+
scope :filter_date_start, lambda { |date| if((date)&&(! date.blank?))
|
18
|
+
{:conditions => ["ledger_moves.date >= ?", Date.parse(date)]}
|
19
|
+
end }
|
20
|
+
|
21
|
+
scope :filter_date_end, lambda { |date| if((date)&&(! date.blank?))
|
22
|
+
{:conditions => ["ledger_moves.date <= ?", Date.parse(date)]}
|
23
|
+
end }
|
24
|
+
|
25
|
+
scope :order_date_asc, :order => 'ledger_moves.date ASC, ledger_moves.id ASC'
|
17
26
|
|
18
27
|
#--------------------------------------------- METHODS
|
19
28
|
|
20
29
|
def update_balance_create
|
21
|
-
self.ledger_account.update_balance(
|
30
|
+
self.ledger_account(true).update_balance(raw_value, dh, ledger_currency)
|
22
31
|
end
|
23
32
|
|
33
|
+
|
24
34
|
def update_balance_destroy
|
25
|
-
self.ledger_account.update_balance_destroy(
|
35
|
+
self.ledger_account(true).update_balance_destroy(raw_value, dh, ledger_currency)
|
26
36
|
end
|
27
37
|
|
38
|
+
|
28
39
|
def update_balance_update
|
29
|
-
self.ledger_account.update_balance_destroy(
|
30
|
-
self.ledger_account.update_balance(
|
40
|
+
self.ledger_account(true).update_balance_destroy(value_was, dh, ledger_currency)
|
41
|
+
self.ledger_account(true).update_balance(raw_value, dh, ledger_currency)
|
31
42
|
end
|
32
43
|
|
44
|
+
def self.format_hash(bal)
|
45
|
+
bal_aux = {}
|
46
|
+
bal.each{|x,y| bal_aux[x] = LedgerMove::format_value(y) }
|
47
|
+
|
48
|
+
bal_sorted = {}
|
49
|
+
bal_aux.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
50
|
+
|
51
|
+
return bal_sorted
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.unformat_hash(bal)
|
55
|
+
bal_aux = {}
|
56
|
+
bal.each{|x,y| bal_aux[x] = LedgerMove::unformat_value(y) }
|
57
|
+
|
58
|
+
bal_sorted = {}
|
59
|
+
bal_aux.sort.collect{|elem| bal_sorted[elem.first] = elem.last }
|
60
|
+
|
61
|
+
return bal_sorted
|
62
|
+
end
|
63
|
+
|
33
64
|
|
34
65
|
def self.format_value(value)
|
35
66
|
value / DIVISOR
|
36
67
|
end
|
37
68
|
|
38
69
|
def self.unformat_value(value)
|
39
|
-
(value * DIVISOR).to_i
|
70
|
+
(value * DIVISOR).round.to_i
|
40
71
|
end
|
41
72
|
|
42
73
|
def value=(val)
|
@@ -47,8 +78,23 @@ class LedgerMove < ActiveRecord::Base
|
|
47
78
|
end
|
48
79
|
end
|
49
80
|
|
81
|
+
def currency_with_value(format_value=true)
|
82
|
+
case self.dh.upcase
|
83
|
+
when 'D'
|
84
|
+
bal = self.ledger_account.process_balance({self.ledger_currency_id.to_s => self.raw_value}, {ledger_currency.id.to_s => 0})
|
85
|
+
when 'H'
|
86
|
+
bal = self.ledger_account.process_balance({ledger_currency.id.to_s => 0}, {self.ledger_currency_id.to_s => self.raw_value})
|
87
|
+
end
|
88
|
+
bal = LedgerMove::format_hash(bal) if(format_value)
|
89
|
+
return bal
|
90
|
+
end
|
91
|
+
|
50
92
|
def value
|
51
93
|
value_formated = read_attribute :value
|
52
94
|
self.class.format_value(value_formated)
|
53
95
|
end
|
96
|
+
|
97
|
+
def raw_value
|
98
|
+
return read_attribute :value
|
99
|
+
end
|
54
100
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
class SnapplerContableMigrate < ActiveRecord::Migration
|
2
3
|
def self.up
|
3
4
|
create_table :ledger_accounts do |t|
|
4
5
|
t.string :name
|
5
|
-
t.
|
6
|
+
t.string :balance_sum
|
6
7
|
t.string :code
|
7
8
|
t.string :code_name
|
8
9
|
t.integer :order_column
|
@@ -28,6 +29,7 @@ class SnapplerContableMigrate < ActiveRecord::Migration
|
|
28
29
|
t.integer :value, :default => 0
|
29
30
|
t.references :ledger_currency
|
30
31
|
t.float :currency_ratio
|
32
|
+
t.date :date
|
31
33
|
|
32
34
|
t.timestamps
|
33
35
|
end
|
@@ -42,10 +44,12 @@ class SnapplerContableMigrate < ActiveRecord::Migration
|
|
42
44
|
create_table :ledger_currencies do |t|
|
43
45
|
t.string :name
|
44
46
|
t.string :code
|
45
|
-
|
47
|
+
t.string :sym
|
46
48
|
t.timestamps
|
47
49
|
end
|
48
|
-
LedgerCurrency.create(name: 'Peso', code: 'ARS')
|
50
|
+
LedgerCurrency.create(name: 'Peso', code: 'ARS', sym: '$')
|
51
|
+
LedgerCurrency.create(name: 'Dolar', code: 'DOL', sym: 'u$s')
|
52
|
+
LedgerCurrency.create(name: 'Euro', code: 'EUR', sym: '€')
|
49
53
|
end
|
50
54
|
|
51
55
|
def self.down
|
@@ -78,7 +78,10 @@ module SnapplerContable
|
|
78
78
|
return res_accounts
|
79
79
|
end
|
80
80
|
|
81
|
-
def self.op(array_debe, array_haber,
|
81
|
+
def self.op(array_debe, array_haber, params_hash)
|
82
|
+
operation_debe = params_hash[:operation_debe]
|
83
|
+
operation_haber = params_hash[:operation_haber]
|
84
|
+
date = params_hash[:date]
|
82
85
|
|
83
86
|
if operation_haber.nil?
|
84
87
|
operation_haber = operation_debe
|
@@ -117,7 +120,7 @@ module SnapplerContable
|
|
117
120
|
m[:currency] = dc
|
118
121
|
m[:currency_ratio] = 1
|
119
122
|
end
|
120
|
-
le.ledger_moves.build(ledger_account: m[:account], value: m[:value], dh: m[:dh], ledger_currency: m[:currency], currency_ratio: m[:currency_ratio])
|
123
|
+
le.ledger_moves.build(ledger_account: m[:account], value: m[:value], dh: m[:dh], ledger_currency: m[:currency], currency_ratio: m[:currency_ratio], date: date)
|
121
124
|
end
|
122
125
|
|
123
126
|
if le.save
|