diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index a01cc717..6b1fb225 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -12,14 +12,14 @@ class Api::BillController < Api::ApiController if booking if booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name) + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) else @status = true end end elsif (params[:order_id]) @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name) + @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) end end diff --git a/app/models/order.rb b/app/models/order.rb index 83eb9418..a53ba3cf 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,orders.status,sales.receipt_no,sales.sale_status,orders.order_id,sales.customer_id,sales.sale_id,dining_facilities.name") + .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id,orders.status,orders.order_id,bookings.booking_id,dining_facilities.name") + .group("sales.sale_id") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end @@ -262,7 +262,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,orders.order_id,sales.customer_id,sales.sale_status,orders.customer_id,sales.sale_id,dining_facilities.name") + .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index c766b8cc..71562277 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,16 +1,16 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil) - self.page_width = 250 - self.page_height = 1450 - self.margin = 10 - self.price_width = 40 + self.page_width = 210 + self.page_height = 2500 + self.margin = 5 + self.price_width = 35 self.qty_width = 20 - self.total_width = 40 - self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4)) + self.total_width = 35 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) self.item_height = 15 - self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=80 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 @@ -22,10 +22,10 @@ class ReceiptBillPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 11 - self.item_font_size = 9 + self.header_font_size = 10 + self.item_font_size = 8 - header( printer_settings.printer_name, printer_settings.name) + header( "Beauty In the Pot", printer_settings.name) stroke_horizontal_rule @@ -92,8 +92,8 @@ class ReceiptBillPdf < Prawn::Document # @item_width.to_i + @half_qty.to_i text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[(self.item_width+self.price_width),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } @@ -121,9 +121,9 @@ class ReceiptBillPdf < Prawn::Document pad_top(15) { text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{price.to_i}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{total_price.to_i}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 3 end @@ -132,10 +132,10 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([item_name_width,y_position], :width =>self.total_width) do + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ sub_total }" , :size => self.item_font_size,:align => :right end @@ -145,10 +145,10 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do + bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do text "Food/Beverage Total", :size => self.item_font_size,:align => :left end - bounding_box([item_name_width,y_position], :width =>self.total_width) do + bounding_box([self.item_description_width,y_position], :width => self.label_width) do text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right end end @@ -158,30 +158,30 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Discount", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right end move_down 5 y_position = cursor - bounding_box([0,y_position], :width =>(item_name_width+self.price_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 end - bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_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 end move_down 5 y_position = cursor move_down 5 - bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Grand Total", :size => self.item_font_size,:align => :left end - bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right end move_down 5 diff --git a/dump.rdb b/dump.rdb index c1a940eb..63a4647b 100644 Binary files a/dump.rdb and b/dump.rdb differ