pacioli 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/lib/pacioli/party.rb CHANGED
@@ -30,9 +30,9 @@ module Pacioli
30
30
 
31
31
  def balance_at(date=Time.now, t_id=nil)
32
32
  if t_id.nil?
33
- debits.before(date).sum(&:amount) - credits.before(date).sum(&:amount)
33
+ debits.before(date.end_of_day).sum(&:amount) - credits.before(date.end_of_day).sum(&:amount)
34
34
  else
35
- debits.before(date).sum(&:amount) - credits.before(date).sum(&:amount)
35
+ debits.before(date.end_of_day).sum(&:amount) - credits.before(date.end_of_day).sum(&:amount)
36
36
  end
37
37
  end
38
38
 
@@ -41,10 +41,13 @@ module Pacioli
41
41
 
42
42
  temp_array = []
43
43
 
44
- temp_array << {description: "Opening Balance", date: start_date, credit_amount: "", debit_amount: "", balance: balance_at(start_date)}
44
+ opening_balance = debits.before(start_date.beginning_of_day).sum(&:amount) - credits.before(start_date.beginning_of_day).sum(&:amount)
45
+
46
+ temp_array << {description: "Opening Balance", date: start_date, credit_amount: "", debit_amount: "", balance: opening_balance}
45
47
 
46
48
  #temp_array << transactions.between(start_date, end_date).map(&:to_hash)
47
- running_balance = balance_at(start_date)
49
+ #running_balance = balance_at(start_date)
50
+ running_balance = opening_balance
48
51
 
49
52
  temp_array << transactions.between(start_date, end_date).map do |transaction|
50
53
  if (!transaction.journal_entry.source_documentable.blank?) && (transaction.journal_entry.source_documentable.respond_to?(:to_s))
@@ -5,7 +5,8 @@ module Pacioli
5
5
  belongs_to :party, foreign_key: :pacioli_party_id
6
6
 
7
7
  def self.before(date=Time.now)
8
- where("dated < :q", q: date.to_time.end_of_day)
8
+ #where("dated < :q", q: date.to_time.end_of_day)
9
+ where("dated < :q", q: date.to_time)
9
10
  end
10
11
 
11
12
  def self.between(start_date, end_date)
@@ -1,3 +1,3 @@
1
1
  module Pacioli
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 22
9
- version: 0.0.22
8
+ - 23
9
+ version: 0.0.23
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeffrey van Aswegen
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
- hash: -2494798010326809980
146
+ hash: -4175151152447961544
147
147
  segments:
148
148
  - 0
149
149
  version: "0"
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- hash: -2494798010326809980
155
+ hash: -4175151152447961544
156
156
  segments:
157
157
  - 0
158
158
  version: "0"