api discount and change tax
This commit is contained in:
@@ -200,6 +200,10 @@ $(document).ready(function() {
|
||||
// });
|
||||
// });
|
||||
|
||||
$("#refresh").on('click', function(){
|
||||
window.location.reload();
|
||||
})
|
||||
|
||||
// for Notificaiotn message
|
||||
var placementFrom = $("#notify_message").attr('data-placement-from');
|
||||
var placementAlign = $("#notify_message").attr('data-placement-align');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::BookingsController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
# skip_before_action :authenticate
|
||||
#Show customer by ID
|
||||
def index
|
||||
@bookings = Booking.all
|
||||
|
||||
16
app/controllers/api/change_tax_controller.rb
Normal file
16
app/controllers/api/change_tax_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Api::ChangeTaxController < Api::ApiController
|
||||
|
||||
def index
|
||||
sale_id = params[:sale_id]
|
||||
group_type = params[:group_type]
|
||||
tax_type = params[:tax_type].present? ? params[:tax_type] : "no_tax"
|
||||
|
||||
sale = Sale.find(sale_id)
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, group_type, tax_type)
|
||||
|
||||
remark = "Change tax to #{tax_type} for Sale ID #{sale_id} By #{current_login_employee.name}"
|
||||
SaleAudit.record_audit_change_tax(sale_id,remark,current_login_employee.name)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -23,9 +23,10 @@ class Api::CustomersController < Api::ApiController
|
||||
|
||||
def get_customer_by_account
|
||||
account_no = params[:account_no]
|
||||
group_type = params[:group_type] || 'food_court'
|
||||
|
||||
unless @customer = Customer.find_by(paypar_account_no: account_no)
|
||||
response = Customer.search_paypar_account_no(account_no)
|
||||
response = Customer.search_paypar_account_no(account_no)
|
||||
if response["status"] == true
|
||||
@customer = Customer.create({
|
||||
name: response["customer_data"]["name"],
|
||||
@@ -39,8 +40,10 @@ class Api::CustomersController < Api::ApiController
|
||||
membership_id: response["customer_data"]["id"],
|
||||
membership_type: response["customer_data"]["member_group_id"],
|
||||
customer_type: "Dinein",
|
||||
tax_profiles: ["1", "2"],
|
||||
tax_profiles: TaxProfile.where(group_type: group_type).pluck(:id),
|
||||
})
|
||||
else
|
||||
@message = response["message"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,138 @@
|
||||
class Api::DiscountsController < ActionController::API
|
||||
def create
|
||||
@invoice = Sale.find(params[:invoice_id])
|
||||
class Api::DiscountsController < Api::ApiController
|
||||
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
sale_item_id = params[:sale_item_id]
|
||||
discount = params[:discount].to_d
|
||||
discount_type = params[:discount_type]
|
||||
|
||||
@sale = Sale.find(sale_id)
|
||||
@booking = @sale.booking
|
||||
dining_facility = @booking.dining_facility
|
||||
action_by = current_login_employee.name
|
||||
|
||||
bill_discount = @sale.total_discount
|
||||
|
||||
if sale_item_id
|
||||
sale_item = SaleItem.find(sale_item_id)
|
||||
discount_item = sale_item.discount_item
|
||||
|
||||
if discount > 0
|
||||
unless discount_item
|
||||
discount_item = sale_item.build_discount_item
|
||||
end
|
||||
|
||||
discount_item.discount = discount
|
||||
if discount_type == 'nett'
|
||||
discount_item.discount_type = 'nett'
|
||||
discount_item.product_name = "#{sale_item.product_name} - discount"
|
||||
unit_price = discount
|
||||
elsif discount_type == 'percentage'
|
||||
discount_item.discount_type = 'percentage'
|
||||
discount_item.product_name = "#{sale_item.product_name} - discount(#{discount}%)"
|
||||
unit_price = sale_item.unit_price * (discount / 100)
|
||||
end
|
||||
|
||||
price = unit_price * sale_item.qty
|
||||
|
||||
discount_item.menu_category_code = sale_item.menu_category_code
|
||||
discount_item.menu_category_name = sale_item.menu_category_name
|
||||
|
||||
discount_item.sale_id = sale_id
|
||||
discount_item.product_code = sale_item != nil ? sale_item.product_code : sale_id
|
||||
discount_item.item_instance_code = sale_item.item_instance_code
|
||||
discount_item.product_alt_name = ""
|
||||
discount_item.status = "Discount"
|
||||
|
||||
discount_item.qty = sale_item.qty
|
||||
discount_item.unit_price = unit_price
|
||||
discount_item.taxable_price = -price
|
||||
discount_item.is_taxable = sale_item.is_taxable
|
||||
discount_item.account_id = sale_item.account_id
|
||||
|
||||
discount_item.price = -price
|
||||
discount_item.save
|
||||
|
||||
remark = "Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_item.price}] | Receipt No #{@sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(discount_item.sale_id, @sale.cashier_name, action_by, remark, "ITEMDISCOUNT" )
|
||||
else
|
||||
discount_item.destroy
|
||||
|
||||
if dining_facility.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_item.price}] | Receipt No #{@sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_item.price}] | Receipt No #{@sale.receipt_no} | Table- #{dining_facility.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(@sale.sale_id, @sale.cashier_name, action_by, remark, "REMOVEITEMDISCOUNT" )
|
||||
end
|
||||
else
|
||||
if discount > 0
|
||||
if discount_type == 'nett'
|
||||
bill_discount = discount
|
||||
elsif discount_type == 'percentage'
|
||||
bill_discount = @sale.total_amount * (discount / 100)
|
||||
end
|
||||
|
||||
if dining_facility.nil?
|
||||
remark = "Discount Overall Price [#{bill_discount}]| Receipt No #{@sale.receipt_no} | Table- no Table "
|
||||
else
|
||||
remark = "Discount Overall Price [#{bill_discount}]| Receipt No #{@sale.receipt_no} | Table- #{dining_facility.name} "
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(@sale.sale_id, @sale.cashier_name, action_by, remark, "OVERALLDISCOUNT" )
|
||||
else
|
||||
if dining_facility.nil?
|
||||
remark = "Remove Discount Sale Id [#{@sale.sale_id}]| Receipt No #{@sale.receipt_no} | Table- No Table"
|
||||
else
|
||||
remark = "Remove Discount Sale Id [#{@sale.sale_id}]| Receipt No #{@sale.receipt_no} | Table- #{dining_facility.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(@sale.sale_id, @sale.cashier_name, action_by, remark, "REMOVEALLDISCOUNT" )
|
||||
|
||||
bill_discount = 0.0.to_d
|
||||
end
|
||||
end
|
||||
|
||||
@sale.compute_by_sale_items(bill_discount, nil, order_source)
|
||||
end
|
||||
|
||||
#Update sale item - Price | Qty |
|
||||
def update
|
||||
end
|
||||
|
||||
#destroy - Remove items form invoice
|
||||
def destroy
|
||||
@sale.remove_item(params[:sale_item_id])
|
||||
sale_id = params[:sale_id]
|
||||
sale_item_id = params[:sale_item_id]
|
||||
|
||||
@sale = Sale.find(sale_id)
|
||||
@booking = @sale.booking
|
||||
dining_facility = @booking.dining_facility
|
||||
action_by = current_login_employee.name
|
||||
|
||||
bill_discount = @sale.total_discount
|
||||
|
||||
if sale_item_id
|
||||
sale_item = SaleItem.find(sale_item_id)
|
||||
discount_item = sale_item.discount_item
|
||||
discount_item.destroy
|
||||
|
||||
if dining_facility.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_item.price}] | Receipt No #{@sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_item.price}] | Receipt No #{@sale.receipt_no} | Table- #{dining_facility.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(@sale.sale_id, @sale.cashier_name, action_by, remark, "REMOVEITEMDISCOUNT" )
|
||||
else
|
||||
if dining_facility.nil?
|
||||
remark = "Remove Discount Sale Id [#{@sale.sale_id}]| Receipt No #{@sale.receipt_no} | Table- No Table"
|
||||
else
|
||||
remark = "Remove Discount Sale Id [#{@sale.sale_id}]| Receipt No #{@sale.receipt_no} | Table- #{dining_facility.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(@sale.sale_id, @sale.cashier_name, action_by, remark, "REMOVEALLDISCOUNT" )
|
||||
|
||||
bill_discount = 0.0.to_d
|
||||
end
|
||||
@sale.compute_by_sale_items(bill_discount, nil, order_source)
|
||||
end
|
||||
|
||||
private
|
||||
def set_invoice_params
|
||||
@sale = Sale.find(params[:invoice_id])
|
||||
def order_source
|
||||
params[:order_source] || 'food_court'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,13 +3,13 @@ class Api::Foodcourt::BillsController < Api::ApiController
|
||||
def create
|
||||
Sale.transaction do
|
||||
if shift = ShiftSale.current_open_shift(current_login_employee)
|
||||
if booking = Booking.find(params[:booking_id])
|
||||
if @booking = Booking.find(params[:booking_id])
|
||||
cashier = Employee.find(shift.employee_id)
|
||||
order = booking.orders.first
|
||||
order = @booking.orders.first
|
||||
|
||||
if @sale_data = booking.sale
|
||||
if @sale_data = @booking.sale
|
||||
@status = true
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
|
||||
@@ -42,38 +42,56 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
table = nil
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
# 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
|
||||
if discount_items.length > 0
|
||||
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
discount = di['discount'].to_d
|
||||
discount_type = di['discount_type']
|
||||
|
||||
sale_item = SaleItem.new
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
discount_item = SaleItem.find_or_initialize_by(parent_id: di['id'])
|
||||
|
||||
sale_item.menu_category_code = origin_sale_item.menu_category_code
|
||||
sale_item.menu_category_name = origin_sale_item.menu_category_name
|
||||
discount_item.discount = discount
|
||||
if discount_type == 'nett'
|
||||
discount_item.discount_type = 'nett'
|
||||
discount_item.product_name = "#{sale_item.product_name} - discount"
|
||||
unit_price = discount
|
||||
elsif discount_type == 'percentage'
|
||||
discount_item.discount_type = 'percentage'
|
||||
discount_item.product_name = "#{sale_item.product_name} - discount(#{discount}%)"
|
||||
unit_price = sale_item.unit_price * (discount / 100)
|
||||
end
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.status = "Discount"
|
||||
price = unit_price * sale_item.qty
|
||||
|
||||
sale_item.qty = -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
|
||||
discount_item.menu_category_code = sale_item.menu_category_code
|
||||
discount_item.menu_category_name = sale_item.menu_category_name
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
discount_item.sale_id = sale_id
|
||||
discount_item.product_code = sale_item != nil ? sale_item.product_code : sale_id
|
||||
discount_item.item_instance_code = sale_item.item_instance_code
|
||||
discount_item.product_alt_name = ""
|
||||
discount_item.status = "Discount"
|
||||
|
||||
discount_item.qty = sale_item.qty
|
||||
discount_item.unit_price = unit_price
|
||||
discount_item.taxable_price = -price
|
||||
discount_item.is_taxable = sale_item.is_taxable
|
||||
discount_item.account_id = sale_item.account_id
|
||||
|
||||
discount_item.price = -price
|
||||
discount_item.save
|
||||
|
||||
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" )
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(discount_item.sale_id, sale.cashier_name, action_by, remark, "ITEMDISCOUNT" )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,7 +120,6 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
@@ -121,24 +138,31 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
|
||||
discount_item = sale_item.discount_item
|
||||
|
||||
next if discount_item.nil?
|
||||
|
||||
sale.total_amount = (sale.total_amount + discount_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 "
|
||||
remark = "Remove Item Discount Item Name ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_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 ->#{discount_item.product_name}-Product Code ->#{discount_item.product_code} | Price [#{discount_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
|
||||
discount_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.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
|
||||
@@ -75,10 +75,10 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
@current_shift = current_user.current_shift || ShiftSale.current_shift
|
||||
status = ['completed', 'void']
|
||||
sale_status = ['completed', 'void']
|
||||
|
||||
@pending_sales = Sale.where('shift_sale_id = ? AND sale_status NOT IN (?)', @current_shift.id, status)
|
||||
@pending_completed = Sale.where('shift_sale_id = ? AND sale_status IN (?)', @current_shift.id, status)
|
||||
@pending_sales = Sale.where('shift_sale_id = ? AND sale_status NOT IN (?)', @current_shift.id, sale_status)
|
||||
@pending_completed = Sale.where('shift_sale_id = ? AND sale_status IN (?)', @current_shift.id, sale_status)
|
||||
@pending_orders = Sale.pending_order('food_court')
|
||||
|
||||
@completed, @bookings = Sale.get_foodcourt_current_shift_orders
|
||||
|
||||
@@ -25,19 +25,24 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
saleitemObj.status = 'void'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
|
||||
@newsaleitem = saleitemObj.dup
|
||||
# @newsaleitem.save
|
||||
@newsaleitem.parent_id = saleitemObj.sale_item_id
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.is_taxable = saleitemObj.is_taxable
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
if saleitemObj.discount_item
|
||||
saleitemObj.discount_item.destroy
|
||||
end
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
@@ -47,7 +52,6 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
def item_foc
|
||||
@@ -61,19 +65,27 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
saleitemObj.save
|
||||
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.parent_id = saleitemObj.sale_item_id
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.unit_price = saleitemObj.unit_price * 1
|
||||
@newsaleitem.is_taxable = saleitemObj.is_taxable
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
if saleitemObj.discount_item
|
||||
saleitemObj.discount_item.destroy
|
||||
end
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
oqs_item = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: oqs_item
|
||||
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
@@ -83,7 +95,6 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
def item_edit
|
||||
@@ -110,47 +121,47 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
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'
|
||||
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
|
||||
end
|
||||
|
||||
saleitemObj.save
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
sale.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
end
|
||||
|
||||
# make cancel void item
|
||||
def item_void_cancel
|
||||
saleitemId = params[:sale_item_id]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
Sale.transaction do
|
||||
saleitemId = params[:sale_item_id]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
|
||||
saleObj = saleitemObj.sale
|
||||
saleObj = saleitemObj.sale
|
||||
|
||||
saleObj.sale_items.where(product_code: saleitemObj.product_code)
|
||||
.where(qty: saleitemObj.qty.abs)
|
||||
.where(unit_price: saleitemObj.unit_price)
|
||||
.where(status: saleitemObj.status).first.update(status: nil, remark: nil)
|
||||
|
||||
saleitemObj.destroy
|
||||
# re-calc tax
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
if saleitemObj.status == 'void'
|
||||
saleitemObj.void_item.destroy
|
||||
else saleitemObj.status == 'foc'
|
||||
saleitemObj.foc_item.destroy
|
||||
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.total_discount, nil, order_source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
saleitemObj.update(status: nil, remark: nil)
|
||||
# re-calc tax
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
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 = "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.total_discount, nil, order_source)
|
||||
end
|
||||
end
|
||||
|
||||
# remove all void items
|
||||
@@ -158,14 +169,13 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
saleObj.sale_items.where(status: ['foc', 'void']).each do |item|
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.status = nil
|
||||
end
|
||||
item.save
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
saleObj.sale_items.reset
|
||||
# re-calc tax
|
||||
@@ -176,10 +186,7 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void(order_source)
|
||||
saleObj.sale_items.each do |item|
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -102,7 +102,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
|
||||
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
|
||||
|
||||
@@ -440,8 +440,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||
|
||||
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type = nil)
|
||||
shop = Shop.current_shop
|
||||
|
||||
#if tax is not apply create new record
|
||||
@@ -459,50 +458,31 @@ class Sale < ApplicationRecord
|
||||
|
||||
if order_source.to_s == "emenu"
|
||||
order_source = "cashier"
|
||||
elsif order_source.to_s == "app"
|
||||
order_source = "online_order"
|
||||
end
|
||||
|
||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||
if tax_type.nil?
|
||||
#in previous >> if tax_profiles.count ==2
|
||||
if tax_profiles.count >= 2
|
||||
tax_type = "all"
|
||||
elsif tax_profiles.count == 1
|
||||
if tax_profiles.name.downcase == "service charges"
|
||||
tax_type = "Service Charges"
|
||||
else
|
||||
tax_type = "Commercial Tax"
|
||||
end
|
||||
elsif tax_profiles.count < 1
|
||||
tax_type = "no_tax"
|
||||
end
|
||||
end
|
||||
|
||||
# #Creat new tax records
|
||||
if self.payment_status != 'foc' && tax_type.to_s == "all"
|
||||
if self.payment_status != 'foc'
|
||||
tax_profiles.each do |tax|
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
next if self.customer_id_before_last_save.nil? && !self.customer_id_changed? && tax_type.blank? && !taxes.map(&:tax_name).include?(tax.name)
|
||||
next unless tax_type == 'all' || tax_type.blank? || tax_type.include?(tax.name)
|
||||
sale_tax = self.sale_taxes.build
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
|
||||
#include or execulive
|
||||
if tax.tax_type.to_s =="Net"
|
||||
sale_tax.tax_payable_amount = tax.rate
|
||||
if tax.inclusive
|
||||
tax_incl_exec = "inclusive"
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
if tax.inclusive
|
||||
tax_incl_exec = "inclusive"
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
end
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
end
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
|
||||
if !tax.inclusive
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
@@ -513,67 +493,6 @@ class Sale < ApplicationRecord
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
end
|
||||
end
|
||||
elsif tax_type.to_s == "no_tax"
|
||||
tax_profiles.each do |tax|
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = 0
|
||||
sale_tax.tax_payable_amount = 0
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
elsif tax_type.to_s == "Commercial Tax"
|
||||
tax_profiles.each do |tax|
|
||||
if tax.name == tax_type.to_s
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
tax_incl_exec = "inclusive"
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
#new taxable amount is standard rule for step by step
|
||||
if shop.calc_tax_order
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
end
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
elsif tax_type.to_s == "Service Charges"
|
||||
tax_profiles.each do |tax|
|
||||
if tax.name == tax_type.to_s
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
tax_incl_exec = "inclusive"
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
#new taxable amount is standard rule for step by step
|
||||
if shop.calc_tax_order
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
end
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
end
|
||||
self.tax_type = tax_incl_exec
|
||||
self.total_tax = total_tax_amount
|
||||
|
||||
@@ -16,6 +16,12 @@ class SaleItem < ApplicationRecord
|
||||
after_update :update_stock_journal
|
||||
after_save :update_stock_journal_set_item
|
||||
|
||||
has_one :discount_item, -> { where(status: 'Discount') }, class_name: 'SaleItem', foreign_key: 'parent_id'
|
||||
has_one :foc_item, -> { where(status: 'foc') }, class_name: 'SaleItem', foreign_key: 'parent_id'
|
||||
has_one :void_item, -> { where(status: 'void') }, class_name: 'SaleItem', foreign_key: 'parent_id'
|
||||
|
||||
enum discount_type: { nett: 'nett', percentage: 'percentage' }
|
||||
|
||||
# Add Sale Items
|
||||
def self.add_sale_items(sale_items)
|
||||
sale_items.each do|saleitemObj|
|
||||
|
||||
1
app/views/api/change_tax/index.json.jbuilder
Normal file
1
app/views/api/change_tax/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
@@ -2,6 +2,7 @@ if @customer.present?
|
||||
json.status true
|
||||
else
|
||||
json.status false
|
||||
json.message @message
|
||||
end
|
||||
|
||||
json.data @customer
|
||||
|
||||
1
app/views/api/discounts/create.json.jbuilder
Normal file
1
app/views/api/discounts/create.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
@@ -1,6 +1,7 @@
|
||||
if @status == true
|
||||
#show invoice number and stuff
|
||||
json.status @status
|
||||
json.booking_id @booking.booking_id
|
||||
json.sale_id @sale_data.sale_id
|
||||
sale = Sale.find(@sale_data.sale_id)
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
if sale_item
|
||||
json.sale_item_id sale_item.sale_item_id
|
||||
json.product_name sale_item.product_name
|
||||
json.product_alt_name sale_item.product_alt_name
|
||||
json.qty sale_item.qty
|
||||
json.unit_price sale_item.unit_price
|
||||
json.price sale_item.price
|
||||
json.taxable_price sale_item.taxable_price
|
||||
json.status sale_item.status
|
||||
if discount_item = sale_item.discount_item
|
||||
json.discount discount_item.discount
|
||||
json.discount_type discount_item.discount_type
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ if sale
|
||||
|
||||
json.shift_sale_id sale.shift_sale_id
|
||||
|
||||
json.sale_items sale.sale_items, partial: "api/sale_items/sale_item", as: :sale_item
|
||||
json.sale_items sale.sale_items.includes(:discount_item).where(status: nil), partial: "api/sale_items/sale_item", as: :sale_item
|
||||
|
||||
json.sale_taxes sale.sale_taxes, partial: "api/sale_taxes/sale_tax", as: :sale_tax
|
||||
end
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
json.status true
|
||||
json.data do
|
||||
json.tax_profiles @tax_profiles, :name, :group_type, :rate, :inclusive, :order_by
|
||||
end
|
||||
json.data @tax_profiles, :name, :group_type, :rate, :inclusive, :order_by
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -398,28 +398,34 @@
|
||||
<i class="material-icons">reply</i>
|
||||
<%= t("views.btn.back") %>
|
||||
</button>
|
||||
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
|
||||
|
||||
<% if @booking && @booking.booking_status == 'assign' %>
|
||||
<button type="button" class="btn btn-primary btn-block waves-effect create" id="done_order">
|
||||
DONE
|
||||
</button>
|
||||
<% end %>
|
||||
<% if @booking && @booking.booking_status != 'void' %>
|
||||
<hr>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void </a>
|
||||
<% end %>
|
||||
|
||||
<!-- pending order button list -->
|
||||
<% if @pending && params[:active].nil? %>
|
||||
|
||||
<% if current_user.role != "waiter" || @status != "sale"%>
|
||||
<% if current_user.role != "waiter" && @status == "order"%>
|
||||
<hr>
|
||||
<button type="button" id="addorder" class="btn bg-blue btn-block">Update Order</button>
|
||||
<%end%>
|
||||
|
||||
<% if current_user.role != "waiter" && @status != "order"%>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#read_modal">Pay</button>
|
||||
<% if current_user.role != "waiter" && @status == "sale"%>
|
||||
<hr>
|
||||
<button type="button" id="void" class="btn btn-block bg-red waves-effect" >VOID</button>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#read_modal">Pay</button>
|
||||
<%end%>
|
||||
|
||||
<% if @status != "sale"%>
|
||||
<hr>
|
||||
<!-- <button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button> -->
|
||||
<% order_id = @pending.try(:orders).try(:first).try(:order_id) if @status == 'order' %>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect req_bill" data-toggle="modal" data-target="#read_modal" >Req.Bill</button>
|
||||
@@ -430,6 +436,7 @@
|
||||
<% elsif @pending && params[:active] == 'completed' %>
|
||||
<% if current_user.role != "waiter" %>
|
||||
<% if @pending.sale_status != 'void' && @pending.sale_status != 'waste' && @pending.sale_status != 'spoile' %>
|
||||
<hr>
|
||||
<% if current_user.role == "cashier" %>
|
||||
<% if @pending.payment_status != 'foc' %>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
@@ -439,7 +446,7 @@
|
||||
<% if @pending.payment_status != 'foc' %>
|
||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" readonly= "<%= (can? :overall_void, :void)? 'true': 'false' %>" > Void </button>
|
||||
<% end %>
|
||||
<button type="button" id="reprint" class="btn bg-blue btn-block">Re.Print</button>
|
||||
<button type="button" id="reprint" class="btn bg-blue btn-block">Re.Print</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -198,11 +198,13 @@
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<%if !@table.nil?%>
|
||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'"><i class="material-icons">reply</i> Back </button>
|
||||
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'" id="back"><i class="material-icons">reply</i> Back</button>
|
||||
<%else%>
|
||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'"><i class="material-icons">reply</i> Back </button>
|
||||
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'" id="back"><i class="material-icons">reply</i> Back</button>
|
||||
<%end%>
|
||||
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
|
||||
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
|
||||
<hr>
|
||||
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -210,17 +210,12 @@
|
||||
Refresh
|
||||
</button>
|
||||
<% if @sale_payment.nil? %>
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<% else %>
|
||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||
<%end %>
|
||||
<% end %>
|
||||
<% if @sale_payment.nil? %>
|
||||
<hr>
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
|
||||
<% else %>
|
||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
|
||||
<% end %>
|
||||
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
|
||||
@@ -460,14 +455,7 @@ $(document).ready(function(){
|
||||
|
||||
});
|
||||
|
||||
$("#refresh").on('click', function(){
|
||||
window.location.reload();
|
||||
})
|
||||
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
|
||||
|
||||
}
|
||||
else {
|
||||
if(localStorage.getItem("cash") != null && localStorage.getItem("cash") != 'null'){
|
||||
$('#cash').text(localStorage.getItem("cash"));
|
||||
}
|
||||
update_balance();
|
||||
|
||||
@@ -40,71 +40,64 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
count = 0
|
||||
sub_total = 0
|
||||
@saleobj.sale_items.each do |sale_item|
|
||||
count += 1
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<% sub_total = BigDecimal("0.0") %>
|
||||
<% count = 0 %>
|
||||
<% @saleobj.sale_items.each do |sale_item| %>
|
||||
<% sub_total = sub_total + sale_item.price %>
|
||||
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
|
||||
<%
|
||||
# Can't check for discount
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr>
|
||||
<td class="p-1" width="2%"><%= count %></td>
|
||||
<td class="p-2" width="20%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
|
||||
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
|
||||
</td>
|
||||
<td class="p-1" width="10%">
|
||||
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
|
||||
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
|
||||
</td> -->
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
||||
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
|
||||
<% if sale_item.price > 0 %>
|
||||
<% count += 1 %>
|
||||
<tr class="item-row">
|
||||
<td class="p-1" width="2%"><%= count %></td>
|
||||
<td class="p-2" width="20%">
|
||||
<% if sale_item.foc_item %>
|
||||
<span><%= sale_item.foc_item.product_name %></span>
|
||||
<% elsif sale_item.void_item %>
|
||||
<span><%= sale_item.void_item.product_name %></span>
|
||||
<% else %>
|
||||
<span><%= sale_item.product_name %></span>
|
||||
<% end %>
|
||||
<% if sale_item.discount_item %>
|
||||
<% if sale_item.discount_item.nett? %>
|
||||
<div id="item-discount" class="text-secondary">With a <strong><%= number_format(sale_item.discount_item.discount) %></strong> discount</div>
|
||||
<% elsif sale_item.discount_item.percentage? %>
|
||||
<div id="item-discount" class="text-secondary">With a <strong><%= number_format(sale_item.discount_item.discount, precision: 0) %>%</strong> discount</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
|
||||
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
|
||||
</td>
|
||||
<td class="p-1" width="10%">
|
||||
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
|
||||
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
|
||||
</td>
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg btn-primary waves-effect update'>Update</button>
|
||||
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg btn-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
|
||||
|
||||
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
|
||||
</td>
|
||||
|
||||
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class='' width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td> -->
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel
|
||||
Void/Update
|
||||
</button>
|
||||
</td>
|
||||
<% else %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class="p-1" width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg btn-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
|
||||
</td>
|
||||
<% elsif sale_item.status == 'foc' || sale_item.status == 'void' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class='' width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg btn-danger waves-effect cancel'>Cancel
|
||||
<%= sale_item.status %>
|
||||
</button>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -121,7 +114,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-lg-4 col-sm-4">
|
||||
|
||||
|
||||
<div class="p-l-20">
|
||||
<div class="row bottom">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 m-l--5">
|
||||
@@ -208,10 +201,11 @@
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
|
||||
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
|
||||
<button type="button" class="btn btn-block bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
|
||||
<hr>
|
||||
<button type="button" class="btn btn-block btn-danger waves-effect" id='cancel_all_void'>Cancel All</button>
|
||||
<button type="button" class="btn btn-block btn-primary waves-effect" id='apply'>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -475,8 +469,4 @@ var access_code = localStorage.getItem("access_code");
|
||||
$("#"+sale_item_id+"_qty").val('1');
|
||||
}
|
||||
}
|
||||
|
||||
$('#add_order').on('click', function () {
|
||||
window.location.href = '/foodcourt/food_court?sale_id=<%=@saleobj.sale_id %>';
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -56,10 +56,6 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get 'get_tax_profiles' => "shops#get_tax_profiles"
|
||||
post 'verifications/update' => "verifications#update"
|
||||
|
||||
scope '/(:group_type)', defaults: { group_type: nil } do
|
||||
resources :tax_profiles, only: [:index]
|
||||
end
|
||||
|
||||
namespace :restaurant do
|
||||
get 'zones' => "zones#index"
|
||||
resources :menu, only: [:index, :show]
|
||||
@@ -97,8 +93,6 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
end
|
||||
end
|
||||
|
||||
get "customers/get_by_account" => "customers#get_customer_by_account"
|
||||
|
||||
resources :customers
|
||||
|
||||
# get customer by phone
|
||||
@@ -109,6 +103,15 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
#get customer last five orders
|
||||
get "get_customer_last_orders" => "customers#get_customer_last_orders"
|
||||
|
||||
post ":sale_id/discount" => "discounts#create"
|
||||
delete ":sale_id/discount" => "discounts#destroy"
|
||||
|
||||
scope ":group_type" do
|
||||
resources :tax_profiles, only: [:index]
|
||||
post ":sale_id/change_tax" => "change_tax#index"
|
||||
get "customers/get_by_account" => "customers#get_customer_by_account"
|
||||
end
|
||||
|
||||
#Generating Invoice and making payments - output render @sale
|
||||
resources :invoices, only: [:index, :show, :create, :update, :destroy] do
|
||||
resources :sale_items, only: [:create, :update, :destroy]
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddReferenceToParentItemToSaleItems < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :sale_items, :parent_id, :string, limit: 16, default: nil, after: :sale_item_id
|
||||
add_index :sale_items, :parent_id
|
||||
end
|
||||
end
|
||||
6
db/migrate/20231005055250_add_discount_to_sale_items.rb
Normal file
6
db/migrate/20231005055250_add_discount_to_sale_items.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddDiscountToSaleItems < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :sale_items, :discount_type, :string, after: :price
|
||||
add_column :sale_items, :discount, :decimal, precision: 10, scale: 2, after: :price
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user