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

@@ -157,6 +157,7 @@ $(document).ready(function(){
if(sale_item_id != null){ if(sale_item_id != null){
ajax_url = "/origami/" + sale_item_id + "/discount"; ajax_url = "/origami/" + sale_item_id + "/discount";
sub_total = $("#"+sale_item_id).children().find("#item-total-price").text();
} }
// For Percentage Discount // For Percentage Discount

View File

@@ -16,6 +16,7 @@ class Origami::DiscountsController < BaseOrigamiController
discount_value = params[:discount_value] discount_value = params[:discount_value]
discount_amount = params[:discount_amount] discount_amount = params[:discount_amount]
grand_total = params[:grand_total] grand_total = params[:grand_total]
product_name = "Overall Discount"
if discount_type == 0 if discount_type == 0
remark="Discount " + discount_amount + " as net" remark="Discount " + discount_amount + " as net"
@@ -32,13 +33,14 @@ class Origami::DiscountsController < BaseOrigamiController
#save sale item for discount #save sale item for discount
if sale_item_id != nil if sale_item_id != nil
origin_sale_item = SaleItem.find(sale_item_id) origin_sale_item = SaleItem.find(sale_item_id)
product_name = origin_sale_item.product_name + "-Disocunt"
end end
sale_item = SaleItem.new sale_item = SaleItem.new
#pull #pull
sale_item.sale_id = sale_id sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : 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.remark = remark
sale_item.qty = 1 sale_item.qty = 1

View File

@@ -35,24 +35,30 @@ class OrderItem < ApplicationRecord
#logger.debug orderitem.to_yml #logger.debug orderitem.to_yml
orderitem.save! orderitem.save!
end end
#Origami : Cashier : to show order items details
#Origami : Cashier : to show order items details
def self.get_order_items_details(booking_id) def self.get_order_items_details(booking_id)
booking_orders = BookingOrder.where("booking_id=?",booking_id) # booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
if booking_orders # if booking_orders
booking_orders.each do |book_order| # 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") 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") .joins("left join orders on orders.order_id = order_items.order_id")
.where("order_items.order_id=?",book_order.order) .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 return order_details
end end
else
return false
end
end
private private
def generate_custom_id def generate_custom_id

View File

@@ -186,6 +186,7 @@ class Sale < ApplicationRecord
end end
# 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

View File

@@ -165,15 +165,31 @@ class ReceiptBillPdf < Prawn::Document
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
end end
if sale_data.sale_taxes.length > 1
sale_data.sale_taxes.each do |st|
move_down 5 move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do 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 text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do 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 text "( " +"#{ st.tax_payable_amount }" +" )" , :size => self.item_font_size,:align => :right
end end
end
else
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 move_down 5
y_position = cursor y_position = cursor

BIN
dump.rdb

Binary file not shown.