Skip to content

Commit

Permalink
feat(crm): Adding e-portal reference to procurement
Browse files Browse the repository at this point in the history
  • Loading branch information
DevMagnataur committed Sep 12, 2024
1 parent 5fa08b1 commit 8780a42
Show file tree
Hide file tree
Showing 17 changed files with 340 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/controllers/support/cases/contracts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def current_contract
end

def case_contracts_form_params
form_params = params.require(:case_contracts_form).permit(:supplier, :spend, :duration)
form_params = params.require(:case_contracts_form).permit(:supplier, :spend, :duration, :is_supplier_sme)
form_params[:started_at] = date_param(:case_contracts_form, :started_at)
form_params[:ended_at] = date_param(:case_contracts_form, :ended_at)
form_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def validation
end

def case_procurement_details_form_params
form_params = params.require(:case_procurement_details_form).permit(:required_agreement_type, :route_to_market, :reason_for_route_to_market, :framework_id, :frameworks_framework_id)
form_params = params.require(:case_procurement_details_form).permit(:required_agreement_type, :route_to_market, :reason_for_route_to_market, :framework_id, :frameworks_framework_id, :e_portal_reference)
form_params[:started_at] = date_param(:case_procurement_details_form, :started_at)
form_params[:ended_at] = date_param(:case_procurement_details_form, :ended_at)
form_params
Expand Down
1 change: 1 addition & 0 deletions app/forms/support/case_contracts_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CaseContractsForm < Form
option :ended_at, Types::DateField, optional: true
option :spend, Types::DecimalField, optional: true
option :duration, optional: true
option :is_supplier_sme, optional: true

# @return [Hash]
def to_h
Expand Down
1 change: 1 addition & 0 deletions app/forms/support/case_contracts_form_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CaseContractsFormSchema < ::Support::Schema
optional(:ended_at).maybe(:hash)
optional(:spend).maybe(Types::DecimalField)
optional(:duration).maybe(:integer)
optional(:is_supplier_sme).maybe(:string)
end

rule :spend do
Expand Down
3 changes: 3 additions & 0 deletions app/forms/support/case_procurement_details_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ class CaseProcurementDetailsForm < Form
# @!attribute [r] ended_at
# @return [Date, nil]
option :ended_at, Types::DateField, optional: true
# @!attribute [r] e_portal_reference
# @return [String, nil]
option :e_portal_reference, optional: true
end
end
1 change: 1 addition & 0 deletions app/forms/support/case_procurement_details_form_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CaseProcurementDetailsFormSchema < ::Support::Schema
optional(:framework_id).value(:string)
optional(:started_at).value(:hash)
optional(:ended_at).value(:hash)
optional(:e_portal_reference).value(:string)
end

rule :started_at do
Expand Down
3 changes: 3 additions & 0 deletions app/views/support/cases/new_contracts/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
<%= form.govuk_number_field :duration, width: 5, label: { text: I18n.t("support.case_contract.new.edit.duration.header"), size: 'm' } %>
<%= form.govuk_text_field :spend, width: 5, label: { text: I18n.t("support.case_contract.new.edit.spend.header"), size: 'm' }, prefix_text: '£' %>
<%= form.govuk_text_field :supplier, width: 20, label: { text: I18n.t("support.case_contract.new.edit.supplier.header"), size: 'm' } %>
<%= form.hidden_field :is_supplier_sme, value: 'false' %>
<%= form.govuk_check_box :is_supplier_sme, 'true', unchecked_value: 'false', multiple: false, checked: @current_case.new_contract.is_supplier_sme, label: { text: "Supplier is a SME", size: 'm' } %>
<br>
<%= form.submit I18n.t("support.case_contract.new.edit.submit"), class: "govuk-button", role: "button" %>
<% end %>
4 changes: 3 additions & 1 deletion app/views/support/cases/procurement_details/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@

