SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
#!/opt/local/bin/perl


#10/20/04 use this to create report of individual fund.
#will report all transactions for specified fund,
#plus summary of fund plus expenditures and commitments
#for specified range.
#insert fund code, fromdate and todate

#01/14/2005 include line number in report to fix problem
#where commitments for different copie of the same order
#were getting sorted out. Also, send output to funds2
#instead of funds

#01/20/2005 initialize $place for each fund transaction read

#03/17/05 count commitment and expenditure totals for each fund
#for each period after sorting has
#taken place. If counting is done in subroutines, if there are
#duplicate lines the sum will not be accurate. A duplicate line
#can occur because one fund transaction can lead to retrieving
#multiple line items, and another fund transaction can retrieve
#some of these same line items, which is why we are sort uniqing
#the report before printing

#05/26/05 get rid of bad characters in title. Might prevent
#records from displaying in Excel spreadsheet


#07/01/05 if total expenditures don't match what's in fund table
#(because Endeavor recalculated fund totals without deleting
#bad lines from fund transaction table), use what's in table
# and write discrepancy to report.

#7/13/05 USE THIS PGM FOR NEW LEDGER CUL07.   SEND OUTPUT TO FUNDS
DIRECTORY
#INSTEAD OF FUNDS2

#05/26/06 sort fund transactions by yyyymmddhhmiss to account for
transactions
#done the same day

#7/13/07 use webdirectory funds3 for CUL07

#7/6/07 new ledger CUL08, use webdir funds4

#7/30/2007 use webdir funds5.    problem with funds4

#07/14/2008 use webdir funds6.   new ledger CUL09

#02/20/2009 get funds for CU or HS ledgers

#07/07/2009 new CUL10 and HSL910 ledgers, and webdir fund7
#07/07/2010 new 10/11 ledgers and webdir funds8

#09/13/2010 add ledger name and note field and piece identifier to xls
file, for google calendar

#05/02/2011 add barnard ledger
#05/05/2011 take barnard out, as per Joyce

#7/7/2011 new cul11/12 ledger and funds9


#$fromdate = '20041116';
#$todate = '20041130';
#$fundcode = '2625B';

$fundcode = $ARGV[0];
$fromdate = $ARGV[1];
$todate = $ARGV[2];



#$disprange =
substr($fromdate,4,2).substr($fromdate,6,2).substr($fromdate,2,2)."-
".substr($todate,4,2).substr($todate,6,2).substr($todate,2,2);

$disprange = "$fromdate-$todate";

print "disprange is $disprangen";

@now = localtime;
$year = ($now[5]+1900);
$month = ($now[4]+1);
$day = ($now[3]);

$fmtday = sprintf("%02d", $day);
$fmtmonth = sprintf("%02d", $month);
$today = "$fmtmonth$fmtday$year.rpt";
$todayrun = "$year$fmtmonth$fmtday";
$place = .01;   #initialize decimal place

BEGIN {
    $ENV{TWO_TASK} = "VGER";
    $ENV{ORACLE_HOME} = "/opt/oracle-9.2";
}

use MARC::Record;
use MARC::Field;
use MARC::Batch;

use DBI;

$database = "COLUMBIADB";
$dbh = DBI-
>connect("dbi:Oracle:",'READ_ONLY_USERNAME','READ_ONLY_PASSWORD')
    || die("could not open $database"). DBI->errstr;
                    #creates database object in handle $dbh. this
                    #represents the connection


$webdir =
"/wwws/data/cu/libraries/inside/clio/statistics/acquisitions/fundcode";
$dir = "/m1/clioprod/ocken/fundrpt";
$title = "FUND ACTIVITY REPORT";
$title2 = "FISCAL YEAR 11/12";
#$title2 = " ";

$fmtdate = "$fmtmonth-$fmtday-$year";


$hdrtxt = "ORDER #        DATE     BRIEF TITLE                        PO LN
# PUB PLACE      CNTRY TRANSACTION       USD AMT   INVOICE     OPID
VENDOR    ORIGINAL CURRENCY";


open (FUNDHDR,">$dir/$fundcode.$disprange.$today.TXT");
write FUNDHDR;
close FUNDHDR;
open FUNDTXT,">$dir/fund.text.$today";

open (FUNDRPT,">>$dir/$fundcode.$disprange.$today.TXT");

system("rm $dir/$fundcode.$disprange.$today.XLS");
open FUNDXLS,">$dir/$fundcode.$disprange.$today.fundrpt.XLS";
open FUNDSHEET,">>$dir/$fundcode.$disprange.$today.XLS";
print FUNDSHEET "FUNDCODEtPURCHASE ORDERtTRANSACTION DATEtTITLEtPO
LINE #tPUB PLACEtPLACE CODEtTRANS TYPEtUSD PRICEtINVOICE
NO.tOPIDtVENDORtORIGINAL CURRENCYtORIGINAL PRICEtLEDGERtVENDOR
NAMEtINVOICE PIECE IDENTIFIERtNOTEn";


$savinstid = "";




#now select funds FOR LEDGER CUL 11 (ledger 29)   OR LEDGER HS11/12
(ledger 30)

$sql = "SELECT DISTINCT FUND_TRANSACTION.TRANS_TYPE,
               FUND_TRANSACTION.AMOUNT,
TO_CHAR(FUND_TRANSACTION.TRANS_DATE,'yyyymmdd'),
               FUND_TRANSACTION.TRANS_DATE,
               FUND_TRANSACTION.OPERATOR_ID,
               FUND_TRANSACTION.REFERENCE_NO,FUND_TRANSACTION.NOTE,
               FUND.INSTITUTION_FUND_ID, FUND.FUND_NAME, FUND.FUND_CODE,
FUND.FUND_ID, FUND.EXPENDITURES,
                 LEDGER.LEDGER_NAME

        FROM   $database.FUND_TRANSACTION, $database.FUND
,$database.LEDGER
        WHERE FUND.FUND_CODE = '$fundcode' AND
        FUND.FUND_ID = FUND_TRANSACTION.FUND_ID AND
           ( FUND.LEDGER_ID = '29' OR FUND.LEDGER_ID = '30') AND
        FUND.LEDGER_ID = FUND_TRANSACTION.LEDGER_ID
         AND FUND_TRANSACTION.LEDGER_ID = LEDGER.LEDGER_ID
           ORDER BY
FUND.FUND_CODE,TO_CHAR(FUND_TRANSACTION.TRANS_DATE,'yyyymmddhhmiss')";

#print "$sqln";

           $sth = $dbh->prepare("$sql")
                    or die "Couldn't prepare statement:" . $Data->errstr;
                         #prepares sql statement and returns object in
                         #statment handle $sth

           $sth->execute() or die "Couldn't execute statement:" . $sth-
>errstr;
                        #executes prepared sql statement

# N.B. $fundid2 is the fund_id.    $fundid is the institution_fund_id


