fixed conflict
This commit is contained in:
@@ -377,6 +377,5 @@ DEPENDENCIES
|
|||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.6.3p62
|
ruby 2.6.3p62
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.0.2
|
2.0.2
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Api::ApiController < ActionController::API
|
class Api::ApiController < ActionController::API
|
||||||
include TokenVerification
|
include TokenVerification
|
||||||
|
include ActionController::MimeResponds
|
||||||
|
|
||||||
# before_action :lookup_domain
|
# before_action :lookup_domain
|
||||||
helper_method :current_token, :current_login_employee, :get_cashier
|
helper_method :current_token, :current_login_employee, :get_cashier
|
||||||
@@ -23,25 +24,25 @@ class Api::ApiController < ActionController::API
|
|||||||
@employee = Employee.find_by_token_session(current_token)
|
@employee = Employee.find_by_token_session(current_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def lookup_domain
|
# def lookup_domain
|
||||||
# if request.subdomain.present? && request.subdomain != "www"
|
# if request.subdomain.present? && request.subdomain != "www"
|
||||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||||
# if (!@license.nil?)
|
# if (!@license.nil?)
|
||||||
# logger.info "Location - " + @license.dbhost
|
# logger.info "Location - " + @license.dbhost
|
||||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
# # authenticate_session_token
|
# # authenticate_session_token
|
||||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||||
# else
|
# else
|
||||||
# # reconnect_default_db
|
# # reconnect_default_db
|
||||||
# logger.info 'License is nil'
|
# logger.info 'License is nil'
|
||||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# def website_connection(license)
|
# def website_connection(license)
|
||||||
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||||
# :username => license.dbusername, :password => license.dbpassword)
|
# :username => license.dbusername, :password => license.dbpassword)
|
||||||
# end
|
# end
|
||||||
@@ -55,8 +56,8 @@ class Api::ApiController < ActionController::API
|
|||||||
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# def cache_license(url, lookup)
|
# def cache_license(url, lookup)
|
||||||
# @license = License.new(url, lookup)
|
# @license = License.new(url, lookup)
|
||||||
|
|
||||||
# if (@license.detail_with_local_cache(lookup) == true)
|
# if (@license.detail_with_local_cache(lookup) == true)
|
||||||
# return @license
|
# return @license
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Api::AuthenticateController < Api::ApiController
|
|||||||
@status = false
|
@status = false
|
||||||
@error_message = "This employee is not active!"
|
@error_message = "This employee is not active!"
|
||||||
# render json: JSON.generate({:status => false, :error_message => "This employee is not active!"})
|
# render json: JSON.generate({:status => false, :error_message => "This employee is not active!"})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "Bad Emp_ID or Password!"
|
@error_message = "Bad Emp_ID or Password!"
|
||||||
|
|||||||
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
require "net/http"
|
||||||
|
class Api::LoaderService::LoadDataController < Api::ApiController
|
||||||
|
skip_before_action :authenticate
|
||||||
|
|
||||||
|
def get_sale_data_rage
|
||||||
|
load_time_start = params[:load_time]
|
||||||
|
load_time_end = params[:load_time_end]
|
||||||
|
unless load_time_start.nil? || load_time_end.nil?
|
||||||
|
@sale_data = Sale.get_load_sale_range(load_time_start.to_datetime,load_time_end.to_datetime)
|
||||||
|
if !@sale_data.empty?
|
||||||
|
@out = {general_status: true, data: @sale_data}
|
||||||
|
else
|
||||||
|
@out = {general_status: false, data: "Data is empty."}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@out = {general_status: false, data: "load_time is missing."}
|
||||||
|
end
|
||||||
|
render :json => @out
|
||||||
|
end
|
||||||
|
|
||||||
|
# SFTP for BreadTalk Start
|
||||||
|
|
||||||
|
# Detail Sale
|
||||||
|
def get_detail_sale_data
|
||||||
|
data = params['data']
|
||||||
|
transaction_date = data[:transaction_date].to_s
|
||||||
|
detail_sale_data = SaleItem.get_detail_sale_data(transaction_date)
|
||||||
|
json = detail_sale_data.to_json
|
||||||
|
trans_count = JSON.parse(json).count
|
||||||
|
unless detail_sale_data.empty?
|
||||||
|
out = { :status => "success", :transaction_count => trans_count, :data => detail_sale_data }
|
||||||
|
else
|
||||||
|
out = { :status => "fail", :data => "Data is empty" }
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.json {render json: out }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Tender sale
|
||||||
|
def get_tender_sale_data
|
||||||
|
data = params['data']
|
||||||
|
transaction_date = data['transaction_date'].to_s
|
||||||
|
tender_sale_data = Sale.get_tender_sale_data(transaction_date)
|
||||||
|
json = tender_sale_data.to_json
|
||||||
|
trans_count = JSON.parse(json).count
|
||||||
|
unless tender_sale_data.empty?
|
||||||
|
out = { :status => "success", :transaction_count => trans_count, :data => tender_sale_data }
|
||||||
|
else
|
||||||
|
out = { :status => "fail", :data => "Data is empty" }
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: out }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Daily_Sale summary
|
||||||
|
def get_daily_sale_data
|
||||||
|
data = params['data']
|
||||||
|
transaction_date = data['transaction_date'].to_s
|
||||||
|
daily_sale_data = Sale.get_daily_sale_data(transaction_date)
|
||||||
|
unless daily_sale_data.empty?
|
||||||
|
out = { :status => "success", :data => daily_sale_data}
|
||||||
|
else
|
||||||
|
out = { :status => "fail", :data => "Data is empty"}
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: out }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check Sale Data
|
||||||
|
def get_check_sale_data
|
||||||
|
data = params['data']
|
||||||
|
transaction_date = data['transaction_date'].to_s
|
||||||
|
check_sale_data = Sale.get_check_sale_data(transaction_date)
|
||||||
|
json = check_sale_data.to_json
|
||||||
|
trans_count = JSON.parse(json).count
|
||||||
|
unless check_sale_data.empty?
|
||||||
|
out = { :status => "success", :transaction_count => trans_count, :data => check_sale_data}
|
||||||
|
else
|
||||||
|
out = { :status => "fail", :data => "Data is empty"}
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: out }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# SFTP for BreadTalk End
|
||||||
|
end
|
||||||
@@ -8,7 +8,7 @@ class Api::VoidController < Api::ApiController
|
|||||||
|
|
||||||
if sale.discount_type == "member_discount"
|
if sale.discount_type == "member_discount"
|
||||||
sale.update_attributes(total_discount: 0)
|
sale.update_attributes(total_discount: 0)
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
sale.compute_by_sale_items(0, nil, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
@@ -25,18 +25,17 @@ class Api::VoidController < Api::ApiController
|
|||||||
shift.save
|
shift.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sale.rounding_adjustment = 0.0
|
sale.rounding_adjustment = 0.0
|
||||||
sale.payment_status = 'void'
|
sale.payment_status = 'void'
|
||||||
sale.sale_status = 'void'
|
sale.sale_status = 'void'
|
||||||
sale.save
|
sale.save
|
||||||
|
|
||||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_login_employee.name, current_login_employee.name,nil,"SALEVOID" )
|
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_login_employee.name, current_login_employee.name,nil,"SALEVOID" )
|
||||||
render json: JSON.generate({:status => true, :message => "Void successful."})
|
render json: JSON.generate({:status => true, :message => "Void successful."})
|
||||||
else
|
else
|
||||||
render json: JSON.generate({:status => false, :error_message => "There is no sale for '#{params[:sale_id]}'!"})
|
render json: JSON.generate({:status => false, :error_message => "There is no sale for '#{params[:sale_id]}'!"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -48,44 +48,44 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
def add_customer
|
def add_customer
|
||||||
@webview = false
|
@webview = false
|
||||||
if check_mobile
|
if check_mobile
|
||||||
@webview = true
|
@webview = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@page = params[:dir_page]
|
@page = params[:dir_page]
|
||||||
|
|
||||||
if(@sale_id[0,3] == "SAL")
|
if(@sale_id[0,3] == "SAL")
|
||||||
@booking = Booking.find_by_sale_id(@sale_id)
|
@booking = Booking.find_by_sale_id(@sale_id)
|
||||||
if @booking.dining_facility_id.to_i > 0
|
if @booking.dining_facility_id.to_i > 0
|
||||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||||
else
|
else
|
||||||
@dining_facility = nil
|
@dining_facility = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||||
@booking = Booking.find(@booking_order.booking_id)
|
@booking = Booking.find(@booking_order.booking_id)
|
||||||
if @booking.dining_facility_id.to_i > 0
|
if @booking.dining_facility_id.to_i > 0
|
||||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||||
else
|
else
|
||||||
@dining_facility = nil
|
@dining_facility = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
|
|
||||||
if filter.nil?
|
if filter.nil?
|
||||||
@crm_customers = Customer.order("customer_id") #.page(params[:page])
|
@crm_customers = Customer.order("customer_id") #.page(params[:page])
|
||||||
#@products = Product.order("name").page(params[:page]).per(5)
|
#@products = Product.order("name").page(params[:page]).per(5)
|
||||||
else
|
else
|
||||||
@crm_customers = Customer.search(filter)
|
@crm_customers = Customer.search(filter)
|
||||||
end
|
end
|
||||||
#@crm_customers = Customer.all
|
#@crm_customers = Customer.all
|
||||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
|
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
|
||||||
@crm_customer = Customer.new
|
@crm_customer = Customer.new
|
||||||
@count_customer = Customer.count_customer
|
@count_customer = Customer.count_customer
|
||||||
|
|
||||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||||
.order("group_type ASC,order_by ASC")
|
.order("group_type ASC,order_by ASC")
|
||||||
@@ -100,7 +100,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
lookup_customer = Lookup.collection_of('customer_settings')
|
lookup_customer = Lookup.collection_of('customer_settings')
|
||||||
if !lookup_customer.empty?
|
if !lookup_customer.empty?
|
||||||
lookup_customer.each do |create_setting|
|
lookup_customer.each do |create_setting|
|
||||||
if create_setting[0].downcase == "create"
|
if create_setting[0].downcase == "create"
|
||||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||||
@create_flag = false
|
@create_flag = false
|
||||||
end
|
end
|
||||||
@@ -154,13 +154,13 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
if status == true
|
if status == true
|
||||||
render json: JSON.generate({:status => true})
|
render json: JSON.generate({:status => true})
|
||||||
if(id == "SAL")
|
if(id == "SAL")
|
||||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_account
|
def send_account
|
||||||
amount = params[:amount]
|
amount = params[:amount]
|
||||||
account_no = params[:account_no]
|
account_no = params[:account_no]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
overall_discount = params[:overall_discount]
|
overall_discount = params[:overall_discount]
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
|
|
||||||
|
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||||
@@ -88,7 +87,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||||
|
|
||||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
|
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
|
||||||
end
|
end
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
|
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
|
||||||
if !table.nil?
|
if !table.nil?
|
||||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||||
else
|
else
|
||||||
@@ -158,7 +157,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||||
# sale.save
|
# sale.save
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||||
if table.nil?
|
if table.nil?
|
||||||
result = {:status=> "Success"}
|
result = {:status=> "Success"}
|
||||||
else
|
else
|
||||||
@@ -220,7 +219,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
|
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||||
|
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
|
sale.compute_by_sale_items(0, nil, order_source)
|
||||||
if table.nil?
|
if table.nil?
|
||||||
result = {:status=> "Success"}
|
result = {:status=> "Success"}
|
||||||
else
|
else
|
||||||
@@ -321,7 +320,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
if response["discount_bonus_earned"]
|
if response["discount_bonus_earned"]
|
||||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||||
end
|
end
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source, tax_type)
|
sale.compute_by_sale_items(discount_amount, 'member_discount', order_source, tax_type)
|
||||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||||
elsif response["status"] == "500"
|
elsif response["status"] == "500"
|
||||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
@webview = false
|
@webview = false
|
||||||
if check_mobile
|
if check_mobile
|
||||||
@webview = true
|
@webview = true
|
||||||
end
|
end
|
||||||
|
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
if Sale.exists?(sale_id)
|
if Sale.exists?(sale_id)
|
||||||
@@ -15,11 +15,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||||
else
|
else
|
||||||
@table = nil
|
@table = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
@@ -34,11 +34,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
table_id = nil
|
table_id = nil
|
||||||
table = nil
|
table = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# sale.total_amount = sub_total.to_f
|
# sale.total_amount = sub_total.to_f
|
||||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||||
# sale.save
|
# sale.save
|
||||||
if other_charges_items.length > 0
|
if other_charges_items.length > 0
|
||||||
#save sale item for discount
|
#save sale item for discount
|
||||||
other_charges_items.each do |di|
|
other_charges_items.each do |di|
|
||||||
@@ -68,18 +68,18 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
else
|
else
|
||||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" )
|
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" )
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
|
sale.compute_by_sale_items(sale.total_discount, nil, cashier_type)
|
||||||
end
|
end
|
||||||
if !table.nil?
|
if !table.nil?
|
||||||
dining = {:table_id => table_id, :table_type => table.type }
|
dining = {:table_id => table_id, :table_type => table.type }
|
||||||
render :json => dining.to_json
|
render :json => dining.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
if saleObj.discount_type == "member_discount"
|
if saleObj.discount_type == "member_discount"
|
||||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
|
saleObj.compute_by_sale_items(0, nil, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||||
@@ -818,7 +818,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
order_source = params[:cashier_type]
|
order_source = params[:cashier_type]
|
||||||
tax_type = params[:tax_type]
|
tax_type = params[:tax_type]
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount,nil,order_source,tax_type)
|
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
||||||
|
|
||||||
render json: JSON.generate({:status => true})
|
render json: JSON.generate({:status => true})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
|
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
|
||||||
|
|
||||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
|
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
|
||||||
|
|
||||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -150,10 +150,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
saleitemObj.save
|
saleitemObj.save
|
||||||
|
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
saleObj = Sale.find(saleitemObj.sale_id)
|
# saleObj = Sale.find(saleitemObj.sale_id)
|
||||||
|
|
||||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
# order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||||
order = Order.find(order_id)
|
# order = Order.find(order_id)
|
||||||
|
|
||||||
# order.order_items.each do |o|
|
# order.order_items.each do |o|
|
||||||
# if saleitemObj.product_code == o.item_code
|
# if saleitemObj.product_code == o.item_code
|
||||||
@@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
sale.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||||
|
|
||||||
ProductCommission.edit_product_commission(saleitemObj)
|
ProductCommission.edit_product_commission(saleitemObj)
|
||||||
end
|
end
|
||||||
@@ -195,8 +195,8 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
|
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
|
||||||
|
|
||||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order_source)
|
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||||
ProductCommission.remove_product_commission(saleitemObj)
|
ProductCommission.remove_product_commission(saleitemObj)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -214,9 +214,9 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
item.save
|
item.save
|
||||||
ProductCommission.remove_product_commission(item)
|
ProductCommission.remove_product_commission(item)
|
||||||
end
|
end
|
||||||
|
saleObj.sale_items.reset
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
saleObj.compute_by_sale_items(saleObj.total_discount,nil, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_void
|
def apply_void
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
sale = Sale.find_by_sale_id(sale_id)
|
sale = Sale.find_by_sale_id(sale_id)
|
||||||
if sale.discount_type == "member_discount"
|
if sale.discount_type == "member_discount"
|
||||||
sale.update_attributes(total_discount: 0)
|
sale.update_attributes(total_discount: 0)
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
sale.compute_by_sale_items(0, nil, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
|||||||
sale.sale_status = remark
|
sale.sale_status = remark
|
||||||
sale.save
|
sale.save
|
||||||
|
|
||||||
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
|
||||||
# add to sale item with foc
|
# add to sale item with foc
|
||||||
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
# GET /transactions/sales
|
# GET /transactions/sales
|
||||||
# GET /transactions/sales.json
|
# GET /transactions/sales.json
|
||||||
def index
|
def index
|
||||||
|
|
||||||
receipt_no = params[:receipt_no]
|
receipt_no = params[:receipt_no]
|
||||||
# from = params[:from]
|
# from = params[:from]
|
||||||
# to = params[:to]
|
# to = params[:to]
|
||||||
@@ -19,18 +19,18 @@ class Transactions::SalesController < ApplicationController
|
|||||||
if receipt_no.nil? && from.nil? && to.nil?
|
if receipt_no.nil? && from.nil? && to.nil?
|
||||||
if @shift.blank?
|
if @shift.blank?
|
||||||
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
|
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
|
||||||
else
|
else
|
||||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
||||||
end
|
end
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||||
else
|
else
|
||||||
sale = Sale.search(receipt_no,from,to,@shift)
|
sale = Sale.search(receipt_no,from,to,@shift)
|
||||||
if sale.count > 0
|
if sale.count > 0
|
||||||
@sales = sale
|
@sales = sale
|
||||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||||
else
|
else
|
||||||
@sales = 0
|
@sales = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@receipt_no = receipt_no
|
@receipt_no = receipt_no
|
||||||
@from = from
|
@from = from
|
||||||
@@ -41,20 +41,20 @@ class Transactions::SalesController < ApplicationController
|
|||||||
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||||
@shift_data = @shift
|
@shift_data = @shift
|
||||||
end
|
end
|
||||||
|
|
||||||
# if receipt_no.nil? && search_date.nil?
|
# if receipt_no.nil? && search_date.nil?
|
||||||
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||||
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
# else
|
# else
|
||||||
# if !search_date.blank? && receipt_no.blank?
|
# if !search_date.blank? && receipt_no.blank?
|
||||||
# sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
# sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||||
# elsif !search_date.blank? && !receipt_no.blank?
|
# elsif !search_date.blank? && !receipt_no.blank?
|
||||||
# sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
# sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||||
# else
|
# else
|
||||||
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
||||||
# end
|
# end
|
||||||
# if sale.count > 0
|
# if sale.count > 0
|
||||||
# @sales = sale
|
# @sales = sale
|
||||||
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||||
# else
|
# else
|
||||||
# @sales = 0
|
# @sales = 0
|
||||||
@@ -182,7 +182,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
period_type = params[:period_type]
|
period_type = params[:period_type]
|
||||||
period = params[:period]
|
period = params[:period]
|
||||||
from = params[:from]
|
from = params[:from]
|
||||||
to = params[:to]
|
to = params[:to]
|
||||||
day_ref = Time.now.utc.getlocal
|
day_ref = Time.now.utc.getlocal
|
||||||
|
|
||||||
if from.present? && to.present?
|
if from.present? && to.present?
|
||||||
@@ -191,8 +191,8 @@ class Transactions::SalesController < ApplicationController
|
|||||||
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||||
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||||
from = f_time.beginning_of_day.utc.getlocal
|
from = f_time.beginning_of_day.utc.getlocal
|
||||||
to = t_time.end_of_day.utc.getlocal
|
to = t_time.end_of_day.utc.getlocal
|
||||||
else
|
else
|
||||||
case period.to_i
|
case period.to_i
|
||||||
when PERIOD["today"]
|
when PERIOD["today"]
|
||||||
from = day_ref.beginning_of_day.utc
|
from = day_ref.beginning_of_day.utc
|
||||||
@@ -226,10 +226,10 @@ class Transactions::SalesController < ApplicationController
|
|||||||
when PERIOD["last_year"]
|
when PERIOD["last_year"]
|
||||||
from = (day_ref - 1.year).beginning_of_year.utc
|
from = (day_ref - 1.year).beginning_of_year.utc
|
||||||
to = (day_ref - 1.year).end_of_year.utc
|
to = (day_ref - 1.year).end_of_year.utc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return from, to
|
return from, to
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_user
|
def check_user
|
||||||
@@ -248,7 +248,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
|
|
||||||
if sale.discount_type == "member_discount"
|
if sale.discount_type == "member_discount"
|
||||||
sale.update_attributes(total_discount: 0)
|
sale.update_attributes(total_discount: 0)
|
||||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
sale.compute_by_sale_items(0, nil, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
@@ -265,7 +265,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
shift.save
|
shift.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sale.rounding_adjustment = 0.0
|
sale.rounding_adjustment = 0.0
|
||||||
sale.payment_status = 'void'
|
sale.payment_status = 'void'
|
||||||
sale.sale_status = 'void'
|
sale.sale_status = 'void'
|
||||||
@@ -308,16 +308,16 @@ class Transactions::SalesController < ApplicationController
|
|||||||
table = nil
|
table = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# FOr Sale Audit
|
# FOr Sale Audit
|
||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
if access_code != "null" && current_user.role == "cashier"
|
if access_code != "null" && current_user.role == "cashier"
|
||||||
action_by = Employee.find_by_emp_id(access_code).name
|
action_by = Employee.find_by_emp_id(access_code).name
|
||||||
end
|
end
|
||||||
|
|
||||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
||||||
|
|
||||||
# For Print
|
# For Print
|
||||||
|
|
||||||
member_info = nil
|
member_info = nil
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
@@ -325,7 +325,7 @@ class Transactions::SalesController < ApplicationController
|
|||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
if bookings.count > 1
|
if bookings.count > 1
|
||||||
# for Multiple Booking
|
# for Multiple Booking
|
||||||
if bookings[0].dining_facility_id.to_i>0
|
if bookings[0].dining_facility_id.to_i>0
|
||||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||||
@@ -339,12 +339,12 @@ class Transactions::SalesController < ApplicationController
|
|||||||
shift = ShiftSale.find(sale.shift_sale_id)
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.find(sale.customer_id)
|
customer= Customer.find(sale.customer_id)
|
||||||
|
|
||||||
#shop detail
|
#shop detail
|
||||||
shop_details = Shop.find_by_id(1)
|
shop_details = Shop.find_by_id(1)
|
||||||
# get member information
|
# get member information
|
||||||
@@ -363,31 +363,31 @@ class Transactions::SalesController < ApplicationController
|
|||||||
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) #other charges
|
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,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,nil,nil,nil)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,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,nil,nil,nil)
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
:printer_model => print_settings.brand_name,
|
:printer_model => print_settings.brand_name,
|
||||||
:printer_url => print_settings.api_settings
|
:printer_url => print_settings.api_settings
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mobile Print
|
# Mobile Print
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
# end
|
# end
|
||||||
|
|
||||||
#end print
|
#end print
|
||||||
|
|
||||||
# update complete order items in oqs
|
# update complete order items in oqs
|
||||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||||
aoi.delivery_status = 1
|
aoi.delivery_status = 1
|
||||||
aoi.save
|
aoi.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_transactions_sale
|
def set_transactions_sale
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class Promotion < ApplicationRecord
|
|||||||
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
||||||
|
|
||||||
if !item.nil?
|
if !item.nil?
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion", item[:price], source)
|
update_existing_item(foc_qty, item, saleObj, "promotion", item[:price], source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# AA - 10 # 3 # BB # orderList, #S34345
|
# AA - 10 # 3 # BB # orderList, #S34345
|
||||||
@@ -128,7 +128,7 @@ class Promotion < ApplicationRecord
|
|||||||
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
||||||
|
|
||||||
if !item.nil?
|
if !item.nil?
|
||||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item[:price],source)
|
update_existing_item(promotion_qty, item, saleObj, "promotion", item[:price],source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -157,8 +157,9 @@ class Promotion < ApplicationRecord
|
|||||||
sale_item.is_taxable = 1
|
sale_item.is_taxable = 1
|
||||||
sale_item.sale = saleObj
|
sale_item.sale = saleObj
|
||||||
sale_item.save
|
sale_item.save
|
||||||
|
|
||||||
saleObj.compute_by_sale_items(saleObj.id, saleObj.sale_items, saleObj.total_discount,nil,source)
|
saleObj.sale_items << sale_item
|
||||||
|
saleObj.compute_by_sale_items(saleObj.total_discount, nil, source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ class Promotion < ApplicationRecord
|
|||||||
item = saleObj.order_items.where(item_instance_code: promo_product.item_code).first
|
item = saleObj.order_items.where(item_instance_code: promo_product.item_code).first
|
||||||
|
|
||||||
if !item.nil?
|
if !item.nil?
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
update_existing_item(foc_qty, item, saleObj, "promotion nett off", promo_product.net_off,source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -361,8 +361,8 @@ class Sale < ApplicationRecord
|
|||||||
sale_item.save
|
sale_item.save
|
||||||
|
|
||||||
# Re-calc
|
# Re-calc
|
||||||
sale = Sale.find(self.id)
|
self.sale_items << sale_item
|
||||||
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source)
|
self.compute_by_sale_items(self.total_discount, nil, order_source)
|
||||||
end
|
end
|
||||||
def create_saleitem_indutycharges(chargeObj, current_checkin_induties_count, induties_pay_amount, dining_name, dining_time, order_source = nil, basic_pay_amount)
|
def create_saleitem_indutycharges(chargeObj, current_checkin_induties_count, induties_pay_amount, dining_name, dining_time, order_source = nil, basic_pay_amount)
|
||||||
sale_item = SaleItem.new
|
sale_item = SaleItem.new
|
||||||
@@ -380,8 +380,8 @@ class Sale < ApplicationRecord
|
|||||||
sale_item.price = induties_pay_amount
|
sale_item.price = induties_pay_amount
|
||||||
sale_item.save
|
sale_item.save
|
||||||
# Re-calc
|
# Re-calc
|
||||||
sale = Sale.find(self.id)
|
self.sale_items << sale_item
|
||||||
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source)
|
self.compute_by_sale_items(self.total_discount, nil, order_source)
|
||||||
end
|
end
|
||||||
def update_item (item)
|
def update_item (item)
|
||||||
#save sale_audit
|
#save sale_audit
|
||||||
@@ -403,14 +403,12 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
#compute - invoice total
|
#compute - invoice total
|
||||||
def compute(order_source = nil, tax_type = nil)
|
def compute(order_source = nil, tax_type = nil)
|
||||||
sales_items = self.sale_items
|
|
||||||
|
|
||||||
#Computation Fields
|
#Computation Fields
|
||||||
subtotal_price = 0
|
subtotal_price = 0
|
||||||
total_taxable = 0
|
total_taxable = 0
|
||||||
rounding_adjustment = 0
|
rounding_adjustment = 0
|
||||||
|
|
||||||
sales_items.each do |item|
|
self.sale_items.each do |item|
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
|
|
||||||
@@ -429,60 +427,54 @@ class Sale < ApplicationRecord
|
|||||||
# self.grand_total_round
|
# self.grand_total_round
|
||||||
#compute rounding adjustment
|
#compute rounding adjustment
|
||||||
# adjust_rounding
|
# adjust_rounding
|
||||||
|
|
||||||
self.save!
|
self.save!
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#compute - invoice total
|
#compute - invoice total
|
||||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil,type=nil)
|
def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil)
|
||||||
shop = Shop.first
|
shop = Shop.first
|
||||||
sale = Sale.find(sale_id)
|
|
||||||
sales_items = sale_itemss
|
|
||||||
|
|
||||||
#Computation Fields
|
#Computation Fields
|
||||||
subtotal_price = 0
|
subtotal_price = 0
|
||||||
total_taxable = 0
|
total_taxable = 0
|
||||||
rounding_adjustment = 0
|
rounding_adjustment = 0
|
||||||
|
|
||||||
sales_items.each do |item|
|
self.sale_items.each do |item|
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
|
|
||||||
# check for item is taxable and calculate
|
# check for item is taxable and calculate
|
||||||
if item.is_taxable
|
if item.is_taxable
|
||||||
total_taxable = total_taxable + item.taxable_price
|
total_taxable = total_taxable + item.taxable_price
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
|
|
||||||
sale.total_amount = subtotal_price
|
compute_tax(total_taxable, total_discount, order_source, tax_type)
|
||||||
sale.total_discount = total_discount
|
self.total_amount = subtotal_price
|
||||||
|
self.total_discount = total_discount
|
||||||
if type =="foc"
|
if type =="foc"
|
||||||
sale.grand_total = 0
|
self.grand_total = 0
|
||||||
else
|
else
|
||||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||||
# sale.grand_total_round
|
# sale.grand_total_round
|
||||||
end
|
end
|
||||||
|
|
||||||
if discount_type == "member_discount"
|
if discount_type == "member_discount"
|
||||||
sale.discount_type = discount_type
|
self.discount_type = discount_type
|
||||||
end
|
end
|
||||||
#compute rounding adjustment
|
#compute rounding adjustment
|
||||||
# adjust_rounding
|
# adjust_rounding
|
||||||
|
self.save!
|
||||||
sale.save!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# No Use too many wrong
|
# No Use too many wrong
|
||||||
def compute_without_void(order_source = nil)
|
def compute_without_void(order_source = nil)
|
||||||
sales_items = self.sale_items
|
|
||||||
|
|
||||||
#Computation Fields
|
#Computation Fields
|
||||||
subtotal_price = 0
|
subtotal_price = 0
|
||||||
total_taxable = 0
|
total_taxable = 0
|
||||||
rounding_adjustment = 0
|
rounding_adjustment = 0
|
||||||
|
|
||||||
sales_items.each do |item|
|
self.sale_items.each do |item|
|
||||||
if item.status != 'void' && item.status != 'foc'
|
if item.status != 'void' && item.status != 'foc'
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
@@ -506,7 +498,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Tax Re-Calculte
|
# Tax Re-Calculte
|
||||||
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||||
shop = Shop.first
|
shop = Shop.first
|
||||||
|
|
||||||
#if tax is not apply create new record
|
#if tax is not apply create new record
|
||||||
@@ -529,9 +521,9 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||||
|
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
if sale.payment_status != 'foc'
|
if self.payment_status != 'foc'
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
sale_tax = SaleTax.new(:sale => sale)
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|
||||||
@@ -555,8 +547,8 @@ class Sale < ApplicationRecord
|
|||||||
sale_tax.save
|
sale_tax.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sale.tax_type = tax_incl_exec
|
self.tax_type = tax_incl_exec
|
||||||
sale.total_tax = total_tax_amount
|
self.total_tax = total_tax_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
# Tax Calculate
|
# Tax Calculate
|
||||||
@@ -759,84 +751,58 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.daily_sales_list(from,to)
|
def self.daily_sales_list(from,to)
|
||||||
sub_query = "SELECT (CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN
|
sales = select("
|
||||||
(SUM(sale_payments.payment_amount) + SUM(sale_payments.outstanding_amount)) ELSE 0 END)
|
sales.*,
|
||||||
FROM sale_payments
|
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||||
INNER JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||||
INNER JOIN sales s ON s.sale_id=sa.sale_id
|
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
||||||
WHERE s.sale_status='completed'
|
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
||||||
AND DATE_FORMAT(CONVERT_TZ(s.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') = DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d')"
|
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
|
CASE WHEN SUM(case when sale_payments.payment_method not in('creditnote') then sale_payments.payment_amount end) < sales.grand_total
|
||||||
|
THEN sales.grand_total - SUM(case when sale_payments.payment_method not in('creditnote') then sale_payments.payment_amount end)
|
||||||
|
ELSE 0 END as credit_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||||
|
.joins("LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND DATE(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30')) = DATE(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'))")
|
||||||
|
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
|
||||||
|
.group("sale_id").to_sql
|
||||||
|
|
||||||
payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
daily_total = connection.select_all("SELECT
|
||||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||||
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||||
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
||||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
|
||||||
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
|
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||||
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
|
SUM(kbzpay_amount) as kbzpay_amount,
|
||||||
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
|
SUM(mpu_amount) as mpu_amount,
|
||||||
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
SUM(master_amount) as master_amount,
|
||||||
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
SUM(visa_amount) as visa_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(jcb_amount) as jcb_amount,
|
||||||
(CASE WHEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end)) > 0 THEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) - (#{sub_query})) ELSE 0 END) as credit_amount,
|
SUM(paypar_amount) as paypar_amount,
|
||||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
SUM(unionpay_amount) as unionpay_amount,
|
||||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
SUM(alipay_amount) as alipay_amount,
|
||||||
.joins(" join sale_payments on sale_payments.sale_id = sales.sale_id")
|
SUM(paymal_amount) as paymal_amount,
|
||||||
.where("sale_status = ? AND sales.receipt_date between ? and ? ", 'completed', from, to)
|
SUM(dinga_amount) as dinga_amount,
|
||||||
.group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
SUM(junctionpay_amount) as junctionpay_amount,
|
||||||
|
SUM(cash_amount) as cash_amount,
|
||||||
|
SUM(credit_amount) as credit_amount,
|
||||||
|
SUM(giftvoucher_amount) as giftvoucher_amount,
|
||||||
|
SUM(foc_amount) as foc_amount
|
||||||
|
FROM (
|
||||||
|
#{sales}
|
||||||
|
) as s
|
||||||
|
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
|
||||||
|
|
||||||
daily_total = Array.new
|
return daily_total
|
||||||
|
|
||||||
payments_total.each do |pay|
|
|
||||||
sale_date = pay.sale_date
|
|
||||||
diff_time = payments_total.first.sale_date.beginning_of_day.utc - from
|
|
||||||
diff = diff_time % 86400
|
|
||||||
from_date = sale_date.beginning_of_day.utc - diff
|
|
||||||
to_date = sale_date.end_of_day.utc - diff
|
|
||||||
|
|
||||||
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
|
||||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
|
||||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
|
||||||
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
|
||||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
|
||||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
|
|
||||||
.where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date)
|
|
||||||
|
|
||||||
total_sale.each do |sale|
|
|
||||||
grand_total = sale.grand_total
|
|
||||||
old_grand_total = sale.old_grand_total
|
|
||||||
total_discount = sale.total_discount
|
|
||||||
void_amount = sale.void_amount
|
|
||||||
total_change_amount = sale.total_change_amount
|
|
||||||
total = {:sale_date => pay.sale_date,
|
|
||||||
:mpu_amount => pay.mpu_amount,
|
|
||||||
:master_amount => pay.master_amount,
|
|
||||||
:visa_amount => pay.visa_amount,
|
|
||||||
:jcb_amount => pay.jcb_amount,
|
|
||||||
:paypar_amount => pay.paypar_amount,
|
|
||||||
:unionpay_amount => pay.unionpay_amount,
|
|
||||||
:alipay_amount => pay.alipay_amount,
|
|
||||||
:kbzpay_amount => pay.kbzpay_amount,
|
|
||||||
:paymal_amount => pay.paymal_amount,
|
|
||||||
:dinga_amount => pay.dinga_amount,
|
|
||||||
:junctionpay_amount => pay.junctionpay_amount,
|
|
||||||
:cash_amount => pay.cash_amount,
|
|
||||||
:credit_amount => pay.credit_amount,
|
|
||||||
:foc_amount => pay.foc_amount,
|
|
||||||
:giftvoucher_amount => pay.giftvoucher_amount,
|
|
||||||
:total_discount => total_discount,
|
|
||||||
:total_change_amount => total_change_amount,
|
|
||||||
:grand_total => grand_total,
|
|
||||||
:old_grand_total => old_grand_total,
|
|
||||||
:void_amount => void_amount,
|
|
||||||
:rounding_adj => sale.rounding_adj}
|
|
||||||
daily_total.push(total)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
return daily_total
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_range_by_saleitems(from,to,status,report_type)
|
def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||||
@@ -1138,73 +1104,64 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
|
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
|
||||||
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
|
order_sources = Order.select("sale_orders.sale_id, orders.source")
|
||||||
THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END)
|
.joins(:sale_orders).to_sql
|
||||||
FROM `sale_payments`
|
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
WHERE sale_audits.sale_id = s.sale_id"
|
|
||||||
|
|
||||||
sub_query1 = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) -
|
credit_payments = SalePayment.select("
|
||||||
(SUM(payment_amount) - (SELECT SUM(payment_amount) FROM sale_payments WHERE payment_method='creditnote' AND sale_id=s.sale_id)) ELSE 0 END)
|
sales.sale_id,
|
||||||
FROM `sale_payments`
|
DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') as credit_payment_receipt_date,
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
sale_payments.payment_amount as credit_payment,
|
||||||
WHERE sale_audits.sale_id = s.sale_id"
|
employees.name as credit_payment_cashier_name,
|
||||||
|
CONCAT(DATE_FORMAT(CONVERT_TZ(shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name")
|
||||||
|
.joins("JOIN sales ON sales.sale_id = sale_payments.sale_id")
|
||||||
|
.joins("JOIN sale_audits ON sale_audits.sale_id = sales.sale_id AND SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id")
|
||||||
|
.joins("JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||||
|
.joins("JOIN employees ON employees.id = shift_sales.employee_id").to_sql
|
||||||
|
|
||||||
sub_query2 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL AND credit_payment > 0
|
credits = SalePayment.select("
|
||||||
THEN CONCAT(DATE_FORMAT(CONVERT_TZ(shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'))
|
sale_payments.sale_payment_id,
|
||||||
ELSE '-' END)
|
sale_payments.payment_method,
|
||||||
FROM shift_sales
|
sale_payments.payment_amount,
|
||||||
WHERE shift_sales.id = s.shift_sale_id"
|
sale_payments.payment_status,
|
||||||
|
sales.sale_id,
|
||||||
|
sales.receipt_no,
|
||||||
|
sales.receipt_date as sale_date,
|
||||||
|
order_sources.source as order_source,
|
||||||
|
sales.cashier_name,
|
||||||
|
customers.name as customer_name,
|
||||||
|
IFNULL(credit_payments.credit_payment_receipt_date, '-') as credit_payment_receipt_date,
|
||||||
|
IFNULL(credit_payments.credit_payment, 0) as credit_payment,
|
||||||
|
IFNULL(credit_payments.credit_payment_cashier_name, '-') as credit_payment_cashier_name,
|
||||||
|
IFNULL(credit_payments.credit_payment_shift_name, '-') as credit_payment_shift_name")
|
||||||
|
.joins("JOIN sales ON sales.sale_id = sale_payments.sale_id")
|
||||||
|
.joins("JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||||
|
.joins("JOIN customers ON customers.customer_id = sales.customer_id")
|
||||||
|
.joins("JOIN (#{order_sources}) order_sources ON order_sources.sale_id = sales.sale_id")
|
||||||
|
.joins("LEFT JOIN (#{credit_payments}) credit_payments ON credit_payments.sale_id = sales.sale_id")
|
||||||
|
.where("sale_payments.payment_method= ? AND sales.sale_status = ?", 'creditnote', 'completed')
|
||||||
|
|
||||||
sub_query3 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL OR shift_closed_at IS NULL AND credit_payment > 0
|
if order_source.present?
|
||||||
THEN employees.name ELSE '-' END)
|
|
||||||
FROM shift_sales
|
|
||||||
INNER JOIN employees ON employees.id=shift_sales.employee_id
|
|
||||||
WHERE shift_sales.id = s.shift_sale_id"
|
|
||||||
|
|
||||||
filter_check = ""
|
|
||||||
if filter == 'paid'
|
|
||||||
filter_check = " AND (SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) ELSE 0 END)
|
|
||||||
FROM `sale_payments`
|
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
WHERE sale_audits.sale_id = s.sale_id) > 0"
|
|
||||||
elsif filter == 'unpaid'
|
|
||||||
filter_check = " AND (SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) ELSE 0 END)
|
|
||||||
FROM `sale_payments`
|
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
WHERE sale_audits.sale_id = s.sale_id) = 0"
|
|
||||||
end
|
|
||||||
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)"
|
|
||||||
|
|
||||||
if order_source.blank?
|
|
||||||
source = ""
|
|
||||||
else
|
|
||||||
if order_source == "cashier"
|
if order_source == "cashier"
|
||||||
source = "and #{order_source_query}='cashier' or #{order_source_query}='emenu'"
|
credits = credits.where("order_sources.source IN (?)", ['cashier', 'emenu'])
|
||||||
else
|
else
|
||||||
source = "and #{order_source_query}='#{order_source}'"
|
credits = credits.where("order_sources.source = ?", order_source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
query = SalePayment.select("s.receipt_no, sale_payments.*,
|
|
||||||
SUM(sale_payments.payment_amount) as payment_amount,
|
if filter == 'paid'
|
||||||
s.receipt_date as sale_date,
|
credits = credits.where("credit_payment IS NOT NULL")
|
||||||
#{order_source_query} as order_source,
|
elsif filter == 'unpaid'
|
||||||
s.cashier_name as cashier_name,
|
credits = credits.where("credit_payment IS NULL")
|
||||||
(#{sub_query}) as credit_payment_receipt_date,
|
end
|
||||||
(#{sub_query1}) as credit_payment,
|
|
||||||
(#{sub_query3}) as credit_payment_cashier_name,
|
|
||||||
(#{sub_query2}) as credit_payment_shift_name")
|
|
||||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
|
||||||
.joins("INNER JOIN shift_sales ss ON ss.id = s.shift_sale_id")
|
|
||||||
|
|
||||||
if shift.present?
|
if shift.present?
|
||||||
query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift.to_a)
|
credits = credits.where("sales.shift_sale_id in (?)",shift.to_a)
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift_sale_range.to_a)
|
credits = credits.where("sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||||
else
|
else
|
||||||
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? #{source}",from,to)
|
credits = credits.where("sales.receipt_date between ? and ?",from,to)
|
||||||
end
|
end
|
||||||
query = query.group("s.sale_id")
|
credits = credits.group("sales.sale_id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_void_sale(shift,from,to)
|
def self.get_void_sale(shift,from,to)
|
||||||
@@ -2727,7 +2684,7 @@ def self.get_hourly_item_query(type)
|
|||||||
"i.status as status_type,i.remark as remark,"+
|
"i.status as status_type,i.remark as remark,"+
|
||||||
"i.unit_price,i.price as price,i.product_name as product_name, " +
|
"i.unit_price,i.price as price,i.product_name as product_name, " +
|
||||||
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
|
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
|
||||||
|
|
||||||
"concat(hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')), ':00 - ', hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) + 1, ':00') as date_format," +
|
"concat(hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')), ':00 - ', hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) + 1, ':00') as date_format," +
|
||||||
"hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) as hour")
|
"hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) as hour")
|
||||||
|
|
||||||
@@ -2751,6 +2708,139 @@ def grand_total_round
|
|||||||
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Loader Service SFTP Start
|
||||||
|
def self.get_load_sale_range(load_time_start,load_time_end)
|
||||||
|
query = Sale.select("sales.sale_id,
|
||||||
|
CONVERT(receipt_date, TIME) as transaction_time,
|
||||||
|
CONVERT(receipt_date, DATE) as transaction_date,
|
||||||
|
receipt_no as transaction_no,
|
||||||
|
SUM(i.qty) as item_no,
|
||||||
|
'MMK' as currency_salesamount,
|
||||||
|
IFNULL((total_amount-total_discount)-((total_amount-total_discount)/21),0) as total_salesamount,
|
||||||
|
IFNULL(amount_changed,0) as change_amt,
|
||||||
|
IFNULL(total_amount-total_discount,0) as grand_salesamount,
|
||||||
|
'5' as tax_percent,
|
||||||
|
'MMK' as currency_payment,
|
||||||
|
IFNULL(amount_received,0) as paymentamount,
|
||||||
|
sp.payment_amount as payment_method,
|
||||||
|
CASE
|
||||||
|
WHEN sales.sale_status='completed' THEN 'Sales'
|
||||||
|
WHEN sales.sale_status='void' THEN 'Void'
|
||||||
|
END as sale_type,
|
||||||
|
sales.updated_at as load_time")
|
||||||
|
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||||
|
" JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
|
.where("(sale_status=? OR sale_status=?) AND sp.payment_method !=? AND sales.updated_at between ? AND ?", 'completed', 'void', 'foc', load_time_start, load_time_end)
|
||||||
|
.group("receipt_no")
|
||||||
|
.order("receipt_date")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_tender_sale_data(transaction_date)
|
||||||
|
query = Sale.select("sales.receipt_no as check_num,
|
||||||
|
DATE_FORMAT(sales.receipt_date, '%d %b %Y') as business_date,
|
||||||
|
sales.receipt_date as transaction_date,
|
||||||
|
'36017' as item_id,
|
||||||
|
'Cash Received' as item_name,
|
||||||
|
'1' as qty,
|
||||||
|
'Tender' as transaction_type,
|
||||||
|
'0' as sales,
|
||||||
|
CASE WHEN sales.sale_status = 'void' THEN '1' ELSE '0' END as is_void
|
||||||
|
")
|
||||||
|
.where("DATE(sales.receipt_date)=? AND sales.sale_status != ?", transaction_date, :void)
|
||||||
|
.order("sales.receipt_no")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_daily_sale_data(transaction_date)
|
||||||
|
query = Sale.connection.select_all("SELECT s.receipt_date as business_date,
|
||||||
|
(SUM(s.grand_total)+SUM(s.total_discount)) as gross_sales,
|
||||||
|
SUM(s.total_discount) as discount,
|
||||||
|
SUM(s.grand_total) as sales,
|
||||||
|
SUM(s.grand_total)/21 as tax,
|
||||||
|
0 as service_charge,
|
||||||
|
SUM(s.grand_total) - (SUM(s.grand_total)/21) as net_sales,
|
||||||
|
SUM(s.credit_amount) as credit_amount,
|
||||||
|
SUM(s.voucher_sales) as voucher_sales,
|
||||||
|
0 as staff_meal_amt,
|
||||||
|
0 as round_amt,
|
||||||
|
0 as raw_wastage_amt,
|
||||||
|
0 as semi_wastage_amt,
|
||||||
|
CASE WHEN s.sale_status='waste' THEN SUM(s.total_amount) ELSE 0 END as wastage_amt,
|
||||||
|
CASE WHEN s.sale_status='spoile' THEN SUM(s.total_amount) ELSE 0 END as spoilage_amt,
|
||||||
|
0 as sampling_amt,
|
||||||
|
0 as other_amt,
|
||||||
|
SUM(s.qty) as total_qty,
|
||||||
|
(SELECT COUNT(sales.sale_id) FROM sales WHERE DATE(sales.receipt_date)='#{transaction_date}') as total_transaction,
|
||||||
|
(SELECT COUNT(sales.sale_id) FROM sales WHERE (sales.sale_status='completed' OR sales.sale_status='void') AND DATE(sales.receipt_date)='#{transaction_date}') as valid_transaction_count,
|
||||||
|
(SELECT COUNT(sales.sale_id) FROM sales WHERE (sales.sale_status IN('new','pending',null)) AND DATE(sales.receipt_date)='#{transaction_date}') as invalid_transaction_count,
|
||||||
|
0 as overing_transaction_count,
|
||||||
|
0 as cancle_transaction_count,
|
||||||
|
0 as no_of_pax,
|
||||||
|
0 as no_of_adult,
|
||||||
|
0 as no_of_child
|
||||||
|
FROM (
|
||||||
|
SELECT s.*, SUM(qty) as qty
|
||||||
|
FROM (
|
||||||
|
SELECT sales.*,
|
||||||
|
SUM(CASE WHEN sp.payment_method IN('mpu','master','visa','jcb','unionpay','alipay') THEN sp.payment_amount ELSE 0 END) as credit_amount,
|
||||||
|
SUM(case when (sp.payment_method='giftvoucher') then sp.payment_amount else 0 end) as voucher_sales
|
||||||
|
FROM sales
|
||||||
|
LEFT JOIN sale_payments sp ON sp.sale_id = sales.sale_id
|
||||||
|
WHERE DATE(sales.receipt_date) = '#{transaction_date}'
|
||||||
|
AND sales.sale_status!='void'
|
||||||
|
AND sales.sale_status='completed'
|
||||||
|
GROUP BY sales.sale_id) AS s
|
||||||
|
LEFT JOIN sale_items si ON si.sale_id = s.sale_id
|
||||||
|
GROUP BY s.sale_id) as s
|
||||||
|
GROUP BY DATE(s.receipt_date)").to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_check_sale_data(transaction_date)
|
||||||
|
sale_receivables_subquery = "SELECT sale_payments.sale_id,
|
||||||
|
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' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as credit_card_sales,
|
||||||
|
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
|
||||||
|
FROM sale_payments
|
||||||
|
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
|
||||||
|
|
||||||
|
query = Sale.select("
|
||||||
|
sales.receipt_no as check_num,
|
||||||
|
sales.receipt_date as business_date,
|
||||||
|
sales.requested_at as check_open_time,
|
||||||
|
sales.updated_at as check_close_time,
|
||||||
|
(sales.grand_total + sales.total_discount) as gross_sales,
|
||||||
|
sales.total_discount as discount_amt,
|
||||||
|
sales.grand_total as sales,
|
||||||
|
(sales.grand_total/21) as tax_amt,
|
||||||
|
0 as service_charges,
|
||||||
|
(sales.grand_total - (sales.grand_total/21)) as net_sales,
|
||||||
|
receivables.credit_card_sales as credit_card_sales,
|
||||||
|
receivables.voucher_sales as voucher_sales,
|
||||||
|
0 as staff_meal_amt,
|
||||||
|
sales.rounding_adjustment as rounding_amt,
|
||||||
|
CASE WHEN sales.sale_status='waste' THEN sales.total_amount ELSE 0 END as wastage_amt,
|
||||||
|
CASE WHEN sales.sale_status='spoile' THEN sales.total_amount ELSE 0 END as spoilage_amt,
|
||||||
|
0 as sampling_amt,
|
||||||
|
SUM(i.qty) as qty,
|
||||||
|
0 as no_of_pax,
|
||||||
|
0 as no_of_adult,
|
||||||
|
0 as no_of_child,
|
||||||
|
shift_sales.cashier_terminal_id as pos_id,
|
||||||
|
sales.cashier_id as employee_code,
|
||||||
|
employees.name as employee_name,
|
||||||
|
CASE WHEN sales.sale_status='completed' THEN 1 ELSE 0 END is_valid,
|
||||||
|
0 as overing,
|
||||||
|
0 as cancle,
|
||||||
|
CONCAT( employees.name, ' Cash&Go receipt generated and completed.') as remarks")
|
||||||
|
.joins("LEFT JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||||
|
.joins("LEFT JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||||
|
.joins("LEFT JOIN (" + sale_receivables_subquery + ") as receivables ON receivables.sale_id = sales.sale_id")
|
||||||
|
.joins("LEFT JOIN employees ON employees.id = sales.cashier_id")
|
||||||
|
.where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void)
|
||||||
|
.group("sales.receipt_no,sales.sale_status")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Loader Service SFTP End
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class SaleItem < ApplicationRecord
|
|||||||
# sale_item.save
|
# sale_item.save
|
||||||
if type != "foc"
|
if type != "foc"
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
sale.compute_by_sale_items(sale.total_discount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -294,4 +294,57 @@ class SaleItem < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Loader Service SFTP Start
|
||||||
|
# Detail Sale Data
|
||||||
|
def self.get_detail_sale_data(transaction_date)
|
||||||
|
query = SaleItem.select("
|
||||||
|
sale_items.sale_item_id as id,
|
||||||
|
sale_items.sale_id as parent_id,
|
||||||
|
s.receipt_no as check_num,
|
||||||
|
s.receipt_date as business_date,
|
||||||
|
s.receipt_date as transaction_date,
|
||||||
|
'' as item_seq,
|
||||||
|
sale_items.menu_category_code as category_code,
|
||||||
|
sale_items.menu_category_name as category_name,
|
||||||
|
'' as sub_category_code,
|
||||||
|
'' as sub_category_name,
|
||||||
|
'' as report_group_code,
|
||||||
|
'' as report_group_name,
|
||||||
|
sale_items.product_code as item_id,
|
||||||
|
sale_items.product_name as item_name,
|
||||||
|
sale_items.qty as qty,
|
||||||
|
CASE
|
||||||
|
WHEN s.sale_status = 'completed' OR s.sale_status = 'void' THEN 'Sales'
|
||||||
|
WHEN s.sale_status = 'waste' THEN 'Waste'
|
||||||
|
WHEN s.sale_status = 'spoile' THEN 'Spoil'
|
||||||
|
END as transaction_type,
|
||||||
|
sale_items.price as gross_sales,
|
||||||
|
'' as discount_code,
|
||||||
|
CASE
|
||||||
|
WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0
|
||||||
|
END as discount_amt,
|
||||||
|
(sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) as sales,
|
||||||
|
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21) as tax_amt,
|
||||||
|
'' as service_charges,
|
||||||
|
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) - ((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21)) as net_sales,
|
||||||
|
'0' as is_set_item,
|
||||||
|
'0' as is_staff_meal,
|
||||||
|
'0' as is_raw_wastage,
|
||||||
|
'0' as is_semi_wastage,
|
||||||
|
CASE WHEN s.sale_status = 'waste' THEN 1 ELSE 0 END as is_wastage,
|
||||||
|
CASE WHEN s.sale_status = 'spoile' THEN 1 ELSE 0 END as is_spoilage,
|
||||||
|
'0' as is_sampling,
|
||||||
|
'1' as tax_able,
|
||||||
|
CASE
|
||||||
|
WHEN s.sale_status = 'void' THEN 1 ELSE 0
|
||||||
|
END as is_void
|
||||||
|
")
|
||||||
|
.joins("LEFT JOIN sales s ON s.sale_id = sale_items.sale_id")
|
||||||
|
.joins("LEFT JOIN sale_items i ON sale_items.sale_id = i.sale_id AND sale_items.item_instance_code = i.item_instance_code AND i.status = 'Discount' AND sale_items.qty = abs(i.qty)")
|
||||||
|
.where("DATE(s.receipt_date) = ? AND s.sale_status != 'void' AND (sale_items.status NOT IN('Discount', 'void','foc') OR sale_items.status IS NULL)", transaction_date)
|
||||||
|
.order("s.receipt_no")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Loader Service SFTP End
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ class SalePayment < ApplicationRecord
|
|||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
end
|
end
|
||||||
sale = Sale.find(self.sale.sale_id)
|
sale = Sale.find(self.sale.sale_id)
|
||||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,'','','',"foc")
|
sale.compute_by_sale_items(sale.total_discount,'','','',"foc")
|
||||||
|
|
||||||
self.payment_method = "foc"
|
self.payment_method = "foc"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<!-- <div class="row"> -->
|
<!-- <div class="row"> -->
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a href="javascript:export_to('<%=reports_credit_payment_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
|
<a href="javascript:export_to('<%=reports_credit_payment_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
else
|
else
|
||||||
delimiter = ""
|
delimiter = ""
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<% unless @sale_data.blank? %>
|
<% unless @sale_data.blank? %>
|
||||||
|
|
||||||
<table class="table table-striped" border="0">
|
<table class="table table-striped" border="0">
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
@@ -61,10 +61,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% total_credit_amount = 0
|
<% total_credit_amount = 0
|
||||||
total_credit_payment = 0 %>
|
total_credit_payment = 0 %>
|
||||||
<% @sale_data.each do |credit| %>
|
<% @sale_data.each do |credit| %>
|
||||||
<% total_credit_amount += credit.payment_amount %>
|
<% total_credit_amount += credit.payment_amount %>
|
||||||
<% total_credit_payment += credit.credit_payment %>
|
<% total_credit_payment += credit.credit_payment %>
|
||||||
<tr>
|
<tr>
|
||||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||||
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -78,10 +78,10 @@
|
|||||||
Quick Service
|
Quick Service
|
||||||
<% else %>
|
<% else %>
|
||||||
Online Order
|
Online Order
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= credit.cashier_name rescue '-' %></td>
|
<td><%= credit.cashier_name rescue '-' %></td>
|
||||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
<td><%= credit.customer_name rescue '-' %></td>
|
||||||
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||||
<td>
|
<td>
|
||||||
<%if credit.credit_payment_shift_name == '-' %>
|
<%if credit.credit_payment_shift_name == '-' %>
|
||||||
@@ -112,20 +112,20 @@
|
|||||||
var check_arr = [];
|
var check_arr = [];
|
||||||
search_by_period();
|
search_by_period();
|
||||||
$('#sel_period').change(function(){
|
$('#sel_period').change(function(){
|
||||||
|
|
||||||
search_by_period();
|
search_by_period();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function search_by_period(){
|
function search_by_period(){
|
||||||
var period = $('#sel_period').val();
|
var period = $('#sel_period').val();
|
||||||
var period_type = 0;
|
var period_type = 0;
|
||||||
var from = "";
|
var from = "";
|
||||||
var to = "";
|
var to = "";
|
||||||
|
|
||||||
show_shift_name(period,period_type,from,to,'shift_item');
|
show_shift_name(period,period_type,from,to,'shift_item');
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK button is clicked
|
// OK button is clicked
|
||||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||||
new_date = new Date(date) ;
|
new_date = new Date(date) ;
|
||||||
@@ -140,32 +140,32 @@
|
|||||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||||
$('#to').val(to)
|
$('#to').val(to)
|
||||||
search_by_date();
|
search_by_date();
|
||||||
});
|
});
|
||||||
|
|
||||||
function search_by_date(){
|
function search_by_date(){
|
||||||
|
|
||||||
from = $("#from").val();
|
from = $("#from").val();
|
||||||
to = $("#to").val();
|
to = $("#to").val();
|
||||||
|
|
||||||
var period = 0;
|
var period = 0;
|
||||||
var period_type = 1;
|
var period_type = 1;
|
||||||
|
|
||||||
if(to != '' && from != ''){
|
if(to != '' && from != ''){
|
||||||
shift_name = from + ',' + to;
|
shift_name = from + ',' + to;
|
||||||
|
|
||||||
check_arr.push(to);
|
check_arr.push(to);
|
||||||
|
|
||||||
console.log(check_arr.length)
|
console.log(check_arr.length)
|
||||||
if(check_arr.length == 1){
|
if(check_arr.length == 1){
|
||||||
show_shift_name(period,period_type,from,to,'shift_item');
|
show_shift_name(period,period_type,from,to,'shift_item');
|
||||||
}
|
}
|
||||||
if(check_arr.length == 3){
|
if(check_arr.length == 3){
|
||||||
check_arr = [];
|
check_arr = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_shift_name(period,period_type,from,to,shift_item){
|
function show_shift_name(period,period_type,from,to,shift_item){
|
||||||
var shift = $('#shift_name');
|
var shift = $('#shift_name');
|
||||||
if (from == '' && to == '') {
|
if (from == '' && to == '') {
|
||||||
@@ -173,18 +173,18 @@
|
|||||||
to = $("#to").val();
|
to = $("#to").val();
|
||||||
}
|
}
|
||||||
shift.empty();
|
shift.empty();
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
var param_shift = '';
|
var param_shift = '';
|
||||||
var param_shift = '<%= params[:shift_name] rescue '-'%>';
|
var param_shift = '<%= params[:shift_name] rescue '-'%>';
|
||||||
|
|
||||||
url = '<%= reports_get_shift_by_date_path %>';
|
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){
|
$.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>';
|
str = '<option value="0">--- All Shift ---</option>';
|
||||||
$(data.message).each(function(index){
|
$(data.message).each(function(index){
|
||||||
|
|
||||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
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 sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||||
var shift_id = data.message[index].shift_id ;
|
var shift_id = data.message[index].shift_id ;
|
||||||
@@ -193,18 +193,18 @@
|
|||||||
selected = 'selected = "selected"';
|
selected = 'selected = "selected"';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
selected = '';
|
selected = '';
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
selected = '';
|
selected = '';
|
||||||
}
|
}
|
||||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||||
|
|
||||||
// console.log(sh_date)
|
// console.log(sh_date)
|
||||||
})
|
})
|
||||||
shift.append(str);
|
shift.append(str);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||||
@@ -33,10 +33,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% total_credit_amount = 0
|
<% total_credit_amount = 0
|
||||||
total_credit_payment = 0 %>
|
total_credit_payment = 0 %>
|
||||||
<% @sale_data.each do |credit| %>
|
<% @sale_data.each do |credit| %>
|
||||||
<% total_credit_amount += credit.payment_amount
|
<% total_credit_amount += credit.payment_amount
|
||||||
total_credit_payment += credit.credit_payment %>
|
total_credit_payment += credit.credit_payment %>
|
||||||
<tr>
|
<tr>
|
||||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||||
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -50,10 +50,10 @@
|
|||||||
Quick Service
|
Quick Service
|
||||||
<% else %>
|
<% else %>
|
||||||
Online Order
|
Online Order
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= credit.cashier_name rescue '-' %></td>
|
<td><%= credit.cashier_name rescue '-' %></td>
|
||||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
<td><%= credit.customer_name rescue '-' %></td>
|
||||||
<td><%= credit.payment_amount rescue '-' %></td>
|
<td><%= credit.payment_amount rescue '-' %></td>
|
||||||
<td>
|
<td>
|
||||||
<%if credit.credit_payment_shift_name == '-' %>
|
<%if credit.credit_payment_shift_name == '-' %>
|
||||||
@@ -78,4 +78,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -138,8 +138,7 @@
|
|||||||
delimiter = ""
|
delimiter = ""
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<% unless @sale_data.empty? %>
|
<% unless @sale_data.blank? %>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% void = 0 %>
|
<% void = 0 %>
|
||||||
<% mpu = 0 %>
|
<% mpu = 0 %>
|
||||||
@@ -322,7 +321,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% total_tax = 0 %>
|
<% total_tax = 0 %>
|
||||||
<% net = 0 %>
|
<% net = 0 %>
|
||||||
<% unless @tax.empty? %>
|
<% unless @tax.blank? %>
|
||||||
<% @tax.each do |tax|
|
<% @tax.each do |tax|
|
||||||
total_tax += tax.tax_amount.to_f %>
|
total_tax += tax.tax_amount.to_f %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="card" style="width:129%;">
|
<div class="card" style="width:129%;">
|
||||||
<div class="body table-responsive">
|
<div class="body table-responsive">
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="15"> <%= 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>
|
<th colspan="15"> <%= 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>
|
</tr>
|
||||||
@@ -58,8 +58,8 @@
|
|||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
||||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@@ -75,8 +75,8 @@
|
|||||||
else
|
else
|
||||||
delimiter = ""
|
delimiter = ""
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<% unless @sale_data.empty? %>
|
<% unless @sale_data.blank? %>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% void = 0 %>
|
<% void = 0 %>
|
||||||
@@ -97,8 +97,8 @@
|
|||||||
<% discount = 0 %>
|
<% discount = 0 %>
|
||||||
<% kbzpay = 0 %>
|
<% kbzpay = 0 %>
|
||||||
<% total = 0 %>
|
<% total = 0 %>
|
||||||
<% grand_total = 0 %>
|
<% grand_total = 0 %>
|
||||||
<% old_grand_total = 0 %>
|
<% old_grand_total = 0 %>
|
||||||
<% count = 1 %> <% rounding_adj = 0 %>
|
<% count = 1 %> <% rounding_adj = 0 %>
|
||||||
<% @sale_data.each do |sale| %>
|
<% @sale_data.each do |sale| %>
|
||||||
<% void += sale[:void_amount] %>
|
<% void += sale[:void_amount] %>
|
||||||
@@ -114,14 +114,14 @@
|
|||||||
<% giftvoucher += sale[:giftvoucher_amount] %>
|
<% giftvoucher += sale[:giftvoucher_amount] %>
|
||||||
<% paypar += sale[:paypar_amount] %>
|
<% paypar += sale[:paypar_amount] %>
|
||||||
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
|
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
|
||||||
<% credit += sale[:credit_amount] %>
|
<% credit += sale[:credit_amount] %>
|
||||||
<% foc += sale[:foc_amount] %>
|
<% foc += sale[:foc_amount] %>
|
||||||
<% discount += sale[:total_discount] %>
|
<% discount += sale[:total_discount] %>
|
||||||
<% kbzpay += sale[:kbzpay_amount] %>
|
<% kbzpay += sale[:kbzpay_amount] %>
|
||||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||||
<% grand_total += sale[:grand_total].to_f %>
|
<% grand_total += sale[:grand_total].to_f %>
|
||||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='text-align:right;'><%= count %></td>
|
<td style='text-align:right;'><%= count %></td>
|
||||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||||
@@ -161,13 +161,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), delimiter: delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), delimiter: delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]),delimiter => ',') rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]),delimiter => ',') rescue '-'%></td>
|
||||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]),delimiter => ',') rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), delimiter => ',') rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), delimiter => ',') rescue '-'%>)</td>
|
||||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(sale[:grand_total].to_f + sale[:rounding_adj].to_f ,delimiter => ',') rescue '-'%></td> -->
|
<!-- <td style='text-align:right;'><%= number_with_delimiter(sale[:grand_total].to_f + sale[:rounding_adj].to_f ,delimiter => ',') rescue '-'%></td> -->
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]),delimiter => ',') rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f),delimiter => ',') rescue '-'%></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% colspan = 7 %>
|
<% colspan = 7 %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="3" style='text-align:center;'>Total</td>
|
<td colspan="3" style='text-align:center;'>Total</td>
|
||||||
<% if @payment_methods.include? ("MPU") %>
|
<% if @payment_methods.include? ("MPU") %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu),delimiter => ',') rescue '-'%></td>
|
||||||
@@ -222,21 +222,21 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash),delimiter => ',') rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit),delimiter => ',') rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), delimiter => ',') rescue '-'%></td>
|
||||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",giftvoucher), delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",giftvoucher), delimiter => ',') rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'>(<%= number_with_delimiter(discount,delimiter => ',') rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_with_delimiter(discount,delimiter => ',') rescue '-'%>)</td>
|
||||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(total,delimiter => ',') rescue '-'%></td> -->
|
<!-- <td style='text-align:right;'><%= number_with_delimiter(total,delimiter => ',') rescue '-'%></td> -->
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total),delimiter => ',') rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% total_tax = 0 %>
|
<% total_tax = 0 %>
|
||||||
<% net = 0 %>
|
<% net = 0 %>
|
||||||
<% unless @tax.empty? %>
|
<% unless @tax.blank? %>
|
||||||
<% @tax.each do |tax|
|
<% @tax.each do |tax|
|
||||||
total_tax += tax.tax_amount.to_f %>
|
total_tax += tax.tax_amount.to_f %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net),delimiter => ',') rescue '-'%></td>
|
||||||
<td colspan="2"> </td>
|
<td colspan="2"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -264,4 +264,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
|
|
||||||
#API for sync cloud
|
#API for sync cloud
|
||||||
post 'sync_data' => 'sync#sync_data'
|
post 'sync_data' => 'sync#sync_data'
|
||||||
|
|
||||||
|
namespace :loader_service do
|
||||||
|
post "get_sale_data" => "load_data#get_sale_data_rage"
|
||||||
|
post "get_detail_sale_data" => "load_data#get_detail_sale_data"
|
||||||
|
post "get_tender_sale_data" => "load_data#get_tender_sale_data"
|
||||||
|
post "get_daily_sale_data" => "load_data#get_daily_sale_data"
|
||||||
|
post "get_check_sale_data" => "load_data#get_check_sale_data"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Cashier ------------#
|
#--------- Cashier ------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user