update receipt
This commit is contained in:
@@ -17,6 +17,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
rebate_amount = Customer.get_membership_transactions(customer)
|
rebate_amount = Customer.get_membership_transactions(customer)
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
# get member information
|
# get member information
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,8 +53,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@accountable_type = ''
|
@accountable_type = ''
|
||||||
if response["status"]==true
|
if response["status"]==true
|
||||||
response["data"].each do |res|
|
response["data"].each do |res|
|
||||||
if res["accountable_type"] == "RebateAccount"
|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||||
@balance = res["balance"]
|
@balance += res["balance"]
|
||||||
# @accountable_type = res["accountable_type"]
|
# @accountable_type = res["accountable_type"]
|
||||||
@accountable_type = "Rebate Balance"
|
@accountable_type = "Rebate Balance"
|
||||||
end
|
end
|
||||||
@@ -89,6 +91,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
# get member information
|
# get member information
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
rebate_amount = Customer.get_membership_transactions(customer)
|
rebate_amount = Customer.get_membership_transactions(customer)
|
||||||
@@ -99,7 +103,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
|
|
||||||
customer= Customer.find(@sale_data.customer_id)
|
customer= Customer.find(@sale_data.customer_id)
|
||||||
# get member information
|
# get member information
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
@@ -36,7 +37,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info)
|
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||||
# redirect_to origami_path(@sale_data.sale_id)
|
# redirect_to origami_path(@sale_data.sale_id)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil)
|
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount)
|
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
|
|
||||||
pdf.render_file "tmp/receipt_bill.pdf"
|
pdf.render_file "tmp/receipt_bill.pdf"
|
||||||
self.print("tmp/receipt_bill.pdf")
|
self.print("tmp/receipt_bill.pdf")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class ReceiptBillPdf < Prawn::Document
|
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
|
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, item_price_by_accounts, member_info = nil,rebate_amount = nil)
|
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
|
||||||
self.page_width = 210
|
self.page_width = 210
|
||||||
self.page_height = 2500
|
self.page_height = 2500
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
@@ -24,7 +24,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
self.header_font_size = 10
|
self.header_font_size = 10
|
||||||
self.item_font_size = 8
|
self.item_font_size = 8
|
||||||
|
|
||||||
header( "Beauty In the Pot", printer_settings.name)
|
header( shop_details)
|
||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
@@ -44,12 +44,15 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
footer
|
footer
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (printer_name, name)
|
def header (shop_details)
|
||||||
text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
move_down 7
|
||||||
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
move_down 5
|
move_down 5
|
||||||
text "#{name}", :size => self.header_font_size,:align => :center
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
# move_down self.item_height
|
# move_down self.item_height
|
||||||
move_down 5
|
move_down 5
|
||||||
|
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
@@ -264,21 +267,22 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if member_info["status"] == true
|
if member_info["status"] == true
|
||||||
|
balance = 0.0
|
||||||
member_info["data"].each do |res|
|
member_info["data"].each do |res|
|
||||||
|
|
||||||
if res["accountable_type"]== "RebateAccount"
|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||||
|
balance = balance + res["balance"]
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
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 "Current Balance", :size => self.item_font_size,:align => :left
|
text "Current Balance", :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 "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
|
text "#{ balance }" , :size => self.item_font_size,:align => :right
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user