diff --git a/app/controllers/productions_controller.rb b/app/controllers/productions_controller.rb
index db6027ba..3ea9a343 100644
--- a/app/controllers/productions_controller.rb
+++ b/app/controllers/productions_controller.rb
@@ -66,7 +66,7 @@ def set_tailors
def production_params
params.require(:production).permit(
- :tailor_id, :cut_date, :expected_delivery_date,
+ :cut_date, :tailor_id, :service_order_number, :expected_delivery_date,
:confirmed, :paid, :consider, :observation,
production_products_attributes: [:id, :product_id, :quantity, :pieces_delivered, :pieces_missing, :_destroy]
)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 44c1c3e2..224e3a15 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -65,6 +65,11 @@ def pt_datetime_format(time)
time.to_datetime.strftime('%d-%m-%Y %H:%M:%S')
end
+ def pt_only_date_format(time)
+ return 'N/A' if time.nil?
+ time.to_datetime.strftime('%d-%m-%Y')
+ end
+
# date format "%d/%m/%Y %H:%m"
def display_status(status)
if status
diff --git a/app/views/productions/_form.html.erb b/app/views/productions/_form.html.erb
index 3ac131a6..25cb546f 100644
--- a/app/views/productions/_form.html.erb
+++ b/app/views/productions/_form.html.erb
@@ -1,6 +1,6 @@
<%# app/views/productions/_form.html.erb %>
-<%= form_with(model: [@account, production], local: true) do |form| %>
+<%= form_with(model: production, local: true) do |form| %>
<% if production.errors.any? %>
<%= pluralize(production.errors.count, "error") %> prohibited this production from being saved:
@@ -12,6 +12,11 @@
<% end %>
+
+ <%= form.label :service_order_number %>
+ <%= form.text_field :service_order_number, class: 'form-control' %>
+
+
<%= form.label :number %>
<%= form.number_field :number, class: 'form-control' %>
@@ -79,6 +84,7 @@
<%= form.submit class: 'btn btn-primary' %>
+ <%= link_to 'Verify', verify_account_production_path(@account, production), class: 'btn btn-secondary', method: :get if production.persisted? %>
<% end %>
<%# app/views/productions/_production_product_fields.html.erb %>
diff --git a/app/views/productions/edit.html.erb b/app/views/productions/edit.html.erb
index a28a6a25..efe3870c 100644
--- a/app/views/productions/edit.html.erb
+++ b/app/views/productions/edit.html.erb
@@ -20,15 +20,19 @@
<%= form_with(model: @production, local: true) do |form| %>
-
+
+ <%= form.label :service_order_number, model_class.human_attribute_name(:service_order_number), class: 'form-label' %>
+ <%= form.text_field :service_order_number, class: 'form-control' %>
+
+
<%= form.label :tailor_id, model_class.human_attribute_name(:tailor), class: 'form-label' %>
<%= form.collection_select :tailor_id, @tailors, :id, :name, { prompt: 'Select a tailor' }, { class: 'form-control' } %>
-
+
<%= form.label :cut_date, model_class.human_attribute_name(:cut_date), class: 'form-label' %>
<%= form.date_field :cut_date, class: 'form-control', readonly: true %>
-
+
<%= form.label :expected_delivery_date, model_class.human_attribute_name(:expected_delivery_date), class: 'form-label' %>
<%= form.date_field :expected_delivery_date, class: 'form-control' %>
diff --git a/app/views/productions/new.html.erb b/app/views/productions/new.html.erb
index c8ec4b5c..78a71262 100644
--- a/app/views/productions/new.html.erb
+++ b/app/views/productions/new.html.erb
@@ -11,15 +11,19 @@
<%= form_with(model: @production, local: true) do |form| %>
-
+
+ <%= form.label :service_order_number, model_class.human_attribute_name(:service_order_number), class: 'form-label' %>
+ <%= form.text_field :service_order_number, class: 'form-control' %>
+
+
<%= form.label :tailor_id, model_class.human_attribute_name(:tailor), class: 'form-label' %>
<%= form.collection_select :tailor_id, @tailors, :id, :name, { prompt: 'Select a tailor' }, { class: 'form-control select2' } %>
-
+
<%= form.label :cut_date, model_class.human_attribute_name(:cut_date), class: 'form-label' %>
<%= form.date_field :cut_date, class: 'form-control' %>
-
+
<%= form.label :expected_delivery_date, model_class.human_attribute_name(:expected_delivery_date), class: 'form-label' %>
<%= form.date_field :expected_delivery_date, class: 'form-control' %>
diff --git a/app/views/productions/show.html.erb b/app/views/productions/show.html.erb
index d74856d2..74a2091a 100644
--- a/app/views/productions/show.html.erb
+++ b/app/views/productions/show.html.erb
@@ -28,12 +28,20 @@
+ - <%= model_class.human_attribute_name(:service_order_number) %>:
+ - <%= @production.service_order_number %>
- <%= model_class.human_attribute_name(:cut_date) %>:
- - <%= @production.cut_date %>
+ - <%= pt_only_date_format(@production.cut_date) %>
- <%= model_class.human_attribute_name(:expected_delivery_date) %>:
- - <%= @production.expected_delivery_date %>
+ - <%= pt_only_date_format(@production.expected_delivery_date) %>
- <%= model_class.human_attribute_name(:consider)%>:
- <%= @production.consider ? 'Sim' : 'Não' %>
+ - <%= model_class.human_attribute_name(:confirmed) %>:
+ - <%= @production.confirmed ? 'Sim' : 'Não' %>
+ - <%= model_class.human_attribute_name(:paid) %>:
+ - <%= @production.paid ? 'Sim' : 'Não' %>
+ - <%= model_class.human_attribute_name(:observation) %>:
+ - <%= @production.observation %>
diff --git a/config/locales/pt-BR.models.productions.yml b/config/locales/pt-BR.models.productions.yml
index 416afc36..0e3b0165 100644
--- a/config/locales/pt-BR.models.productions.yml
+++ b/config/locales/pt-BR.models.productions.yml
@@ -5,6 +5,7 @@ pt-BR:
production_product: "Produto da Produção"
attributes:
production:
+ service_order_number: "Número da Ordem de Serviço"
tailor: "Costureiro"
cut_date: "Data de Corte"
delivery_date: "Data de Entrega"
diff --git a/db/migrate/20240902181724_add_service_order_number_to_productions.rb b/db/migrate/20240902181724_add_service_order_number_to_productions.rb
new file mode 100644
index 00000000..715a2991
--- /dev/null
+++ b/db/migrate/20240902181724_add_service_order_number_to_productions.rb
@@ -0,0 +1,5 @@
+class AddServiceOrderNumberToProductions < ActiveRecord::Migration[7.0]
+ def change
+ add_column :productions, :service_order_number, :string
+ end
+end