<%= form.govuk_date_field :started_at, legend: { text: I18n.t("support.procurement_details.edit.started_at.header") } %>
<%= form.govuk_date_field :ended_at, legend: { text: I18n.t("support.procurement_details.edit.ended_at.header") } %>
<%= form.govuk_date_field :ended_at, legend: { text: I18n.t("support.procurement_details.edit.ended_at.header")} %>
<%= form.govuk_text_field :e_portal_reference, label: { text: I18n.t("support.procurement_details.edit.e_portal_reference.header"), class: "govuk-label govuk-fieldset__legend govuk-fieldset__legend--m" } %>
<%= form.submit I18n.t("support.procurement_details.edit.submit"), class: "govuk-button", role: "button" %>
<% end %>
Expand Down
19 changes: 18 additions & 1 deletion app/views/support/cases/show/_case_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@
<dd class="govuk-summary-list__actions"></dd>
</div>
<% end %>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<%= I18n.t("support.case.label.procurement_details.procurement_e_portal_reference") %>
</dt>
<dd class="govuk-summary-list__value">
<%= current_case.procurement&.e_portal_reference %>
</dd>
<dd class="govuk-summary-list__actions"></dd>
</div>
</dl>

<h3 id="pd-existing-contract" class="govuk-heading-m">
Expand Down Expand Up @@ -248,7 +257,6 @@
<dd class="govuk-summary-list__actions"></dd>
</div>
</dl>

<h3 id="pd-new-contract" class="govuk-heading-m">
New contract details -
<%= link_to I18n.t("support.case.link.change"), edit_support_case_contract_path(current_case, current_case.new_contract_id), class: "govuk-link govuk-link--no-visited-state"%>
Expand Down Expand Up @@ -290,6 +298,15 @@
</dd>
<dd class="govuk-summary-list__actions"></dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<%= I18n.t("support.case.label.procurement_details.supplier_is_sme") %>
</dt>
<dd class="govuk-summary-list__value">
<%= current_case.new_contract&.is_supplier_sme ? "Yes" : "No" %>
</dd>
<dd class="govuk-summary-list__actions"></dd>
</div>
</dl>

<h3 id="pd-savings" class="govuk-heading-m">
Expand Down
6 changes: 5 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ en:
legacy_framework_name: Legacy Framework
procurement_end_date: Procurement end date
procurement_start_date: Procurement start date
procurement_e_portal_reference: E-portal reference
reason_for_route_to_market: Reason for route to market
required_agreement_type: Required agreement type
route_to_market: Route to market
Expand All @@ -1090,6 +1091,7 @@ en:
savings_status: Status
start_date: Start date
supplier: Supplier
supplier_is_sme: Supplier is an SME
procurement_stage: Procurement stage
query: Query
received_at: Received
Expand Down Expand Up @@ -1345,7 +1347,7 @@ en:
supplier:
header: Existing contract supplier
flash:
updated: Successfully changed case contracts
updated: Case contract details successfully changed
new:
edit:
duration:
Expand Down Expand Up @@ -1926,6 +1928,8 @@ en:
header: Procurement stage
started_at:
header: Start date of the procurement
e_portal_reference:
header: E-portal reference
submit: Continue
flash:
updated: Successfully changed procurement details
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddEPortalReferenceToProcurement < ActiveRecord::Migration[7.1]
def change
add_column :support_procurements, :e_portal_reference, :string, default: nil
end
end
5 changes: 5 additions & 0 deletions db/migrate/20240911100311_add_is_supplier_sme_to_contract.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIsSupplierSmeToContract < ActiveRecord::Migration[7.1]
def change
add_column :support_contracts, :is_supplier_sme, :boolean, default: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class UpdateSupportCaseDataToVersion12 < ActiveRecord::Migration[7.1]
def change
update_view :support_case_data, version: 12, revert_to_version: 11
end
end
50 changes: 27 additions & 23 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_08_18_210639) do
ActiveRecord::Schema[7.1].define(version: 2024_09_11_140017) do
create_sequence "evaluation_refs"
create_sequence "framework_refs"

Expand Down Expand Up @@ -589,11 +589,11 @@
t.integer "savings_status"
t.integer "savings_estimate_method"
t.integer "savings_actual_method"
t.decimal "savings_estimate", precision: 9, scale: 2
t.decimal "savings_actual", precision: 9, scale: 2
t.decimal "savings_estimate", precision: 10, scale: 2
t.decimal "savings_actual", precision: 10, scale: 2
t.boolean "action_required", default: false
t.string "organisation_type"
t.decimal "value", precision: 9, scale: 2
t.decimal "value", precision: 10, scale: 2
t.integer "closure_reason"
t.string "extension_number"
t.string "other_category"
Expand Down Expand Up @@ -652,7 +652,8 @@
t.date "started_at"
t.date "ended_at"
t.interval "duration"
t.decimal "spend", precision: 9, scale: 2
t.decimal "spend", precision: 10, scale: 2
t.boolean "is_supplier_sme", default: false
end

