Commit ffd65744 authored by dpawar's avatar dpawar

added source for scheme


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94425 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 10968d80
...@@ -37,7 +37,7 @@ import com.sun.jmx.snmp.Timestamp; ...@@ -37,7 +37,7 @@ import com.sun.jmx.snmp.Timestamp;
@Stateless @Stateless
public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote
{ {
String siteCodeG="",invTypeG="",xtraParamsG=""; String siteCodeG="",invTypeG="",xtraParamsG="",schemeCodeG="",multipleScheme="";
Map<String,Double> partialInvoiceMapG = new HashMap <String,Double>(); Map<String,Double> partialInvoiceMapG = new HashMap <String,Double>();
Map <String,Double>partialInvMap=new HashMap<String,Double>(); Map <String,Double>partialInvMap=new HashMap<String,Double>();
int invdoneCnt=0; int invdoneCnt=0;
...@@ -307,6 +307,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -307,6 +307,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
System.out.println("Final invoice Id ready for debit note12---->>["+podProcessInvIDList+"]"); System.out.println("Final invoice Id ready for debit note12---->>["+podProcessInvIDList+"]");
...@@ -487,9 +489,16 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -487,9 +489,16 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
} }
//check if scheme is apply or not //check if scheme is apply or not
if(isSchemeApply(conn,itemCode)){ if(isSchemeApply(conn,itemCode,invoiceId)){
//java code if scheme is apply //java code if scheme is apply
System.out.println("-------Scheme is apply -----------"); System.out.println("-------Scheme is apply -----------");
System.out.println("multipleScheme--->>["+multipleScheme+"]");
if("FOUND".equalsIgnoreCase(multipleScheme)){
errCode="VTITEM10"; //Multiple Scheme Code !
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
}
schemeQty=schemeApply(conn,invoiceId,itemCode); schemeQty=schemeApply(conn,invoiceId,itemCode);
System.out.println("schemeQty map---->>["+schemeQty+"]"); System.out.println("schemeQty map---->>["+schemeQty+"]");
if(schemeQty.size() > 0){ if(schemeQty.size() > 0){
...@@ -859,14 +868,20 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -859,14 +868,20 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
return inv45dayListL; //podProcessInvIDListL; return inv45dayListL; //podProcessInvIDListL;
} }
private boolean isSchemeApply(Connection conn,String itemCodeL) private boolean isSchemeApply(Connection conn,String itemCodeL,String invoiceId)
{ {
String sql=""; String sql="",custCodeBil="",stateCode="",countCode="",schemeCode="",applyCustList="",
noApplyCustList="";
schemeCodeG="";
multipleScheme="NOTFOUND";
ResultSet rsL=null; ResultSet rsL=null;
PreparedStatement pstmtL=null; PreparedStatement pstmtL=null;
int countL=0; int countL=0;
ProofOfDelivery podObject=null;
boolean schemeApply=false;
ArrayList <String> schemeCodeList =new ArrayList <String>();
try{ try{
sql="select count(*) from bomdet where item_code= ? and eff_from <= sysdate and " /*sql="select count(*) from bomdet where item_code= ? and eff_from <= sysdate and "
+ "valid_upto >= sysdate order by nature"; + "valid_upto >= sysdate order by nature";
pstmtL=conn.prepareStatement(sql); pstmtL=conn.prepareStatement(sql);
pstmtL.setString(1, itemCodeL); pstmtL.setString(1, itemCodeL);
...@@ -879,8 +894,128 @@ private boolean isSchemeApply(Connection conn,String itemCodeL) ...@@ -879,8 +894,128 @@ private boolean isSchemeApply(Connection conn,String itemCodeL)
pstmtL.close(); pstmtL.close();
pstmtL=null; pstmtL=null;
if(countL > 0) if(countL > 0)
return true; return true; */
podObject=ProofOfDelivery.getInstance(); //siteCodeG
custCodeBil=podObject.getColumnDescr(conn, "cust_code__bil", "invoice", "invoice_id", invoiceId);
custCodeBil=custCodeBil == null ? "" : custCodeBil.trim();
sql= "select state_code,count_code from customer where cust_code= ? ";
pstmtL=conn.prepareStatement(sql);
pstmtL.setString(1, custCodeBil);
rsL=pstmtL.executeQuery();
if(rsL.next())
{
stateCode = rsL.getString(1) == null ? "" : rsL.getString(1).trim();
countCode = rsL.getString(2) == null ? "" : rsL.getString(2).trim();
}
rsL.close();
rsL=null;
pstmtL.close();
pstmtL=null;
System.out.println("StateCode---->>["+stateCode+"]");
System.out.println("countCode---->>["+countCode+"]");
sql = " select a.scheme_code,a.apply_cust_list,a.noapply_cust_list "
+ " from scheme_applicability a, scheme_applicability_det b"
+ " where a.scheme_code = b.scheme_code"
+ " and a.item_code = ?"
+ " and a.app_from <= ?"
+ " and a.valid_upto >= ?"
+ " and ( b.site_code = ? or b.state_code = ? or b.count_code = ? )" ;// stateCode value not fetched
pstmtL=conn.prepareStatement(sql);
pstmtL.setString(1, itemCodeL);
pstmtL.setTimestamp(2, new java.sql.Timestamp(System.currentTimeMillis()));
pstmtL.setTimestamp(3, new java.sql.Timestamp(System.currentTimeMillis()));
pstmtL.setString(4, siteCodeG);
pstmtL.setString(5, stateCode);
pstmtL.setString(6, countCode);
rsL=pstmtL.executeQuery();
while(rsL.next()){
schemeCodeList.add(rsL.getString(1));
applyCustList=rsL.getString(2);
noApplyCustList=rsL.getString(3);
}
applyCustList=applyCustList ==null ? "" :applyCustList.trim();
noApplyCustList=noApplyCustList ==null ? "" :noApplyCustList.trim();
rsL.close();
rsL=null;
pstmtL.close();
pstmtL=null;
System.out.println("schemeCodeList size---->>["+schemeCodeList.size()+"]");
System.out.println("noApplyCustList---->>["+noApplyCustList+"]");
System.out.println("applyCustList---->>["+applyCustList+"]");
if(schemeCodeList.size() == 0){
return false;
}
else if(schemeCodeList.size() > 1){
multipleScheme="FOUND";
return true;
}
/* If no apply customer list is not null then POD cust code will be
checked in this list.
If match is found scheme won't be applicable
If match not found then system will check for apply customer list
If no apply customer list is null system will check for apply
customer list
If apply customer list is null then scheme will be applicable
If apply customer list is not null then system will check for POD
cust code in this list.
If no match found then scheme wont be applicable
If match found then scheme will be applicable */
else if(schemeCodeList.size() == 1){
if(noApplyCustList.length() == 0 && applyCustList.length() ==0){
schemeApply=true;
}
if(noApplyCustList.length() > 0){ //if no apply customer list not null then checked
String [] custList=noApplyCustList.split(",");
for(int i=0 ;i < custList.length; i++)
{
System.out.println("Customer in noApplyCustList --->>["+custList[i]+"]");
if(custCodeBil.equalsIgnoreCase(custList[i].trim()))
{
System.out.println("scheme not apply111--->>["+custList[i]+"]");
return false;
}
}
}
if(applyCustList.length() > 0){// if apply customer list not null then checked
String [] custList=applyCustList.split(",");
for(int i=0 ;i < custList.length; i++)
{
System.out.println("Customer in applyCustList --->>["+custList[i]+"]");
if(custCodeBil.equalsIgnoreCase(custList[i].trim()))
{
System.out.println("scheme apply222--->>["+custList[i]+"]");
schemeApply=true;
}
}
}
}
System.out.println("Scheme apply in isSchemeApply------>>["+schemeApply+"]");
if(schemeApply){
int count=0;
sql="select count(*) from bomdet where item_code= ? and bom_code = ?";
pstmtL=conn.prepareStatement(sql);
pstmtL.setString(1, itemCodeL);
pstmtL.setString(2, schemeCodeList.get(0));
rsL=pstmtL.executeQuery();
if(rsL.next()){
count=rsL.getInt(1);
}
System.out.println("count in bomdet----->>["+count+"]");
if(count > 0){
schemeCodeG=schemeCodeList.get(0);
return true;
}else
return false;
}
} }
catch(Exception e) catch(Exception e)
...@@ -904,10 +1039,10 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i ...@@ -904,10 +1039,10 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i
double quantity=0; double quantity=0;
try{ try{
sql="select qty_per,nature from bomdet where item_code= ? and eff_from <= sysdate and " sql="select qty_per,nature from bomdet where item_code = ? and bom_code = ?";
+ "valid_upto >= sysdate order by nature";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2, schemeCodeG);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()){ while(rs.next()){
quantity=rs.getDouble(1); quantity=rs.getDouble(1);
...@@ -919,6 +1054,8 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i ...@@ -919,6 +1054,8 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i
if("F".equalsIgnoreCase(nature.trim())){ if("F".equalsIgnoreCase(nature.trim())){
schemeQtyMap.put("free_qty", quantity); schemeQtyMap.put("free_qty", quantity);
System.out.println("free qty added in map------>>["+schemeQtyMap.get("free_qty")+"]"); System.out.println("free qty added in map------>>["+schemeQtyMap.get("free_qty")+"]");
}else{
schemeQtyMap.put("free_qty", 0.0);
} }
} //end while } //end while
rs.close(); rs.close();
...@@ -1462,7 +1599,7 @@ public String actualQtyPODProcessPartial(Connection conn) //partialInvoiceMap ...@@ -1462,7 +1599,7 @@ public String actualQtyPODProcessPartial(Connection conn) //partialInvoiceMap
return errString; return errString;
} }
if(isSchemeApply(conn,itemCode)){ if(isSchemeApply(conn,itemCode,invIdPartial)){
//java code if scheme is apply //java code if scheme is apply
System.out.println("-------Scheme is apply -----------"); System.out.println("-------Scheme is apply -----------");
schemeQty=schemeApply(conn,invIdPartial,itemCode); schemeQty=schemeApply(conn,invIdPartial,itemCode);
......
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