From 1eeec23c80dc9a3dea2179e63d637d5fe82cbc16 Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 8 Jul 2013 02:31:54 +0200 Subject: [PATCH 1/2] only add undeleted articles in balancing screen --- app/helpers/finance/order_articles_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/finance/order_articles_helper.rb b/app/helpers/finance/order_articles_helper.rb index 548dfc4f..0ebbc835 100644 --- a/app/helpers/finance/order_articles_helper.rb +++ b/app/helpers/finance/order_articles_helper.rb @@ -4,7 +4,7 @@ module Finance::OrderArticlesHelper if @order.stockit? StockArticle.order('articles.name') else - @order.supplier.articles.order('articles.name') + @order.supplier.articles.undeleted.order('articles.name') end end end From 33d3b9c4665cdb633fc4c4f0491bf9e7ea61115e Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 10 Jul 2013 22:02:36 +0200 Subject: [PATCH 2/2] merge branch minimum_balance into master (closes #133) --- app/assets/javascripts/ordering.js | 7 ++++++- app/views/group_orders/_form.html.haml | 1 + config/app_config.yml.SAMPLE | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/ordering.js b/app/assets/javascripts/ordering.js index 1a1421bd..159370f2 100644 --- a/app/assets/javascripts/ordering.js +++ b/app/assets/javascripts/ordering.js @@ -10,6 +10,7 @@ var groupBalance = 0; // available group money var currencySeparator = "."; // default decimal separator var currencyPrecision = 2; // default digits behind comma var currencyUnit = "€"; // default currency +var minimumBalance = 0; // minimum group balance for the order to be succesful var toleranceIsCostly = true; // default tolerance behaviour var isStockit = false; // Wheter the order is from stock oder normal supplier @@ -40,6 +41,10 @@ function setGroupBalance(amount) { groupBalance = amount; } +function setMinimumBalance(amount) { + minimumBalance = amount; +} + function addData(orderArticleId, itemPrice, itemUnit, itemSubtotal, itemQuantityOthers, itemToleranceOthers, allocated, available) { var i = orderArticleId; price[i] = itemPrice; @@ -159,7 +164,7 @@ function updateBalance() { $('#total_balance').val(asMoney(balance)); // determine bgcolor and submit button state according to balance var bgcolor = ''; - if (balance < 0) { + if (balance < minimumBalance) { bgcolor = '#FF0000'; $('#submit_button').attr('disabled', 'disabled') } else { diff --git a/app/views/group_orders/_form.html.haml b/app/views/group_orders/_form.html.haml index 2939a689..2bd2f30b 100644 --- a/app/views/group_orders/_form.html.haml +++ b/app/views/group_orders/_form.html.haml @@ -4,6 +4,7 @@ #{data_to_js(@ordering_data)} setGroupBalance(#{@ordering_data[:available_funds]}); setCurrencyFormat("#{t('number.currency.format.separator')}", #{t('number.currency.format.precision')}, "#{t('number.currency.format.unit')}"); + setMinimumBalance(#{FoodsoftConfig[:minimum_balance] or 0}); setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]}); setStockit(#{@order.stockit?}); }); diff --git a/config/app_config.yml.SAMPLE b/config/app_config.yml.SAMPLE index 50f1d63b..594b9c70 100644 --- a/config/app_config.yml.SAMPLE +++ b/config/app_config.yml.SAMPLE @@ -48,6 +48,10 @@ default: &defaults # Comment out this option to activate this restriction # stop_ordering_under: 75 + # ordergroups can only order when their balance is higher than or equal to this + # not fully enforced right now, since the check is only client-side + # minimum_balance: 0 + # email address to be used as sender email_sender: foodsoft@foodcoop.test