-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransferPending.rb
63 lines (56 loc) · 2.07 KB
/
TransferPending.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module TransferPending
class TransferPending
require 'date'
class << self
def weekend(date)
if date.wday == 0
return date + 1
elsif date.wday == 6
return date - 1
else
return date
end
end
def insert (billDates)
File.open('output.txt','a') do |file|
file.puts "INSERT INTO #{billDates[:table]}"
file.puts "VALUES ('#{billDates[:accountID]}'"
file.puts " ,'#{billDates[:referenceDate].strftime('%m/%d/%Y')}'"
file.puts " ,'#{billDates[:startDueDate].strftime('%m/%d/%Y')}'"
file.puts " ,'#{billDates[:startDueDate].strftime('%m/%d/%Y')}'"
file.puts " ,'#{billDates[:invoiceDate].strftime('%m/%d/%Y')}'"
file.puts " ,'S'"
file.puts " ,'N'"
file.puts " ,' '"
file.puts " ,'Y'"
file.puts " ,'N'"
file.puts " ,' ')"
file.puts ";"
end
end
def update (billDates)
File.open('output.txt', 'a') do |file|
file.puts "UPDATE"
file.puts " #{billDates[:table]}"
file.puts "SET BIL_ADJ_DUE_DT = '#{billDates[:startDueDate].strftime('%m/%d/%Y')}'"
file.puts ", BIL_INV_DT = '#{billDates[:invoiceDate].strftime('%m/%d/%Y')}'"
file.puts "WHERE BIL_ACCOUNT_ID = '#{billDates[:accountID]}'"
file.puts "AND BIL_REFERENCE_DT = '#{billDates[:referenceDate].strftime('%m/%d/%Y')}'"
file.puts ";"
end
end
def select (billDates)
File.open('output.txt', 'a') do |file|
file.puts "SELECT *"
file.puts "FROM #{billDates[:table]}"
file.puts "WHERE BIL_ACCOUNT_ID = '#{billDates[:accountID]}'"
file.puts "AND BIL_REFERENCE_DT = '#{billDates[:referenceDate].strftime('%m/%d/%Y')}'" if billDates[:update]
file.puts ";"
end
end
def increment (date)
date>>(1)
end
end
end
end