smerp-quotation-engine 0.2.5 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/smerp/quotation/engine/quotations_controller.rb +12 -1
- data/app/helpers/smerp/quotation/engine/quotations_helper.rb +22 -0
- data/app/models/smerp/quotation/engine/quotation.rb +13 -0
- data/app/models/smerp/quotation/engine/quotation_item.rb +2 -0
- data/app/models/smerp/quotation/engine/quotation_product.rb +5 -0
- data/app/models/smerp/quotation/engine/quotation_product_category.rb +1 -1
- data/app/views/smerp/quotation/engine/quotations/resources_allocation_summary.html.erb +62 -0
- data/app/views/smerp/quotation/engine/quotations/show.html.erb +4 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20221005090104_add_position_to_quotation_products.rb +6 -0
- data/lib/smerp/quotation/engine/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8546e16b5580393b492285b0e9a1b6ad03db1b07b0d1c020d793c5d072cc7c2d
|
4
|
+
data.tar.gz: 6f4f31d01f493c52c75ef4efe931e53803a737a9b07ca5447e89a0867d00106d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22cf2555a4422d10f0e01a9e499bd41d76ba74b26f4f0b900f8a11a5382bdce58c6aba09e6c93f64615cd757e023c36f3cfdb1e1b93ffc12abfb025ad1131ca
|
7
|
+
data.tar.gz: bd09f9344fd1d7c9cce91d0958e953994dfcdc7e92e60be97c44e5a708a82c62e185c4e12056e26377b63ff657786d7e176386911735bc065c65682a55090567
|
@@ -3,7 +3,7 @@ require 'smerp/quotation'
|
|
3
3
|
|
4
4
|
module Smerp::Quotation::Engine
|
5
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 ]
|
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 resources_allocation_summary ]
|
7
7
|
|
8
8
|
# GET /quotations
|
9
9
|
def index
|
@@ -173,6 +173,17 @@ module Smerp::Quotation::Engine
|
|
173
173
|
@quotation_item = QuotationItem.new
|
174
174
|
end
|
175
175
|
|
176
|
+
def resources_allocation_summary
|
177
|
+
@resTable = {}
|
178
|
+
@quotation.quotation_items_allocated_resources.each do |qi|
|
179
|
+
prodId = qi.quotation_product.name
|
180
|
+
@resTable[prodId] = { total: 0.0, rate: qi.quotation_product.unit_price.to_f } if @resTable[prodId].nil?
|
181
|
+
@resTable[prodId][:total] += qi.quantity
|
182
|
+
|
183
|
+
@resTable[prodId][:total_rate] = @resTable[prodId][:total] * @resTable[prodId][:rate]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
176
187
|
private
|
177
188
|
# Use callbacks to share common setup or constraints between actions.
|
178
189
|
def set_quotation
|
@@ -76,5 +76,27 @@ module Smerp::Quotation::Engine
|
|
76
76
|
not session[:hide_children_parent_id].nil? and session[:hide_children_parent_id].include?(id)
|
77
77
|
end
|
78
78
|
|
79
|
+
def days_to_human_readable(days)
|
80
|
+
if days > 20
|
81
|
+
months = (days/20).to_i
|
82
|
+
monthDays = months*20
|
83
|
+
balMonthDay = days - monthDays
|
84
|
+
|
85
|
+
weeks = (balMonthDay/5).to_i
|
86
|
+
weekDays = weeks*5
|
87
|
+
days = (balMonthDay - weekDays).to_i
|
88
|
+
|
89
|
+
if days > 0
|
90
|
+
"#{months} month(s), #{weeks} week(s) and #{days} days (Calendar Based)"
|
91
|
+
elsif balMonthDay > 0
|
92
|
+
"#{months} month(s) and #{weeks} week(s) (Calendar Based)"
|
93
|
+
else
|
94
|
+
"#{months} month(s)"
|
95
|
+
end
|
96
|
+
else
|
97
|
+
"#{days} calendar day(s)"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
79
101
|
end
|
80
102
|
end
|
@@ -7,5 +7,18 @@ module Smerp::Quotation::Engine
|
|
7
7
|
|
8
8
|
validates_presence_of :name
|
9
9
|
|
10
|
+
has_many :quotation_items
|
11
|
+
|
12
|
+
def quotation_items_allocated_resources
|
13
|
+
|
14
|
+
resType = QuotationProductCategory.where(["name = ?","Resources"]).first
|
15
|
+
|
16
|
+
qpIds = QuotationProduct.active_products(resType.id).order(:position).select(:id)
|
17
|
+
|
18
|
+
# all quotation items that carries the resources link
|
19
|
+
self.quotation_items.where({ quotation_product_id: qpIds })
|
20
|
+
|
21
|
+
end
|
22
|
+
|
10
23
|
end
|
11
24
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<h3>Resources Allocation Summary</h3>
|
4
|
+
|
5
|
+
<table class="table">
|
6
|
+
|
7
|
+
<tr>
|
8
|
+
<th>Quotation ID</th>
|
9
|
+
<th>Customer</th>
|
10
|
+
<th class="text-center">Date</th>
|
11
|
+
<th>Status</th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<div <%= dom_id @quotation %>>
|
15
|
+
<%= render "quotation", quotation: @quotation %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
</table>
|
19
|
+
|
20
|
+
<table class="table">
|
21
|
+
<tr style="background-color: lightgrey">
|
22
|
+
<th></th>
|
23
|
+
<th>Role</th>
|
24
|
+
<th colspan="2" class="text-center">Total Allocated Mandays</th>
|
25
|
+
<th colspan="2" class="text-center">Total Price</th>
|
26
|
+
</tr>
|
27
|
+
|
28
|
+
<% cnt = 0 %>
|
29
|
+
<% ttlMd = 0 %>
|
30
|
+
<% ttlPrice = 0 %>
|
31
|
+
<% @resTable.each do |res, val| %>
|
32
|
+
<tr>
|
33
|
+
<td><%= cnt += 1 %>.</td>
|
34
|
+
<td><%= res %></td>
|
35
|
+
<td class="text-end"><%= val[:total] %></td>
|
36
|
+
<td style="font-style: italic">
|
37
|
+
(Roughly <%= days_to_human_readable(val[:total]) %>)
|
38
|
+
</td>
|
39
|
+
<td class="text-end">
|
40
|
+
<%= currency(val[:total_rate]) %>
|
41
|
+
</td>
|
42
|
+
<td></td>
|
43
|
+
</tr>
|
44
|
+
<% ttlMd += val[:total] %>
|
45
|
+
<% ttlPrice += val[:total_rate] %>
|
46
|
+
<% end %>
|
47
|
+
|
48
|
+
<tr style="font-weight: bold; background-color: #8EFEC1">
|
49
|
+
<td></td>
|
50
|
+
<td class="text-end">Grand Total : </td>
|
51
|
+
<td class="text-end"><%= ttlMd %></td>
|
52
|
+
<td style="font-style: italic">(Roughly <%= days_to_human_readable(ttlMd) %>)</td>
|
53
|
+
<td class="text-end"><%= currency(ttlPrice) %></td>
|
54
|
+
<td style="font-style: italic;"><%= ttlPrice.percent_of(@quotation.total, 2) %>%</td>
|
55
|
+
</tr>
|
56
|
+
|
57
|
+
</table>
|
58
|
+
|
59
|
+
|
60
|
+
<%= link_back quotation_url(@quotation) %>
|
61
|
+
|
62
|
+
|
@@ -35,6 +35,10 @@
|
|
35
35
|
<%= button_to "Delete Quotation", @quotation, method: :delete, class: "btn btn-danger" %>
|
36
36
|
</div>
|
37
37
|
|
38
|
+
<div class="pt-2">
|
39
|
+
<%= link_to "Resources Summary", resources_allocation_summary_quotation_path(@quotation), class: "btn btn-secondary" %>
|
40
|
+
</div>
|
41
|
+
|
38
42
|
<table class="table">
|
39
43
|
|
40
44
|
<tr>
|
data/config/routes.rb
CHANGED
@@ -4,6 +4,7 @@ Smerp::Quotation::Engine::Engine.routes.draw do
|
|
4
4
|
resources :quotation_products
|
5
5
|
|
6
6
|
resources :quotations do
|
7
|
+
|
7
8
|
resources :quotation_item_groups do
|
8
9
|
resources :quotation_items
|
9
10
|
end
|
@@ -24,6 +25,8 @@ Smerp::Quotation::Engine::Engine.routes.draw do
|
|
24
25
|
|
25
26
|
get :new_product_item
|
26
27
|
|
28
|
+
get :resources_allocation_summary
|
29
|
+
|
27
30
|
end
|
28
31
|
|
29
32
|
end # quotations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smerp-quotation-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -190,11 +190,13 @@ files:
|
|
190
190
|
- app/views/smerp/quotation/engine/quotations/new.html.erb
|
191
191
|
- app/views/smerp/quotation/engine/quotations/new_extended_calculator.html.erb
|
192
192
|
- app/views/smerp/quotation/engine/quotations/new_product_item.html.erb
|
193
|
+
- app/views/smerp/quotation/engine/quotations/resources_allocation_summary.html.erb
|
193
194
|
- app/views/smerp/quotation/engine/quotations/show.html.erb
|
194
195
|
- config/routes.rb
|
195
196
|
- db/migrate/20220929020407_create_smerp_quotation_engine_quotation_products.rb
|
196
197
|
- db/migrate/20220929041715_create_smerp_quotation_engine_quotation_product_categories.rb
|
197
198
|
- db/migrate/20220929074438_link_product_to_item.rb
|
199
|
+
- db/migrate/20221005090104_add_position_to_quotation_products.rb
|
198
200
|
- db/seeds.rb
|
199
201
|
- lib/smerp/quotation/engine.rb
|
200
202
|
- lib/smerp/quotation/engine/engine.rb
|