add menu item taxable
This commit is contained in:
@@ -141,6 +141,6 @@ class Settings::SetMenuItemsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def settings_menu_item_params
|
def settings_menu_item_params
|
||||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
|
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -157,6 +157,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def settings_menu_item_params
|
def settings_menu_item_params
|
||||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
|
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class MenuItem < ApplicationRecord
|
|||||||
has_many :menu_item_sets
|
has_many :menu_item_sets
|
||||||
has_many :item_sets, through: :menu_item_sets
|
has_many :item_sets, through: :menu_item_sets
|
||||||
|
|
||||||
validates_presence_of :item_code, :name, :type, :min_qty, :taxable,:account_id
|
validates_presence_of :item_code, :name, :type, :min_qty,:account_id
|
||||||
validates_uniqueness_of :item_code
|
validates_uniqueness_of :item_code
|
||||||
|
|
||||||
default_scope { order('item_code asc') }
|
default_scope { order('item_code asc') }
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
|
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
|
||||||
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
||||||
self.employee_name)
|
self.employee_name, menu_item[:taxable])
|
||||||
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class OrderItem < ApplicationRecord
|
|||||||
# option_values : [],
|
# option_values : [],
|
||||||
# sub_order_items : [],
|
# sub_order_items : [],
|
||||||
# }
|
# }
|
||||||
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
|
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by, taxable)
|
||||||
|
|
||||||
orderitem = OrderItem.create do |oitem|
|
orderitem = OrderItem.create do |oitem|
|
||||||
oitem.order_id = order_id
|
oitem.order_id = order_id
|
||||||
@@ -31,6 +31,7 @@ class OrderItem < ApplicationRecord
|
|||||||
oitem.account_id = account_id
|
oitem.account_id = account_id
|
||||||
oitem.qty = qty
|
oitem.qty = qty
|
||||||
oitem.price = price
|
oitem.price = price
|
||||||
|
oitem.taxable = taxable
|
||||||
oitem.options = options
|
oitem.options = options
|
||||||
oitem.set_menu_items = set_menu_items
|
oitem.set_menu_items = set_menu_items
|
||||||
oitem.item_order_by = item_order_by #person who order this. * If emenu - it will be login user on the app
|
oitem.item_order_by = item_order_by #person who order this. * If emenu - it will be login user on the app
|
||||||
|
|||||||
@@ -225,7 +225,11 @@ class Sale < ApplicationRecord
|
|||||||
puts "item.sales_item_id ddd"
|
puts "item.sales_item_id ddd"
|
||||||
puts item.sale_item_id
|
puts item.sale_item_id
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
total_taxable = total_taxable + item.taxable_price
|
|
||||||
|
# only calc tax when true
|
||||||
|
if(item.is_taxable)
|
||||||
|
total_taxable = total_taxable + item.taxable_price
|
||||||
|
end
|
||||||
# total_taxable = total_taxable + (item.taxable_price * item.qty)
|
# total_taxable = total_taxable + (item.taxable_price * item.qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -287,7 +291,11 @@ class Sale < ApplicationRecord
|
|||||||
if item.remark != 'void' && item.remark != 'foc'
|
if item.remark != 'void' && item.remark != 'foc'
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
total_taxable = total_taxable + item.price
|
|
||||||
|
# only calc tax when true
|
||||||
|
if(item.is_taxable)
|
||||||
|
total_taxable = total_taxable + item.taxable_price
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
|
<%= f.input :taxable,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
|
<%= f.input :taxable,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|
||||||
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>
|
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>
|
||||||
|
|||||||
Reference in New Issue
Block a user