smerp-quotation-engine 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 (77) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +10 -0
  5. data/app/assets/config/smerp_quotation_engine_manifest.js +1 -0
  6. data/app/assets/stylesheets/smerp/quotation/engine/application.css +15 -0
  7. data/app/controllers/smerp/quotation/engine/application_controller.rb +9 -0
  8. data/app/controllers/smerp/quotation/engine/quotation_item_groups_controller.rb +70 -0
  9. data/app/controllers/smerp/quotation/engine/quotation_items_controller.rb +237 -0
  10. data/app/controllers/smerp/quotation/engine/quotation_product_categories_controller.rb +60 -0
  11. data/app/controllers/smerp/quotation/engine/quotation_products_controller.rb +60 -0
  12. data/app/controllers/smerp/quotation/engine/quotations_controller.rb +192 -0
  13. data/app/helpers/smerp/quotation/engine/application_helper.rb +29 -0
  14. data/app/helpers/smerp/quotation/engine/quotation_item_groups_helper.rb +4 -0
  15. data/app/helpers/smerp/quotation/engine/quotation_items_helper.rb +4 -0
  16. data/app/helpers/smerp/quotation/engine/quotation_product_categories_helper.rb +4 -0
  17. data/app/helpers/smerp/quotation/engine/quotation_products_helper.rb +4 -0
  18. data/app/helpers/smerp/quotation/engine/quotations_helper.rb +81 -0
  19. data/app/jobs/smerp/quotation/engine/application_job.rb +8 -0
  20. data/app/mailers/smerp/quotation/engine/application_mailer.rb +10 -0
  21. data/app/models/smerp/quotation/engine/application_record.rb +9 -0
  22. data/app/models/smerp/quotation/engine/quotation.rb +11 -0
  23. data/app/models/smerp/quotation/engine/quotation_item.rb +34 -0
  24. data/app/models/smerp/quotation/engine/quotation_item_group.rb +10 -0
  25. data/app/models/smerp/quotation/engine/quotation_product.rb +30 -0
  26. data/app/models/smerp/quotation/engine/quotation_product_category.rb +11 -0
  27. data/app/views/layouts/smerp/quotation/engine/application.html.erb +15 -0
  28. data/app/views/smerp/quotation/engine/_new_quotation_item_form.html.erb +48 -0
  29. data/app/views/smerp/quotation/engine/extended_calculators/extended_calculators.html.erb +36 -0
  30. data/app/views/smerp/quotation/engine/quotation_item_groups/_form.html.erb +17 -0
  31. data/app/views/smerp/quotation/engine/quotation_item_groups/_quotation_item_group.html.erb +2 -0
  32. data/app/views/smerp/quotation/engine/quotation_item_groups/edit.html.erb +10 -0
  33. data/app/views/smerp/quotation/engine/quotation_item_groups/index.html.erb +14 -0
  34. data/app/views/smerp/quotation/engine/quotation_item_groups/new.html.erb +9 -0
  35. data/app/views/smerp/quotation/engine/quotation_item_groups/show.html.erb +10 -0
  36. data/app/views/smerp/quotation/engine/quotation_items/_form.html.erb +53 -0
  37. data/app/views/smerp/quotation/engine/quotation_items/_product_item_form.html.erb +47 -0
  38. data/app/views/smerp/quotation/engine/quotation_items/_quotation_item.html.erb +17 -0
  39. data/app/views/smerp/quotation/engine/quotation_items/edit.html.erb +9 -0
  40. data/app/views/smerp/quotation/engine/quotation_items/index.html.erb +14 -0
  41. data/app/views/smerp/quotation/engine/quotation_items/new.html.erb +9 -0
  42. data/app/views/smerp/quotation/engine/quotation_items/new_product_item.html.erb +7 -0
  43. data/app/views/smerp/quotation/engine/quotation_items/show.html.erb +76 -0
  44. data/app/views/smerp/quotation/engine/quotation_product_categories/_form.html.erb +33 -0
  45. data/app/views/smerp/quotation/engine/quotation_product_categories/_quotation_product_category.html.erb +17 -0
  46. data/app/views/smerp/quotation/engine/quotation_product_categories/edit.html.erb +10 -0
  47. data/app/views/smerp/quotation/engine/quotation_product_categories/index.html.erb +14 -0
  48. data/app/views/smerp/quotation/engine/quotation_product_categories/new.html.erb +9 -0
  49. data/app/views/smerp/quotation/engine/quotation_product_categories/show.html.erb +10 -0
  50. data/app/views/smerp/quotation/engine/quotation_products/_form.html.erb +41 -0
  51. data/app/views/smerp/quotation/engine/quotation_products/_quotation_product.html.erb +9 -0
  52. data/app/views/smerp/quotation/engine/quotation_products/edit.html.erb +10 -0
  53. data/app/views/smerp/quotation/engine/quotation_products/index.html.erb +19 -0
  54. data/app/views/smerp/quotation/engine/quotation_products/new.html.erb +9 -0
  55. data/app/views/smerp/quotation/engine/quotation_products/show.html.erb +32 -0
  56. data/app/views/smerp/quotation/engine/quotations/_form.html.erb +49 -0
  57. data/app/views/smerp/quotation/engine/quotations/_new_group_form.html.erb +24 -0
  58. data/app/views/smerp/quotation/engine/quotations/_product_item_form.html.erb +47 -0
  59. data/app/views/smerp/quotation/engine/quotations/_quotation.html.erb +10 -0
  60. data/app/views/smerp/quotation/engine/quotations/_quotation_item.html.erb +96 -0
  61. data/app/views/smerp/quotation/engine/quotations/edit.html.erb +9 -0
  62. data/app/views/smerp/quotation/engine/quotations/extended_calculators.html.erb +36 -0
  63. data/app/views/smerp/quotation/engine/quotations/index.html.erb +21 -0
  64. data/app/views/smerp/quotation/engine/quotations/new.html.erb +9 -0
  65. data/app/views/smerp/quotation/engine/quotations/new_extended_calculator.html.erb +65 -0
  66. data/app/views/smerp/quotation/engine/quotations/new_product_item.html.erb +7 -0
  67. data/app/views/smerp/quotation/engine/quotations/show.html.erb +151 -0
  68. data/config/routes.rb +50 -0
  69. data/db/migrate/20220929020407_create_smerp_quotation_engine_quotation_products.rb +16 -0
  70. data/db/migrate/20220929041715_create_smerp_quotation_engine_quotation_product_categories.rb +12 -0
  71. data/db/migrate/20220929074438_link_product_to_item.rb +5 -0
  72. data/db/seeds.rb +36 -0
  73. data/lib/smerp/quotation/engine/engine.rb +40 -0
  74. data/lib/smerp/quotation/engine/version.rb +7 -0
  75. data/lib/smerp/quotation/engine.rb +10 -0
  76. data/lib/tasks/smerp/quotation/engine_tasks.rake +4 -0
  77. metadata +216 -0
