abrasf-desif 1.0.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 (135) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +55 -0
  4. data/Rakefile +24 -0
  5. data/app/controllers/abrasf/desif/application_controller.rb +8 -0
  6. data/app/controllers/abrasf/desif/cities_controller.rb +12 -0
  7. data/app/controllers/abrasf/desif/city_tax_codes_controller.rb +71 -0
  8. data/app/controllers/abrasf/desif/service_items_controller.rb +29 -0
  9. data/app/controllers/abrasf/desif/tax_codes_controller.rb +26 -0
  10. data/app/decorators/abrasf/desif/tax_code_decorator.rb +27 -0
  11. data/app/models/abrasf/desif.rb +9 -0
  12. data/app/models/abrasf/desif/city.rb +15 -0
  13. data/app/models/abrasf/desif/city_tax_code.rb +29 -0
  14. data/app/models/abrasf/desif/service_item.rb +10 -0
  15. data/app/models/abrasf/desif/tax_code.rb +16 -0
  16. data/app/views/abrasf/desif/cities/_city.html.erb +5 -0
  17. data/app/views/abrasf/desif/cities/index.html.erb +15 -0
  18. data/app/views/abrasf/desif/city_tax_codes/_city_tax_code.html.erb +10 -0
  19. data/app/views/abrasf/desif/city_tax_codes/_form.html.erb +41 -0
  20. data/app/views/abrasf/desif/city_tax_codes/edit.html.erb +6 -0
  21. data/app/views/abrasf/desif/city_tax_codes/index.html.erb +25 -0
  22. data/app/views/abrasf/desif/city_tax_codes/new.html.erb +5 -0
  23. data/app/views/abrasf/desif/city_tax_codes/show.html.erb +34 -0
  24. data/app/views/abrasf/desif/service_items/_service_item.html.erb +5 -0
  25. data/app/views/abrasf/desif/service_items/index.html.erb +7 -0
  26. data/app/views/abrasf/desif/tax_codes/_tax_code.html.erb +5 -0
  27. data/app/views/abrasf/desif/tax_codes/index.csv.erb +3 -0
  28. data/app/views/abrasf/desif/tax_codes/index.html.erb +16 -0
  29. data/config/locales/en.yml +56 -0
  30. data/config/locales/pt.yml +60 -0
  31. data/config/routes.rb +6 -0
  32. data/db/migrate/20160408160535_create_desif_abrasf_service_items.rb +7 -0
  33. data/db/migrate/20160412200143_create_abrasf_desif_tax_codes.rb +8 -0
  34. data/db/migrate/20160413201725_create_abrasf_desif_cities.rb +8 -0
  35. data/db/migrate/20160418190116_create_abrasf_desif_city_tax_code.rb +14 -0
  36. data/db/seeds.rb +22 -0
  37. data/db/seeds/cities.csv +5565 -0
  38. data/db/seeds/service_items.csv +194 -0
  39. data/db/seeds/tax_codes.csv +251 -0
  40. data/lib/abrasf.rb +6 -0
  41. data/lib/abrasf/desif.rb +9 -0
  42. data/lib/abrasf/desif/engine.rb +30 -0
  43. data/lib/abrasf/desif/tax_code_to_city.rb +38 -0
  44. data/lib/abrasf/desif/version.rb +7 -0
  45. data/lib/abrasf_desif.rb +3 -0
  46. data/lib/tasks/desif_abrasf_tasks.rake +21 -0
  47. data/spec/controllers/abrasf/desif/cities_controller_spec.rb +26 -0
  48. data/spec/controllers/abrasf/desif/city_tax_codes_controller_spec.rb +130 -0
  49. data/spec/controllers/abrasf/desif/service_items_controller_spec.rb +31 -0
  50. data/spec/controllers/abrasf/desif/tax_codes_controller_spec.rb +27 -0
  51. data/spec/decorators/abrasf/desif/tax_code_decorator_spec.rb +31 -0
  52. data/spec/dummy/README.rdoc +28 -0
  53. data/spec/dummy/Rakefile +6 -0
  54. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  55. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  56. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  57. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  58. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  59. data/spec/dummy/bin/bundle +3 -0
  60. data/spec/dummy/bin/rails +4 -0
  61. data/spec/dummy/bin/rake +4 -0
  62. data/spec/dummy/bin/setup +29 -0
  63. data/spec/dummy/config.ru +4 -0
  64. data/spec/dummy/config/application.rb +32 -0
  65. data/spec/dummy/config/boot.rb +5 -0
  66. data/spec/dummy/config/database.yml +25 -0
  67. data/spec/dummy/config/environment.rb +5 -0
  68. data/spec/dummy/config/environments/development.rb +41 -0
  69. data/spec/dummy/config/environments/production.rb +79 -0
  70. data/spec/dummy/config/environments/test.rb +42 -0
  71. data/spec/dummy/config/initializers/assets.rb +11 -0
  72. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  74. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/spec/dummy/config/initializers/inflections.rb +16 -0
  76. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  77. data/spec/dummy/config/initializers/session_store.rb +3 -0
  78. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  79. data/spec/dummy/config/locales/en.yml +23 -0
  80. data/spec/dummy/config/routes.rb +3 -0
  81. data/spec/dummy/config/secrets.yml +22 -0
  82. data/spec/dummy/db/development.sqlite3 +0 -0
  83. data/spec/dummy/db/schema.rb +46 -0
  84. data/spec/dummy/db/test.sqlite3 +0 -0
  85. data/spec/dummy/log/development.log +26087 -0
  86. data/spec/dummy/log/test.log +80851 -0
  87. data/spec/dummy/public/404.html +67 -0
  88. data/spec/dummy/public/422.html +67 -0
  89. data/spec/dummy/public/500.html +66 -0
  90. data/spec/dummy/public/favicon.ico +0 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Iv/IvDM1j8-H1H6kEjVCsyIW8N2zla-aIp9q_OE9PVZtVw.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Oj/OjYnbNV-4H2wB22qA8vak8p70VzibwrJDHRRc9N73wM.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ol/OlBX9JIv9SAOmK2t35x1SYDx1sxCXF0yvqpna3WMyH0.cache +1 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Pf/Pfv3CJAV6pC6GNSukkfNn8rDJ_akR2vXUJHKfFGfEec.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qv/Qvh8ZRaow--u_cxJTKTRSBmhxHZ2gCInZpLH9aOQ7j4.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wj/WjUfRWFfV2RfTLWhS9YXsOE1vFE663g4nIf-XAjQpHk.cache +1 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Yr/YrZ0OIHu42cExs1kqngMA6ShVDKhfGmhyW-E9haNo5Y.cache +1 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fi/fiWk-EIFM9DWQRQ_5EJjHWgch83bbHfvO4pzuUQE5KM.cache +0 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gp/gpiWtnqpufka8lRtMznM6Ko0aWJrcH_j8cfZwdYmzNI.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hU/hUrafJ93523F4gu5J0fKI4s_Xwe8hAe471ftz89sRmA.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yD/yDtRlN_BF4e3gVA0QORRB8oUdMNc1ttnGrN2N2cGVZ8.cache +0 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yz/yz2DRlMVn6xJ6XlrKZAcHX7ZU3Rl0k3MmwyIIfiDA0I.cache +0 -0
  107. data/spec/factories/city.rb +9 -0
  108. data/spec/factories/city_tax_code.rb +10 -0
  109. data/spec/factories/service_item.rb +8 -0
  110. data/spec/factories/tax_code.rb +9 -0
  111. data/spec/features/city_spec.rb +12 -0
  112. data/spec/features/city_tax_codes_spec.rb +63 -0
  113. data/spec/features/service_item_spec.rb +12 -0
  114. data/spec/features/tax_codes_spec.rb +15 -0
  115. data/spec/lib/tax_code_to_city_spec.rb +25 -0
  116. data/spec/models/abrasf/desif/city_spec.rb +13 -0
  117. data/spec/models/abrasf/desif/city_tax_code_spec.rb +21 -0
  118. data/spec/models/abrasf/desif/service_item_spec.rb +10 -0
  119. data/spec/models/abrasf/desif/tax_code_spec.rb +13 -0
  120. data/spec/rails_helper.rb +62 -0
  121. data/spec/routing/abrasf/desif/cities_routing_spec.rb +16 -0
  122. data/spec/routing/abrasf/desif/city_tax_codes_routing_spec.rb +51 -0
  123. data/spec/routing/abrasf/desif/service_items_routing_spec.rb +16 -0
  124. data/spec/routing/abrasf/desif/tax_codes_routing_spec.rb +16 -0
  125. data/spec/spec_helper.rb +49 -0
  126. data/spec/support/factory_girl.rb +11 -0
  127. data/spec/support/shoulda_matcher.rb +13 -0
  128. data/spec/tasks/desif_abrasf_tasks_rake_spec.rb +36 -0
  129. data/spec/views/abrasf/desif/cities/_city.html.erb_spec.rb +11 -0
  130. data/spec/views/abrasf/desif/cities/index.html.erb_spec.rb +13 -0
  131. data/spec/views/abrasf/desif/service_items/_service_item.html.erb_spec.rb +11 -0
  132. data/spec/views/abrasf/desif/service_items/index.html.erb_spec.rb +13 -0
  133. data/spec/views/abrasf/desif/tax_codes/_tax_code.html.erb_spec.rb +12 -0
  134. data/spec/views/abrasf/desif/tax_codes/index.html.erb_spec.rb +20 -0
  135. metadata +376 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a5c40fd857a60254f75ca45aaadb3efa271c2de0
