Menu item with Accout

This commit is contained in:
PhyoTheingi
2017-06-06 17:29:34 +06:30
parent 2abc2e5f3d
commit 59434e2c3a
11 changed files with 25 additions and 11 deletions

View File

@@ -81,6 +81,6 @@ class Settings::SetMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -78,6 +78,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -3,5 +3,7 @@ class Account < ApplicationRecord
has_many :menu_items
# belongs_to :lookup , :class_name => "Lookup"
def self.collection
Account.select("id, title").map { |e| [e.title, e.id] }
end
end

View File

@@ -1,9 +1,10 @@
class MenuItem < ApplicationRecord
# belongs_to :account
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item

View File

@@ -6,6 +6,7 @@
<%= f.input :name %>
<%= f.input :alt_name %>
<%= f.input :type %>
<%= f.input :account_id, :label => "Account type", :collection => Account.collection %>
<%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %>
<%= f.input :min_qty %>

View File

@@ -19,6 +19,7 @@
<th>Name</th>
<th>Alt name</th>
<th>Type</th>
<th>Account Type</th>
<th>Menu category</th>
<th>Menu item</th>
<th>Min qty</th>
@@ -35,6 +36,7 @@
<td><%= @settings_menu_item.name rescue "-" %></td>
<td><%= @settings_menu_item.alt_name %></td>
<td><%= @settings_menu_item.type %></td>
<td><%= @settings_menu_item.account.title %></td>
<td><%= @settings_menu_item.menu_category_id %></td>
<td><%= @settings_menu_item.menu_item_id %></td>
<td><%= @settings_menu_item.min_qty %></td>

View File

@@ -6,6 +6,7 @@
<%= f.input :name %>
<%= f.input :alt_name %>
<%= f.input :type %>
<%= f.input :account_id, :label => "Account type", :collection => Account.collection %>
<%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %>
<%= f.input :min_qty %>
<%= f.input :min_selectable_item %>

View File

@@ -21,6 +21,7 @@
<th>Name</th>
<th>Alt name</th>
<th>Type</th>
<th>Accout</th>
<th>Menu category</th>
<th>Menu item</th>
<th>Min qty</th>
@@ -37,6 +38,7 @@
<td><%= @settings_menu_item.name rescue "-" %></td>
<td><%= @settings_menu_item.alt_name %></td>
<td><%= @settings_menu_item.type %></td>
<td><%= @settings_menu_item.account.title %></td>
<td><%= @settings_menu_item.menu_category_id %></td>
<td><%= @settings_menu_item.menu_item_id %></td>
<td><%= @settings_menu_item.min_qty %></td>