Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support leave day saldo.

  • Loading branch information...
commit ebf5c3bc05225dae12bf202a8eef515611deec2d 1 parent 9cff6a3
Simon Hürlimann authored
3  app/controllers/salaries_controller.rb
View
@@ -40,6 +40,9 @@ def new
@salary.title = "Lohn #{month_name} #{@salary.duration_from.year} - #{@salary.employee.vcard.full_name}"
@salary.duration_to = @salary.duration_from.end_of_month
+ @salary.leave_days_balance = @salary.previous.leave_days_balance || 0
+ @salary.used_leave_days = 0
+
# Prebuild line items
@salary.build_line_items
5 app/models/salary.rb
View
@@ -37,6 +37,11 @@ def to_s(format = :default)
end
end
+ # Helpers
+ def previous
+ employee.salaries.order("duration_to DESC").where("duration_to < ?", duration_to).first
+ end
+
# Calculations
def ahv_amount
amount_of('AHV')
3  app/views/salaries/_form.html.haml
View
@@ -8,6 +8,9 @@
.span6= f.input :duration_from, :as => :date_field
.span6= f.input :duration_to, :as => :date_field
.row-fluid
+ .span6= f.input :used_leave_days, :as => :string
+ .span6= f.input :leave_days_balance, :as => :string
+ .row-fluid
.span12= f.input :text, :input_html => {:rows => 4}
.row-fluid
.span12= f.input :remarks, :input_html => {:rows => 4}
31 app/views/salaries/payslip.pdf.prawn
View
@@ -25,6 +25,8 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
unless resource.employment.hourly_paid
pdf.move_down 20
+
+ top_y = pdf.y
pdf.text "Stundenabrechnung", :style => :bold
month_name = t('date.month_names')[@salary.duration_from.month]
@@ -35,7 +37,7 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
["Aktueller Stundensaldo", "%0.2f" % @hours_saldo],
]
- pdf.table rows, :width => (pdf.bounds.width * 0.4) do
+ pdf.table rows, :width => 8.cm do
cells.valign = :top
cells.borders = []
cells.padding_bottom = 2
@@ -47,6 +49,33 @@ prawn_document(:filename => "#{resource.to_s}.pdf", :renderer => PayslipDocument
rows(3).font_style = :bold
end
+ bottom_y = pdf.y
+
+ pdf.y = top_y
+ pdf.indent 10.cm do
+ pdf.text "Ferienabrechnung", :style => :bold
+
+ month_name = t('date.month_names')[@salary.duration_from.month]
+ rows = [
+ ["#{t_attr(:used_leave_days)} #{month_name}", "%0.1f" % resource.used_leave_days],
+ [t_attr(:leave_days_balance), "%0.1f" % resource.leave_days_balance],
+ ]
+
+ pdf.table rows, :width => 8.cm do
+ cells.valign = :top
+ cells.borders = []
+ cells.padding_bottom = 2
+ cells.padding_top = 2
+
+ columns(0).padding_left = 0
+ columns(0).width = 5.cm
+ columns(1).align = :right
+
+ rows(3).font_style = :bold
+ end
+ end
+
+ pdf.y = bottom_y
end
# Free text with the socical security number
2  config/locales/bookyt_salary.de.yml
View
@@ -12,6 +12,8 @@ de:
employer: Arbeitgeber
employee: Arbeitnehmer
text: Text auf Lohnabrechnung
+ leave_days_balance: Restliche Ferientage
+ used_leave_days: Bezogene Ferientage
salary_booking_template:
include_in_saldo_list: Pflichtigkeit
5 db/migrate/20120503120833_add_unused_leave_days_to_debit_invoices.rb
View
@@ -0,0 +1,5 @@
+class AddLeaveDayColumnsToSalaries < ActiveRecord::Migration
+ def change
+ add_column :invoices, :unused_leave_days, :decimal
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.