-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestGetRoutingCode.pl
More file actions
executable file
·148 lines (118 loc) · 4.08 KB
/
testGetRoutingCode.pl
File metadata and controls
executable file
·148 lines (118 loc) · 4.08 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/etrade/pkgs/linux/intel/perl/5.8.0/bin/perl -w
#
# play code to get the routing code from the
# financial inst. number
#
use strict;
use DBI;
use Env;
Env::import();
use Date::Calc qw(:all);
use et_db;
use lib "/etrade/pkgs/linux/intel/bfw_core/2.7.2/lib/";
#
#
# Setup all the vars we need fromt he etrade environment
#
my $logicalDBName = "UsAccountDB_rpt";
my $logicalDBServer = "USDTPRD";
my $inst = "68095050";
#my $inst = "2583751019";
#my $inst = "236203050";
my $etEnv = $ENV{"ET_ENVIRONMENT"};
# Comment the following for PRD, and uncomment the line after
$ENV{"WSNADDR"} = `/etrade/bin/etproperties -p WSNADDR`;
my $wsnAddr = $ENV{"WSNADDR"};
my $etLogicalHost = `/etrade/bin/etproperties -p DB_DOMAIN`;
chomp($etLogicalHost);
$ENV{"ET_LOGICAL_HOST"} = $etLogicalHost;
if (!$wsnAddr) { exit; }
if (!$etLogicalHost) { exit; }
my $dbServer="";
my $dbName="";
my $dbUser="";
my $dbPassword="";
#
# This checks if we're in a DEV environment or not
#
if ($etEnv eq "dev") {
$dbServer = "UATUSS5";
$dbName = "UsAccountDB";
$dbUser = "tuxuser";
$dbPassword = "tuxedo";
}
else {
($dbServer,$dbName,$dbUser,$dbPassword) = et_db::get_db_info($logicalDBName, $logicalDBServer);
}
sub GetOldRoutingNumber {
my $finInst = $_[0];
my $dbh = $_[1];
my $oldRoutingNum = "default";
my $sql = "SELECT cmod.Attrib_Value LE_ROUTING_NUM FROM UsLegalEntityDB..CM_Organization_Detail cmod WHERE cmod.Legal_Entity_Id = $finInst AND cmod.Attrib_Type = 'ROUTING_NUM'";
# output to xml
my $response = et_db::output_select_to_xml ($dbh, $sql, "OLD_ROUTING_CODE");
# print "$response\n";
if ($response =~ m/.*<LE_ROUTING_NUM>(.*)<\/LE_ROUTING_NUM>.*/) {
my $leRoutingNum = $1;
# print "LE_ROUTING_NUM:\t$leRoutingNum\n";
$oldRoutingNum = $leRoutingNum;
} else {
my $sql2 = "SELECT cmod.Attrib_Value SWIFT_CODE FROM UsLegalEntityDB..CM_Organization_Detail cmod WHERE cmod.Legal_Entity_Id = $finInst AND cmod.Attrib_Type = 'SWIFT_CODE'";
# output to xml
my $response2 = et_db::output_select_to_xml ($dbh, $sql2, "OLD_SWIFT_CODE");
# print "$response2\n";
$response2 =~ m/.*<SWIFT_CODE>(.*)<\/SWIFT_CODE>.*/;
my $swiftCode = $1;
# print "SWIFT_CODE:\t$swiftCode\n";
if ($swiftCode !~ m/^$/) {
$oldRoutingNum = $swiftCode;
}
}
return $oldRoutingNum;
}
sub GetNewerRoutingNumber {
my $oldRoutingNum = $_[0];
my $dbh = $_[1];
my $newerRoutingNum = "default";
my $sql = "SELECT cmrx.NewRoutingNo NEW_ROUTING_NUM FROM UsLegalEntityDB..CM_Routing_Xlation cmrx WHERE cmrx.OldRoutingNo = \"$oldRoutingNum\"";
# output to xml
my $response = et_db::output_select_to_xml ($dbh, $sql, "NEWER_ROUTING_CODE");
# print "$response\n";
if ($response =~ m/.*<NEW_ROUTING_NUM>(.*)<\/NEW_ROUTING_NUM>.*/) {
my $newRoutingNum = $1;
# print "NEW_ROUTING_NUM:\t$newRoutingNum\n";
my $sql2 = "SELECT cmrx.Status STATUS FROM UsLegalEntityDB..CM_Routing_Xlation cmrx WHERE cmrx.OldRoutingNo = \"$oldRoutingNum\"";
# output to xml
my $response2 = et_db::output_select_to_xml ($dbh, $sql2, "NEWER_STATUS");
# print "$response2\n";
$response2 =~ m/.*<STATUS>(.*)<\/STATUS>.*/;
my $status = $1;
# print "STATUS:\t$status\n";
if (($newRoutingNum !~ m/^$/) &&
($status =~ m/^0$/)) {
$newerRoutingNum = $newRoutingNum;
}
}
return $newerRoutingNum;
}
# open a connection to the DB
#
my $dbh = et_db::connect_to_sybase($dbServer, $dbName , $dbUser, $dbPassword);
unless (defined $dbh)
{
die "Could not connect to $dbName\n.";
}
#my $leRoutingNum = "063114386";
my $leRoutingNum = GetOldRoutingNumber($inst, $dbh);
my $finalRoutingNum = $leRoutingNum;
my $newRoutingNum = "default";
my $done = "false";
while ($done =~ m/^false$/) {
$newRoutingNum = GetNewerRoutingNumber($finalRoutingNum, $dbh);
if ($newRoutingNum =~ m/^default$/) {
$done = "true";
} else {
$finalRoutingNum = $newRoutingNum;
}
}
print "Final Routing Number:\t$finalRoutingNum\n";