diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9004803f9f..45454f4ba9 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -7,6 +7,8 @@ def index @donations = current_organization.donations.during(helpers.selected_range) @recent_donations = @donations.recent + @purchases = current_organization.purchases.during(helpers.selected_range) + @recent_purchases = @purchases.recent.includes(:vendor) distributions = current_organization.distributions.includes(:partner).during(helpers.selected_range) @recent_distributions = distributions.recent diff --git a/app/controllers/purchases_summary_controller.rb b/app/controllers/purchases_summary_controller.rb deleted file mode 100644 index 3f81e0d5a3..0000000000 --- a/app/controllers/purchases_summary_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class PurchasesSummaryController < ApplicationController - def index - setup_date_range_picker - @purchases = current_organization.purchases.during(helpers.selected_range) - @recent_purchases = @purchases.recent.includes(:vendor) - end -end diff --git a/app/views/purchases_summary/_purchase.html.erb b/app/views/dashboard/_purchase.html.erb similarity index 98% rename from app/views/purchases_summary/_purchase.html.erb rename to app/views/dashboard/_purchase.html.erb index 86344a45a1..bb13b180f7 100644 --- a/app/views/purchases_summary/_purchase.html.erb +++ b/app/views/dashboard/_purchase.html.erb @@ -1,4 +1,4 @@ - +
<%= link_to purchase do %> <%= number_with_delimiter purchase.line_items.total %> items from <%= purchase.purchased_from_view %> @@ -7,4 +7,3 @@
<%= distance_of_time_in_words_to_now purchase.created_at %> ago
- diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index d8ae90765c..185404290a 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -286,6 +286,26 @@
<% end %> + <%= render( + "card", + id: "purchases", + gradient: "secondary", + title: "Purchases", + subtitle: @selected_date_range, + footer_options: { class: "text-center" }, + footer: link_to("See more...", purchases_path), + ) do %> + <%= new_button_to new_purchase_path, {text: "New Purchase"} %> +

<%= dollar_presentation(@purchases.sum(&:amount_spent_in_cents)) %> + spent + <%= @selected_date_range_label %> +

+
+

Recent purchases

+ <%= render partial: "purchase", collection: @recent_purchases, as: :purchase %> +
+ <% end %> + <%= render( "card", gradient: "warning", diff --git a/app/views/layouts/_lte_sidebar.html.erb b/app/views/layouts/_lte_sidebar.html.erb index 60018a8449..0175496b56 100644 --- a/app/views/layouts/_lte_sidebar.html.erb +++ b/app/views/layouts/_lte_sidebar.html.erb @@ -62,11 +62,6 @@ New Purchase <% end %> -