create_table "support_documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
Expand Down Expand Up @@ -904,6 +905,7 @@
t.datetime "updated_at", null: false
t.uuid "framework_id"
t.uuid "frameworks_framework_id"
t.string "e_portal_reference"
t.index ["framework_id"], name: "index_support_procurements_on_framework_id"
t.index ["stage"], name: "index_support_procurements_on_stage"
end
Expand Down Expand Up @@ -1117,24 +1119,6 @@
LEFT JOIN support_establishment_searches ses ON (((sc.organisation_id = ses.id) AND ((sc.organisation_type)::text = ses.source))))
LEFT JOIN support_categories cat ON ((sc.category_id = cat.id)));
SQL
create_view "support_tower_cases", sql_definition: <<-SQL
SELECT sc.id,
sc.state,
sc.value,
sc.procurement_id,
sc.organisation_id,
(sc.procurement_stage_id)::text AS procurement_stage_id,
COALESCE(sc.support_level, 99) AS support_level,
COALESCE(tow.title, 'No Tower'::character varying) AS tower_name,
lower(replace((COALESCE(tow.title, 'No Tower'::character varying))::text, ' '::text, '-'::text)) AS tower_slug,
tow.id AS tower_id,
sc.created_at,
sc.updated_at
FROM ((support_cases sc
LEFT JOIN support_categories cat ON ((sc.category_id = cat.id)))
LEFT JOIN support_towers tow ON ((cat.support_tower_id = tow.id)))
WHERE (sc.state = ANY (ARRAY[0, 1, 3]));
SQL
create_view "support_message_threads", sql_definition: <<-SQL
SELECT DISTINCT ON (se.outlook_conversation_id, se.ticket_id) se.outlook_conversation_id AS conversation_id,
se.case_id,
Expand Down Expand Up @@ -1235,6 +1219,24 @@
FROM frameworks_evaluations ffe
GROUP BY ffe.framework_id) evals ON ((evals.framework_id = ff.id)));
SQL
create_view "support_tower_cases", sql_definition: <<-SQL
SELECT sc.id,
sc.state,
sc.value,
sc.procurement_id,
sc.organisation_id,
(sc.procurement_stage_id)::text AS procurement_stage_id,
COALESCE(sc.support_level, 99) AS support_level,
COALESCE(tow.title, 'No Tower'::character varying) AS tower_name,
lower(replace((COALESCE(tow.title, 'No Tower'::character varying))::text, ' '::text, '-'::text)) AS tower_slug,
tow.id AS tower_id,
sc.created_at,
sc.updated_at
FROM ((support_cases sc
LEFT JOIN support_categories cat ON ((sc.category_id = cat.id)))
LEFT JOIN support_towers tow ON ((cat.support_tower_id = tow.id)))
WHERE (sc.state = ANY (ARRAY[0, 1, 3]));
SQL
create_view "support_case_data", sql_definition: <<-SQL
SELECT sc.id AS case_id,
sc.ref AS case_ref,
Expand Down Expand Up @@ -1301,6 +1303,7 @@
sps.key AS procurement_stage_key,
sp.started_at AS procurement_started_at,
sp.ended_at AS procurement_ended_at,
sp.e_portal_reference AS procurement_e_portal_reference,
ec.started_at AS previous_contract_started_at,
ec.ended_at AS previous_contract_ended_at,
ec.duration AS previous_contract_duration,
Expand All @@ -1311,6 +1314,7 @@
nc.duration AS new_contract_duration,
nc.spend AS new_contract_spend,
nc.supplier AS new_contract_supplier,
nc.is_supplier_sme AS new_contract_supplier_sme_check,
ps.created_at AS participation_survey_date,
es.created_at AS exit_survey_date,
sir.referrer
Expand Down
Loading

0 comments on commit 8780a42

Please sign in to comment.