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
-
.all ⇒ Array<Symbol>
Get all valid document types.
-
.normalize(document_type) ⇒ Symbol?
Convert string to document type symbol.
-
.valid?(document_type) ⇒ Boolean
Check if a document type is valid.
Class Method Details
.all ⇒ Array<Symbol>
Get 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
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
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 |