has_accounts 0.5.0 → 0.6.0
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/app/models/booking.rb +17 -0
- data/app/models/booking.rb~ +18 -1
- data/lib/has_accounts/model.rb +1 -2
- data/lib/has_accounts/model.rb~ +7 -3
- metadata +3 -3
data/app/models/booking.rb
CHANGED
@@ -155,6 +155,23 @@ class Booking < ActiveRecord::Base
|
|
155
155
|
def booking_template_id=(value)
|
156
156
|
end
|
157
157
|
|
158
|
+
# Helpers
|
159
|
+
def split(amount, params = {})
|
160
|
+
# Clone
|
161
|
+
new_booking = self.clone
|
162
|
+
|
163
|
+
# Set amount
|
164
|
+
new_booking[:amount] = amount
|
165
|
+
self.amount -= amount
|
166
|
+
|
167
|
+
# Update attributes
|
168
|
+
params.each{|key, value|
|
169
|
+
new_booking[key] = value
|
170
|
+
}
|
171
|
+
|
172
|
+
[self, new_booking]
|
173
|
+
end
|
174
|
+
|
158
175
|
# Reference
|
159
176
|
belongs_to :reference, :polymorphic => true
|
160
177
|
after_save :notify_references
|
data/app/models/booking.rb~
CHANGED
@@ -64,7 +64,7 @@ class Booking < ActiveRecord::Base
|
|
64
64
|
rescue ArgumentError
|
65
65
|
end
|
66
66
|
|
67
|
-
where("title LIKE :text OR
|
67
|
+
where("title LIKE :text OR comments = :text OR amount = :amount OR value_date = :value_date", :text => text, :amount => amount, :value_date => date)
|
68
68
|
}
|
69
69
|
|
70
70
|
# Returns array of all years we have bookings for
|
@@ -155,6 +155,23 @@ class Booking < ActiveRecord::Base
|
|
155
155
|
def booking_template_id=(value)
|
156
156
|
end
|
157
157
|
|
158
|
+
# Helpers
|
159
|
+
def split(amount, params = {})
|
160
|
+
# Clone
|
161
|
+
new_booking = self.clone
|
162
|
+
|
163
|
+
# Set amount
|
164
|
+
new_booking[:amount] = amount
|
165
|
+
self.amount -= amount
|
166
|
+
|
167
|
+
# Update attributes
|
168
|
+
params.each{|key, value|
|
169
|
+
new_booking[key] = value
|
170
|
+
}
|
171
|
+
|
172
|
+
new_booking
|
173
|
+
end
|
174
|
+
|
158
175
|
# Reference
|
159
176
|
belongs_to :reference, :polymorphic => true
|
160
177
|
after_save :notify_references
|
data/lib/has_accounts/model.rb
CHANGED
data/lib/has_accounts/model.rb~
CHANGED
@@ -40,7 +40,11 @@ module HasAccounts
|
|
40
40
|
booking_template = BookingTemplate.find_by_code(template_code)
|
41
41
|
|
42
42
|
# Prepare booking parameters
|
43
|
-
booking_params = {
|
43
|
+
booking_params = {
|
44
|
+
:value_date => value_date,
|
45
|
+
:reference_type => self.class.name,
|
46
|
+
:reference_id => self.id
|
47
|
+
}
|
44
48
|
booking_params.merge!(params)
|
45
49
|
|
46
50
|
# Build and assign booking
|
@@ -50,8 +54,8 @@ module HasAccounts
|
|
50
54
|
booking
|
51
55
|
end
|
52
56
|
|
53
|
-
def balance(value_date = nil)
|
54
|
-
bookings.direct_balance(value_date)
|
57
|
+
def balance(value_date = nil, direct_account = nil)
|
58
|
+
bookings.direct_balance(value_date, direct_account)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 6
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Simon H\xC3\xBCrlimann (CyT)"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-26 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|