receipt bill sale payments action cable
This commit is contained in:
@@ -126,6 +126,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
Rails.logger.debug "############## filename::" + filename
|
Rails.logger.debug "############## filename::" + filename
|
||||||
else
|
else
|
||||||
if !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1')
|
if !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1')
|
||||||
|
sale_payments = SalePayment
|
||||||
|
.select(:payment_method, 'SUM(`sale_payments`.`payment_amount`) AS `payment_amount`')
|
||||||
|
.where(sale_id: sale_data.sale_id).group(:payment_method)
|
||||||
|
|
||||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||||
queue: cashier_terminal.printer_name,
|
queue: cashier_terminal.printer_name,
|
||||||
unique_code: print_settings.unique_code,
|
unique_code: print_settings.unique_code,
|
||||||
@@ -148,7 +152,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
card_balance_amount: card_balance_amount,
|
card_balance_amount: card_balance_amount,
|
||||||
discount_price_by_accounts: discount_price_by_accounts,
|
discount_price_by_accounts: discount_price_by_accounts,
|
||||||
item_price_by_accounts: item_price_by_accounts,
|
item_price_by_accounts: item_price_by_accounts,
|
||||||
sale_payments: sale_data.sale_payments
|
sale_payments: sale_payments.as_json
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
printed_status: printed_status, footer_text: "Thank You! See you Again"
|
printed_status: printed_status, footer_text: "Thank You! See you Again"
|
||||||
|
|||||||
@@ -439,16 +439,16 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sale_payment(sale_data,precision,delimiter,printed_status)
|
def sale_payment(sale_data,precision,delimiter,printed_status)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
#move_down line_move
|
#move_down line_move
|
||||||
# sql = "SELECT SUM(payment_amount)
|
# sql = "SELECT SUM(payment_amount)
|
||||||
# FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
# and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
|
|
||||||
if printed_status == 'credit_payment'
|
if printed_status == 'credit_payment'
|
||||||
sale_payments = SalePayment.select(:payment_amount, :payment_method, :updated_at)
|
sale_payments = SalePayment.select(:payment_amount, :payment_method, :updated_at)
|
||||||
.where("sale_id = '#{sale_data.sale_id}' AND payment_method != 'creditnote'")
|
.where("sale_id = '#{sale_data.sale_id}' AND payment_method != 'creditnote'")
|
||||||
else
|
else
|
||||||
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote' and sale_id='#{sale_data.sale_id}'").to_sql
|
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote' and sale_id='#{sale_data.sale_id}'").to_sql
|
||||||
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
# FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
@@ -466,38 +466,38 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
|
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
|
||||||
.group("payment_method")
|
.group("payment_method")
|
||||||
end
|
end
|
||||||
|
|
||||||
sale_payments.each do |payment|
|
sale_payments.each do |payment|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
if payment.payment_method == "paypar"
|
if payment.payment_method == "paypar"
|
||||||
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 "Redeem Payment", :size => self.item_font_size,:align => :left
|
text "Redeem Payment", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
elsif printed_status == 'credit_payment'
|
elsif printed_status == 'credit_payment'
|
||||||
text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left
|
text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left
|
||||||
else
|
else
|
||||||
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 "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
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 "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
end
|
|
||||||
move_down line_move
|
|
||||||
end
|
end
|
||||||
if sale_data.amount_received > 0
|
move_down line_move
|
||||||
y_position = cursor
|
end
|
||||||
move_down line_move
|
if sale_data.amount_received > 0
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
y_position = cursor
|
||||||
text "Change Amount", :size => self.item_font_size,:align => :left
|
move_down line_move
|
||||||
end
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||||
text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
|
||||||
end
|
|
||||||
# move_down line_move
|
|
||||||
end
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
# move_down line_move
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# show member information
|
# show member information
|
||||||
|
|||||||
Reference in New Issue
Block a user