Class: TqlOtrFactoringDataExchange::InvoiceStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/invoice_status.rb

Overview

Processing and payment status of an invoice. The lifecycle typically flows: ‘Received` → `Validating` → `Processing` → `Approved` → `NotPaid` → `Paid`. Branches include `AwaitingDocuments`, `PendingExceptions`, and `Rejected`.

Constant Summary collapse

INVOICE_STATUS =
[
  # TODO: Write general description for RECEIVED
  RECEIVED = 'Received'.freeze,

  # TODO: Write general description for VALIDATING
  VALIDATING = 'Validating'.freeze,

  # TODO: Write general description for PROCESSING
  PROCESSING = 'Processing'.freeze,

  # TODO: Write general description for AWAITINGDOCUMENTS
  AWAITINGDOCUMENTS = 'AwaitingDocuments'.freeze,

  # TODO: Write general description for PENDINGEXCEPTIONS
  PENDINGEXCEPTIONS = 'PendingExceptions'.freeze,

  # TODO: Write general description for APPROVED
  APPROVED = 'Approved'.freeze,

  # TODO: Write general description for NOTPAID
  NOTPAID = 'NotPaid'.freeze,

  # TODO: Write general description for PAID
  PAID = 'Paid'.freeze,

  # TODO: Write general description for PARTIALLYPAID
  PARTIALLYPAID = 'PartiallyPaid'.freeze,

  # TODO: Write general description for COMPLETE
  COMPLETE = 'Complete'.freeze,

  # TODO: Write general description for REJECTED
  REJECTED = 'Rejected'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = RECEIVED) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_status.rb', line 52

def self.from_value(value, default_value = RECEIVED)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'received' then RECEIVED
  when 'validating' then VALIDATING
  when 'processing' then PROCESSING
  when 'awaitingdocuments' then AWAITINGDOCUMENTS
  when 'pendingexceptions' then PENDINGEXCEPTIONS
  when 'approved' then APPROVED
  when 'notpaid' then NOTPAID
  when 'paid' then PAID
  when 'partiallypaid' then PARTIALLYPAID
  when 'complete' then COMPLETE
  when 'rejected' then REJECTED
  else
    default_value
  end
end

.validate(value) ⇒ Object



46
47
48
49
50
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_status.rb', line 46

def self.validate(value)
  return false if value.nil?

  INVOICE_STATUS.include?(value)
end