fixed conflict

This commit is contained in:
git_code2lab
2019-11-15 14:24:54 +06:30
55 changed files with 1479 additions and 1332 deletions

View File

@@ -1,5 +1,6 @@
class Api::ApiController < ActionController::API
# include TokenVerification
include TokenVerification
include ActionController::MimeResponds
# before_action :lookup_domain
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)
end
# def lookup_domain
# if request.subdomain.present? && request.subdomain != "www"
# from = request.subdomain.downcase + "." + request.domain.downcase
# def lookup_domain
# if request.subdomain.present? && request.subdomain != "www"
# from = request.subdomain.downcase + "." + request.domain.downcase
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
# if (!@license.nil?)
# logger.info "Location - " + @license.dbhost
# ActiveRecord::Base.establish_connection(website_connection(@license))
# # authenticate_session_token
# logger.info "Location - " + @license.dbhost
# ActiveRecord::Base.establish_connection(website_connection(@license))
# # authenticate_session_token
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
# else
# # reconnect_default_db
# logger.info 'License is nil'
# # redirect_to root_url(:host => request.domain) + "store_error"
# render :json => [{ status: false, message: 'Invalid Access!'}]
# 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,
# :username => license.dbusername, :password => license.dbpassword)
# end
@@ -55,8 +56,8 @@ class Api::ApiController < ActionController::API
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
# end
# def cache_license(url, lookup)
# @license = License.new(url, lookup)
# def cache_license(url, lookup)
# @license = License.new(url, lookup)
# if (@license.detail_with_local_cache(lookup) == true)
# return @license

View File

@@ -40,7 +40,7 @@ class Api::AuthenticateController < Api::ApiController
@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
@status = false
@error_message = "Bad Emp_ID or Password!"

View 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

View File

@@ -8,7 +8,7 @@ class Api::VoidController < Api::ApiController
if sale.discount_type == "member_discount"
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
# update count for shift sale
@@ -25,18 +25,17 @@ class Api::VoidController < Api::ApiController
shift.save
end
end
sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
# 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" )
render json: JSON.generate({:status => true, :message => "Void successful."})
else
render json: JSON.generate({:status => false, :error_message => "There is no sale for '#{params[:sale_id]}'!"})
end
end
end
end

View File

@@ -305,7 +305,7 @@ class Origami::AddordersController < BaseOrigamiController
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
from = request.subdomain.to_s + "." + request.domain.to_s
end
return from

View File

@@ -48,44 +48,44 @@ class Origami::CustomersController < BaseOrigamiController
def add_customer
@webview = false
if check_mobile
@webview = true
@webview = true
end
@sale_id = params[:sale_id]
@cashier_type = params[:type]
@page = params[:dir_page]
if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id)
if @booking.dining_facility_id.to_i > 0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@dining_facility = nil
@dining_facility = nil
end
else
@booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id)
if @booking.dining_facility_id.to_i > 0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@dining_facility = nil
@dining_facility = nil
end
end
end
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id") #.page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
# @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")
.order("group_type ASC,order_by ASC")
@@ -100,7 +100,7 @@ class Origami::CustomersController < BaseOrigamiController
lookup_customer = Lookup.collection_of('customer_settings')
if !lookup_customer.empty?
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'
@create_flag = false
end
@@ -154,13 +154,13 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
if(id == "SAL")
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
end
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
end
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
def send_account
amount = params[:amount]
account_no = params[:account_no]

View File

