Sha256: 9ed517226a8662d7d58c2fbae07df9c6f02a9afee8d007797389b757cba76018
Contents?: true
Size: 911 Bytes
Versions: 28
Compression:
Stored size: 911 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, prefix, sep = nil, start = 1) # clz_hash = { # "PurchaseRequisition" => "PR", # "PurchaseOrder" => "PO", # "Invoice" => "IN", # "SalesOrder" => "SO", # "DeliveryNote" => "DN" # } clazz_name = "Comee::Core::#{clz}" clazz = clazz_name.constantize last = clazz.last return "#{prefix}#{sep}#{start}" unless last index = prefix.length val = last.send(field) pref = val.slice(0, index) suff = sep ? val.slice(index + 1, val.length).to_i : val.slice(index, val.length).to_i return "#{prefix}#{sep}#{start}" unless prefix == pref "#{prefix}#{sep}#{suff + 1}" end end end end
Version data entries
28 entries across 28 versions & 1 rubygems