update sale audit
This commit is contained in:
@@ -104,6 +104,10 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
order = Order.find(sale_order.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
action_by = current_user.id
|
||||
remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" )
|
||||
|
||||
else
|
||||
@booking = BookingOrder.find_by_order_id(params[:sale_id])
|
||||
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
|
||||
|
||||
@@ -21,7 +21,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
table = DiningFacility.find(table_id)
|
||||
# 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;
|
||||
@@ -46,14 +46,24 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.id
|
||||
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_id, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
if overall_discount.to_f > 0
|
||||
action_by = current_user.id
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
|
||||
@@ -67,13 +77,18 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
table = DiningFacility.find(table_id)
|
||||
|
||||
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)
|
||||
|
||||
action_by = current_user.id
|
||||
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} "
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEITEMDISCOUNT" )
|
||||
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
@@ -82,9 +97,9 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
@@ -115,6 +130,10 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#destroy in sale.sale_items
|
||||
sale.sale_items.destroy(discount_items)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
|
||||
|
||||
@@ -16,7 +16,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
table = DiningFacility.find(table_id)
|
||||
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
@@ -41,6 +41,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ADDOTHERCHARGES" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,7 +53,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
end
|
||||
@@ -24,6 +24,11 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
|
||||
|
||||
saleObj.compute_without_void
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
@@ -44,6 +49,11 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_without_void
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
@@ -73,11 +83,16 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
update_qty = params[:update_qty]
|
||||
update_price = params[:update_price]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
sale = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
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
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Update Qty #{update_qty} Price [#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,sale.cashier_id, action_by,remark,"SALEITEMEDIT" )
|
||||
# saleitemObj.remark = 'edit'
|
||||
|
||||
unless saleitemObj.product_name.include? 'updated'
|
||||
@@ -108,6 +123,11 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
action_by = current_user.id
|
||||
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,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
saleObj.compute_without_void
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Origami::SalesController < ApplicationController#BaseOrigamiController
|
||||
class Origami::SalesController < BaseOrigamiController
|
||||
def show
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
|
||||
@@ -40,6 +40,12 @@ class Origami::VoidController < BaseOrigamiController
|
||||
table.save
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.id
|
||||
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
||||
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
|
||||
Reference in New Issue
Block a user