inventorymaster 0.0.1 → 0.0.2

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: c08baa06dd7ae6f7d9ef110c71bea3b7c056721d
4
- data.tar.gz: b0118198395f9d383c218a69a1af3f072b5677db
3
+ metadata.gz: b46fc41fbd204bff01b7a94a41d528dc154aca8e
4
+ data.tar.gz: a9ab3f2077c84219d9c59a3628ccf5e5109b53ac
5
5
  SHA512:
6
- metadata.gz: 9475080feb1672870d2b52f88cb8f7001729003c5c79d7997800a574aa6e6cc8e3d8a966dcc93e80ac01907bb610e607e85e742c69344149f79a3c0156ea264c
7
- data.tar.gz: c3605029322249f49b639086f0cd36e78e5ef9a7472784f8878ab69b24276d261942ab549d9869ef7def32e87f9e66be18e34e2c9a24880f60d26e7b14996185
6
+ metadata.gz: 0b3dd3ac48d9382c1e9f8fe3cbc167cbdb1d7dbf418bcdb332792c8847fbe46ce88ed3c93d17768047ef5f6a27dce207482129c78b59d05af7514a8f930b93d6
7
+ data.tar.gz: 8e2af0e6e07d478493115f6934838823f8c37c9a397212359a2beb1341f5b9ddbcbeb9044ad73055295b6a1ae8ec64e79fdd83bbea003acf0f2cffbf0b0217f0
@@ -12,3 +12,6 @@
12
12
  //
13
13
  //= require_tree .
14
14
  //= require jquery_nested_form
15
+ //= require jquery-ui
16
+ //= require autocomplete-rails
17
+
@@ -3,10 +3,11 @@ require_dependency "inventorymaster/application_controller"
3
3
  module Inventorymaster
4
4
  class ProductsController < ApplicationController
5
5
  before_action :set_product, only: [:show, :edit, :update, :destroy]
6
-
6
+ autocomplete Inventorymaster::Product, :name
7
7
  # GET /products
8
8
  def index
9
- @products = Product.all
9
+ @products = Product.all.page(params[:page])
10
+ @product = Product.new
10
11
  end
11
12
 
12
13
  # GET /products/1
@@ -20,16 +21,30 @@ module Inventorymaster
20
21
  @locations = Location.all
21
22
  @transactiontypes = TransactionType.all
22
23
  #@product.transaction.build
24
+ @manufactures= Manufacturer.all
25
+ @areas = Area.all
23
26
 
24
27
  end
25
28
 
26
29
  # GET /products/1/edit
27
30
  def edit
31
+ @products = Product.all
32
+ @locations = Location.all
33
+ @transactiontypes = TransactionType.all
34
+ #@product.transaction.build
35
+ @manufactures= Manufacturer.all
36
+ @areas = Area.all
28
37
  end
29
38
 
30
39
  # POST /products
31
40
  def create
32
41
  @product = Product.new(product_params)
42
+ @products = Product.all
43
+ @locations = Location.all
44
+ @transactiontypes = TransactionType.all
45
+ #@product.transaction.build
46
+ @manufactures= Manufacturer.all
47
+ @areas = Area.all
33
48
  @product.ammount = 0
34
49
 
35
50
  if @product.save
@@ -1,4 +1,5 @@
1
1
  module Inventorymaster
2
2
  class Location < ActiveRecord::Base
3
+ has_many :products
3
4
  end
4
5
  end
@@ -1,6 +1,24 @@
1
1
  module Inventorymaster
2
2
  class Product < ActiveRecord::Base
3
+ belongs_to :location
4
+ belongs_to :area
5
+ belongs_to :manufacturer
3
6
  has_many :transactions
4
7
  accepts_nested_attributes_for :transactions
8
+
9
+ validates_uniqueness_of :sku
10
+ before_save do
11
+ if self.sku.blank?
12
+ self.sku = build_token(6)
13
+ end
14
+ end
15
+ def build_token(size)
16
+ begin
17
+ charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z}
18
+ sku = (0...size).map{ charset.to_a[rand(charset.size)] }.join
19
+ end while Product.exists?(sku: sku)
20
+ sku
21
+ end
22
+
5
23
  end
6
24
  end
@@ -1,5 +1,6 @@
1
1
  module Inventorymaster
2
2
  class Transaction < ActiveRecord::Base
3
- has_many :locations
3
+ belongs_to :location
4
+ belongs_to :user
4
5
  end
5
6
  end
@@ -1,4 +1,4 @@
1
- <h1>Editing Product</h1>
1
+ <h1>Editando Produto</h1>
2
2
 
