remove conflict data

This commit is contained in:
phyusin
2018-07-10 18:13:41 +06:30
23 changed files with 850 additions and 33 deletions

View File

@@ -8,6 +8,10 @@ class AssignedOrderItem < ApplicationRecord
belongs_to :order_queue_station
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
<<<<<<< HEAD
AssignedOrderItem.transaction do
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
assigned_order_item = AssignedOrderItem.new()
assigned_order_item.order = order
assigned_order_item.item_code = item_code
@@ -16,6 +20,10 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.print_status = false
assigned_order_item.delivery_status = false
assigned_order_item.save!
<<<<<<< HEAD
end
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
end
def self.assigned_order_item_by_job(order_id)

View File

@@ -3,7 +3,11 @@ class PrintSetting < ApplicationRecord
validates_presence_of :name, :unique_code, :printer_name, :api_settings, :page_width, :page_height, :print_copies, :header_font_size, :item_font_size
def self.get_precision_delimiter
PrintSetting.find_by_unique_code("CloseCashierPdf")
setting = PrintSetting.find_by_unique_code("CloseCashierPdf")
if setting.nil?
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
end
return setting
end
end

View File

@@ -37,7 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# pdf.render_file filename
# self.print(filename, cashier_terminal.printer_name)
# end
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
#Use CUPS service
@@ -46,16 +46,16 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,@total_waste,@total_spoile)
else
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
end
end
end

View File

@@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,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)
def print_receipt_bill(printer_settings,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)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.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)
pdf = ReceiptBillPdf.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)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
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)
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)
else
pdf = ReceiptBillPdf.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)
pdf = ReceiptBillPdf.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)
end
end
end

View File

@@ -913,9 +913,14 @@ def self.get_other_charges()
query = query.group("i.sale_item_id")
end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type)
# date_type_selection = get_sql_function_for_report_type(report_type)
if account_type.blank?
account_type = ''
else
account_type = " and acc.title = '#{account_type}'"
end
query = self.get_item_query(type)
discount_query = 0
@@ -931,7 +936,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
product = self.get_product_sale()
if shift.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
end
@@ -954,7 +959,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
### => get all sales range in shift_sales
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
end
@@ -977,11 +982,13 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
@@ -1061,6 +1068,37 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
return query
end
def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type)
## => left join -> show all sales although no orders
if payment_type.blank?
payment_type = ''
else
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
end
query = Sale.select("sales.*,dining_facilities.name as table_name,dining_facilities.type as table_type")
if shift.present?
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.group("sales.sale_id")
elsif shift_sale_range.present?
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.group("sales.sale_id")
else
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.group("sales.sale_id")
end
return query
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")

View File

@@ -150,6 +150,19 @@ class SaleItem < ApplicationRecord
return price,type
end
# Get Prices for each accounts (eg: food, beverage)
def self.calculate_other_charges(sale_items)
total = 0
# Check for actual sale items
sale_items.each do |si|
if si.product_code == "Other Charges" && si.item_instance_code == nil
total = total + si.price
end
end
return total
end
# def self.get_overall_discount(sale_id)
# price = 0.0
# item=SaleItem.where("product_code=?", sale_id)

View File

@@ -8,10 +8,18 @@ class SaleOrder < ApplicationRecord
belongs_to :order
def create_sale_order(sale, order)
<<<<<<< HEAD
SaleOrder.transaction do
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
sale_order = SaleOrder.new
sale_order.sale_id = sale
sale_order.order_id = order
sale_order.save!
<<<<<<< HEAD
end
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
end
private