Sha256: ce059400c7247d2b4e5314cdfd50938078b3f7b9484dd9743d7d789d8770de4a

Contents?: true

Size: 612 Bytes

Versions: 55

Compression:

Stored size: 612 Bytes

Contents

module Comee
  module Core
    class Util
      # This method generates document numbers with a certain prefix
      # and a serial suffix
      def self.generate_number(clz, field)
        clz_hash = {
          "PurchaseRequisition" => "PR",
          "PurchaseOrder" => "PO",
          "Invoice" => "IN",
          "SalesOrder" => "SO"
        }
        clazz_name = "Comee::Core::#{clz}"
        clazz = clazz_name.constantize
        last = clazz.last

        return "#{clz_hash[clz]}1" unless last

        num = last.send(field)[2..].to_i
        "#{clz_hash[clz]}#{num + 1}"
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
comee_core-0.3.13 app/utils/comee/core/util.rb
comee_core-0.3.12 app/utils/comee/core/util.rb
comee_core-0.3.11 app/utils/comee/core/util.rb
comee_core-0.3.10 app/utils/comee/core/util.rb
comee_core-0.3.9 app/utils/comee/core/util.rb
comee_core-0.3.8 app/utils/comee/core/util.rb
comee_core-0.3.7 app/utils/comee/core/util.rb
comee_core-0.3.6 app/utils/comee/core/util.rb
comee_core-0.3.5 app/utils/comee/core/util.rb
comee_core-0.3.4 app/utils/comee/core/util.rb
comee_core-0.3.3 app/utils/comee/core/util.rb
comee_core-0.3.2 app/utils/comee/core/util.rb
comee_core-0.3.1 app/utils/comee/core/util.rb
comee_core-0.3.0 app/utils/comee/core/util.rb
comee_core-0.2.99 app/utils/comee/core/util.rb
comee_core-0.2.98 app/utils/comee/core/util.rb
comee_core-0.2.97 app/utils/comee/core/util.rb
comee_core-0.2.96 app/utils/comee/core/util.rb
comee_core-0.2.95 app/utils/comee/core/util.rb
comee_core-0.2.94 app/utils/comee/core/util.rb