item void
This commit is contained in:
@@ -51,6 +51,8 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def apply_void
|
def apply_void
|
||||||
|
sale_id = params[:sale_id]
|
||||||
|
saleObj = Sale.find(sale_id)
|
||||||
|
saleObj.compute_without_void
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ class Sale < ApplicationRecord
|
|||||||
"daily" => 0,
|
"daily" => 0,
|
||||||
"monthly" => 1,
|
"monthly" => 1,
|
||||||
"yearly" => 2
|
"yearly" => 2
|
||||||
}
|
}
|
||||||
|
|
||||||
SALE_STATUS_COMPLETED = "completed"
|
SALE_STATUS_COMPLETED = "completed"
|
||||||
|
|
||||||
def generate_invoice_from_booking(booking_id, requested_by)
|
def generate_invoice_from_booking(booking_id, requested_by)
|
||||||
booking = Booking.find(booking_id)
|
booking = Booking.find(booking_id)
|
||||||
@@ -199,6 +199,31 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
end
|
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
|
# Tax Calculate
|
||||||
def apply_tax(total_taxable)
|
def apply_tax(total_taxable)
|
||||||
#if tax is not apply create new record
|
#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.name as menu_category_name,
|
||||||
mc.id as menu_category_id ")
|
mc.id as menu_category_id ")
|
||||||
.group('mi.id')
|
.group('mi.id')
|
||||||
.order("mi.menu_category_id")
|
.order("mi.menu_category_id")
|
||||||
|
|
||||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_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_items mi ON i.product_code = mi.item_code" +
|
||||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
||||||
JOIN employees ea ON ea.id = sales.cashier_id")
|
JOIN employees ea ON ea.id = sales.cashier_id")
|
||||||
|
|
||||||
|
|
||||||
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case report_type.to_i
|
case report_type.to_i
|
||||||
when REPORT_TYPE["daily"]
|
when REPORT_TYPE["daily"]
|
||||||
return query
|
return query
|
||||||
when REPORT_TYPE["monthly"]
|
when REPORT_TYPE["monthly"]
|
||||||
|
|
||||||
return query.group("MONTH(date)")
|
return query.group("MONTH(date)")
|
||||||
when REPORT_TYPE["yearly"]
|
when REPORT_TYPE["yearly"]
|
||||||
return query.group("YEAR(date)")
|
return query.group("YEAR(date)")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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