4
+ data.tar.gz: 2eb423c03c7c4f30b0e86c3ea2f90aea13fa6568
5
+ SHA512:
6
+ metadata.gz: 92edd58daa24a1281d20e95e20dafbdaf84d7b13f3d458eb6e9685320356b7d308b01bd73aaa9fa06e7905933e7b53e0dd652b93e60226677556692726f5255d
7
+ data.tar.gz: b296ab0cbd25b72b34bfca4ac6a829942b38e3eb5c6752277b357ac705e27fa9f52fe7a2d7bed0f99fde64aa171941c77f6b1bd952120b85d946627b224c5654
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Marco Moura
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.
@@ -0,0 +1,55 @@
1
+ [![wercker status](https://app.wercker.com/status/ebd567df675e3729babbdbafc4651e3e/s/master "wercker status")](https://app.wercker.com/project/bykey/ebd567df675e3729babbdbafc4651e3e)
2
+ [![Dependency Status](https://gemnasium.com/badges/github.com/marcomoura/desif_abrasf.svg)](https://gemnasium.com/github.com/marcomoura/desif_abrasf)
3
+ [![Code Climate](https://codeclimate.com/repos/570b9abdd165c835ca0053d5/badges/846b8f2a08ca8b537537/gpa.svg)](https://codeclimate.com/repos/570b9abdd165c835ca0053d5/feed)
4
+ # DES-IF ABRASF
5
+
6
+ Here are the tables of the conceptual DES-IF version 2.3 from ABRASF
7
+
8
+ It contains the following models:
9
+
10
+ * Service Item - List of services from Complementary law 116/2003
11
+ * Tax Codes - List of tax codes from DES-IF
12
+ * Cities - List of Cities from IBGE
13
+ * City Tax Codes - Tax codes from City (without seed)
14
+
15
+
16
+ ## Getting started
17
+
18
+ ```ruby
19
+ gem 'abrasf-desif'
20
+ ```
21
+
22
+ Run the bundle command to install it.
23
+
24
+ After you install add it to your Gemfile, you need to run the migration:
25
+
26
+ ```console
27
+ rake db:migrate
28
+ ```
29
+
30
+ After the migration, you need to run the following task to load the seeds:
31
+
32
+ ```console
33
+ rake abrasf-desif:db:seed
34
+ ```
35
+
36
+ There is a task to seed an default Tax Code for the city,
37
+ to call it is necessary to inform the IBGE city code.
38
+
39
+ ```console
40
+ rake abrasf-desif:city_tax_code[3550308]
41
+ ```
42
+
43
+ You can also use this feature calling the following code:
44
+
45
+ ```ruby
46
+ Abrasf::Desif::TaxCodeToCity.create city_id:
47
+ ```
48
+
49
+ ## TODO
50
+
51
+ - validate uniqueness (tax_code) in city tax code
52
+ scoped by city and date interval (since-expiry = date interval)
53
+
54
+ - validate period valid in city tax code
55
+ expiry date should be greater than since date
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Abrasf Desif'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.rd')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
20
+ load 'rails/tasks/engine.rake'
21
+
22
+ load 'rails/tasks/statistics.rake'
23
+
24
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class ApplicationController < ActionController::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class CitiesController < ApplicationController
6
+ # GET /desif/cities
7
+ def index
8
+ @cities = Desif::City.all
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class CityTaxCodesController < ApplicationController
6
+ before_action :set_city_tax_code,
7
+ only: [:show, :edit, :update, :destroy]
8
+
9
+ # GET /city_tax_codes
10
+ def index
11
+ @city_tax_codes = CityTaxCode.all
12
+ end
13
+
14
+ # GET /city_tax_codes/1
15
+ def show
16
+ end
17
+
18
+ # GET /city_tax_codes/new
19
+ def new
20
+ @city_tax_code = CityTaxCode.new
21
+ end
22
+
23
+ # GET /city_tax_codes/1/edit
24
+ def edit
25
+ end
26
+
27
+ # POST /city_tax_codes
28
+ def create
29
+ @city_tax_code = CityTaxCode.new(city_tax_code_params)
30
+
31
+ if @city_tax_code.save
32
+ redirect_to @city_tax_code, notice: t('.created')
33
+ else
34
+ render :new
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT /city_tax_codes/1
39
+ def update
40
+ if @city_tax_code.update(city_tax_code_params)
41
+ redirect_to @city_tax_code, notice: t('.updated')
42
+ else
43
+ render :edit
44
+ end
45
+ end
46
+
47
+ # DELETE /city_tax_codes/1
48
+ def destroy
49
+ @city_tax_code.destroy
50
+ redirect_to city_tax_codes_url, notice: t('.destroyed')
51
+ end
52
+
53
+ private
54
+
55
+ # Use callbacks to share common setup or constraints between actions.
56
+ def set_city_tax_code
57
+ @city_tax_code = CityTaxCode.find(params[:id])
58
+ end
59
+
60
+ # Only allow a trusted parameter "white list" through.
61
+ def city_tax_code_params
62
+ params.require(:city_tax_code)
63
+ .permit :city_id, :city,
64
+ :tax_code, :tax_code_id,
65
+ :abrasf_desif_city_id, :abrasf_desif_city,
66
+ :abrasf_desif_tax_code, :abrasf_desif_tax_code_id,
67
+ :city_tax_code, :aliquot, :since, :expiry
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+
5
+ module Abrasf
6
+ module Desif
7
+ class ServiceItemsController < ApplicationController
8
+ before_action :set_service_items
9
+
10
+ # GET /service_items
11
+ def index
12
+ respond_to do |format|
13
+ format.html
14
+ format.csv do
15
+ send_data @service_items.to_csv,
16
+ type: Mime::CSV,
17
+ disposition: 'attachment; filename=attachament_4.csv'
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def set_service_items
25
+ @service_items = ServiceItem.all
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class TaxCodesController < ApplicationController
6
+ before_action :set_tax_codes
7
+
8
+ # GET /desif/tax_codes
9
+ def index
10
+ respond_to do |format|
11
+ format.html
12
+ format.csv do
13
+ filename = "attachment; filename=\"#{t '.filename'}\""
14
+ headers['Content-Disposition'] = filename
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def set_tax_codes
22
+ @tax_codes = TaxCodeDecorator.wrap TaxCode.all
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class TaxCodeDecorator < SimpleDelegator
6
+ def self.wrap(collection)
7
+ collection.map { |obj| new obj }
8
+ end
9
+
10
+ def service_item_id
11
+ format '%04d', super
12
+ end
13
+
14
+ def id
15
+ format '%09d', super
16
+ end
17
+
18
+ def id_mask
19
+ "#{id[0..1]}.#{id[2..3]}.#{id[4..6]}-#{id[7..8]}"
20
+ end
21
+
22
+ def to_csv
23
+ [id, description, service_item_id]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ def self.table_name_prefix
6
+ 'abrasf_desif_'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class City < ActiveRecord::Base
6
+ validates_presence_of :id
7
+ validates :name,
8
+ presence: true,
9
+ length: { maximum: 50, allow_blank: true }
10
+ validates :federative_unit,
11
+ presence: true,
12
+ length: { is: 2, allow_blank: true }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class CityTaxCode < ActiveRecord::Base
6
+ belongs_to :tax_code, foreign_key: :abrasf_desif_tax_code_id
7
+ belongs_to :city, foreign_key: :abrasf_desif_city_id
8
+
9
+ alias_attribute :code, :city_tax_code
10
+ alias_attribute :city_id, :abrasf_desif_city_id
11
+ alias_attribute :tax_code_id, :abrasf_desif_tax_code_id
12
+ delegate :description, to: :tax_code
13
+
14
+ validates_presence_of :abrasf_desif_tax_code_id,
15
+ :abrasf_desif_city_id,
16
+ :since
17
+
18
+ validates :city_tax_code,
19
+ presence: true,
20
+ length: { maximum: 20, allow_blank: true }
21
+
22
+ validates :aliquot,
23
+ presence: true,
24
+ numericality: { greater_than_or_equal_to: 2,
25
+ less_than_or_equal_to: 5,
26
+ allow_nil: true }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class ServiceItem < ActiveRecord::Base
6
+ has_many :tax_codes
7
+ validates_presence_of :id, :description
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Abrasf
4
+ module Desif
5
+ class TaxCode < ActiveRecord::Base
6
+ belongs_to :service_item, foreign_key: :abrasf_desif_service_item_id
7
+
8
+ alias_attribute :service_item_id, :abrasf_desif_service_item_id
9
+
10
+ validates_presence_of :id, :abrasf_desif_service_item_id
11
+ validates :description,
12
+ presence: true,
13
+ length: { maximum: 200, allow_blank: true }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ <tr>
2
+ <td><%= city.id %></td>
3
+ <td><%= city.name %></td>
4
+ <td><%= city.federative_unit %></td>
5
+ </tr>
@@ -0,0 +1,15 @@
1
+ <h3><%= t '.title' %></h3>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th><%= t '.code' %></th>
7
+ <th><%= t '.name' %></th>
8
+ <th><%= t '.federative_unit' %></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <tbody>
13
+ <%= render partial: @cities %>
14
+ </tbody>
15
+ </table>
@@ -0,0 +1,10 @@
1
+ <tr>
2
+ <td><%= city_tax_code.abrasf_desif_city_id %></td>
3
+ <td><%= city_tax_code.abrasf_desif_tax_code_id %></td>
4
+ <td><%= city_tax_code.city_tax_code %></td>
5
+ <td><%= city_tax_code.aliquot %></td>
6
+ <td><%= l city_tax_code.since, format: :year_month %></td>
7
+ <td><%= city_tax_code.expiry %></td>
8
+ <td><%= link_to t('.edit'), edit_city_tax_code_path(city_tax_code) %></td>
9
+ <td><%= link_to t('.destroy'), city_tax_code, method: :delete, data: { confirm: 'Are you sure?' } %></td>
10
+ </tr>
@@ -0,0 +1,41 @@
1
+ <%= form_for(@city_tax_code) do |f| %>
2
+ <% if @city_tax_code.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@city_tax_code.errors.count, "error") %> <%= t '.error' %> </h2>
5
+
6
+ <ul>
7
+ <% @city_tax_code.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :abrasf_desif_city_id %><br>
16
+ <%= f.number_field :abrasf_desif_city_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :abrasf_desif_tax_code_id %><br>
20
+ <%= f.number_field :abrasf_desif_tax_code_id %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :city_tax_code %><br>
24
+ <%= f.text_field :city_tax_code %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :aliquot %><br>
28
+ <%= f.number_field :aliquot, value: 5, min: 2, max: 5, step: 0.5 %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :since %><br>
32
+ <%= f.date_field :since %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :expiry %><br>
36
+ <%= f.date_field :expiry %>
37
+ </div>
38
+ <div class="actions">
39
+ <%= f.submit %>
40
+ </div>
41
+ <% end %>