Class: ComplyanceSDK::Models::LogicalDocType

Inherits:
Object
  • Object
show all
Defined in:
lib/complyance_sdk/models/logical_doc_type.rb

Overview

Logical document type enumeration for business-level document classification Supports both B2B and B2C tax invoice types with various modifiers

Constant Summary collapse

INVOICE =

Base types

:invoice
CREDIT_NOTE =
:credit_note
DEBIT_NOTE =
:debit_note
RECEIPT =
:receipt
TAX_INVOICE =

B2B Tax Invoice types

:tax_invoice
TAX_INVOICE_CREDIT_NOTE =
:tax_invoice_credit_note
TAX_INVOICE_DEBIT_NOTE =
:tax_invoice_debit_note
TAX_INVOICE_PREPAYMENT =
:tax_invoice_prepayment
TAX_INVOICE_PREPAYMENT_ADJUSTED =
:tax_invoice_prepayment_adjusted
TAX_INVOICE_EXPORT_INVOICE =
:tax_invoice_export_invoice
TAX_INVOICE_EXPORT_CREDIT_NOTE =
:tax_invoice_export_credit_note
TAX_INVOICE_EXPORT_DEBIT_NOTE =
:tax_invoice_export_debit_note
TAX_INVOICE_THIRD_PARTY_INVOICE =
:tax_invoice_third_party_invoice
TAX_INVOICE_SELF_BILLED_INVOICE =
:tax_invoice_self_billed_invoice
TAX_INVOICE_NOMINAL_SUPPLY_INVOICE =
:tax_invoice_nominal_supply_invoice
TAX_INVOICE_SUMMARY_INVOICE =
:tax_invoice_summary_invoice
SIMPLIFIED_TAX_INVOICE =

B2C Simplified Tax Invoice types

:simplified_tax_invoice
SIMPLIFIED_TAX_INVOICE_CREDIT_NOTE =
:simplified_tax_invoice_credit_note
SIMPLIFIED_TAX_INVOICE_DEBIT_NOTE =
:simplified_tax_invoice_debit_note
SIMPLIFIED_TAX_INVOICE_PREPAYMENT =
:simplified_tax_invoice_prepayment
SIMPLIFIED_TAX_INVOICE_PREPAYMENT_ADJUSTED =
:simplified_tax_invoice_prepayment_adjusted
SIMPLIFIED_TAX_INVOICE_EXPORT_INVOICE =
:simplified_tax_invoice_export_invoice
SIMPLIFIED_TAX_INVOICE_EXPORT_CREDIT_NOTE =
:simplified_tax_invoice_export_credit_note
SIMPLIFIED_TAX_INVOICE_EXPORT_DEBIT_NOTE =
:simplified_tax_invoice_export_debit_note
SIMPLIFIED_TAX_INVOICE_THIRD_PARTY_INVOICE =
:simplified_tax_invoice_third_party_invoice
SIMPLIFIED_TAX_INVOICE_SELF_BILLED_INVOICE =
:simplified_tax_invoice_self_billed_invoice
SIMPLIFIED_TAX_INVOICE_NOMINAL_SUPPLY_INVOICE =
:simplified_tax_invoice_nominal_supply_invoice
SIMPLIFIED_TAX_INVOICE_SUMMARY_INVOICE =
:simplified_tax_invoice_summary_invoice
EXPORT_INVOICE =

Country-specific logical types (legacy support)

:export_invoice
EXPORT_CREDIT_NOTE =
:export_credit_note
EXPORT_THIRD_PARTY_INVOICE =
:export_third_party_invoice
THIRD_PARTY_INVOICE =
:third_party_invoice
SELF_BILLED_INVOICE =
:self_billed_invoice
NOMINAL_SUPPLY_INVOICE =
:nominal_supply_invoice
SUMMARY_INVOICE =
:summary_invoice
ALL_TYPES =

All valid logical document types

[
  INVOICE, CREDIT_NOTE, DEBIT_NOTE, RECEIPT,
  TAX_INVOICE, TAX_INVOICE_CREDIT_NOTE, TAX_INVOICE_DEBIT_NOTE,
  TAX_INVOICE_PREPAYMENT, TAX_INVOICE_PREPAYMENT_ADJUSTED,
  TAX_INVOICE_EXPORT_INVOICE, TAX_INVOICE_EXPORT_CREDIT_NOTE, TAX_INVOICE_EXPORT_DEBIT_NOTE,
  TAX_INVOICE_THIRD_PARTY_INVOICE, TAX_INVOICE_SELF_BILLED_INVOICE,
  TAX_INVOICE_NOMINAL_SUPPLY_INVOICE, TAX_INVOICE_SUMMARY_INVOICE,
  SIMPLIFIED_TAX_INVOICE, SIMPLIFIED_TAX_INVOICE_CREDIT_NOTE, SIMPLIFIED_TAX_INVOICE_DEBIT_NOTE,
  SIMPLIFIED_TAX_INVOICE_PREPAYMENT, SIMPLIFIED_TAX_INVOICE_PREPAYMENT_ADJUSTED,
  SIMPLIFIED_TAX_INVOICE_EXPORT_INVOICE, SIMPLIFIED_TAX_INVOICE_EXPORT_CREDIT_NOTE, SIMPLIFIED_TAX_INVOICE_EXPORT_DEBIT_NOTE,
  SIMPLIFIED_TAX_INVOICE_THIRD_PARTY_INVOICE, SIMPLIFIED_TAX_INVOICE_SELF_BILLED_INVOICE,
  SIMPLIFIED_TAX_INVOICE_NOMINAL_SUPPLY_INVOICE, SIMPLIFIED_TAX_INVOICE_SUMMARY_INVOICE,
  EXPORT_INVOICE, EXPORT_CREDIT_NOTE, EXPORT_THIRD_PARTY_INVOICE,
  THIRD_PARTY_INVOICE, SELF_BILLED_INVOICE, NOMINAL_SUPPLY_INVOICE, SUMMARY_INVOICE
].freeze

