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.33 app/utils/comee/core/util.rb
comee_core-0.3.32 app/utils/comee/core/util.rb
comee_core-0.3.31 app/utils/comee/core/util.rb
comee_core-0.3.30 app/utils/comee/core/util.rb
comee_core-0.3.29 app/utils/comee/core/util.rb
comee_core-0.3.28 app/utils/comee/core/util.rb
comee_core-0.3.27 app/utils/comee/core/util.rb
comee_core-0.3.26 app/utils/comee/core/util.rb
comee_core-0.3.25 app/utils/comee/core/util.rb
comee_core-0.3.24 app/utils/comee/core/util.rb
comee_core-0.3.23 app/utils/comee/core/util.rb
comee_core-0.3.22 app/utils/comee/core/util.rb
comee_core-0.3.21 app/utils/comee/core/util.rb
comee_core-0.3.20 app/utils/comee/core/util.rb
comee_core-0.3.19 app/utils/comee/core/util.rb
comee_core-0.3.18 app/utils/comee/core/util.rb
comee_core-0.3.17 app/utils/comee/core/util.rb
comee_core-0.3.16 app/utils/comee/core/util.rb
comee_core-0.3.15 app/utils/comee/core/util.rb
comee_core-0.3.14 app/utils/comee/core/util.rb