smerp-quotation-engine 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +10 -0
- data/app/assets/config/smerp_quotation_engine_manifest.js +1 -0
- data/app/assets/stylesheets/smerp/quotation/engine/application.css +15 -0
- data/app/controllers/smerp/quotation/engine/application_controller.rb +9 -0
- data/app/controllers/smerp/quotation/engine/quotation_item_groups_controller.rb +70 -0
- data/app/controllers/smerp/quotation/engine/quotation_items_controller.rb +237 -0
- data/app/controllers/smerp/quotation/engine/quotation_product_categories_controller.rb +60 -0
- data/app/controllers/smerp/quotation/engine/quotation_products_controller.rb +60 -0
- data/app/controllers/smerp/quotation/engine/quotations_controller.rb +192 -0
- data/app/helpers/smerp/quotation/engine/application_helper.rb +29 -0
- data/app/helpers/smerp/quotation/engine/quotation_item_groups_helper.rb +4 -0
- data/app/helpers/smerp/quotation/engine/quotation_items_helper.rb +4 -0
- data/app/helpers/smerp/quotation/engine/quotation_product_categories_helper.rb +4 -0
- data/app/helpers/smerp/quotation/engine/quotation_products_helper.rb +4 -0
- data/app/helpers/smerp/quotation/engine/quotations_helper.rb +81 -0
- data/app/jobs/smerp/quotation/engine/application_job.rb +8 -0
- data/app/mailers/smerp/quotation/engine/application_mailer.rb +10 -0
- data/app/models/smerp/quotation/engine/application_record.rb +9 -0
- data/app/models/smerp/quotation/engine/quotation.rb +11 -0
- data/app/models/smerp/quotation/engine/quotation_item.rb +34 -0
- data/app/models/smerp/quotation/engine/quotation_item_group.rb +10 -0
- data/app/models/smerp/quotation/engine/quotation_product.rb +30 -0
- data/app/models/smerp/quotation/engine/quotation_product_category.rb +11 -0
- data/app/views/layouts/smerp/quotation/engine/application.html.erb +15 -0
- data/app/views/smerp/quotation/engine/_new_quotation_item_form.html.erb +48 -0
- data/app/views/smerp/quotation/engine/extended_calculators/extended_calculators.html.erb +36 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/_form.html.erb +17 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/_quotation_item_group.html.erb +2 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/edit.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/index.html.erb +14 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/new.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_item_groups/show.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotation_items/_form.html.erb +53 -0
- data/app/views/smerp/quotation/engine/quotation_items/_product_item_form.html.erb +47 -0
- data/app/views/smerp/quotation/engine/quotation_items/_quotation_item.html.erb +17 -0
- data/app/views/smerp/quotation/engine/quotation_items/edit.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_items/index.html.erb +14 -0
- data/app/views/smerp/quotation/engine/quotation_items/new.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_items/new_product_item.html.erb +7 -0
- data/app/views/smerp/quotation/engine/quotation_items/show.html.erb +76 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/_form.html.erb +33 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/_quotation_product_category.html.erb +17 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/edit.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/index.html.erb +14 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/new.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_product_categories/show.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotation_products/_form.html.erb +41 -0
- data/app/views/smerp/quotation/engine/quotation_products/_quotation_product.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_products/edit.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotation_products/index.html.erb +19 -0
- data/app/views/smerp/quotation/engine/quotation_products/new.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotation_products/show.html.erb +32 -0
- data/app/views/smerp/quotation/engine/quotations/_form.html.erb +49 -0
- data/app/views/smerp/quotation/engine/quotations/_new_group_form.html.erb +24 -0
- data/app/views/smerp/quotation/engine/quotations/_product_item_form.html.erb +47 -0
- data/app/views/smerp/quotation/engine/quotations/_quotation.html.erb +10 -0
- data/app/views/smerp/quotation/engine/quotations/_quotation_item.html.erb +96 -0
- data/app/views/smerp/quotation/engine/quotations/edit.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotations/extended_calculators.html.erb +36 -0
- data/app/views/smerp/quotation/engine/quotations/index.html.erb +21 -0
- data/app/views/smerp/quotation/engine/quotations/new.html.erb +9 -0
- data/app/views/smerp/quotation/engine/quotations/new_extended_calculator.html.erb +65 -0
- data/app/views/smerp/quotation/engine/quotations/new_product_item.html.erb +7 -0
- data/app/views/smerp/quotation/engine/quotations/show.html.erb +151 -0
- data/config/routes.rb +50 -0
- data/db/migrate/20220929020407_create_smerp_quotation_engine_quotation_products.rb +16 -0
- data/db/migrate/20220929041715_create_smerp_quotation_engine_quotation_product_categories.rb +12 -0
- data/db/migrate/20220929074438_link_product_to_item.rb +5 -0
- data/db/seeds.rb +36 -0
- data/lib/smerp/quotation/engine/engine.rb +40 -0
- data/lib/smerp/quotation/engine/version.rb +7 -0
- data/lib/smerp/quotation/engine.rb +10 -0
- data/lib/tasks/smerp/quotation/engine_tasks.rake +4 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d68cf8a3a09b4bb085a2d0e89da3fc9419fc4c94d7df7f3631265f1015b2131f
|
4
|
+
data.tar.gz: 2f087046539ac9af424f26e1cdd0348276846da5ce3e344a988be5e2fad5a62c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14f91b006501d88f4486798f0041a8081479fe937e3125e6953a2db9ffe4c87e0730206309555cd77d19663fe327ed05132998f874c29693aa7f322600aff72a
|
7
|
+
data.tar.gz: '038b254cdacb62dbefba42717a5f1150fee5a299e8c932b9f836e7f40a99e3c5d0ee971215389fd6f843de4cb475358c0f7f979ca053d66a367f57fae6cae7ef'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2022 Ian
|
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,28 @@
|
|
1
|
+
# Smerp::Quotation::Engine
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "smerp-quotation-engine"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install smerp-quotation-engine
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
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 @@
|
|
1
|
+
//= link_directory ../stylesheets/smerp/quotation/engine .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Smerp::Quotation::Engine
|
2
|
+
class QuotationItemGroupsController < ApplicationController
|
3
|
+
before_action :find_quotation
|
4
|
+
before_action :set_quotation_item_group, only: %i[ show edit update destroy ]
|
5
|
+
|
6
|
+
def find_quotation
|
7
|
+
if params[:quotation_item_group].nil?
|
8
|
+
@quotation = Quotation.find(params[:quotation_id])
|
9
|
+
else
|
10
|
+
@quotation = Quotation.find(params[:quotation_item_group][:quotation_id])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /quotation_item_groups
|
15
|
+
def index
|
16
|
+
@quotation_item_groups = QuotationItemGroup.all
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /quotation_item_groups/1
|
20
|
+
def show
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /quotation_item_groups/new
|
24
|
+
def new
|
25
|
+
@quotation_item_group = QuotationItemGroup.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /quotation_item_groups/1/edit
|
29
|
+
def edit
|
30
|
+
end
|
31
|
+
|
32
|
+
# POST /quotation_item_groups
|
33
|
+
def create
|
34
|
+
@quotation_item_group = QuotationItemGroup.new(quotation_item_group_params)
|
35
|
+
|
36
|
+
if @quotation_item_group.save
|
37
|
+
redirect_to @quotation, notice: "Quotation item group was successfully created."
|
38
|
+
else
|
39
|
+
render :new, status: :unprocessable_entity
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# PATCH/PUT /quotation_item_groups/1
|
44
|
+
def update
|
45
|
+
if @quotation_item_group.update(quotation_item_group_params)
|
46
|
+
redirect_to @quotation, notice: "Quotation item group was successfully updated."
|
47
|
+
else
|
48
|
+
render :edit, status: :unprocessable_entity
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# DELETE /quotation_item_groups/1
|
53
|
+
def destroy
|
54
|
+
@quotation_item_group.destroy
|
55
|
+
redirect_to @quotation, notice: "Quotation item group was successfully destroyed."
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
# Use callbacks to share common setup or constraints between actions.
|
60
|
+
def set_quotation_item_group
|
61
|
+
@quotation_item_group = QuotationItemGroup.find(params[:id])
|
62
|
+
end
|
63
|
+
|
64
|
+
# Only allow a list of trusted parameters through.
|
65
|
+
def quotation_item_group_params
|
66
|
+
#params.fetch(:quotation_item_group, {})
|
67
|
+
params.require(:quotation_item_group).permit(:quotation_id, :name)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
module Smerp::Quotation::Engine
|
2
|
+
class QuotationItemsController < ApplicationController
|
3
|
+
|
4
|
+
include TR::CondUtils
|
5
|
+
|
6
|
+
before_action :find_parent
|
7
|
+
before_action :set_quotation_item, only: %i[ show edit update destroy apply_discount remove_tax add_sub_item apply_tax hide_children show_children new_product_item ]
|
8
|
+
|
9
|
+
def find_parent
|
10
|
+
if params[:quotation_item].nil?
|
11
|
+
qid = params[:quotation_id]
|
12
|
+
gid = params[:quotation_item_group_id]
|
13
|
+
else
|
14
|
+
qid = params[:quotation_item][:quotation_id]
|
15
|
+
gid = params[:quotation_item][:quotation_item_group_id]
|
16
|
+
end
|
17
|
+
|
18
|
+
if not_empty?(qid)
|
19
|
+
@quotation = Quotation.find(qid)
|
20
|
+
elsif not_empty?(gid)
|
21
|
+
@group = QuotationItemGroup.find(gid)
|
22
|
+
@quotation = @group.quotation
|
23
|
+
else
|
24
|
+
# use sprangly as the route allow direct access without parent
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET /quotation_items
|
30
|
+
def index
|
31
|
+
@quotation_items = QuotationItem.all
|
32
|
+
end
|
33
|
+
|
34
|
+
# GET /quotation_items/1
|
35
|
+
def show
|
36
|
+
end
|
37
|
+
|
38
|
+
# GET /quotation_items/new
|
39
|
+
def new
|
40
|
+
@quotation_item = QuotationItem.new
|
41
|
+
end
|
42
|
+
|
43
|
+
# GET /quotation_items/1/edit
|
44
|
+
def edit
|
45
|
+
end
|
46
|
+
|
47
|
+
# POST /quotation_items
|
48
|
+
def create
|
49
|
+
@quotation_item = QuotationItem.new(quotation_item_params)
|
50
|
+
|
51
|
+
if @quotation_item.save
|
52
|
+
redirect_to @quotation, notice: "Quotation item was successfully created."
|
53
|
+
else
|
54
|
+
render :new, status: :unprocessable_entity
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# PATCH/PUT /quotation_items/1
|
59
|
+
def update
|
60
|
+
if @quotation_item.update(quotation_item_params)
|
61
|
+
redirect_to @quotation, notice: "Quotation item was successfully updated."
|
62
|
+
else
|
63
|
+
render :edit, status: :unprocessable_entity
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# DELETE /quotation_items/1
|
68
|
+
def destroy
|
69
|
+
q = @quotation_item.quotation.clone
|
70
|
+
@quotation_item.destroy
|
71
|
+
|
72
|
+
redirect_to quotation_url(q), notice: "Quotation item was successfully destroyed."
|
73
|
+
end
|
74
|
+
|
75
|
+
def apply_discount
|
76
|
+
val = params[:quotation_item][:discount]
|
77
|
+
target = params[:quotation_item][:discount_on]
|
78
|
+
ecid = params[:quotation_item][:ecid]
|
79
|
+
|
80
|
+
if not @quotation_item.attributes.keys.include?(target)
|
81
|
+
raise "Discount target '#{target}' not a valid field"
|
82
|
+
end
|
83
|
+
|
84
|
+
indx = val =~ /p/
|
85
|
+
if not indx.nil?
|
86
|
+
vv = val[0...indx]
|
87
|
+
vf = vv.to_f
|
88
|
+
|
89
|
+
if not_empty?(ecid)
|
90
|
+
@quotation_item.update_ext_cal(ecid, params: vf.percent)
|
91
|
+
else
|
92
|
+
cal = Smerp::Quotation::ExtendedCalculator.instance(:discount, vf.percent)
|
93
|
+
cal.input_field = target
|
94
|
+
cal.output_field = [{ discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { line_total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
|
95
|
+
@quotation_item.add_ext_cal(cal)
|
96
|
+
end
|
97
|
+
|
98
|
+
if @quotation_item.save
|
99
|
+
redirect_to quotation_url(@quotation_item.quotation), notice: "Discount applied"
|
100
|
+
else
|
101
|
+
redirect_to quotation_url(@quotation_item.quotation), error: "Quotation item update field. Error was : #{@quotation_item.errors}"
|
102
|
+
end
|
103
|
+
|
104
|
+
else
|
105
|
+
vf = val.to_f
|
106
|
+
|
107
|
+
if not_empty?(ecid)
|
108
|
+
@quotation_item.update_ext_cal(ecid, params: vf)
|
109
|
+
else
|
110
|
+
cal = Smerp::Quotation::ExtendedCalculator.instance(:discount, vf)
|
111
|
+
cal.input_field = target
|
112
|
+
cal.output_field = [{ discount: Smerp::Quotation::DiscountCalculator::DiscountedAmount }, { line_total_after_discount: Smerp::Quotation::DiscountCalculator::ValueAfterDiscount }]
|
113
|
+
@quotation_item.add_ext_cal(cal)
|
114
|
+
end
|
115
|
+
|
116
|
+
if @quotation_item.save
|
117
|
+
redirect_to quotation_url(@quotation_item.quotation), notice: "Discount applied"
|
118
|
+
else
|
119
|
+
redirect_to quotation_url(@quotation_item.quotation), error: "Quotation item update field. Error was : #{@quotation_item.errors}"
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
def apply_tax
|
127
|
+
val = params[:quotation_item][:tax]
|
128
|
+
ecid = params[:quotation_item][:ecid]
|
129
|
+
|
130
|
+
indx = val =~ /p/
|
131
|
+
if not indx.nil?
|
132
|
+
vv = val[0...indx]
|
133
|
+
vf = vv.to_f
|
134
|
+
|
135
|
+
if not_empty?(ecid)
|
136
|
+
@quotation_item.update_ext_cal(ecid, params: vf.percent)
|
137
|
+
else
|
138
|
+
cal = Smerp::Quotation::ExtendedCalculator.instance(:tax, vf.percent)
|
139
|
+
cal.input_field = :line_total_after_discount
|
140
|
+
cal.output_field = [{ tax: Smerp::Quotation::TaxCalculator::TaxAmount }, { line_total_with_tax: Smerp::Quotation::TaxCalculator::ValueWithTax }]
|
141
|
+
@quotation_item.add_ext_cal(cal)
|
142
|
+
end
|
143
|
+
|
144
|
+
if @quotation_item.save
|
145
|
+
redirect_to quotation_url(@quotation_item.quotation), notice: "Tax applied"
|
146
|
+
else
|
147
|
+
redirect_to quotation_url(@quotation_item.quotation), error: "Quotation item update field. Error was : #{@quotation_item.errors}"
|
148
|
+
end
|
149
|
+
|
150
|
+
else
|
151
|
+
vf = val.to_f
|
152
|
+
|
153
|
+
if not_empty?(ecid)
|
154
|
+
@quotation_item.update_ext_cal(ecid, params: vf)
|
155
|
+
else
|
156
|
+
cal = Smerp::Quotation::ExtendedCalculator.instance(:tax, vf)
|
157
|
+
cal.input_field = target
|
158
|
+
cal.output_field = [{ tax: Smerp::Quotation::TaxCalculator::TaxAmount }, { line_total_with_tax: Smerp::Quotation::TaxCalculator::ValueWithTax }]
|
159
|
+
@quotation_item.add_ext_cal(cal)
|
160
|
+
end
|
161
|
+
|
162
|
+
if @quotation_item.save
|
163
|
+
redirect_to quotation_url(@quotation_item.quotation), notice: "Tax applied"
|
164
|
+
else
|
165
|
+
redirect_to quotation_url(@quotation_item.quotation), error: "Quotation item update field. Error was : #{@quotation_item.errors}"
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
def remove_tax
|
173
|
+
if not_empty?(@quotation_item.extended_calculators)
|
174
|
+
cal = YAML.load(@quotation_item.extended_calculators)
|
175
|
+
# cannot directly remove as there is current tax value calculated before
|
176
|
+
# If remove means the previous value will not get updated.
|
177
|
+
# Provbably later device a mechanism to remove after update
|
178
|
+
cal[:local].each do |c|
|
179
|
+
c.params = 0.percent if c.is_a?(Smerp::Quotation::TaxCalculator)
|
180
|
+
end
|
181
|
+
cal[:quotation].each do |c|
|
182
|
+
c.params = 0.percent if c.is_a?(Smerp::Quotation::TaxCalculator)
|
183
|
+
end
|
184
|
+
@quotation_item.extended_calculators = YAML.dump(cal)
|
185
|
+
@quotation_item.save
|
186
|
+
end
|
187
|
+
|
188
|
+
redirect_to quotation_url(@quotation_item.quotation), notice: "Tax removed for '#{@quotation_item.name}'"
|
189
|
+
end
|
190
|
+
|
191
|
+
def add_sub_item
|
192
|
+
@parent = @quotation_item
|
193
|
+
@quotation = @parent.quotation
|
194
|
+
|
195
|
+
@quotation_item = QuotationItem.new
|
196
|
+
@quotation_item.parent = @parent
|
197
|
+
@quotation_item.quotation = @quotation
|
198
|
+
|
199
|
+
render "new", quotation_item: @quotation_item, quotation: @quotation
|
200
|
+
end
|
201
|
+
|
202
|
+
def hide_children
|
203
|
+
session[:hide_children_parent_id] = [] if session[:hide_children_parent_id].nil?
|
204
|
+
session[:hide_children_parent_id] << @quotation_item.id
|
205
|
+
session[:hide_children_parent_id].uniq!
|
206
|
+
|
207
|
+
redirect_to quotation_url(@quotation_item.quotation)
|
208
|
+
end
|
209
|
+
|
210
|
+
def show_children
|
211
|
+
if not session[:hide_children_parent_id].nil?
|
212
|
+
session[:hide_children_parent_id].delete_if { |i| i == @quotation_item.id }
|
213
|
+
end
|
214
|
+
|
215
|
+
redirect_to quotation_url(@quotation_item.quotation)
|
216
|
+
end
|
217
|
+
|
218
|
+
def new_product_item
|
219
|
+
@parent = @quotation_item
|
220
|
+
@quotation = @quotation_item.quotation
|
221
|
+
|
222
|
+
@quotation_item = QuotationItem.new
|
223
|
+
end
|
224
|
+
|
225
|
+
private
|
226
|
+
# Use callbacks to share common setup or constraints between actions.
|
227
|
+
def set_quotation_item
|
228
|
+
@quotation_item = QuotationItem.find(params[:id])
|
229
|
+
end
|
230
|
+
|
231
|
+
# Only allow a list of trusted parameters through.
|
232
|
+
def quotation_item_params
|
233
|
+
#params.fetch(:quotation_item, {})
|
234
|
+
params.require(:quotation_item).permit(:quotation_id, :name, :quantity, :unit, :unit_price, :discount, :discount_unit, :tax, :tax_unit, :quotation_item_group_id, :ecid, :parent_id, :quotation_product_id )
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Smerp::Quotation::Engine
|
2
|
+
class QuotationProductCategoriesController < ApplicationController
|
3
|
+
before_action :set_quotation_product_category, only: %i[ show edit update destroy ]
|
4
|
+
|
5
|
+
# GET /quotation_product_categories
|
6
|
+
def index
|
7
|
+
@quotation_product_categories = QuotationProductCategory.all
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /quotation_product_categories/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /quotation_product_categories/new
|
15
|
+
def new
|
16
|
+
@quotation_product_category = QuotationProductCategory.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /quotation_product_categories/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /quotation_product_categories
|
24
|
+
def create
|
25
|
+
@quotation_product_category = QuotationProductCategory.new(quotation_product_category_params)
|
26
|
+
|
27
|
+
if @quotation_product_category.save
|
28
|
+
redirect_to @quotation_product_category, notice: "Quotation product category was successfully created."
|
29
|
+
else
|
30
|
+
render :new, status: :unprocessable_entity
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /quotation_product_categories/1
|
35
|
+
def update
|
36
|
+
if @quotation_product_category.update(quotation_product_category_params)
|
37
|
+
redirect_to @quotation_product_category, notice: "Quotation product category was successfully updated."
|
38
|
+
else
|
39
|
+
render :edit, status: :unprocessable_entity
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE /quotation_product_categories/1
|
44
|
+
def destroy
|
45
|
+
@quotation_product_category.destroy
|
46
|
+
redirect_to quotation_product_categories_url, notice: "Quotation product category was successfully destroyed."
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
# Use callbacks to share common setup or constraints between actions.
|
51
|
+
def set_quotation_product_category
|
52
|
+
@quotation_product_category = QuotationProductCategory.find(params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Only allow a list of trusted parameters through.
|
56
|
+
def quotation_product_category_params
|
57
|
+
params.require(:quotation_product_category).permit(:name, :notes, :state)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Smerp::Quotation::Engine
|
2
|
+
class QuotationProductsController < ApplicationController
|
3
|
+
before_action :set_quotation_product, only: %i[ show edit update destroy ]
|
4
|
+
|
5
|
+
# GET /quotation_products
|
6
|
+
def index
|
7
|
+
@quotation_products = QuotationProduct.all
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /quotation_products/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /quotation_products/new
|
15
|
+
def new
|
16
|
+
@quotation_product = QuotationProduct.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /quotation_products/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /quotation_products
|
24
|
+
def create
|
25
|
+
@quotation_product = QuotationProduct.new(quotation_product_params)
|
26
|
+
|
27
|
+
if @quotation_product.save
|
28
|
+
redirect_to @quotation_product, notice: "Quotation product was successfully created."
|
29
|
+
else
|
30
|
+
render :new, status: :unprocessable_entity
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /quotation_products/1
|
35
|
+
def update
|
36
|
+
if @quotation_product.update(quotation_product_params)
|
37
|
+
redirect_to @quotation_product, notice: "Quotation product was successfully updated."
|
38
|
+
else
|
39
|
+
render :edit, status: :unprocessable_entity
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE /quotation_products/1
|
44
|
+
def destroy
|
45
|
+
@quotation_product.destroy
|
46
|
+
redirect_to quotation_products_url, notice: "Quotation product was successfully destroyed."
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
# Use callbacks to share common setup or constraints between actions.
|
51
|
+
def set_quotation_product
|
52
|
+
@quotation_product = QuotationProduct.find(params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Only allow a list of trusted parameters through.
|
56
|
+
def quotation_product_params
|
57
|
+
params.require(:quotation_product).permit(:name, :notes, :quotation_product_category_id, :state, :unit, :unit_price)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|