Class: VendorDocument

Inherits:
Object show all
Defined in:
lib/models/vendor_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#doc_typeObject

helper accessors for creating vendor document filename_prefix helps set up the path to the document



8
9
10
# File 'lib/models/vendor_document.rb', line 8

def doc_type
  @doc_type
end

#doc_type_valueObject

helper accessors for creating vendor document filename_prefix helps set up the path to the document



8
9
10
# File 'lib/models/vendor_document.rb', line 8

def doc_type_value
  @doc_type_value
end

#file_nameObject

helper accessors for creating vendor document filename_prefix helps set up the path to the document



8
9
10
# File 'lib/models/vendor_document.rb', line 8

def file_name
  @file_name
end

#file_name_prefixObject

helper accessors for creating vendor document filename_prefix helps set up the path to the document



8
9
10
# File 'lib/models/vendor_document.rb', line 8

def file_name_prefix
  @file_name_prefix
end

Instance Method Details

#after_initializeObject



21
22
23
24
25
26
# File 'lib/models/vendor_document.rb', line 21

def after_initialize
  if new?
    set_kids
    set_other_vars
  end
end

#next_kid_multObject



36
37
38
39
# File 'lib/models/vendor_document.rb', line 36

def next_kid_mult
  vd = VendorDocument.filter(:kid_date=>kid_date,:kid_time=>kid_time).order(:kid_mult).last
  (vd and vd.kid_mult < 255) ? vd.kid_mult+1 : 0
end

#set_kidsObject



28
29
30
31
32
33
34
# File 'lib/models/vendor_document.rb', line 28

def set_kids
  self.kid_date=Date.today.to_fos_days
  self.kid_time=Time.now.as_minutes
  self.kid_comm=0
  self.kid_mult=next_kid_mult
  self.kid_user="ADMN"
end

#set_other_varsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/models/vendor_document.rb', line 41

def set_other_vars
  self.doc_date =
    case doc_date
      when String then Date.parse(doc_date).to_fos_days
      when Date then doc_date.to_fos_days
      else Date.today.to_fos_days
    end
  self.renew_days= 0
  self.category= 0
  self.cost= 0
  self.status_code= 0
  self.acct_number= ""
  self.paid_date= 0
  self.paid= 0
  self.billed_date= 0
  self.image_name= File.join(file_name_prefix, file_name) if file_name 
  self.document_type= doc_type_value if Code.valid_value_for_group?(doc_type_value, :aircraft_document)
end

#validateObject



17
18
19
# File 'lib/models/vendor_document.rb', line 17

def validate
  validates_presence [:document_type, :image_name, :number, :doc_date, :document_type]
end