Class: Ubill::Invoice
- Inherits:
-
Object
- Object
- Ubill::Invoice
- Includes:
- Prawn::View, Concerns::Configurable
- Defined in:
- lib/ubill/invoice.rb
Constant Summary collapse
- COLOR_SECONDARY =
"777777"
- EXTERNAL_FONTS_DIR =
File.join(__dir__, "fonts")
Instance Method Summary collapse
- #addendum(value) ⇒ Object
- #config ⇒ Object
- #document ⇒ Object
- #due(value) ⇒ Object
- #height ⇒ Object
-
#initialize {|_self| ... } ⇒ Invoice
constructor
A new instance of Invoice.
- #margin_bottom ⇒ Object
- #margin_left ⇒ Object
- #margin_right ⇒ Object
- #margin_top ⇒ Object
- #position(name:, description:, price_per_unit:, units:, price:) ⇒ Object
- #recipient(**options) ⇒ Object
- #render(*args, **options) ⇒ Object
- #save_as(*args, **options) ⇒ Object
- #subject(title, subtitle = nil) ⇒ Object
- #total(value) ⇒ Object
- #width ⇒ Object
Methods included from Concerns::Configurable
Constructor Details
#initialize {|_self| ... } ⇒ Invoice
Returns a new instance of Invoice.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ubill/invoice.rb', line 15 def initialize super() @recipient = {} @subject = "" @subject_info = "" @positions = [["#", "Beschreibung", "Einzelpreis", "Menge", "Gesamt"]] @total = "" @due = "" @addendum = "" load_external_font_families yield(self) if block_given? end |
Instance Method Details
#addendum(value) ⇒ Object
57 58 59 |
# File 'lib/ubill/invoice.rb', line 57 def addendum(value) @addendum = value end |
#document ⇒ Object
66 67 68 |
# File 'lib/ubill/invoice.rb', line 66 def document @doc ||= Prawn::Document.new(config.) end |
#due(value) ⇒ Object
53 54 55 |
# File 'lib/ubill/invoice.rb', line 53 def due(value) @due = value end |
#height ⇒ Object
74 75 76 |
# File 'lib/ubill/invoice.rb', line 74 def height bounds.top_left[1] end |
#margin_bottom ⇒ Object
86 87 88 |
# File 'lib/ubill/invoice.rb', line 86 def margin_bottom config.[:margin][2] end |
#margin_left ⇒ Object
90 91 92 |
# File 'lib/ubill/invoice.rb', line 90 def margin_left config.[:margin][3] end |
#margin_right ⇒ Object
82 83 84 |
# File 'lib/ubill/invoice.rb', line 82 def margin_right config.[:margin][1] end |
#margin_top ⇒ Object
78 79 80 |
# File 'lib/ubill/invoice.rb', line 78 def margin_top config.[:margin][0] end |
#position(name:, description:, price_per_unit:, units:, price:) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/ubill/invoice.rb', line 39 def position(name:, description:, price_per_unit:, units:, price:) @positions << [ @positions.size, "<b>#{name}</b><font size=\"9\">\n#{description}</font>", price_per_unit, units, price ] end |
#recipient(**options) ⇒ Object
30 31 32 |
# File 'lib/ubill/invoice.rb', line 30 def recipient(**) @recipient.merge!() end |
#render(*args, **options) ⇒ Object
99 100 101 102 |
# File 'lib/ubill/invoice.rb', line 99 def render(*args, **) describe super end |
#save_as(*args, **options) ⇒ Object
94 95 96 97 |
# File 'lib/ubill/invoice.rb', line 94 def save_as(*args, **) describe super end |
#subject(title, subtitle = nil) ⇒ Object
34 35 36 37 |
# File 'lib/ubill/invoice.rb', line 34 def subject(title, subtitle=nil) @subject = title @subject_info = subtitle end |
#total(value) ⇒ Object
49 50 51 |
# File 'lib/ubill/invoice.rb', line 49 def total(value) @total = value end |
#width ⇒ Object
70 71 72 |
# File 'lib/ubill/invoice.rb', line 70 def width bounds.top_right[0] end |