3
3
  <%= form_for(@product) do |f| %>
4
4
  <% if @product.errors.any? %>
@@ -14,42 +14,45 @@
14
14
  <% end %>
15
15
 
16
16
  <div class="field">
17
- <%= f.label :name %><br>
17
+ <%= f.label :name ,"Nome"%><br>
18
18
  <%= f.text_field :name %>
19
19
  </div>
20
20
  <div class="field">
21
- <%= f.label :sku %><br>
21
+ <%= f.label :sku ,"SKU"%><br>
22
22
  <%= f.text_field :sku %>
23
23
  </div>
24
24
  <div class="field">
25
- <%= f.label :upc %><br>
25
+ <%= f.label :upc ,"UPC"%><br>
26
26
  <%= f.text_field :upc %>
27
27
  </div>
28
28
  <div class="field">
29
- <%= f.label :summary %><br>
29
+ <%= f.label :summary ,"Descrição"%><br>
30
30
  <%= f.text_area :summary %>
31
31
  </div>
32
32
  <div class="field">
33
- <%= f.label :labels %><br>
33
+ <%= f.label :labels,"Labels" %><br>
34
34
  <%= f.text_field :labels %>
35
+ </div>
36
+ <div class="field">
37
+ <%= f.label :location_id ,"Localização do Estoque"%><br>
38
+ <%= f.select :location_id , @locations.collect { |c| [ c.name, c.id ] } %>
35
39
  </div>
36
40
  <div class="field">
37
41
  <%= f.label :area_id %><br>
38
- <%= f.number_field :area_id %>
42
+ <%= f.select :area_id , @areas.collect { |c| [ c.name, c.id ] },:prompt => 'Selecione um Produto' %>
39
43
  </div>
40
44
  <div class="field">
41
45
  <%= f.label :manufacturer_id %><br>
42
- <%= f.number_field :manufacturer_id %>
46
+ <%= f.select :manufacturer_id , @manufactures.collect { |c| [ c.name, c.id ] },:prompt => 'Selecione um Produto' %>
43
47
  </div>
44
48
  <div class="field">
45
- <%= f.label :minimum_stock_count %><br>
49
+ <%= f.label :minimum_stock_count,"Estoque Minimo" %><br>
46
50
  <%= f.number_field :minimum_stock_count %>
47
51
  </div>
48
52
  <div class="actions">
49
- <%= f.submit %>
50
- </div>
53
+ <%= f.submit "Gravar",:class=>"btn btn-success"%>
51
54
  <% end %>
52
55
 
53
56
 
54
- <%= link_to 'Show', @product %> |
55
- <%= link_to 'Back', products_path %>
57
+ <%= link_to 'Detalhar', @product ,:class=>"btn btn-default"%> |
58
+ <%= link_to 'Voltar', products_path ,:class=>"btn btn-default"%>
@@ -2,6 +2,13 @@
2
2
  <h3><span class="glyphicon glyphicon-users"></span> Produtos</h3>
3
3
  </div>
4
4
 
5
+ <!--<%= form_for @product do |f| %>
6
+ <%=f.label :name %>
7
+ <%=f.autocomplete_field :name, autocomplete_product_name_products_path %>
8
+ <% end %>
9
+ -->
10
+
11
+
5
12
  <div align="right"><%= link_to 'Inserir Produto', new_product_path ,:class=>"btn btn-primary"%></div>
6
13
  <br>
7
14
 
@@ -20,12 +27,25 @@
20
27
 
21
28
  <tbody>
22
29
  <% @products.each do |product| %>
23
- <tr>
30
+ <%if product.minimum_stock_count.present?%>
31
+ <%if product.ammount < product.minimum_stock_count%>
32
+ <tr class="danger">
33
+ <%else%>
34
+ <tr>
35
+ <%end%>
36
+ <%else%>
37
+ <%if product.ammount < Inventorymaster::Setting.find(1).minimum_stock_count%>
38
+ <tr class="danger">
39
+ <%else%>
40
+ <tr>
41
+ <%end%>
42
+ <%end%>
43
+
24
44
  <td><%= product.name %></td>
25
45
  <td><%= product.sku %></td>
26
- <td><%= product.upc %></td>
27
- <td><%= product.area_id %></td>
28
- <td><%= product.manufacturer_id %></td>
46
+ <td><%if product.upc.present?%><%= product.upc %><%else%>-<%end%></td>
47
+ <td><%= product.area.name unless product.area.nil? %></td>
48
+ <td><%= product.manufacturer.name unless product.manufacturer.nil?%></td>
29
49
  <td><%= product.minimum_stock_count %></td>
