Skip to content
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

Get current_orders plugin working #6

Open
wvengen opened this issue Aug 6, 2020 · 5 comments
Open

Get current_orders plugin working #6

wvengen opened this issue Aug 6, 2020 · 5 comments

Comments

@wvengen
Copy link
Member

wvengen commented Aug 6, 2020

The current_orders plugin has a member checkout screen, which is heavily used in the foodcoop.
First the plugin needs to be enabled, then we need to make sure it still works fine.
Changes can also be sent upstream as a PR.

Note that the newer version of Foodsoft has support for a pickup day, and may have a screen already to work with the current pickup day. It would make sense to integrate the current_orders plugin functionality there, perhaps. But let's first get it working again (and perhaps it still works, just need to check it does).

@wvengen
Copy link
Member Author

wvengen commented Aug 6, 2020

I enabled it in Foodsoft, build it locally with tag vokomokum/foodsoft:latest, ran docker-compose build and brought it all up, enabled the plugin in the configuration screen. Then I found that the receive (Orders > Receive) and member checkout screen (Orders > Member orders) at least rendered, but

  • the distribute screen (Orders > Distribute) gave an error about a wrong query

    An ActionView::Template::Error occurred in articles#index:

    Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':distinct=>true}) FROM groups INNER JOIN group_orders ON group_orders.... at line 1: SELECT COUNT({:distinct=>true}) FROM groups INNER JOIN group_orders ON group_orders.ordergroup_id = groups.id INNER JOIN orders ON orders.id = group_orders.order_id WHERE groups.type IN ('Ordergroup') AND orders.state = 'finished'
    app/controllers/application_controller.rb:94:in `set_currency'

  • the navigation in the API returns a server error (visible in foodsoft-shop) - Navigation REST API breaks on divider foodcoops/foodsoft#755 (fixed)

@wvengen wvengen changed the title Get member checkout screen working Get current_orders plugin working Feb 3, 2021
@wvengen
Copy link
Member Author

wvengen commented Feb 3, 2021

Fixing one error and a warning, but when clicking a new article, it seems like a new group_order_article is added with an empty ordergroup (returning HTTP 500).

diff --git a/plugins/current_orders/app/controllers/current_orders/articles_controller.rb b/plugins/current_orders/app/controllers/current_orders/articles_controller.rb
index 4f33f98e..503c4633 100644
--- a/plugins/current_orders/app/controllers/current_orders/articles_controller.rb
+++ b/plugins/current_orders/app/controllers/current_orders/articles_controller.rb
@@ -34,7 +34,7 @@ class CurrentOrders::ArticlesController < ApplicationController
     else
       @order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
     end
-    @q = OrderArticle.search(params[:q])
+    @q = OrderArticle.ransack(params[:q])
     @order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price)
     @order_article = @order_articles.where(id: params[:id]).first
   end
diff --git a/plugins/current_orders/app/views/current_orders/articles/_article.html.haml b/plugins/current_orders/app/views/current_orders/articles/_article.html.haml
index 15d7f9d3..b6838544 100644
--- a/plugins/current_orders/app/views/current_orders/articles/_article.html.haml
+++ b/plugins/current_orders/app/views/current_orders/articles/_article.html.haml
@@ -8,6 +8,6 @@
     %h2= t('current_orders.articles.index.title')
     #articles_by_articles
       %p
-        %i= t '.counts', ordergroups: Ordergroup.joins(:orders).where(orders: {state: 'finished'}).count(distinct: true), articles: @order_articles.count
+        %i= t '.counts', ordergroups: Ordergroup.joins(:orders).where(orders: {state: 'finished'}).distinct.count, articles: @order_articles.count
       %p
         %i= t '.no_selection'

@wvengen
Copy link
Member Author

wvengen commented Apr 9, 2021

So ideally we'd integrate current_orders functionality in Foodsoft.
Some of already is there (e.g. PDFs of multiple orders), we'd better use that.
Some other functionality will take a while to integrate, so in the meantime we can use it as a plugin.

@wvengen
Copy link
Member Author

wvengen commented Nov 17, 2023

Since foodcoops/foodsoft#373 we have this plugin upstream. But it is likely that it is broken, so can be fixed upstream. Maybe for a while, we can have our own version of the current_orders plugin. Then when it is working for us, we can see what we can bring upstream (which would be good to fix as well, of course).

@wvengen
Copy link
Member Author

wvengen commented Nov 17, 2023

A suggestion for the piece / weight switch (foodcoop-adam/foodsoft#187) would be to do this client-side in Javascript, e.g. with a Stimulus controller.

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

No branches or pull requests

1 participant