update add order
This commit is contained in:
@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@taxes = TaxProfile.all.order("order_by asc")
|
||||
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@@ -63,16 +65,21 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
# GET /crm/customers/1/edit
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
# update tax profile
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -81,7 +88,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
nrc = customer_params[:nrc_no]
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if member_group_id.present?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -90,13 +97,24 @@ class Crm::CustomersController < BaseCrmController
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => {name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
@@ -128,8 +146,25 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
|
||||
# When paypar account no not exist in paypar
|
||||
if response["message"] == "Account has not exist."
|
||||
customer.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] }
|
||||
end
|
||||
end
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]}
|
||||
else
|
||||
@@ -161,10 +196,12 @@ end
|
||||
# PATCH/PUT /crm/customers/1
|
||||
# PATCH/PUT /crm/customers/1.json
|
||||
def update
|
||||
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
respond_to do |format|
|
||||
if @crm_customer.update(customer_params)
|
||||
|
||||
# update tax profile
|
||||
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -174,23 +211,33 @@ end
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if id.nil? && !member_group_id.nil?
|
||||
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
paypar_account_no: paypar_account_no,
|
||||
card_no:card_no,member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
@@ -207,34 +254,47 @@ end
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
if response["status"] == true
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
||||
|
||||
else
|
||||
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: response["error"] }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => {name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
@@ -255,6 +315,13 @@ end
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
else
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
@@ -289,7 +356,7 @@ end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
|
||||
end
|
||||
end
|
||||
|
||||
126
app/controllers/oqs/backhome_controller.rb
Normal file
126
app/controllers/oqs/backhome_controller.rb
Normal file
@@ -0,0 +1,126 @@
|
||||
class Oqs::HomeController < BaseOqsController
|
||||
def index
|
||||
queue_stations=OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
@queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
@queue_completed_item = completed_order
|
||||
|
||||
@queue_stations_items=Array.new
|
||||
|
||||
# Calculate Count for each station tab
|
||||
queue_stations.each do |que|
|
||||
i = 0
|
||||
zone_id = 0
|
||||
@queue_items_details.each do |qid|
|
||||
dining = DiningFacility.find_by_name(qid.zone)
|
||||
que.order_queue_process_by_zones.each do |qz|
|
||||
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
zone_id = qid.zone_id
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
end
|
||||
|
||||
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
@queue_stations_items
|
||||
end
|
||||
|
||||
# Get Order items
|
||||
def get_order_items
|
||||
items = []
|
||||
table_name = params[:table_id]
|
||||
status = params[:status]
|
||||
dining = DiningFacility.find_by_name(table_name);
|
||||
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
|
||||
# if status == ""
|
||||
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
|
||||
# oi = OrderItem.find_by_item_code(aoi.item_code)
|
||||
# items.push(oi)
|
||||
# end
|
||||
# else
|
||||
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
|
||||
# oi = OrderItem.find_by_item_code(aoi.item_code)
|
||||
# items.push(oi)
|
||||
# end
|
||||
# end
|
||||
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
|
||||
order=Order.find(bo.order_id)
|
||||
order.order_items.each do |oi|
|
||||
items.push(oi)
|
||||
end
|
||||
end
|
||||
|
||||
# booking_id = dining.get_new_booking
|
||||
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
|
||||
# order=Order.find(bo.order_id);
|
||||
# order.order_items.each do |oi|
|
||||
# items.push(oi)
|
||||
# end
|
||||
# end
|
||||
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
# update delivery status when complete click
|
||||
def update_delivery_status
|
||||
removed_item = []
|
||||
assigned_item_id = params[:id]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# update delivery status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.delivery_status=true
|
||||
ai.save
|
||||
removed_item.push(ai.assigned_order_item_id)
|
||||
end
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.order("assigned_order_items.created_at")
|
||||
end
|
||||
|
||||
# Completed Order
|
||||
def completed_order
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,33 +1,44 @@
|
||||
class Oqs::HomeController < BaseOqsController
|
||||
def index
|
||||
queue_stations=OrderQueueStation.all
|
||||
|
||||
@queue_stations = OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
@queue_items_details = queue_items_query(false)
|
||||
# @queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
@queue_completed_item = completed_order
|
||||
|
||||
|
||||
@queue_stations_items=Array.new
|
||||
@filter = params[:filter]
|
||||
|
||||
@queue_completed_item = completed_order(@filter)
|
||||
if !@filter.nil?
|
||||
@count = queue_items_count_query(false,@filter)
|
||||
@count.each do |count|
|
||||
|
||||
# Calculate Count for each station tab
|
||||
queue_stations.each do |que|
|
||||
i = 0
|
||||
zone_id = 0
|
||||
@queue_items_details.each do |qid|
|
||||
dining = DiningFacility.find_by_name(qid.zone)
|
||||
que.order_queue_process_by_zones.each do |qz|
|
||||
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
zone_id = qid.zone_id
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
end
|
||||
|
||||
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
@queue_stations_items
|
||||
# @queue_stations_items=Array.new
|
||||
|
||||
# Calculate Count for each station tab
|
||||
# @queue_stations.each do |que|
|
||||
# i = 0
|
||||
# zone_id = 0
|
||||
# @queue_items_details.each do |qid|
|
||||
# dining = DiningFacility.find_by_name(qid.zone)
|
||||
# que.order_queue_process_by_zones.each do |qz|
|
||||
# if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
# zone_id = qid.zone_id
|
||||
# i=i+1
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
# end
|
||||
|
||||
# # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
# @queue_stations_items
|
||||
end
|
||||
|
||||
# Get Order items
|
||||
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def get_items_by_oqs
|
||||
oqs_id = params[:id]
|
||||
filter = params[:filter]
|
||||
items = queue_items_query(false,oqs_id,filter)
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
def queue_items_query(status,oqs_id=nil,filter)
|
||||
if oqs_id == nil
|
||||
oqs = ''
|
||||
else
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
end
|
||||
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -98,14 +129,15 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
end
|
||||
|
||||
# Completed Order
|
||||
def completed_order
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
def completed_order(filter)
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -115,12 +147,28 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
def queue_items_count_query(status,filter)
|
||||
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("oqs.id")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,6 +8,17 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
def show
|
||||
end
|
||||
|
||||
def get_customer
|
||||
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)
|
||||
end
|
||||
render :json => @crm_customers.to_json
|
||||
end
|
||||
|
||||
def add_customer
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@@ -18,9 +29,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||
@booking = Booking.find(@booking_order.booking_id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
end
|
||||
|
||||
filter = params[:filter]
|
||||
end
|
||||
|
||||
filter = params[:filter]
|
||||
|
||||
@@ -28,14 +37,14 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@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(50)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@taxes = TaxProfile.all.order("order_by asc")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@@ -51,21 +60,22 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
|
||||
# Check and find with card no
|
||||
if(!customer_id.include? "CUS")
|
||||
customer = Customer.find_by_paypar_account_no(customer_id)
|
||||
if(customer != nil)
|
||||
customer_id = customer.customer_id
|
||||
end
|
||||
end
|
||||
# if(!customer_id.include? "CUS")
|
||||
# customer = Customer.find_by_paypar_account_no(customer_id)
|
||||
# if(customer != nil)
|
||||
# customer_id = customer.customer_id
|
||||
# end
|
||||
# end
|
||||
|
||||
if(id == "SAL")
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: customer_id)
|
||||
sale.sale_orders.each do |sale_order|
|
||||
order = Order.find(sale_order.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
else
|
||||
@booking = BookingOrder.find_by_order_id(params[:sale_id])
|
||||
@@ -73,13 +83,15 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
@orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
|
||||
@@ -155,31 +155,35 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { account_no: nil,
|
||||
generic_customer_id:generic_customer_id ,
|
||||
campaign_type_id: campaign_type_id,
|
||||
receipt_no: receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
campaign_method:arr.to_json,
|
||||
total_sale_transaction_amount: sale.grand_total,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
# Check for items for Paypar Cloud
|
||||
if arr.length > 0
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { account_no: nil,
|
||||
generic_customer_id:generic_customer_id ,
|
||||
campaign_type_id: campaign_type_id,
|
||||
receipt_no: receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
campaign_method:arr.to_json,
|
||||
total_sale_transaction_amount: sale.grand_total,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
rescue Net::OpenTimeout
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
|
||||
rescue SocketError
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
rescue SocketError
|
||||
response = {:status=> false, :message => "Can't open membership server " }
|
||||
end
|
||||
else
|
||||
response = {:status=> false, :message => "You have no selected discount item" }
|
||||
end
|
||||
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
|
||||
@@ -2,10 +2,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
before_action :set_dining, only: [:show]
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.all.order('date desc')
|
||||
@shop = Shop.find_by_id(1)
|
||||
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
@@ -15,6 +17,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
@@ -37,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
|
||||
@@ -163,10 +163,46 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
|
||||
end
|
||||
|
||||
def foc
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
sub_total = params[:sub_total]
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "foc")
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
|
||||
end
|
||||
end
|
||||
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@shop = Shop.find_by_id(1)
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
else
|
||||
new_total = saleObj.grand_total
|
||||
end
|
||||
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
|
||||
@@ -5,7 +5,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
@sale = Sale.new
|
||||
sale_order=SaleOrder.new
|
||||
|
||||
if ShiftSale.current_open_shift(current_user.id)
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
order_id = params[:id] # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
@@ -20,6 +20,10 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@sale_data.shift_sale_id = shift.id
|
||||
@sale_data.save
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
|
||||
@@ -1,36 +1,80 @@
|
||||
class Origami::RoomsController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
@room.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
|
||||
@room.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
@obj = order
|
||||
@customer = order.customer
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@status = 'order'
|
||||
@status_order = 'order'
|
||||
else
|
||||
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed"
|
||||
@sale_array.push(sale)
|
||||
@status = 'sale'
|
||||
@obj = sale
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# @room.bookings.each do |booking|
|
||||
# if booking.sale_id.nil?
|
||||
# @order_items = Array.new
|
||||
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# @obj = order
|
||||
# @customer = order.customer
|
||||
# order.order_items.each do |item|
|
||||
# @order_items.push(item)
|
||||
# end
|
||||
# end
|
||||
# @status = 'order'
|
||||
# else
|
||||
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status != "completed"
|
||||
# @sale_array.push(sale)
|
||||
# @status = 'sale'
|
||||
# @obj = sale
|
||||
# @customer = sale.customer
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +1,50 @@
|
||||
class Origami::SaleEditController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
@table_id = params[:table_id]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
end
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
@table_id = params[:table_id]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
end
|
||||
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
def item_void
|
||||
saleitemId = params[:sale_item_id]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'void'
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + " - void"
|
||||
@newsaleitem.save
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
def item_void
|
||||
saleitemId = params[:sale_item_id]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'void'
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + " - void"
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
|
||||
def item_foc
|
||||
saleitemId = params[:sale_item_id]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'foc'
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' foc'
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
|
||||
# def item_edit
|
||||
# saleitemId = params[:sale_item_id]
|
||||
@@ -48,63 +67,63 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def item_edit
|
||||
saleitemId = params[:sale_item_id]
|
||||
update_qty = params[:update_qty]
|
||||
saleitemId = params[:sale_item_id]
|
||||
update_qty = params[:update_qty]
|
||||
update_price = params[:update_price]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
|
||||
saleitemObj.qty = update_qty
|
||||
saleitemObj.price = update_qty.to_f * update_price.to_f
|
||||
saleitemObj.unit_price = update_price
|
||||
saleitemObj.qty = update_qty
|
||||
saleitemObj.price = update_qty.to_f * update_price.to_f
|
||||
saleitemObj.unit_price = update_price
|
||||
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
|
||||
# saleitemObj.remark = 'edit'
|
||||
saleitemObj.product_name = saleitemObj.product_name + " - updated"
|
||||
saleitemObj.product_name = saleitemObj.product_name + " - updated"
|
||||
saleitemObj.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
|
||||
|
||||
# make cancel void item
|
||||
def item_void_cancel
|
||||
saleitemId = params[:sale_item_id]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
both = SaleItem.where('product_code=?',saleitemObj.product_code)
|
||||
both.each do |item|
|
||||
if item.qty.to_i > 0
|
||||
item.remark = nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
saleitemObj.destroy
|
||||
# make cancel void item
|
||||
def item_void_cancel
|
||||
saleitemId = params[:sale_item_id]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
||||
both.each do |item|
|
||||
if item.qty.to_i > 0
|
||||
item.remark = nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
saleitemObj.destroy
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
|
||||
# remove all void items
|
||||
def cancel_all_void
|
||||
sale_id = params[:sale_id]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.remark = nil
|
||||
end
|
||||
item.save
|
||||
end
|
||||
# remove all void items
|
||||
def cancel_all_void
|
||||
sale_id = params[:sale_id]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.remark = nil
|
||||
end
|
||||
item.save
|
||||
end
|
||||
|
||||
# re-calc tax
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
# re-calc tax
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
|
||||
def apply_void
|
||||
sale_id = params[:sale_id]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
def apply_void
|
||||
sale_id = params[:sale_id]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,15 +31,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
unique_code = "CloseCashierPdf"
|
||||
shop_details = Shop.find(1)
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes)
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
|
||||
|
||||
|
||||
end
|
||||
@@ -52,6 +58,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
def sale_summary
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
|
||||
# @shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -6,18 +6,19 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
|
||||
# update count for shift sale
|
||||
if(sale.sale_status == "void")
|
||||
if(sale.sale_status == "completed")
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.calculate(sale_id, "void")
|
||||
end
|
||||
end
|
||||
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
bookings = sale.bookings
|
||||
bookings.each do |booking|
|
||||
orders = booking.orders
|
||||
|
||||
72
app/controllers/origami/voucher_controller.rb
Normal file
72
app/controllers/origami/voucher_controller.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
class Origami::VoucherController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
# limit voucher_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
@vouchercount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "voucher"
|
||||
@vouchercount = @vouchercount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_voucher = total - @vouchercount - others
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
sale_id = params[:refnumber]
|
||||
if(Sale.exists?(sale_id))
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
membership_id = customer_data.membership_id
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here
|
||||
if member_actions.gateway_url
|
||||
campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
# if membership_data["status"]==true
|
||||
begin
|
||||
response = HTTParty.get(url,
|
||||
:body => { app_token: token,membership_id:membership_id,
|
||||
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
|
||||
auth_token:auth_token
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
if( response["status"]==true )
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def print_setting_params
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
end
|
||||
end
|
||||
|
||||
61
app/controllers/reports/credit_payment_controller.rb
Normal file
61
app/controllers/reports/credit_payment_controller.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
class Reports::CreditPaymentController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
60
app/controllers/reports/void_sale_controller.rb
Normal file
60
app/controllers/reports/void_sale_controller.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
class Reports::VoidSaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
# @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@sale_data = Sale.get_void_sale(@shift,from,to)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
102
app/controllers/settings/dining_charges_controller.rb
Normal file
102
app/controllers/settings/dining_charges_controller.rb
Normal file
@@ -0,0 +1,102 @@
|
||||
class Settings::DiningChargesController < ApplicationController
|
||||
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_settings_facility
|
||||
before_action :set_settings_zone
|
||||
# GET /dining_charges
|
||||
# GET /dining_charges.json
|
||||
def index
|
||||
@dining_charges = DiningCharge.all
|
||||
end
|
||||
|
||||
# GET /dining_charges/1
|
||||
# GET /dining_charges/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /dining_charges/new
|
||||
def new
|
||||
@dining_charge = DiningCharge.new
|
||||
@dining_charge.minimum_free_time="00:30"
|
||||
@dining_charge.charge_block="02:00"
|
||||
@dining_charge.time_rounding_block="00:15"
|
||||
end
|
||||
|
||||
# GET /dining_charges/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /dining_charges
|
||||
# POST /dining_charges.json
|
||||
def create
|
||||
@dining_charge = DiningCharge.new(dining_charge_params)
|
||||
@dining_charge.dining_facility_id = @settings_dining_facility.id
|
||||
respond_to do |format|
|
||||
if @dining_charge.save
|
||||
if @table
|
||||
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
|
||||
end
|
||||
format.json { render :show, status: :created, location: @dining_charge }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /dining_charges/1
|
||||
# PATCH/PUT /dining_charges/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
@dining_charge.dining_facility_id = @settings_dining_facility.id
|
||||
if @dining_charge.update(dining_charge_params)
|
||||
if @table
|
||||
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
|
||||
else
|
||||
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
|
||||
end
|
||||
format.json { render :show, status: :ok, location: @dining_charge }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /dining_charges/1
|
||||
# DELETE /dining_charges/1.json
|
||||
def destroy
|
||||
@dining_charge.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_charge
|
||||
@dining_charge = DiningCharge.find(params[:id])
|
||||
end
|
||||
|
||||
def set_settings_facility
|
||||
if params[:table_id]
|
||||
@table = true
|
||||
@settings_dining_facility = Table.find(params[:table_id])
|
||||
elsif params[:room_id]
|
||||
@room = true
|
||||
@settings_dining_facility = Room.find(params[:room_id])
|
||||
end
|
||||
end
|
||||
|
||||
def set_settings_zone
|
||||
@zone = Zone.find(params[:zone_id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_charge_params
|
||||
# params.fetch(:dining_charge, {})
|
||||
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
|
||||
end
|
||||
end
|
||||
74
app/controllers/settings/item_sets_controller.rb
Normal file
74
app/controllers/settings/item_sets_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::ItemSetsController < ApplicationController
|
||||
before_action :set_settings_item_set, only: [:show, :edit, :update, :destroy]
|
||||
load_and_authorize_resource except: [:create]
|
||||
# GET /settings/item_sets
|
||||
# GET /settings/item_sets.json
|
||||
def index
|
||||
@settings_item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/1
|
||||
# GET /settings/item_sets/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/new
|
||||
def new
|
||||
@settings_item_set = ItemSet.new
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/item_sets
|
||||
# POST /settings/item_sets.json
|
||||
def create
|
||||
@settings_item_set = ItemSet.new(settings_item_set_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_item_set.save
|
||||
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_item_set }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/item_sets/1
|
||||
# PATCH/PUT /settings/item_sets/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_item_set.update(settings_item_set_params)
|
||||
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_item_set }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/item_sets/1
|
||||
# DELETE /settings/item_sets/1.json
|
||||
def destroy
|
||||
@settings_item_set.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_item_sets_url, notice: 'Item set was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_item_set
|
||||
@settings_item_set = ItemSet.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_item_set_params
|
||||
params.require(:item_set).permit(:name, :min_selectable_qty, :max_selectable_qty)
|
||||
end
|
||||
end
|
||||
@@ -28,11 +28,11 @@ class Settings::LookupsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_lookup.save
|
||||
format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully created.' }
|
||||
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_lookup }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
|
||||
format.json { render json: settings_lookups_path.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,11 +42,11 @@ class Settings::LookupsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_lookup.update(settings_lookup_params)
|
||||
format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully updated.' }
|
||||
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_lookup }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
|
||||
format.json { render json: settings_lookups_path.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,7 +56,7 @@ class Settings::LookupsController < ApplicationController
|
||||
def destroy
|
||||
@settings_lookup.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_lookups_url, notice: 'Lookup was successfully destroyed.' }
|
||||
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
74
app/controllers/settings/menu_item_sets_controller.rb
Normal file
74
app/controllers/settings/menu_item_sets_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::MenuItemSetsController < ApplicationController
|
||||
before_action :set_settings_menu_item_set, only: [:show, :edit, :update, :destroy]
|
||||
load_and_authorize_resource except: [:create]
|
||||
# GET /settings/menu_item_sets
|
||||
# GET /settings/menu_item_sets.json
|
||||
def index
|
||||
@settings_menu_item_sets = MenuItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/1
|
||||
# GET /settings/menu_item_sets/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/new
|
||||
def new
|
||||
@settings_menu_item_set = MenuItemSet.new
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/menu_item_sets
|
||||
# POST /settings/menu_item_sets.json
|
||||
def create
|
||||
@settings_menu_item_set = MenuItemSet.new(settings_menu_item_set_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_set.save
|
||||
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item_set }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/menu_item_sets/1
|
||||
# PATCH/PUT /settings/menu_item_sets/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_set.update(settings_menu_item_set_params)
|
||||
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item_set }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/menu_item_sets/1
|
||||
# DELETE /settings/menu_item_sets/1.json
|
||||
def destroy
|
||||
@settings_menu_item_set.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_item_sets_url, notice: 'Menu item set was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_menu_item_set
|
||||
@settings_menu_item_set = MenuItemSet.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_set_params
|
||||
params.require(:menu_item_set).permit(:item_set_id, :menu_item_id)
|
||||
end
|
||||
end
|
||||
@@ -11,9 +11,7 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
# GET /settings/menu_items/1.json
|
||||
def show
|
||||
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
|
||||
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/new
|
||||
@@ -62,6 +60,8 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
# DELETE /settings/menu_items/1
|
||||
# DELETE /settings/menu_items/1.json
|
||||
def destroy
|
||||
path_to_file = @settings_menu_item.image_path.to_s
|
||||
File.delete(path_to_file) if File.exist?(path_to_file)
|
||||
abc = MenuItem.deleteRecursive(@settings_menu_item)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' }
|
||||
@@ -81,6 +81,6 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
|
||||
# GET /settings/menu_items/new
|
||||
def new
|
||||
@settings_menu_item = MenuItem.new
|
||||
@settings_menu_item = MenuItem.new
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/1/edit
|
||||
@@ -27,10 +27,12 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# POST /settings/menu_items.json
|
||||
def create
|
||||
@settings_menu_item = MenuItem.new(settings_menu_item_params)
|
||||
|
||||
if params[:simple_menu_item][:menu_item_id] == ''
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
end
|
||||
@settings_menu_item.created_by = current_login_employee.name
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
|
||||
@@ -59,6 +61,8 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# DELETE /settings/menu_items/1
|
||||
# DELETE /settings/menu_items/1.json
|
||||
def destroy
|
||||
path_to_file = @settings_menu_item.image_path.to_s
|
||||
File.delete(path_to_file) if File.exist?(path_to_file)
|
||||
abc = MenuItem.deleteRecursive(@settings_menu_item)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' }
|
||||
@@ -78,6 +82,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,25 @@ class Transactions::CreditNotesController < ApplicationController
|
||||
# GET /transactions/sales.json
|
||||
def index
|
||||
|
||||
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
||||
|
||||
|
||||
@customers = Customer.all
|
||||
|
||||
filter = params[:filter]
|
||||
customer = params[:customer]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
||||
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
||||
puts "cccccccccccc"
|
||||
else
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to)
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -3,6 +3,7 @@ class Transactions::ManualSalesController < ApplicationController
|
||||
def void
|
||||
@sale = params[:sale_id]
|
||||
@reason = Lookup.where("lookup_type = 'void_reason'")
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @sales }
|
||||
|
||||
@@ -2,23 +2,30 @@ class Transactions::OrdersController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
if filter.nil?
|
||||
filter = params[:filter]
|
||||
count = params[:count]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil? && count.nil?
|
||||
orders = Order.order("order_id desc")
|
||||
puts "ssssss"
|
||||
else
|
||||
order = Order.search(filter)
|
||||
if order.count > 0
|
||||
orders = order
|
||||
else
|
||||
orders = Order.order("order_id desc")
|
||||
|
||||
end
|
||||
orders = Order.search(filter,from,to,count)
|
||||
puts "aaaaa"
|
||||
|
||||
end
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
end
|
||||
|
||||
if !orders.nil?
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
||||
else
|
||||
@orders = []
|
||||
end
|
||||
puts @orders.to_json
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -6,28 +6,41 @@ class Transactions::SalesController < ApplicationController
|
||||
# GET /transactions/sales.json
|
||||
def index
|
||||
|
||||
search_date = params[:date]
|
||||
receipt_no = params[:receipt_no]
|
||||
today = Date.today
|
||||
|
||||
if receipt_no.nil? && search_date.nil?
|
||||
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
receipt_no = params[:receipt_no]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if receipt_no.nil? && from.nil? && to.nil?
|
||||
@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?
|
||||
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?
|
||||
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
|
||||
sale = Sale.search(receipt_no,from,to)
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
end
|
||||
|
||||
# if receipt_no.nil? && search_date.nil?
|
||||
# @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?
|
||||
# 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?
|
||||
# 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
|
||||
# if sale.count > 0
|
||||
# @sales = sale
|
||||
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
# else
|
||||
# @sales = 0
|
||||
# end
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
Reference in New Issue
Block a user