update inventory and shop and seed

This commit is contained in:
Aung Myo
2018-10-09 16:12:52 +06:30
parent 1816b76028
commit 87502ec0f2
17 changed files with 92 additions and 75 deletions

View File

@@ -3,7 +3,7 @@ module LoginVerification
included do
before_action :authenticate_session_token
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
end
#this is base api base controller to need to inherit.
@@ -17,6 +17,14 @@ module LoginVerification
end
end
def current_shop
begin
return Shop.first
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
end

View File

@@ -1,45 +1,13 @@
class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource
def index
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC LIMIT 1"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance,"+
"acc.title as account_name,mi.name as item_name,
mii.item_instance_name as instance_name," +
"mc.name as menu_category_name,mc.id as menu_category_id "
)
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
filter = params[:filter]
@inventory_definitions = InventoryDefinition.get_by_category(filter)
end
# def self.get_item_query(type)
# query = Sale.select("acc.title as account_name,mi.name as item_name,mii.item_instance_name as instance_name" +
# "mc.name as menu_category_name,mc.id as menu_category_id ")
# query = query.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
# " JOIN menu_items mi ON mi.id = mii.menu_item_id" +
# " JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
# query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
# query = query.group("acc.title,mi.account_id,mi.menu_category_id")
# .order("acc.title desc, mi.account_id desc, mi.menu_category_id desc")
# end
def show
inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find(inventory_definition_id)

View File

@@ -41,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController
member_info = nil
unique_code = 'StockCheckPdf'
shop_details = Shop.find(1)
shop_details = current_shop
checker = Employee.find(stockcheck.check_by)
print_settings = PrintSetting.find_by_unique_code(unique_code)
if !print_settings.nil?
@@ -66,7 +66,7 @@ class Inventory::StockChecksController < BaseInventoryController
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
@shop = current_shop
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]

View File

@@ -109,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate

View File

@@ -90,7 +90,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate

View File

@@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController
File.delete(delete_path)
end
end
save_path = Rails.root.join("public/#{Shop.find(1).shop_code}_#{a.original_filename}")
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
File.open(save_path, 'wb') do |f|
f.write a.read
end
audio_name = "#{Shop.find(1).shop_code}_#{a.original_filename}"
audio_name = "#{current_shop.shop_code}_#{a.original_filename}"
@settings_shop.display_images.where(:name => "order_audio").destroy_all
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
else

View File

@@ -72,10 +72,37 @@ class InventoryDefinition < ApplicationRecord
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.where("mc.id=#{cat_id}")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("mi.menu_category_id desc")
.order("mi.menu_category_id desc")
end
def self.get_by_category(filter)
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC LIMIT 1"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance,"+
"acc.title as account_name,mi.name as item_name,
mii.item_instance_name as instance_name," +
"mc.name as menu_category_name,mc.id as menu_category_id "
)
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
.where("inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ?
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
end
end

View File

@@ -20,10 +20,10 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class CustomerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -15,15 +15,15 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"image/menu_images/#{Shop.find(1).shop_code}"
"image/menu_images/#{current_shop.shop_code}"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ProductImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ShopImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -7,8 +7,22 @@
</span>
</ol>
</div>
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="font-14"><%= t("views.right_panel.detail.product") %></label>
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 text-">
<br>
<input type="submit" value="Filter" class='btn btn-primary'>
</div>
</div>
<% end %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="m-b-10 clearfix">

View File

@@ -19,7 +19,7 @@ class ActionController::Base
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
check for license file
# check for license file
if check_license
current_license(ENV["SX_PROVISION_URL"])
else

View File

@@ -208,26 +208,26 @@ queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf
zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paypar.ws",merchant_account_id:"pZBHXEFbGNj/G"})
member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"},
{membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv",auth_token:"code2lab"}
member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"},
{membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "/api/membership_campaigns/redeem",merchant_account_id:"pZBHXEFbGNj/G"})
#Default Order Queue stations
# order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})

View File

@@ -3,7 +3,7 @@ namespace :consolidate do
task :receipt => :environment do
# Receipt.delete_all
sales = Sale.all_receipts
shop = Shop.find(1)
shop = current_shop
sales.each do |sale|
if sale.shift_sale_id.present?
@@ -57,7 +57,7 @@ namespace :consolidate do
ReceiptDetail.delete_all
sales = Sale.all_receipt_details
shop = Shop.find(1)
shop = current_shop
sale_id = ''
count = 0