Class: SunatInvoice::XmlDocument
- Includes:
- Utils
- Defined in:
- lib/sunat_invoice/xml_document.rb
Direct Known Subclasses
Constant Summary collapse
- UBL_VERSION =
'2.0'.freeze
- CUSTOMIZATION =
'1.0'.freeze
Constants included from Utils
Utils::COMMON_NAMESPACES, Utils::CREDIT_NOTE_NAMESPACES, Utils::DAILY_SUMMARY_NAMESPACES, Utils::DEBIT_NOTE_NAMESPACES, Utils::INVOICE_NAMESPACES, Utils::SUMMARY_NAMESPACES, Utils::TRADE_NAMESPACES, Utils::VOIDED_NAMESPACES
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#date ⇒ Object
Returns the value of attribute date.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#signature ⇒ Object
Returns the value of attribute signature.
Instance Method Summary collapse
- #build_ext(xml, &block) ⇒ Object
- #build_lines_xml(xml) ⇒ Object
- #build_number(xml) ⇒ Object
- #build_xml(&block) ⇒ Object
- #formatted_date(date) ⇒ Object
-
#initialize(*args) ⇒ XmlDocument
constructor
A new instance of XmlDocument.
Methods included from Utils
Methods inherited from Model
Constructor Details
#initialize(*args) ⇒ XmlDocument
Returns a new instance of XmlDocument.
15 16 17 18 |
# File 'lib/sunat_invoice/xml_document.rb', line 15 def initialize(*args) super(*args) @date ||= Date.today end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
10 11 12 |
# File 'lib/sunat_invoice/xml_document.rb', line 10 def currency @currency end |
#date ⇒ Object
Returns the value of attribute date.
10 11 12 |
# File 'lib/sunat_invoice/xml_document.rb', line 10 def date @date end |
#lines ⇒ Object
Returns the value of attribute lines.
10 11 12 |
# File 'lib/sunat_invoice/xml_document.rb', line 10 def lines @lines end |
#provider ⇒ Object
Returns the value of attribute provider.
10 11 12 |
# File 'lib/sunat_invoice/xml_document.rb', line 10 def provider @provider end |
#signature ⇒ Object
Returns the value of attribute signature.
10 11 12 |
# File 'lib/sunat_invoice/xml_document.rb', line 10 def signature @signature end |
Instance Method Details
#build_ext(xml, &block) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/sunat_invoice/xml_document.rb', line 31 def build_ext(xml, &block) xml['ext'].UBLExtensions do yield(xml) if block @signature.signature_ext(xml) end end |
#build_lines_xml(xml) ⇒ Object
46 47 48 49 50 |
# File 'lib/sunat_invoice/xml_document.rb', line 46 def build_lines_xml(xml) lines&.each_with_index do |line, index| line.xml(xml, index, currency) end end |
#build_number(xml) ⇒ Object
38 39 40 |
# File 'lib/sunat_invoice/xml_document.rb', line 38 def build_number(xml) xml['cbc'].ID document_number end |
#build_xml(&block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sunat_invoice/xml_document.rb', line 20 def build_xml(&block) Nokogiri::XML::Builder.new do |xml| xml.send(root_name, namespaces) do build_ext(xml) xml['cbc'].UBLVersionID UBL_VERSION xml['cbc'].CustomizationID CUSTOMIZATION yield(xml) if block end end end |
#formatted_date(date) ⇒ Object
42 43 44 |
# File 'lib/sunat_invoice/xml_document.rb', line 42 def formatted_date(date) date.strftime('%Y-%m-%d') end |