Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -51,6 +51,8 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def apply_void
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,9 +21,9 @@ class Sale < ApplicationRecord
|
||||
"daily" => 0,
|
||||
"monthly" => 1,
|
||||
"yearly" => 2
|
||||
}
|
||||
}
|
||||
|
||||
SALE_STATUS_COMPLETED = "completed"
|
||||
SALE_STATUS_COMPLETED = "completed"
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by)
|
||||
booking = Booking.find(booking_id)
|
||||
@@ -199,6 +199,31 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def compute_without_void
|
||||
sales_items = self.sale_items
|
||||
|
||||
#Computation Fields
|
||||
subtotal_price = 0
|
||||
total_taxable = 0
|
||||
rounding_adjustment = 0
|
||||
|
||||
sales_items.each do |item|
|
||||
if item.remark != 'void'
|
||||
#compute each item and added to total
|
||||
subtotal_price = subtotal_price + item.price
|
||||
total_taxable = total_taxable + item.taxable_price
|
||||
end
|
||||
end
|
||||
|
||||
apply_tax (total_taxable)
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||
#compute rounding adjustment
|
||||
adjust_rounding
|
||||
|
||||
self.save!
|
||||
end
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable)
|
||||
#if tax is not apply create new record
|
||||
@@ -354,28 +379,28 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
mc.name as menu_category_name,
|
||||
mc.id as menu_category_id ")
|
||||
.group('mi.id')
|
||||
.order("mi.menu_category_id")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
JOIN menu_items mi ON i.product_code = mi.item_code" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
||||
.order("mi.menu_category_id")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
JOIN menu_items mi ON i.product_code = mi.item_code" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
||||
JOIN employees ea ON ea.id = sales.cashier_id")
|
||||
|
||||
|
||||
|
||||
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
||||
|
||||
|
||||
|
||||
|
||||
case report_type.to_i
|
||||
when REPORT_TYPE["daily"]
|
||||
return query
|
||||
when REPORT_TYPE["monthly"]
|
||||
|
||||
return query.group("MONTH(date)")
|
||||
|
||||
return query.group("MONTH(date)")
|
||||
when REPORT_TYPE["yearly"]
|
||||
return query.group("YEAR(date)")
|
||||
return query.group("YEAR(date)")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
1
app/views/origami/sale_edit/apply_void.json.jbuilder
Normal file
1
app/views/origami/sale_edit/apply_void.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
Reference in New Issue
Block a user