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