has_accounts 0.7.0 → 0.7.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.
@@ -13,9 +13,16 @@ module HasAccounts
13
13
  direct_account ||= proxy_owner.direct_account
14
14
  balance = BigDecimal.new('0')
15
15
 
16
- direct_bookings = scoped
17
- direct_bookings = direct_bookings.where("date(value_date) <= ?", value_date) if value_date
16
+ # Scope by value_date
17
+ if value_date.is_a? Range or value_date.is_a? Array
18
+ direct_bookings = where("date(value_date) BETWEEN :from AND :to", :from => value_date.first, :to => value_date.last)
19
+ elsif value_date
20
+ direct_bookings = where("date(value_date) <= ?", value_date) if value_date
21
+ else
22
+ direct_bookings = scoped
23
+ end
18
24
 
25
+ # Accumulate
19
26
  for booking in direct_bookings.all
20
27
  balance += booking.accounted_amount(direct_account)
21
28
  end
@@ -14,7 +14,7 @@ module HasAccounts
14
14
  balance = BigDecimal.new('0')
15
15
 
16
16
  direct_bookings = scoped
17
- direct_bookings = direct_bookings.where("value_date <= ?", value_date) if value_date
17
+ direct_bookings = direct_bookings.where("date(value_date) <= ?", value_date) if value_date
18
18
 
19
19
  for booking in direct_bookings.all
20
20
  balance += booking.accounted_amount(direct_account)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Simon H\xC3\xBCrlimann (CyT)"