inventorymaster 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3db309a0b7ef8ab9589453e6e11028501e401153
4
- data.tar.gz: b4d46b40fef05cb4a30efb8ca72bea911190e178
3
+ metadata.gz: 7d09361368f333253ad8197b441edca6a9922995
4
+ data.tar.gz: 71940e1320e0e7b8081e70c132de4d440ac84f0a
5
5
  SHA512:
6
- metadata.gz: afe960edc6c193ba1731679575c3dbb7489adecec11f03bdbf3388597c2e97fd43cacfdc8005e6148cb9de964219b4af18757eaffd2f8c16c9247bbf38a67a1d
7
- data.tar.gz: 3b4aaeebb8e83115e4c21c8b0526fbf8e3e87287f1f2b893234e951a99dec6dbae53335ad7373f63e4e021b2081b455e7cb0271c0fe25e326848224c3a086ece
6
+ metadata.gz: e6b3309797d11e643a41c7794ee129ef907a1f40b2e39b0c2b9f509346e2e951e3b62662144f4d520ebf93dfcdc890e705b4a57ee3794f7c05c9657bf56f19e3
7
+ data.tar.gz: e185202b758ba3a3a8739b1f95a779f24d3984ee4d95f4b95b2be38f6aaa974f57edb438819c81de648dfb05196609570130456c6d79c15abfc46adc9a545a29
@@ -1,5 +1,13 @@
1
1
  module Inventorymaster
2
2
  module ProductsHelper
3
-
3
+ def average_cost(unit_cost,ammount)
4
+ if unit_cost == nil
5
+ return @cost / @average
6
+ else
7
+ @average += ammount
8
+ @cost += unit_cost* ammount
9
+ return @cost / @average
10
+ end
11
+ end
4
12
  end
5
13
  end
@@ -1,6 +1,6 @@
1
1
  module Inventorymaster
2
2
  class Product < ActiveRecord::Base
3
- searchkick autocomplete: ['name']
3
+ searchkick autocomplete: ['name','sku']
4
4
  belongs_to :location
5
5
  belongs_to :area
6
6
  belongs_to :manufacturer
@@ -2,5 +2,6 @@ module Inventorymaster
2
2
  class Transaction < ActiveRecord::Base
3
3
  belongs_to :location
4
4
  belongs_to :user
5
+ belongs_to :transaction_type
5
6
  end
6
7
  end
@@ -71,8 +71,21 @@
71
71
  <td><span class="label label-warning"><%= product.minimum_stock_count %></span></td>
72
72
  <td><span class="label label-primary"><%= product.ammount %></span></td>
73
73
  <td><%= link_to 'Detalhar', product ,:class=>"btn btn-xs btn-default"%></td>
74
- <td><%= link_to 'Editar', edit_product_path(product) ,:class=>"btn btn-xs btn-warning"%></td>
75
- <td><%= link_to 'Deletar', product, method: :delete, data: { confirm: 'Voce tem Certeza?' },:class=>"btn btn-xs btn-danger" %></td>
74
+ <td>
75
+ <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
76
+ <%= hidden_field_tag 'product_id',nil,:value => product.id%>
77
+ <%= hidden_field_tag 'kind',nil,:value => "Entrada"%>
78
+ <%= submit_tag("+ Entrada", :class => 'btn btn-xs btn-success') %>
79
+ <% end %>
80
+ </td>
81
+ <td>
82
+ <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
83
+ <%= hidden_field_tag 'product_id',nil,:value => product.id%>
84
+ <%= hidden_field_tag 'kind',nil,:value => "Saida"%>
85
+ <%= submit_tag("+ Saida", :class => 'btn btn-xs btn-danger') %>
86
+ <% end %>
87
+ </td>
88
+
76
89
  </tr>
77
90
  <% end %>
78
91
  </tbody>
@@ -1,24 +1,46 @@
1
1
 
2
- <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
2
+
3
+ <table >
4
+ <tr>
5
+ <td><%= link_to 'Voltar', products_path,:class=>"btn btn-default btn-xs" %></td>
6
+ <td>&nbsp;</td>
7
+ <td><%= link_to 'Editar', edit_product_path(@product) ,:class=>"btn btn-xs btn-warning"%></td>
8
+ <td>&nbsp;</td>
9
+ <td><%= link_to 'Deletar', @product, method: :delete, data: { confirm: 'Voce tem Certeza?' },:class=>"btn btn-xs btn-danger" %></td>
10
+ <td>&nbsp;</td>
11
+ <td>
12
+ <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
3
13
  <%= hidden_field_tag 'product_id',nil,:value => @product.id%>
4
14
  <%= hidden_field_tag 'kind',nil,:value => "Entrada"%>
5
- <%= submit_tag("+ Entrada", :class => 'btn btn-small btn-success') %>
15
+ <%= submit_tag("+ Entrada", :class => 'btn btn-xs btn-success') %>
6
16
  <% end %>
7
17
 
8
- <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
18
+
19
+ </td>
20
+ <td>&nbsp;</td>
21
+ <td>
22
+ <%= form_tag({:controller=>'transactions',:action=>'new'}, {:method => :get}) do %>
9
23
  <%= hidden_field_tag 'product_id',nil,:value => @product.id%>
