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
- #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:, context:, 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 |
# File 'lib/ubill/invoice.rb', line 15 def initialize super() @recipient = {} @subject = "" @subject_info = "" @positions = [["#", "Beschreibung", "Einzelpreis", "Menge", "Gesamt"]] @total = "" @due = "" load_external_font_families yield(self) if block_given? end |
Instance Method Details
#config ⇒ Object
57 58 59 |
# File 'lib/ubill/invoice.rb', line 57 def config Ubill.config end |
#document ⇒ Object
61 62 63 |
# File 'lib/ubill/invoice.rb', line 61 def document @doc ||= Prawn::Document.new(config.) end |
#due(value) ⇒ Object
52 53 54 |
# File 'lib/ubill/invoice.rb', line 52 def due(value) @due = value end |
#height ⇒ Object
69 70 71 |
# File 'lib/ubill/invoice.rb', line 69 def height bounds.top_left[1] end |
#margin_bottom ⇒ Object
81 82 83 |
# File 'lib/ubill/invoice.rb', line 81 def margin_bottom config.[:margin][2] end |
#margin_left ⇒ Object
85 86 87 |
# File 'lib/ubill/invoice.rb', line 85 def margin_left config.[:margin][3] end |
#margin_right ⇒ Object
77 78 79 |
# File 'lib/ubill/invoice.rb', line 77 def margin_right config.[:margin][1] end |
#margin_top ⇒ Object
73 74 75 |
# File 'lib/ubill/invoice.rb', line 73 def margin_top config.[:margin][0] end |
#position(name:, context:, description:, price_per_unit:, units:, price:) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/ubill/invoice.rb', line 38 def position(name:, context:, description:, price_per_unit:, units:, price:) @positions << [ @positions.size, "<b>#{name}</b><font size=\"9\">\n#{context}\n#{description}</font>", price_per_unit, units, price ] end |
#recipient(**options) ⇒ Object
29 30 31 |
# File 'lib/ubill/invoice.rb', line 29 def recipient(**) @recipient.merge!() end |
#render(*args, **options) ⇒ Object
94 95 96 97 |
# File 'lib/ubill/invoice.rb', line 94 def render(*args, **) describe super end |
#save_as(*args, **options) ⇒ Object
89 90 91 92 |
# File 'lib/ubill/invoice.rb', line 89 def save_as(*args, **) describe super end |
#subject(title, subtitle = nil) ⇒ Object
33 34 35 36 |
# File 'lib/ubill/invoice.rb', line 33 def subject(title, subtitle=nil) @subject = title @subject_info = subtitle end |
#total(value) ⇒ Object
48 49 50 |
# File 'lib/ubill/invoice.rb', line 48 def total(value) @total = value end |
#width ⇒ Object
65 66 67 |
# File 'lib/ubill/invoice.rb', line 65 def width bounds.top_right[0] end |