Merge branch 'master' into menu_sync

This commit is contained in:
Yan
2017-08-14 15:34:19 +06:30
50 changed files with 1481 additions and 172 deletions

View File

@@ -0,0 +1,41 @@
class DiningCharge < ApplicationRecord
belongs_to :table
belongs_to :room
def amount_calculate(dining_charges_obj, checkin , checkout)
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes
dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
elsif charge_type == 'day'
price = charge_by_day
end
end
end
def charge_by_hour
end
def charge_by_day(chargesObj, dining_minutes)
minues_per_day = 12 * 60
result = dining_minutes / minues_per_day
if result < 1
return chargesObj.unit_price
elsif result > 1
solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % minues_per_day
roundingblock = remain_value / chargesObj.time_rounding_block
if roundingblock > 1
end
end
end
end

View File

@@ -1,5 +1,6 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

View File

@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
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")
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)

View File

@@ -274,10 +274,9 @@ class Sale < ApplicationRecord
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
@@ -319,11 +318,10 @@ class Sale < ApplicationRecord
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
# #Create new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate

View File

@@ -125,6 +125,12 @@ class ShiftSale < ApplicationRecord
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
.group("acc.title").order("acc.id")
end
end
def self.get_total_member_discount(shift)
query = Sale.select("SUM(sales.total_discount) as member_discount")
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
end
end