quickpep 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/quickpep.rb +23 -4
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b7cb104e2090fb59936478625cf3802e3cb994b22279e1ee22b973749daed1
|
4
|
+
data.tar.gz: 051e2bc9b41b8fa555a47f0af0f2a069ce472ab65a60426d7a3c7dd8f0fee88f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e8b74f36ec2486e985e9c936735d7e6394315c479b829b95de2b426abb2d477be0497e6a37241c95993d487bafbe144f796084e9de8cd9fcacf9c4fa775dc2
|
7
|
+
data.tar.gz: d17d3b85c28bc7cfc7c633927122d28ef1d5644d7d9a48f440700fb19228a656fcab5f6c2a1ae09601a56262e2fddcc58df7d7b5e1c2d6fe4ac484b283dbe16b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/quickpep.rb
CHANGED
@@ -13,9 +13,10 @@ class QuickPep
|
|
13
13
|
|
14
14
|
attr_reader :to_s
|
15
15
|
|
16
|
-
def initialize(s, balance: 0, currency: '', debug: false)
|
16
|
+
def initialize(s, balance: 0, currency: '', today: Date.today, debug: false)
|
17
17
|
|
18
18
|
@balance, @currency, @debug = balance, currency, debug
|
19
|
+
@today = today
|
19
20
|
@warnings = []
|
20
21
|
@to_s = calc_expenses(s)
|
21
22
|
|
@@ -23,9 +24,11 @@ class QuickPep
|
|
23
24
|
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
+
# options: year, month, weel, day
|
28
|
+
#
|
29
|
+
def annual_costs(perx=:year, per: perx)
|
27
30
|
|
28
|
-
|
31
|
+
rows = @date_events.map do |date, title|
|
29
32
|
|
30
33
|
amount = @h[title].amount
|
31
34
|
|
@@ -36,9 +39,25 @@ class QuickPep
|
|
36
39
|
|
37
40
|
end
|
38
41
|
|
39
|
-
a.group_by {|date,title, amount| title }\
|
42
|
+
a = rows.group_by {|date,title, amount| title }\
|
40
43
|
.map {|key, rows| [key, rows.map(&:last).sum]}.sort_by(&:last)
|
41
44
|
|
45
|
+
a.map do |title, total|
|
46
|
+
|
47
|
+
amount = case per.to_sym
|
48
|
+
when :year
|
49
|
+
total
|
50
|
+
when :month
|
51
|
+
total / (12 - @today.month)
|
52
|
+
when :week
|
53
|
+
total / (52 - @today.cweek )
|
54
|
+
when :day
|
55
|
+
total / (365 - @today.yday)
|
56
|
+
end
|
57
|
+
|
58
|
+
[title, amount.round(2)]
|
59
|
+
end
|
60
|
+
|
42
61
|
end
|
43
62
|
|
44
63
|
def warnings()
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|