19 Commits

Author SHA1 Message Date
c629b42d57 Add Salary model. Needs testing and then devs. 2020-10-01 17:11:39 +01:00
c7ee97139e Try improving capistrano behaviour with passenger. 2020-10-01 17:11:00 +01:00
231364338d Small style improvement. 2020-09-10 17:55:29 +01:00
184424bc23 Default sort on tax_reference. 2020-09-10 17:46:49 +01:00
2f2f78776b Add rails_admin_import for easy import in the backoffice. 2020-09-10 17:25:20 +01:00
83ba256f9d Add tax_references, its controller and some basic pages for viewing ref data about taxes. 2020-09-10 12:36:43 +01:00
49d17e5850 Add admin link in top navbar. 2020-09-09 12:11:55 +01:00
9a6b4862a3 update apt only once 2020-09-09 11:41:11 +01:00
7add23e62a Use production rails_env in staging deployment - should investigate what else is needed for correct asset compilation in a new env. 2020-08-22 13:57:32 +01:00
371cfb25f1 Fix stylesheet_pack_tag 2020-08-22 13:35:37 +01:00
d9d7929604 Add .env loading to capistrano deployment. 2020-08-22 12:41:27 +01:00
611f1b94ba remove .iml file. 2020-08-21 20:27:01 +01:00
9564208054 layout with generic logic. 2020-08-21 20:25:47 +01:00
6bb06010ae Add capistrano and deploy configs for staging. 2020-08-21 20:25:10 +01:00
e70fab734f Add staging env for webpacker. 2020-08-21 19:20:23 +01:00
e22d670933 Ignore more files and add staging database config. 2020-08-21 19:14:50 +01:00
a7c80ac14e Add staging env for webpacker. 2020-08-21 18:03:00 +01:00
717c3b4ea7 Add staging env. 2020-08-21 18:01:03 +01:00
10168de123 Update ruby-version. 2020-08-21 17:41:54 +01:00
38 changed files with 651 additions and 156 deletions

2
.gitignore vendored
View File

@@ -27,6 +27,7 @@
# Ignore master key for decrypting credentials and more.
/config/master.key
/config/credentials.yml.enc
/public/packs
/public/packs-test
@@ -107,3 +108,4 @@ yarn-debug.log*
# Ignore IJ IDE directory
/.idea/
*.iml

View File

@@ -1 +1 @@
ruby-2.5.8
ruby-2.6.6@ss-calculator

47
Capfile Normal file
View File

@@ -0,0 +1,47 @@
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Include rails specific deploy scripts
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"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
# require "capistrano/bundler"
# require "capistrano/rails/assets"
# require "capistrano/rails/migrations"
# require "capistrano/passenger"
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

View File

@@ -1,8 +1,7 @@
FROM ruby:2.6
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update && apt install yarn
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client yarn
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile

View File

@@ -41,6 +41,11 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Capistrano
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
@@ -57,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'

View File

@@ -62,12 +62,29 @@ GEM
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
bcrypt (3.1.15)
bindex (0.8.1)
bootsnap (1.4.8)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
capistrano (3.14.1)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
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)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capybara (3.33.0)
addressable
mini_mime (>= 0.1.3)
@@ -76,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)
@@ -141,6 +159,9 @@ GEM
multi_xml (0.6.0)
multipart-post (2.1.1)
nested_form (0.3.2)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
@@ -219,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)
@@ -251,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)
@@ -262,6 +291,9 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.21.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.8.2)
thor (1.0.1)
thread_safe (0.3.6)
@@ -302,6 +334,10 @@ PLATFORMS
DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
capistrano (~> 3.10)
capistrano-passenger
capistrano-rails (~> 1.3)
capistrano-rvm
capybara (>= 2.15)
devise (~> 4.7)
devise-bootstrap-views (~> 1.0)
@@ -315,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

View 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/

View 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

View File

@@ -0,0 +1,2 @@
module TaxReferencesHelper
end

View File

@@ -8,7 +8,7 @@
}
main > .container {
padding: 60px 15px 0;
padding: 60px 15px 60px 15px;
}
.footer {

2
app/models/salary.rb Normal file
View File

@@ -0,0 +1,2 @@
class Salary < ApplicationRecord
end

View 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

View File

@@ -0,0 +1,3 @@
<header>
<%= render 'layouts/top_navigation' %>
</header>

View File

@@ -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">
@@ -29,6 +29,11 @@
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<%= link_to "Admin", rails_admin_path, class: 'nav-link' %>
</li>
</ul>
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>

View File

@@ -5,16 +5,14 @@
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/toasts' %>
<header>
<%= render 'layouts/top_navigation' %>
</header>
<%= render 'layouts/header' %>
<%= render 'layouts/content' %>
<%= render 'layouts/footer' %>

View 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>

View File

@@ -0,0 +1 @@
<%= render 'top_list', tax_references: @tax_references %>

View 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>

View File

@@ -83,4 +83,8 @@ test:
#
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
url: <%= ENV['DATABASE_URL'] %>
staging:
<<: *default
url: <%= ENV['DATABASE_URL'] %>

47
config/deploy.rb Normal file
View File

@@ -0,0 +1,47 @@
# config valid for current version and patch releases of Capistrano
lock "~> 3.14.1"
set :application, "ss-calculator"
set :repo_url, "git@github.com:dlage/ss-calculator.git"
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, "/var/www/my_app_name"
set :deploy_to, "/srv/www/ss-calculator"
set :rvm_ruby_version, '2.6.6'
# Default value for :format is :airbrussh.
# set :format, :airbrussh
# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
# Default value for :pty is false
# set :pty, true
# 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', 'tmp/restart.txt'
# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for local_user is ENV['USER']
# set :local_user, -> { `git config user.name`.chomp }
# Default value for keep_releases is 5
set :keep_releases, 5
set :keep_assets, 5
# Uncomment the following to require manually verifying the host key before first deploy.
# set :ssh_options, verify_host_key: :secure
namespace :deploy do
after :starting, 'envvars:load'
end

View File

@@ -0,0 +1,61 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server "example.com",
# user: "user_name",
# roles: %w{web app},
# ssh_options: {
# user: "user_name", # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: "please use keys"
# }

64
config/deploy/staging.rb Normal file
View File

@@ -0,0 +1,64 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}
ask :deployer_username, 'deployer'
server "usaserver4.senolage.net", user: fetch(:deployer_username), roles: %w{app db web}, :primary => true
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
set :deploy_to, "/srv/www/ss-calculator-staging"
set :rails_env, 'production'
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# keys: %w(/home/user_name/.ssh/id_rsa),
set :ssh_options, {
forward_agent: true,
auth_methods: %w(publickey)
}
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server "example.com",
# user: "user_name",
# roles: %w{web app},
# ssh_options: {
# user: "user_name", # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: "please use keys"
# }

