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

@@ -103,4 +103,8 @@ i.logout_icon{
/* Second display image */ /* Second display image */
.second-display{ .second-display{
margin : 12px; margin : 12px;
}
.float_right{
float : right;
} }

View File

@@ -77,9 +77,11 @@ class Origami::PaymentsController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
result = { result = {
:filepath => filename, :filepath => filename,
@@ -216,9 +218,10 @@ class Origami::PaymentsController < BaseOrigamiController
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
@@ -475,9 +478,10 @@ class Origami::PaymentsController < BaseOrigamiController
# Calculate price_by_accounts # Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount)
result = { result = {
:status => true, :status => true,
@@ -560,9 +564,11 @@ class Origami::PaymentsController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount)
result = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,

View File

@@ -101,7 +101,7 @@ class Origami::ShiftsController < BaseOrigamiController
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings) printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile) printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile )
end end
end end
Employee.logout(session[:session_token]) Employee.logout(session[:session_token])

View File

@@ -124,9 +124,9 @@ class Origami::VoidController < BaseOrigamiController
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -105,9 +105,9 @@ class Origami::WasteSpoileController < BaseOrigamiController
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -0,0 +1,71 @@
class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false
def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params
@shift_sale_range = ''
@shift = ''
if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -1,7 +1,8 @@
class Reports::SaleitemController < BaseReportController class Reports::SaleitemController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@account = Account.all
from, to = get_date_range_from_params from, to = get_date_range_from_params
shift_sale_range = '' shift_sale_range = ''
@@ -23,8 +24,9 @@ class Reports::SaleitemController < BaseReportController
end end
end end
account_type = params[:account_type]
@type = params[:sale_type] @type = params[:sale_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)

View File

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

View File

@@ -37,7 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# pdf.render_file filename # pdf.render_file filename
# self.print(filename, cashier_terminal.printer_name) # self.print(filename, cashier_terminal.printer_name)
# end # 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) 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 #Use CUPS service
@@ -46,16 +46,16 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name 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") 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" 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 close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty? if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier| close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf' if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1' 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 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 end
end end

View File

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

View File

@@ -913,9 +913,14 @@ def self.get_other_charges()
query = query.group("i.sale_item_id") query = query.group("i.sale_item_id")
end 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) # 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) query = self.get_item_query(type)
discount_query = 0 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() product = self.get_product_sale()
if shift.present? 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" if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
end 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 ### => get all sales range in shift_sales
elsif shift_sale_range.present? 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" 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) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
end 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 total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else 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" if type.nil? || type == 'all' || type == "other"
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end end
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) 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) 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) 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, 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 return query
end 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) 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, query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name") s.cashier_name as cashier_name")

View File

@@ -150,6 +150,19 @@ class SaleItem < ApplicationRecord
return price,type return price,type
end 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) # def self.get_overall_discount(sale_id)
# price = 0.0 # price = 0.0
# item=SaleItem.where("product_code=?", sale_id) # item=SaleItem.where("product_code=?", sale_id)

View File

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

View File

@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_waste,total_spoile) def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -54,7 +54,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile) shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges)
end end
def header (shop_details) def header (shop_details)
@@ -70,7 +70,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule stroke_horizontal_rule
end end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile) def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges)
move_down 7 move_down 7
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -449,6 +449,14 @@ class CloseCashierPdf < Prawn::Document
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end end
end end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Other Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
end
#end total amount by Account #end total amount by Account
y_position = cursor y_position = cursor

View File

@@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(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,current_balance,card_data) def initialize(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,current_balance,card_data,other_charges_amount)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -79,6 +79,9 @@ class ReceiptBillA5Pdf < Prawn::Document
if shop_details.show_account_info if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter) items_account(item_price_by_accounts,printer_settings.precision,delimiter)
if other_charges_amount
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
end
end end
#start for individual payment #start for individual payment
@@ -537,6 +540,17 @@ class ReceiptBillA5Pdf < Prawn::Document
end end
end end
def show_other_charges_amount(other_amount,precision,delimiter)
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
#individual payment per person #individual payment per person
def individual_payment(sale_data, precision, delimiter) def individual_payment(sale_data, precision, delimiter)
per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i

View File

