change product account
This commit is contained in:
@@ -5,11 +5,18 @@ class Product < ApplicationRecord
|
|||||||
mount_uploader :image_path, ProductImageUploader
|
mount_uploader :image_path, ProductImageUploader
|
||||||
|
|
||||||
def self.search_by_product_code(item_code)
|
def self.search_by_product_code(item_code)
|
||||||
|
account = Account.where('title','like','%Product%').first()
|
||||||
|
if !account.nil?
|
||||||
|
account_id = account.id
|
||||||
|
else
|
||||||
|
account_id = 1
|
||||||
|
end
|
||||||
|
|
||||||
menu_item_hash = Hash.new
|
menu_item_hash = Hash.new
|
||||||
mt_instance = Product.find_by_item_code(item_code)
|
mt_instance = Product.find_by_item_code(item_code)
|
||||||
if (!mt_instance.nil?)
|
if (!mt_instance.nil?)
|
||||||
menu_item_hash[:type] = 'Product'
|
menu_item_hash[:type] = 'Product'
|
||||||
menu_item_hash[:account_id] = 3
|
menu_item_hash[:account_id] = account_id
|
||||||
menu_item_hash[:item_code] = mt_instance.item_code
|
menu_item_hash[:item_code] = mt_instance.item_code
|
||||||
menu_item_hash[:item_instance_code] = mt_instance.item_code
|
menu_item_hash[:item_instance_code] = mt_instance.item_code
|
||||||
menu_item_hash[:name] = mt_instance.name.to_s
|
menu_item_hash[:name] = mt_instance.name.to_s
|
||||||
|
|||||||
Reference in New Issue
Block a user