10
24
  <%= hidden_field_tag 'kind',nil,:value => "Saida"%>
11
- <%= submit_tag("+ Saida", :class => 'btn btn-small btn-danger') %>
25
+ <%= submit_tag("+ Saida", :class => 'btn btn-xs btn-danger') %>
12
26
  <% end %>
13
- <p>
14
- <%= link_to 'Editar', edit_product_path(@product) ,:class=>"btn btn-xs btn-warning"%>
15
- <%= link_to 'Deletar', @product, method: :delete, data: { confirm: 'Voce tem Certeza?' },:class=>"btn btn-xs btn-danger" %>
27
+
28
+ </td>
29
+ </tr>
30
+ </table>
31
+
32
+
33
+
34
+
35
+ <br>
36
+ <br>
37
+ <p>
16
38
  <strong>Quantidade em Estoque:</strong>
17
39
  <span class="label label-primary"><%= @product.ammount %></span>
18
40
  </p>
19
41
  <p>
20
42
  <strong>Nome:</strong>
21
- <%= @product.name %>
43
+ <%= @product.name.upcase %>
22
44
  </p>
23
45
 
24
46
  <p>
@@ -43,12 +65,12 @@
43
65
 
44
66
  <p>
45
67
  <strong>Area:</strong>
46
- <%= @product.area_id %>
68
+ <%= @product.area.name%>
47
69
  </p>
48
70
 
49
71
  <p>
50
72
  <strong>Fabricante:</strong>
51
- <%= @product.manufacturer_id %>
73
+ <%= @product.manufacturer.name %>
52
74
  </p>
53
75
 
54
76
  <p>
@@ -56,8 +78,9 @@
56
78
  <%= @product.minimum_stock_count %>
57
79
  </p>
58
80
 
59
- <%= link_to 'Editar', edit_product_path(@product) ,:class=>"btn btn-warning"%> |
60
- <%= link_to 'Voltar', products_path,:class=>"btn btn-default" %>
81
+ <%@average=0%>
82
+ <%@cost=0%>
83
+
61
84
  <hr>
62
85
  <table class="table table-striped" style="text-align:left;">
63
86
  <tr>
@@ -71,17 +94,17 @@
71
94
  <td>Custo Medio</td>
72
95
  <td>Motivo</td>
73
96
  </tr>
74
- <%@product.transactions.each do |transaction|%>
97
+ <%@product.transactions.order("created_at ASC").each do |transaction|%>
75
98
  <tr>
76
99
  <td><%=transaction.kind%></td>
77
100
  <td><%=transaction.date.strftime("%d/%m/%Y")%></td>
78
101
  <td><%=transaction.user.first_name unless transaction.user.nil?%></td>
79
102
  <td><%if transaction.upc.present?%><%=transaction.upc%><%else%>-<%end%></td>
80
- <td><%=transaction.unit_cost%></td>
81
- <td><%=transaction.unit_sale%></td>
103
+ <td><%=number_to_currency(transaction.unit_cost,:precision=>2)%></td>
104
+ <td><%=number_to_currency(transaction.unit_sale,:precision=>2)%></td>
82
105
  <td><%if transaction.kind == "Saida"%><font color="red">-</font><%else%><font color="blue">+</font><%end%><%=transaction.ammount%></td>
83
- <td><%=transaction.average_cost%></td>
84
- <td><%=transaction.reason%></td>
106
+ <td><%=number_to_currency(average_cost(transaction.unit_cost,transaction.ammount),:precision=>2)%></td>
107
+ <td><%=transaction.transaction_type.name%></td>
85
108
  </tr>
86
109
 
87
110
  <%end%>
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  <% end %>
13
13
 
14
- <%f.hidden_field :user_id,:value=>current_user.id%>
14
+ <%= f.hidden_field :user_id, :value => current_user.id %>
15
15
 
16
16
  <div class="field" style="display:none;">
17
17
  <%= f.label :product_id ,"Produto"%><br>
@@ -31,6 +31,7 @@
31
31
  <%= f.label :upc ,"UPC"%><br>
32
32
  <%= f.text_field :upc %>
33
33
  </div>
34
+
34
35
  <div class="field">
35
36
  <%= f.label :unit_cost,"Custo Unitário" %><br>
36
37
  <%= f.text_field :unit_cost %>
@@ -0,0 +1,11 @@
1
+ module ActionView
2
+ module Helpers
3
+ module NumberHelper
4
+ def number_to_currency_with_real(number, options = {})
5
+ defaults = {:unit => 'R$', :format => "%u %n", :separator => ",", :delimiter => "."}
6
+ s = number_to_currency_without_real(number, defaults.merge(options))
7
+ end
8
+ alias_method_chain :number_to_currency, :real
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventorymaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - jcottobboni
@@ -152,6 +152,7 @@ files:
152
152
  - app/views/inventorymaster/transactions/new.html.erb
153
153
  - app/views/inventorymaster/transactions/show.html.erb
154
154
  - app/views/layouts/inventorymaster/application.html.erb
155
+ - config/initializers/format_money.rb
155
156
  - config/initializers/kaminari_config.rb
156
157
  - config/routes.rb
157
158
  - db/migrate/20150502125839_create_inventorymaster_locations.rb