@@ -3,7 +3,7 @@ class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(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,current_balance,card_data) def initialize(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,current_balance,card_data,other_charges_amount)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i self.header_font_size = printer_settings.header_font_size.to_i
@@ -80,6 +80,9 @@ class ReceiptBillPdf < Prawn::Document
if shop_details.show_account_info if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter) items_account(item_price_by_accounts,printer_settings.precision,delimiter)
if other_charges_amount
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
end
end end
#start for individual payment #start for individual payment
@@ -536,6 +539,17 @@ class ReceiptBillPdf < Prawn::Document
end end
end end
def show_other_charges_amount(other_amount,precision,delimiter)
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
#individual payment per person #individual payment per person
def individual_payment(sale_data, survey, precision, delimiter) def individual_payment(sale_data, survey, precision, delimiter)
# per_person = sale_data.grand_total.to_f / survey.total_customer.to_i # per_person = sale_data.grand_total.to_f / survey.total_customer.to_i

View File

@@ -143,6 +143,9 @@
<li> <li>
<a href="<%= reports_receipt_no_index_path %>">Receipt</a> <a href="<%= reports_receipt_no_index_path %>">Receipt</a>
</li> </li>
<li>
<a href="<%= reports_receipt_no_detail_index_path %>">Receipt Detail</a>
</li>
<li> <li>
<a href="<%= reports_shiftsale_index_path %>">Shift Sales</a> <a href="<%= reports_shiftsale_index_path %>">Shift Sales</a>
</li> </li>

View File

@@ -0,0 +1,140 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<% if defined? payments %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
<select name="payment_type" id="payment_type" class="form-control">
<% @payments.each do |pm| %>
<option class="<%=pm[1].downcase%>" value="<%=pm[1].downcase%>"><%=pm[0]%></option>
<%end %>
<% @payment_method.each do |pm| %>
<option value="<%=pm.payment_method%>" class="<%=pm.payment_method%>" > <%=pm.payment_method%></option>
<%end %>
</select>
</div>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.all_shift") %></label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 margin-top-20">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
$(".<%=params[:payment_type]%>").attr('selected','selected')
// shift = $(".shift-id").text()
// if (shift.length>0) {
// $('.shift_name > option[value="'+shift+'"]').attr('selected','selected');
// }
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,289 @@
<div class="container-fluid">
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.receipt_no_report") %> Details</li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_detail_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_receipt_no_detail_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<thead>
<tr>
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
</th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
<th><b><%= t("views.right_panel.detail.table") %></b></th>
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<% grand_total = 0 %>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
<tr style="border-top:4px double #666;">
<td><%= @shift_from %> - <%= @shift_to %></td>
<td><%= result.table_type %> - <%= result.table_name %></td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%=result.grand_total%></td>
<!-- <td>&nbsp;</td> -->
</tr>
<tr>
<th><b><%= t("views.right_panel.detail.product") %></b></th>
<th><b><%= t("views.right_panel.detail.qty") %></b></th>
<th><b><%= t("views.right_panel.detail.unit_price") %></b></th>
<th><b><%= t("views.right_panel.detail.total_price") %></b></th>
<th><b><%= t("views.right_panel.detail.created_at") %></b></th>
</tr>
<% result.sale_items.each do |item|%>
<tr>
<td>
<% if item.price.to_i < 0.to_i %>
<% if item.qty.to_i < 0.to_i%>
[PROMO QTY]<%= item.product_name rescue '-' %>
<% else %>
[PROMO PRICE]<%= item.product_name rescue '-' %>
<% end %>
<% else %>
<%= item.product_name rescue '-' %>
<% end %>
</td>
<td><%= item.qty rescue '-' %></td>
<td><%= item.unit_price rescue '-' %></td>
<td><%= item.price rescue '-' %></td>
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
</tr>
<% end %>
<tr><td colspan="5">&nbsp;</td></tr>
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
<% if !survey.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>No. of Guest</td>
<td><%= survey.total_customer rescue '-' %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.total_amount.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= result.total_amount %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if result.total_discount.to_f > 0 %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %>
<%= t("views.right_panel.detail.discount") %>
<%= t("views.right_panel.detail.amount") %></td>
<td> - <%= result.total_discount %> </td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.total_tax.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Tax Amount </td>
<td><%= result.total_tax %> </td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if result.sale_payments.count > 0%>
<% result.sale_payments.each do |rec| %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Payment <%= rec.payment_method.upcase %></td>
<td><%= rec.payment_amount %> ( <%= result.payment_status %> )</td>
<td>&nbsp;</td>
</tr>
<% if !rec.payment_reference.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Payment Ref.</td>
<td><%= rec.payment_reference %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% end %>
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= result.amount_changed %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.customer_id.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Customer</td>
<td><%= result.customer.name.contact_first_name rescue '-'%>
(<%= result.customer.company rescue '-' %>)
</td>
<td>&nbsp;</td>
</tr>
<% end %>
<% end %>
<% end %>
<tr style="border-top:4px double #666;">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><b>Total Nett</b> - <b><%= grand_total %></b></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
search_by_period();
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#from').val(from)
search_by_date();
});
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
shift.empty();
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
if(param_shift != ''){
if(shift_id == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}else{
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
});
</script>

