Class: NtiReceiptBuilder::Template

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/nti_receipt_builder/template.rb

Overview

A receipt template: paper geometry plus a jsonb layout of positioned elements.

Hosts may subclass this to attach their own concerns — audit trail, archivable status, tenancy — and point config.template_class at the subclass so the gem's own queries return host instances. inheritance_column = nil keeps the subclass sharing this table with no STI type condition and no type column to maintain.

Constant Summary collapse

ORIENTATIONS =
%w[portrait landscape].freeze
HEIGHT_MODES =
%w[fixed content].freeze
MIN_PAPER_DIMENSION_MM =
10.0
MAX_PAPER_DIMENSION_MM =
1000.0
MIN_MARGIN_MM =
0.0
MAX_MARGIN_MM =
100.0
PAPER_PRESETS =
{
  'roll_58mm' => { label: '58mm Roll', width_mm: 58.0, height_mm: 297.0, orientation: 'portrait' },
  'roll_80mm' => { label: '80mm Roll', width_mm: 80.0, height_mm: 297.0, orientation: 'portrait' },
  'a4' => { label: 'A4', width_mm: 210.0, height_mm: 297.0, orientation: 'portrait' },
  'letter' => { label: 'Letter', width_mm: 215.9, height_mm: 279.4, orientation: 'portrait' },
  'custom' => { label: 'Custom', width_mm: 80.0, height_mm: 200.0, orientation: 'portrait' }
}.freeze

Instance Method Summary collapse

Instance Method Details

#content_layout?Boolean

Returns:

  • (Boolean)


47
# File 'app/models/nti_receipt_builder/template.rb', line 47

def content_layout? = height_mode == 'content'