africompta 1.9.10 → 1.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/Gemfile.lock +14 -8
- data/africompta.gemspec +3 -2
- data/bin/afri_compta.rb +119 -0
- data/bin/africompta.sh +23 -0
- data/config.yaml.default +19 -0
- data/lib/africompta.rb +7 -1
- data/lib/africompta/acaccess.rb +54 -68
- data/lib/africompta/acqooxview.rb +10 -10
- data/lib/africompta/entities/account.rb +120 -116
- data/lib/africompta/entities/config_base.rb +9 -0
- data/lib/africompta/entities/remote.rb +240 -6
- data/lib/africompta/entities/report.rb +136 -0
- data/lib/africompta/entities/users.rb +18 -6
- data/lib/africompta/views/compta/admin.rb +135 -0
- data/lib/africompta/views/compta/check.rb +245 -0
- data/lib/africompta/views/compta/edit_accounts.rb +138 -0
- data/lib/africompta/views/compta/edit_movements.rb +167 -0
- data/lib/africompta/views/compta/remotes.rb +23 -0
- data/lib/africompta/views/compta/tabs.rb +9 -0
- data/lib/africompta/views/compta/users.rb +23 -0
- data/lib/africompta/views/report/compta_executive.rb +221 -0
- data/lib/africompta/views/report/compta_flat.rb +79 -0
- data/lib/africompta/views/report/tabs.rb +7 -2
- data/po/afri_compta-ar.po +2356 -0
- data/po/afri_compta-en.po +2253 -0
- data/po/afri_compta-fr.po +4345 -0
- data/test/ac_account.rb +176 -0
- data/{Test → test}/ac_africompta.rb +0 -0
- data/{Test → test}/ac_big.rb +0 -0
- data/test/ac_merge.rb +177 -0
- data/{Test → test}/ac_movement.rb +14 -1
- data/{Test → test}/ac_sqlite.rb +0 -0
- data/{Test → test}/config_test.yaml +1 -6
- data/test/other.conf +1 -0
- data/test/other.rb +18 -0
- data/test/test.conf +1 -0
- data/{Test → test}/test.rb +7 -14
- metadata +63 -18
- data/Test/ac_account.rb +0 -128
- data/lib/africompta/africompta.rb +0 -83
- data/lib/africompta/views/edit/movement.rb +0 -8
- data/lib/africompta/views/edit/tabs.rb +0 -8
- data/lib/africompta/views/report/annual.rb +0 -3
@@ -0,0 +1,138 @@
|
|
1
|
+
class ComptaEditAccounts < View
|
2
|
+
def layout
|
3
|
+
@rpc_update = true
|
4
|
+
@order = 200
|
5
|
+
@functions_need = [:accounting]
|
6
|
+
|
7
|
+
gui_hboxg do
|
8
|
+
gui_vboxg :nogroup do
|
9
|
+
show_entity_account :account_archive, :drop, :callback => true
|
10
|
+
show_entity_account :account_list, :single,
|
11
|
+
:width => 400, :flex => 1, :callback => true
|
12
|
+
show_button :delete, :new
|
13
|
+
end
|
14
|
+
gui_vbox :nogroup do
|
15
|
+
show_str :name
|
16
|
+
show_str :desc, :width => 300
|
17
|
+
show_list_drop :multiplier, '%w(passive active)'
|
18
|
+
show_list_drop :keep_total, '%w(true false)'
|
19
|
+
show_button :save, :account_update
|
20
|
+
end
|
21
|
+
|
22
|
+
gui_window :account_new do
|
23
|
+
show_str :name_new, :width => 300
|
24
|
+
show_str :desc_new
|
25
|
+
show_list_drop :multiplier_new, '%w(passive active)'
|
26
|
+
show_list_drop :keep_total_new, '%w(true false)'
|
27
|
+
show_button :add_account, :close
|
28
|
+
end
|
29
|
+
|
30
|
+
gui_window :msg_win do
|
31
|
+
show_html :msg
|
32
|
+
show_button :close
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def rpc_button_account_update(session, data)
|
38
|
+
if (acc = data._account_list).class == Account
|
39
|
+
acc.update_total
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_mult_keep(acc, mult, keep)
|
44
|
+
acc.multiplier = mult.first == 'active' ? -1 : 1
|
45
|
+
acc.keep_total = keep.first == 'true'
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_mult_keep(acc)
|
49
|
+
[acc.multiplier == -1 ? 'active' : 'passive',
|
50
|
+
acc.keep_total ? 'true' : 'false']
|
51
|
+
end
|
52
|
+
|
53
|
+
def rpc_button_save(session, data)
|
54
|
+
if (acc = data._account_list).class == Account
|
55
|
+
acc.desc, acc.name = data._desc, data._name
|
56
|
+
set_mult_keep(acc, data._multiplier, data._keep_total)
|
57
|
+
update_list
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def rpc_button_new(session, data)
|
62
|
+
if (acc = data._account_list).class == Account
|
63
|
+
mult, keep = get_mult_keep(acc)
|
64
|
+
reply(:window_show, :account_new) +
|
65
|
+
reply(:empty, %w( name_new desc_new )) +
|
66
|
+
reply(:update, multiplier_new: [mult]) +
|
67
|
+
reply(:update, keep_total_new: [keep])
|
68
|
+
else
|
69
|
+
reply(:window_show, :msg_win) +
|
70
|
+
reply(:update, :msg => "Choisir un compte parent d'abord")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def rpc_button_add_account(session, data)
|
75
|
+
if (acc = data._account_list).class == Account
|
76
|
+
return unless data._name_new.to_s.length > 0
|
77
|
+
new_acc = Accounts.create(data._name_new, data._desc_new, acc)
|
78
|
+
set_mult_keep(new_acc, data._multiplier_new, data._keep_total_new)
|
79
|
+
update_list(data._account_archive) +
|
80
|
+
reply(:update, :account_list => new_acc.id) +
|
81
|
+
reply(:window_hide)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def rpc_button_delete(session, data)
|
86
|
+
if (acc = data._account_list).class == Account
|
87
|
+
if acc.is_empty
|
88
|
+
acc.delete
|
89
|
+
update_list(data._account_archive)
|
90
|
+
else
|
91
|
+
reply(:window_show, :msg_win) +
|
92
|
+
reply(:update, msg: "The account #{acc.name} is not empty!")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def update_list(account = [])
|
98
|
+
account.class == Account or account = AccountRoot.current
|
99
|
+
|
100
|
+
reply(:empty_nonlists, :account_list) +
|
101
|
+
reply(:update, :account_list => account.listp_path)
|
102
|
+
end
|
103
|
+
|
104
|
+
def update_archive
|
105
|
+
reply(:empty_nonlists, :account_archive) +
|
106
|
+
reply(:update_silent, :account_archive => [[0, "Actual"]].concat(
|
107
|
+
if archive = AccountRoot.archive
|
108
|
+
archive.accounts.collect { |a|
|
109
|
+
[a.id, a.path] }.sort_by { |a| a[1] }
|
110
|
+
else
|
111
|
+
[]
|
112
|
+
end))
|
113
|
+
end
|
114
|
+
|
115
|
+
def rpc_update_view(session)
|
116
|
+
super(session) +
|
117
|
+
update_list +
|
118
|
+
update_archive
|
119
|
+
end
|
120
|
+
|
121
|
+
def rpc_list_choice_account_list(session, data)
|
122
|
+
reply(:empty_nonlists) +
|
123
|
+
if (acc = data._account_list) != []
|
124
|
+
mult, kt = get_mult_keep(acc)
|
125
|
+
reply(:update, {total: acc.total_form,
|
126
|
+
desc: acc.desc,
|
127
|
+
name: acc.name,
|
128
|
+
multiplier: [mult],
|
129
|
+
keep_total: [kt]})
|
130
|
+
else
|
131
|
+
[]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def rpc_list_choice_account_archive(session, data)
|
136
|
+
update_list(data._account_archive)
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
class ComptaEditMovements < View
|
2
|
+
|
3
|
+
def layout
|
4
|
+
@rpc_update = true
|
5
|
+
@order = 100
|
6
|
+
@functions_need = [:accounting]
|
7
|
+
|
8
|
+
gui_hbox do
|
9
|
+
gui_vbox :nogroup do
|
10
|
+
show_entity_account :account_archive, :drop, :callback => true
|
11
|
+
show_entity_account :account_src, :drop,
|
12
|
+
:width => 400, :callback => true
|
13
|
+
show_table :movement_list, :headings => [:Date, :Description, :Account, :Sub, :Total],
|
14
|
+
:widths => [80, 300, 200, 75, 75], :height => 400,
|
15
|
+
:columns => [:align_right, 0, :align_right, :align_right],
|
16
|
+
:callback => :edit,
|
17
|
+
:edit => [0, 1, 3]
|
18
|
+
show_button :edit, :delete, :new
|
19
|
+
end
|
20
|
+
|
21
|
+
gui_window :movement_edit do
|
22
|
+
show_entity_account :account_dst, :drop, :width => 400
|
23
|
+
show_str :desc, :width => 300
|
24
|
+
show_int :value
|
25
|
+
show_date :date
|
26
|
+
show_button :save, :new_mov, :close
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def rpc_button_new_mov(session, data)
|
32
|
+
if (acc_src = data._account_src).class == Account &&
|
33
|
+
(acc_dst = data._account_dst).class == Account
|
34
|
+
value = to_money(data._value)
|
35
|
+
Movements.create(data._desc, Date.from_web(data._date), value / 1000.0,
|
36
|
+
acc_src, acc_dst)
|
37
|
+
reply(:window_hide) +
|
38
|
+
update_list(data._account_archive, data._account_src)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def rpc_button_save(session, data)
|
43
|
+
if (mov = Movements.match_by_id(data._movement_list.first._element_id)).class == Movement
|
44
|
+
value = to_money(data._value)
|
45
|
+
mov.desc, mov.value, mov.date =
|
46
|
+
data._desc, value / 1000.0, Date.from_web(data._date)
|
47
|
+
|
48
|
+
old = mov.get_other_account(data._account_src)
|
49
|
+
dputs(3) { "Old account: #{old.get_path} - new account: #{data._account_dst.get_path}" }
|
50
|
+
if old != data._account_dst
|
51
|
+
mov.move_from_to(old, data._account_dst)
|
52
|
+
end
|
53
|
+
|
54
|
+
reply(:window_hide) +
|
55
|
+
update_list(data._account_archive, data._account_src)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def rpc_button_edit(session, data)
|
60
|
+
if (mov = Movements.match_by_id(data._movement_list.first._element_id)).class == Movement
|
61
|
+
other = mov.get_other_account(data._account_src).id
|
62
|
+
reply(:window_show, :movement_edit) +
|
63
|
+
reply(:update, :desc => mov.desc, :value => (mov.value*1000).to_i,
|
64
|
+
:date => mov.date.to_web, :account_dst => [other]) +
|
65
|
+
reply_show_hide(:save, :new_mov)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def rpc_button_new(session, data)
|
70
|
+
reply(:window_show, :movement_edit) +
|
71
|
+
reply(:empty, %w( desc value )) +
|
72
|
+
reply(:update, :date => Date.today.to_web) +
|
73
|
+
reply_show_hide(:new_mov, :save)
|
74
|
+
end
|
75
|
+
|
76
|
+
def rpc_button_delete(session, data)
|
77
|
+
if (mov = Movements.match_by_id(data._movement_list.first._element_id)).class == Movement
|
78
|
+
mov.delete
|
79
|
+
update_list(data._account_archive, data._account_src)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def update_list(archive = nil, account = nil)
|
84
|
+
if !(archive && account)
|
85
|
+
return reply(:empty_nonlists, [:movement_list, :account_src]) +
|
86
|
+
if archive
|
87
|
+
reply(:update_silent, account_src: archive.listp_path) +
|
88
|
+
reply(:update_silent, account_dst: archive.listp_path)
|
89
|
+
else
|
90
|
+
[]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
total = account.movements.inject(0.0) { |sum, m|
|
95
|
+
sum + (m.get_value(account) * 1000).round
|
96
|
+
}.to_i
|
97
|
+
reply(:empty_nonlists, :movement_list) +
|
98
|
+
reply(:update, :movement_list => account.movements.collect { |m|
|
99
|
+
value = (m.get_value(account) * 1000).to_i
|
100
|
+
total_old = total
|
101
|
+
total -= value
|
102
|
+
other = m.get_other_account(account).get_path
|
103
|
+
m.date ||= Date.today
|
104
|
+
[m.id, [m.date.to_web, m.desc, other, value.separator,
|
105
|
+
total_old.separator]]
|
106
|
+
})
|
107
|
+
end
|
108
|
+
|
109
|
+
def update_accounts()
|
110
|
+
reply(:empty_nonlists, [:account_archive, :account_src, :account_dst]) +
|
111
|
+
reply(:update_silent, :account_archive =>
|
112
|
+
[[AccountRoot.actual.id, 'Actual']].concat(
|
113
|
+
if archive = AccountRoot.archive
|
114
|
+
archive.accounts.collect { |a|
|
115
|
+
[a.id, a.path] }.sort_by { |a| a[1] }
|
116
|
+
else
|
117
|
+
[]
|
118
|
+
end)) +
|
119
|
+
update_list(AccountRoot.actual, AccountRoot.actual) +
|
120
|
+
reply(:update, :account_src => AccountRoot.actual.listp_path,
|
121
|
+
:account_dst => AccountRoot.actual.listp_path)
|
122
|
+
end
|
123
|
+
|
124
|
+
def rpc_update_view(session)
|
125
|
+
super(session) +
|
126
|
+
update_list +
|
127
|
+
update_accounts
|
128
|
+
end
|
129
|
+
|
130
|
+
def rpc_update(session)
|
131
|
+
reply(:update, :date => Date.today.to_web)
|
132
|
+
end
|
133
|
+
|
134
|
+
def rpc_list_choice_account_src(session, data)
|
135
|
+
return if data._account_src == []
|
136
|
+
update_list(data._account_archive, data._account_src)
|
137
|
+
end
|
138
|
+
|
139
|
+
def rpc_list_choice_account_archive(session, data)
|
140
|
+
return if data._account_archive == []
|
141
|
+
update_list(data._account_archive)
|
142
|
+
end
|
143
|
+
|
144
|
+
def rpc_list_choice_movement_list(session, data)
|
145
|
+
if (mov = data._movement_list).class == Movement
|
146
|
+
reply(:update, :desc => mov.desc, :value => (mov.value * 1000).to_i,
|
147
|
+
:date => mov.date.to_web)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def rpc_table_movement_list(session, data)
|
152
|
+
ml = data._movement_list.first
|
153
|
+
dst = Accounts.get_by_path(ml._Account)
|
154
|
+
rpc_button_save(session, data.merge('value' => ml._Sub, 'desc' => ml._Description,
|
155
|
+
'date' => ml._Date, 'account_dst' => dst))
|
156
|
+
#if (mov = Movements.match_by_id(data._movement_list.first)).class == Movement
|
157
|
+
# rpc_button_edit(session, data)
|
158
|
+
#end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Delete all non-number characters, but also accept european
|
162
|
+
# 10,5 == 10.5
|
163
|
+
def to_money(str)
|
164
|
+
return str.delete('^0123456789.,-').gsub(/,/, '.').to_f
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ComptaRemotes < View
|
2
|
+
include VTListPane
|
3
|
+
def layout
|
4
|
+
@order = 500
|
5
|
+
|
6
|
+
set_data_class :Remotes
|
7
|
+
|
8
|
+
gui_hbox do
|
9
|
+
gui_vbox :nogroup do
|
10
|
+
vtlp_list :remotes_list, 'url', width: 250, maxheight: 250
|
11
|
+
show_button :new
|
12
|
+
end
|
13
|
+
gui_vbox :nogroup do
|
14
|
+
show_str :url, width: 250
|
15
|
+
show_str :name
|
16
|
+
show_str :pass
|
17
|
+
show_int :account_index
|
18
|
+
show_int :movement_index
|
19
|
+
show_button :save
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ComptaUsers < View
|
2
|
+
include VTListPane
|
3
|
+
def layout
|
4
|
+
@order = 600
|
5
|
+
|
6
|
+
set_data_class :Users
|
7
|
+
|
8
|
+
gui_hbox do
|
9
|
+
gui_vbox :nogroup do
|
10
|
+
vtlp_list :users_list, 'name', :width => 150, :maxheight => 250
|
11
|
+
show_button :new
|
12
|
+
end
|
13
|
+
gui_vbox :nogroup do
|
14
|
+
show_str :name
|
15
|
+
show_str :full
|
16
|
+
show_str :pass
|
17
|
+
show_int :account_index
|
18
|
+
show_int :movement_index
|
19
|
+
show_button :save
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
class ReportComptaExecutive < View
|
2
|
+
include PrintButton
|
3
|
+
|
4
|
+
def layout
|
5
|
+
@order = 20
|
6
|
+
@update = true
|
7
|
+
@functions_need = [:accounting]
|
8
|
+
|
9
|
+
gui_hboxg do
|
10
|
+
gui_vbox :nogroup do
|
11
|
+
gui_vboxg :nogroup do
|
12
|
+
show_entity_report_all :reports, :single, :name, :callback => true,
|
13
|
+
:flexheight => 1
|
14
|
+
show_button :report_add, :report_delete
|
15
|
+
end
|
16
|
+
gui_vbox :nogroup do
|
17
|
+
show_date :start
|
18
|
+
show_int :months
|
19
|
+
show_print :print
|
20
|
+
end
|
21
|
+
end
|
22
|
+
gui_vboxg :nogroup do
|
23
|
+
show_str :name
|
24
|
+
show_entity_reportAccount :accounts, :single,
|
25
|
+
:flexheight => 1, :width => 300
|
26
|
+
show_button :account_add, :account_del, :account_edit
|
27
|
+
show_button :account_up, :account_down
|
28
|
+
end
|
29
|
+
|
30
|
+
gui_window :win_account do
|
31
|
+
gui_vbox :nogroup do
|
32
|
+
show_entity_account :root, :drop, :width => 400,
|
33
|
+
:callback => true
|
34
|
+
show_entity_account :account, :drop
|
35
|
+
show_int :level
|
36
|
+
show_button :account_add_win, :account_save_win, :close
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
gui_window :win_report do
|
41
|
+
show_str :report_name
|
42
|
+
show_button :report_add_win, :close
|
43
|
+
end
|
44
|
+
|
45
|
+
gui_window :progress do
|
46
|
+
show_html :progress_txt
|
47
|
+
show_button :report_cancel
|
48
|
+
end
|
49
|
+
|
50
|
+
window_print_status
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def rpc_button_report_add(session, data)
|
55
|
+
reply(:window_show, :print_status)
|
56
|
+
end
|
57
|
+
|
58
|
+
def update_account(root = AccountRoot.actual, account = nil)
|
59
|
+
reply(:empty, :account) +
|
60
|
+
reply(:update, :account => root.listp_path) +
|
61
|
+
reply(:update, :account => [(account.class == Account) ? account.id : 0])
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_root(root = AccountRoot.actual)
|
65
|
+
roots = [[AccountRoot.actual.id, 'Actual']]
|
66
|
+
archive = AccountRoot.archive and roots.concat(archive.listp_path(1)[1..-1])
|
67
|
+
reply(:empty, :root) +
|
68
|
+
reply(:update_silent, :root =>
|
69
|
+
roots.concat([(root.class == Account) ? root.id : 0]))
|
70
|
+
end
|
71
|
+
|
72
|
+
def update_reports
|
73
|
+
reply(:empty, :reports) +
|
74
|
+
reply(:update, :reports => Reports.listp_name)
|
75
|
+
end
|
76
|
+
|
77
|
+
def update_report(report, account = nil)
|
78
|
+
reply(:empty, :accounts) +
|
79
|
+
reply(:update, :name => report.name) +
|
80
|
+
reply(:update, :accounts => report.listp_accounts) +
|
81
|
+
reply(:update, :accounts => (account.class == ReportAccount) ?
|
82
|
+
[account.id] : nil)
|
83
|
+
end
|
84
|
+
|
85
|
+
def rpc_update(session)
|
86
|
+
td = Date.today
|
87
|
+
# Start in beginning of semester
|
88
|
+
start = Date.new(td.year, (td.month / 7.0).floor * 6 + 1)
|
89
|
+
update_reports +
|
90
|
+
reply(:update, :start => start.to_web) +
|
91
|
+
reply(:update, :months => 6) +
|
92
|
+
reply_print(session)
|
93
|
+
end
|
94
|
+
|
95
|
+
def button_account(session, name, data)
|
96
|
+
return if data._reports == []
|
97
|
+
|
98
|
+
case name
|
99
|
+
when /add_win/
|
100
|
+
data._reports.accounts = data._reports.accounts +
|
101
|
+
[ReportAccounts.create(data)]
|
102
|
+
update_report(data._reports) +
|
103
|
+
reply(:window_hide)
|
104
|
+
when /add/
|
105
|
+
reply(:window_show, :win_account) +
|
106
|
+
update_account +
|
107
|
+
update_root +
|
108
|
+
reply(:update, :level => "1") +
|
109
|
+
reply_show_hide(:account_add_win, :account_save_win)
|
110
|
+
when /del/
|
111
|
+
return if data._accounts == []
|
112
|
+
data._reports.accounts = data._reports.accounts.reject { |a|
|
113
|
+
a == data._accounts
|
114
|
+
}
|
115
|
+
update_report(data._reports)
|
116
|
+
when /edit/
|
117
|
+
return if data._accounts == []
|
118
|
+
reply(:window_show, :win_account) +
|
119
|
+
update_root(data._accounts.root) +
|
120
|
+
update_account(data._accounts.root, data._accounts.account) +
|
121
|
+
reply(:update, :level => data._accounts.level) +
|
122
|
+
reply_show_hide(:account_save_win, :account_add_win)
|
123
|
+
when /save_win/
|
124
|
+
data._accounts.data_set_hash(data)
|
125
|
+
update_report(data._reports) +
|
126
|
+
reply(:window_hide)
|
127
|
+
when /up/
|
128
|
+
accs = data._reports.accounts
|
129
|
+
if (index = accs.index(data._accounts)) > 0
|
130
|
+
accs[index - 1], accs[index] = accs[index], accs[index - 1]
|
131
|
+
end
|
132
|
+
data._reports.accounts = accs
|
133
|
+
update_report(data._reports, data._accounts)
|
134
|
+
when /down/
|
135
|
+
accs = data._reports.accounts
|
136
|
+
if (index = accs.index(data._accounts)) < accs.length - 1
|
137
|
+
accs[index + 1], accs[index] = accs[index], accs[index + 1]
|
138
|
+
end
|
139
|
+
data._reports.accounts = accs
|
140
|
+
update_report(data._reports, data._accounts)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def button_report(session, name, data)
|
145
|
+
case name
|
146
|
+
when /add_win/
|
147
|
+
if data._report_name.to_s.length > 0
|
148
|
+
Reports.create(:name => data._report_name, :accounts => [])
|
149
|
+
end
|
150
|
+
reply(:window_hide) +
|
151
|
+
update_reports
|
152
|
+
when /add/
|
153
|
+
reply(:window_show, :win_report) +
|
154
|
+
reply(:empty, :report_name)
|
155
|
+
when /del/
|
156
|
+
data._reports != [] and data._reports.delete
|
157
|
+
rpc_update(session)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def rpc_button(session, name, data)
|
162
|
+
case name
|
163
|
+
when /^account_(.*)/
|
164
|
+
button_account(session, $~[1], data)
|
165
|
+
when /^report_(.*)/
|
166
|
+
button_report(session, $~[1], data)
|
167
|
+
when /print/
|
168
|
+
if data._reports.class == Report
|
169
|
+
start_thread(session, data)
|
170
|
+
reply(:auto_update, -1) +
|
171
|
+
reply(:update, progress_txt: 'Starting checking') +
|
172
|
+
reply(:window_show, :progress) +
|
173
|
+
rpc_print(session, :print, data)
|
174
|
+
end
|
175
|
+
when /close/
|
176
|
+
reply(:window_hide)
|
177
|
+
when /report_cancel/
|
178
|
+
dputs(2){ "Killing thread #{session.s_data._report_ce_thread}"}
|
179
|
+
if thr = session.s_data._report_ce_thread
|
180
|
+
thr.kill
|
181
|
+
end
|
182
|
+
reply(:window_hide) +
|
183
|
+
reply(:auto_update, 0)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def start_thread(session, data)
|
188
|
+
session.s_data._report_ce = nil
|
189
|
+
session.s_data._report_ce_thread = Thread.start {
|
190
|
+
System.rescue_all do
|
191
|
+
session.s_data._report_ce = data._reports.print_pdf_monthly(
|
192
|
+
Date.from_web(data._start), data._months.to_i)
|
193
|
+
end
|
194
|
+
dputs(2){ 'Thread finished'}
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
def rpc_update_with_values(session, data)
|
199
|
+
report = data._reports
|
200
|
+
if report_ce = session.s_data._report_ce
|
201
|
+
return reply(:window_hide) +
|
202
|
+
reply(:auto_update, 0) +
|
203
|
+
send_printer_reply(session, :print, data, report_ce)
|
204
|
+
else
|
205
|
+
return reply(:update, :progress_txt =>
|
206
|
+
"Accounts done: #{(report.print_accounts * 100).floor}%<br>" +
|
207
|
+
"Calculating: #{report.print_account}")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def rpc_list_choice_reports(session, data)
|
212
|
+
return if data._reports == []
|
213
|
+
reply(:empty, :accounts) +
|
214
|
+
update_report(data._reports)
|
215
|
+
end
|
216
|
+
|
217
|
+
def rpc_list_choice_root(session, data)
|
218
|
+
return if data._root == []
|
219
|
+
update_account(data._root)
|
220
|
+
end
|
221
|
+
end
|