Sha256: cb66d1cf07c9370daaaade0518ec557921f2233bf8615b1722567fb271168c9f

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Prawn
  module SwissQRBill
    module Sections
      # Information section at receipt
      class ReceiptInformation < Section
        KEY = 'receipt.information'

        include Helpers::BoxHelper

        def draw
          box do
            draw_payable_to
            draw_reference if @data.key?(:reference)
            draw_payable_by
          end
        end

        private

        def draw_payable_to
          label I18n.t('creditor', scope: i18n_scope)
          content [@data[:creditor][:iban],
                   build_address(@data[:creditor][:address])].join("\n")

          line_spacing
        end

        def draw_reference
          label I18n.t('reference', scope: i18n_scope)
          content @data[:reference]

          line_spacing
        end

        def draw_payable_by
          if @data.key?(:debtor)
            label I18n.t('debtor', scope: i18n_scope)
            content build_address(@data[:debtor][:address])
          else
            label I18n.t('debtor_blank', scope: i18n_scope)

            doc.move_down 2
            corner_box(doc, [0, doc.cursor], width: 52.mm, height: 20.mm)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prawn-swiss_qr_bill-0.5.4 lib/prawn/swiss_qr_bill/sections/receipt_information.rb
prawn-swiss_qr_bill-0.5.2 lib/prawn/swiss_qr_bill/sections/receipt_information.rb
prawn-swiss_qr_bill-0.5.1 lib/prawn/swiss_qr_bill/sections/receipt_information.rb
prawn-swiss_qr_bill-0.5.0 lib/prawn/swiss_qr_bill/sections/receipt_information.rb
prawn-swiss_qr_bill-0.4.2 lib/prawn/swiss_qr_bill/sections/receipt_information.rb
prawn-swiss_qr_bill-0.4.1 lib/prawn/swiss_qr_bill/sections/receipt_information.rb