edit for shop_code query

This commit is contained in:
Thein Lin Kyaw
2020-01-13 15:28:26 +06:30
parent bad46cf02c
commit d379c05298
32 changed files with 58 additions and 115 deletions

View File

@@ -43,7 +43,7 @@ class Employee < ApplicationRecord
if (session_token)
user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time
if !user.session_expiry.nil?
if user && !user.session_expiry.nil?
if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes

View File

@@ -1,7 +1,6 @@
class Lookup < ApplicationRecord
has_many :accounts
belongs_to :shop
scope :number_formats, -> { where(lookup_type: 'number_format')}
@@ -26,12 +25,10 @@ class Lookup < ApplicationRecord
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end
def self.time_limit
TIME_LIMIT
end
def self.get_checkin_time_limit
return RequestStore[:checkin_time_limit] if RequestStore[:checkin_time_limit]
RequestStore[:checkin_time_limit] = Lookup.find_by_lookup_type('checkin_time_limit').value.to_i rescue time_limit
@@ -63,41 +60,39 @@ class Lookup < ApplicationRecord
Lookup.where("lookup_type" => type ).pluck("name, value")
end
def self.create_shift_sale_lookup(shop_code)
def self.create_shift_sale_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'shift_sale_items'
@lookup.name = 'Shift Sale Items'
@lookup.value = 0
@lookup.shop_code = shop_code
@lookup.save
return @lookup
end
def self.create_reprint_receipt_lookup(shop_code)
def self.create_reprint_receipt_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'reprint_receipt'
@lookup.name = 'Reprint Receipt in Report'
@lookup.value = 0
@lookup.shop_code = shop_code
@lookup.save
return @lookup
end
def self.save_shift_sale_items_settings(val,shop_code)
def self.save_shift_sale_items_settings(val)
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
@lookup = Lookup.create_shift_sale_lookup
end
@lookup.value = val
@lookup.save
end
def self.shift_sale_items_lookup_value(shop_code)
def self.shift_sale_items_lookup_value
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
@lookup = Lookup.create_shift_sale_lookup
end
return @lookup.value
end

View File

@@ -90,20 +90,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation,transaction_ref)
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, order_reservation = nil, transaction_ref = nil)
#Use CUPS service
#Generate PDF
#Print
if printer_settings
if !printer_settings.unique_code.match?(/receiptbillorder/i)
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount)
else
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, transaction_ref)
end
else
#doemal online order pdf template
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
end
# print as print copies in printer setting

View File

@@ -33,7 +33,7 @@ class ProductCommission < ApplicationRecord
product_commission.save
end
def self.edit_product_commission(saleItemObj,shop_code)
def self.edit_product_commission(saleItemObj)
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take

View File

@@ -705,7 +705,7 @@ class SalePayment < ApplicationRecord
self.sale.cashier_name = Employee.find(shift.employee_id).name
self.sale.save
else
shift = ShiftSale.current_shift(self.sale.shop_code)
shift = ShiftSale.current_shift
shift.update(self.sale)
self.sale.shift_sale_id = shift.id
self.sale.cashier_id = shift.employee_id