Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into crm

This commit is contained in:
Aung Myo
2017-07-02 09:38:01 +06:30
14 changed files with 96 additions and 81 deletions

View File

@@ -65,11 +65,12 @@ 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, discount_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, printed_status)
#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)
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)
# print as print copies in printer setting
count = printer_settings.print_copies

View File

@@ -223,7 +223,7 @@ class Sale < ApplicationRecord
total_taxable = total_taxable + (item.taxable_price * item.qty)
end
compute_tax(sale, total_taxable)
compute_tax(sale, total_taxable, total_discount)
sale.total_amount = subtotal_price
sale.total_discount = total_discount
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
@@ -261,7 +261,7 @@ class Sale < ApplicationRecord
end
# Tax Re-Calculte
def compute_tax(sale, total_taxable)
def compute_tax(sale, total_taxable, total_discount = 0)
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -279,9 +279,12 @@ class Sale < ApplicationRecord
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_taxable = total_taxable - total_discount
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
#new taxable amount
total_taxable = total_taxable + sale_tax.tax_payable_amount
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
@@ -318,8 +321,8 @@ class Sale < ApplicationRecord
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
#new taxable amount
total_taxable = total_taxable + sale_tax.tax_payable_amount
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save

View File

@@ -20,12 +20,7 @@ class ShiftSale < ApplicationRecord
#if current_user
#find open shift where is open today and is not closed and login by current cashier
today_date = DateTime.now.strftime("%Y-%m-%d")
# puts today_date
# shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
return shift
#end
end