Commit 60ff7da3 authored by cpatil's avatar cpatil

change code as per suggestion


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98313 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 38cf66c4
...@@ -223,7 +223,7 @@ public class POMilestoneCnf ...@@ -223,7 +223,7 @@ public class POMilestoneCnf
amount = Double.parseDouble(genericUtility.getColumnValue("amount",xmlDataAllDom)==null?"":genericUtility.getColumnValue("amount",xmlDataAllDom)); amount = Double.parseDouble(genericUtility.getColumnValue("amount",xmlDataAllDom)==null?"":genericUtility.getColumnValue("amount",xmlDataAllDom));
paymentOpt = genericUtility.getColumnValue("payment_opt",xmlDataAllDom); paymentOpt = genericUtility.getColumnValue("payment_opt",xmlDataAllDom);
System.out.println("@@@@ paymentOpt["+paymentOpt+"]amount["+amount+"]"); System.out.println("@@@@ paymentOpt["+paymentOpt+"]amount["+amount+"]");
String amountStr = ""+amount;
String complDateStr = checkNull(genericUtility.getColumnValue("compl_date",xmlDataAllDom)); String complDateStr = checkNull(genericUtility.getColumnValue("compl_date",xmlDataAllDom));
// xml end // xml end
...@@ -238,7 +238,7 @@ public class POMilestoneCnf ...@@ -238,7 +238,7 @@ public class POMilestoneCnf
} }
*/ */
System.out.println("tranId["+tranId+"]tranType["+tranType+"]timeDiff["+timeDiff+"]paymentOpt["+paymentOpt+"]taskCode["+taskCode+"]complDateStr["+complDateStr+"]"); System.out.println("tranId["+tranId+"]tranType["+tranType+"]timeDiff["+timeDiff+"]paymentOpt["+paymentOpt+"]taskCode["+taskCode+"]complDateStr["+complDateStr+"]amountStr["+amountStr+"]");
if( "P".equalsIgnoreCase(tranType)) if( "P".equalsIgnoreCase(tranType))
{ // voucher created for tran type 'P' { // voucher created for tran type 'P'
...@@ -260,24 +260,22 @@ public class POMilestoneCnf ...@@ -260,24 +260,22 @@ public class POMilestoneCnf
if("P".equalsIgnoreCase(paymentOpt)) if("P".equalsIgnoreCase(paymentOpt))
{ {
String returnStr2 = voucherValidate ( purcOrder, amount, conn);
System.out.println("voucherValidate returnStr2["+returnStr2+"]");
if(!(returnStr2.indexOf("Success") > -1))
{
//conn.rollback();
System.out.println("voucherValidate() failed...rollback()...");
return returnStr2;
}
CreatePoVoucherAdvance createPoVouchAdv = new CreatePoVoucherAdvance(); CreatePoVoucherAdvance createPoVouchAdv = new CreatePoVoucherAdvance();
returnStr = createPoVouchAdv.createPoVoucher(purcOrder,xtraParams,conn,"PR", 0,today ,taskCode,relAgnst,lineNoOrd); returnStr = createPoVouchAdv.createPoVoucher(purcOrder,xtraParams,conn,"PR", 0,today ,taskCode,relAgnst,lineNoOrd);
System.out.println("CreatePoVoucherAdvance returnStr["+returnStr+"]"); System.out.println("CreatePoVoucherAdvance returnStr["+returnStr+"]");
if(returnStr.indexOf("Success") > -1 ) if(returnStr.indexOf("Success") > -1 )
{ {
String returnStr2 = voucherValidate ( tranId, purcOrder, xmlDataAll,returnStr, conn);
System.out.println("voucherValidate returnStr2["+returnStr2+"]");
if(!(returnStr2.indexOf("Success") > -1))
{
conn.rollback();
System.out.println("voucherValidate failed...rollback()...");
return returnStr2;
}
System.out.println("CreatePoVoucherAdvance created Successfully["+returnStr+"]"); System.out.println("CreatePoVoucherAdvance created Successfully["+returnStr+"]");
conn.commit(); conn.commit();
String[] arrayForTranId = returnStr.split("<TranID>"); String[] arrayForTranId = returnStr.split("<TranID>");
...@@ -330,6 +328,8 @@ public class POMilestoneCnf ...@@ -330,6 +328,8 @@ public class POMilestoneCnf
{ // insert into purc_milstn with tran type as 'D' { // insert into purc_milstn with tran type as 'D'
System.out.println("@@@@@@@@ insert into purc_milstn with tran type as 'D' "); System.out.println("@@@@@@@@ insert into purc_milstn with tran type as 'D' ");
double penalatyAmount = penalatyAmount(xmlDataAllDom,purcOrder,amountStr,timeDiff,taskCode,conn );
xmlBuff = new StringBuffer(); xmlBuff = new StringBuffer();
System.out.println("--XML CREATION !!!!!--"); System.out.println("--XML CREATION !!!!!--");
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n"); xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
...@@ -367,7 +367,8 @@ public class POMilestoneCnf ...@@ -367,7 +367,8 @@ public class POMilestoneCnf
xmlBuff.append( "<tax_chap><![CDATA["+taxChap+"]]></tax_chap>"); xmlBuff.append( "<tax_chap><![CDATA["+taxChap+"]]></tax_chap>");
xmlBuff.append( "<tax_env><![CDATA["+taxEnv+"]]></tax_env>"); xmlBuff.append( "<tax_env><![CDATA["+taxEnv+"]]></tax_env>");
xmlBuff.append( "<task_code><![CDATA["+taskCode+"]]></task_code>"); xmlBuff.append( "<task_code><![CDATA["+taskCode+"]]></task_code>");
xmlBuff.append( "<amount><![CDATA["+amount+"]]></amount>"); // xmlBuff.append( "<amount><![CDATA["+amount+"]]></amount>"); //penalatyAmount
xmlBuff.append( "<amount><![CDATA["+penalatyAmount+"]]></amount>"); //penalatyAmount
xmlBuff.append( "<due_date><![CDATA["+sdf.format(dueDate).toString()+"]]></due_date>"); xmlBuff.append( "<due_date><![CDATA["+sdf.format(dueDate).toString()+"]]></due_date>");
// xmlBuff.append( "<due_date><![CDATA["+dueDate+"]]></due_date>"); // xmlBuff.append( "<due_date><![CDATA["+dueDate+"]]></due_date>");
xmlBuff.append( "<task_status><![CDATA[P]]></task_status>"); xmlBuff.append( "<task_status><![CDATA[P]]></task_status>");
...@@ -382,7 +383,8 @@ public class POMilestoneCnf ...@@ -382,7 +383,8 @@ public class POMilestoneCnf
//xmlBuff.append( "<compl_date><![CDATA[]]></compl_date>"); //xmlBuff.append( "<compl_date><![CDATA[]]></compl_date>");
xmlBuff.append( "<compl_date><![CDATA["+complDateStr+"]]></compl_date>"); xmlBuff.append( "<compl_date><![CDATA["+complDateStr+"]]></compl_date>");
xmlBuff.append( "<allow_override><![CDATA["+allowOverride+"]]></allow_override>"); xmlBuff.append( "<allow_override><![CDATA["+allowOverride+"]]></allow_override>");
xmlBuff.append( "<amount_orig><![CDATA["+amountOrig+"]]></amount_orig>"); xmlBuff.append( "<amount_orig><![CDATA["+penalatyAmount+"]]></amount_orig>");
// xmlBuff.append( "<amount_orig><![CDATA["+amountOrig+"]]></amount_orig>");
xmlBuff.append( "<date_format><![CDATA["+genericUtility.getApplDateFormat()+"]]></date_format>"); xmlBuff.append( "<date_format><![CDATA["+genericUtility.getApplDateFormat()+"]]></date_format>");
xmlBuff.append( "<add_user><![CDATA["+chgUser+"]]></add_user>"); xmlBuff.append( "<add_user><![CDATA["+chgUser+"]]></add_user>");
xmlBuff.append( "<add_date><![CDATA["+ sdf.format(currentDate).toString() +"]]></add_date>"); xmlBuff.append( "<add_date><![CDATA["+ sdf.format(currentDate).toString() +"]]></add_date>");
...@@ -420,9 +422,7 @@ public class POMilestoneCnf ...@@ -420,9 +422,7 @@ public class POMilestoneCnf
HashMap<String , String> drcrMap = new HashMap<String, String>(); HashMap<String , String> drcrMap = new HashMap<String, String>();
// sql= " select tran_id__vch from pur_milstn where tran_id = ? "; // sql= " select tran_id__vch from pur_milstn where tran_id = ? ";
sql = " select tran_id__vch from pur_milstn where " + sql = " select tran_id__vch from pur_milstn where tran_id = ? and tran_id__vch is not null ";
" purc_order in ( select purc_order from pur_milstn where tran_id = ? ) " +
" and tran_id__vch is not null ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -445,7 +445,7 @@ public class POMilestoneCnf ...@@ -445,7 +445,7 @@ public class POMilestoneCnf
drcrMap.put("rel_amt", String.valueOf(amount)); drcrMap.put("rel_amt", String.valueOf(amount));
drcrMap.put("date_diff", String.valueOf(timeDiff)); drcrMap.put("date_diff", String.valueOf(timeDiff));
if( amount == 0 ) if( amount > 0 )
{ {
returnStr = createDebitNote(drcrMap,conn); returnStr = createDebitNote(drcrMap,conn);
System.out.println("createDebitNote tranId["+tranId+"]returnStr["+returnStr+"]"); System.out.println("createDebitNote tranId["+tranId+"]returnStr["+returnStr+"]");
...@@ -519,20 +519,107 @@ public class POMilestoneCnf ...@@ -519,20 +519,107 @@ public class POMilestoneCnf
} }
private String voucherValidate(String tranId,String purcOrder, String xmlDataAll, String tranIdxml, Connection conn ) throws SQLException private double penalatyAmount(Document xmlDataAllDom,String purcOrder,String relAmt,double datediff,String taskCode,Connection conn ) throws SQLException
{
System.out.println("penalatyAmount().calculation.....called...datediff :"+datediff);
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql="";
int cnt = 0,count=0,detailsCnt =0,shipmentleadTime=0,lineNo=0,minDays=0,maxDays=0;
//ConnDriver connDriver = new ConnDriver();
ITMDBAccessLocal itmDBAccessLocal = new ITMDBAccessEJB();
// long diff=0,datediff=0;
double finChrge=0.0,minAmt=0.0,maxAmt=0.0,amtDet=0.0,taxAmtDet=0.0,amount=0.0,pentlyAmt=0.0;
double exchRate = 0.0,billAmt=0.0,taxAmt=0.0,totAmt=0.0,netAMt=0.0;
String fchgType="" ;
sql = " select min_day,max_day,fin_chg,fchg_type,min_amt,max_amt from pord_dlv_term where purc_order= ? " +
" and REF_CODE=? and ? between min_day and max_day ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
pstmt.setString(2, taskCode);
pstmt.setDouble(3, datediff);
rs = pstmt.executeQuery();
if (rs.next())
{
//siteCode = rs.getString("SITE_CODE");
minDays=rs.getInt("min_day");
maxDays=rs.getInt("max_day");
finChrge=rs.getDouble("fin_chg");
fchgType=rs.getString("fchg_type");
minAmt=rs.getDouble("min_amt");
maxAmt=rs.getDouble("max_amt");
fchgType=fchgType==null ? "" :fchgType;
System.out.println("minDays :"+minDays);
System.out.println("maxDays :"+maxDays);
System.out.println("finChrge :"+finChrge);
System.out.println("fchgType :"+fchgType);
System.out.println("minAmt :"+minAmt);
System.out.println("maxAmt :"+maxAmt);
System.out.println("========Penalty amount calculation=======");
System.out.println("Purchase order :"+purcOrder);
System.out.println("relAmt :"+relAmt);
System.out.println("finChrge:"+finChrge);
if(fchgType.equalsIgnoreCase("P"))
{
amount=Double.parseDouble(relAmt);
System.out.println("Formula :pentlyAmt=(finChrge * amount)/100;");
pentlyAmt=(finChrge * amount)/100;//finChrge conside as percentage
System.out.println("Calculated pentlyAmt :"+pentlyAmt);
}
else if(fchgType.equalsIgnoreCase("Q"))
{
System.out.println("Formula :pentlyAmt=finChrge * amount");
amount=Double.parseDouble(relAmt);
pentlyAmt=finChrge * amount;//finChrge conside as Quantity
}
else
{
System.out.println("Formula:pentlyAmt=finChrge;");
System.out.println("Formula :pentlyAmt=finChrge");
pentlyAmt=finChrge;//finChrge conside as fixed amount
}
System.out.println("calculate penalaty amount :"+pentlyAmt);
if(pentlyAmt > maxAmt)
{
pentlyAmt=maxAmt;
}
else if(pentlyAmt < minAmt)
{
pentlyAmt=minAmt;
}
// flag=true;
System.out.println("selected pentlyAmt from min to max amount:"+pentlyAmt);
}
else
{
System.out.println("data not found in pord_dlv_term for penalty calculation!!");
// flag=false;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
return pentlyAmt;
}
private String voucherValidate( String purcOrder, double vouchAmt, Connection conn ) throws SQLException
{ {
System.out.println("@@@@@@ voucherValidate called............"); System.out.println("@@@@@@ voucherValidate called............");
ResultSet rs = null; ResultSet rs = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String sql="", tranIdForVoucher="", returnStr= ""; String sql="", returnStr= ""; // tranIdForVoucher="",
double vouchTotAmt=0; double vouchTotAmt=0;
double ordAmt=0, vouchAmt= 0 ; double ordAmt=0 ;
String[] arrayForTranId = tranIdxml.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
tranIdForVoucher = arrayForTranId[1].substring(0,endIndex);
tranIdForVoucher=tranIdForVoucher==null ? "" : tranIdForVoucher.trim();
System.out.println("tranIdForVoucher["+tranIdForVoucher+"]");
sql = " select sum(tot_amt) from voucher where purc_order = ? " ; sql = " select sum(tot_amt) from voucher where purc_order = ? " ;
// "and confirmed = 'Y' " ; // "and confirmed = 'Y' " ;
...@@ -561,7 +648,7 @@ public class POMilestoneCnf ...@@ -561,7 +648,7 @@ public class POMilestoneCnf
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = " select tot_amt from voucher where tran_id = ? " ; /*sql = " select tot_amt from voucher where tran_id = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdForVoucher); pstmt.setString(1, tranIdForVoucher);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -572,9 +659,9 @@ public class POMilestoneCnf ...@@ -572,9 +659,9 @@ public class POMilestoneCnf
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;*/
double differenceAmt = ordAmt- vouchTotAmt ; double differenceAmt = ordAmt - vouchTotAmt ;
System.out.println("ordAmt["+ordAmt+"]-vouchTotAmt["+vouchTotAmt+"]=vouchAmt["+vouchAmt+"]>differenceAmt["+differenceAmt+"]"); System.out.println("ordAmt["+ordAmt+"]-vouchTotAmt["+vouchTotAmt+"]=vouchAmt["+vouchAmt+"]>differenceAmt["+differenceAmt+"]");
...@@ -612,8 +699,6 @@ public class POMilestoneCnf ...@@ -612,8 +699,6 @@ public class POMilestoneCnf
public String createDebitNote(HashMap<String,String> drcrMap,Connection conn) public String createDebitNote(HashMap<String,String> drcrMap,Connection conn)
throws RemoteException, ITMException { throws RemoteException, ITMException {
StringBuffer xmlBuff = null; StringBuffer xmlBuff = null;
String xmlString = null; String xmlString = null;
// Connection conn = null; // Connection conn = null;
...@@ -683,15 +768,20 @@ public class POMilestoneCnf ...@@ -683,15 +768,20 @@ public class POMilestoneCnf
System.out.println("processDate1:"+processDate); System.out.println("processDate1:"+processDate);
System.out.println("datediff :"+datediff); System.out.println("datediff :"+datediff);
pentlyAmt = Double.parseDouble(relAmt== null ?"0":relAmt);
System.out.println("@@@@@@@@@@@@ final pentlyAmt["+pentlyAmt+"]");
/* /*
select * from TARODEV.pord_dlv_term where purc_order='718PNF0299' select * from TARODEV.pord_dlv_term where purc_order='718PNF0299'
and min_day <=14 and max_day>=14 and min_day <=14 and max_day>=14
*/ */
/* sql = "select * from (select min_day,max_day,fin_chg,fchg_type,min_amt,max_amt from pord_dlv_term where " + /* sql = "select * from (select min_day,max_day,fin_chg,fchg_type,min_amt,max_amt from pord_dlv_term where " +
"purc_order=? and REF_CODE=? ORDER BY ABS( min_day - ? ) ,ABS( max_day - ? ) ) where rownum <=1 ";*/ "purc_order=? and REF_CODE=? ORDER BY ABS( min_day - ? ) ,ABS( max_day - ? ) ) where rownum <=1 ";*/
/*
sql = " select min_day,max_day,fin_chg,fchg_type,min_amt,max_amt from pord_dlv_term where purc_order= ? " + sql = " select min_day,max_day,fin_chg,fchg_type,min_amt,max_amt from pord_dlv_term where purc_order= ? " +
" and REF_CODE=? and ? between min_day and max_day "; " and REF_CODE=? and ? between min_day and max_day ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -766,12 +856,12 @@ public class POMilestoneCnf ...@@ -766,12 +856,12 @@ public class POMilestoneCnf
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
*/
/* /*
if flag is true then only debit node generated. if flag is true then only debit node generated.
flag true means purc_order data exist in pord_dlv_term and penalty is greater than 0. flag true means purc_order data exist in pord_dlv_term and penalty is greater than 0.
*/ */
if(flag) if( pentlyAmt > 0 )
{ {
sql = " select SUPP_CODE,PURC_ORDER,ACCT_CODE,CCTR_CODE,DUE_DATE,SITE_CODE " + sql = " select SUPP_CODE,PURC_ORDER,ACCT_CODE,CCTR_CODE,DUE_DATE,SITE_CODE " +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment