diff --git a/.gitignore b/.gitignore index f4897780..b6d9a051 100644 --- a/.gitignore +++ b/.gitignore @@ -48,9 +48,9 @@ config/deploy/config/* #Gemfile.lock # For Redis Server log file -dump.rdb +/dump.rdb -# Fonts +# Fonts public/fonts/* # Ruby-Mine IDE folder diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 705b1a97..0840cec0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,18 +2,7 @@ - - - - - - - - - - - @@ -28,7 +17,7 @@ - + @@ -55,85 +44,51 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -165,6 +120,7 @@ mom gem "select2-rails" custom_excel + load @@ -173,12 +129,6 @@ @@ -292,6 +248,20 @@ + + + + + + + + + + + + + + @@ -311,22 +281,15 @@ - + - - - - - - - - - + + @@ -346,10 +309,13 @@ - - - - + + + + + + + + + +
+
+
+
+ Product +
+
+ +
+
+
+
+
+
+ Qty +
+
+ +
+
+
+
+
+
+ +
+
+ - - - - - - +
+
+
+
+ + + + + +
#ProductBalance
+ + + +
+
+ +
+
+ - - <% @stock_checks.each do |stock_check| %> - - <%= link_to 'Show', stock_check %> - <%= link_to 'Edit', edit_stock_check_path(stock_check) %> - <%= link_to 'Destroy', stock_check, method: :delete, data: { confirm: 'Are you sure?' } %> - - <% end %> - - + diff --git a/app/views/inventory/stock_checks/index.json.jbuilder b/app/views/inventory/stock_checks/index.json.jbuilder deleted file mode 100644 index 23740183..00000000 --- a/app/views/inventory/stock_checks/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @stock_checks, partial: 'stock_checks/stock_check', as: :stock_check diff --git a/app/views/inventory/stock_checks/new.html.erb b/app/views/inventory/stock_checks/new.html.erb deleted file mode 100644 index 503af621..00000000 --- a/app/views/inventory/stock_checks/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New Stock Check

- -<%= render 'form', stock_check: @stock_check %> - -<%= link_to 'Back', stock_checks_path %> diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 6c306d8d..4d0e83d0 100644 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -1,4 +1,83 @@ -

<%= notice %>

+
+ +
+
+
+ Check by +
+
+ <%= @check.check_by %> +
+
+
+
+ Check At +
+
+ <%= @check.created_at %>
+
+
+
+ Reason +
+
+ <%= @check.reason %> +
+
+
+
+ + + + + + + + + + <% + count = 0 + @check.stock_check_items.each do |item| + count += 1 + %> + + + + + + + + + <% end %> +
#ProductStock CountStock BalanceDifferentRemark
<%= count %><%= item.item_code %><%= item.stock_count %><%= item.stock_balance %><%= item.different %><%= item.remark %>
+
+
+
+ + + +
+
-<%= link_to 'Edit', edit_stock_check_path(@stock_check) %> | -<%= link_to 'Back', stock_checks_path %> + diff --git a/app/views/inventory/stock_checks/show.json.jbuilder b/app/views/inventory/stock_checks/show.json.jbuilder deleted file mode 100644 index 1a4ad710..00000000 --- a/app/views/inventory/stock_checks/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! "stock_checks/stock_check", stock_check: @stock_check diff --git a/app/views/layouts/inventory.html.erb b/app/views/layouts/inventory.html.erb index 5bcf7e0a..d6bbf436 100644 --- a/app/views/layouts/inventory.html.erb +++ b/app/views/layouts/inventory.html.erb @@ -9,7 +9,7 @@ SmartSales : Restaurant <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'inventory', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %> diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index b7f0cf1d..67c5c134 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -13,7 +13,7 @@
- @@ -43,7 +43,7 @@
- -
-
- - - - - - - - - - - - - <% @in_juties.each do |in_juty| %> - - - - - - - - - - <% end %> - -
Dining Facility NameCommissioner IdsIn timeOut time
<%= in_juty.dining_facility.name rescue '-' %><%= in_juty.commissioner.name rescue '-' %><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %><%= link_to 'Show', origami_in_juty_path(in_juty) %><%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %><%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %>
+
+
+ + + diff --git a/app/views/origami/in_juties/index_in_juty.html.erb b/app/views/origami/in_juties/index_in_juty.html.erb index c9247acd..52d79c89 100644 --- a/app/views/origami/in_juties/index_in_juty.html.erb +++ b/app/views/origami/in_juties/index_in_juty.html.erb @@ -22,7 +22,7 @@ <%= in_juty.commissioner.name rescue '-' %> <%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> <%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> - <%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> + <%= link_to 'Remove', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> <% end %> @@ -30,11 +30,16 @@ <%= paginate @juties_in %>
-
- <%= render 'assign_in_juty', in_juty: @in_juty, table: @table %> +
+ <%= render 'form', in_juty: @in_juty, table: @table %>
+
+      + +
+ diff --git a/app/views/origami/in_juties/new.html.erb b/app/views/origami/in_juties/new.html.erb index eb34f01c..f59ff6fd 100644 --- a/app/views/origami/in_juties/new.html.erb +++ b/app/views/origami/in_juties/new.html.erb @@ -6,5 +6,5 @@
  • New
  • - <%= render 'form', in_juty: @in_juty %> + <%= render 'form', in_juty: @in_juty, table: @table %> diff --git a/app/views/settings/commissions/load_commissioners.html.erb b/app/views/origami/product_commissions/load_commissioners.html.erb similarity index 100% rename from app/views/settings/commissions/load_commissioners.html.erb rename to app/views/origami/product_commissions/load_commissioners.html.erb diff --git a/app/views/settings/menu_item_instances/get_instance.json.jbuilder b/app/views/settings/menu_item_instances/get_instance.json.jbuilder index 136c1ff1..69302b8e 100644 --- a/app/views/settings/menu_item_instances/get_instance.json.jbuilder +++ b/app/views/settings/menu_item_instances/get_instance.json.jbuilder @@ -1,4 +1,28 @@ if(@id) + menu_item = MenuItem.find(@id.menu_item_id) + # Format for option json + opt_format = [] + # Format for attributes json + menu_item.item_options.each do|opt| + menu_opt = MenuItemOption.find(opt) + if opt_format.count == 0 + opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] }) + next + end + + opt_format.each do |of| + if menu_opt.option_type.in? opt_format.map {|k| k[:type]} + if menu_opt.option_type == of[:type] + of[:values].push(menu_opt.name) + end + else + new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] } + opt_format.push(new_opt) + break + end + end + end + json.success true json.id @id.id json.name @id.item_instance_name @@ -8,6 +32,8 @@ if(@id) json.attributes @id.item_attributes json.price @id.price json.is_default @id.is_default + + json.options opt_format else json.success false end diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index 1e4a3f86..bea1f981 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -39,9 +39,18 @@ <% end %> -
    -
    <%= f.input :promo_day %>
    + +
    + <%= f.hidden_field :promo_day, :value => "", :class => "form-control col-md-1" %> +
    Sun
    +
    Mon
    +
    Tue
    +
    Wed
    +
    Thu
    +
    Fri
    +
    Sat
    +
    <%= f.input :promo_type,input_html: { class: "" }, @@ -49,32 +58,79 @@
    -
    <%= f.input :original_product,collection: MenuItem.order("name desc").pluck(:name,:item_code),input_html: { selected: 2 } %>
    + <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> + <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
    + + + +
    + + <% sample = [] %> + <% if !@promotion.original_product.nil? %> + <% if !MenuItemInstance.find_by_item_instance_code(@promotion.original_product).nil? %> + <% sample = MenuItemInstance.where("item_instance_code=?",@promotion.original_product).pluck(:item_instance_name,:item_instance_code)%> + <% else %> + <% sample = Product.where("item_code=?",@promotion.original_product).pluck(:name,:item_code)%> + <% end %> + <% end %> +
    <%= f.input :original_product,collection: sample %>
    +
    <%= f.input :min_qty %>

    -
    Item Code
    +
    Item Code
    Min Qty
    Net off
    Net Price
    -
    Percentage
    -
    +
    Percentage
    +
    <%= f.fields_for :promotion_products do |pro| %>
    -
    <%= pro.input :item_code, label: false,collection: MenuItem.order("name desc").pluck(:name,:item_code)%>
    + <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> + <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
    + +
    + <% sample = [] %> +
    <%= pro.input :item_code, :class => 'promoproduct', collection: sample,input_html: { selected: 2 }, label: false %>
    <%= pro.input :min_qty , label: false%>
    <%= pro.input :net_off , label: false %>
    <%= pro.input :net_price , label: false %>
    -
    <%= pro.input :percentage , label: false %>
    -
    <%= pro.link_to_remove "X" %>
    +
    <%= pro.input :percentage , label: false %>
    +
    <%= pro.link_to_remove "X" %>
    <% end %>
    -
    <%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>
    +
    <%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary addProduct' %>
    @@ -86,6 +142,8 @@ <% end %> diff --git a/app/views/settings/promotions/index.html.erb b/app/views/settings/promotions/index.html.erb index b0cfd599..3274fae1 100644 --- a/app/views/settings/promotions/index.html.erb +++ b/app/views/settings/promotions/index.html.erb @@ -39,7 +39,13 @@ <%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %> <%= pro.promo_day %> - <%= MenuItem.find_by_item_code(pro.original_product).name rescue "-"%> + <% item = MenuItemInstance.find_by_item_instance_code(pro.original_product)%> + <% if item.nil? %> + <%= Product.find_by_item_code(pro.original_product).name rescue "-" %> + <% else %> + <%= item.menu_item.name rescue "-" %> + - <%= item.item_instance_name rescue "-" %> + <% end %> <% if Employee.exists?(pro.created_by) %> <%= Employee.find(pro.created_by).name %> diff --git a/app/views/settings/promotions/new.html.erb b/app/views/settings/promotions/new.html.erb index 321aa4d1..13918973 100644 --- a/app/views/settings/promotions/new.html.erb +++ b/app/views/settings/promotions/new.html.erb @@ -10,7 +10,11 @@ <%= render 'form', promotion: @promotion %> diff --git a/config/routes.rb b/config/routes.rb index 628ec753..65b7ab8a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,7 @@ Rails.application.routes.draw do resources :menu_item_attributes, only: [:index] resources :menu_item_options, only: [:index] resources :menu_sold_out, only: [:index] + resources :menu_item_instances, only: [:show] get "item_sets" => "item_sets#index" end @@ -184,6 +185,12 @@ Rails.application.routes.draw do resources :commissioners resources :in_juties + + # product_commission + get 'table/:table_id/sale/:sale_id/load_commissioners' => 'product_commissions#load_commissioners', as: 'load_commissioners' + post 'select_sale_item' => 'product_commissions#select_sale_item', as: 'select_sale_item' + post 'select_commissioner' => 'product_commissions#set_commissioner_to_sale_item', as: 'select_commissioner' + end #--------- Waiter/Ordering Station ------------# @@ -297,6 +304,7 @@ Rails.application.routes.draw do resources :promotions do resources :promotion_products end + get '/find_item_instance' => 'promotions#find_item_instance', as:'find_item_instance' # commission resources :commissions @@ -304,15 +312,9 @@ Rails.application.routes.draw do get '/get_transactions_by_commissioner' => 'commissioners#get_transaction_by_commissioner', as:'get_transaction_by_commissioner' - get 'menu_item_instances/get_instance/:id' => 'menu_item_instances#get_instance',:as => "show_instance" + # get 'menu_item_instances/get_instance/:id' => 'menu_item_instances#get_instance',:as => "show_instance" end - # commissions - get 'origami/table/:table_id/sale/:sale_id/load_commissioners' => 'settings/commissions#load_commissioners', as: 'load_commissioners' - post 'origami/select_sale_item' => 'settings/commissions#select_sale_item', as: 'select_sale_item' - # product_commission - post 'origami/select_commissioner' => 'origami/product_commissions#set_commissioner_to_sale_item', as: 'select_commissioner' - #--------- Transactions Sections ------------# namespace :transactions do resources :sales @@ -340,9 +342,13 @@ Rails.application.routes.draw do # ----------- Inventory --------------------------- namespace :inventory do - get 'inventory' => 'inventory#index' - resources :stock_check_items - resources :stock_checks + get '/' => 'inventory#index' + get '/stock_checks' => 'stock_checks#index' + post 'save_stock' => 'stock_checks#create', as:'stock_check_save' + get '/stock_checks/:id' => 'stock_checks#show' + post 'save_to_journal' => 'stock_checks#save_to_journal', as: 'save_to_journal' + post 'print_stock_check' => 'stock_checks#print_stock_check', as: 'print_stock_check' + # resources :stock_checks resources :stock_journals resources :inventory_definitions end diff --git a/db/migrate/20170824110103_create_inventory_definitions.rb b/db/migrate/20170824110103_create_inventory_definitions.rb index 4278ce89..ad63ac6b 100644 --- a/db/migrate/20170824110103_create_inventory_definitions.rb +++ b/db/migrate/20170824110103_create_inventory_definitions.rb @@ -1,9 +1,12 @@ class CreateInventoryDefinitions < ActiveRecord::Migration[5.1] + # rake db:migrate:down VERSION=20170824110103 def change create_table :inventory_definitions do |t| t.string :item_code t.integer :min_order_level, :default => 0 t.integer :max_stock_level, :default => 0 + t.integer :created_by + t.boolean :is_active, :default => true t.timestamps end end diff --git a/db/migrate/20170824110130_create_stock_check_items.rb b/db/migrate/20170824110130_create_stock_check_items.rb index c8908a1d..578ca893 100644 --- a/db/migrate/20170824110130_create_stock_check_items.rb +++ b/db/migrate/20170824110130_create_stock_check_items.rb @@ -1,7 +1,7 @@ class CreateStockCheckItems < ActiveRecord::Migration[5.1] def change create_table :stock_check_items do |t| - t.integer :stock_check_id, :null => false + t.integer :stock_check_id t.string :item_code, :null => false t.integer :stock_count, :default => 0 t.integer :stock_journal_id diff --git a/dump.rdb b/dump.rdb index 332310c7..29aafb9a 100644 Binary files a/dump.rdb and b/dump.rdb differ