has_accounts 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,18 +40,22 @@ module HasAccounts
40
40
  booking_template = BookingTemplate.find_by_code(template_code)
41
41
 
42
42
  # Prepare booking parameters
43
- booking_params = {:value_date => value_date, :amount => amount}
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
47
- booking = booking_template.build_booking(:value_date => value_date, :amount => amount)
51
+ booking = booking_template.build_booking(booking_params)
48
52
  bookings << booking
49
53
 
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
@@ -34,10 +34,17 @@ module HasAccounts
34
34
  self.class.direct_account
35
35
  end
36
36
 
37
- def build_booking
38
- booking_template = BookingTemplate.find_by_code(self.class.to_s.underscore + ':invoice')
37
+ # Build booking
38
+ def build_booking(params = {}, template_code = nil)
39
+ template_code ||= self.class.to_s.underscore + ':invoice'
40
+ booking_template = BookingTemplate.find_by_code(template_code)
39
41
 
40
- booking = booking_template.build_booking(:value_date => value_date, :amount => amount)
42
+ # Prepare booking parameters
43
+ booking_params = {:value_date => value_date}
44
+ booking_params.merge!(params)
45
+
46
+ # Build and assign booking
47
+ booking = booking_template.build_booking(booking_params)
41
48
  bookings << booking
42
49
 
43
50
  booking
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 1
9
- version: 0.4.1
7
+ - 5
8
+ - 0
9
+ version: 0.5.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-13 00:00:00 +02:00
17
+ date: 2011-04-15 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20