vokomokum / vkmkm-deploy

[WiP] Vokomokum setup for deployment of IT systems
http://www.vokomokum.nl/
3 stars 1 forks source link

Get current_orders plugin working #6

Open wvengen opened 4 years ago

wvengen commented 4 years ago

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 commented 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

wvengen commented 3 years ago

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 commented 3 years ago

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 commented 12 months ago

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).

wvengen commented 12 months ago

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.