Class: SunatInvoice::CreditNote

Inherits:
TradeDocument show all
Defined in:
lib/sunat_invoice/credit_note.rb

Direct Known Subclasses

DebitNote

Constant Summary

Constants inherited from TradeDocument

TradeDocument::INVOICE_TYPES

Constants inherited from XmlDocument

XmlDocument::CUSTOMIZATION, XmlDocument::UBL_VERSION

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

Attributes inherited from TradeDocument

#customer, #discount, #document_number, #document_type, #sale_totals, #taxes_totals, #total

Attributes inherited from XmlDocument

#currency, #date, #lines, #provider, #signature

Instance Method Summary collapse

Methods inherited from TradeDocument

#document_name, #initialize, #operation

Methods included from TradeCalculations

#calculate_sale_totals, #calculate_taxes_totals, #calculate_total, #get_total_code, #get_total_igv_code, #prepare_totals

Methods inherited from XmlDocument

#build_ext, #build_lines_xml, #build_number, #build_xml, #formatted_date, #initialize

Methods included from Utils

#amount_xml, #ubl_ext

Methods inherited from Model

#initialize, #to_hash

Constructor Details

This class inherits a constructor from SunatInvoice::TradeDocument

Instance Attribute Details

#descriptionObject

  • date - issued date

  • ref_document_number - serial and number of document affected

  • ref_document_type - type of document affected

  • response_code - reason for which credit note is issued (CATALOG_09)

  • description - description of reason

  • document_type - should be ‘07’ according CATALOG_01

  • document_number - serial and correlative number of document

  • provider - a SunatInvoice::Provider instance

  • customer - a SunatInvoice::Customer instance

  • signature - a SunatInvoice::Signature instance

  • lines - array of SunatInvoice::CreditNoteLine instances



19
20
21
# File 'lib/sunat_invoice/credit_note.rb', line 19

def description
  @description
end

#ref_document_numberObject

  • date - issued date

  • ref_document_number - serial and number of document affected

  • ref_document_type - type of document affected

  • response_code - reason for which credit note is issued (CATALOG_09)

  • description - description of reason

  • document_type - should be ‘07’ according CATALOG_01

  • document_number - serial and correlative number of document

  • provider - a SunatInvoice::Provider instance

  • customer - a SunatInvoice::Customer instance

  • signature - a SunatInvoice::Signature instance

  • lines - array of SunatInvoice::CreditNoteLine instances



19
20
21
# File 'lib/sunat_invoice/credit_note.rb', line 19

def ref_document_number
  @ref_document_number
end

#ref_document_typeObject

  • date - issued date

  • ref_document_number - serial and number of document affected

  • ref_document_type - type of document affected

  • response_code - reason for which credit note is issued (CATALOG_09)

  • description - description of reason

  • document_type - should be ‘07’ according CATALOG_01

  • document_number - serial and correlative number of document

  • provider - a SunatInvoice::Provider instance

  • customer - a SunatInvoice::Customer instance

  • signature - a SunatInvoice::Signature instance

  • lines - array of SunatInvoice::CreditNoteLine instances



19
20
21
# File 'lib/sunat_invoice/credit_note.rb', line 19

def ref_document_type
  @ref_document_type
end

#response_codeObject

  • date - issued date

  • ref_document_number - serial and number of document affected

  • ref_document_type - type of document affected

  • response_code - reason for which credit note is issued (CATALOG_09)

  • description - description of reason

  • document_type - should be ‘07’ according CATALOG_01

  • document_number - serial and correlative number of document

  • provider - a SunatInvoice::Provider instance

  • customer - a SunatInvoice::Customer instance

  • signature - a SunatInvoice::Signature instance

  • lines - array of SunatInvoice::CreditNoteLine instances



19
20
21
# File 'lib/sunat_invoice/credit_note.rb', line 19

def response_code
  @response_code
end

Instance Method Details

#xmlObject



22
23
24
25
26
27
28
29
30
# File 'lib/sunat_invoice/credit_note.rb', line 22

def xml
  build = build_xml do |xml|
    build_document_data(xml)
    build_discrepancy_response(xml)
    build_billing_reference(xml)
    build_common_content(xml)
  end
  @signature.sign(build.to_xml)
end