pacioli 0.0.17 → 0.0.18

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/lib/pacioli/party.rb CHANGED
@@ -61,5 +61,15 @@ module Pacioli
61
61
  temp_array.flatten
62
62
  end
63
63
 
64
+ def age_analysis_report
65
+ [
66
+ {description: "Present", date: Date.today, balance: balance_at(Date.today)},
67
+ {description: "30 Days", date: Date.today - 30.days, balance: balance_at(Date.today - 30.days)},
68
+ {description: "60 Days", date: Date.today - 60.days, balance: balance_at(Date.today - 60.days)},
69
+ {description: "90 Days", date: Date.today - 90.days, balance: balance_at(Date.today - 90.days)},
70
+ {description: "120 Days", date: Date.today - 120.days, balance: balance_at(Date.today - 120.days)}
71
+ ]
72
+ end
73
+
64
74
  end
65
75
  end
@@ -1,3 +1,3 @@
1
1
  module Pacioli
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
3
3
  end
@@ -83,4 +83,71 @@ describe Pacioli::Party do
83
83
  end
84
84
 
85
85
  end
86
+
87
+ context "Debtors Age Analysis Report" do
88
+ before(:each) do
89
+ debtor = @debtor
90
+
91
+ debit_entries = [
92
+ {description: "Invoice 119 for Rent #{Date.today - 22.weeks}", dated: Date.today - 22.weeks, source: debtor, amt: 5500.00, against: debtor},
93
+ {description: "Invoice 120 for Rent #{Date.today - 18.weeks}", dated: Date.today - 18.weeks, source: debtor, amt: 3000.00, against: debtor},
94
+ {description: "Invoice 121 for Rent #{Date.today - 14.weeks}", dated: Date.today - 14.weeks, source: debtor, amt: 300.00, against: debtor},
95
+ {description: "Invoice 123 for Rent #{Date.today - 12.weeks}", dated: Date.today - 12.weeks, source: debtor, amt: 10000.00, against: debtor},
96
+ {description: "Invoice 124 for Rent #{Date.today - 8.weeks}", dated: Date.today - 8.weeks, source: debtor, amt: 2000.00, against: debtor},
97
+ {description: "Invoice 125 for Rent #{Date.today - 4.weeks}", dated: Date.today - 4.weeks, source: debtor, amt: 3000.00, against: debtor},
98
+ {description: "Invoice 126 for Fee #{Date.today - 2.weeks}", dated: Date.today - 2.weeks, source: debtor, amt: 4000.00, against: debtor}
99
+ ]
100
+
101
+ credit_entries = [
102
+ {description: "PMT Received for Invoice 123 #{Date.today - 20.weeks}", dated: Date.today - 20.weeks, source: debtor, amt: 5500.00, against: debtor},
103
+ {description: "PMT Received for Invoice 123 #{Date.today - 15.weeks}", source: debtor, dated: Date.today - 15.weeks, amt: 3000.00, against: debtor},
104
+ {description: "PMT Received for Invoice 123 #{Date.today - 7.weeks}", dated: Date.today - 7.weeks, source: debtor, amt: 5000.00, against: debtor},
105
+ {description: "PMT Received for Invoice 123 #{Date.today - 3.weeks}", source: debtor, dated: Date.today - 3.weeks, amt: 2000.00, against: debtor},
106
+ ]
107
+
108
+ credit_entries.each do |credit_entry|
109
+ @company.record_journal_entry do
110
+ with_description credit_entry[:description]
111
+ with_source_document credit_entry[:source]
112
+ with_date credit_entry[:dated]
113
+
114
+ debit account: "Cash in Bank", amount: credit_entry[:amt]
115
+ credit account: "Accounts Receivable", amount: credit_entry[:amt], against_party: credit_entry[:against]
116
+ end
117
+ end
118
+
119
+ debit_entries.each do |debit_entry|
120
+ @company.record_journal_entry do
121
+ with_description debit_entry[:description]
122
+ with_source_document debit_entry[:source]
123
+ with_date debit_entry[:dated]
124
+
125
+ debit account: "Accounts Receivable", amount: debit_entry[:amt], against_party: debit_entry[:against]
126
+ credit account: "Sales", amount: debit_entry[:amt]
127
+ end
128
+ end
129
+
130
+ @age_analysis = @debtor.age_analysis_report
131
+ end
132
+
133
+ it "should have a balance of 3000.00 on 120 days" do
134
+ @age_analysis.select{|item| item[:description] == "120 Days"}.first[:balance].to_s.should == "3000.0"
135
+ end
136
+
137
+ it "should have a balance of 300.00 on 90 days" do
138
+ @age_analysis.select{|item| item[:description] == "90 Days"}.first[:balance].to_s.should == "300.0"
139
+ end
140
+
141
+ it "should have a balance of 10300.00 on 60 days" do
142
+ @age_analysis.select{|item| item[:description] == "60 Days"}.first[:balance].to_s.should == "10300.0"
143
+ end
144
+
145
+ it "should have a balance of 7300.00 on 30 days" do
146
+ @age_analysis.select{|item| item[:description] == "30 Days"}.first[:balance].to_s.should == "7300.0"
147
+ end
148
+
149
+ it "should have a balance of 12300.00 on present day" do
150
+ @age_analysis.select{|item| item[:description] == "Present"}.first[:balance].to_s.should == "12300.0"
151
+ end
152
+ end
86
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pacioli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-29 00:00:00.000000000Z
12
+ date: 2013-05-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70124552565000 !ruby/object:Gem::Requirement
16
+ requirement: &70095913730760 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70124552565000
24
+ version_requirements: *70095913730760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70124552564500 !ruby/object:Gem::Requirement
27
+ requirement: &70095913730260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70124552564500
35
+ version_requirements: *70095913730260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: i18n
38
- requirement: &70124552564080 !ruby/object:Gem::Requirement
38
+ requirement: &70095913729840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70124552564080
46
+ version_requirements: *70095913729840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: combustion
49
- requirement: &70124552563540 !ruby/object:Gem::Requirement
49
+ requirement: &70095913729300 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.3.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70124552563540
57
+ version_requirements: *70095913729300
58
58
  description: A double-entry bookkeeping system for Ruby on Rails
59
59
  email:
60
60
  - jeffmess@gmail.com