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