Sha256: 04e0721a57618b4c1eab7bba4d5dc7d15c5fe958eadb137f29ee6d5f6a2b352b

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

module Dorsale
  module BillingMachine
    class QuotationPdf < ::Dorsale::BillingMachine::InvoicePdf
      def build
        super
        build_attachments
      end

      def build_attachments
        @main_document.attachments.each do |attachment|
          next unless File.extname(attachment.file.path) == ".pdf"

          file     = attachment.file.path
          nb_pages = ::CombinePDF.load(file).pages.count

          nb_pages.times do |i|
            start_new_page template: file, template_page: (i+1)
          end
        end
      end

      def main_document_type
        Dorsale::BillingMachine::Quotation.model_name.human.humanize
      end

      def build_bank_informations
      end

      def build_expiry
        return if @main_document.expires_at.nil?
        top = bounds.top - 11.5.cm
        height = 0.5.cm
        width  = 7.5.cm

        bounding_box [bounds.left, top], height: height, width: width do
          draw_bounds_debug
          font_size 9 do
            text "<b>#{I18n.t("pdfs.expires_at")}</b> #{I18n.l(@main_document.expires_at)}", inline_format: true
          end
        end
      end

      def build_comments
        return if @main_document.comments.blank?
        top = bounds.top - 12.cm
        height = 1.5.cm
        width  = 10.cm

        font_size 9 do
          text_box @main_document.comments,
            :at       => [bounds.left, top],
            :height   => height,
            :width    => width,
            :overflow => :shrink_to_fit
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dorsale-2.1.15 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.14 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.13 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.12 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.11 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.10 app/pdfs/dorsale/billing_machine/quotation_pdf.rb
dorsale-2.1.9 app/pdfs/dorsale/billing_machine/quotation_pdf.rb