fixed conflict

This commit is contained in:
Nweni
2017-06-29 13:39:37 +06:30
21 changed files with 550 additions and 140 deletions

View File

@@ -40,6 +40,8 @@ class Ability
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :show, :payment
can :create, :payment
@@ -63,6 +65,8 @@ class Ability
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :show, :payment
can :create, :payment

View File

@@ -25,9 +25,8 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name,
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
table = DiningFacility.find(self.table_id)
table.status = "occupied"
@@ -55,7 +54,7 @@ class Order < ApplicationRecord
end
return false
return false, @message = "booking fail"
end

View File

@@ -33,13 +33,13 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
order_items.each do|odi|
order.each do|odi|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
# check for item not to show
if odi.price != 0 || odi.price != 10
if odi.price != 0
pdf = OrderItemPdf.new(odi, print_status, options)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename

View File

@@ -65,14 +65,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
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)
pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf")
# print as print copies in printer setting
count = printer_settings.print_copies
begin
pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf")
count -= 1
end until count == 0
end
#Queue No Print

View File

@@ -25,7 +25,7 @@ class Sale < ApplicationRecord
SALE_STATUS_OUTSTANDING = "outstanding"
SALE_STATUS_COMPLETED = "completed"
def generate_invoice_from_booking(booking_id, requested_by)
def generate_invoice_from_booking(booking_id, requested_by, cashier)
booking = Booking.find(booking_id)
status = false
Rails.logger.debug "Booking -> " + booking.id.to_s
@@ -35,9 +35,9 @@ class Sale < ApplicationRecord
booking.booking_orders.each do |order|
if booking.sale_id
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier)
else
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by)
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier)
end
booking.sale_id = sale_id
end
@@ -47,7 +47,7 @@ class Sale < ApplicationRecord
end
end
def generate_invoice_from_order (order_id, sale_id, booking, requested_by)
def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil)
taxable = true
#if sale_id is exsit and validate
#add order to that invoice
@@ -66,12 +66,19 @@ class Sale < ApplicationRecord
#Default Tax - Values
self.tax_type = "exclusive"
# set cashier by current login
self.cashier_id = requested_by.id
self.cashier_name = requested_by.name
# set cashier
if cashier != nil
self.cashier_id = cashier[0].id
self.cashier_name = cashier[0].name
else
self.cashier_id = requested_by.id
self.cashier_name = requested_by.name
end
# set waiter
self.requested_by = requested_by.name
self.requested_at = DateTime.now.utc
self.requested_at = DateTime.now.utc.getlocal
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
if order

View File

@@ -30,11 +30,13 @@ class SaleItem < ApplicationRecord
# end
end
# Get Prices for each accounts (eg: food, beverage)
def self.calculate_price_by_accounts(sale_items)
price_accounts = []
Account.all.each do |a|
account_price = {:name => a.title, :price => 0}
# Check for actual sale items
sale_items.each do |si|
if si.account_id == a.id
account_price[:price] = account_price[:price] + si.price
@@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord
return price_accounts
end
# Get discount Prices for each accounts (eg: food, beverage)
def self.get_discount_price_by_accounts(sale_items)
discount_accounts = []
Account.all.each do |a|
discount_account = {:name => a.title, :price => 0}
# Check for actual sale items
sale_items.where("is_taxable = 0 AND remark = 'Discount'").find_each do |si|
if si.account_id == a.id
discount_account[:price] = (discount_account[:price] + si.price) * -1
end
end
discount_accounts.push(discount_account)
end
return discount_accounts
end
# Calculate rebate_by_account
def self.calculate_rebate_by_account(sale_items)
rebateacc = Account.where("rebate=?",true)