Skip to content

[OSU-242] Public estimates - #6458

Open
diebas wants to merge 4 commits into
masterfrom
OSU-242/public-estimates
Open

[OSU-242] Public estimates#6458
diebas wants to merge 4 commits into
masterfrom
OSU-242/public-estimates

Conversation

@diebas

@diebas diebas commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Notes

Visitors can now get a cost estimate without logging in. A "Get an Estimate" link next to Support opens a page where they pick whether they are internal or external, choose a facility, and enter quantities for the products they are interested in, then see the estimated cost. Off by default behind the public_estimates feature flag.

OSU-242 | Public estimates

Additional Context

Nothing is persisted. Phase 1 calculates and displays only. PublicEstimatesController#show builds an in-memory Estimate with estimate_details.build and calls assign_price_policy_and_cost on each detail — no new models and no migration. That method was already able to run on unsaved records; the specs pin that it resolves the policy, computes the same cost as a persisted equivalent, and writes nothing.

Price group selection. PriceGroup.for_public_estimate maps the visitor's answer to a global price group: internal → base, external non-profit → secondary_external falling back to external, everything else → external. PriceGroup.secondary_external is new and returns nil when price_group.name.external_2 is unset, so schools without a second external group only see two options instead of three.

Cost does not depend on the user. Verified through PricePolicySelector and all three estimate_cost_from_estimate_detail implementations — they read only price group, quantity and duration, which is what makes an accountless estimate possible.

Existing admin views were not reused. facility_estimates/show.html.haml calls includes and maximum on the association, which hit the database and therefore return nothing for an unsaved estimate.

Products are listed from available_for_estimates, excluding bundles. A product with no purchaseable, in-date policy on the selected price group is shown as "No public rate available" rather than hidden, so visitors can tell the difference between a product that is unavailable and one that simply has no public rate.

Screenshot

Screen.Recording.2026-09-07.at.10.29.30.AM.mov

@diebas
diebas marked this pull request as ready for review September 7, 2026 13:39
Comment on lines +21 to +27
return [[t(".internal"), "internal"], [t(".external"), "external"]] if PriceGroup.secondary_external.blank?

[
[t(".internal"), "internal"],
[t(".external_for_profit"), "external"],
[t(".external_non_profit"), "external_non_profit"],
]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have this predefined to base and external and allow each school override it? what do you think?

Comment on lines +43 to +44
@requested_quantities ||=
params[:quantities].presence&.to_unsafe_h&.select { |_id, quantity| quantity.to_i.positive? } || {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use strong parameters instead of to_unsafe_h

estimate = Estimate.new(facility: @facility, price_group: @price_group)

requested_quantities.each do |product_id, quantity|
product = @products.find_by(id: product_id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a chance we can make a single db query?

@joaquinco joaquinco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread config/locales/en.yml
Comment on lines +125 to +128
base: Internal
external: External
external_2: External - non-profit
cancer_center: Cancer Center

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make it consistent with the price groups we have defined for open (without external_2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants