fix get_order_items_details method in order_item and add taxes in receipt
This commit is contained in:
@@ -157,10 +157,11 @@ $(document).ready(function(){
|
||||
|
||||
if(sale_item_id != null){
|
||||
ajax_url = "/origami/" + sale_item_id + "/discount";
|
||||
sub_total = $("#"+sale_item_id).children().find("#item-total-price").text();
|
||||
}
|
||||
|
||||
// For Percentage Discount
|
||||
if(discount_type == 1){
|
||||
if(discount_type == 1){
|
||||
discount_amount=(sub_total*discount_value)/100;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
discount_value = params[:discount_value]
|
||||
discount_amount = params[:discount_amount]
|
||||
grand_total = params[:grand_total]
|
||||
product_name = "Overall Discount"
|
||||
|
||||
if discount_type == 0
|
||||
remark="Discount " + discount_amount + " as net"
|
||||
@@ -32,13 +33,14 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#save sale item for discount
|
||||
if sale_item_id != nil
|
||||
origin_sale_item = SaleItem.find(sale_item_id)
|
||||
product_name = origin_sale_item.product_name + "-Disocunt"
|
||||
end
|
||||
sale_item = SaleItem.new
|
||||
|
||||
#pull
|
||||
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 = "Overall Discount"
|
||||
sale_item.product_name = product_name
|
||||
sale_item.remark = remark
|
||||
|
||||
sale_item.qty = 1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -186,6 +186,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable)
|
||||
|
||||
#if tax is not apply create new record
|
||||
|
||||
@@ -165,16 +165,32 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
if sale_data.sale_taxes.length > 1
|
||||
sale_data.sale_taxes.each do |st|
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( " +"#{ st.tax_payable_amount }" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
# move_down 5
|
||||
# y_position = cursor
|
||||
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
# text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
# end
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
|
||||
Reference in New Issue
Block a user