Class Method Summary collapse

Class Method Details

.adjusted?(type) ⇒ Boolean

Check if logical document type is adjusted type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s an adjusted type



186
187
188
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 186

def adjusted?(type)
  type.to_s.include?('adjusted')
end

.b2b?(type) ⇒ Boolean

Check if logical document type is B2B (tax invoice)

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a B2B type



122
123
124
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 122

def b2b?(type)
  type.to_s.start_with?('tax_invoice')
end

.b2c?(type) ⇒ Boolean

Check if logical document type is B2C (simplified tax invoice)

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a B2C type



130
131
132
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 130

def b2c?(type)
  type.to_s.start_with?('simplified_tax_invoice')
end

.credit_note?(type) ⇒ Boolean

Check if logical document type contains credit note

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a credit note type



106
107
108
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 106

def credit_note?(type)
  type.to_s.include?('credit_note')
end

.debit_note?(type) ⇒ Boolean

Check if logical document type contains debit note

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a debit note type



114
115
116
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 114

def debit_note?(type)
  type.to_s.include?('debit_note')
end

.export?(type) ⇒ Boolean

Check if logical document type is export type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s an export type



138
139
140
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 138

def export?(type)
  type.to_s.include?('export')
end

.from_string(str) ⇒ Symbol

Parse a string to a logical document type symbol

Parameters:

  • str (String)

    The string to parse

Returns:

  • (Symbol)

    The logical document type symbol

Raises:

  • (ArgumentError)

    If the string is invalid



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 82

def from_string(str)
  return str if str.is_a?(Symbol)
  
  type = str.to_s.downcase.gsub(/[^a-z_]/, '_').to_sym
  
  unless valid?(type)
    raise ArgumentError, "Invalid logical document type: #{str}. Valid types: #{ALL_TYPES.join(', ')}"
  end
  
  type
end

.invoice_data_document_type(type) ⇒ String

Get the document type string for invoice_data field

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (String)

    The document type string for invoice_data



216
217
218
219
220
221
222
223
224
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 216

def invoice_data_document_type(type)
  if credit_note?(type)
    'credit_note'
  elsif debit_note?(type)
    'debit_note'
  else
    'tax_invoice'
  end
end

.meta_config_document_type(type) ⇒ String

Get the meta config document type string for a logical type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (String)

    The meta config document type



202
203
204
205
206
207
208
209
210
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 202

def meta_config_document_type(type)
  if credit_note?(type)
    'credit_note'
  elsif debit_note?(type)
    'debit_note'
  else
    'tax_invoice'
  end
end

.nominal_supply?(type) ⇒ Boolean

Check if logical document type is nominal supply type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a nominal supply type



162
163
164
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 162

def nominal_supply?(type)
  type.to_s.include?('nominal_supply')
end

.prepayment?(type) ⇒ Boolean

Check if logical document type is prepayment type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a prepayment type



178
179
180
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 178

def prepayment?(type)
  type.to_s.include?('prepayment')
end

.receipt?(type) ⇒ Boolean

Check if logical document type is receipt type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a receipt type



194
195
196
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 194

def receipt?(type)
  type.to_s.include?('receipt')
end

.self_billed?(type) ⇒ Boolean

Check if logical document type is self billed type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a self billed type



154
155
156
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 154

def self_billed?(type)
  type.to_s.include?('self_billed')
end

.summary?(type) ⇒ Boolean

Check if logical document type is summary type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a summary type



170
171
172
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 170

def summary?(type)
  type.to_s.include?('summary')
end

.third_party?(type) ⇒ Boolean

Check if logical document type is third party type

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (Boolean)

    True if it’s a third party type



146
147
148
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 146

def third_party?(type)
  type.to_s.include?('third_party')
end

.to_string(type) ⇒ String

Convert a logical document type to string format

Parameters:

  • type (Symbol)

    The logical document type

Returns:

  • (String)

    The string representation



98
99
100
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 98

def to_string(type)
  type.to_s.upcase
end

.valid?(type) ⇒ Boolean

Check if a logical document type is valid

Parameters:

  • type (Symbol)

    The logical document type to validate

Returns:

  • (Boolean)

    True if valid, false otherwise



73
74
75
# File 'lib/complyance_sdk/models/logical_doc_type.rb', line 73

def valid?(type)
  ALL_TYPES.include?(type)
end