taxable 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +25 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/taxable_manifest.js +0 -0
  6. data/app/assets/stylesheets/scaffold.css +80 -0
  7. data/app/assets/stylesheets/tax_group_items.css +4 -0
  8. data/app/assets/stylesheets/tax_groups.css +4 -0
  9. data/app/assets/stylesheets/taxes.css +4 -0
  10. data/app/controllers/tax_groups_controller.rb +61 -0
  11. data/app/controllers/taxes_controller.rb +58 -0
  12. data/app/helpers/tax_group_items_helper.rb +2 -0
  13. data/app/helpers/tax_groups_helper.rb +8 -0
  14. data/app/helpers/taxes_helper.rb +8 -0
  15. data/app/models/tax.rb +3 -0
  16. data/app/models/tax_group.rb +5 -0
  17. data/app/models/tax_group_item.rb +4 -0
  18. data/app/views/tax_groups/_form.html.erb +27 -0
  19. data/app/views/tax_groups/_tax_group.html.erb +18 -0
  20. data/app/views/tax_groups/edit.html.erb +5 -0
  21. data/app/views/tax_groups/index.html.erb +23 -0
  22. data/app/views/tax_groups/new.html.erb +5 -0
  23. data/app/views/taxes/_form.html.erb +37 -0
  24. data/app/views/taxes/_tax.html.erb +16 -0
  25. data/app/views/taxes/edit.html.erb +5 -0
  26. data/app/views/taxes/index.html.erb +24 -0
  27. data/app/views/taxes/new.html.erb +5 -0
  28. data/config/locales/en.yml +40 -0
  29. data/config/locales/es.yml +40 -0
  30. data/config/routes.rb +4 -0
  31. data/db/migrate/20210821075101_create_taxes.rb +11 -0
  32. data/db/migrate/20210821080313_create_tax_groups.rb +9 -0
  33. data/db/migrate/20210821080629_create_tax_group_items.rb +10 -0
  34. data/db/migrate/20210821080752_add_currency_to_taxes.rb +5 -0
  35. data/lib/generators/taxable/install_generator.rb +24 -0
  36. data/lib/tasks/taxable_tasks.rake +4 -0
  37. data/lib/taxable.rb +5 -0
  38. data/lib/taxable/engine.rb +4 -0
  39. data/lib/taxable/version.rb +3 -0
  40. metadata +112 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ef116c091018b9ab2b135cb219d6387fc68b59dcad6e393193507216c2837e2