@@ -0,0 +1,192 @@
1
+
2
+ require 'smerp/quotation'
3
+
4
+ module Smerp::Quotation::Engine
5
+ class QuotationsController < ApplicationController
6
+ before_action :set_quotation, only: %i[ show edit update destroy extended_calculators new_extended_calculator create_calculator edit_extended_calculator update_extended_calculator delete_extended_calculator new_product_item ]
7
+
8
+ # GET /quotations
9
+ def index
10
+ @quotations = Quotation.all
11
+ end
12
+
13
+ # GET /quotations/1
14
+ def show
15
+ @qi = QuotationItem.new
16
+ @qig = QuotationItemGroup.new
17
+
18
+ @parent = [["(Group) Others", 0]]
19
+ @parent += @quotation.quotation_item_groups.collect { |g| ["(Group) #{g.name}", "group-#{g.id}"] }
20
+ @parent += @quotation.quotation_items.collect { |i|
21
+ nm = []
22
+
23
+ if not i.quotation_item_group.nil?
24
+ nm << "(Group) #{i.quotation_item_group.name}"
25
+ else
26
+ nm << "(Group) Others"
27
+ end
28
+
29
+ nm << "(Parent) #{i.parent.name}" if not i.parent.nil?
30
+ fnm = "#{nm.join("/")} - #{i.name}"
31
+ [fnm, "item-#{i.id}"]
32
+ }
33
+
34
+ @extCals = @quotation.extended_calculators.nil? ? [] : YAML.load(@quotation.extended_calculators)
35
+ @privExtCals = @quotation.private_extended_calculators.nil? ? [] : YAML.load(@quotation.private_extended_calculators)
36
+
37
+
38
+ render layout: "full_width_application"
39
+ end
40
+
41
+ # GET /quotations/new
42
+ def new
43
+ @quotation = Quotation.new
44
+ end
45
+
46
+ # GET /quotations/1/edit
47
+ def edit
48
+ end
49
+
50
+ # POST /quotations
51
+ def create
52
+ @quotation = Quotation.new(quotation_params)
53
+
54
+ if @quotation.save
55
+ redirect_to @quotation, notice: "Quotation was successfully created."
56
+ else
57
+ render :new, status: :unprocessable_entity
58
+ end
59
+ end
60
+
61
+ # PATCH/PUT /quotations/1
62
+ def update
63
+ if @quotation.update(quotation_params)
64
+ redirect_to @quotation, notice: "Quotation was successfully updated."
65
+ else
66
+ render :edit, status: :unprocessable_entity
67
+ end
68
+ end
69
+
70
+ # DELETE /quotations/1
71
+ def destroy
72
+ @quotation.destroy
73
+ redirect_to quotations_url, notice: "Quotation was successfully destroyed."
74
+ end
75
+
76
+ #def apply_discount
77
+ # redirect_to @quotation, notice: "Discount applied"
78
+ #end
79
+
80
+ # extended calculators operations
81
+ def extended_calculators
82
+ @extCals = @quotation.extended_calculators.nil? ? [] : YAML.load(@quotation.extended_calculators)
83
+ @privExtCals = @quotation.private_extended_calculators.nil? ? [] : YAML.load(@quotation.private_extended_calculators)
84
+ render "extended_calculators"
85
+ end
86
+
87
+ def new_extended_calculator
88
+ end
89
+
90
+ def create_calculator
91
+ root = params[:calculator]
92
+ calType = root[:cal_type]
93
+
94
+ val = root[:value]
95
+ app = root[:applicability]
96
+
97
+ indx = (val =~ /p/)
98
+ if not indx.nil?
99
+ valType = :percent
100
+ vval = val[0...indx]
101
+ vval = vval.to_f.percent
102
+ else
103
+ valType = :raw
104
+ vval = val.to_f.value
105
+ end
106
+
107
+ case calType
108
+ when "tax"
109
+ cal = Smerp::Quotation::ExtendedCalculator.instance(:tax,vval)
110
+ case app
111
+ when "quotation"
112
+ cal.input_field = :total_after_discount
113
+ cal.output_field = [{ total_tax: Smerp::Quotation::TaxCalculator::TaxAmount }, { total_with_tax: Smerp::Quotation::TaxCalculator::ValueWithTax }]
114
+ when "items"
115
+ cal.input_field = :line_total_after_discount
116
+ cal.output_field = [{ tax: Smerp::Quotation::TaxCalculator::TaxAmount }, { line_total_with_tax: Smerp::Quotation::TaxCalculator::ValueWithTax }]
117
+ end
118
+ when "discount"
119
+ cal = Smerp::Quotation::ExtendedCalculator.instance(:discount,vval)
120
+
121
+ case app
122
+ when "quotation"
123
+ cal.input_field = :total
124
+ cal.output_field = [{ total_discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
125
+ when "items"
126
+ cal.input_field = :line_total
127
+ cal.output_field = [{ discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { line_total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
128
+ end
129
+
130
+ #when "roundup"
131
+ # cal = Smerp::Quotation::ExtendedCalculator.instance(:round_up,vval)
132
+
133
+ # case app
134
+ # when "quotation"
135
+ # cal.input_field = :total
136
+ # cal.output_field = [{ total_discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
137
+ # when "items"
138
+ # cal.input_field = :line_total
139
+ # cal.output_field = [{ discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { line_total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
140
+ # end
141
+
142
+
143
+ end
144
+
145
+ if not cal.nil?
146
+
147
+ case app
148
+ when "quotation"
149
+ @quotation.add_priv_ext_cal(cal)
150
+ when "items"
151
+ @quotation.add_ext_cal(cal)
152
+ end
153
+
154
+ @quotation.save
155
+ end
156
+
157
+ redirect_to extended_calculators_quotation_path(@quotation)
158
+ end
159
+
160
+ def edit_extended_calculator
161
+ redirect_to extended_calculators_quotation_path(@quotation)
162
+ end
163
+
164
+ #def update_calculator
165
+ #
166
+ #end
167
+
168
+ #def delete_extended_calculator
169
+ #
170
+ #end
171
+
172
+ def new_product_item
173
+ @quotation_item = QuotationItem.new
174
+ end
175
+
176
+ private
177
+ # Use callbacks to share common setup or constraints between actions.
178
+ def set_quotation
179
+ @quotation = Quotation.find(params[:id])
180
+ end
181
+
182
+ # Only allow a list of trusted parameters through.
183
+ def quotation_params
184
+ #params.fetch(:quotation, {})
185
+ params.require(:quotation).permit(:name, :address, :attention_to, :qdate, :qid)
186
+ end
187
+
188
+ #def calculator_params
189
+ # params.require(:calculator).permit(:cal_type, :applicability, :value)
190
+ #end
191
+ end
192
+ end
@@ -0,0 +1,29 @@
1
+ module Smerp
2
+ module Quotation
3
+ module Engine
4
+ module ApplicationHelper
5
+
6
+ def currency(val)
7
+ number_to_currency(val, unit: "")
8
+ end
9
+
10
+ def short_date(dt)
11
+ dt.strftime("%d-%m-%Y")
12
+ end
13
+
14
+ def link_add(url, text = "Add")
15
+ link_to text, url, class: "btn btn-primary"
16
+ end
17
+
18
+ def link_back(url, text = "Back")
19
+ link_to text, url, class: "btn btn-secondary"
20
+ end
21
+
22
+ def link_edit(url, text= "Edit")
23
+ link_to text, url, class: "btn btn-warning"
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ module Smerp::Quotation::Engine
2
+ module QuotationItemGroupsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Smerp::Quotation::Engine
2
+ module QuotationItemsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Smerp::Quotation::Engine
2
+ module QuotationProductCategoriesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Smerp::Quotation::Engine
2
+ module QuotationProductsHelper
3
+ end
4
+ end
@@ -0,0 +1,81 @@
1
+ module Smerp::Quotation::Engine
2
+ module QuotationsHelper
3
+
4
+ def render_item_tree(itm)
5
+ cont = []
6
+ cont << "<ol type=\"i\">"
7
+ itm.children.each do |c|
8
+ cont << "<div id=\"quotation_items\">"
9
+ cont << render("quotation_item", quotation_item: c)
10
+ cont << "</div>"
11
+
12
+ cont += render_item_tree(c)
13
+ end
14
+ cont << "</ol>"
15
+ cont
16
+ end
17
+
18
+ def render_item_tree_table(itm, level = 1, indx = 0)
19
+ cont = []
20
+ level += 1
21
+ indx = 0
22
+ puts "Inside : #{itm.id.to_s} / #{session[:hide_children_parent_id].include?(itm.id)} / #{session[:hide_children_parent_id]}"
23
+ if session[:hide_children_parent_id].nil? or not session[:hide_children_parent_id].include?(itm.id)
24
+ itm.children.each do |c|
25
+ cont << render("quotation_item", quotation_item: c, level: level, index: indx)
26
+ indx += 1
27
+ cont += render_item_tree_table(c, level, indx)
28
+ end
29
+ end
30
+ cont
31
+
32
+ end
33
+
34
+ def level_marker(level)
35
+ marker = [
36
+ "#DBFED8", #light green
37
+ "#FEF0D8",
38
+ "#D8F8FE",
39
+ "#FED8D8"
40
+ ]
41
+
42
+ marker[level%4]
43
+ end
44
+
45
+ def extended_calculator_name(ec)
46
+ case ec
47
+ when Smerp::Quotation::TaxCalculator
48
+ "Tax Calculator"
49
+ when Smerp::Quotation::DiscountCalculator
50
+ "Discount Calculator"
51
+ when Smerp::Quotation::RoundUpCalculator
52
+ "Round Up Calculator"
53
+ else
54
+ ec
55
+ end
56
+ end
57
+
58
+ def extended_calculator_value_name(ec)
59
+ case ec.params
60
+ when Smerp::Common::FinUtils::Percent
61
+ "#{ec.params.value}%"
62
+ else
63
+ "#{ec.params.value}"
64
+ end
65
+ end
66
+
67
+ def extended_calculator_value_code(ec)
68
+ case ec.params
69
+ when Smerp::Common::FinUtils::Percent
70
+ "#{ec.params.value}p"
71
+ else
72
+ "#{ec.params}"
73
+ end
74
+ end
75
+
76
+ def is_children_hidden?(id)
77
+ not session[:hide_children_parent_id].nil? and session[:hide_children_parent_id].include?(id)
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,8 @@
1
+ module Smerp
2
+ module Quotation
3
+ module Engine
4
+ class ApplicationJob < ActiveJob::Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Smerp
2
+ module Quotation
3
+ module Engine
4
+ class ApplicationMailer < ActionMailer::Base
5
+ default from: "from@example.com"
6
+ layout "mailer"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Smerp
2
+ module Quotation
3
+ module Engine
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+
2
+ require 'smerp/quotation'
3
+
4
+ module Smerp::Quotation::Engine
5
+ #class Quotation < ApplicationRecord
6
+ class Quotation < Smerp::Quotation::ArModel::Quotation
7
+
8
+ validates_presence_of :name
9
+
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+
2
+ require 'acts_as_list'
3
+
4
+ module Smerp::Quotation::Engine
5
+ class QuotationItem < Smerp::Quotation::ArModel::QuotationItem
6
+ #include ActsAsList
7
+ include TR::CondUtils
8
+
9
+ acts_as_list
10
+
11
+ belongs_to :quotation_product, optional: true
12
+
13
+ validates_presence_of :name
14
+
15
+ # can only have one before_save hook
16
+ # Have to override the parent method and call the parent
17
+ # method instead
18
+ # This method shall be activated by parent's
19
+ # before_save hook
20
+ def update_total
21
+
22
+ if not self.quotation_product_id.nil?
23
+ prod = QuotationProduct.find(self.quotation_product_id)
24
+ self.name = prod.name
25
+ self.unit_price = prod.unit_price
26
+ self.unit = prod.unit if is_empty?(self.unit)
27
+ end
28
+
29
+ # call parent update_total
30
+ super
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+
2
+ require 'acts_as_list'
3
+
4
+ module Smerp::Quotation::Engine
5
+ class QuotationItemGroup < Smerp::Quotation::ArModel::QuotationItemGroup
6
+
7
+ acts_as_list
8
+
9
+ end
10
+ end
@@ -0,0 +1,30 @@
1
+ module Smerp::Quotation::Engine
2
+ class QuotationProduct < ApplicationRecord
3
+
4
+ state_machine initial: :active do
5
+
6
+ event :suspend do
7
+ transition :active => :inactive
8
+ end
9
+
10
+ end
11
+
12
+ Cat_Hardware = 1
13
+ Cat_License = 2
14
+ Cat_Resource = 3
15
+ Cat_Services = 4
16
+
17
+ belongs_to :quotation_product_category
18
+
19
+ has_many :quotation_items
20
+
21
+ def QuotationProduct.active_products(cat = nil)
22
+ if cat.nil?
23
+ QuotationProduct.where(["state = 'active'"])
24
+ else
25
+ QuotationProduct.where(["state = 'active' and quotation_product_category_id = ?", cat])
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ module Smerp::Quotation::Engine
2
+ class QuotationProductCategory < ApplicationRecord
3
+
4
+ has_many :quotation_products
5
+
6
+ def QuotationProductCategory.active_products
7
+ QuotationProductCategory.where(["state = 'active'"])
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Smerp quotation engine</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "smerp/quotation/engine/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,48 @@
1
+
2
+
3
+ <% parent = (defined?(group).nil? ? @quotation : group) %>
4
+ <% url = (defined?(group).nil? ? quotation_quotation_items_path(@quotation) : quotation_item_group_quotation_items_path(group)) %>
5
+
6
+ <%= form_with(model: @qi, url: url, method: :post) do |f| %>
7
+ <% if @qi.errors.any? %>
8
+ <div style="color: red">
9
+ <h2><%= pluralize(@qi.errors.count, "error") %> prohibited this quotation_item from being saved:</h2>
10
+
11
+ <ul>
12
+ <% @qi.errors.each do |error| %>
13
+ <li><%= error.full_message %></li>
14
+ <% end %>
15
+ </ul>
16
+ </div>
17
+ <% end %>
18
+
19
+ <% if not defined?(group).nil? %>
20
+ <%= f.hidden_field :quotation_item_group_id, value: group.id %>
21
+ <% else %>
22
+ <%= f.hidden_field :quotation_id, value: @quotation.id %>
23
+ <% end %>
24
+
25
+ <div class="row pb-1">
26
+ <div class="col-10">
27
+ <%= f.select :parent_is, @parent, {}, class: "form-control" %>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="row pb-1">
32
+ <div class="col-6"><%= f.text_field :name, placeholder: (defined?(group).nil?) ? "Item" : "Sub Item Under Group #{group.name}", class: "form-control" %></div>
33
+ <div class="col-1"><%= f.text_field :quantity, placeholder: "Quantity", class: "form-control" %></div>
34
+ <div class="col-1"><%= f.text_field :unit, placeholder: "Unit", class: "form-control" %></div>
35
+ <div class="col-1"><%= f.text_field :unit_price, placeholder: "Unit Price", class: "form-control" %></div>
36
+ <div class="col-1">
37
+ <%= f.text_field :discount, placeholder: "Discount", class: "form-control" %>
38
+ <%= f.select :discount_unit, [["Percent","percent"],["Value","value"]], {}, class: "form-control" %>
39
+ </div>
40
+ <div class="col-1">
41
+ <%= f.text_field :tax, placeholder: "Tax", class: "form-control" %>
42
+ <%= f.select :tax_unit, [["Percent","percent"],["Value","value"]], {}, class: "form-control" %>
43
+ </div>
44
+ <div class="col-1"><%= f.submit "Create" %></div>
45
+ </div>
46
+
47
+ <% end %>
48
+
@@ -0,0 +1,36 @@
1
+
2
+ <h2>Extended Calculator</h2>
3
+
4
+ <% case @target
5
+ when Smerp::Quotation::ArModel::Quotation %>
6
+ <table class="table">
7
+ <tr>
8
+ <th>Quotation</th>
9
+ <td><%= @target.name %></td>
10
+ </tr>
11
+ </table>
12
+ <% end %>
13
+
14
+ <h4>Current Defined Calculator (Applicable for all items)</h4>
15
+ <table>
16
+ <% @extCals.each do |ec| %>
17
+ <tr>
18
+ <td><%= ec %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <%= link_to "Add Item Calculator", add_extended_calculator_quotation_path(@target), class: "btn btn-primary" %>
24
+
25
+ <h4>Current Defined Calculator (Applicable for quotation only)</h4>
26
+ <table>
27
+ <% @privExtCals.each do |ec| %>
28
+ <tr>
29
+ <td><%= ec %></td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+
34
+ <%= link_to "Add Quotation Calculator", add_extended_calculator_quotation_path(@target), class: "btn btn-primary" %>
35
+
36
+
@@ -0,0 +1,17 @@
1
+ <%= form_with(model: [@quotation,quotation_item_group]) do |form| %>
2
+ <% if quotation_item_group.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(quotation_item_group.errors.count, "error") %> prohibited this quotation_item_group from being saved:</h2>
5
+
6
+ <ul>
7
+ <% quotation_item_group.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.submit %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <div id="<%= dom_id quotation_item_group %>">
2
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Editing quotation item group</h1>
2
+
3
+ <%= render "form", quotation_item_group: @quotation_item_group %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this quotation item group", @quotation_item_group %> |
9
+ <%= link_to "Back to quotation item groups", quotation_item_groups_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Quotation item groups</h1>
4
+
5
+ <div id="quotation_item_groups">
6
+ <% @quotation_item_groups.each do |quotation_item_group| %>
7
+ <%= render quotation_item_group %>
8
+ <p>
9
+ <%= link_to "Show this quotation item group", quotation_item_group %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New quotation item group", new_quotation_item_group_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New quotation item group</h1>
2
+
3
+ <%= render "form", quotation_item_group: @quotation_item_group %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back", @quotation, class: 'btn btn-secondary' %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @quotation_item_group %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this quotation item group", edit_quotation_item_group_path(@quotation_item_group) %> |
7
+ <%= link_to "Back to quotation item groups", quotation_item_groups_path %>
8
+
9
+ <%= button_to "Destroy this quotation item group", @quotation_item_group, method: :delete %>
10
+ </div>