Skip to content

Instantly share code, notes, and snippets.

@bjonord
Last active November 3, 2017 13:43
Show Gist options
  • Save bjonord/2d58013491f07a5d9a05699ec6048ead to your computer and use it in GitHub Desktop.
Save bjonord/2d58013491f07a5d9a05699ec6048ead to your computer and use it in GitHub Desktop.
some TS thing
def print_online_order(order)
transaction do
order.lock!
do_print_summary = current_account.setting('print_summary_for_online_orders')
policies = {"Customer" => {"online" => false}}
printer = Printing::Printer.new(order, nil, [], print_ticket_summary: do_print_summary,
policies: policies)
printables = printer.printable_pages
raise EmptyPrintBatchError if printables.size.zero?
# print at home tickets can be downloaded multiple times,
# but we only want to add them to one batch.
if !order.all_printed?
Printing::PrintBatchingService.new.reset_order_batching_state(order)
Printing::PrintBatchingService.new.put_order_in_printed_immediate_batch(order)
end
printables
end
end
require 'script_helper'
li 97
@order = current_account.orders.find_by(order_number: 136513019)
printables = print_online_order(@order)
out_data = Printing::PrintBatchingService.new.render_tickets(
all_printables: printables,
print_ticket_summary: current_account.setting('print_summary_for_online_orders'),
print_at_home: false
);nil
File.open("/home/app/tmp/order.pdf", 'wb') do |output|
output.write out_data
end
# NOTE:
# 001 account id 97
# order# 136513019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment