Module: ComplyanceSDK::Models::DocumentType

Defined in:
lib/complyance_sdk/models/document_type.rb

Overview

Document type enumeration

Constant Summary collapse

TAX_INVOICE =

Tax invoice document type

:tax_invoice
CREDIT_NOTE =

Credit note document type

:credit_note
DEBIT_NOTE =

Debit note document type

:debit_note

Class Method Summary collapse

Class Method Details

.allArray<Symbol>

Get all valid document types

Returns:

  • (Array<Symbol>)

    All valid document types



19
20
21
# File 'lib/complyance_sdk/models/document_type.rb', line 19

def self.all
  [TAX_INVOICE, CREDIT_NOTE, DEBIT_NOTE]
end

.normalize(document_type) ⇒ Symbol?

Convert string to document type symbol

Parameters:

  • document_type (String, Symbol)

    The document type

Returns:

  • (Symbol, nil)

    The document type symbol or nil if invalid



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/complyance_sdk/models/document_type.rb', line 36

def self.normalize(document_type)
  return nil if document_type.nil?
  
  case document_type.to_s.downcase.gsub(/[-_\s]/, '')
  when "taxinvoice", "invoice"
    TAX_INVOICE
  when "creditnote", "credit"
    CREDIT_NOTE
  when "debitnote", "debit"
    DEBIT_NOTE
  else
    document_type.to_sym if valid?(document_type)
  end
end

.valid?(document_type) ⇒ Boolean

Check if a document type is valid

Parameters:

  • document_type (Symbol, String)

    The document type to check

Returns:

  • (Boolean)

    True if valid, false otherwise



27
28
29
30
# File 'lib/complyance_sdk/models/document_type.rb', line 27

def self.valid?(document_type)
  return false if document_type.nil?
  all.include?(document_type.to_sym)
end