financial 0.0.1
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.
- data/.gitignore +4 -0
- data/.infinity_test +16 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +74 -0
- data/README.markdown +157 -0
- data/Rakefile +1 -0
- data/duck_tales.gif +0 -0
- data/example.png +0 -0
- data/examples/two_accounts.rb +32 -0
- data/features/portuguese_dsl.feature +93 -0
- data/features/print_financial_table.feature +318 -0
- data/features/support/env.rb +1 -0
- data/financial.gemspec +22 -0
- data/lib/financial.rb +39 -0
- data/lib/financial/account.rb +129 -0
- data/lib/financial/account_manager.rb +26 -0
- data/lib/financial/balance.rb +11 -0
- data/lib/financial/balance_calculation.rb +35 -0
- data/lib/financial/cost.rb +34 -0
- data/lib/financial/costs.rb +30 -0
- data/lib/financial/deposit.rb +30 -0
- data/lib/financial/deposits.rb +15 -0
- data/lib/financial/dsl.rb +16 -0
- data/lib/financial/financial_date.rb +18 -0
- data/lib/financial/financial_table.rb +109 -0
- data/lib/financial/locale.rb +153 -0
- data/lib/financial/locales/en.yml +34 -0
- data/lib/financial/locales/pt.yml +67 -0
- data/lib/financial/parcels.rb +87 -0
- data/lib/financial/per_cent.rb +12 -0
- data/lib/financial/print_table.rb +34 -0
- data/lib/financial/revenue.rb +40 -0
- data/lib/financial/revenues.rb +16 -0
- data/lib/financial/rspec_matchers.rb +32 -0
- data/lib/financial/tax.rb +4 -0
- data/lib/financial/version.rb +3 -0
- data/spec/financial/account_manager_spec.rb +38 -0
- data/spec/financial/account_spec.rb +399 -0
- data/spec/financial/balance_spec.rb +44 -0
- data/spec/financial/cost_spec.rb +78 -0
- data/spec/financial/costs_spec.rb +18 -0
- data/spec/financial/deposit_spec.rb +78 -0
- data/spec/financial/deposits_spec.rb +23 -0
- data/spec/financial/english_spec.rb +76 -0
- data/spec/financial/financial_date_spec.rb +50 -0
- data/spec/financial/financial_spec.rb +14 -0
- data/spec/financial/financial_table_spec.rb +31 -0
- data/spec/financial/locale_spec.rb +37 -0
- data/spec/financial/parcels_spec.rb +179 -0
- data/spec/financial/per_cent_spec.rb +24 -0
- data/spec/financial/portuguese_spec.rb +117 -0
- data/spec/financial/print_table_spec.rb +76 -0
- data/spec/financial/revenue_spec.rb +89 -0
- data/spec/financial/revenues_spec.rb +18 -0
- data/spec/financial/tax_spec.rb +42 -0
- data/spec/spec_helper.rb +25 -0
- metadata +139 -0
data/.gitignore
ADDED
data/.infinity_test
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# InfinityTest configuration setup
|
4
|
+
# You can see more information in here:
|
5
|
+
# https://github.com/tomas-stefano/infinity_test/wiki/Customize-Infinity-Test
|
6
|
+
#
|
7
|
+
infinity_test do
|
8
|
+
# notifications :growl
|
9
|
+
# notifications :lib_notify
|
10
|
+
|
11
|
+
#
|
12
|
+
use({:test_framework=>:rspec, :verbose=>true})
|
13
|
+
|
14
|
+
|
15
|
+
ignore :folders => %w(), :files => %w()
|
16
|
+
end
|
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2@financial --create
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
source :rubygems
|
3
|
+
|
4
|
+
gem 'terminal-table', '1.4.2'
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'aruba'
|
8
|
+
gem 'cucumber'
|
9
|
+
gem 'infinity_test', :git => 'git://github.com/tomas-stefano/infinity_test.git'
|
10
|
+
gem 'rspec'
|
11
|
+
end
|
12
|
+
|
13
|
+
platform :mri_19 do
|
14
|
+
gem 'ruby-debug19', :require => false
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/tomas-stefano/infinity_test.git
|
3
|
+
revision: 33f70f29a32bafee99cd666519f8201c3a2b6e3b
|
4
|
+
specs:
|
5
|
+
infinity_test (1.0.3)
|
6
|
+
notifiers (= 1.1.0)
|
7
|
+
notifiers (>= 1.1.0)
|
8
|
+
watchr (= 0.7)
|
9
|
+
watchr (>= 0.7)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
specs:
|
14
|
+
archive-tar-minitar (0.5.2)
|
15
|
+
aruba (0.4.3)
|
16
|
+
bcat (>= 0.6.1)
|
17
|
+
childprocess (>= 0.1.9)
|
18
|
+
cucumber (>= 0.10.7)
|
19
|
+
rdiscount (>= 1.6.8)
|
20
|
+
rspec (>= 2.6.0)
|
21
|
+
bcat (0.6.1)
|
22
|
+
rack (~> 1.0)
|
23
|
+
builder (3.0.0)
|
24
|
+
childprocess (0.1.9)
|
25
|
+
ffi (~> 1.0.6)
|
26
|
+
columnize (0.3.3)
|
27
|
+
cucumber (1.0.0)
|
28
|
+
builder (>= 2.1.2)
|
29
|
+
diff-lcs (>= 1.1.2)
|
30
|
+
gherkin (~> 2.4.1)
|
31
|
+
json (>= 1.4.6)
|
32
|
+
term-ansicolor (>= 1.0.5)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
ffi (1.0.9)
|
35
|
+
gherkin (2.4.1)
|
36
|
+
json (>= 1.4.6)
|
37
|
+
json (1.5.3)
|
38
|
+
linecache19 (0.5.12)
|
39
|
+
ruby_core_source (>= 0.1.4)
|
40
|
+
notifiers (1.1.0)
|
41
|
+
rack (1.3.0)
|
42
|
+
rdiscount (1.6.8)
|
43
|
+
rspec (2.6.0)
|
44
|
+
rspec-core (~> 2.6.0)
|
45
|
+
rspec-expectations (~> 2.6.0)
|
46
|
+
rspec-mocks (~> 2.6.0)
|
47
|
+
rspec-core (2.6.4)
|
48
|
+
rspec-expectations (2.6.0)
|
49
|
+
diff-lcs (~> 1.1.2)
|
50
|
+
rspec-mocks (2.6.0)
|
51
|
+
ruby-debug-base19 (0.11.25)
|
52
|
+
columnize (>= 0.3.1)
|
53
|
+
linecache19 (>= 0.5.11)
|
54
|
+
ruby_core_source (>= 0.1.4)
|
55
|
+
ruby-debug19 (0.11.6)
|
56
|
+
columnize (>= 0.3.1)
|
57
|
+
linecache19 (>= 0.5.11)
|
58
|
+
ruby-debug-base19 (>= 0.11.19)
|
59
|
+
ruby_core_source (0.1.5)
|
60
|
+
archive-tar-minitar (>= 0.5.2)
|
61
|
+
term-ansicolor (1.0.5)
|
62
|
+
terminal-table (1.4.2)
|
63
|
+
watchr (0.7)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
aruba
|
70
|
+
cucumber
|
71
|
+
infinity_test!
|
72
|
+
rspec
|
73
|
+
ruby-debug19
|
74
|
+
terminal-table (= 1.4.2)
|
data/README.markdown
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
Financial
|
2
|
+
=========
|
3
|
+
|
4
|
+
* A simple way to organize your money and costs, dates.
|
5
|
+
Is just a table information to you know the exactly money you will have in your account.
|
6
|
+
|
7
|
+
<div style="padding:2px; border:1px solid silver; float:right; margin:0 0 1em 2em; background:white">
|
8
|
+
<img src="https://github.com/tomas-stefano/financial/raw/master/duck_tales.gif" alt="Duck Tales" />
|
9
|
+
</div>
|
10
|
+
|
11
|
+
Why?
|
12
|
+
----
|
13
|
+
|
14
|
+
* Solve my problems. Maybe this will solve yours problems.
|
15
|
+
|
16
|
+
Install
|
17
|
+
-------
|
18
|
+
|
19
|
+
gem install financial
|
20
|
+
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
|
24
|
+
require 'financial'
|
25
|
+
|
26
|
+
include Financial::DSL
|
27
|
+
include Financial::PerCent
|
28
|
+
|
29
|
+
account :my_bank_account do
|
30
|
+
total 10 # current total
|
31
|
+
|
32
|
+
costs do
|
33
|
+
a_cost(400).in_date('7/30/2011')
|
34
|
+
other_cost(500).in_date('7/31/2011')
|
35
|
+
other_other_cost(100) # will use current date if dont pass a date option
|
36
|
+
credit_card(1000)
|
37
|
+
end
|
38
|
+
|
39
|
+
revenues do # or billing do
|
40
|
+
a_revenue(300).tax(200).in_date('09/20/2011') # the profit here will be 100 and the date of the a_revenue will be today and the tax date will be '09/20/2011'
|
41
|
+
other_revenue(500).in_date('07/15/2011').tax(6.per_cent).in_date('08/20/2011')
|
42
|
+
bill(2000).tax(12.per_cent)
|
43
|
+
developing_the_site_y 1000
|
44
|
+
developing_the_other_site 900
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
**Obs**:
|
50
|
+
|
51
|
+
* **You can pass ANY NAME in the #revenues block and #costs block**
|
52
|
+
because is used **method_missing** feature.
|
53
|
+
* The **tax** method is a **cost** that will be a **multiplication**,
|
54
|
+
and the profit will be calculate like the following: 500 * 0.06 == Profit! :)
|
55
|
+
* If you wanna **subtract** the revenue use the **tax(:decreases => 200)** option,
|
56
|
+
and the profit will be calculate like that: 10 - 200
|
57
|
+
|
58
|
+
Print information in the terminal
|
59
|
+
---------------------------------
|
60
|
+
|
61
|
+
And to print the information of bank account:
|
62
|
+
|
63
|
+
print_financial_account :my_bank_account do
|
64
|
+
period :from => current_date, :to => '07/16/2011'
|
65
|
+
end
|
66
|
+
|
67
|
+
Work with more than one bank account
|
68
|
+
------------------------------------
|
69
|
+
|
70
|
+
account :other_bank do
|
71
|
+
total 30
|
72
|
+
|
73
|
+
deposits do
|
74
|
+
deposit(500).in_account(:my_bank_account) # The bank account above!
|
75
|
+
end
|
76
|
+
|
77
|
+
costs do
|
78
|
+
some_cost(500).in_date('07/20/2011')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
**OBS.:**
|
83
|
+
|
84
|
+
* You can deposit in yours accounts objects or in accounts that don't exist
|
85
|
+
* If you deposit in a existent accountant then will decreases from this account and increase in that account that exists.
|
86
|
+
|
87
|
+
If you just like to get/find the object of bank account just do:
|
88
|
+
|
89
|
+
other_bank_account = Financial::Account.where :account => :other_bank
|
90
|
+
|
91
|
+
:)
|
92
|
+
|
93
|
+
Print information of all accounts
|
94
|
+
---------------------------------
|
95
|
+
|
96
|
+
Just pass **:all** option:
|
97
|
+
|
98
|
+
print_financial_account :all do
|
99
|
+
period(current_date).to('07/16/2011')
|
100
|
+
end
|
101
|
+
|
102
|
+
More Examples
|
103
|
+
-------------
|
104
|
+
|
105
|
+
See [examples folder](https://github.com/tomas-stefano/financial/tree/master/examples)
|
106
|
+
|
107
|
+
Portuguese
|
108
|
+
----------
|
109
|
+
|
110
|
+
Is possible to have a portuguese DSL with dates, and the language itself.
|
111
|
+
|
112
|
+
Then:
|
113
|
+
|
114
|
+
require 'financial'
|
115
|
+
|
116
|
+
Financial.locale = :pt
|
117
|
+
include Financial::DSL
|
118
|
+
include Financial::PerCent
|
119
|
+
|
120
|
+
conta :minha_conta do
|
121
|
+
total 215.0
|
122
|
+
|
123
|
+
depositos do
|
124
|
+
deposite(500).na_conta(:outra_conta).na_data('20/07/2011') # will add 500 in outra_conta in the 20 July 2011
|
125
|
+
end
|
126
|
+
|
127
|
+
despesas do
|
128
|
+
contador 100
|
129
|
+
end
|
130
|
+
|
131
|
+
faturamento do
|
132
|
+
nota_fiscal(1000).na_data('25/07/2011').imposto(6.por_cento)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# imprima_conta :minha_conta do
|
137
|
+
# periodo(data_corrente).até('16/07/2011')
|
138
|
+
# end
|
139
|
+
|
140
|
+
imprima_conta :todos do
|
141
|
+
periodo(data_atual).até('16/07/2011')
|
142
|
+
end
|
143
|
+
|
144
|
+
# imprima_conta :todos do
|
145
|
+
# periodo('20/06/2011').até('16/07/2011')
|
146
|
+
# end
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
OUTPUT EXAMPLE
|
151
|
+
--------------
|
152
|
+
|
153
|
+
This is an output example from [two_accounts.rb](https://github.com/tomas-stefano/financial/blob/master/examples/two_accounts.rb)
|
154
|
+
|
155
|
+
<div style="padding:2px; border:1px solid silver; float:right; margin:0 0 1em 2em; background:white">
|
156
|
+
<img src="https://github.com/tomas-stefano/financial/raw/master/example.png" alt="Output Example" />
|
157
|
+
</div>
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/duck_tales.gif
ADDED
Binary file
|
data/example.png
ADDED
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
3
|
+
|
4
|
+
require 'financial'
|
5
|
+
include Financial::DSL
|
6
|
+
|
7
|
+
account :example do
|
8
|
+
total 1000.5
|
9
|
+
|
10
|
+
deposits do
|
11
|
+
deposit(100.5).in_account(:other_example).in_date('7/13/2011')
|
12
|
+
deposit(400).in_date('7/13/2011')
|
13
|
+
end
|
14
|
+
|
15
|
+
revenues do
|
16
|
+
salary(100).in_date('7/06/2011')
|
17
|
+
design_site(300).in_date('7/8/2011')
|
18
|
+
end
|
19
|
+
|
20
|
+
costs do
|
21
|
+
credit_card(150).in_date('7/06/2011')
|
22
|
+
notebook(250).in_date('7/9/2011')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
account :other_example do
|
27
|
+
total -100
|
28
|
+
end
|
29
|
+
|
30
|
+
print_account :all do
|
31
|
+
from('06/03/2011').to('07/16/2011')
|
32
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
Feature: Financial Portuguese dsl
|
2
|
+
In order to wrtie my code in portuguese
|
3
|
+
As a user
|
4
|
+
I want to write my dsl in portuguese to use the dates and stuff in pt
|
5
|
+
|
6
|
+
Scenario: Print with deposits in the same day and different days and receive deposits too
|
7
|
+
Given a file named "example.rb" with:
|
8
|
+
"""
|
9
|
+
# coding: utf-8
|
10
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
11
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
12
|
+
|
13
|
+
require 'financial'
|
14
|
+
Financial.locale = :pt
|
15
|
+
include Financial::DSL
|
16
|
+
|
17
|
+
conta :minha_conta do
|
18
|
+
total 1000.5
|
19
|
+
|
20
|
+
depositos do
|
21
|
+
deposite(100.5).na_conta(:outra_conta).na_data('13/7/2011')
|
22
|
+
deposite(400).na_conta(:conta_do_sobrinho).in_date('13/7/2011')
|
23
|
+
end
|
24
|
+
|
25
|
+
faturamento do
|
26
|
+
salario(100).na_data('6/7/2011')
|
27
|
+
design_site(300).na_data('8/7/2011')
|
28
|
+
end
|
29
|
+
|
30
|
+
custos do
|
31
|
+
cartao_de_credito(150).na_data('6/7/2011')
|
32
|
+
notebook(250).in_date('9/7/2011')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
conta :outra_conta do
|
37
|
+
total -100
|
38
|
+
end
|
39
|
+
|
40
|
+
imprima_conta :todas do
|
41
|
+
de('3/6/2011').até('16/7/2011')
|
42
|
+
end
|
43
|
+
|
44
|
+
"""
|
45
|
+
When I run `ruby example.rb`
|
46
|
+
Then the stdout should contain exactly:
|
47
|
+
"""
|
48
|
+
Nome da Conta: Minha conta (de: 03/06/2011, até: 16/07/2011)
|
49
|
+
+------------+-----------------------------+-----------+------------+
|
50
|
+
| Data | Nome | Valor(R$) | Total |
|
51
|
+
+------------+-----------------------------+-----------+------------+
|
52
|
+
| 03/06/2011 | Saldo Inicial | -------- | R$ 1000,50 |
|
53
|
+
+------------+-----------------------------+-----------+------------+
|
54
|
+
| 06/07/2011 | Cartao de credito | - 150,00 | |
|
55
|
+
| | Salario | + 100,00 | |
|
56
|
+
+------------+-----------------------------+-----------+------------+
|
57
|
+
| | Saldo | -------- | 950,50 |
|
58
|
+
+------------+-----------------------------+-----------+------------+
|
59
|
+
| 08/07/2011 | Design site | + 300,00 | |
|
60
|
+
+------------+-----------------------------+-----------+------------+
|
61
|
+
| | Saldo | -------- | 1250,50 |
|
62
|
+
+------------+-----------------------------+-----------+------------+
|
63
|
+
| 09/07/2011 | Notebook | - 250,00 | |
|
64
|
+
+------------+-----------------------------+-----------+------------+
|
65
|
+
| | Saldo | -------- | 1000,50 |
|
66
|
+
+------------+-----------------------------+-----------+------------+
|
67
|
+
| 13/07/2011 | Deposito: outra_conta | - 100,50 | |
|
68
|
+
| | Deposito: conta_do_sobrinho | - 400,00 | |
|
69
|
+
+------------+-----------------------------+-----------+------------+
|
70
|
+
| | Saldo | -------- | 500,00 |
|
71
|
+
+------------+-----------------------------+-----------+------------+
|
72
|
+
+------------+-----------------------------+-----------+------------+
|
73
|
+
| 16/07/2011 | Saldo Final | -------- | R$ 500,00 |
|
74
|
+
+------------+-----------------------------+-----------+------------+
|
75
|
+
|
76
|
+
Nome da Conta: Outra conta (de: 03/06/2011, até: 16/07/2011)
|
77
|
+
+------------+--------------------------------+-----------+------------+
|
78
|
+
| Data | Nome | Valor(R$) | Total |
|
79
|
+
+------------+--------------------------------+-----------+------------+
|
80
|
+
| 03/06/2011 | Saldo Inicial | -------- | R$ -100,00 |
|
81
|
+
+------------+--------------------------------+-----------+------------+
|
82
|
+
| 13/07/2011 | Deposito recebido: minha_conta | + 100,50 | |
|
83
|
+
+------------+--------------------------------+-----------+------------+
|
84
|
+
| | Saldo | -------- | 0,50 |
|
85
|
+
+------------+--------------------------------+-----------+------------+
|
86
|
+
+------------+--------------------------------+-----------+------------+
|
87
|
+
| 16/07/2011 | Saldo Final | -------- | R$ 0,50 |
|
88
|
+
+------------+--------------------------------+-----------+------------+
|
89
|
+
|
90
|
+
|
91
|
+
"""
|
92
|
+
|
93
|
+
|
@@ -0,0 +1,318 @@
|
|
1
|
+
Feature: Print Financial Table
|
2
|
+
In order to know all information of all my finances
|
3
|
+
As a user
|
4
|
+
I want to know all dates for my costs and revenues to see my profit!
|
5
|
+
|
6
|
+
@announce
|
7
|
+
Scenario: Print an empty account
|
8
|
+
Given a file named "example.rb" with:
|
9
|
+
"""
|
10
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
11
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
12
|
+
|
13
|
+
require 'financial'
|
14
|
+
include Financial::DSL
|
15
|
+
|
16
|
+
account :my_bank_account do
|
17
|
+
total 100
|
18
|
+
end
|
19
|
+
|
20
|
+
print_account :all do
|
21
|
+
from('06/03/2011').to('07/16/2011')
|
22
|
+
end
|
23
|
+
|
24
|
+
"""
|
25
|
+
When I run `ruby example.rb`
|
26
|
+
Then the stdout should contain exactly:
|
27
|
+
"""
|
28
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
29
|
+
+------------+-----------------+----------+----------+
|
30
|
+
| Date | Name | Value($) | Total |
|
31
|
+
+------------+-----------------+----------+----------+
|
32
|
+
| 06/03/2011 | Initial Balance | -------- | $ 100,00 |
|
33
|
+
+------------+-----------------+----------+----------+
|
34
|
+
+------------+-----------------+----------+----------+
|
35
|
+
| 07/16/2011 | Final Balance | -------- | $ 100,00 |
|
36
|
+
+------------+-----------------+----------+----------+
|
37
|
+
|
38
|
+
|
39
|
+
"""
|
40
|
+
|
41
|
+
@announce
|
42
|
+
Scenario: Print with costs
|
43
|
+
Given a file named "example.rb" with:
|
44
|
+
"""
|
45
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
46
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
47
|
+
|
48
|
+
require 'financial'
|
49
|
+
include Financial::DSL
|
50
|
+
|
51
|
+
account :my_bank_account do
|
52
|
+
total 100
|
53
|
+
|
54
|
+
costs do
|
55
|
+
credit_card(110).in_date '7/06/2011'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
print_account :all do
|
60
|
+
from('06/03/2011').to('07/16/2011')
|
61
|
+
end
|
62
|
+
|
63
|
+
"""
|
64
|
+
When I run `ruby example.rb`
|
65
|
+
Then the stdout should contain exactly:
|
66
|
+
"""
|
67
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
68
|
+
+------------+-----------------+----------+----------+
|
69
|
+
| Date | Name | Value($) | Total |
|
70
|
+
+------------+-----------------+----------+----------+
|
71
|
+
| 06/03/2011 | Initial Balance | -------- | $ 100,00 |
|
72
|
+
+------------+-----------------+----------+----------+
|
73
|
+
| 07/06/2011 | Credit card | - 110,00 | |
|
74
|
+
+------------+-----------------+----------+----------+
|
75
|
+
| | Balance | -------- | -10,00 |
|
76
|
+
+------------+-----------------+----------+----------+
|
77
|
+
+------------+-----------------+----------+----------+
|
78
|
+
| 07/16/2011 | Final Balance | -------- | $ -10,00 |
|
79
|
+
+------------+-----------------+----------+----------+
|
80
|
+
|
81
|
+
|
82
|
+
"""
|
83
|
+
|
84
|
+
@announce
|
85
|
+
Scenario: Print with revenues
|
86
|
+
Given a file named "example.rb" with:
|
87
|
+
"""
|
88
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
89
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
90
|
+
|
91
|
+
require 'financial'
|
92
|
+
include Financial::DSL
|
93
|
+
|
94
|
+
account :my_bank_account do
|
95
|
+
total 100
|
96
|
+
|
97
|
+
revenues do
|
98
|
+
salary(110).in_date('7/06/2011')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
print_account :all do
|
103
|
+
from('06/03/2011').to('07/16/2011')
|
104
|
+
end
|
105
|
+
|
106
|
+
"""
|
107
|
+
When I run `ruby example.rb`
|
108
|
+
Then the stdout should contain exactly:
|
109
|
+
"""
|
110
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
111
|
+
+------------+-----------------+----------+----------+
|
112
|
+
| Date | Name | Value($) | Total |
|
113
|
+
+------------+-----------------+----------+----------+
|
114
|
+
| 06/03/2011 | Initial Balance | -------- | $ 100,00 |
|
115
|
+
+------------+-----------------+----------+----------+
|
116
|
+
| 07/06/2011 | Salary | + 110,00 | |
|
117
|
+
+------------+-----------------+----------+----------+
|
118
|
+
| | Balance | -------- | 210,00 |
|
119
|
+
+------------+-----------------+----------+----------+
|
120
|
+
+------------+-----------------+----------+----------+
|
121
|
+
| 07/16/2011 | Final Balance | -------- | $ 210,00 |
|
122
|
+
+------------+-----------------+----------+----------+
|
123
|
+
|
124
|
+
|
125
|
+
"""
|
126
|
+
|
127
|
+
@announce
|
128
|
+
Scenario: Print with revenues and costs in the same day
|
129
|
+
Given a file named "example.rb" with:
|
130
|
+
"""
|
131
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
132
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
133
|
+
|
134
|
+
require 'financial'
|
135
|
+
include Financial::DSL
|
136
|
+
|
137
|
+
account :my_bank_account do
|
138
|
+
total 100
|
139
|
+
|
140
|
+
revenues do
|
141
|
+
salary(110).in_date('7/06/2011')
|
142
|
+
end
|
143
|
+
|
144
|
+
costs do
|
145
|
+
credit_card(180).in_date('7/06/2011')
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
print_account :all do
|
150
|
+
from('06/03/2011').to('07/16/2011')
|
151
|
+
end
|
152
|
+
|
153
|
+
"""
|
154
|
+
When I run `ruby example.rb`
|
155
|
+
Then the stdout should contain exactly:
|
156
|
+
"""
|
157
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
158
|
+
+------------+-----------------+----------+----------+
|
159
|
+
| Date | Name | Value($) | Total |
|
160
|
+
+------------+-----------------+----------+----------+
|
161
|
+
| 06/03/2011 | Initial Balance | -------- | $ 100,00 |
|
162
|
+
+------------+-----------------+----------+----------+
|
163
|
+
| 07/06/2011 | Credit card | - 180,00 | |
|
164
|
+
| | Salary | + 110,00 | |
|
165
|
+
+------------+-----------------+----------+----------+
|
166
|
+
| | Balance | -------- | 30,00 |
|
167
|
+
+------------+-----------------+----------+----------+
|
168
|
+
+------------+-----------------+----------+----------+
|
169
|
+
| 07/16/2011 | Final Balance | -------- | $ 30,00 |
|
170
|
+
+------------+-----------------+----------+----------+
|
171
|
+
|
172
|
+
|
173
|
+
"""
|
174
|
+
|
175
|
+
@announce
|
176
|
+
Scenario: Print with revenues and costs in the same day and different days
|
177
|
+
Given a file named "example.rb" with:
|
178
|
+
"""
|
179
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
180
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
181
|
+
|
182
|
+
require 'financial'
|
183
|
+
include Financial::DSL
|
184
|
+
|
185
|
+
account :my_bank_account do
|
186
|
+
total 1000.5
|
187
|
+
|
188
|
+
revenues do
|
189
|
+
salary(100).in_date('7/06/2011')
|
190
|
+
design_site(300).in_date('7/8/2011')
|
191
|
+
end
|
192
|
+
|
193
|
+
costs do
|
194
|
+
credit_card(150).in_date('7/06/2011')
|
195
|
+
notebook(250).in_date('7/9/2011')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
print_account :all do
|
200
|
+
from('06/03/2011').to('07/16/2011')
|
201
|
+
end
|
202
|
+
|
203
|
+
"""
|
204
|
+
When I run `ruby example.rb`
|
205
|
+
Then the stdout should contain exactly:
|
206
|
+
"""
|
207
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
208
|
+
+------------+-----------------+----------+-----------+
|
209
|
+
| Date | Name | Value($) | Total |
|
210
|
+
+------------+-----------------+----------+-----------+
|
211
|
+
| 06/03/2011 | Initial Balance | -------- | $ 1000,50 |
|
212
|
+
+------------+-----------------+----------+-----------+
|
213
|
+
| 07/06/2011 | Credit card | - 150,00 | |
|
214
|
+
| | Salary | + 100,00 | |
|
215
|
+
+------------+-----------------+----------+-----------+
|
216
|
+
| | Balance | -------- | 950,50 |
|
217
|
+
+------------+-----------------+----------+-----------+
|
218
|
+
| 07/08/2011 | Design site | + 300,00 | |
|
219
|
+
+------------+-----------------+----------+-----------+
|
220
|
+
| | Balance | -------- | 1250,50 |
|
221
|
+
+------------+-----------------+----------+-----------+
|
222
|
+
| 07/09/2011 | Notebook | - 250,00 | |
|
223
|
+
+------------+-----------------+----------+-----------+
|
224
|
+
| | Balance | -------- | 1000,50 |
|
225
|
+
+------------+-----------------+----------+-----------+
|
226
|
+
+------------+-----------------+----------+-----------+
|
227
|
+
| 07/16/2011 | Final Balance | -------- | $ 1000,50 |
|
228
|
+
+------------+-----------------+----------+-----------+
|
229
|
+
|
230
|
+
|
231
|
+
"""
|
232
|
+
|
233
|
+
@announce
|
234
|
+
Scenario: Print with deposits in the same day and different days and receive deposits too
|
235
|
+
Given a file named "example.rb" with:
|
236
|
+
"""
|
237
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
238
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
239
|
+
|
240
|
+
require 'financial'
|
241
|
+
include Financial::DSL
|
242
|
+
|
243
|
+
account :my_bank_account do
|
244
|
+
total 1000.5
|
245
|
+
|
246
|
+
deposits do
|
247
|
+
deposit(100.5).in_account(:other_bank_account).in_date('7/13/2011')
|
248
|
+
deposit(400).in_account(:inexistent_account).in_date('7/13/2011')
|
249
|
+
end
|
250
|
+
|
251
|
+
revenues do
|
252
|
+
salary(100).in_date('7/06/2011')
|
253
|
+
design_site(300).in_date('7/8/2011')
|
254
|
+
end
|
255
|
+
|
256
|
+
costs do
|
257
|
+
credit_card(150).in_date('7/06/2011')
|
258
|
+
notebook(250).in_date('7/9/2011')
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
account :other_bank_account do
|
263
|
+
total -100
|
264
|
+
end
|
265
|
+
|
266
|
+
print_account :all do
|
267
|
+
from('06/03/2011').to('07/16/2011')
|
268
|
+
end
|
269
|
+
|
270
|
+
"""
|
271
|
+
When I run `ruby example.rb`
|
272
|
+
Then the stdout should contain exactly:
|
273
|
+
"""
|
274
|
+
Account name: My bank account (from: 2011-06-03, to: 2011-07-16)
|
275
|
+
+------------+-----------------------------+----------+-----------+
|
276
|
+
| Date | Name | Value($) | Total |
|
277
|
+
+------------+-----------------------------+----------+-----------+
|
278
|
+
| 06/03/2011 | Initial Balance | -------- | $ 1000,50 |
|
279
|
+
+------------+-----------------------------+----------+-----------+
|
280
|
+
| 07/06/2011 | Credit card | - 150,00 | |
|
281
|
+
| | Salary | + 100,00 | |
|
282
|
+
+------------+-----------------------------+----------+-----------+
|
283
|
+
| | Balance | -------- | 950,50 |
|
284
|
+
+------------+-----------------------------+----------+-----------+
|
285
|
+
| 07/08/2011 | Design site | + 300,00 | |
|
286
|
+
+------------+-----------------------------+----------+-----------+
|
287
|
+
| | Balance | -------- | 1250,50 |
|
288
|
+
+------------+-----------------------------+----------+-----------+
|
289
|
+
| 07/09/2011 | Notebook | - 250,00 | |
|
290
|
+
+------------+-----------------------------+----------+-----------+
|
291
|
+
| | Balance | -------- | 1000,50 |
|
292
|
+
+------------+-----------------------------+----------+-----------+
|
293
|
+
| 07/13/2011 | Deposit: other_bank_account | - 100,50 | |
|
294
|
+
| | Deposit: inexistent_account | - 400,00 | |
|
295
|
+
+------------+-----------------------------+----------+-----------+
|
296
|
+
| | Balance | -------- | 500,00 |
|
297
|
+
+------------+-----------------------------+----------+-----------+
|
298
|
+
+------------+-----------------------------+----------+-----------+
|
299
|
+
| 07/16/2011 | Final Balance | -------- | $ 500,00 |
|
300
|
+
+------------+-----------------------------+----------+-----------+
|
301
|
+
|
302
|
+
Account name: Other bank account (from: 2011-06-03, to: 2011-07-16)
|
303
|
+
+------------+-------------------------------+----------+-----------+
|
304
|
+
| Date | Name | Value($) | Total |
|
305
|
+
+------------+-------------------------------+----------+-----------+
|
306
|
+
| 06/03/2011 | Initial Balance | -------- | $ -100,00 |
|
307
|
+
+------------+-------------------------------+----------+-----------+
|
308
|
+
| 07/13/2011 | Deposit from: my_bank_account | + 100,50 | |
|
309
|
+
+------------+-------------------------------+----------+-----------+
|
310
|
+
| | Balance | -------- | 0,50 |
|
311
|
+
+------------+-------------------------------+----------+-----------+
|
312
|
+
+------------+-------------------------------+----------+-----------+
|
313
|
+
| 07/16/2011 | Final Balance | -------- | $ 0,50 |
|
314
|
+
+------------+-------------------------------+----------+-----------+
|
315
|
+
|
316
|
+
|
317
|
+
"""
|
318
|
+
|