bookyt_salary 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,9 @@ class SalariesController < InvoicesController
43
43
  @salary.title = "Lohn #{month_name} #{@salary.duration_from.year} - #{@salary.employee.vcard.full_name}"
44
44
  @salary.duration_to = @salary.duration_from.end_of_month
45
45
 
46
+ # Prebuild line items
47
+ @salary.build_line_items
48
+
46
49
  # Prebuild an empty attachment instance
47
50
  @salary.attachments.build
48
51
 
data/app/models/salary.rb CHANGED
@@ -75,6 +75,16 @@ class Salary < Invoice
75
75
  self.due_date ||= date
76
76
  end
77
77
 
78
+ # Line Items
79
+ def build_line_items
80
+ template = SalaryTemplate.where(:person_id => employee.id).first
81
+ template.salary_booking_templates.each do |booking_template|
82
+ line_item = line_items.build(:date => self.value_date)
83
+ line_item.booking_template = booking_template
84
+ end
85
+ end
86
+
87
+
78
88
  # Filter/Search
79
89
  # =============
80
90
  scope :by_value_period, lambda {|from, to| where("date(value_date) BETWEEN ? AND ?", from, to) }
@@ -101,33 +111,4 @@ class Salary < Invoice
101
111
  def self.default_debit_account
102
112
  self.direct_account
103
113
  end
104
-
105
- # Bookings
106
- # ========
107
- def amount
108
- employment.salary_amount if employment
109
- end
110
-
111
- # Build booking
112
- #
113
- # We need to ensure the order of creation as we depent on current balance.
114
- def build_booking(params = {}, template_code = nil)
115
- # Build and assign booking
116
- super(params, 'salary:invoice')
117
- super(params, 'salary:employee:ahv_iv_eo')
118
- super(params, 'salary:employer:ahv_iv_eo')
119
- super(params, 'salary:employee:alv')
120
- super(params, 'salary:employer:alv')
121
- super(params, 'salary:employee:nbu')
122
- super(params, 'salary:employer:nbu')
123
- super(params, 'salary:employer:bu')
124
- super(params, 'salary:employer:fak')
125
- super(params, 'salary:employer:vkb')
126
-
127
- super(params, 'salary:employee:ktg')
128
- super(params.merge(:person_id => employee.id), "salary:employee:bvg")
129
-
130
- super(params.merge(:person_id => employee.id), "salary:employee:kz")
131
- super(params.merge(:person_id => employee.id), "salary:social:kz")
132
- end
133
114
  end
@@ -1,4 +1,4 @@
1
1
  class SalaryTemplate < ActiveRecord::Base
2
2
  belongs_to :person
3
- has_and_belongs_to_many :salary_booking_template
3
+ has_and_belongs_to_many :salary_booking_templates
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module BookytSalary
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_salary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Simon H\xC3\xBCrlimann (CyT)"