Class: Xrechnung::Document

Inherits:
Object
  • Object
show all
Includes:
MemberContainer
Defined in:
lib/xrechnung.rb

Constant Summary collapse

DEFAULT_CUSTOMIZATION_ID =

Default customization specs

"urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"
DEFAULT_PROFILE_ID =
"urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MemberContainer

#[], #[]=, included, #initialize

Instance Attribute Details

#accounting_customer_partyXrechnung::Party

Returns:



147
# File 'lib/xrechnung.rb', line 147

member :accounting_customer_party, type: Xrechnung::Party

#accounting_supplier_partyXrechnung::Party

Returns:



139
# File 'lib/xrechnung.rb', line 139

member :accounting_supplier_party, type: Xrechnung::Party

#additional_document_referencesArray

Returns:

  • (Array)


194
# File 'lib/xrechnung.rb', line 194

member :additional_document_references, type: Array, default: []

#allowance_chargesArray

Returns:

  • (Array)


290
# File 'lib/xrechnung.rb', line 290

member :allowance_charges, type: Array, default: []

#billing_referenceXrechnung::InvoiceDocumentReference



189
# File 'lib/xrechnung.rb', line 189

member :billing_reference, type: Xrechnung::InvoiceDocumentReference, optional: true

#buyer_referenceString

Returns:

  • (String)


185
# File 'lib/xrechnung.rb', line 185

member :buyer_reference, type: String

#contract_document_reference_idString

Returns:

  • (String)


206
# File 'lib/xrechnung.rb', line 206

member :contract_document_reference_id, type: String, optional: true

#customization_idString

Returns:

  • (String)


44
# File 'lib/xrechnung.rb', line 44

member :customization_id, type: String, default: DEFAULT_CUSTOMIZATION_ID

#document_currency_codeString

Returns:

  • (String)


106
# File 'lib/xrechnung.rb', line 106

member :document_currency_code, type: String, default: "EUR"

#due_dateDate

Returns:

  • (Date)


75
# File 'lib/xrechnung.rb', line 75

member :due_date, type: Date

#idString

Returns:

  • (String)


59
# File 'lib/xrechnung.rb', line 59

member :id, type: String

#invoice_linesArray

Returns:

  • (Array)


279
# File 'lib/xrechnung.rb', line 279

member :invoice_lines, type: Array, default: []

#invoice_periodXrechnung::InvoicePeriod



198
# File 'lib/xrechnung.rb', line 198

member :invoice_period, type: Xrechnung::InvoicePeriod, optional: true

#invoice_type_codeInteger

Returns:

  • (Integer)


93
# File 'lib/xrechnung.rb', line 93

member :invoice_type_code, type: Integer, default: 380

#issue_dateDate

Returns:

  • (Date)


67
# File 'lib/xrechnung.rb', line 67

member :issue_date, type: Date


270
# File 'lib/xrechnung.rb', line 270

member :legal_monetary_total, type: Xrechnung::LegalMonetaryTotal

#notesArray

Returns:

  • (Array)


115
# File 'lib/xrechnung.rb', line 115

member :notes, type: Array, default: []

#payee_partyXrechnung::PayeeParty



241
# File 'lib/xrechnung.rb', line 241

member :payee_party, type: Xrechnung::PayeeParty, optional: true

#payment_meansXrechnung::PaymentMeans



232
# File 'lib/xrechnung.rb', line 232

member :payment_means, type: Xrechnung::PaymentMeans

#payment_terms_noteString

Returns:

  • (String)


252
# File 'lib/xrechnung.rb', line 252

member :payment_terms_note, type: String

#profile_idString

Returns:

  • (String)


50
# File 'lib/xrechnung.rb', line 50

member :profile_id, type: String, default: DEFAULT_PROFILE_ID

#project_reference_idString

Returns:

  • (String)


214
# File 'lib/xrechnung.rb', line 214

member :project_reference_id, type: String, optional: true

#purchase_order_referenceString

Returns:

  • (String)


123
# File 'lib/xrechnung.rb', line 123

member :purchase_order_reference, type: String

