Commit 7225aa12 authored by cpatil's avatar cpatil

fright rate calculation code modified


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98438 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f1f2eb43
......@@ -10,7 +10,8 @@ package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.GenericUtility;
// import ibase.webitm.utility.GenericUtility;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
......@@ -31,7 +32,9 @@ import java.sql.Timestamp;
public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, ShipmentLocICRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
......@@ -121,7 +124,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
if(childNodeName.equalsIgnoreCase("shipment_id"))
{
shipmentId = genericUtility.getColumnValue("shipment_id", dom);
shipmentId = checkNull(genericUtility.getColumnValue("shipment_id", dom));
//Shipment Date should not be blank.
String keyFlag = setDescription("key_flag", "transetup", "tran_window", "w_shipment_loc", conn);
......@@ -718,6 +721,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
rs = null;
pstmt.close();
pstmt = null;
System.out.println("COUNT["+cnt+"]");
if( cnt > 0)
{
retStr = "TRUE";
......@@ -778,7 +782,8 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0;
......@@ -798,6 +803,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
int i=0,noArt=0;
Timestamp despDate=null;
double netWeightCIss=0;
try
{
......@@ -1291,13 +1297,13 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
{
System.out.println("@@@@@@@@ itemchange charge_code called @@@@@@@@");
chargeCode = genericUtility.getColumnValue("charge_code", dom);
shipmentId = genericUtility.getColumnValue("shipment_id", dom1);
chargeCode = genericUtility.getColumnValue("charge_code", dom)==null?"":genericUtility.getColumnValue("charge_code", dom).trim();
shipmentId = genericUtility.getColumnValue("shipment_id", dom1)==null?"":genericUtility.getColumnValue("shipment_id", dom1).trim();
frtList = genericUtility.getColumnValue("frt_list", dom1);
stanCodeFrom = genericUtility.getColumnValue("stan_code__from", dom1);
stanCodeTo = genericUtility.getColumnValue("stan_code__to", dom1);
loadType = genericUtility.getColumnValue("load_type", dom1);
frtList = genericUtility.getColumnValue("frt_list", dom1)==null?"":genericUtility.getColumnValue("frt_list", dom1).trim();
stanCodeFrom = genericUtility.getColumnValue("stan_code__from", dom1)==null?"":genericUtility.getColumnValue("stan_code__from", dom1).trim();
stanCodeTo = genericUtility.getColumnValue("stan_code__to", dom1)==null?"":genericUtility.getColumnValue("stan_code__to", dom1).trim();
loadType = genericUtility.getColumnValue("load_type", dom1)==null?"":genericUtility.getColumnValue("load_type", dom1).trim();
/*
sql = " select c.descr,b.charges_mode,b.amount,b.charge_code__add,sequence " +
" from shipment a, freight_rate_det b, gencodes c " +
......@@ -1332,9 +1338,9 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
pstmt.setString(3,stanCodeTo );
pstmt.setString(4,loadType );
pstmt.setString(5,shipmentId );
pstmt.setString(6,"CHARGE_CODE" );
pstmt.setString(7,chargeCode );
// pstmt.setString(5,shipmentId );
pstmt.setString(5,"CHARGE_CODE" );
pstmt.setString(6,chargeCode );
rs = pstmt.executeQuery();
if(rs.next())
......@@ -1432,7 +1438,24 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
pstmt.close();
pstmt = null;
nettWeight = (nettWeight + netWeight) * amount;
sql = " select nvl(sum(gross_weight),0) from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, shipmentId);
rs = pstmt.executeQuery();
if( rs.next())
{
grossWeightCIss = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@@@@@grossWeightCIss["+grossWeightCIss+"]");
nettWeight = (nettWeight + netWeight + grossWeightCIss ) * amount;
valueXmlString.append("<amount>").append("<![CDATA["+nettWeight+"]]>").append("</amount>");
}
else if ("V".equalsIgnoreCase(mode) ) //volume
......@@ -1492,7 +1515,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
System.out.println("@@@@@2 stanCodeShip ["+ stanCodeShip + "]");
stationaDescr = setDescription("descr", "station", "stan_code", stanCodeShip, conn);
valueXmlString.append("<stationa_descr protect = \"1\">").append("<![CDATA["+stationaDescr+"]]>").append("</stationa_descr>");
}
} //stationa_descr
else if( currentColumn.trim().equalsIgnoreCase( "stan_code__dlv" ) )
......
......@@ -265,7 +265,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("updCnt["+updCnt+"]");
frtAmt = val;
}
else
......@@ -277,7 +277,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("updCnt["+updCnt+"]");
frtAmt = minValue;
} //end if
......@@ -378,13 +378,13 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
}
val = val + frtAmt;
}
else
{
val = frtAmt;
} // end if
System.out.println("@@@@@@ val["+val+"]chargeRate["+chargeRate+"]");
val = ( val * chargeRate)/100 ;
System.out.println("@@@@@@ val["+val+"]");
}
else if("W".equalsIgnoreCase(chargesMode)) // ls_mode = 'W' then//weight
{
......@@ -438,6 +438,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
val = ( tempNettWeight + tempNetWeight + grossWeightCIss ) * chargeRate ;
System.out.println("@@@@@@ val["+val+"]chargeRate["+chargeRate+"]");
} // end if
......
......@@ -56,16 +56,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
String retString="";
String errString = "";
String sql = "";
String lorryNo = "";
String lrNo = "";
String confirmed = "";
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String errCode="",recallFrt="";
double totalFreight=0;
Timestamp lrDate=null;
String errCode="" ;
try
{
......@@ -77,25 +73,19 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
// check whether already confirmed or not
sql = " select confirmed , total_freight , lr_no , lr_date , recall_frt, lorry_no " +
" from shipment where shipment_id = ? ";
sql = " select confirmed from shipment where shipment_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next())
{
confirmed = rs.getString("confirmed");
totalFreight = rs.getDouble("total_freight");
lrNo = checkNull(rs.getString("lr_no"));
lrDate = rs.getTimestamp("lr_date");
recallFrt = checkNull(rs.getString("recall_frt"));
lorryNo = checkNull(rs.getString("lorry_no"));
confirmed = checkNull(rs.getString("confirmed"));
}
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
rs.close();rs = null;
pstmt.close();pstmt = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@shipment_id["+tranId+"]confirmed["+confirmed+"]");
if( "Y".equalsIgnoreCase(confirmed))
{
......@@ -118,17 +108,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
else
{
conn.commit();
//retString=generateTrackInfo(tranId,conn);
System.out.println("final retString @@@@@"+retString);
// retString=generateTrackInfo(tranId,conn); // comment this method by mahendra
System.out.println("@@@@@@@@@ commit successful...........");
errString = itmDBAccessLocal.getErrorString("","VTCONFIRM","");
System.out.println("@@@@@@@@@ confirm successful...........");
}
}
}
catch(Exception e)
{
......@@ -155,6 +140,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
throw new ITMException(se);
}
}
System.out.println("final errString @@@@@"+errString);
return errString;
}
......@@ -163,11 +149,11 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
throws RemoteException, ITMException
{
PreparedStatement pstmt = null, pstmtSql = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
int cnt = 0,updCnt=0;
String retString = "", sql = "", errCode = "";
Timestamp sysDate = null, tranDate = null,lrDate=null,lrDateUpd=null;
String sql = "", sql1 = "", errCode = "";
Timestamp sysDate = null, lrDate=null,lrDateUpd=null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
int cntDist=0,cntConsIss=0;
......@@ -177,35 +163,35 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
try
{
System.out.println("@@@@@@@@@@@@@@@ confirmShipmentLoc method called next..............");
System.out.println("@@@@@@@@@@@@@@@ confirmShipmentLoc method called next.....1, tranId["+tranId+"].........");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate= Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = " select confirmed , total_freight , lr_no , lr_date , recall_frt, lorry_no " +
" from shipment where shipment_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next())
{
confirmed = rs.getString("confirmed");
confirmed = checkNull(rs.getString("confirmed"));
totalFreight = rs.getDouble("total_freight");
lrNo = checkNull(rs.getString("lr_no"));
lrDate = rs.getTimestamp("lr_date");
recallFrt = checkNull(rs.getString("recall_frt"));
lorryNo = checkNull(rs.getString("lorry_no"));
}
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
// check shipment allocated to at least one despatch or dist issue
sql = " select count(1) " +
......@@ -221,7 +207,9 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
rs = null;
pstmt.close();
pstmt = null;
System.out.println("cnt["+cnt+"]");
if( cnt == 0 ) // ll_cnt = 0 then
{
sql = " select count(1) " +
......@@ -244,7 +232,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
{
sql = " select count(1) from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) " +
" and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
......@@ -323,7 +312,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("@@@@totGwt["+totGwt+"]");
// for despatch
sql = " select desp_id,gross_weight, lr_date, lr_no, lorry_no from despatch " +
" where shipment_id = ? and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -336,11 +325,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]gwtDesp["+gwtDesp+"]");
//calculating the freight amt proportionately
......@@ -385,18 +370,26 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("@@@@@@[despatch]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[despatch]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql = " update despatch set freight = ?, lr_no = ? , lr_date = ? ," +
sql1 = " update despatch set freight = ?, lr_no = ? , lr_date = ? ," +
" lorry_no = ? where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, despId);
updCnt = pstmt.executeUpdate();
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, despId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// for distord_iss
sql = " select tran_id,gross_weight,lr_date, lr_no, lorry_no from distord_iss " +
" where shipment_id = ? and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -409,11 +402,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@distOrdIssId["+distOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
......@@ -455,21 +444,27 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql = " update distord_iss set frt_amt = ?, lr_no = ? , " +
sql1 = " update distord_iss set frt_amt = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, distOrdIssId);
updCnt = pstmt.executeUpdate();
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, distOrdIssId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
////
// for cons_issue
sql = " select cons_issue,gross_weight,lr_date, lr_no, lorry_no from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -482,11 +477,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@conOrdIssId["+conOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
......@@ -525,21 +516,28 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql = " update CONSUME_ISS set FREIGHT_AMT = ?, lr_no = ? , " +
sql1 = " update CONSUME_ISS set FREIGHT_AMT = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where cons_issue = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, conOrdIssId);
updCnt = pstmt.executeUpdate();
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, conOrdIssId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// END TEST
// END TEST
/*
//calculating the freight amt proportionately
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
......@@ -555,7 +553,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
{ // lc_calc_frt = lc_frt_amt - (lc_tot_frt - lc_calc_frt)
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
......@@ -591,9 +589,10 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
*/
/// test
// everything's OK, update shipment.
if( errCode == null || errCode.trim().length() == 0 )
{
......
......@@ -246,6 +246,11 @@ public class ShipmentLocDefaultAct extends ActionHandlerEJB implements ShipmentL
valueXmlString.append("</Detail>\r\n");
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("valueXmlString =" + valueXmlString.toString());
valueXmlString.append("</Root>\r\n");
......
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