fix get_order_items_details method in order_item and add taxes in receipt

This commit is contained in:
Yan
2017-06-15 17:57:58 +06:30
parent e085adab74
commit 03feae5b0f
6 changed files with 48 additions and 22 deletions

View File

@@ -35,23 +35,29 @@ class OrderItem < ApplicationRecord
#logger.debug orderitem.to_yml
orderitem.save!
end
#Origami : Cashier : to show order items details
#Origami : Cashier : to show order items details
def self.get_order_items_details(booking_id)
booking_orders = BookingOrder.where("booking_id=?",booking_id)
if booking_orders
booking_orders.each do |book_order|
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
# booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
# if booking_orders
# booking_orders.each do |book_order|
# order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
# .joins("left join orders on orders.order_id = order_items.order_id")
# .where("order_items.order_id=?",book_order.order)
# return order_details
# end
# else
# return false
# end
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
.joins("left join orders on orders.order_id = order_items.order_id")
.where("order_items.order_id=?",book_order.order)
return order_details
end
else
return false
end
.joins("left join booking_orders on booking_orders.order_id = order_items.order_id")
.joins("left join bookings on bookings.booking_id = booking_orders.booking_id")
.where("bookings.booking_id=?",booking_id)
return order_details
end
private

View File

@@ -186,6 +186,7 @@ class Sale < ApplicationRecord
end
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record