From edcb61d5811c11eb8eb885e529ff09b98f849861 Mon Sep 17 00:00:00 2001 From: puppe1990 Date: Thu, 31 Oct 2024 15:27:20 -0300 Subject: [PATCH 1/3] add a filter to the suggestion of purchase --- app/controllers/stocks_controller.rb | 4 +++- app/views/stocks/index.html.erb | 35 +++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/controllers/stocks_controller.rb b/app/controllers/stocks_controller.rb index c82c433e..efb85b84 100644 --- a/app/controllers/stocks_controller.rb +++ b/app/controllers/stocks_controller.rb @@ -65,6 +65,7 @@ def collection @default_status_filter = params['status'] @default_situation_balance_filter = params['balance_situation'] @default_sku_filter = params['sku'] + @default_period_filter = params['period'] || '30' stocks = Stock.where(account_id: current_tenant) .includes(:product, :balances) @@ -75,7 +76,8 @@ def collection @warehouses = Warehouse.where(account_id: current_tenant).pluck(:bling_id, :description).to_h - start_date = 1.month.ago.to_date + days = @default_period_filter.to_i + start_date = days.days.ago.to_date end_date = Date.today items_sold = Item.joins(:bling_order_item) diff --git a/app/views/stocks/index.html.erb b/app/views/stocks/index.html.erb index 1ae23242..0568f327 100644 --- a/app/views/stocks/index.html.erb +++ b/app/views/stocks/index.html.erb @@ -8,12 +8,35 @@ -
- <%= form_with(url: stocks_path, method: :get) do %> - <%= select_tag "status", options_for_select([['Situação', ''], ['Ativo', 1], ['Inativo', 0]], @default_status_filter) %> - <%= select_tag "balance_situation", options_for_select([['Saldo total', ''], ['Maior do que zero', 1], ['Igual a zero', 0], ['Menor do que zero', -1]], @default_situation_balance_filter) %> - <%= text_field_tag "sku", @default_sku_filter, placeholder: "Filtrar por SKU" %> - <%= submit_tag "Filtro", class: 'btn btn-primary' %> +
+ <%= form_with(url: stocks_path, method: :get, class: "row g-3 align-items-end") do %> +
+ <%= select_tag "status", + options_for_select([['Situação', ''], ['Ativo', 1], ['Inativo', 0]], @default_status_filter), + class: "form-select" %> +
+ +
+ <%= select_tag "balance_situation", + options_for_select([['Saldo total', ''], ['Maior do que zero', 1], ['Igual a zero', 0], ['Menor do que zero', -1]], @default_situation_balance_filter), + class: "form-select" %> +
+ +
+ <%= select_tag "period", + options_for_select([['30 dias', '30'], ['15 dias', '15'], ['7 dias', '7']], @default_period_filter), + class: "form-select" %> +
+ +
+ <%= text_field_tag "sku", @default_sku_filter, + placeholder: "Filtrar por SKU", + class: "form-control" %> +
+ +
+ <%= submit_tag "Filtro", class: 'btn btn-primary w-100' %> +
<% end %>
From 116302670789560761c6dbcff5626b9e01070f29 Mon Sep 17 00:00:00 2001 From: puppe1990 Date: Thu, 31 Oct 2024 15:34:14 -0300 Subject: [PATCH 2/3] change to be a custom header with the period --- app/views/stocks/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/stocks/index.html.erb b/app/views/stocks/index.html.erb index 0568f327..536fe65e 100644 --- a/app/views/stocks/index.html.erb +++ b/app/views/stocks/index.html.erb @@ -53,7 +53,7 @@ <%= t('stocks.sku') %> <%= t('stocks.balance') %> <%= t('stocks.in_production') %> - <%= t('stocks.count_sold') %> + Quantidade vendida dos últimos <%= params[:period] || '30' %> dias <%= t('stocks.calculate_basic_forecast') %> <%= t('stocks.number_of_rolls') %> <%= t('stocks.product') %> From 0e437a5228c375098e9d8e5f88bbc87f1d055d83 Mon Sep 17 00:00:00 2001 From: puppe1990 Date: Thu, 31 Oct 2024 15:36:43 -0300 Subject: [PATCH 3/3] add missing custom header --- app/views/stocks/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/stocks/index.html.erb b/app/views/stocks/index.html.erb index 536fe65e..9e82379a 100644 --- a/app/views/stocks/index.html.erb +++ b/app/views/stocks/index.html.erb @@ -54,7 +54,7 @@ <%= t('stocks.balance') %> <%= t('stocks.in_production') %> Quantidade vendida dos últimos <%= params[:period] || '30' %> dias - <%= t('stocks.calculate_basic_forecast') %> + Previsão para os próximos <%= params[:period] || '30' %> dias <%= t('stocks.number_of_rolls') %> <%= t('stocks.product') %> <%= t '.actions', :default => t("helpers.actions") %>