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.
- data/lib/has_accounts/model.rb +9 -2
- data/lib/has_accounts/model.rb~ +1 -1
- metadata +2 -2
data/lib/has_accounts/model.rb
CHANGED
@@ -13,9 +13,16 @@ module HasAccounts
|
|
13
13
|
direct_account ||= proxy_owner.direct_account
|
14
14
|
balance = BigDecimal.new('0')
|
15
15
|
|
16
|
-
|
17
|
-
|
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
|
data/lib/has_accounts/model.rb~
CHANGED
@@ -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)
|