Sha256: dde716390ed95ce39d8d19635796b28fb744160f778c09ab792d15d51ca5b8c9

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

module Einvoice
  module Tradevan
    module Model
      class VoidData < Base
        VALID_OPTIONS_KEYS = [
          :type,
          :saleIdentifier,
          :invoiceNumber,
          :invoicePaperReturned,
          :allowanceNumber,
          :allowancePaperReturned,
          :companyUn
        ].freeze

        attr_accessor *VALID_OPTIONS_KEYS

        validates :type, presence: true, length: { is: 1 }, inclusion: { in: %w(C I A) }

        # Type C I
        validates :saleIdentifier, presence: true, length: { maximum: 100 }, if: proc { %w(C I).include?(self.type) }
        validates :invoiceNumber, presence: true, length: { is: 10 }, if: proc { %w(C I).include?(self.type) }
        validates :invoicePaperReturned, presence: true, length: { maximum: 1 }, inclusion: { in: %w(Y N) }, if: proc { %w(C I).include?(self.type) }

        # Type A
        validates :companyUn, presence: true, length: { is: 8 }, if: proc { self.type == 'A' }
        validates :allowanceNumber, presence: true, length: { is: 16 }, if: proc { self.type == 'A' }
        validates :allowancePaperReturned, presence: true, length: { is: 1 }, inclusion: { in: %w(Y N) }, if: proc { self.type == 'A' }

        def payload
          serializable_hash(except: [:errors, :validation_context, :itemList])
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
einvoice-1.2.22 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.21 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.20 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.19 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.18 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.17 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.16 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.15 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.14 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.13 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.12 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.11 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.10 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.9 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.8 lib/einvoice/tradevan/model/void_data.rb
einvoice-1.2.7 lib/einvoice/tradevan/model/void_data.rb