@@ -7,9 +7,9 @@ class Origami::DiscountsController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
@webview = false
if check_mobile
@webview = true
@webview = true
end
sale_id = params[:id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@@ -32,7 +32,6 @@ class Origami::DiscountsController < BaseOrigamiController
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -44,26 +43,29 @@ class Origami::DiscountsController < BaseOrigamiController
table_id = nil
end
# sale.total_discount = overall_discount.to_f
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
if discount_items.length > 0
#save sale item for discount
discount_items.each do |di|
origin_sale_item = SaleItem.find(di["id"])
sale_item = SaleItem.new
if !origin_sale_item.nil?
menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
if !menu_category.nil?
sale_item.menu_category_code = menu_category.code
sale_item.menu_category_name = menu_category.name
end
end
# if !origin_sale_item.nil?
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
# if !menu_category.nil?
# sale_item.menu_category_code = menu_category.code
# sale_item.menu_category_name = menu_category.name
# end
# end
sale_item.menu_category_code = origin_sale_item.menu_category_code
sale_item.menu_category_name = origin_sale_item.menu_category_name
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
@@ -73,7 +75,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.status = "Discount"
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * (-1)
sale_item.unit_price = di["price"].to_f * -1
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 1
sale_item.account_id = origin_sale_item.account_id
@@ -83,11 +85,11 @@ class Origami::DiscountsController < BaseOrigamiController
action_by = current_user.name
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" )
end
end
end
end
# Re-calc All Amount in Sale
if overall_discount.to_f > 0
@@ -97,24 +99,24 @@ class Origami::DiscountsController < BaseOrigamiController
else
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
end
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
if !table.nil?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Success" }
end
else
else
if !table.nil?
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!" }
end
end
end
render :json => result.to_json
end
@@ -131,45 +133,45 @@ class Origami::DiscountsController < BaseOrigamiController
else
table_id = nil
table = nil
end
if discount_items.length > 0
end
if discount_items.length > 0
#destroy sale item for discount
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
sale.total_amount = (sale.total_amount + sale_item.price.abs)
action_by = current_user.name
if table.nil?
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
else
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" )
sale_item.destroy
end
end
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
sale_item.destroy
end
end
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
# 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?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
end
else
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
end
end
render :json => result.to_json
end
@@ -180,29 +182,29 @@ class Origami::DiscountsController < BaseOrigamiController
order_source = params[:type]
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
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
table_type = table.type
table_type = table.type
else
table_id = nil
table = nil
table_type = nil
end
end
discount_items = []
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
sale.sale_items.each do |si|
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
end
end
# sale.total_discount = 0
# 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
#destroy in sale.sale_items
@@ -215,23 +217,23 @@ class Origami::DiscountsController < BaseOrigamiController
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
# 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?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
else
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
end
end
render :json => result.to_json
end
@@ -251,7 +253,7 @@ class Origami::DiscountsController < BaseOrigamiController
end
# Check for Card Payment
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
# if is_card != "true"
account_types = Account.where("discount=?",true)
table_id = sale.bookings[0].dining_facility_id
@@ -267,9 +269,9 @@ class Origami::DiscountsController < BaseOrigamiController
str={type:pc[:name],amount:pc[:price]}
acc_prices.push(str)
end
end
end
end
generic_customer_id = sale.customer.membership_id
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
@@ -282,7 +284,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Check for items for Paypar Cloud
if acc_prices.length > 0
begin
response = HTTParty.post(url,
response = HTTParty.post(url,
:body => { account_no: account_no,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
@@ -307,7 +309,7 @@ class Origami::DiscountsController < BaseOrigamiController
rescue SocketError
response = {"status": false, "message": "Can't open membership server " }
end
else
else
response = {"status": false, "message": "You have no selected discount item" }
end
Rails.logger.debug "-------------- Member Discount Osaka ---------"
@@ -318,14 +320,14 @@ class Origami::DiscountsController < BaseOrigamiController
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
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 }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
else
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
render :json => result.to_json
# end #end Is Card Payment
@@ -376,5 +378,5 @@ class Origami::DiscountsController < BaseOrigamiController
# redirect_to origami_path(sale_id)
# end
end

View File

@@ -4,9 +4,9 @@ class Origami::OtherChargesController < BaseOrigamiController
def index
@webview = false
if check_mobile
@webview = true
@webview = true
end
sale_id = params[:sale_id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@@ -15,11 +15,11 @@ class Origami::OtherChargesController < BaseOrigamiController
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
else
@table = nil
end
end
end
end
def create
def create
sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total]
@@ -34,11 +34,11 @@ class Origami::OtherChargesController < BaseOrigamiController
table_id = nil
table = nil
end
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
@@ -68,18 +68,18 @@ class Origami::OtherChargesController < BaseOrigamiController
else
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
end
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
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
end
sale.compute_by_sale_items(sale.total_discount, nil, cashier_type)
end
if !table.nil?
dining = {:table_id => table_id, :table_type => table.type }
render :json => dining.to_json
end
end
end
end
end
end

View File

@@ -64,15 +64,9 @@ class Origami::PaymentsController < BaseOrigamiController
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if shop_detail.is_rounding_adj
a = sale_data.grand_total % 25 # Modulus
b = sale_data.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total-sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
end
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total - sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
end
#end rounding adjustment
#record for sale audit
@@ -151,15 +145,9 @@ class Origami::PaymentsController < BaseOrigamiController
# rounding adjustment
if !path.include? ("credit_payment")
if shop_detail.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total - saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
end
end
#end rounding adjustment
@@ -655,7 +643,7 @@ class Origami::PaymentsController < BaseOrigamiController
if saleObj.discount_type == "member_discount"
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
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
@@ -830,7 +818,7 @@ class Origami::PaymentsController < BaseOrigamiController
order_source = params[:cashier_type]
tax_type = params[:tax_type]
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})
end
@@ -839,7 +827,7 @@ class Origami::PaymentsController < BaseOrigamiController
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
from = request.subdomain.to_s + "." + request.domain.to_s
end
return from

View File

@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
else
redirect_to "/origami/#{params[:type]}" and return
end
elsif (id.start_with?("BKI")|| id.start_with?("CBKI"))
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
@bookings = Booking.find(id)
@order = @bookings.orders.where(status: "new").first
@order_items = @bookings.order_items

View File

@@ -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}"
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)
end
@@ -72,7 +72,7 @@ class Origami::SaleEditController < BaseOrigamiController
saleitemObj.status = 'foc'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.unit_price = saleitemObj.unit_price * 1
@@ -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}"
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)
end
@@ -143,17 +143,17 @@ class Origami::SaleEditController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" )
# saleitemObj.remark = 'edit'
unless saleitemObj.product_name.include? 'updated'
unless saleitemObj.product_name.include? 'UPDATED'
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
end
saleitemObj.save
# 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 = Order.find(order_id)
# order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
# order = Order.find(order_id)
# order.order_items.each do |o|
# if saleitemObj.product_code == o.item_code
@@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController
# 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)
end
@@ -195,8 +195,8 @@ class Origami::SaleEditController < BaseOrigamiController
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}"
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)
end
@@ -214,9 +214,9 @@ class Origami::SaleEditController < BaseOrigamiController
item.save
ProductCommission.remove_product_commission(item)
end
saleObj.sale_items.reset
# 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
def apply_void

