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

Staging #401

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/stocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
39 changes: 31 additions & 8 deletions app/views/stocks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,35 @@
</div>
</div>

<div class="form-group">
<%= 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' %>
<div class="form-group mb-3">
<%= form_with(url: stocks_path, method: :get, class: "row g-3 align-items-end") do %>
<div class="col-md-2">
<%= select_tag "status",
options_for_select([['Situação', ''], ['Ativo', 1], ['Inativo', 0]], @default_status_filter),
class: "form-select" %>
</div>

<div class="col-md-2">
<%= 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" %>
</div>

<div class="col-md-2">
<%= select_tag "period",
options_for_select([['30 dias', '30'], ['15 dias', '15'], ['7 dias', '7']], @default_period_filter),
class: "form-select" %>
</div>

<div class="col-md-3">
<%= text_field_tag "sku", @default_sku_filter,
placeholder: "Filtrar por SKU",
class: "form-control" %>
</div>

<div class="col-md-2">
<%= submit_tag "Filtro", class: 'btn btn-primary w-100' %>
</div>
<% end %>
</div>

Expand All @@ -30,8 +53,8 @@
<th><%= t('stocks.sku') %></th>
<th><%= t('stocks.balance') %></th>
<th><%= t('stocks.in_production') %></th>
<th><%= t('stocks.count_sold') %></th>
<th><%= t('stocks.calculate_basic_forecast') %></th>
<th>Quantidade vendida dos últimos <%= params[:period] || '30' %> dias</th>
<th>Previsão para os próximos <%= params[:period] || '30' %> dias</th>
<th><%= t('stocks.number_of_rolls') %></th>
<th><%= t('stocks.product') %></th>
<th><%= t '.actions', :default => t("helpers.actions") %></th>
Expand Down
Loading