#sales_order_referenceString

Returns:

  • (String)


131
# File 'lib/xrechnung.rb', line 131

member :sales_order_reference, type: String, optional: true

#tax_currency_codeString

Returns:

  • (String)


169
# File 'lib/xrechnung.rb', line 169

member :tax_currency_code, type: String

#tax_point_dateDate

Returns:

  • (Date)


156
# File 'lib/xrechnung.rb', line 156

member :tax_point_date, type: Date

#tax_representative_partyXrechnung::Party

Returns:



223
# File 'lib/xrechnung.rb', line 223

member :tax_representative_party, type: Xrechnung::Party, optional: true

#tax_totalXrechnung::TaxTotal

Returns:



261
# File 'lib/xrechnung.rb', line 261

member :tax_total, type: Xrechnung::TaxTotal

Instance Method Details

#to_xml(indent: 2, target: "") ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/xrechnung.rb', line 292

def to_xml(indent: 2, target: "")
  xml = Builder::XmlMarkup.new(indent: indent, target: target)
  xml.instruct! :xml, version: "1.0", encoding: "UTF-8"

  xml.ubl :Invoice, \
    "xmlns:ubl"          => "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
    "xmlns:cac"          => "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
    "xmlns:cbc"          => "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
    "xmlns:xsi"          => "http://www.w3.org/2001/XMLSchema-instance",
    "xsi:schemaLocation" => "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd" do
    xml.cbc :CustomizationID, customization_id
    xml.cbc :ProfileID, profile_id
    xml.cbc :ID, id
    xml.cbc :IssueDate, issue_date
    xml.cbc :DueDate, due_date
    xml.cbc :InvoiceTypeCode, invoice_type_code

    notes.each do |note|
      xml.cbc :Note, note
    end

    xml.cbc :TaxPointDate, tax_point_date unless tax_point_date.nil?
    xml.cbc :DocumentCurrencyCode, document_currency_code
    xml.cbc :TaxCurrencyCode, tax_currency_code unless tax_currency_code.nil?
    xml.cbc :BuyerReference, buyer_reference

    invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?

    unless purchase_order_reference.nil? &&
           self.class.members[:sales_order_reference].optional && sales_order_reference.nil?
      xml.cac :OrderReference do
        xml.cbc :ID, purchase_order_reference
        unless self.class.members[:sales_order_reference].optional && sales_order_reference.nil?
          xml.cbc :SalesOrderID, sales_order_reference
        end
      end
    end

    unless self.class.members[:billing_reference].optional && billing_reference.nil?
      xml.cac :BillingReference do
        billing_reference&.to_xml(xml)
      end
    end

    unless self.class.members[:contract_document_reference_id].optional && contract_document_reference_id.nil?
      xml.cac :ContractDocumentReference do
        xml.cbc :ID, contract_document_reference_id
      end
    end

    unless self.class.members[:project_reference_id].optional && project_reference_id.nil?
      xml.cac :ProjectReference do
        xml.cbc :ID, project_reference_id
      end
    end

    additional_document_references.each { _1.to_xml(xml) }

    xml.cac :AccountingSupplierParty do
      accounting_supplier_party&.to_xml(xml)
    end

    xml.cac :AccountingCustomerParty do
      accounting_customer_party&.to_xml(xml)
    end

    unless self.class.members[:tax_representative_party].optional && tax_representative_party.nil?
      xml.cac :TaxRepresentativeParty do
        tax_representative_party&.to_xml(xml)
      end
    end

    xml.cac :PaymentMeans do
      payment_means&.to_xml(xml)
    end

    payee_party&.to_xml(xml) unless self.class.members[:payee_party].optional && payee_party.nil?

    xml.cac :PaymentTerms do
      xml.cbc :Note, payment_terms_note
    end

    allowance_charges.each { _1.to_xml(xml) }

    xml.cac :TaxTotal do
      tax_total&.to_xml(xml)
    end

    xml.cac :LegalMonetaryTotal do
      legal_monetary_total&.to_xml(xml)
    end

    invoice_lines.each { _1.to_xml(xml) }
  end

  target
end