4
+ data.tar.gz: a8f0b6a5b7c94851dead26fd811e6f1da4b469fb7ae79225ce8af98586ba3212
5
+ SHA512:
6
+ metadata.gz: 97e8f922e8a43972eef3c3b6b86e33f971a8edbac787c47aaa5f08b0678c6c91955384da2c78d070e29b054008c50aa8a5e78d135755f931beb62666c2e806c6
7
+ data.tar.gz: b3f88eff92687a011301445b82db7dbd6fa993fd89d79608a39b5f0fe6189689d1ee00e1717797f95b6db6456f05b5cc48da29ae29bb7d345cf86287b7a74470
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Otoniel Reyes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Taxable
2
+ Add tax support to your rails application.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'taxable', github: 'kenliten/taxable', branch: 'main'
9
+ ```
10
+
11
+ And then execute:
12
+ ```bash
13
+ $ bundle
14
+ ```
15
+
16
+ Generate the installation:
17
+ ```bash
18
+ $ bin/rails g taxable:install
19
+ ```
20
+
21
+ ## Contributing
22
+ To contribute, just fork this repository, add/edit the code, and make a pull request. All contribution are welcome.
23
+
24
+ ## License
25
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
File without changes
@@ -0,0 +1,80 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ margin: 33px;
5
+ }
6
+
7
+ body, p, ol, ul, td {
8
+ font-family: verdana, arial, helvetica, sans-serif;
9
+ font-size: 13px;
10
+ line-height: 18px;
11
+ }
12
+
13
+ pre {
14
+ background-color: #eee;
15
+ padding: 10px;
16
+ font-size: 11px;
17
+ }
18
+
19
+ a {
20
+ color: #000;
21
+ }
22
+
23
+ a:visited {
24
+ color: #666;
25
+ }
26
+
27
+ a:hover {
28
+ color: #fff;
29
+ background-color: #000;
30
+ }
31
+
32
+ th {
33
+ padding-bottom: 5px;
34
+ }
35
+
36
+ td {
37
+ padding: 0 5px 7px;
38
+ }
39
+
40
+ div.field,
41
+ div.actions {
42
+ margin-bottom: 10px;
43
+ }
44
+
45
+ #notice {
46
+ color: green;
47
+ }
48
+
49
+ .field_with_errors {
50
+ padding: 2px;
51
+ background-color: red;
52
+ display: table;
53
+ }
54
+
55
+ #error_explanation {
56
+ width: 450px;
57
+ border: 2px solid red;
58
+ padding: 7px 7px 0;
59
+ margin-bottom: 20px;
60
+ background-color: #f0f0f0;
61
+ }
62
+
63
+ #error_explanation h2 {
64
+ text-align: left;
65
+ font-weight: bold;
66
+ padding: 5px 5px 5px 15px;
67
+ font-size: 12px;
68
+ margin: -7px -7px 0;
69
+ background-color: #c00;
70
+ color: #fff;
71
+ }
72
+
73
+ #error_explanation ul li {
74
+ font-size: 12px;
75
+ list-style: square;
76
+ }
77
+
78
+ label {
79
+ display: block;
80
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,61 @@
1
+ class TaxGroupsController < ApplicationController
2
+ before_action :set_tax_group, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /tax_groups
5
+ def index
6
+ @tax_groups = TaxGroup.all
7
+ end
8
+
9
+ # GET /tax_groups/1
10
+ def show
11
+ end
12
+
13
+ # GET /tax_groups/new
14
+ def new
15
+ @tax_group = TaxGroup.new
16
+ end
17
+
18
+ # GET /tax_groups/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /tax_groups
23
+ def create
24
+ @tax_group = TaxGroup.new({name: params[:tax_group][:name]})
25
+ params[:tax_group][:tax_group_items].each do |item|
26
+ @tax_group.tax_group_items.build({ tax_id: item }).save unless item.empty?
27
+ end
28
+
29
+ if @tax_group.save
30
+ redirect_to tax_groups_url, notice: 'Tax group was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /tax_groups/1
37
+ def update
38
+ if @tax_group.update(tax_group_params)
39
+ redirect_to tax_groups_url, notice: 'Tax group was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /tax_groups/1
46
+ def destroy
47
+ @tax_group.destroy
48
+ redirect_to tax_groups_url, notice: 'Tax group was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_tax_group
54
+ @tax_group = TaxGroup.find(params[:id])
55
+ end
56
+
57
+ # Only allow a list of trusted parameters through.
58
+ def tax_group_params
59
+ params.require(:tax_group).permit(:name, :tax_group_items)
60
+ end
61
+ end
@@ -0,0 +1,58 @@
1
+ class TaxesController < ApplicationController
2
+ before_action :set_tax, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /taxes
5
+ def index
6
+ @taxes = Tax.all
7
+ end
8
+
9
+ # GET /taxes/1
10
+ def show
11
+ end
12
+
13
+ # GET /taxes/new
14
+ def new
15
+ @tax = Tax.new
16
+ end
17
+
18
+ # GET /taxes/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /taxes
23
+ def create
24
+ @tax = Tax.new(tax_params)
25
+
26
+ if @tax.save
27
+ redirect_to taxes_url, notice: 'Tax was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /taxes/1
34
+ def update
35
+ if @tax.update(tax_params)
36
+ redirect_to taxes_url, notice: 'Tax was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /taxes/1
43
+ def destroy
44
+ @tax.destroy
45
+ redirect_to taxes_url, notice: 'Tax was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_tax
51
+ @tax = Tax.find(params[:id])
52
+ end
53
+
54
+ # Only allow a list of trusted parameters through.
55
+ def tax_params
56
+ params.require(:tax).permit(:name, :rate, :active, :currency)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module TaxGroupItemsHelper
2
+ end
@@ -0,0 +1,8 @@
1
+ require 'currencies'
2
+
3
+ module TaxGroupsHelper
4
+
5
+ def currency(c)
6
+ return ISO4217::Currency.from_code c
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'currencies'
2
+
3
+ module TaxesHelper
4
+
5
+ def currency(c)
6
+ return ISO4217::Currency.from_code c
7
+ end
8
+ end
data/app/models/tax.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Tax < ApplicationRecord
2
+ has_many :tax_group_items, dependent: :destroy
3
+ end
@@ -0,0 +1,5 @@
1
+ class TaxGroup < ApplicationRecord
2
+ has_many :tax_group_items, dependent: :destroy
3
+
4
+ has_many :taxes, through: :tax_group_items
5
+ end
@@ -0,0 +1,4 @@
1
+ class TaxGroupItem < ApplicationRecord
2
+ belongs_to :tax_group
3
+ belongs_to :tax
4
+ end
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: tax_group) do |form| %>
2
+ <% if tax_group.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(tax_group.errors.count, "error") %> prohibited this tax_group from being saved:</h2>
5
+
6
+ <ul>
7
+ <% tax_group.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-group mb-2">
15
+ <%= form.label :name, t('.name') %>
16
+ <%= form.text_field :name, class: 'form-control' %>
17
+ </div>
18
+
19
+ <div class="form-group my-2">
20
+ <%= form.label :tax_group_items, t('.tax_group_items') %>
21
+ <%= form.select :tax_group_items, Tax.all.collect { |e| [e.name, e.id] }, {include_blank: false}, {multiple: true, class: 'form-control' } %>
22
+ </div>
23
+
24
+ <div class="my-3">
25
+ <%= form.submit t('save'), data: { disable_with: t('saving') }, class: 'btn btn-primary' %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <tr>
2
+ <td><%= tax_group.name %></td>
3
+ <td>
4
+ <% tax_group.tax_group_items.each do |item| %>
5
+ <%= tag.span "#{item.tax.name} (#{ISO4217::Currency.from_code(item.tax.currency).name})", class: 'badge bg-dark text-white' %>
6
+ <% end %>
7
+ </td>
8
+ <td>
9
+ <div class="d-grid gap-2">
10
+ <%= link_to t('edit'), edit_tax_group_path(tax_group), class: 'btn btn-outline-secondary btn-sm' %>
11
+ </div>
12
+ </td>
13
+ <td>
14
+ <div class="d-grid gap-2">
15
+ <%= link_to t('destroy'), tax_group, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-outline-danger btn-sm' %>
16
+ </div>
17
+ </td>
18
+ </tr>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('.editing_tax_group') %></h1>
2
+
3
+ <%= render 'form', tax_group: @tax_group %>
4
+
5
+ <%= link_to t('back'), :back, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,23 @@
1
+ <h1><%= t('.tax_groups') %></h1>
2
+
3
+ <table class="table table-striped table-hover mb-3">
4
+ <thead>
5
+ <tr>
6
+ <th><%= t('.name') %></th>
7
+ <th><%= t('.taxes') %></th>
8
+ <th colspan="2"></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <tbody id="tax_groups">
13
+ <%= render @tax_groups %>
14
+ </tbody>
15
+ </table>
16
+
17
+ <%= link_to t('.new_tax_group'), new_tax_group_path, class: 'btn btn-primary' %>
18
+
19
+ <style type="text/css">
20
+ td {
21
+ vertical-align: middle;
22
+ }
23
+ </style>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('.new_tax_group') %></h1>
2
+
3
+ <%= render 'form', tax_group: @tax_group %>
4
+
5
+ <%= link_to t('back'), :back, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,37 @@
1
+ <%= form_with(model: tax) do |form| %>
2
+ <% if tax.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(tax.errors.count, "error") %> prohibited this tax from being saved:</h2>
5
+
6
+ <ul>
7
+ <% tax.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-group mb-2">
15
+ <%= form.label :name, t('.name') %>
16
+ <%= form.text_field :name, class: 'form-control' %>
17
+ </div>
18
+
19
+ <div class="form-group my-2">
20
+ <%= form.label :rate, t('.rate') %>
21
+ <%= form.text_field :rate, class: 'form-control' %>
22
+ </div>
23
+
24
+ <div class="form-group my-2">
25
+ <%= form.label :currency, t('.currency') %>
26
+ <%= form.select :currency, ['DOP', 'USD', 'EUR'].collect { |e| ["#{ISO4217::Currency.from_code(e).name} (#{ISO4217::Currency.from_code(e).symbol})", ISO4217::Currency.from_code(e).code] }, {}, {class: 'form-control'} %>
27
+ </div>
28
+
29
+ <div class="form-group my-2">
30
+ <%= form.check_box :active, class: 'form-check-input' %>
31
+ <%= form.label :active, t('.active'), class: 'form-check-label' %>
32
+ </div>
33
+
34
+ <div class="my-3">
35
+ <%= form.submit t('save'), data: { disable_with: t('saving') }, class: 'btn btn-primary' %>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <tr>
2
+ <td><%= tax.name %></td>
3
+ <td><%= tax.rate %></td>
4
+ <td><%= currency(tax.currency).name %> (<%= currency(tax.currency).code %>)</td>
5
+ <td><%= tax.active ? t('active') : t('inactive') %></td>
6
+ <td>
7
+ <div class="d-grid gap-2">
8
+ <%= link_to t('edit'), edit_tax_path(tax), class: 'btn btn-outline-secondary btn-sm' %>
9
+ </div>
10
+ </td>
11
+ <td>
12
+ <div class="d-grid gap-2">
13
+ <%= link_to t('destroy'), tax, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-outline-danger btn-sm' %>
14
+ </div>
15
+ </td>
16
+ </tr>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('.editing_tax') %></h1>
2
+
3
+ <%= render 'form', tax: @tax %>
4
+
5
+ <%= link_to t('back'), :back, class:'btn btn-outline-secondary' %>
@@ -0,0 +1,24 @@
1
+ <h1><%= t('.taxes') %></h1>
2
+
3
+ <table class="table table-striped table-hover mb-3">
4
+ <thead>
5
+ <tr>
6
+ <th><%= t('.name') %></th>
7
+ <th><%= t('.rate') %></th>
8
+ <th><%= t('.active') %></th>
9
+ <th><%= t('.currency') %></th>
10
+ <th colspan="2"></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <%= render @taxes %>
15
+ </tbody>
16
+ </table>
17
+
18
+ <%= link_to t('.new_tax'), new_tax_path, class: 'btn btn-primary' %>
19
+
20
+ <style type="text/css">
21
+ td {
22
+ vertical-align: middle;
23
+ }
24
+ </style>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('.new_tax') %></h1>
2
+
3
+ <%= render 'form', tax: @tax %>
4
+
5
+ <%= link_to t('back'), :back, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,40 @@
1
+ en:
2
+ show: 'Show'
3
+ edit: 'Edit'
4
+ destroy: 'Delete'
5
+ back: 'Back'
6
+ save: 'Save'
7
+ saving: 'Saving'
8
+ active: 'Active'
9
+ inactive: 'Inactive'
10
+ taxes:
11
+ form:
12
+ name: 'Name'
13
+ rate: 'Rate'
14
+ currency: 'Currency'
15
+ active: 'Active'
16
+ edit:
17
+ editing_tax: 'Editing Tax'
18
+ index:
19
+ taxes: 'Taxes'
20
+ name: 'Name'
21
+ rate: 'Rate'
22
+ active: 'Active'
23
+ currency: 'Currency'
24
+ new_tax: 'New Tax'
25
+ new:
26
+ new_tax: 'New Tax'
27
+ tax_groups:
28
+ form:
29
+ name: 'Name'
30
+ taxes: 'Taxes'
31
+ tax_group_items: 'Taxes'
32
+ index:
33
+ tax_groups: 'Tax Groups'
34
+ name: 'Name'
35
+ taxes: 'Taxes'
36
+ new_tax_group: 'New Tax Group'
37
+ edit:
38
+ editing_tax_group: 'Editing Tax Groups'
39
+ new:
40
+ new_tax_group: 'New Tax Group'
@@ -0,0 +1,40 @@
1
+ es:
2
+ show: 'Mostrar'
3
+ edit: 'Editar'
4
+ destroy: 'Eliminar'
5
+ back: 'Atrás'
6
+ save: 'Guardar'
7
+ saving: 'Guardando'
8
+ active: 'Activa'
9
+ inactive: 'Inactiva'
10
+ taxes:
11
+ form:
12
+ name: 'Nombre'
13
+ rate: 'Tarifa'
14
+ currency: 'Moneda'
15
+ active: 'Activo'
16
+ edit:
17
+ editing_tax: 'Editando Impuesto'
18
+ index:
19
+ taxes: 'Impuestos'
20
+ name: 'Nombre'
21
+ rate: 'Tarifa'
22
+ active: 'Activo'
23
+ currency: 'Moneda'
24
+ new_tax: 'Registrar Impuesto'
25
+ new:
26
+ new_tax: 'Registrar Impuesto'
27
+ tax_groups:
28
+ form:
29
+ name: 'Nombre'
30
+ taxes: 'Impuestos'
31
+ tax_group_items: 'Impuestos'
32
+ index:
33
+ tax_groups: 'Grupos de Impuestos'
34
+ name: 'Nombre'
35
+ taxes: 'Impuestos'
36
+ new_tax_group: 'Registrar Grupo'
37
+ edit:
38
+ editing_tax_group: 'Editando Grupo de Impuestos'
39
+ new:
40
+ new_tax_group: 'Registrar Grupo de Impuestos'
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ resources :taxes, only: [:index, :edit, :new, :create, :update, :destroy]
3
+ resources :tax_groups, only: [:index, :edit, :new, :create, :update, :destroy]
4
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTaxes < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :taxes do |t|
4
+ t.string :name
5
+ t.decimal :rate
6
+ t.boolean :active
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaxGroups < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :tax_groups do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateTaxGroupItems < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :tax_group_items do |t|
4
+ t.references :tax_group, null: false, foreign_key: true
5
+ t.references :tax, null: false, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddCurrencyToTaxes < ActiveRecord::Migration[6.1]
2
+ def change
3
+ add_column :taxes, :currency, :string
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Taxable
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def copy_migrations
9
+ rake "taxable_engine:install:migrations"
10
+ rake "db:migrate"
11
+ end
12
+
13
+ def copy_locales
14
+ copy_file "../../../../config/locales/en.yml", "config/locales/taxable.en.yml"
15
+ copy_file "../../../../config/locales/es.yml", "config/locales/taxable.es.yml"
16
+ end
17
+
18
+ def add_route
19
+ # Sisnce this engine isn't mountable, don't need to be mounted, so remove this line
20
+ # route "mount Taxable::Engine => '/taxes'"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :taxable do
3
+ # # Task goes here
4
+ # end
data/lib/taxable.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "taxable/version"
2
+ require "taxable/engine"
3
+
4
+ module Taxable
5
+ end
@@ -0,0 +1,4 @@
1
+ module Taxable
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Taxable
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taxable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kenliten
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: currencies
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.2
41
+ description: Add a basic VAT support to your Rails application.
42
+ email:
43
+ - kenliten@otonielreyes.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/assets/config/taxable_manifest.js
52
+ - app/assets/stylesheets/scaffold.css
53
+ - app/assets/stylesheets/tax_group_items.css
54
+ - app/assets/stylesheets/tax_groups.css
55
+ - app/assets/stylesheets/taxes.css
56
+ - app/controllers/tax_groups_controller.rb
57
+ - app/controllers/taxes_controller.rb
58
+ - app/helpers/tax_group_items_helper.rb
59
+ - app/helpers/tax_groups_helper.rb
60
+ - app/helpers/taxes_helper.rb
61
+ - app/models/tax.rb
62
+ - app/models/tax_group.rb
63
+ - app/models/tax_group_item.rb
64
+ - app/views/tax_groups/_form.html.erb
65
+ - app/views/tax_groups/_tax_group.html.erb
66
+ - app/views/tax_groups/edit.html.erb
67
+ - app/views/tax_groups/index.html.erb
68
+ - app/views/tax_groups/new.html.erb
69
+ - app/views/taxes/_form.html.erb
70
+ - app/views/taxes/_tax.html.erb
71
+ - app/views/taxes/edit.html.erb
72
+ - app/views/taxes/index.html.erb
73
+ - app/views/taxes/new.html.erb
74
+ - config/locales/en.yml
75
+ - config/locales/es.yml
76
+ - config/routes.rb
77
+ - db/migrate/20210821075101_create_taxes.rb
78
+ - db/migrate/20210821080313_create_tax_groups.rb
79
+ - db/migrate/20210821080629_create_tax_group_items.rb
80
+ - db/migrate/20210821080752_add_currency_to_taxes.rb
81
+ - lib/generators/taxable/install_generator.rb
82
+ - lib/tasks/taxable_tasks.rake
83
+ - lib/taxable.rb
84
+ - lib/taxable/engine.rb
85
+ - lib/taxable/version.rb
86
+ homepage: https://taxable.kenliten.website
87
+ licenses:
88
+ - MIT
89
+ metadata:
90
+ homepage_uri: https://taxable.kenliten.website
91
+ source_code_uri: https://github.com/kenliten/taxable
92
+ changelog_uri: https://github.com/kenliten/taxable/blob/main/CHANGELOG.md
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.2.15
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Add VAT support to your Rails application
112
+ test_files: []