smerp-quotation-engine 0.3.1 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8546e16b5580393b492285b0e9a1b6ad03db1b07b0d1c020d793c5d072cc7c2d
4
- data.tar.gz: 6f4f31d01f493c52c75ef4efe931e53803a737a9b07ca5447e89a0867d00106d
3
+ metadata.gz: 877f701dd655baa97ce7bfa6ccd12a6577efcb96f7988ead8756f7dff06df017
4
+ data.tar.gz: e8e2c6853575812585ab3e15ff45043fb9ac478cf662e72e04f608bff8361d8b
5
5
  SHA512:
6
- metadata.gz: b22cf2555a4422d10f0e01a9e499bd41d76ba74b26f4f0b900f8a11a5382bdce58c6aba09e6c93f64615cd757e023c36f3cfdb1e1b93ffc12abfb025ad1131ca
7
- data.tar.gz: bd09f9344fd1d7c9cce91d0958e953994dfcdc7e92e60be97c44e5a708a82c62e185c4e12056e26377b63ff657786d7e176386911735bc065c65682a55090567
6
+ metadata.gz: 435a82a08f9cf51494e8e385743cec220e2c83d38987e5fe0c93a2e0bd9933015d48bf580791f50d6953232ad088b1e67cb2006b02ff098b5f36400c0aa7d4f6
7
+ data.tar.gz: 156f5ea4da300e867e39ddeea60ff752b3439015b7251bbf09b7af46ba143ffdc7a66c161ea58a896b8ebfe4198ffce61e5c9e00bfe17bcd1dc5fd2fbd382244
@@ -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 resources_allocation_summary ]
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 filter ]
7
7
 
8
8
  # GET /quotations
9
9
  def index
@@ -177,13 +177,32 @@ module Smerp::Quotation::Engine
177
177
  @resTable = {}
178
178
  @quotation.quotation_items_allocated_resources.each do |qi|
179
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
180
+ @resTable[prodId] = { total: 0, rate: qi.quotation_product.unit_price.to_f } if @resTable[prodId].nil?
181
+ @resTable[prodId][:total] += qi.quantity.to_i
182
182
 
183
183
  @resTable[prodId][:total_rate] = @resTable[prodId][:total] * @resTable[prodId][:rate]
184
184
  end
185
185
  end
186
186
 
187
+ def filter
188
+
189
+ val = params[:val]
190
+
191
+ case val
192
+ when "main_only"
193
+ session[:hide_children_parent_id] = [] if session[:hide_children_parent_id].nil?
194
+ @quotation.quotation_items.where(["parent_id is null"]).each do |qi|
195
+ session[:hide_children_parent_id] << qi.id
196
+ end
197
+ when "show_all"
198
+ if not session[:hide_children_parent_id].nil?
199
+ session[:hide_children_parent_id].clear
200
+ end
201
+ end
202
+
203
+ redirect_to quotation_url(@quotation)
204
+ end
205
+
187
206
  private
188
207
  # Use callbacks to share common setup or constraints between actions.
189
208
  def set_quotation
@@ -1,3 +1,4 @@
1
+
1
2
  module Smerp::Quotation::Engine
2
3
  module QuotationsHelper
3
4
 
@@ -35,10 +36,31 @@ module Smerp::Quotation::Engine
35
36
  "#DBFED8", #light green
36
37
  "#FEF0D8",
37
38
  "#D8F8FE",
38
- "#FED8D8"
39
+ "#FED8D8",
40
+ "#B7FFD8"
39
41
  ]
40
42
 
41
- marker[level%4]
43
+ marker[level%marker.length]
44
+ end
45
+
46
+ def level_seq_conv(level, seq)
47
+ levelConv = [:to_i, :alpha_lowercase, :roman_lowercase, :alpha_upcase, :roman_upcase]
48
+ conv = levelConv[level%levelConv.length]
49
+
50
+ case conv
51
+ when :to_i
52
+ seq.to_i
53
+ when :alpha_lowercase
54
+ seq.to_i.int_to_alpha_downcase
55
+ when :roman_lowercase
56
+ seq.to_i.int_to_roman_downcase
57
+ when :alpha_upcase
58
+ seq.to_i.int_to_alpha
59
+ when :roman_upcase
60
+ seq.to_i.int_to_roman
61
+ else
62
+ seq.to_i
63
+ end
42
64
  end
43
65
 
44
66
  def extended_calculator_name(ec)
@@ -91,7 +113,7 @@ module Smerp::Quotation::Engine
91
113
  elsif balMonthDay > 0
92
114
  "#{months} month(s) and #{weeks} week(s) (Calendar Based)"
93
115
  else
94
- "#{months} month(s)"
116
+ "#{months} month(s) (Calendar Based)"
95
117
  end
96
118
  else
97
119
  "#{days} calendar day(s)"
@@ -2,8 +2,9 @@
2
2
 
3
3
  <tr style="background-color: <%= level_marker(level) %>">
4
4
  <td>
5
- <%= (" * " * level).html_safe %>
6
- <%= index+1 %>.
5
+ <%= (" &nbsp; " * level).html_safe %>
6
+ <%# index += 1 %>
7
+ <%= level_seq_conv(level, index+1) %>.
7
8
  <%= link_to quotation_item.name, quotation_quotation_item_path(@quotation, quotation_item) %>
8
9
  <%#= link_to "Add Sub Item", add_sub_item_quotation_item_url(quotation_item) %>
9
10
  <%= link_to image_tag('add.png', size: "20x20"), add_sub_item_quotation_item_url(quotation_item) %>
@@ -47,11 +47,21 @@
47
47
 
48
48
  <tr style="font-weight: bold; background-color: #8EFEC1">
49
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>
50
+ <td class="text-end">
51
+ Grand Total :
52
+ </td>
53
+ <td class="text-end">
54
+ <%= ttlMd %>
55
+ </td>
56
+ <td style="font-style: italic">
57
+ (Roughly <%= ttlMd %> mandays ~ <%= days_to_human_readable(ttlMd) %>)
58
+ </td>
59
+ <td class="text-end">
60
+ <%= currency(ttlPrice) %>
61
+ </td>
62
+ <td style="font-style: italic;">
63
+ (<%= ttlPrice.percent_of(@quotation.total, 2) %>%)
64
+ </td>
55
65
  </tr>
56
66
 
57
67
  </table>
@@ -69,6 +69,13 @@
69
69
 
70
70
  <h3>Details</h3>
71
71
 
72
+ <div class="pb-1">
73
+ <%= button_to "Main Items Only", filter_quotation_path(@quotation, val: "main_only"), class: "btn btn-info" %>
74
+ </div>
75
+ <div>
76
+ <%= button_to "Show All Items", filter_quotation_path(@quotation, val: "show_all"), class: "btn btn-info" %>
77
+ </div>
78
+
72
79
  <% if not notice.nil? %>
73
80
  <div class="alert alert-success text-center w-100" role="alert">
74
81
  <%= notice %>
data/config/routes.rb CHANGED
@@ -27,6 +27,8 @@ Smerp::Quotation::Engine::Engine.routes.draw do
27
27
 
28
28
  get :resources_allocation_summary
29
29
 
30
+ post :filter
31
+
30
32
  end
31
33
 
32
34
  end # quotations
@@ -1,7 +1,7 @@
1
1
  module Smerp
2
2
  module Quotation
3
3
  module Engine
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.6"
5
5
  end
6
6
  end
7
7
  end
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.3.1
4
+ version: 0.3.6
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-05 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails