africompta 1.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/Test/ac_big.rb ADDED
@@ -0,0 +1,62 @@
1
+ require 'test/unit'
2
+
3
+ TESTBIG=false
4
+
5
+ class TC_Big < Test::Unit::TestCase
6
+ def setup
7
+ setup_db
8
+ end
9
+
10
+ def teardown
11
+ Entities.save_all
12
+ end
13
+
14
+ def setup_db
15
+ dputs_func
16
+ dputs(1) { 'Setting up big data' }
17
+ Entities.delete_all_data()
18
+
19
+ dputs(2) { 'Resetting SQLite' }
20
+ SQLite.dbs_close_all
21
+ dputs(2) { 'Loading big data' }
22
+ MigrationVersions.create({:class_name => 'Account', :version => 2})
23
+ MigrationVersions.create({:class_name => 'Movement', :version => 1})
24
+ MigrationVersions.save
25
+ FileUtils.cp('db.man', 'data/compta.db')
26
+ SQLite.dbs_open_load_migrate
27
+ dputs(2) { 'Finished loading' }
28
+ Entities.save_all
29
+ @user = Users.match_by_name('local')
30
+ end
31
+
32
+ def reload_all
33
+ Entities.delete_all_data(true)
34
+ Entities.load_all
35
+ end
36
+
37
+ def test_matches_speed_improved
38
+ dputs_func
39
+ require 'benchmark'
40
+
41
+ ret = ''
42
+ dputs(1){ @user.account_index}
43
+ dputs(1) { Benchmark.measure {
44
+ ret = Accounts.data.select { |k, v|
45
+ v._rev_index > 14000 }.
46
+ collect { |k, v| Accounts.get_data_instance(k) }.
47
+ sort_by { |a| a.path }.reverse.
48
+ collect { |a| a.to_s }.
49
+ join("\n")
50
+ }.to_s
51
+ }
52
+ dputs(1){ ret.length}
53
+ end
54
+
55
+ def test_matches_speed_old
56
+ dputs_func
57
+ dputs(1) { Benchmark.measure {
58
+ ACaccess.accounts_fetch(@user)
59
+ }.to_s
60
+ }
61
+ end
62
+ end
@@ -0,0 +1,59 @@
1
+ require 'test/unit'
2
+
3
+ class TC_Movement < Test::Unit::TestCase
4
+ def setup
5
+ dputs(1) { 'Setting up new data' }
6
+ Entities.delete_all_data()
7
+
8
+ dputs(2) { 'Resetting SQLite' }
9
+ SQLite.dbs_close_all
10
+ FileUtils.cp('db.testGestion', 'data/compta.db')
11
+ SQLite.dbs_open_load_migrate
12
+
13
+ dputs(2) { 'And searching for some accounts' }
14
+ @root = Accounts.match_by_name('Root')
15
+ @cash = Accounts.match_by_name('Cash')
16
+ @lending = Accounts.match_by_name('Lending')
17
+ @income = Accounts.match_by_name('Income')
18
+ @outcome = Accounts.match_by_name('Outcome')
19
+ @local = Users.match_by_name('local')
20
+
21
+ @user_1 = Users.create('user1', '', 'pass')
22
+ @user_2 = Users.create('user2', '', 'pass')
23
+ end
24
+
25
+ def teardown
26
+ end
27
+
28
+ def test_move
29
+ value_cash = @cash.total.to_f
30
+ value_lending = @lending.total.to_f
31
+ value_income = @income.total.to_f
32
+ m = Movements.create('test', Date.today, 1000, @cash, @lending)
33
+ assert_equal @cash, m.account_src
34
+ assert_equal @lending, m.account_dst
35
+ assert_equal value_cash + 1000, @cash.total.to_f
36
+ assert_equal value_lending - 1000, @lending.total.to_f
37
+
38
+ m.move_from_to(@cash, @income)
39
+ assert_equal @income, m.account_src
40
+ assert_equal @lending, m.account_dst
41
+ assert_equal value_cash, @cash.total.to_f
42
+ assert_equal value_income - 1000, @income.total.to_f
43
+ assert_equal value_lending - 1000, @lending.total.to_f
44
+
45
+ m.move_from_to(@lending, @cash)
46
+ assert_equal @income, m.account_src
47
+ assert_equal @cash, m.account_dst
48
+ assert_equal value_cash - 1000, @cash.total.to_f
49
+ assert_equal value_income - 1000, @income.total.to_f
50
+ assert_equal value_lending, @lending.total.to_f
51
+ end
52
+
53
+ def test_search_index
54
+ res = Movements.search_index_range(2, 3)
55
+ assert_equal 2, res.length
56
+ assert_equal Movement, res.first.class
57
+ assert_equal [2, 3], res.map { |m| m.rev_index }
58
+ end
59
+ end
data/Test/ac_sqlite.rb ADDED
@@ -0,0 +1,139 @@
1
+ require 'test/unit'
2
+ require 'sqlite3'
3
+
4
+ class TC_SQLite < Test::Unit::TestCase
5
+ def setup
6
+ Entities.delete_all_data()
7
+ SQLite.dbs_close_all
8
+ FileUtils.cp('db.testGestion', 'data/compta.db')
9
+ SQLite.dbs_open_load_migrate
10
+
11
+ dputs(2) { 'And searching for some accounts' }
12
+ @root = Accounts.match_by_name('Root')
13
+ @cash = Accounts.match_by_name('Cash')
14
+ @lending = Accounts.match_by_name('Lending')
15
+ @income = Accounts.match_by_name('Income')
16
+ @outcome = Accounts.match_by_name('Outcome')
17
+ @local = Users.match_by_name('local')
18
+
19
+ @user_1 = Users.create('user1', '', 'pass')
20
+ @user_2 = Users.create('user2', '', 'pass')
21
+ end
22
+
23
+ def teardown
24
+ end
25
+
26
+ def test_check_accounts
27
+ Entities.delete_all_data
28
+ Entities.load_all
29
+
30
+ tmpfile = '/tmp/compta.db'
31
+ tmpfile2 = '/tmp/compta2.db'
32
+
33
+ FileUtils.cp('data/compta.db', tmpfile)
34
+ in_db, diff, in_local = Accounts.check_against_db(tmpfile)
35
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
36
+ assert_equal [], in_db
37
+ assert_equal [], diff
38
+ assert_equal [], in_local
39
+
40
+ Accounts.create('Services', '', Accounts.match_by_name('Income'))
41
+ in_db, diff, in_local = Accounts.check_against_db(tmpfile)
42
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
43
+ assert_equal [], in_db
44
+ assert_equal [], diff
45
+ assert_equal Accounts.match_by_name('Services').to_s.to_a,
46
+ in_local
47
+
48
+ Accounts.save
49
+ FileUtils.cp('data/compta.db', tmpfile2)
50
+ Accounts.match_by_name('Lending').name = 'Prêts'
51
+ in_db, diff, in_local = Accounts.check_against_db(tmpfile2)
52
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
53
+ assert_equal [], in_db
54
+ assert_equal 1, diff.length
55
+ assert_equal [], in_local
56
+
57
+ Accounts.delete_all
58
+ Accounts.storage[:SQLiteAC].close_db
59
+ FileUtils.cp(tmpfile, 'data/compta.db')
60
+ SQLite.dbs_open_load_migrate
61
+ in_db, diff, in_local = Accounts.check_against_db(tmpfile2)
62
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
63
+ assert_equal [Accounts.create('Services', '', Accounts.match_by_name('Income')).to_s],
64
+ in_db
65
+ assert_equal 0, diff.length
66
+ assert_equal [], in_local
67
+ end
68
+
69
+ def add_mov(desc, value, src, dst)
70
+ Movements.create(desc, Date.today, value.to_f,
71
+ Accounts.match_by_name(src), Accounts.match_by_name(dst))
72
+ end
73
+
74
+ def add_movements
75
+ [
76
+ %w( Income Cash course1 10),
77
+ %w( Income Cash course2 20),
78
+ %w( Income Cash course3 30),
79
+ %w( Cash Outcome salary1 25),
80
+ %w( Cash Outcome salary2 15),
81
+ ].each { |src, dst, desc, value|
82
+ add_mov desc, value, src, dst
83
+ }
84
+ end
85
+
86
+ def test_check_movements
87
+ Entities.delete_all_data()
88
+ Entities.load_all
89
+
90
+ add_movements
91
+ Movements.save
92
+ tmpfile = '/tmp/compta.db'
93
+ tmpfile2 = '/tmp/compta2.db'
94
+
95
+ FileUtils.cp('data/compta.db', tmpfile)
96
+ in_db, diff, in_local = Movements.check_against_db(tmpfile)
97
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
98
+ assert_equal [], in_db
99
+ assert_equal [], diff
100
+ assert_equal [], in_local
101
+
102
+ add_mov 'Services', 20, 'Income', 'Cash'
103
+ in_db, diff, in_local = Movements.check_against_db(tmpfile)
104
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
105
+ assert_equal [], in_db
106
+ assert_equal [], diff
107
+ assert_equal Movements.match_by_desc('Services').to_s.to_a,
108
+ in_local
109
+
110
+ add_mov 'Services2', 20, 'Income', 'Cash'
111
+ Movements.match_by_desc('Services2').delete
112
+ Movements.save
113
+ FileUtils.cp('data/compta.db', tmpfile2)
114
+ in_db, diff, in_local = Movements.check_against_db(tmpfile2)
115
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
116
+ assert_equal [], in_db
117
+ assert_equal [], diff
118
+ assert_equal [], in_local
119
+
120
+ Movements.save
121
+ FileUtils.cp('data/compta.db', tmpfile2)
122
+ Movements.match_by_desc('Services').desc = 'Prêts'
123
+ in_db, diff, in_local = Movements.check_against_db(tmpfile2)
124
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
125
+ assert_equal [], in_db
126
+ assert_equal 1, diff.length
127
+ assert_equal [], in_local
128
+
129
+ Movements.delete_all
130
+ Movements.storage[:SQLiteAC].close_db
131
+ FileUtils.cp(tmpfile, 'data/compta.db')
132
+ SQLite.dbs_open_load_migrate
133
+ in_db, diff, in_local = Movements.check_against_db(tmpfile2)
134
+ dputs(3) { "#{in_db.inspect}\n#{diff.inspect}\n#{in_local.inspect}" }
135
+ assert_equal [add_mov('Services', 20, 'Income', 'Cash').to_s], in_db
136
+ assert_equal 0, diff.length
137
+ assert_equal [], in_local
138
+ end
139
+ end
@@ -0,0 +1,31 @@
1
+ StorageType:
2
+ CSV:
3
+ csv_dir: ./data2/
4
+
5
+ #autologin: linus
6
+ #autologin: admin
7
+
8
+ title: "Gestion du Markas-al-Nour"
9
+
10
+ log: events.log
11
+
12
+ compta_due:
13
+ host: "http://localhost:3301"
14
+ user: "gestion"
15
+ pass: "gestion777"
16
+ src: "Emprunts::"
17
+ dst: "Entrés"
18
+
19
+ StorageHandler:
20
+ Replace:
21
+ LDAP: CSV
22
+
23
+ AfriCompta:
24
+ disabled: true
25
+
26
+ DiplomaDir: Diplomas
27
+
28
+ Entities:
29
+ LogActions:
30
+ logging: false
31
+
Binary file
data/Test/test.rb ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ ##!/usr/local/bin/ruby -I.
3
+ ##!/usr/bin/ruby -I.. -I../../QooxView -I../../AfriCompta -I../../LibNet -I. -wKU
4
+ %w( QooxView AfriCompta HelperClasses/lib ).each{|l|
5
+ $LOAD_PATH.push "../../#{l}"
6
+ }
7
+ $LOAD_PATH.push '.'
8
+
9
+ require 'test/unit'
10
+ require 'fileutils'
11
+
12
+ FileUtils.rm_rf('data/')
13
+ FileUtils.rm_rf('data2/')
14
+
15
+ CONFIG_FILE='config_test.yaml'
16
+ DEBUG_LVL=0
17
+
18
+ require 'QooxView'
19
+ require 'ACQooxView'
20
+ require 'ACaccess'
21
+
22
+ Permission.add( 'default', 'View,Welcome' )
23
+ Permission.add( 'admin', '.*', '.*' )
24
+ Permission.add( 'internet', 'Internet,PersonShow', 'default' )
25
+ Permission.add( 'student', '', 'internet' )
26
+ Permission.add( 'professor', '', 'student' )
27
+ Permission.add( 'secretary', 'PersonModify', 'professor' )
28
+
29
+ qooxView = QooxView.init( '../Entities', '../Views' )
30
+
31
+ tests = %w( africompta account movement sqlite )
32
+ #tests = %w( africompta )
33
+ #tests = %w( sqlite )
34
+ #tests = %w( big )
35
+ tests.each{|t|
36
+ require "ac_#{t}"
37
+ }
38
+
39
+ # Fails test_archive_sum_up
data/VERSION ADDED
@@ -0,0 +1,140 @@
1
+ Sometime
2
+ + Change the movement/list-description field so it automatically
3
+ takes the optimum width... Javascript-magic...
4
+ + Put money from multiple into multiple accounts, but only once into any
5
+ tree!
6
+ + UNDO
7
+
8
+ ? - 1.3
9
+ + Present transactions
10
+ ? - 1.2
11
+ + Interface for Josue
12
+ ? - 1.1
13
+ + Better user-authentification
14
+ + Jobs for users
15
+ + Open / close trees in account-view
16
+ + Good <titles>
17
+
18
+ 130227 - 1.0.1
19
+ + Added interface for QooxView-Entities
20
+ + Use JSON instead of to_s and from_s -> take care about id's of
21
+ the objects...
22
+ + lots of changes in account-handling
23
+ + Fixed bugs
24
+ + added possibility to show archives
25
+ + cleaned up front-interface
26
+ + Archive accounts and movements and hide them
27
+ + Delete accounts and merge them
28
+ + add "status" field with bits
29
+ 100421 - 0.9.8
30
+ + added a movements_put to the code, so that a lot of movements don't
31
+ block the server
32
+ + removed several errors
33
+ 090601 - 0.9.7
34
+ + Deleted the menu for chosing accounts, too slow
35
+ 090519 - 0.9.6
36
+ + add menu for chosing accoun - it's slow, very slow!t
37
+ + translation to french
38
+ + Test for bad movements in own menu
39
+ + merged report_c and report_a
40
+ + Debug-level on 1
41
+ + ledger - "grand livre" - first try
42
+ 081103 - 0.9.5
43
+ + Fixed "changed"-method for ActiveRecord 2.1.x
44
+ + Fixed wrong starting account in "report"-view
45
+ 081028 - 0.9.4
46
+ + Speed up merge
47
+ - Accounts and Movements get a changed "revision":
48
+ it is a global (one for Accounts and one for Movements)
49
+ counter that increases steadily. If something is changed,
50
+ the counter gets increased by one.
51
+ Remote.account_index and Remote.movement_index point to the
52
+ last Account and Movement transferred, while
53
+ User.account_index and User.movement_index do the same on
54
+ the server side
55
+ User('local').account_index and User('local').movement_index
56
+ point to the actual index used in the local database
57
+ 081009 - 0.9.3
58
+ * account-edit: only propagate multiplier if changed
59
+ * Only show range of time in accounts
60
+ * Insert checkboxes on movements and allow moving/deleting
61
+ 080717 - 0.9.2
62
+ * Merging works again when root-account is not id==0
63
+ * Cleanup "bypass_markaby" in movement.rb::movement_list
64
+ 080514 - 0.9.1
65
+ * Speed up movement-listing (wget: 3.0s -> 0.95s)
66
+ * Kick account-listing with totals and replace with a
67
+ combobox
68
+ * Fix delete movement (still shown till next update)
69
+ * Report: Add all sub-accounts in the total of each month,
70
+ including the name of the direct child
71
+ 080221 - 0.9
72
+ * Throw away user-restriction on accounts -
73
+ has to be re-evaluated in version 1.1
74
+ * Sort accounts alphabetically in lists
75
+ * Multiplier for accounts: +1 or -1
76
+ * When adding account, take multiplier of parent
77
+ account
78
+ * Keep last account in "new movement"
79
+ * Monthly and yearly sums
80
+ * Speed: setting multipliers in merge-mode doesn't need to go
81
+ recursif!
82
+ 080213 - 0.8.5
83
+ * Merge accounts
84
+ * Put a revision in the accounts, so they
85
+ can be changed, too
86
+ * Allow for accounts to be merged back and
87
+ forth
88
+ 080212 - 0.8.4
89
+ * Merge transactions
90
+ * If both change the transaction, the one
91
+ who does the second merge looses!
92
+ * Only negativ revisions are to be sent,
93
+ not revision == 0!
94
+ * Movement
95
+ * /movement/list needs to take into account
96
+ the $ of the sub-accounts
97
+ * Interface
98
+ * More nice interface
99
+ 080201 - 0.8.3
100
+ * Merge transactions
101
+ * Deleted transactions (value == 0)
102
+ 080130 - 0.8.2
103
+ * Merge transactions
104
+ * Movements get the global_id of the accounts
105
+ * Fix the problem of who's older... or newer, btw.
106
+ using a "version"-string
107
+ * Only send new movements to the other side
108
+ 080120 - 0.8.1
109
+ * Movements
110
+ * Editing, Deleting
111
+ 080119 - 0.8
112
+ * Add movements
113
+ * Date, Amount, src, dst
114
+ * Adding
115
+ 080116 - 0.7.1
116
+ * sync to a remote repository
117
+ * Check for authentification
118
+ * Add and update accounts
119
+ * added user "local" with random-md5-hashed string
120
+ for unique representation of database
121
+ * user "local" is not shown for editing
122
+ * added unique account-ids Account.global_id based
123
+ on the user "local"
124
+ * create global_id only upon creation of Account
125
+ and not when editing
126
+ * Verify account-viewing when root-account is missing
127
+ 080114 - 0.7
128
+ * Add remote repositories
129
+ 080109 - 0.6
130
+ * Users
131
+ * Users and Accounts
132
+ * Users have passwords
133
+ * Accounts has_and_belongs_to_many Users
134
+ * Edit of Users
135
+ * Accounts
136
+ * Edit of Users
137
+ * General cleaning up
138
+ 080105 - 0.5
139
+ * Accounts work:
140
+ * It's possible to list, add and delete
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'africompta'
3
+ s.version = '1.9.8'
4
+ s.date = '2015-05-13'
5
+ s.summary = 'Africompta-module for QooxView'
6
+ s.description = 'With this module you can have a simple accounting-system'
7
+ s.authors = ['Linus Gasser']
8
+ s.email = 'ineiti@linusetviviane.ch'
9
+
10
+ s.files = `git ls-files -z`.split("\x0")
11
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
12
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
13
+ s.require_paths = ['lib']
14
+
15
+ s.homepage =
16
+ 'https://github.com/ineiti/AfriCompta'
17
+ s.license = 'GPLv3'
18
+
19
+ s.add_dependency 'qooxview'
20
+ end