Papers - Pre packing list

Template Pre-Pack List Setup

Setup a Pre-Pack List

If there is a need to list all items actually picked, a Pre-Pack List is available to be configured.

A Pre-Pack Lists may become handy if the Picker overpicked items that need to be returned. This document will identify from which container and bin location it is picked from.

TIP! Pre-Pack Lists will be configurable by Business Model using conditions.


To set up a Pre Pack List, navigate through [Admin] > [Papers] > [Templates] and click on Create Template.

Configure the template whose Klass is [PickList] Use is [Document] and Event is [complete].

Conditions:

{%assign business_models = picklist.orders | map: "business_model"%}
{%if business_models contains 'b2b'%}true{%endif%}

Data:

# frozen_string_literal: true

pdf.font_families['MyHelvetica'] = {
  normal: { file: open('Helvetica-01.ttf'), format: 'ttf', font: 'Helvetica' },
  italic: { file: open('Helvetica-Oblique-03.ttf'), format: 'ttf', font: 'Helvetica Oblique' },
  bold: { file: open('Helvetica-Bold-02.ttf'), format: 'ttf', font: 'Helvetica Bold' },
  bold_italic: { file: open('Helvetica-BoldOblique-04.ttf'), format: 'ttf', font: 'Helvetica Bold Oblique' }
}

pdf.font_families['SimSun'] = {
  normal: { file: open('SimSun.ttf'), format: 'ttf', font: 'Helvetica' },
  bold: { file: open('SimSun.ttf'), format: 'ttf', font: 'Helvetica Bold' },
}

method(:draw_block) do |pdf, pos, width, height, block, limit|
  return unless block

  pdf.bounding_box(pos, width: width, height: height) do
    pdf.text block.first, style: :bold
    pdf.font 'MyHelvetica', size: 10 do
      block[1..-1].first(limit).each do |line|
        pdf.text line
      end
    end
  end
end

pdf.font 'MyHelvetica'

number_of_orders = pick_list.orders.count

pick_list.orders.each_with_index do |order, index|
  next if order.business_model != 'b2b'
  pdf.start_new_page if index > 0
  
  y_pos = pdf.cursor
  pdf.image open(order.account.logo), position: :left, vposition: :top, width: 40.mm if order.account&.logo
  pdf.bounding_box([100.mm, y_pos - 5.mm], width: 100.mm, position: :right) do
    pdf.text 'Pre-Packlist', align: :right, size: 24
  end

  date = pick_list.created_at
  date = Date.parse(date) if date.is_a? String

  draw_block(pdf, [0, 260.mm], 60.mm, 20.mm, ['Date', l(date, format: "%d-%m-%Y")], 3)
  draw_block(pdf, [70.mm, 260.mm], 60.mm, 20.mm, ['Reference', order.name], 3)
  draw_block(pdf, [140.mm, 260.mm], 60.mm, 20.mm, ['',''], 3)
  
  customer_name = order.customer_name
  customer_name ||= order.delivery_contact&.company_name
  customer_name ||= "#{order.delivery_contact&.first_name} #{order.delivery_contact&.last_name}".strip
  
  draw_block(pdf, [0, 240.mm], 60.mm, 20.mm, ['Customer Name', customer_name], 3)
  draw_block(pdf, [70.mm, 240.mm], 60.mm, 20.mm, ['Customer Reference Number', order.customer_reference_number ], 3)
  draw_block(pdf, [140.mm, 240.mm], 60.mm, 20.mm, ['',''], 3)

  table_data = [
    ['Product Number', 'Product Name', 'Container', "Bin Location", 'Qty.']
  ]

  line_details = Hash.new
  order.pick_list_lines.each do |pick_list_line|
    pick_list_line.line_details.each do |value|
      next if value[:order_id] != order.id
      
      value[:product_number] = pick_list_line.product.number
      value[:product_name] = pick_list_line.product.name
      
      key = [value[:product_number], value[:product_name], value[:container]&.name, value[:bin_location]&.name]
			unless line_details[key]
        line_details[key] = value
        next
      end
      
      line_details[key][:quantity] = line_details[key][:quantity] + value[:quantity]  
    end
  end
  line_details = line_details.values

  line_details.each do |values|
    table_data << [values[:product_number], values[:product_name], values[:container]&.name, values[:bin_location]&.name, values[:quantity]]
  end
  
  pdf.table(table_data, header: true, cell_style: { size: 8 }) do
    row(0).font_style = :bold

    cells.style do |cell|
      cell.overflow = :shrink_to_fit
      cell.size = 8
      cell.padding = 4
      cell.border_width = 0.2
      cell.border_color = 'cccccc'
    end
  end
end

WARNING! If configured for a parent account e.g. Rapid, all child accounts will be affected.


Sample Template

Pre Pack List 1 Pre Pack List 2


Sample Pre-Packlist

Pre Pack List 3


Related Docs