-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SalaryItem as habt model between SalaryTemplate and SalaryB…
…ookingTemplate.
- Loading branch information
Showing
16 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class SalaryItem < ActiveRecord::Base | ||
belongs_to :salary_template | ||
belongs_to :salary_booking_template | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
class SalaryTemplate < ActiveRecord::Base | ||
belongs_to :person | ||
has_and_belongs_to_many :salary_booking_templates | ||
|
||
# Salary Items | ||
has_many :salary_items | ||
accepts_nested_attributes_for :salary_items, :allow_destroy => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%tr.salary_item.nested-form-item | ||
%td= salary_item.select :salary_booking_template_id, SalaryBookingTemplate.all.map{|template| [template.title, template.id]}, :required => true, :style => 'width: 30em' | ||
%td= salary_item.text_field :times, :required => true, :style => 'width: 3em', :autocomplete => "off" | ||
%td= salary_item.text_field :price, :required => true, :style => 'width: 5em', :autocomplete => "off" | ||
%td.action_links | ||
= salary_item.hidden_field :_destroy | ||
= link_to t_action(:delete), '#', :class => 'icon-delete-text delete-nested-form-item' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%tr[line_item] | ||
%td= line_item.date | ||
%td= line_item.title | ||
%td.currency= line_item.times_to_s | ||
%td.currency= currency_fmt(line_item.price) | ||
%td.currency= currency_fmt(line_item.total_amount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= f.inputs t_title(:list, SalaryItem) do | ||
%table#salary_items | ||
%thead | ||
= render 'salary_items/list_header' | ||
%tbody | ||
= f.fields_for :salary_items do |salary_item| | ||
= render 'salary_items/form', :salary_item => salary_item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%tr | ||
%th{:style => 'padding: 2px'}= t_attr(:salary_booking_template, SalaryItem) | ||
%th{:style => 'padding: 2px; width: 3em'}= t_attr(:times, SalaryItem) | ||
%th{:style => 'padding: 2px; width: 3em'}= t_attr(:price, SalaryItem) | ||
%th | ||
%th.action_links= link_to t_action(:more), [:new_salary_item, resource.persisted? ? resource : resource.class.name.underscore.pluralize.to_sym], :remote => true, :class => 'icon-add-text' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= fields_for @salary_template do |salary_template| | ||
= salary_template.fields_for :salary_items, @salary_item, :child_index => -(DateTime.now.to_i) do |salary_item| | ||
= render 'salary_items/form', :salary_item => salary_item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$('#salary_items tbody').append('<%=j render 'salary_item_form' %>'); | ||
initializeBehaviours(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateSalaryItems < ActiveRecord::Migration | ||
def change | ||
create_table :salary_items do |t| | ||
t.integer :salary_booking_template_id | ||
t.integer :salary_template_id | ||
t.decimal :times, :precision => 10, :scale => 2 | ||
t.decimal :price, :precision => 10, :scale => 2 | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :salary_items, :salary_booking_template_id | ||
add_index :salary_items, :salary_template_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Read about factories at http://github.com/thoughtbot/factory_girl | ||
|
||
FactoryGirl.define do | ||
factory :salary_item do | ||
salary_booking_template_id 1 | ||
salary_template_id 1 | ||
times "9.99" | ||
price "9.99" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe SalaryItem do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |