bean_sprout 0.0.7 → 0.0.8
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/bean_sprout/ledger.rb +18 -6
- data/lib/bean_sprout/version.rb +1 -1
- 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: f0c296f0544c8cc79cd02755c6f56f24707fec21
|
4
|
+
data.tar.gz: 4697a8ecd50d231262c809febd4624fe985d814c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f14e1a8a7e8dcdc68e70e379395859bf63a6dee8aa936eb8ed611a605345c5db59d6593b526516cbf8803a7c7b6c4ffc2e8c5bd2ace07f93994a5954a73225
|
7
|
+
data.tar.gz: 8fee22de7310d99c6e9e15ab64add0a3093fabb116a59eb0403007262f6ed5a91a8c31ad6fb6fb759313b3e79e426231e066ab22bc43564a596b65c95ae2b24b
|
data/lib/bean_sprout/ledger.rb
CHANGED
@@ -13,7 +13,9 @@ module BeanSprout
|
|
13
13
|
@beans = SparseArray.new
|
14
14
|
@sprout_bunches = SparseArray.new
|
15
15
|
@sprouts = SparseArray.new
|
16
|
-
@
|
16
|
+
@forex_accounts = {}
|
17
|
+
@income_accounts = {}
|
18
|
+
@expense_accounts = {}
|
17
19
|
end
|
18
20
|
|
19
21
|
def create_account currency, other_data: nil
|
@@ -54,9 +56,9 @@ module BeanSprout
|
|
54
56
|
|
55
57
|
def forex_transfer from_acc, to_acc, from_amount, to_amount, other_data: nil
|
56
58
|
entry0 = create_entry from_acc, -from_amount
|
57
|
-
entry1 = create_entry (
|
59
|
+
entry1 = create_entry (forex_account from_acc.currency), from_amount
|
58
60
|
entry2 = create_entry to_acc, to_amount
|
59
|
-
entry3 = create_entry (
|
61
|
+
entry3 = create_entry (forex_account to_acc.currency), -to_amount
|
60
62
|
commit_entries [entry0, entry1, entry2, entry3], other_data
|
61
63
|
end
|
62
64
|
|
@@ -92,10 +94,20 @@ module BeanSprout
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
|
-
def
|
97
|
+
def forex_account currency = nil
|
96
98
|
currency ||= @base_currency
|
97
|
-
acc = create_account currency, other_data: "This is a
|
98
|
-
@
|
99
|
+
acc = create_account currency, other_data: "This is a forex account for #{currency}."
|
100
|
+
@forex_accounts[currency] ||= acc
|
101
|
+
end
|
102
|
+
|
103
|
+
def income_account currency = nil
|
104
|
+
currency ||= @base_currency
|
105
|
+
@income_accounts[currency] ||= create_account currency, other_data: "This is an income account for #{currency}."
|
106
|
+
end
|
107
|
+
|
108
|
+
def expense_account currency = nil
|
109
|
+
currency ||= @base_currency
|
110
|
+
@expense_accounts[currency] ||= create_account currency, other_data: "This is an expense account for #{currency}."
|
99
111
|
end
|
100
112
|
|
101
113
|
private
|
data/lib/bean_sprout/version.rb
CHANGED