30
50
  <td><%= link_to 'Detalhar', product ,:class=>"btn btn-xs btn-default"%></td>
31
51
  <td><%= link_to 'Editar', edit_product_path(product) ,:class=>"btn btn-xs btn-warning"%></td>
@@ -35,4 +55,5 @@
35
55
  </tbody>
36
56
  </table>
37
57
  <br>
58
+ <center><%= paginate @products %></center>
38
59
 
@@ -1,6 +1,6 @@
1
- <h1>New Product</h1>
1
+ <h1>Novo Produto</h1>
2
2
 
3
- <%= nested_form_for(@product) do |f| %>
3
+ <%= form_for(@product) do |f| %>
4
4
  <% if @product.errors.any? %>
5
5
  <div id="error_explanation">
6
6
  <h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
@@ -14,43 +14,46 @@
14
14
  <% end %>
15
15
 
16
16
  <div class="field">
17
- <%= f.label :name %><br>
17
+ <%= f.label :name ,"Nome"%><br>
18
18
  <%= f.text_field :name %>
19
19
  </div>
20
20
  <div class="field">
21
- <%= f.label :sku %><br>
22
- <%= f.text_field :sku %>
21
+ <%= f.label :sku ,"SKU"%><br>
22
+ <%= f.text_field :sku %> <i>se você deixar este campo em branco sera gerado um número automaticamente</i>
23
23
  </div>
24
24
  <div class="field">
25
- <%= f.label :upc %><br>
25
+ <%= f.label :upc,"UPC" %><br>
26
26
  <%= f.text_field :upc %>
27
27
  </div>
28
28
  <div class="field">
29
- <%= f.label :summary %><br>
29
+ <%= f.label :summary ,"Descrição"%><br>
30
30
  <%= f.text_area :summary %>
31
31
  </div>
32
32
  <div class="field">
33
- <%= f.label :labels %><br>
33
+ <%= f.label :labels,"Labels" %><br>
34
34
  <%= f.text_field :labels %>
35
35
  </div>
36
- <div class="field">
37
- <%= f.label :area_id %><br>
38
- <%= f.number_field :area_id %>
36
+ <div class="field">
37
+ <%= f.label :location_id ,"Localização do Estoque"%><br>
38
+ <%= f.select :location_id , @locations.collect { |c| [ c.name, c.id ] }%>
39
+ </div>
40
+ <div class="field">
41
+ <%= f.label :area_id ,"Area"%><br>
42
+ <%= f.select :area_id , @areas.collect { |c| [ c.name, c.id ] } %>
39
43
  </div>
40
44
  <div class="field">
41
- <%= f.label :manufacturer_id %><br>
42
- <%= f.number_field :manufacturer_id %>
45
+ <%= f.label :manufacturer_id,"Fabricante" %><br>
46
+ <%= f.select :manufacturer_id , @manufactures.collect { |c| [ c.name, c.id ] } %>
43
47
  </div>
44
48
  <div class="field">
45
- <%= f.label :minimum_stock_count %><br>
49
+ <%= f.label :minimum_stock_count,"Estoque Minimo" %><br>
46
50
  <%= f.number_field :minimum_stock_count %>
47
51
  </div>
48
52
 
49
53
 
50
54
  <div class="actions">
51
- <%= f.submit %>
52
- </div>
55
+ <%= f.submit "Gravar",:class=>"btn btn-success"%>
53
56
  <% end %>
54
57
 
55
58
 
56
- <%= link_to 'Back', products_path %>
59
+ <%= link_to 'Voltar', products_path ,:class=>"btn btn-default" %>
@@ -15,22 +15,22 @@
15
15
  <%= @product.ammount %>
16
16
  </p>
17
17
  <p>
18
- <strong>Name:</strong>
18
+ <strong>Nome:</strong>
19
19
  <%= @product.name %>
20
20
  </p>
21
21
 
22
22
  <p>
23
- <strong>Sku:</strong>
23
+ <strong>SKU:</strong>
24
24
  <%= @product.sku %>
25
25
  </p>
26
26
 
27
27
  <p>
28
- <strong>Upc:</strong>
28
+ <strong>UPC:</strong>
29
29
  <%= @product.upc %>
30
30
  </p>
31
31
 
32
32
  <p>
33
- <strong>Summary:</strong>
33
+ <strong>Descrição:</strong>
34
34
  <%= @product.summary %>
35
35
  </p>
36
36
 
@@ -45,21 +45,19 @@
45
45
  </p>
46
46
 
47
47
  <p>
