Sha256: 8986890956736c886649245c02219e98c69390144a7e7c7f0cf5b9c33140e19d

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require_relative 'write_invoice/version'

require_relative './write_invoice/example/index'

require_relative './write_invoice/document/index'
require_relative './write_invoice/document/options'
require_relative './write_invoice/document/sections'

require 'json'
require 'prawn/table'
require 'prawn'
require 'prawn/measurement_extensions'

require 'active_support'
require 'active_support/core_ext'

require 'prawn/qrcode'
require 'date'
require 'faker'


module WriteInvoice
  class Error < StandardError; end

  
  class Example
    extend Exmple

    def self.generate( invoices_total: 3..6, articles_total: 2..6, debug: true ) 
      payload = examples_generate( invoices_total: invoices_total, articles_total: articles_total )
      debug ? puts( "Example       #{payload[:document][:encrypt][:user_password]}" ) : ''
      return payload
    end
  end


  class Document
    extend Dcmnt
    extend Options
    extend Sections

    def self.generate( output: nil, payload: nil, options: {}, debug: true )

      template = Marshal.load( Marshal.dump( get_options ) )
      valid, messages = options_update( options, template, true )

      if valid
        debug ? print( 'Document      ' ) : ''
        pdf = self.document( template, options, payload, output, debug )
        debug ? puts : ''
        debug ? puts( "Pages Total   #{pdf.page_count}" ) : ''

        if output.nil?
          doc = pdf.render
          return doc
        else
          pdf.render_file( output )
          return true
        end

      else
        return messages
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
write_invoice-0.1.83 lib/write_invoice.rb
write_invoice-0.1.82 lib/write_invoice.rb