Skip to content

Commit bc2aba0

Browse files
committed
create 2 new fields to production
1 parent 3216e1a commit bc2aba0

File tree

9 files changed

+57
-4
lines changed

9 files changed

+57
-4
lines changed

app/controllers/productions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def set_tailors
111111
def production_params
112112
params.require(:production).permit(
113113
:cut_date, :tailor_id, :service_order_number, :expected_delivery_date,
114-
:confirmed, :paid, :consider, :observation,
114+
:confirmed, :paid, :consider, :observation, :notions_cost, :fabric_cost,
115115
production_products_attributes: [:id, :product_id, :quantity, :pieces_delivered, :delivery_date,
116116
:dirty, :error, :discard, :_destroy]
117117
)

app/views/productions/_form.html.erb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,19 @@
100100
</div>
101101

102102
<%= link_to_remove_association "Remove Product", f %>
103+
</div>
104+
105+
<div class="form-group">
106+
<%= form.label :notions_cost, "Valor dos Aviamentos" %>
107+
<%= form.number_field :notions_cost, step: 0.01, class: 'form-control' %>
108+
</div>
109+
110+
<div class="form-group">
111+
<%= form.label :fabric_cost, "Valor do Tecido" %>
112+
<%= form.number_field :fabric_cost, step: 0.01, class: 'form-control' %>
113+
</div>
114+
115+
<div class="form-group">
116+
<%= form.label :total_material_cost, "Custo Total de Materiais" %>
117+
<%= form.number_field :total_material_cost, step: 0.01, class: 'form-control', readonly: true %>
103118
</div>

app/views/productions/_production_card.html.erb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<h5 class="card-title">
55
<%= t('.service_order_number') %>: <%= production.service_order_number %>
66
</h5>
7-
<p class="card-text">
8-
<strong><%= t('.cut_date') %>:</strong> <%= production.cut_date.strftime('%d/%m/%Y') %>
9-
</p>
107
<p><strong><%= Production.human_attribute_name(:tailor) %>:</strong> <%= production.tailor.name %></p>
118
<p><strong><%= Production.human_attribute_name(:cut_date) %>:</strong> <%= pt_only_date_format(production.cut_date) if production.cut_date %></p>
129
<p><strong><%= Production.human_attribute_name(:expected_delivery_date) %>:</strong> <%= l(production.expected_delivery_date) if production.expected_delivery_date %></p>

app/views/productions/edit.html.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@
5555
</div>
5656
</div>
5757

58+
<div class="row mb-3">
59+
<div class="col-md-6">
60+
<%= form.label :notions_cost, t('productions.form.notions_cost'), class: 'form-label' %>
61+
<%= form.number_field :notions_cost, step: 0.01, class: 'form-control' %>
62+
</div>
63+
<div class="col-md-6">
64+
<%= form.label :fabric_cost, t('productions.form.fabric_cost'), class: 'form-label' %>
65+
<%= form.number_field :fabric_cost, step: 0.01, class: 'form-control' %>
66+
</div>
67+
</div>
68+
5869
<div class="row mb-3">
5970
<div class="col-12">
6071
<%= form.label :observation, model_class.human_attribute_name(:observation), class: 'form-label' %>

app/views/productions/new.html.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@
3636
</div>
3737
</div>
3838

39+
<div class="row mb-3">
40+
<div class="col-md-6">
41+
<%= form.label :notions_cost, t('productions.form.notions_cost'), class: 'form-label' %>
42+
<%= form.number_field :notions_cost, step: 0.01, class: 'form-control' %>
43+
</div>
44+
<div class="col-md-6">
45+
<%= form.label :fabric_cost, t('productions.form.fabric_cost'), class: 'form-label' %>
46+
<%= form.number_field :fabric_cost, step: 0.01, class: 'form-control' %>
47+
</div>
48+
</div>
49+
3950
<div class="row mb-3">
4051
<div class="col-12">
4152
<%= form.label :observation, model_class.human_attribute_name(:observation), class: 'form-label' %>

app/views/productions/show.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<dd class="col-sm-9"><%= @production.paid ? 'Sim' : 'Não' %></dd>
4343
<dt class="col-sm-3"><%= model_class.human_attribute_name(:observation) %>:</dt>
4444
<dd class="col-sm-9"><%= @production.observation %></dd>
45+
<dt class="col-sm-3"><%= model_class.human_attribute_name(:notions_cost) %>:</dt>
46+
<dd class="col-sm-9"><%= number_to_currency(@production.notions_cost) %></dd>
47+
<dt class="col-sm-3"><%= model_class.human_attribute_name(:fabric_cost) %>:</dt>
48+
<dd class="col-sm-9"><%= number_to_currency(@production.fabric_cost) %></dd>
4549
</dl>
4650
</div>
4751
</div>

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ en:
8585
observation: "Observation"
8686
pieces_delivered: "Pieces Delivered"
8787
pieces_missing: "Pieces Missing"
88+
notions_cost: "Notions Cost"
89+
fabric_cost: "Fabric Cost"
8890
production_product:
8991
product: "Product"
9092
quantity: "Quantity"

config/locales/pt-BR.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ pt-BR:
6262
dirty: "Sujo"
6363
error: "Erro"
6464
discard: "Descarte"
65+
production:
66+
notions_cost: "Custo de Aviamentos"
67+
fabric_cost: "Custo de Tecido"
68+
# Remove the total_material_cost line
6569
actions:
6670
remove_product: "Remover Produto"
6771
errors:
@@ -329,4 +333,7 @@ helpers:
329333
add_product: "Adicionar Produto"
330334
consider: "Considerar"
331335
submit_button: "Enviar"
336+
notions_cost: "Custo de Aviamentos"
337+
fabric_cost: "Custo de Tecido"
338+
# Remove the total_material_cost line
332339

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class AddMaterialCostsToProductions < ActiveRecord::Migration[7.0]
2+
def change
3+
add_column :productions, :notions_cost, :decimal, precision: 10, scale: 2
4+
add_column :productions, :fabric_cost, :decimal, precision: 10, scale: 2
5+
end
6+
end

0 commit comments

Comments
 (0)