View File

@@ -10,7 +10,7 @@ class Origami::VoidController < BaseOrigamiController
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
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
# update count for shift sale

View File

@@ -15,7 +15,6 @@ class Origami::WasteSpoileController < BaseOrigamiController
sale.sale_status = remark
sale.save
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
# add to sale item with foc
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")

View File

@@ -6,7 +6,7 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales
# GET /transactions/sales.json
def index
receipt_no = params[:receipt_no]
# from = params[:from]
# to = params[:to]
@@ -19,18 +19,18 @@ class Transactions::SalesController < ApplicationController
if receipt_no.nil? && from.nil? && to.nil?
if @shift.blank?
@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")
end
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else
sale = Sale.search(receipt_no,from,to,@shift)
if sale.count > 0
@sales = sale
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else
@sales = 0
end
end
end
@receipt_no = receipt_no
@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_data = @shift
end
# 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)
# 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])
# 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])
# else
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
# end
# else
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
# end
# if sale.count > 0
# @sales = sale
# @sales = sale
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
# else
# @sales = 0
@@ -182,7 +182,7 @@ class Transactions::SalesController < ApplicationController
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
to = params[:to]
day_ref = Time.now.utc.getlocal
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)
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
to = t_time.end_of_day.utc.getlocal
else
to = t_time.end_of_day.utc.getlocal
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
@@ -226,10 +226,10 @@ class Transactions::SalesController < ApplicationController
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
end
return from, to
return from, to
end
def check_user
@@ -248,7 +248,7 @@ class Transactions::SalesController < ApplicationController
if sale.discount_type == "member_discount"
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
# update count for shift sale
@@ -265,7 +265,7 @@ class Transactions::SalesController < ApplicationController
shift.save
end
end
sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'
@@ -308,16 +308,16 @@ class Transactions::SalesController < ApplicationController
table = nil
end
# FOr Sale Audit
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
# 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" )
# For Print
# For Print
member_info = nil
rebate_amount = nil
@@ -325,7 +325,7 @@ class Transactions::SalesController < ApplicationController
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
if bookings.count > 1
# for Multiple Booking
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
@@ -339,12 +339,12 @@ class Transactions::SalesController < ApplicationController
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find_by_id(1)
# get member information
@@ -363,31 +363,31 @@ class Transactions::SalesController < ApplicationController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
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)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_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)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print
# 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|
aoi.delivery_status = 1
aoi.save
end
end
end
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_sale