View File

@@ -0,0 +1,114 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "myapp_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: 'sscalc-staging.lage.pw', port: 443 }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end

View 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
View File

@@ -0,0 +1,10 @@
pt:
hello: "Olá Mundo"
number:
currency:
format:
unit: '€'
delimiter: ','
separator: '.'
precision: 2
format: '%u%n'

View File

@@ -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

View File

@@ -0,0 +1,5 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'staging'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()

View File

@@ -94,3 +94,15 @@ production:
# Cache manifest.json for performance
cache_manifest: true
staging:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true

View 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

View 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

View File

@@ -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

View File

@@ -0,0 +1,31 @@
namespace :envvars do
desc 'Load environment variables'
task :load do
# Grab the current value of :default_env
environment = fetch(:default_env, {})
on roles(:app) do
# Read in the environment file
env_file = fetch(:env_file, "#{fetch(:deploy_to)}/shared/.env")
lines = capture("cat #{env_file}")
lines.each_line do |line|
# Remove the "export " keyword, we have no use for that here
line = line.sub /^export /, ""
# Clean up the input by removing line breaks, tabs etc
line = line.gsub /[\t\r\n\f]+/, ""
# Grab the key and value from the line
key, value = line.split("=")
# Remove surrounding quotes if present
value = value.slice(1..-2) if value.start_with?('"') and value.end_with?('"')
# Store the value in our :default_env copy
environment.store(key, value)
end
# Finally, update the global :default_env variable again
set :default_env, environment
end
end
end

View File

@@ -1,143 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUBY_MODULE" version="4">
<component name="FacetManager">
<facet type="RailsFacetType" name="Ruby on Rails">
<configuration>
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_SUPPORT_REMOVED" VALUE="false" />
<RAILS_FACET_CONFIG_ID NAME="RAILS_TESTS_SOURCES_PATCHED" VALUE="true" />
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_APPLICATION_ROOT" VALUE="$MODULE_DIR$" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
<excludeFolder url="file://$MODULE_DIR$/components" />
<excludeFolder url="file://$MODULE_DIR$/log" />
<excludeFolder url="file://$MODULE_DIR$/public/packs" />
<excludeFolder url="file://$MODULE_DIR$/public/system" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/cache" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailbox (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actiontext (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel-serializers-xml (v1.0.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activestorage (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.7.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.15, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bindex (v0.8.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bootsnap (v1.4.8, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="capybara (v3.33.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="childprocess (v3.0.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.7, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="devise (v4.7.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="devise-bootstrap-views (v1.1.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.9.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="faraday (v1.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.13.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="globalid (v0.4.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="haml (v5.1.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="hashie (v4.1.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.10.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.4.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-ui-rails (v6.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jwt (v2.2.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="kaminari (v1.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="kaminari-actionview (v1.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="kaminari-activerecord (v1.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="kaminari-core (v1.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="listen (v3.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.6.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mail (v2.7.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="marcel (v0.3.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mimemagic (v0.3.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.0.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.4.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="msgpack (v1.3.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.15.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.1.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="nested_form (v0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="nio4r (v2.5.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.10.10, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="oauth2 (v1.4.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth (v1.9.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth-facebook (v6.0.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth-github (v1.4.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth-google-oauth2 (v0.8.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth-oauth2 (v1.7.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="omniauth-openid (v1.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="orm_adapter (v0.5.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="pg (v1.2.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="puma (v4.3.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-openid (v1.3.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-pjax (v1.1.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-proxy (v0.6.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.3.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails_admin (v2.0.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v6.0.3.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.10.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.10.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v1.7.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="remotipart (v1.4.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="responders (v3.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="ruby-openid (v2.9.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sass-rails (v6.0.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sassc (v2.4.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sassc-rails (v2.1.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v3.142.7, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="spring (v2.1.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="spring-watcher-listen (v2.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets (v4.0.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets-rails (v3.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="temple (v0.8.2, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="thor (v1.0.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.10, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="turbolinks (v5.2.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="turbolinks-source (v5.2.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.7, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tzinfo-data (v1.2020.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="warden (v1.2.8, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="web-console (v4.0.4, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="webdrivers (v4.4.1, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="webpacker (v4.3.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.3, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="xpath (v3.2.0, ruby-2.6.5-p114) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.4.0, ruby-2.6.5-p114) [gem]" level="application" />
</component>
<component name="RModuleSettingsStorage">
<LOAD_PATH number="0" />
<I18N_FOLDERS number="1" string0="$MODULE_DIR$/config/locales" />
</component>
</module>

View 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
View 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
View 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

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class SalaryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class TaxReferenceTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end