Class: VertexClient::Payload::Invoice

Inherits:
Quotation show all
Defined in:
lib/vertex_client/payloads/invoice.rb

Direct Known Subclasses

DistributeTax

Constant Summary collapse

DOCUMENT_NUMBER_LIMIT =
40

Constants inherited from Quotation

Quotation::SALE_TRANSACTION_TYPE

Instance Attribute Summary

Attributes inherited from Base

#params

Instance Method Summary collapse

Methods inherited from Base

#initialize, #transform

Constructor Details

This class inherits a constructor from VertexClient::Payload::Base

Instance Method Details

#bodyObject



13
14
15
16
17
18
# File 'lib/vertex_client/payloads/invoice.rb', line 13

def body
  super.merge({
     :'@documentNumber' => params[:document_number],
     :'@documentDate'   => params[:date]
   })
end

#document_number_missing?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/vertex_client/payloads/invoice.rb', line 20

def document_number_missing?
  params[:document_number].to_s.empty?
end

#document_number_too_long?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/vertex_client/payloads/invoice.rb', line 24

def document_number_too_long?
  params[:document_number].to_s.length > DOCUMENT_NUMBER_LIMIT
end

#validate!Object



7
8
9
10
11
# File 'lib/vertex_client/payloads/invoice.rb', line 7

def validate!
  super
  raise VertexClient::ValidationError.new('document_number is required for invoice') if document_number_missing?
  raise VertexClient::ValidationError.new("document_number must be less than or equal to #{DOCUMENT_NUMBER_LIMIT} characters") if document_number_too_long?
end