while
(($type,$amount,$transdate,$date2,$opid,$refnum,$note,$instid,$fundid,$fu
ndcode,$fundid2,$expends,$ledger) = $sth->fetchrow_array() )
{ #print
"$type,$amount,$transdate,$date2,$opid,$refnum,$instid,$fundid,$fundcode,
$fundid2,$ledgern";
    #print "date2 is $date2n";
    $note =~ s/x0a//g;    #get rid of line feeds in note field
    $note =~ s/x0d//g;    #get rid of carriage returns
   if ($opid eq "<R>") {$opid = R;} # <> dont display well in html
    if ($type eq '1') {$typetxt = 'initial allocation';}
    if ($type eq '2') {$typetxt = 'fund increase';}
    if ($type eq '3') {$typetxt = 'fund decrease';}
    if ($type eq '4') {$typetxt = 'commitment';}
    if ($type eq '5') {$typetxt = 'expenditure';}
    if ($type eq '6') {$typetxt = 'transfer in';}
    if ($type eq '7') {$typetxt = 'transfer out';}
    $amounttxt = sprintf("%6.2f",($amount*.01));
    $vendor = "";
    $vendname = "";
    if ($type eq '4') {#print "refnum is $refnumn";
                        getvendc($refnum);}
                        #print "commit vendor is $vendorn";} #for
commitment get vendor from order
    if ($type eq '5') {#print "refnum is $refnumn";
                        getvende($refnum);}
#print "expend vendor is $vendorn";   #for expend
get vendor from invoice



            if ($instid ne $savinstid) {&initrtn;}

                if ($type eq '1') {#print "initalloc is $initalloc.
amount is $amountn";
                                   $initalloc = $initalloc + $amount;
#initial allocation
                                   $netalloc = $netalloc + $amount;}

                 if ($type eq '2') {$netalloc = $netalloc + $amount;
                                    $incsum = $incsum + $amount;}
#fund increase

                 if ($type eq '3') {#print "netalloc is $netalloc before
decreasen";
                                   $netalloc = $netalloc - $amount;
                                   $decsum = $decsum + $amount;}
                                   #print "we have a decrease. amount is
$amount. decsum is $decsum, netalloc is $netallocn";}
#fund decrease

                 if ($type eq '4') {$commitsum = $commitsum + $amount;}
#commitment
                 if ($type eq '5') {$expsum = $expsum + $amount;}
#expenditures
                 if ($type eq '6') {$netalloc = $netalloc + $amount;
                                    $transinsum = $transinsum + $amount;}
#transfer in

                 if ($type eq '7') {$netalloc = $netalloc - $amount;
                                    $transoutsum = $transoutsum +
$amount;}        #transfer out


                 $cashbal = $netalloc - $expsum;


                 $freebal = $cashbal - $commitsum;



               # print "trans date is $transdate lastrun is $lastrun
today is $todayrunn";
           if ($transdate ge $fromdate && $transdate le $todate)     #if
within date range
               { #print "amount is $amount, refnum is $refnumn ";
                 if ($type eq '4') {$commitdtl = $commitdtl + $amount;}
#commitment
                 if ($type eq '5') {$expdtl = $expdtl + $amount;}
#expenditures
#write FUNDTXT;
                    $po = ""; #initialize
                    $inv = ""; #initialize
                    $title = ""; #initialize
                    $currency = "";
                    $lineprice = "";
               $placecode = "";
                    $pubplace = "";
                    $linenum = "";
              $place = .01;

##ignore negative commitments (created by system) but accept all
expenditures (negative
#expenditures are created by users
#02/11/05 ignore negative expenditures without opid's
   if ($amount < 0 && !$opid) {next;}
          #if expenditure was cancelled by system there's no opid, just
ignore

  if ($type eq '4' && $amount > 0) {$po = $refnum; lineord($refnum);}
#get line items for orders if positive commitment
  if ($type eq '5') {lineinv($refnum);} #for expenditures get all line
items associated with that invoice
  if ($type ne '4' && $type ne '5')
               {$usprice = $amount;
                 write FUNDTXT;
printf FUNDXLS
("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s
t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec
ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,,$ledger,$vendn
ame,,$note); }


           # print FUNDXLS
"$fundcodet$transdatet$typetxtt$amounttxtt$opidt$refnumt$vendort$l
edgern";

            } #end of if transaction is in date range




}   #end of while   sql

&initrtn;              #print last fund


close FUNDRPT;
close FUNDXLS;


$dbh->disconnect;

#print "savfundcode is $savfundcoden";
print "file is $savfundcode.$disprange.$today.TXTn";
system("rm $webdir/funds9/$savfundcode.$disprange.$today.TXT");
system("cat $dir/$savfundcode.$disprange.$today.TXT >
$webdir/funds9/$savfundcode.$disprange.$today.TXT");
system("chmod a+r $webdir/funds9/$savfundcode.$disprange.$today.TXT");

system("rm $webdir/funds9/$savfundcode.$disprange.$today.XLS");
system("cat $dir/$savfundcode.$disprange.$today.XLS >
$webdir/funds9/$savfundcode.$disprange.$today.XLS");
system("chmod a+r $webdir/funds9/$savfundcode.$disprange.$today.XLS");



#************************************************************************
***
#initialize counters and institution id
#************************************************************************
***

sub initrtn()   {

if ($savinstid)
{if ($expsum ne $savexpend) #07/01/05
 {#print "$savfundcode table expenditures = $savexpend, report
expenditures = $expsumn";
  $expsum = $savexpend;
  $cashbal = $netalloc - $expsum;     #and re-compute
  $freebal = $cashbal - $commitsum;}

print FUNDRPT "nFUND: $savinstid $savfundid:n";
    print FUNDRPT "DATE RANGE : $fromdate - $todatenn";
    print FUNDRPT "$hdrtxtn";

  if ($netalloc > 0) {$free = $freebal/$netalloc;
                     $free = $free*100;
                     $freepct = sprintf("%6.2f",$free);
                     $cashfree = $cashbal/$netalloc;
                     $cashfree = $cashfree*100;
                     $cashfreepct = sprintf("%10.2f",$cashfree); }
                         else {$freepct = 0;
                              $cashfreepct = 0;}


 #print "free is $freebal, free is $freepctn";



 #print FUNDRPT "test expenditures : $expdtltestn";
 #print FUNDRPT "test commits : $commitdtltestn";


$totinit = $totinit + $initalloc;
$totnet = $totnet + $netalloc;
$totexp = $totexp + $expsum;
$totcommit = $totcommit + $commitsum;
$totinc = $totinc + $incsum;
$totdec = $totdec + $decsum;
$tottransin = $tottransin + $transinsum;
$tottransout = $tottransout + $transoutsum;

 #print "we are here. new fund is $fundcode, old fund is
$savfundcoden";
 close FUNDTXT;
#sort by title and date
system("cat $dir/fund.text.$today | sort -d -k 3,3 -k 2,2n | uniq >
$dir/fund.text.$today.sorted");

 open SORTED,"$dir/fund.text.$today.sorted";

 $expendpd = "0.00";    #03/17/05 now count expenditures and commitments
from line items for this period
 $commitpd = "0.00";

while ($line = <SORTED>)                         #get rid of copyid from
report. was only nec. for sorting uniq
{($printline,$copyid) = ($line =~ /(.*) ([^ ]+$)/); #printline is
everything before the last space

   if ($printline =~ /expenditure/) {$expend = substr($printline,100,13);
                                   print "expend is $expendn";
                              $expendpd = $expend + $expendpd;}

   if ($printline =~ /commitment/) {$commit = substr($printline,100,13);
                             print "commit is $commitn";
                             $commitpd = $commit + $commitpd;}

print FUNDRPT "$printlinen";}
#print FUNDRPT $_;}

write FUNDRPT ;
open FUNDTXT,">$dir/fund.text.$today";

close FUNDRPT;
close FUNDXLS;
system("cat $dir/$savfundcode.$disprange.$today.fundrpt.XLS | sort -d -k
4,4 -k 3,3n | uniq > $dir/$savfundcode.$disprange.$today.sorted.XLS");

open SORTEDXLS,"$dir/$savfundcode.$disprange.$today.sorted.XLS";
while ($line = <SORTEDXLS>)
{($printline,$copyid) = ($line =~ /(.*)t([^t]+$)/);   #printline is
everything before the last tab
                  print FUNDSHEET "$printlinen";}
close FUNDSHEET;


#print "savfundcode is $savfundcoden";
#print "file is $savfundcode.$disprange.$today.TXTn";
system("rm
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT");
system("cat $dir/$savfundcode.$disprange.$today.TXT >
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT");
system("chmod a+r
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT");

system("rm
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS");
system("cat $dir/$savfundcode.$disprange.$today.XLS >
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS");
system("chmod a+r
$webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS");


exit;          #uncomment here to test 1 fund code.   exit here to retain
fund code name for report

}



$savexpend = $expends;    #save fund total expends
$savinstid = $instid;           #initialize institution id save field
$savfundid = $fundid;           #initialize fund id save field
$savfundcode = $fundcode;       #initialize fund code save field
$initalloc = 0;             #initialize initial allocation
$netalloc =0;             #initialize net allocation
$expsum = 0;              #initialize expediture sum
$commitsum = 0;           #initialize commitment sum
$incsum = 0;              #initialize fund increase sum
$decsum = 0;              #initialize fund decrease sum
$transinsum = 0;          #initialize tranfer in sum
$transoutsum = 0;         #initialize transfer out sum
$cashbal = 0;             #initialize cash balance
$freebal = 0;           #initialize freeable balance
$commitdtl = 0;
$expdtl = 0;
$expdtltest = 0;
$commitdtltest = 0;

}   #end of subrtn

#########################################################################
# fund report header routine
#########################################################################
format FUNDHDR =


@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$title
@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$title2
@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$fmtdate
.

#########################################################################
# fund report format routine
#########################################################################

format FUNDRPT   =


TOTAL EXPENDITURES from @<<<<<<<< to @<<<<<<<< : @########.##
$fromdate,$todate,$expendpd
TOTAL COMMITMENTS from @<<<<<<<< to @<<<<<<<< : @########.##
$fromdate,$todate,$commitpd




FUND TOTALS: @<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
$savfundcode,$savinstid,$savfundid

    InitAlloc   Net Alloc. Tot.Expends CashBalance     Cash %
Tot.Commits Free Balance   Free %
@#########.## @#########.## @########.## @########.## @###.##
@########.## @########.## @###.##
$initalloc*.01,$netalloc*.01,$expsum*.01,$cashbal*.01,$cashfreepct,$commi
tsum*.01,$freebal*.01,$freepct


*************************************************************************
*************************************************

.


#########################################################################
# fund text format routine
#########################################################################

format FUNDTXT =
@<<<<<<<<<<    @<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<
@<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<< @#######.## @<<<<<<<<<<< @<<<<
@<<<<<<< @<<< @#######.## @<<<<<
$po,$transdate,$title,
$linenum,$pubplace,$placecode,$typetxt,$usprice*$place,$inv,$opid,$vendor
,$currency,$lineprice*$place,$copyid
.

#########################################################################
#############################################
# edit routine formats totals
#########################################################################
############################################

sub edit() {

       $newamt = $_[0]*.01;
       $newamt =~s/ //g;      #get rid of spaces
       return $newamt;

}

#########################################################################
# fund report totals routine
#########################################################################

format FUNDTOTS =
*************************************************************************
**************************************

TOTAL ALL FUNDS:

    InitAlloc   Net Alloc.   Tot.Expends CashBalance Cash % Tot.Commits
Free Balance   Free %
@#########.## @#########.## @########.## @########.## @###.##
@########.## @########.## @###.##
$totinit*.01,$totnet*.01,$totexp*.01,$totcash*.01,$cashfreepct,$totcommit
*.01,$totfree*.01,$freepct
.

#################################################################
# getvendc   get vendor code from order table
#################################################################
sub getvendc() {
 $sql2 = "SELECT   VENDOR.VENDOR_CODE, VENDOR.VENDOR_NAME
           FROM $database.VENDOR, $database.PURCHASE_ORDER
             WHERE
               PURCHASE_ORDER.PO_NUMBER = '$refnum'
                 AND PURCHASE_ORDER.VENDOR_ID = VENDOR.VENDOR_ID";


$sth2 = $dbh->prepare("$sql2")
                 or die "Couldn't prepare statement:" . $Data->errstr;

    $sth2->execute() or die "Couldn't execute statement:" . $sth2->errstr;

    ($vendor,$vendname) = $sth2->fetchrow_array();


return ($vendor,$vendname);
}
#################################################################
# getvende   get vendor from invoice
#################################################################
sub getvende() {
$vendor = "";
    $vendname = "";
 $sql3 = "SELECT DISTINCT VENDOR.VENDOR_CODE, VENDOR.VENDOR_NAME
           FROM $database.VENDOR, $database.INVOICE,
$database.INVOICE_FUNDS
             WHERE
               INVOICE.INVOICE_NUMBER = '$refnum'
                AND INVOICE.INVOICE_ID = INVOICE_FUNDS.INVOICE_ID
                 AND INVOICE_FUNDS.FUND_ID = '$fundid2'
                   AND INVOICE.VENDOR_ID = VENDOR.VENDOR_ID";


#AND TO_CHAR(INVOICE.INVOICE_STATUS_DATE,'yyyymmdd') = '$transdate'
#                          AND INVOICE.VENDOR_ID = VENDOR.VENDOR_ID";


    #print "$sql3n";
$sth3 = $dbh->prepare("$sql3")
                 or die "Couldn't prepare statement:" . $Data->errstr;

 $sth3->execute() or die "Couldn't execute statement:" . $sth2->errstr;

    ($vendor,$vendname) = $sth3->fetchrow_array();


return ($vendor,$vendname);
}

#########################################################################
########################
# lineinv - get line items for invoice
# GET PRICE FROM INVOICE LINE ITEM FUNDS TABLE INSTEAD OF INVOICE LINE
ITEM
#########################################################################
#######################


sub lineinv() {
    #print "refnum is $refnumn";
    $po = "";
    $inv = $refnum;
    $note = ""; #initialize
 $sql4 = "SELECT DISTINCT PURCHASE_ORDER.PO_NUMBER,
INVOICE_LINE_ITEM_FUNDS.AMOUNT,
          INVOICE_LINE_ITEM_FUNDS.COPY_ID,
          LINE_ITEM.LINE_ITEM_NUMBER,
          BIB_TEXT.TITLE_BRIEF,
          BIB_TEXT.PUB_PLACE, BIB_TEXT.PLACE_CODE,
          INVOICE.CURRENCY_CODE, INVOICE.CONVERSION_RATE,
CURRENCY_CONVERSION.DECIMALS,
            INV_LINE_ITEM_NOTES.NOTE, INVOICE_LINE_ITEM.PIECE_IDENTIFIER
                        FROM $database.INV_LINE_ITEM_NOTES,
              $database.PURCHASE_ORDER,
              $database.INVOICE_LINE_ITEM, $database.INVOICE,
$database.INVOICE_LINE_ITEM_FUNDS, $database.LINE_ITEM,
$database.BIB_TEXT,
               $database.CURRENCY_CONVERSION
         WHERE INVOICE.INVOICE_NUMBER = '$refnum' AND
                     TO_CHAR(INVOICE.INVOICE_STATUS_DATE,'yyyymmdd') =
'$transdate'
           AND INVOICE.INVOICE_ID = INVOICE_LINE_ITEM.INVOICE_ID
             AND INVOICE_LINE_ITEM.INV_LINE_ITEM_ID =
INVOICE_LINE_ITEM_FUNDS.INV_LINE_ITEM_ID
              AND INVOICE_LINE_ITEM_FUNDS.FUND_ID = '$fundid2'
              AND INVOICE_LINE_ITEM.LINE_ITEM_ID = LINE_ITEM.LINE_ITEM_ID
                 AND INVOICE_LINE_ITEM.INV_LINE_ITEM_ID =
INV_LINE_ITEM_NOTES.INV_LINE_ITEM_ID(+)
                AND LINE_ITEM.PO_ID = PURCHASE_ORDER.PO_ID
                  AND LINE_ITEM.BIB_ID = BIB_TEXT.BIB_ID AND
                  INVOICE.CURRENCY_CODE =
CURRENCY_CONVERSION.CURRENCY_CODE(+)";

       #print "$sql4n";

$sth4 = $dbh->prepare("$sql4")
    or die "Couldn't prepare statement:" . $Data->errstr;

    $sth4->execute() or die "Couldn't execute statement:" . $sth4->errstr;

  while
(($po,$lineprice,$copyid,$linenum,$title,$pubplace,$placecode,$currency,$
convrate,$decimals,$note,$piece) = $sth4->fetchrow_array())

  {$note =~ s/x0a//g;   #get rid of line feeds in note field
   $note =~ s/x0d//g;   #get rid of carriage returns
   $title =~ s/[^x20-x7e]//g; #get rid of ALL bad characters
   $title =~ s/"//g;            #and quotes
   if ($currency ne 'USD')
         {$usprice = $lineprice/($convrate*.00001);
          if ($decimals eq 0) {$place = 1;} }
      else {$usprice = $lineprice;}
   if (!$pubplace) {$pubplace = " ";}
   #print "lineprice is $lineprice, convrate is $convrate, usprice is
$usprice, decimals is $decimalsn";
   $expdtltest = $expdtltest + $usprice;
   printf FUNDXLS
("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s
t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec
ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,$lineprice*$pla
ce,$ledger,$vendname,$piece,$note,$copyid);
    write FUNDTXT; }




}    #end of lineinv subroutne
#########################################################################
################################
## lineord - get all line items for that order
#first get all line items for that order
#then get copy numbers for each line item
#then check that copy number has a status date that is in the date range
#then make sure fund for that copy number is the fund we're looking for
#(this should take of problem where copies are ordered under a split
fund)
#
#9/15/2010 get both notes and print notes.
#########################################################################
################################

sub lineord()   {

    #print "refnum is $refnum, date is $transdaten";
    $note = ""; #initialize
$sql5 = "SELECT DISTINCT LINE_ITEM.LINE_ITEM_NUMBER,
LINE_ITEM_FUNDS.AMOUNT, LINE_ITEM_FUNDS.COPY_ID,
          BIB_TEXT.TITLE_BRIEF, BIB_TEXT.PUB_PLACE,
          BIB_TEXT.PLACE_CODE,
         PURCHASE_ORDER.CURRENCY_CODE,
         PURCHASE_ORDER.CONVERSION_RATE,
CURRENCY_CONVERSION.DECIMALS,LINE_ITEM_NOTES.NOTE,
           LINE_ITEM_NOTES.PRINT_NOTE
           FROM $database.LINE_ITEM_NOTES,
            $database.BIB_TEXT, $database.LINE_ITEM,
$database.LINE_ITEM_COPY_HISTORY,
            $database.LINE_ITEM_COPY_STATUS, $database.PURCHASE_ORDER,
$database.LINE_ITEM_FUNDS,
              $database.CURRENCY_CONVERSION
             WHERE PURCHASE_ORDER.PO_NUMBER = '$refnum'
               AND PURCHASE_ORDER.PO_ID = LINE_ITEM.PO_ID
                AND LINE_ITEM.LINE_ITEM_ID =
LINE_ITEM_COPY_STATUS.LINE_ITEM_ID
                  AND LINE_ITEM.LINE_ITEM_ID =
LINE_ITEM_NOTES.LINE_ITEM_ID(+)
                   AND LINE_ITEM_COPY_STATUS.COPY_ID =
LINE_ITEM_COPY_HISTORY.COPY_ID
                AND (
TO_CHAR(LINE_ITEM_COPY_HISTORY.STATUS_DATE,'yyyymmdd') >= '$fromdate'
                        AND

TO_CHAR(LINE_ITEM_COPY_HISTORY.STATUS_DATE,'yyyymmdd') <= '$todate')
                AND LINE_ITEM_COPY_HISTORY.COPY_ID =
LINE_ITEM_FUNDS.COPY_ID
                  AND LINE_ITEM_FUNDS.FUND_ID = '$fundid2'
                                       AND LINE_ITEM.BIB_ID =
BIB_TEXT.BIB_ID
              AND PURCHASE_ORDER.CURRENCY_CODE =
CURRENCY_CONVERSION.CURRENCY_CODE(+)";

#print"$sql5n";
$sth5 = $dbh->prepare("$sql5")
           or die "Couldn't prepare statement:" . $Data->errstr;

$sth5->execute() or die "Couldn't execute statement:" . $sth5->errstr;

  while
(($linenum,$lineprice,$copyid,$title,$pubplace,$placecode,$currency,$conv
rate,$decimals,$note,$print_note) = $sth5->fetchrow_array() )

  { if (!$note && $print_note) {$note = $print_note;}
    #print "note is $noten";
    $note =~ s/x0a//g;   #get rid of line feeds
    $note =~ s/x0d//g;   #get rid of carriage returns
  #print "now note is $noten";
    #print
"$linenum,$lineprice,$copyid,$title,$pubplace,$placecode,$currency,$convr
ate,$decimals,$noten";

    if (!$pubplace) {$pubplace = " ";}
    if ($currency ne 'USD') {$usprice = $lineprice/($convrate*.00001);
                            if ($decimals eq 0) {$place = 1;} }
                     #print "conversion rate is $convraten";
                            # print "usprice is $uspricen";}
     else {$usprice = $lineprice;}
   $commitdtltest = $commitdtltest + $usprice;
   #print "order is $refnumn";
    printf FUNDXLS
("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s
t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec
ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,$lineprice*$pla
ce,$ledger,$vendname,$piece,$note);
    #print "copyid is $copyid, price is $linepricen";
    write FUNDTXT;}

}

Mais conteúdo relacionado

Mais procurados

20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
Arabic uae e_services_user_manual
Arabic uae e_services_user_manualArabic uae e_services_user_manual
Arabic uae e_services_user_manual
Confidential
 
Tips for using Firebird system tables
Tips for using Firebird system tablesTips for using Firebird system tables
Tips for using Firebird system tables
Mind The Firebird
 

Mais procurados (20)

Revisiting SOLID Principles
Revisiting  SOLID Principles Revisiting  SOLID Principles
Revisiting SOLID Principles
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHP
 
var, let in SIL
var, let in SILvar, let in SIL
var, let in SIL
 
Space Invaders Source Code
Space Invaders Source CodeSpace Invaders Source Code
Space Invaders Source Code
 
PythonでJWT生成からボット作成、投稿までやってみた
PythonでJWT生成からボット作成、投稿までやってみたPythonでJWT生成からボット作成、投稿までやってみた
PythonでJWT生成からボット作成、投稿までやってみた
 
Arabic uae e_services_user_manual
Arabic uae e_services_user_manualArabic uae e_services_user_manual
Arabic uae e_services_user_manual
 
14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor
 
Tips for using Firebird system tables
Tips for using Firebird system tablesTips for using Firebird system tables
Tips for using Firebird system tables
 
What is Dependency Injection
What is Dependency InjectionWhat is Dependency Injection
What is Dependency Injection
 
My Development Story
My Development StoryMy Development Story
My Development Story
 
So cal0365productivitygroup feb2019
So cal0365productivitygroup feb2019So cal0365productivitygroup feb2019
So cal0365productivitygroup feb2019
 
Gérer vos objets
Gérer vos objetsGérer vos objets
Gérer vos objets
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of Transduction
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 

Semelhante a Oneal perl-code-to-extract-from-voyager

Baksik3 enug baksik_xmlinvoice
Baksik3 enug baksik_xmlinvoiceBaksik3 enug baksik_xmlinvoice
Baksik3 enug baksik_xmlinvoice
ENUG
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
ady36
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
anjalitimecenter11
 

Semelhante a Oneal perl-code-to-extract-from-voyager (20)

Bouncingballs sh
Bouncingballs shBouncingballs sh
Bouncingballs sh
 
Nop2
Nop2Nop2
Nop2
 
Baksik3 enug baksik_xmlinvoice
Baksik3 enug baksik_xmlinvoiceBaksik3 enug baksik_xmlinvoice
Baksik3 enug baksik_xmlinvoice
 
PHP Tips & Tricks
PHP Tips & TricksPHP Tips & Tricks
PHP Tips & Tricks
 
Dades i operadors
Dades i operadorsDades i operadors
Dades i operadors
 
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
 
perl_lessons
perl_lessonsperl_lessons
perl_lessons
 
perl_lessons
perl_lessonsperl_lessons
perl_lessons
 
Daily notes
Daily notesDaily notes
Daily notes
 
Php functions
Php functionsPhp functions
Php functions
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Random. Kinda.
Random. Kinda.Random. Kinda.
Random. Kinda.
 
Developing applications for performance
Developing applications for performanceDeveloping applications for performance
Developing applications for performance
 
Pop3ck sh
Pop3ck shPop3ck sh
Pop3ck sh
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdfphp global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
php global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowAr.pdf
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 

Mais de ENUG

Jaffe o'brien-rosetta
Jaffe o'brien-rosettaJaffe o'brien-rosetta
Jaffe o'brien-rosetta
ENUG
 
Jones aleph acqorders
Jones aleph acqordersJones aleph acqorders
Jones aleph acqorders
ENUG
 
Yang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovationsYang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovations
ENUG
 
Yang hofmann-next generationcatalogforenug
Yang hofmann-next generationcatalogforenugYang hofmann-next generationcatalogforenug
Yang hofmann-next generationcatalogforenug
ENUG
 
Bischof custom-circ-ov
Bischof custom-circ-ovBischof custom-circ-ov
Bischof custom-circ-ov
ENUG
 
Wenger sf xin-barton
Wenger sf xin-bartonWenger sf xin-barton
Wenger sf xin-barton
ENUG
 
Collins whats buggingyou-aleph
Collins whats buggingyou-alephCollins whats buggingyou-aleph
Collins whats buggingyou-aleph
ENUG
 
Wagner whats buggingyou-voyager
Wagner whats buggingyou-voyagerWagner whats buggingyou-voyager
Wagner whats buggingyou-voyager
ENUG
 
Schwartz ez proxy-logs
Schwartz ez proxy-logsSchwartz ez proxy-logs
Schwartz ez proxy-logs
ENUG
 
Moulen digital bookplates
Moulen digital bookplatesMoulen digital bookplates
Moulen digital bookplates
ENUG
 
Moulen aleph update
Moulen aleph updateMoulen aleph update
Moulen aleph update
ENUG
 
Enug2011 innovative use-of_sfx_with_new_interface-final
Enug2011 innovative use-of_sfx_with_new_interface-finalEnug2011 innovative use-of_sfx_with_new_interface-final
Enug2011 innovative use-of_sfx_with_new_interface-final
ENUG
 
Callahan princetonenug2011
Callahan princetonenug2011Callahan princetonenug2011
Callahan princetonenug2011
ENUG
 
Baksik2 enug baksik_ebookplates
Baksik2 enug baksik_ebookplatesBaksik2 enug baksik_ebookplates
Baksik2 enug baksik_ebookplates
ENUG
 
Baksik1 enug baksik_rest
Baksik1 enug baksik_restBaksik1 enug baksik_rest
Baksik1 enug baksik_rest
ENUG
 
O neal columbia
O neal columbiaO neal columbia
O neal columbia
ENUG
 
Moulen batch loadingebookspdf
Moulen batch loadingebookspdfMoulen batch loadingebookspdf
Moulen batch loadingebookspdf
ENUG
 

Mais de ENUG (18)

Jaffe o'brien-rosetta
Jaffe o'brien-rosettaJaffe o'brien-rosetta
Jaffe o'brien-rosetta
 
Jones aleph acqorders
Jones aleph acqordersJones aleph acqorders
Jones aleph acqorders
 
Yang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovationsYang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovations
 
Yang hofmann-next generationcatalogforenug
Yang hofmann-next generationcatalogforenugYang hofmann-next generationcatalogforenug
Yang hofmann-next generationcatalogforenug
 
Bischof custom-circ-ov
Bischof custom-circ-ovBischof custom-circ-ov
Bischof custom-circ-ov
 
Wenger sf xin-barton
Wenger sf xin-bartonWenger sf xin-barton
Wenger sf xin-barton
 
Guy avoiding-dat apocalypse
Guy avoiding-dat apocalypseGuy avoiding-dat apocalypse
Guy avoiding-dat apocalypse
 
Collins whats buggingyou-aleph
Collins whats buggingyou-alephCollins whats buggingyou-aleph
Collins whats buggingyou-aleph
 
Wagner whats buggingyou-voyager
Wagner whats buggingyou-voyagerWagner whats buggingyou-voyager
Wagner whats buggingyou-voyager
 
Schwartz ez proxy-logs
Schwartz ez proxy-logsSchwartz ez proxy-logs
Schwartz ez proxy-logs
 
Moulen digital bookplates
Moulen digital bookplatesMoulen digital bookplates
Moulen digital bookplates
 
Moulen aleph update
Moulen aleph updateMoulen aleph update
Moulen aleph update
 
Enug2011 innovative use-of_sfx_with_new_interface-final
Enug2011 innovative use-of_sfx_with_new_interface-finalEnug2011 innovative use-of_sfx_with_new_interface-final
Enug2011 innovative use-of_sfx_with_new_interface-final
 
Callahan princetonenug2011
Callahan princetonenug2011Callahan princetonenug2011
Callahan princetonenug2011
 
Baksik2 enug baksik_ebookplates
Baksik2 enug baksik_ebookplatesBaksik2 enug baksik_ebookplates
Baksik2 enug baksik_ebookplates
 
Baksik1 enug baksik_rest
Baksik1 enug baksik_restBaksik1 enug baksik_rest
Baksik1 enug baksik_rest
 
O neal columbia
O neal columbiaO neal columbia
O neal columbia
 
Moulen batch loadingebookspdf
Moulen batch loadingebookspdfMoulen batch loadingebookspdf
Moulen batch loadingebookspdf
 

Último

Call Girls in Yamuna Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Yamuna Vihar  (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Yamuna Vihar  (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Yamuna Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdfMASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
Cocity Enterprises
 

Último (20)

Call Girls in Yamuna Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Yamuna Vihar  (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Yamuna Vihar  (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Yamuna Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Solution Manual For Financial Statement Analysis, 13th Edition By Charles H. ...
Solution Manual For Financial Statement Analysis, 13th Edition By Charles H. ...Solution Manual For Financial Statement Analysis, 13th Edition By Charles H. ...
Solution Manual For Financial Statement Analysis, 13th Edition By Charles H. ...
 
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
W.D. Gann Theory Complete Information.pdf
W.D. Gann Theory Complete Information.pdfW.D. Gann Theory Complete Information.pdf
W.D. Gann Theory Complete Information.pdf
 
GIFT City Overview India's Gateway to Global Finance
GIFT City Overview  India's Gateway to Global FinanceGIFT City Overview  India's Gateway to Global Finance
GIFT City Overview India's Gateway to Global Finance
 
7 tips trading Deriv Accumulator Options
7 tips trading Deriv Accumulator Options7 tips trading Deriv Accumulator Options
7 tips trading Deriv Accumulator Options
 
Technology industry / Finnish economic outlook
Technology industry / Finnish economic outlookTechnology industry / Finnish economic outlook
Technology industry / Finnish economic outlook
 
Lion One Corporate Presentation May 2024
Lion One Corporate Presentation May 2024Lion One Corporate Presentation May 2024
Lion One Corporate Presentation May 2024
 
Toronto dominion bank investor presentation.pdf
Toronto dominion bank investor presentation.pdfToronto dominion bank investor presentation.pdf
Toronto dominion bank investor presentation.pdf
 
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdfMASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
 
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
 
Famous No1 Amil Baba Love marriage Astrologer Specialist Expert In Pakistan a...
Famous No1 Amil Baba Love marriage Astrologer Specialist Expert In Pakistan a...Famous No1 Amil Baba Love marriage Astrologer Specialist Expert In Pakistan a...
Famous No1 Amil Baba Love marriage Astrologer Specialist Expert In Pakistan a...
 
falcon-invoice-discounting-unlocking-prime-investment-opportunities
falcon-invoice-discounting-unlocking-prime-investment-opportunitiesfalcon-invoice-discounting-unlocking-prime-investment-opportunities
falcon-invoice-discounting-unlocking-prime-investment-opportunities
 
logistics industry development power point ppt.pdf
logistics industry development power point ppt.pdflogistics industry development power point ppt.pdf
logistics industry development power point ppt.pdf
 
Explore Dual Citizenship in Africa | Citizenship Benefits & Requirements
Explore Dual Citizenship in Africa | Citizenship Benefits & RequirementsExplore Dual Citizenship in Africa | Citizenship Benefits & Requirements
Explore Dual Citizenship in Africa | Citizenship Benefits & Requirements
 
Kurla Capable Call Girls ,07506202331, Sion Affordable Call Girls
Kurla Capable Call Girls ,07506202331, Sion Affordable Call GirlsKurla Capable Call Girls ,07506202331, Sion Affordable Call Girls
Kurla Capable Call Girls ,07506202331, Sion Affordable Call Girls
 
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
 
Seeman_Fiintouch_LLP_Newsletter_May-2024.pdf
Seeman_Fiintouch_LLP_Newsletter_May-2024.pdfSeeman_Fiintouch_LLP_Newsletter_May-2024.pdf
Seeman_Fiintouch_LLP_Newsletter_May-2024.pdf
 
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
 
Benefits & Risk Of Stock Loans
Benefits & Risk Of Stock LoansBenefits & Risk Of Stock Loans
Benefits & Risk Of Stock Loans
 

Oneal perl-code-to-extract-from-voyager

  • 1. #!/opt/local/bin/perl #10/20/04 use this to create report of individual fund. #will report all transactions for specified fund, #plus summary of fund plus expenditures and commitments #for specified range. #insert fund code, fromdate and todate #01/14/2005 include line number in report to fix problem #where commitments for different copie of the same order #were getting sorted out. Also, send output to funds2 #instead of funds #01/20/2005 initialize $place for each fund transaction read #03/17/05 count commitment and expenditure totals for each fund #for each period after sorting has #taken place. If counting is done in subroutines, if there are #duplicate lines the sum will not be accurate. A duplicate line #can occur because one fund transaction can lead to retrieving #multiple line items, and another fund transaction can retrieve #some of these same line items, which is why we are sort uniqing #the report before printing #05/26/05 get rid of bad characters in title. Might prevent #records from displaying in Excel spreadsheet #07/01/05 if total expenditures don't match what's in fund table #(because Endeavor recalculated fund totals without deleting #bad lines from fund transaction table), use what's in table # and write discrepancy to report. #7/13/05 USE THIS PGM FOR NEW LEDGER CUL07. SEND OUTPUT TO FUNDS DIRECTORY #INSTEAD OF FUNDS2 #05/26/06 sort fund transactions by yyyymmddhhmiss to account for transactions #done the same day #7/13/07 use webdirectory funds3 for CUL07 #7/6/07 new ledger CUL08, use webdir funds4 #7/30/2007 use webdir funds5. problem with funds4 #07/14/2008 use webdir funds6. new ledger CUL09 #02/20/2009 get funds for CU or HS ledgers #07/07/2009 new CUL10 and HSL910 ledgers, and webdir fund7
  • 2. #07/07/2010 new 10/11 ledgers and webdir funds8 #09/13/2010 add ledger name and note field and piece identifier to xls file, for google calendar #05/02/2011 add barnard ledger #05/05/2011 take barnard out, as per Joyce #7/7/2011 new cul11/12 ledger and funds9 #$fromdate = '20041116'; #$todate = '20041130'; #$fundcode = '2625B'; $fundcode = $ARGV[0]; $fromdate = $ARGV[1]; $todate = $ARGV[2]; #$disprange = substr($fromdate,4,2).substr($fromdate,6,2).substr($fromdate,2,2)."- ".substr($todate,4,2).substr($todate,6,2).substr($todate,2,2); $disprange = "$fromdate-$todate"; print "disprange is $disprangen"; @now = localtime; $year = ($now[5]+1900); $month = ($now[4]+1); $day = ($now[3]); $fmtday = sprintf("%02d", $day); $fmtmonth = sprintf("%02d", $month); $today = "$fmtmonth$fmtday$year.rpt"; $todayrun = "$year$fmtmonth$fmtday"; $place = .01; #initialize decimal place BEGIN { $ENV{TWO_TASK} = "VGER"; $ENV{ORACLE_HOME} = "/opt/oracle-9.2"; } use MARC::Record; use MARC::Field; use MARC::Batch; use DBI; $database = "COLUMBIADB";
  • 3. $dbh = DBI- >connect("dbi:Oracle:",'READ_ONLY_USERNAME','READ_ONLY_PASSWORD') || die("could not open $database"). DBI->errstr; #creates database object in handle $dbh. this #represents the connection $webdir = "/wwws/data/cu/libraries/inside/clio/statistics/acquisitions/fundcode"; $dir = "/m1/clioprod/ocken/fundrpt"; $title = "FUND ACTIVITY REPORT"; $title2 = "FISCAL YEAR 11/12"; #$title2 = " "; $fmtdate = "$fmtmonth-$fmtday-$year"; $hdrtxt = "ORDER # DATE BRIEF TITLE PO LN # PUB PLACE CNTRY TRANSACTION USD AMT INVOICE OPID VENDOR ORIGINAL CURRENCY"; open (FUNDHDR,">$dir/$fundcode.$disprange.$today.TXT"); write FUNDHDR; close FUNDHDR; open FUNDTXT,">$dir/fund.text.$today"; open (FUNDRPT,">>$dir/$fundcode.$disprange.$today.TXT"); system("rm $dir/$fundcode.$disprange.$today.XLS"); open FUNDXLS,">$dir/$fundcode.$disprange.$today.fundrpt.XLS"; open FUNDSHEET,">>$dir/$fundcode.$disprange.$today.XLS"; print FUNDSHEET "FUNDCODEtPURCHASE ORDERtTRANSACTION DATEtTITLEtPO LINE #tPUB PLACEtPLACE CODEtTRANS TYPEtUSD PRICEtINVOICE NO.tOPIDtVENDORtORIGINAL CURRENCYtORIGINAL PRICEtLEDGERtVENDOR NAMEtINVOICE PIECE IDENTIFIERtNOTEn"; $savinstid = ""; #now select funds FOR LEDGER CUL 11 (ledger 29) OR LEDGER HS11/12 (ledger 30) $sql = "SELECT DISTINCT FUND_TRANSACTION.TRANS_TYPE, FUND_TRANSACTION.AMOUNT, TO_CHAR(FUND_TRANSACTION.TRANS_DATE,'yyyymmdd'), FUND_TRANSACTION.TRANS_DATE, FUND_TRANSACTION.OPERATOR_ID, FUND_TRANSACTION.REFERENCE_NO,FUND_TRANSACTION.NOTE, FUND.INSTITUTION_FUND_ID, FUND.FUND_NAME, FUND.FUND_CODE,
  • 4. FUND.FUND_ID, FUND.EXPENDITURES, LEDGER.LEDGER_NAME FROM $database.FUND_TRANSACTION, $database.FUND ,$database.LEDGER WHERE FUND.FUND_CODE = '$fundcode' AND FUND.FUND_ID = FUND_TRANSACTION.FUND_ID AND ( FUND.LEDGER_ID = '29' OR FUND.LEDGER_ID = '30') AND FUND.LEDGER_ID = FUND_TRANSACTION.LEDGER_ID AND FUND_TRANSACTION.LEDGER_ID = LEDGER.LEDGER_ID ORDER BY FUND.FUND_CODE,TO_CHAR(FUND_TRANSACTION.TRANS_DATE,'yyyymmddhhmiss')"; #print "$sqln"; $sth = $dbh->prepare("$sql") or die "Couldn't prepare statement:" . $Data->errstr; #prepares sql statement and returns object in #statment handle $sth $sth->execute() or die "Couldn't execute statement:" . $sth- >errstr; #executes prepared sql statement # N.B. $fundid2 is the fund_id. $fundid is the institution_fund_id while (($type,$amount,$transdate,$date2,$opid,$refnum,$note,$instid,$fundid,$fu ndcode,$fundid2,$expends,$ledger) = $sth->fetchrow_array() ) { #print "$type,$amount,$transdate,$date2,$opid,$refnum,$instid,$fundid,$fundcode, $fundid2,$ledgern"; #print "date2 is $date2n"; $note =~ s/x0a//g; #get rid of line feeds in note field $note =~ s/x0d//g; #get rid of carriage returns if ($opid eq "<R>") {$opid = R;} # <> dont display well in html if ($type eq '1') {$typetxt = 'initial allocation';} if ($type eq '2') {$typetxt = 'fund increase';} if ($type eq '3') {$typetxt = 'fund decrease';} if ($type eq '4') {$typetxt = 'commitment';} if ($type eq '5') {$typetxt = 'expenditure';} if ($type eq '6') {$typetxt = 'transfer in';} if ($type eq '7') {$typetxt = 'transfer out';} $amounttxt = sprintf("%6.2f",($amount*.01)); $vendor = ""; $vendname = ""; if ($type eq '4') {#print "refnum is $refnumn"; getvendc($refnum);} #print "commit vendor is $vendorn";} #for commitment get vendor from order if ($type eq '5') {#print "refnum is $refnumn"; getvende($refnum);}
  • 5. #print "expend vendor is $vendorn"; #for expend get vendor from invoice if ($instid ne $savinstid) {&initrtn;} if ($type eq '1') {#print "initalloc is $initalloc. amount is $amountn"; $initalloc = $initalloc + $amount; #initial allocation $netalloc = $netalloc + $amount;} if ($type eq '2') {$netalloc = $netalloc + $amount; $incsum = $incsum + $amount;} #fund increase if ($type eq '3') {#print "netalloc is $netalloc before decreasen"; $netalloc = $netalloc - $amount; $decsum = $decsum + $amount;} #print "we have a decrease. amount is $amount. decsum is $decsum, netalloc is $netallocn";} #fund decrease if ($type eq '4') {$commitsum = $commitsum + $amount;} #commitment if ($type eq '5') {$expsum = $expsum + $amount;} #expenditures if ($type eq '6') {$netalloc = $netalloc + $amount; $transinsum = $transinsum + $amount;} #transfer in if ($type eq '7') {$netalloc = $netalloc - $amount; $transoutsum = $transoutsum + $amount;} #transfer out $cashbal = $netalloc - $expsum; $freebal = $cashbal - $commitsum; # print "trans date is $transdate lastrun is $lastrun today is $todayrunn"; if ($transdate ge $fromdate && $transdate le $todate) #if within date range { #print "amount is $amount, refnum is $refnumn "; if ($type eq '4') {$commitdtl = $commitdtl + $amount;} #commitment if ($type eq '5') {$expdtl = $expdtl + $amount;} #expenditures
  • 6. #write FUNDTXT; $po = ""; #initialize $inv = ""; #initialize $title = ""; #initialize $currency = ""; $lineprice = ""; $placecode = ""; $pubplace = ""; $linenum = ""; $place = .01; ##ignore negative commitments (created by system) but accept all expenditures (negative #expenditures are created by users #02/11/05 ignore negative expenditures without opid's if ($amount < 0 && !$opid) {next;} #if expenditure was cancelled by system there's no opid, just ignore if ($type eq '4' && $amount > 0) {$po = $refnum; lineord($refnum);} #get line items for orders if positive commitment if ($type eq '5') {lineinv($refnum);} #for expenditures get all line items associated with that invoice if ($type ne '4' && $type ne '5') {$usprice = $amount; write FUNDTXT; printf FUNDXLS ("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,,$ledger,$vendn ame,,$note); } # print FUNDXLS "$fundcodet$transdatet$typetxtt$amounttxtt$opidt$refnumt$vendort$l edgern"; } #end of if transaction is in date range } #end of while sql &initrtn; #print last fund close FUNDRPT; close FUNDXLS; $dbh->disconnect; #print "savfundcode is $savfundcoden";
  • 7. print "file is $savfundcode.$disprange.$today.TXTn"; system("rm $webdir/funds9/$savfundcode.$disprange.$today.TXT"); system("cat $dir/$savfundcode.$disprange.$today.TXT > $webdir/funds9/$savfundcode.$disprange.$today.TXT"); system("chmod a+r $webdir/funds9/$savfundcode.$disprange.$today.TXT"); system("rm $webdir/funds9/$savfundcode.$disprange.$today.XLS"); system("cat $dir/$savfundcode.$disprange.$today.XLS > $webdir/funds9/$savfundcode.$disprange.$today.XLS"); system("chmod a+r $webdir/funds9/$savfundcode.$disprange.$today.XLS"); #************************************************************************ *** #initialize counters and institution id #************************************************************************ *** sub initrtn() { if ($savinstid) {if ($expsum ne $savexpend) #07/01/05 {#print "$savfundcode table expenditures = $savexpend, report expenditures = $expsumn"; $expsum = $savexpend; $cashbal = $netalloc - $expsum; #and re-compute $freebal = $cashbal - $commitsum;} print FUNDRPT "nFUND: $savinstid $savfundid:n"; print FUNDRPT "DATE RANGE : $fromdate - $todatenn"; print FUNDRPT "$hdrtxtn"; if ($netalloc > 0) {$free = $freebal/$netalloc; $free = $free*100; $freepct = sprintf("%6.2f",$free); $cashfree = $cashbal/$netalloc; $cashfree = $cashfree*100; $cashfreepct = sprintf("%10.2f",$cashfree); } else {$freepct = 0; $cashfreepct = 0;} #print "free is $freebal, free is $freepctn"; #print FUNDRPT "test expenditures : $expdtltestn"; #print FUNDRPT "test commits : $commitdtltestn"; $totinit = $totinit + $initalloc; $totnet = $totnet + $netalloc; $totexp = $totexp + $expsum;
  • 8. $totcommit = $totcommit + $commitsum; $totinc = $totinc + $incsum; $totdec = $totdec + $decsum; $tottransin = $tottransin + $transinsum; $tottransout = $tottransout + $transoutsum; #print "we are here. new fund is $fundcode, old fund is $savfundcoden"; close FUNDTXT; #sort by title and date system("cat $dir/fund.text.$today | sort -d -k 3,3 -k 2,2n | uniq > $dir/fund.text.$today.sorted"); open SORTED,"$dir/fund.text.$today.sorted"; $expendpd = "0.00"; #03/17/05 now count expenditures and commitments from line items for this period $commitpd = "0.00"; while ($line = <SORTED>) #get rid of copyid from report. was only nec. for sorting uniq {($printline,$copyid) = ($line =~ /(.*) ([^ ]+$)/); #printline is everything before the last space if ($printline =~ /expenditure/) {$expend = substr($printline,100,13); print "expend is $expendn"; $expendpd = $expend + $expendpd;} if ($printline =~ /commitment/) {$commit = substr($printline,100,13); print "commit is $commitn"; $commitpd = $commit + $commitpd;} print FUNDRPT "$printlinen";} #print FUNDRPT $_;} write FUNDRPT ; open FUNDTXT,">$dir/fund.text.$today"; close FUNDRPT; close FUNDXLS; system("cat $dir/$savfundcode.$disprange.$today.fundrpt.XLS | sort -d -k 4,4 -k 3,3n | uniq > $dir/$savfundcode.$disprange.$today.sorted.XLS"); open SORTEDXLS,"$dir/$savfundcode.$disprange.$today.sorted.XLS"; while ($line = <SORTEDXLS>) {($printline,$copyid) = ($line =~ /(.*)t([^t]+$)/); #printline is everything before the last tab print FUNDSHEET "$printlinen";} close FUNDSHEET; #print "savfundcode is $savfundcoden"; #print "file is $savfundcode.$disprange.$today.TXTn";
  • 9. system("rm $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT"); system("cat $dir/$savfundcode.$disprange.$today.TXT > $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT"); system("chmod a+r $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.TXT"); system("rm $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS"); system("cat $dir/$savfundcode.$disprange.$today.XLS > $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS"); system("chmod a+r $webdir/funds9/$savfundcode/$savfundcode.$disprange.$today.XLS"); exit; #uncomment here to test 1 fund code. exit here to retain fund code name for report } $savexpend = $expends; #save fund total expends $savinstid = $instid; #initialize institution id save field $savfundid = $fundid; #initialize fund id save field $savfundcode = $fundcode; #initialize fund code save field $initalloc = 0; #initialize initial allocation $netalloc =0; #initialize net allocation $expsum = 0; #initialize expediture sum $commitsum = 0; #initialize commitment sum $incsum = 0; #initialize fund increase sum $decsum = 0; #initialize fund decrease sum $transinsum = 0; #initialize tranfer in sum $transoutsum = 0; #initialize transfer out sum $cashbal = 0; #initialize cash balance $freebal = 0; #initialize freeable balance $commitdtl = 0; $expdtl = 0; $expdtltest = 0; $commitdtltest = 0; } #end of subrtn ######################################################################### # fund report header routine ######################################################################### format FUNDHDR = @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| $title @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  • 10. $title2 @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| $fmtdate . ######################################################################### # fund report format routine ######################################################################### format FUNDRPT = TOTAL EXPENDITURES from @<<<<<<<< to @<<<<<<<< : @########.## $fromdate,$todate,$expendpd TOTAL COMMITMENTS from @<<<<<<<< to @<<<<<<<< : @########.## $fromdate,$todate,$commitpd FUND TOTALS: @<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< $savfundcode,$savinstid,$savfundid InitAlloc Net Alloc. Tot.Expends CashBalance Cash % Tot.Commits Free Balance Free % @#########.## @#########.## @########.## @########.## @###.## @########.## @########.## @###.## $initalloc*.01,$netalloc*.01,$expsum*.01,$cashbal*.01,$cashfreepct,$commi tsum*.01,$freebal*.01,$freepct ************************************************************************* ************************************************* . ######################################################################### # fund text format routine ######################################################################### format FUNDTXT = @<<<<<<<<<< @<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<< @#######.## @<<<<<<<<<<< @<<<< @<<<<<<< @<<< @#######.## @<<<<< $po,$transdate,$title, $linenum,$pubplace,$placecode,$typetxt,$usprice*$place,$inv,$opid,$vendor ,$currency,$lineprice*$place,$copyid . ######################################################################### ############################################# # edit routine formats totals
  • 11. ######################################################################### ############################################ sub edit() { $newamt = $_[0]*.01; $newamt =~s/ //g; #get rid of spaces return $newamt; } ######################################################################### # fund report totals routine ######################################################################### format FUNDTOTS = ************************************************************************* ************************************** TOTAL ALL FUNDS: InitAlloc Net Alloc. Tot.Expends CashBalance Cash % Tot.Commits Free Balance Free % @#########.## @#########.## @########.## @########.## @###.## @########.## @########.## @###.## $totinit*.01,$totnet*.01,$totexp*.01,$totcash*.01,$cashfreepct,$totcommit *.01,$totfree*.01,$freepct . ################################################################# # getvendc get vendor code from order table ################################################################# sub getvendc() { $sql2 = "SELECT VENDOR.VENDOR_CODE, VENDOR.VENDOR_NAME FROM $database.VENDOR, $database.PURCHASE_ORDER WHERE PURCHASE_ORDER.PO_NUMBER = '$refnum' AND PURCHASE_ORDER.VENDOR_ID = VENDOR.VENDOR_ID"; $sth2 = $dbh->prepare("$sql2") or die "Couldn't prepare statement:" . $Data->errstr; $sth2->execute() or die "Couldn't execute statement:" . $sth2->errstr; ($vendor,$vendname) = $sth2->fetchrow_array(); return ($vendor,$vendname); } ################################################################# # getvende get vendor from invoice ################################################################# sub getvende() {
  • 12. $vendor = ""; $vendname = ""; $sql3 = "SELECT DISTINCT VENDOR.VENDOR_CODE, VENDOR.VENDOR_NAME FROM $database.VENDOR, $database.INVOICE, $database.INVOICE_FUNDS WHERE INVOICE.INVOICE_NUMBER = '$refnum' AND INVOICE.INVOICE_ID = INVOICE_FUNDS.INVOICE_ID AND INVOICE_FUNDS.FUND_ID = '$fundid2' AND INVOICE.VENDOR_ID = VENDOR.VENDOR_ID"; #AND TO_CHAR(INVOICE.INVOICE_STATUS_DATE,'yyyymmdd') = '$transdate' # AND INVOICE.VENDOR_ID = VENDOR.VENDOR_ID"; #print "$sql3n"; $sth3 = $dbh->prepare("$sql3") or die "Couldn't prepare statement:" . $Data->errstr; $sth3->execute() or die "Couldn't execute statement:" . $sth2->errstr; ($vendor,$vendname) = $sth3->fetchrow_array(); return ($vendor,$vendname); } ######################################################################### ######################## # lineinv - get line items for invoice # GET PRICE FROM INVOICE LINE ITEM FUNDS TABLE INSTEAD OF INVOICE LINE ITEM ######################################################################### ####################### sub lineinv() { #print "refnum is $refnumn"; $po = ""; $inv = $refnum; $note = ""; #initialize $sql4 = "SELECT DISTINCT PURCHASE_ORDER.PO_NUMBER, INVOICE_LINE_ITEM_FUNDS.AMOUNT, INVOICE_LINE_ITEM_FUNDS.COPY_ID, LINE_ITEM.LINE_ITEM_NUMBER, BIB_TEXT.TITLE_BRIEF, BIB_TEXT.PUB_PLACE, BIB_TEXT.PLACE_CODE, INVOICE.CURRENCY_CODE, INVOICE.CONVERSION_RATE, CURRENCY_CONVERSION.DECIMALS, INV_LINE_ITEM_NOTES.NOTE, INVOICE_LINE_ITEM.PIECE_IDENTIFIER FROM $database.INV_LINE_ITEM_NOTES, $database.PURCHASE_ORDER, $database.INVOICE_LINE_ITEM, $database.INVOICE,
  • 13. $database.INVOICE_LINE_ITEM_FUNDS, $database.LINE_ITEM, $database.BIB_TEXT, $database.CURRENCY_CONVERSION WHERE INVOICE.INVOICE_NUMBER = '$refnum' AND TO_CHAR(INVOICE.INVOICE_STATUS_DATE,'yyyymmdd') = '$transdate' AND INVOICE.INVOICE_ID = INVOICE_LINE_ITEM.INVOICE_ID AND INVOICE_LINE_ITEM.INV_LINE_ITEM_ID = INVOICE_LINE_ITEM_FUNDS.INV_LINE_ITEM_ID AND INVOICE_LINE_ITEM_FUNDS.FUND_ID = '$fundid2' AND INVOICE_LINE_ITEM.LINE_ITEM_ID = LINE_ITEM.LINE_ITEM_ID AND INVOICE_LINE_ITEM.INV_LINE_ITEM_ID = INV_LINE_ITEM_NOTES.INV_LINE_ITEM_ID(+) AND LINE_ITEM.PO_ID = PURCHASE_ORDER.PO_ID AND LINE_ITEM.BIB_ID = BIB_TEXT.BIB_ID AND INVOICE.CURRENCY_CODE = CURRENCY_CONVERSION.CURRENCY_CODE(+)"; #print "$sql4n"; $sth4 = $dbh->prepare("$sql4") or die "Couldn't prepare statement:" . $Data->errstr; $sth4->execute() or die "Couldn't execute statement:" . $sth4->errstr; while (($po,$lineprice,$copyid,$linenum,$title,$pubplace,$placecode,$currency,$ convrate,$decimals,$note,$piece) = $sth4->fetchrow_array()) {$note =~ s/x0a//g; #get rid of line feeds in note field $note =~ s/x0d//g; #get rid of carriage returns $title =~ s/[^x20-x7e]//g; #get rid of ALL bad characters $title =~ s/"//g; #and quotes if ($currency ne 'USD') {$usprice = $lineprice/($convrate*.00001); if ($decimals eq 0) {$place = 1;} } else {$usprice = $lineprice;} if (!$pubplace) {$pubplace = " ";} #print "lineprice is $lineprice, convrate is $convrate, usprice is $usprice, decimals is $decimalsn"; $expdtltest = $expdtltest + $usprice; printf FUNDXLS ("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,$lineprice*$pla ce,$ledger,$vendname,$piece,$note,$copyid); write FUNDTXT; } } #end of lineinv subroutne
  • 14. ######################################################################### ################################ ## lineord - get all line items for that order #first get all line items for that order #then get copy numbers for each line item #then check that copy number has a status date that is in the date range #then make sure fund for that copy number is the fund we're looking for #(this should take of problem where copies are ordered under a split fund) # #9/15/2010 get both notes and print notes. ######################################################################### ################################ sub lineord() { #print "refnum is $refnum, date is $transdaten"; $note = ""; #initialize $sql5 = "SELECT DISTINCT LINE_ITEM.LINE_ITEM_NUMBER, LINE_ITEM_FUNDS.AMOUNT, LINE_ITEM_FUNDS.COPY_ID, BIB_TEXT.TITLE_BRIEF, BIB_TEXT.PUB_PLACE, BIB_TEXT.PLACE_CODE, PURCHASE_ORDER.CURRENCY_CODE, PURCHASE_ORDER.CONVERSION_RATE, CURRENCY_CONVERSION.DECIMALS,LINE_ITEM_NOTES.NOTE, LINE_ITEM_NOTES.PRINT_NOTE FROM $database.LINE_ITEM_NOTES, $database.BIB_TEXT, $database.LINE_ITEM, $database.LINE_ITEM_COPY_HISTORY, $database.LINE_ITEM_COPY_STATUS, $database.PURCHASE_ORDER, $database.LINE_ITEM_FUNDS, $database.CURRENCY_CONVERSION WHERE PURCHASE_ORDER.PO_NUMBER = '$refnum' AND PURCHASE_ORDER.PO_ID = LINE_ITEM.PO_ID AND LINE_ITEM.LINE_ITEM_ID = LINE_ITEM_COPY_STATUS.LINE_ITEM_ID AND LINE_ITEM.LINE_ITEM_ID = LINE_ITEM_NOTES.LINE_ITEM_ID(+) AND LINE_ITEM_COPY_STATUS.COPY_ID = LINE_ITEM_COPY_HISTORY.COPY_ID AND ( TO_CHAR(LINE_ITEM_COPY_HISTORY.STATUS_DATE,'yyyymmdd') >= '$fromdate' AND TO_CHAR(LINE_ITEM_COPY_HISTORY.STATUS_DATE,'yyyymmdd') <= '$todate') AND LINE_ITEM_COPY_HISTORY.COPY_ID = LINE_ITEM_FUNDS.COPY_ID AND LINE_ITEM_FUNDS.FUND_ID = '$fundid2' AND LINE_ITEM.BIB_ID = BIB_TEXT.BIB_ID AND PURCHASE_ORDER.CURRENCY_CODE = CURRENCY_CONVERSION.CURRENCY_CODE(+)"; #print"$sql5n";
  • 15. $sth5 = $dbh->prepare("$sql5") or die "Couldn't prepare statement:" . $Data->errstr; $sth5->execute() or die "Couldn't execute statement:" . $sth5->errstr; while (($linenum,$lineprice,$copyid,$title,$pubplace,$placecode,$currency,$conv rate,$decimals,$note,$print_note) = $sth5->fetchrow_array() ) { if (!$note && $print_note) {$note = $print_note;} #print "note is $noten"; $note =~ s/x0a//g; #get rid of line feeds $note =~ s/x0d//g; #get rid of carriage returns #print "now note is $noten"; #print "$linenum,$lineprice,$copyid,$title,$pubplace,$placecode,$currency,$convr ate,$decimals,$noten"; if (!$pubplace) {$pubplace = " ";} if ($currency ne 'USD') {$usprice = $lineprice/($convrate*.00001); if ($decimals eq 0) {$place = 1;} } #print "conversion rate is $convraten"; # print "usprice is $uspricen";} else {$usprice = $lineprice;} $commitdtltest = $commitdtltest + $usprice; #print "order is $refnumn"; printf FUNDXLS ("%st%st%st%st%st%st%st%st%10.2ft%st%st%st%st%10.2ft%st%s t%st%st%sn",$fundcode,$po,$transdate,$title,$linenum,$pubplace,$placec ode,$typetxt,$usprice*$place,$inv,$opid,$vendor,$currency,$lineprice*$pla ce,$ledger,$vendname,$piece,$note); #print "copyid is $copyid, price is $linepricen"; write FUNDTXT;} }