Class: FE::Document::Summary
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/facturacr/document/summary.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#discount_total ⇒ Object
Returns the value of attribute discount_total.
-
#document_type ⇒ Object
Returns the value of attribute document_type.
-
#exchange_rate ⇒ Object
Returns the value of attribute exchange_rate.
-
#exent_total ⇒ Object
Returns the value of attribute exent_total.
-
#exonerate_total ⇒ Object
Returns the value of attribute exonerate_total.
-
#goods_exent_total ⇒ Object
Returns the value of attribute goods_exent_total.
-
#goods_exonerate_total ⇒ Object
Returns the value of attribute goods_exonerate_total.
-
#goods_taxable_total ⇒ Object
Returns the value of attribute goods_taxable_total.
-
#gross_total ⇒ Object
Returns the value of attribute gross_total.
-
#has_exoneration ⇒ Object
Returns the value of attribute has_exoneration.
-
#medical_services_condition ⇒ Object
Returns the value of attribute medical_services_condition.
-
#net_total ⇒ Object
Returns the value of attribute net_total.
-
#services_exent_total ⇒ Object
Returns the value of attribute services_exent_total.
-
#services_exonerate_total ⇒ Object
Returns the value of attribute services_exonerate_total.
-
#services_taxable_total ⇒ Object
Returns the value of attribute services_taxable_total.
-
#subtotal ⇒ Object
Returns the value of attribute subtotal.
-
#tax_total ⇒ Object
Returns the value of attribute tax_total.
-
#taxable_total ⇒ Object
Returns the value of attribute taxable_total.
-
#total_iva_returned ⇒ Object
Returns the value of attribute total_iva_returned.
-
#total_other_charges ⇒ Object
Returns the value of attribute total_other_charges.
-
#with_credit_card ⇒ Object
Returns the value of attribute with_credit_card.
Attributes inherited from Element
Instance Method Summary collapse
- #build_xml(node, document) ⇒ Object
-
#initialize(args = {}) ⇒ Summary
constructor
A new instance of Summary.
Constructor Details
#initialize(args = {}) ⇒ Summary
Returns a new instance of Summary.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/facturacr/document/summary.rb', line 21 def initialize(args={}) @currency = args[:currency] @exchange_rate = args[:exchange_rate] @services_taxable_total = args[:services_taxable_total].to_f @services_exent_total = args[:services_exent_total].to_f @services_exonerate_total = args[:services_exonerate_total].to_f @goods_taxable_total = args[:goods_taxable_total].to_f @goods_exent_total = args[:goods_exent_total].to_f @goods_exonerate_total = args[:goods_exonerate_total].to_f @taxable_total = args[:taxable_total].to_f @exent_total = args[:exent_total].to_f @exonerate_total = args[:exonerate_total].to_f @subtotal = args[:subtotal].to_f @discount_total = args[:discount_total].to_f @gross_total = args[:gross_total].to_f @tax_total = args[:tax_total].to_f @total_iva_returned = args[:total_iva_returned].to_f @total_other_charges = args[:total_other_charges].to_f @net_total = args[:net_total].to_f @has_exoneration = args[:has_exoneration] || false @medical_services_condition = args[:medical_services_condition] || false end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def currency @currency end |
#discount_total ⇒ Object
Returns the value of attribute discount_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def discount_total @discount_total end |
#document_type ⇒ Object
Returns the value of attribute document_type.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def document_type @document_type end |
#exchange_rate ⇒ Object
Returns the value of attribute exchange_rate.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def exchange_rate @exchange_rate end |
#exent_total ⇒ Object
Returns the value of attribute exent_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def exent_total @exent_total end |
#exonerate_total ⇒ Object
Returns the value of attribute exonerate_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def exonerate_total @exonerate_total end |
#goods_exent_total ⇒ Object
Returns the value of attribute goods_exent_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def goods_exent_total @goods_exent_total end |
#goods_exonerate_total ⇒ Object
Returns the value of attribute goods_exonerate_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def goods_exonerate_total @goods_exonerate_total end |
#goods_taxable_total ⇒ Object
Returns the value of attribute goods_taxable_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def goods_taxable_total @goods_taxable_total end |
#gross_total ⇒ Object
Returns the value of attribute gross_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def gross_total @gross_total end |
#has_exoneration ⇒ Object
Returns the value of attribute has_exoneration.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def has_exoneration @has_exoneration end |
#medical_services_condition ⇒ Object
Returns the value of attribute medical_services_condition.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def medical_services_condition @medical_services_condition end |
#net_total ⇒ Object
Returns the value of attribute net_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def net_total @net_total end |
#services_exent_total ⇒ Object
Returns the value of attribute services_exent_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def services_exent_total @services_exent_total end |
#services_exonerate_total ⇒ Object
Returns the value of attribute services_exonerate_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def services_exonerate_total @services_exonerate_total end |
#services_taxable_total ⇒ Object
Returns the value of attribute services_taxable_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def services_taxable_total @services_taxable_total end |
#subtotal ⇒ Object
Returns the value of attribute subtotal.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def subtotal @subtotal end |
#tax_total ⇒ Object
Returns the value of attribute tax_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def tax_total @tax_total end |
#taxable_total ⇒ Object
Returns the value of attribute taxable_total.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def taxable_total @taxable_total end |
#total_iva_returned ⇒ Object
Returns the value of attribute total_iva_returned.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def total_iva_returned @total_iva_returned end |
#total_other_charges ⇒ Object
Returns the value of attribute total_other_charges.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def total_other_charges @total_other_charges end |
#with_credit_card ⇒ Object
Returns the value of attribute with_credit_card.
6 7 8 |
# File 'lib/facturacr/document/summary.rb', line 6 def with_credit_card @with_credit_card end |
Instance Method Details
#build_xml(node, document) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/facturacr/document/summary.rb', line 44 def build_xml(node, document) @document = document @document_type = document.document_type raise FE::Error.new("summary invalid: #{ errors..map{|k,v| "#{k}=#{v.join(". ")}"}.join("; ")}",class: self.class, messages: errors.) unless valid? node = Nokogiri::XML::Builder.new if node.nil? node.ResumenFactura do |xml| if document.version_42? xml.CodigoMoneda @currency if @currency.present? xml.TipoCambio @exchange_rate if @exchange_rate.present? elsif document.version_43? && @currency.present? #&& @currency != "CRC" xml.CodigoTipoMoneda do |x| x.CodigoMoneda @currency x.TipoCambio @exchange_rate || 1 end end xml.TotalServGravados @services_taxable_total xml.TotalServExentos @services_exent_total xml.TotalServExonerado @services_exonerate_total if @services_exonerate_total && document.version_43? && !document_type.eql?(FE::ExportInvoice::DOCUMENT_TYPE) xml.TotalMercanciasGravadas @goods_taxable_total xml.TotalMercanciasExentas @goods_exent_total xml.TotalMercExonerada @goods_exonerate_total if @goods_exonerate_total.present? && document.version_43? && !document_type.eql?(FE::ExportInvoice::DOCUMENT_TYPE) xml.TotalGravado @taxable_total xml.TotalExento @exent_total xml.TotalExonerado @exonerate_total if @exonerate_total.present? && document.version_43? && !document_type.eql?(FE::ExportInvoice::DOCUMENT_TYPE) xml.TotalVenta @subtotal xml.TotalDescuentos @discount_total xml.TotalVentaNeta @gross_total xml.TotalImpuesto @tax_total if document.version_43? xml.TotalIVADevuelto @total_iva_returned if @medical_services_condition && !document_type.eql?(FE::ExportInvoice::DOCUMENT_TYPE) && !document_type.eql?(FE::PurchaseInvoice::DOCUMENT_TYPE) xml.TotalOtrosCargos @total_other_charges if @total_other_charges > 0 end xml.TotalComprobante @net_total end end |