Class: SunatInvoice::TradeDocument

Inherits:
XmlDocument show all
Includes:
TradeCalculations
Defined in:
lib/sunat_invoice/trade_document.rb

Direct Known Subclasses

CreditNote, Invoice

Constant Summary collapse

INVOICE_TYPES =
%w[01 03].freeze

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 XmlDocument

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

Instance Method Summary collapse

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_lines_xml, #build_number, #build_xml, #formatted_date

Methods included from Utils

#amount_xml, #ubl_ext

Methods inherited from Model

#to_hash

Constructor Details

#initialize(*args) ⇒ TradeDocument

Returns a new instance of TradeDocument.



23
24
25
26
# File 'lib/sunat_invoice/trade_document.rb', line 23

def initialize(*args)
  super(*args)
  @signature ||= SunatInvoice::Signature.new(provider: @provider)
end

Instance Attribute Details

#customerObject

Returns the value of attribute customer.



10
11
12
# File 'lib/sunat_invoice/trade_document.rb', line 10

def customer
  @customer
end

#discountObject

Returns the value of attribute discount.



10
11
12
# File 'lib/sunat_invoice/trade_document.rb', line 10

def discount
  @discount
end

#document_numberObject

Returns the value of attribute document_number.



10
11
12
# File 'lib/sunat_invoice/trade_document.rb', line 10

def document_number
  @document_number
end

#document_typeObject

Returns the value of attribute document_type.



10
11
12
# File 'lib/sunat_invoice/trade_document.rb', line 10

def document_type
  @document_type
end

#sale_totalsObject (readonly)

a hash with totals without taxes for any kind of sale



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

def sale_totals
  @sale_totals
end

#taxes_totalsObject (readonly)

a hash with taxes totals by tax type



16
17
18
# File 'lib/sunat_invoice/trade_document.rb', line 16

def taxes_totals
  @taxes_totals
end

#totalObject (readonly)

total for document (sale totals + taxes - discounts)



13
14
15
# File 'lib/sunat_invoice/trade_document.rb', line 13

def total
  @total
end

Instance Method Details

#document_nameObject



32
33
34
# File 'lib/sunat_invoice/trade_document.rb', line 32

def document_name
  "#{@provider.ruc}-#{document_type}-#{document_number}"
end

#operationObject



28
29
30
# File 'lib/sunat_invoice/trade_document.rb', line 28

def operation
  :send_bill
end