Open wvengen opened 4 years ago
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) - https://github.com/foodcoops/foodsoft/issues/755 (fixed)
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'
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.
Since https://github.com/foodcoops/foodsoft/pull/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).
A suggestion for the piece / weight switch (https://github.com/foodcoop-adam/foodsoft/issues/187) would be to do this client-side in Javascript, e.g. with a Stimulus controller.
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).