Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c629b42d57 | |||
| c7ee97139e | |||
| 231364338d | |||
| 184424bc23 | |||
| 2f2f78776b | |||
| 83ba256f9d |
3
Capfile
3
Capfile
@@ -10,6 +10,9 @@ require 'capistrano/rails'
|
||||
# Include rvm helpers
|
||||
require 'capistrano/rvm'
|
||||
|
||||
# Include passenger helpers
|
||||
require 'capistrano/passenger'
|
||||
|
||||
# Load the SCM plugin appropriate to your project:
|
||||
#
|
||||
# require "capistrano/scm/hg"
|
||||
|
||||
2
Gemfile
2
Gemfile
@@ -45,6 +45,7 @@ group :development do
|
||||
gem "capistrano", "~> 3.10", require: false
|
||||
gem "capistrano-rails", "~> 1.3", require: false
|
||||
gem 'capistrano-rvm', require: false
|
||||
gem 'capistrano-passenger', require: false
|
||||
end
|
||||
|
||||
group :test do
|
||||
@@ -61,6 +62,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||
|
||||
# Add rails_admin
|
||||
gem 'rails_admin', '~> 2.0'
|
||||
gem "rails_admin_import", "~> 2.2"
|
||||
|
||||
# Auth with devise
|
||||
gem 'devise', '~> 4.7'
|
||||
|
||||
13
Gemfile.lock
13
Gemfile.lock
@@ -77,6 +77,8 @@ GEM
|
||||
sshkit (>= 1.9.0)
|
||||
capistrano-bundler (2.0.1)
|
||||
capistrano (~> 3.1)
|
||||
capistrano-passenger (0.2.0)
|
||||
capistrano (~> 3.0)
|
||||
capistrano-rails (1.6.1)
|
||||
capistrano (~> 3.1)
|
||||
capistrano-bundler (>= 1.1, < 3)
|
||||
@@ -91,6 +93,7 @@ GEM
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.5)
|
||||
xpath (~> 3.2)
|
||||
charlock_holmes (0.7.7)
|
||||
childprocess (3.0.0)
|
||||
concurrent-ruby (1.1.7)
|
||||
crass (1.0.6)
|
||||
@@ -237,6 +240,11 @@ GEM
|
||||
rails (>= 5.0, < 7)
|
||||
remotipart (~> 1.3)
|
||||
sassc-rails (>= 1.3, < 3)
|
||||
rails_admin_import (2.2.0)
|
||||
charlock_holmes (~> 0.6)
|
||||
rails (>= 3.2)
|
||||
rails_admin (>= 0.6.6)
|
||||
simple_xlsx_reader (~> 1.0)
|
||||
railties (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
@@ -269,6 +277,9 @@ GEM
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
simple_xlsx_reader (1.0.4)
|
||||
nokogiri
|
||||
rubyzip
|
||||
spring (2.1.0)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
@@ -324,6 +335,7 @@ DEPENDENCIES
|
||||
bootsnap (>= 1.4.2)
|
||||
byebug
|
||||
capistrano (~> 3.10)
|
||||
capistrano-passenger
|
||||
capistrano-rails (~> 1.3)
|
||||
capistrano-rvm
|
||||
capybara (>= 2.15)
|
||||
@@ -339,6 +351,7 @@ DEPENDENCIES
|
||||
puma (~> 4.1)
|
||||
rails (~> 6.0.3, >= 6.0.3.2)
|
||||
rails_admin (~> 2.0)
|
||||
rails_admin_import (~> 2.2)
|
||||
rake
|
||||
sass-rails (>= 6)
|
||||
selenium-webdriver
|
||||
|
||||
3
app/assets/stylesheets/tax_references.scss
Normal file
3
app/assets/stylesheets/tax_references.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the TaxReferences controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: https://sass-lang.com/
|
||||
10
app/controllers/tax_references_controller.rb
Normal file
10
app/controllers/tax_references_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class TaxReferencesController < ApplicationController
|
||||
def index
|
||||
@tax_references = TaxReference.all
|
||||
end
|
||||
|
||||
def show
|
||||
@tax_references = TaxReference.all
|
||||
@tax_reference = TaxReference.find_by(year: params[:year])
|
||||
end
|
||||
end
|
||||
2
app/helpers/tax_references_helper.rb
Normal file
2
app/helpers/tax_references_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module TaxReferencesHelper
|
||||
end
|
||||
@@ -8,7 +8,7 @@
|
||||
}
|
||||
|
||||
main > .container {
|
||||
padding: 60px 15px 0;
|
||||
padding: 60px 15px 60px 15px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
|
||||
2
app/models/salary.rb
Normal file
2
app/models/salary.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Salary < ApplicationRecord
|
||||
end
|
||||
18
app/models/tax_reference.rb
Normal file
18
app/models/tax_reference.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class TaxReference < ApplicationRecord
|
||||
default_scope { order(year: :desc) }
|
||||
validates :year, uniqueness: true
|
||||
MAX_MONTHLY_HOURS = 172
|
||||
|
||||
def worker_contribution(number_of_hours)
|
||||
return self.hourly_wage * number_of_hours * self.worker_percentage / 100
|
||||
end
|
||||
|
||||
def employer_contribution(number_of_hours)
|
||||
return self.hourly_wage * number_of_hours * self.employer_percentage / 100
|
||||
end
|
||||
|
||||
def total_contribution(number_of_hours)
|
||||
return self.employer_contribution(number_of_hours) +
|
||||
self.worker_contribution(number_of_hours)
|
||||
end
|
||||
end
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||
<li class="nav-item">
|
||||
<%= link_to(t('Home'), root_path, class: 'nav-link') %>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
<%= link_to(t('Tax References Tables'), tax_references_path, class: 'nav-link') %>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
|
||||
13
app/views/tax_references/_top_list.html.erb
Normal file
13
app/views/tax_references/_top_list.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<% tax_references.each do |tax_ref| %>
|
||||
<li class="nav-item">
|
||||
<% item_class = 'nav-link' %>
|
||||
<% if not @tax_reference.nil? and tax_ref.year == @tax_reference.year %>
|
||||
<% item_class.concat(' active') %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to tax_ref.year, {controller: 'tax_references', action: :show, year: tax_ref.year},
|
||||
class: item_class %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
1
app/views/tax_references/index.html.erb
Normal file
1
app/views/tax_references/index.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render 'top_list', tax_references: @tax_references %>
|
||||
28
app/views/tax_references/show.html.erb
Normal file
28
app/views/tax_references/show.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<%= render 'top_list', tax_references: @tax_references %>
|
||||
|
||||
<p><%= @tax_reference.year %></p>
|
||||
<p><%= @tax_reference.hourly_wage %></p>
|
||||
<p><%= number_to_percentage(@tax_reference.worker_percentage, precision: 2) %></p>
|
||||
<p><%= number_to_percentage(@tax_reference.employer_percentage, precision: 2) %></p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><%= t('Number of Hours') %></th>
|
||||
<th scope="col"><%= t('Employer (extra)') %></th>
|
||||
<th scope="col"><%= t('Worker (discount)') %></th>
|
||||
<th scope="col"><%= t('Total contribution') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% hourly_contribution = @tax_reference.hourly_wage / 100 %>
|
||||
<% (@tax_reference.min_monthly_hours..TaxReference::MAX_MONTHLY_HOURS).each do |n_hours| %>
|
||||
<tr>
|
||||
<td scope="row"><%= n_hours %></td>
|
||||
<td><%= number_to_currency(@tax_reference.employer_contribution(n_hours), locale: :pt) %></td>
|
||||
<td><%= number_to_currency(@tax_reference.worker_contribution(n_hours), locale: :pt) %></td>
|
||||
<td><%= number_to_currency(@tax_reference.total_contribution(n_hours), locale: :pt) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -25,7 +25,7 @@ set :rvm_ruby_version, '2.6.6'
|
||||
# Default value for :linked_files is []
|
||||
# append :linked_files, "config/database.yml"
|
||||
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'
|
||||
append :linked_files, 'config/secrets.yml', 'config/master.key', 'config/credentials.yml.enc', '.env'
|
||||
append :linked_files, 'config/secrets.yml', 'config/master.key', 'config/credentials.yml.enc', '.env', 'tmp/restart.txt'
|
||||
|
||||
# Default value for linked_dirs is []
|
||||
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
|
||||
|
||||
25
config/initializers/rails_admin_import.rb
Normal file
25
config/initializers/rails_admin_import.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
RailsAdmin.config do |config|
|
||||
# REQUIRED:
|
||||
# Include the import action
|
||||
# See https://github.com/sferik/rails_admin/wiki/Actions
|
||||
config.actions do
|
||||
all
|
||||
import
|
||||
end
|
||||
|
||||
# Optional:
|
||||
# Configure global RailsAdminImport options
|
||||
config.configure_with(:import) do |config|
|
||||
config.logging = true
|
||||
end
|
||||
|
||||
# Optional:
|
||||
# Configure model-specific options using standard RailsAdmin DSL
|
||||
# See https://github.com/sferik/rails_admin/wiki/Railsadmin-DSL
|
||||
config.model 'User' do
|
||||
import do
|
||||
include_all_fields
|
||||
exclude_fields :secret_token
|
||||
end
|
||||
end
|
||||
end
|
||||
10
config/locales/pt.yml
Normal file
10
config/locales/pt.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
pt:
|
||||
hello: "Olá Mundo"
|
||||
number:
|
||||
currency:
|
||||
format:
|
||||
unit: '€'
|
||||
delimiter: ','
|
||||
separator: '.'
|
||||
precision: 2
|
||||
format: '%u%n'
|
||||
@@ -1,6 +1,8 @@
|
||||
Rails.application.routes.draw do
|
||||
devise_for :users
|
||||
get 'pages/home'
|
||||
get '/tax_references', to: 'tax_references#index'
|
||||
get '/tax_references/:year', to: 'tax_references#show'
|
||||
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
||||
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
|
||||
|
||||
|
||||
13
db/migrate/20200909112404_create_tax_references.rb
Normal file
13
db/migrate/20200909112404_create_tax_references.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateTaxReferences < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :tax_references do |t|
|
||||
t.integer :year
|
||||
t.float :hourly_wage
|
||||
t.integer :min_monthly_hours
|
||||
t.float :worker_percentage
|
||||
t.float :employer_percentage
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20201001160115_create_salaries.rb
Normal file
11
db/migrate/20201001160115_create_salaries.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateSalaries < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :salaries do |t|
|
||||
t.integer :year
|
||||
t.float :hourly_rate
|
||||
t.json :hour_table
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
20
db/schema.rb
20
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_08_19_085432) do
|
||||
ActiveRecord::Schema.define(version: 2020_10_01_160115) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -41,6 +41,24 @@ ActiveRecord::Schema.define(version: 2020_08_19_085432) do
|
||||
t.index ["unlock_token"], name: "index_admins_on_unlock_token", unique: true
|
||||
end
|
||||
|
||||
create_table "salaries", force: :cascade do |t|
|
||||
t.integer "year"
|
||||
t.float "hourly_rate"
|
||||
t.json "hour_table"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "tax_references", force: :cascade do |t|
|
||||
t.integer "year"
|
||||
t.float "hourly_wage"
|
||||
t.integer "min_monthly_hours"
|
||||
t.float "worker_percentage"
|
||||
t.float "employer_percentage"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
|
||||
7
test/controllers/tax_references_controller_test.rb
Normal file
7
test/controllers/tax_references_controller_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TaxReferencesControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
11
test/fixtures/salaries.yml
vendored
Normal file
11
test/fixtures/salaries.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
year:
|
||||
hourly_rate: 1.5
|
||||
hour_table:
|
||||
|
||||
two:
|
||||
year:
|
||||
hourly_rate: 1.5
|
||||
hour_table:
|
||||
15
test/fixtures/tax_references.yml
vendored
Normal file
15
test/fixtures/tax_references.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
year: 1
|
||||
hourly_wage: 1.5
|
||||
min_monthly_hours: 1
|
||||
worker_percentage: 1.5
|
||||
employer_percentage: 1.5
|
||||
|
||||
two:
|
||||
year: 1
|
||||
hourly_wage: 1.5
|
||||
min_monthly_hours: 1
|
||||
worker_percentage: 1.5
|
||||
employer_percentage: 1.5
|
||||
7
test/models/salary_test.rb
Normal file
7
test/models/salary_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SalaryTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/tax_reference_test.rb
Normal file
7
test/models/tax_reference_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TaxReferenceTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user