-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sales total by products #38
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is helpful. We need some test and eager loading would be necessary to prevent a N+1 query
<tr> | ||
<td><%= currency %></td> | ||
<td> | ||
<% if (variant = ::Spree::Variant.where(id: variant_id).first) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we eager load in the controller this to prevent a N+1 query here, please?
@@ -6,6 +6,8 @@ | |||
collection do | |||
get :sales_total | |||
post :sales_total | |||
get :sales_total_by_product | |||
post :sales_total_by_product |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we would need the post route here.
<% admin_breadcrumb(link_to t('spree.reports'), spree.admin_reports_path) %> | ||
<% admin_breadcrumb(t('spree.sales_total_by_product')) %> | ||
|
||
<% content_for :page_actions do %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This empty block can be omitted
</tbody> | ||
</table> | ||
<div style="text-align: center"> | ||
<i>Not including tax, shipping, and adjustments</i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we translate this note, please?
@totals[order.currency][:sales_total] += line_item.display_amount.money | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to see a spec for this
def sales_total | ||
params[:q] = search_params | ||
|
||
@search = Order.complete.not_canceled.ransack(params[:q]) | ||
@search = Order.complete.not_canceled.where(payment_state: "paid").ransack(params[:q]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to break the existing specs.
@orders = @search.result | ||
|
||
Rails.logger.info("Orders Total: #{@orders.count}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be removed?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
No description provided.