Class: Twinfield::SalesInvoice::Line
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- Twinfield::SalesInvoice::Line
- Defined in:
- lib/twinfield/sales_invoice.rb
Instance Attribute Summary collapse
-
#allowdiscountorpremium ⇒ Object
Returns the value of attribute allowdiscountorpremium.
-
#article ⇒ Object
Returns the value of attribute article.
-
#description ⇒ Object
Returns the value of attribute description.
-
#dim1 ⇒ Object
Returns the value of attribute dim1.
-
#freetext1 ⇒ Object
Returns the value of attribute freetext1.
-
#freetext2 ⇒ Object
Returns the value of attribute freetext2.
-
#freetext3 ⇒ Object
Returns the value of attribute freetext3.
-
#id ⇒ Object
Returns the value of attribute id.
-
#invoice ⇒ Object
Returns the value of attribute invoice.
-
#performancedate ⇒ Object
Returns the value of attribute performancedate.
-
#performancetype ⇒ Object
Returns the value of attribute performancetype.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#subarticle ⇒ Object
Returns the value of attribute subarticle.
-
#units ⇒ Object
Returns the value of attribute units.
-
#unitspriceexcl ⇒ Object
Returns the value of attribute unitspriceexcl.
-
#unitspriceinc ⇒ Object
Returns the value of attribute unitspriceinc.
-
#valueexcl ⇒ Object
Returns the value of attribute valueexcl.
-
#valueinc ⇒ Object
Returns the value of attribute valueinc.
-
#vatcode ⇒ Object
Returns the value of attribute vatcode.
-
#vatvalue ⇒ Object
Returns the value of attribute vatvalue.
Instance Method Summary collapse
-
#initialize(id: nil, article: "-", subarticle: nil, quantity: 1, units: nil, allowdiscountorpremium: true, description: nil, unitspriceexcl: nil, unitspriceinc: nil, freetext1: nil, freetext2: nil, freetext3: nil, dim1: nil, vatcode: nil, performancetype: nil, performancedate: nil, valueinc: nil, vatvalue: nil, valueexcl: nil) ⇒ Line
constructor
A new instance of Line.
- #to_h ⇒ Object
- #to_xml(lineid = id) ⇒ Object
Constructor Details
#initialize(id: nil, article: "-", subarticle: nil, quantity: 1, units: nil, allowdiscountorpremium: true, description: nil, unitspriceexcl: nil, unitspriceinc: nil, freetext1: nil, freetext2: nil, freetext3: nil, dim1: nil, vatcode: nil, performancetype: nil, performancedate: nil, valueinc: nil, vatvalue: nil, valueexcl: nil) ⇒ Line
Returns a new instance of Line.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/twinfield/sales_invoice.rb', line 46 def initialize(id: nil, article: "-", subarticle: nil, quantity: 1, units: nil, allowdiscountorpremium: true, description: nil, unitspriceexcl: nil, unitspriceinc: nil, freetext1: nil, freetext2: nil, freetext3: nil, dim1: nil, vatcode: nil, performancetype: nil, performancedate: nil, valueinc: nil, vatvalue: nil, valueexcl: nil) @id = id @article = article # article "-" is an article-less article in Twinfield @subarticle = if .to_s != "" @quantity = Float(quantity) unless article == "-" @units = Integer(units) if units && units != "" @allowdiscountorpremium = allowdiscountorpremium unless article == "-" @description = description @unitspriceexcl = Float(unitspriceexcl) if unitspriceexcl @unitspriceinc = Float(unitspriceinc) if unitspriceinc @freetext1 = freetext1 if freetext1.to_s != "" @freetext2 = freetext2 if freetext2.to_s != "" @freetext3 = freetext3 if freetext3.to_s != "" @dim1 = dim1 if dim1.to_s != "" @vatcode = vatcode if vatcode.to_s != "" @performancetype = performancetype if performancetype.to_s != "" @performancedate = performancedate if performancedate.to_s != "" @valueinc = valueinc @vatvalue = vatvalue @valueexcl = valueexcl end |
Instance Attribute Details
#allowdiscountorpremium ⇒ Object
Returns the value of attribute allowdiscountorpremium.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def allowdiscountorpremium @allowdiscountorpremium end |
#article ⇒ Object
Returns the value of attribute article.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def article @article end |
#description ⇒ Object
Returns the value of attribute description.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def description @description end |
#dim1 ⇒ Object
Returns the value of attribute dim1.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def dim1 @dim1 end |
#freetext1 ⇒ Object
Returns the value of attribute freetext1.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def freetext1 @freetext1 end |
#freetext2 ⇒ Object
Returns the value of attribute freetext2.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def freetext2 @freetext2 end |
#freetext3 ⇒ Object
Returns the value of attribute freetext3.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def freetext3 @freetext3 end |
#id ⇒ Object
Returns the value of attribute id.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def id @id end |
#invoice ⇒ Object
Returns the value of attribute invoice.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def invoice @invoice end |
#performancedate ⇒ Object
Returns the value of attribute performancedate.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def performancedate @performancedate end |
#performancetype ⇒ Object
Returns the value of attribute performancetype.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def performancetype @performancetype end |
#quantity ⇒ Object
Returns the value of attribute quantity.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def quantity @quantity end |
#subarticle ⇒ Object
Returns the value of attribute subarticle.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def @subarticle end |
#units ⇒ Object
Returns the value of attribute units.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def units @units end |
#unitspriceexcl ⇒ Object
Returns the value of attribute unitspriceexcl.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def unitspriceexcl @unitspriceexcl end |
#unitspriceinc ⇒ Object
Returns the value of attribute unitspriceinc.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def unitspriceinc @unitspriceinc end |
#valueexcl ⇒ Object
Returns the value of attribute valueexcl.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def valueexcl @valueexcl end |
#valueinc ⇒ Object
Returns the value of attribute valueinc.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def valueinc @valueinc end |
#vatcode ⇒ Object
Returns the value of attribute vatcode.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def vatcode @vatcode end |
#vatvalue ⇒ Object
Returns the value of attribute vatvalue.
44 45 46 |
# File 'lib/twinfield/sales_invoice.rb', line 44 def vatvalue @vatvalue end |
Instance Method Details
#to_h ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/twinfield/sales_invoice.rb', line 90 def to_h { id: id, article: article, subarticle: , quantity: quantity, units: units, allowdiscountorpremium: allowdiscountorpremium, description: description, unitspriceexcl: unitspriceexcl, unitspriceinc: unitspriceinc, freetext1: freetext1, freetext2: freetext2, freetext3: freetext3, dim1: dim1, vatcode: vatcode, performancetype: performancetype, performancedate: performancedate, valueexcl: valueexcl, valueinc: valueinc, vatvalue: vatvalue } end |
#to_xml(lineid = id) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/twinfield/sales_invoice.rb', line 68 def to_xml(lineid = id) Nokogiri::XML::Builder.new do |xml| xml.line(id: lineid) { xml.article article xml. if xml.quantity quantity if quantity xml.units units if units xml.allowdiscountorpremium allowdiscountorpremium if allowdiscountorpremium xml.description description if description xml.unitspriceexcl unitspriceexcl if unitspriceexcl xml.unitspriceinc unitspriceinc if unitspriceinc xml.freetext1 freetext1 if freetext1 xml.freetext2 freetext2 if freetext2 xml.freetext3 freetext3 if freetext3 xml.dim1 dim1 if dim1 xml.vatcode vatcode if vatcode xml.performancetype performancetype if performancetype xml.performancedate performancedate.strftime("%Y%m%d") if performancedate } end.doc.root.to_xml end |