48
- <strong>Manufacturer:</strong>
48
+ <strong>Fabricante:</strong>
49
49
  <%= @product.manufacturer_id %>
50
50
  </p>
51
51
 
52
52
  <p>
53
- <strong>Minimum stock count:</strong>
53
+ <strong>Estoque Minimo:</strong>
54
54
  <%= @product.minimum_stock_count %>
55
55
  </p>
56
56
 
57
- <%= link_to 'Edit', edit_product_path(@product) %> |
58
- <%= link_to 'Back', products_path %>
57
+ <%= link_to 'Editar', edit_product_path(@product) ,:class=>"btn btn-warning"%> |
58
+ <%= link_to 'Voltar', products_path,:class=>"btn btn-default" %>
59
59
  <hr>
60
-
61
- <%@product.transactions.each do |transaction|%>
62
- <table class="table table-condensed">
60
+ <table class="table table-striped" style="text-align:left;">
63
61
  <tr>
64
62
  <td>Tipo</td>
65
63
  <td>Data</td>
@@ -72,20 +70,21 @@
72
70
  <td>Custo Medio</td>
73
71
  <td>Motivo</td>
74
72
  </tr>
73
+ <%@product.transactions.each do |transaction|%>
75
74
  <tr>
76
75
  <td><%=transaction.kind%></td>
77
- <td><%=transaction.date%></td>
78
- <td><%=transaction.location_id%></td>
79
- <td><%=transaction.user_id%></td>
80
- <td><%=transaction.upc%></td>
76
+ <td><%=transaction.date.strftime("%d/%m/%Y")%></td>
77
+ <td><%=transaction.user.first_name unless transaction.user.nil?%></td>
78
+ <td><%if transaction.upc.present?%><%=transaction.upc%><%else%>-<%end%></td>
81
79
  <td><%=transaction.unit_cost%></td>
82
80
  <td><%=transaction.unit_sale%></td>
83
- <td><%=transaction.ammount%></td>
81
+ <td><%if transaction.kind == "Saida"%><font color="red">-</font><%else%><font color="blue">+</font><%end%><%=transaction.ammount%></td>
84
82
  <td><%=transaction.average_cost%></td>
85
83
  <td><%=transaction.reason%></td>
86
84
  </tr>
87
- </table>
85
+
88
86
  <%end%>
87
+ </table>
89
88
 
90
89
 
91
90
 
@@ -0,0 +1,10 @@
1
+ Kaminari.configure do |config|
2
+ config.default_per_page = 10
3
+ # config.max_per_page = nil
4
+ # config.window = 4
5
+ # config.outer_window = 0
6
+ # config.left = 0
7
+ # config.right = 0
8
+ # config.page_method_name = :page
9
+ # config.param_name = :page
10
+ end
@@ -4,7 +4,9 @@ Inventorymaster::Engine.routes.draw do
4
4
  get ':transactions/:id', to: 'transactions#new', on: :member
5
5
  end
6
6
 
7
- resources :products
7
+ resources :products do
8
+ get :autocomplete_product_name, :on => :collection
9
+ end
8
10
  resources :settings
9
11
  resources :manufacturers
10
12
  resources :areas
@@ -0,0 +1,5 @@
1
+ class AddlocationToProduct < ActiveRecord::Migration
2
+ def change
3
+ add_column :inventorymaster_products, :location_id, :integer
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventorymaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jcottobboni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-03 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails4-autocomplete
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: This gem provides a basic inventory system engine
56
70
  email:
57
71
  - jcottobboni@gmail.com
@@ -138,6 +152,7 @@ files:
138
152
  - app/views/inventorymaster/transactions/new.html.erb
139
153
  - app/views/inventorymaster/transactions/show.html.erb
140
154
  - app/views/layouts/inventorymaster/application.html.erb
155
+ - config/initializers/kaminari_config.rb
141
156
  - config/routes.rb
142
157
  - db/migrate/20150502125839_create_inventorymaster_locations.rb
143
158
  - db/migrate/20150502133104_create_inventorymaster_areas.rb
@@ -148,6 +163,7 @@ files:
148
163
  - db/migrate/20150502141015_create_inventorymaster_transaction_types.rb
149
164
  - db/migrate/20150502141139_addproduct_to_transaction.rb
150
165
  - db/migrate/20150502144050_add_amount_to_product.rb
166
+ - db/migrate/20150504000356_addlocation_to_product.rb
151
167
  - lib/inventorymaster.rb
152
168
  - lib/inventorymaster/engine.rb
153
169
  - lib/inventorymaster/version.rb