Sha256: e9eb1e31a01126ccc55a530bea90d8f3448f99b3363757f1021764342c303412

Contents?: true

Size: 774 Bytes

Versions: 9

Compression:

Stored size: 774 Bytes

Contents

require 'pp'
module Logistics
  module Core
    class ReferenceNumber < ApplicationRecord

      def self.ref_num
        reference_number = self.find_by_reference_type('Quotation Request')
        year = DateTime.now.strftime('%Y')
        company = "MA"
        acro = reference_number.prefix
        number = reference_number.next_no
        if number <= 9
          number_str = "000" + number.to_s
        elsif number <= 99
          number_str = "00" + number.to_s
        elsif number <= 999
          number_str = "0" + number.to_s
        else
          number_str = number.to_s
        end
        reference_number.next_no = reference_number.next_no + 1
        reference_number.save
        [company,acro, number_str, year].join "/"
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/models/logistics/core/reference_number.rb
logistics_core-21.11.1 app/models/logistics/core/reference_number.rb
logistics_core-21.08.1 app/models/logistics/core/reference_number.rb
logistics_core-21.03.1 app/models/logistics/core/reference_number.rb
logistics_core-20.10.3 app/models/logistics/core/reference_number.rb
logistics_core-20.10.2 app/models/logistics/core/reference_number.rb
logistics_core-20.10.1 app/models/logistics/core/reference_number.rb
logistics_core-20.9.1 app/models/logistics/core/reference_number.rb
logistics_core-20.8.1 app/models/logistics/core/reference_number.rb