View File

@@ -0,0 +1,182 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<table class="table table-striped" border="0">
<thead>
<tr>
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
</th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
<th><b><%= t("views.right_panel.detail.table") %></b></th>
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<% grand_total = 0 %>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
<tr style="border-top:4px double #666;">
<td><%= @shift_from %> - <%= @shift_to %></td>
<td><%= result.table_type %> - <%= result.table_name %></td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%=result.grand_total%></td>
<!-- <td>&nbsp;</td> -->
</tr>
<tr>
<th><b><%= t("views.right_panel.detail.product") %></b></th>
<th><b><%= t("views.right_panel.detail.qty") %></b></th>
<th><b><%= t("views.right_panel.detail.unit_price") %></b></th>
<th><b><%= t("views.right_panel.detail.total_price") %></b></th>
<th><b><%= t("views.right_panel.detail.created_at") %></b></th>
</tr>
<% result.sale_items.each do |item|%>
<tr>
<td>
<% if item.price.to_i < 0.to_i %>
<% if item.qty.to_i < 0.to_i%>
[PROMO QTY]<%= item.product_name rescue '-' %>
<% else %>
[PROMO PRICE]<%= item.product_name rescue '-' %>
<% end %>
<% else %>
<%= item.product_name rescue '-' %>
<% end %>
</td>
<td><%= item.qty rescue '-' %></td>
<td><%= item.unit_price rescue '-' %></td>
<td><%= item.price rescue '-' %></td>
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
</tr>
<% end %>
<tr><td colspan="5">&nbsp;</td></tr>
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
<% if !survey.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>No. of Guest</td>
<td><%= survey.total_customer rescue '-' %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.total_amount.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= result.total_amount %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if result.total_discount.to_f > 0 %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %>
<%= t("views.right_panel.detail.discount") %>
<%= t("views.right_panel.detail.amount") %></td>
<td> - <%= result.total_discount %> </td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.total_tax.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Tax Amount </td>
<td><%= result.total_tax %> </td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if result.sale_payments.count > 0%>
<% result.sale_payments.each do |rec| %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Payment <%= rec.payment_method.upcase %></td>
<td><%= rec.payment_amount %> ( <%= result.payment_status %> )</td>
<td>&nbsp;</td>
</tr>
<% if !rec.payment_reference.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Payment Ref.</td>
<td><%= rec.payment_reference %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% end %>
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= result.amount_changed %></td>
<td>&nbsp;</td>
</tr>
<% end %>
<% if !result.customer_id.nil?%>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Customer</td>
<td><%= result.customer.name.contact_first_name rescue '-'%>
(<%= result.customer.company rescue '-' %>)
</td>
<td>&nbsp;</td>
</tr>
<% end %>
<% end %>
<% end %>
<tr style="border-top:4px double #666;">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><b>Total Nett</b> - <b><%= grand_total %></b></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -32,6 +32,16 @@
<option value="other">Other Amount Only</option> <option value="other">Other Amount Only</option>
</select> </select>
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_account") %></label>
<select name="account_type" id="account_type" class="form-control">
<option value = "">Select Account</option>
<% @account.each do |acc| %>
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
<%end %>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<!-- <label class="">Select Shift Period</label> --> <!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label> <label class="font-14"><%= t("views.right_panel.detail.from") %></label>
@@ -46,9 +56,9 @@
<select class="form-control select" name="shift_name" id="shift_name" > <select class="form-control select" name="shift_name" id="shift_name" >
</select> </select>
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20"> <div class="col-lg-12 col-md-12 col-sm-12 margin-top-20">
<br> <br>
<input type="submit" value="Generate Report" class='btn btn-primary'> <input type="submit" value="Generate Report" class='btn btn-primary float_right'>
</div> </div>
</div> </div>
<% end %> <% end %>
@@ -70,6 +80,8 @@
var item = $('#item').val(); var item = $('#item').val();
var payment_type = $('#payment_type'); var payment_type = $('#payment_type');
$("#account_type").val("<%=params[:account_type]%>");
if(item == 'order'){ if(item == 'order'){
$('#cashier').hide(); $('#cashier').hide();
$('#waiter').show(); $('#waiter').show();

View File

@@ -473,6 +473,7 @@ scope "(:locale)", locale: /en|mm/ do
#--------- Reports Controller Sections ------------# #--------- Reports Controller Sections ------------#
namespace :reports do namespace :reports do
resources :receipt_no resources :receipt_no
resources :receipt_no_detail
resources :dailysale, :only => [:index, :show] resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show] resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show] resources :shiftsale, :only => [:index, :show]