Commit 2bfd42b6 authored by rtiwari's avatar rtiwari

Validation added- Debit Note cannot be generate less than 100 Debit amount


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98358 ce508802-f39f-4f6c-b175-0d175dae99d5
parent afeb72b1
......@@ -245,14 +245,15 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
pstmt.setString(2, "Y");
pstmt.setString(3, invType);
} else {
//sql = "select invoice_id from invoice where cust_code__bil between ? and ? and site_code = ? and confirmed = ?"
// + " and sysdate - conf_date > 45 and inv_type =?";
// sql = "select invoice_id from invoice where
// cust_code__bil between ? and ? and site_code = ? and
// confirmed = ?"
// + " and sysdate - conf_date > 45 and inv_type =?";
sql = "select invoice_id from invoice where cust_code__bil between ? and ? and site_code = ? and confirmed = ?"
+ " and conf_date > '"
+ disDate
+ "' and inv_type = ?";
+ " and conf_date > '"
+ disDate
+ "' and inv_type = ?";
// [13-JUL-15] CHANGED BY
// SANKET GIRME TO GET THE
// INVOICE_DATE GRETTER THAN
......@@ -389,9 +390,9 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
ArrayList<String> podProcessInvIDListL, String priceListL,
String xtraParams, String siteCode, String invType) {
invdoneCnt = 0;
ResultSet rs = null, rs1 = null;
ResultSet rs = null, rs1 = null, rs2 = null;
Connection conn1 = null;
PreparedStatement pstmt = null, pstmt1 = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ProofOfDelivery pod = null;
ProofOfDeliveryConf podC = null;
Map<String, Object> invoiceDetailsMap = null;
......@@ -405,12 +406,13 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
String custCode = "", currCode = "", partial = "N", QtyInvTrace = "", scheme = "N", errCode = "", sreturnTranID = "", sql1 = "";
double invRate = 0, invQty = 0, discount = 0, priceListRate = 0, detail3Amt = 0, detail3AmtT = 0, debitNoteAmtDetail = 0;
double debitNoteAmtHdr = 0, ExchRate = 0, actualRate = 0, chargQty = 0, freeQty = 0, netPTS = 0, sreturnQuantity = 0, partialQty = 0;
int lineNotrace = 0, lineNo = 0, noOfInvoicePrc = 0, totalInvoice = 0;
int lineNotrace = 0, lineNo = 0, noOfInvoicePrc = 0, totalInvoice = 0, sumDebitNote = 0;
pod = ProofOfDelivery.getInstance();
podC = ProofOfDeliveryConf.getInstance();
ITMDBAccessEJB itmdbAccess1 = new ITMDBAccessEJB();
ConnDriver connDriver1 = new ConnDriver();
DecimalFormat df = new DecimalFormat("#.###");
boolean invstatus;
try {
conn1 = connDriver1.getConnectDB("DriverITM");
......@@ -434,7 +436,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
System.out.println("invoice ID in for loop------->>["
+ invoiceId + "]");
sql = "select rate,quantity,lot_no,lot_sl,item_code,inv_line_no,discount,item_code__ord,invoice_id "
sql = " select rate,quantity,lot_no,lot_sl,item_code,inv_line_no,discount,item_code__ord,invoice_id "
+ "from invoice_trace where invoice_id = ? order by inv_line_no";
pstmt = conn.prepareStatement(sql);
......@@ -442,6 +444,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
rs = pstmt.executeQuery();
while (rs.next()) {
invRate = rs.getDouble(1);
invQty = rs.getDouble(2);
lotNo = rs.getString(3);
......@@ -517,8 +520,10 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
// partialQty=actualQtyPODProcessPartial(conn,invoiceId,itemCode,lineNotrace);
// System.out.println("partial
// qty---->>["+partialQty+"]");
// partialMap.put(invoiceId+","+itemCode, partial);
// Check if item code Active or not."N" or null then
// partialMap.put(invoiceId+","+itemCode,
// partial);
// Check if item code Active or not."N" or
// null then
// return error message.
itemActive = pod.getColumnDescr(conn, "active",
"item", "item_code", itemCode);
......@@ -526,12 +531,14 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
.trim();
if (itemActive.equalsIgnoreCase("N")
|| itemActive.length() <= 0) {
errCode = "VTITMCNAC"; // Item code not active
errCode = "VTITMCNAC"; // Item code not
// active
errString = itmdbAccess1.getErrorString("",
errCode, "", "", conn);
errString = newErrorMessage(errString,
invoiceId);
return errString; // item code not active
return errString; // item code not
// active
}
java.util.Date tranDate = new Date();
priceListRate = getPriceListRate(priceListL,
......@@ -555,7 +562,8 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
System.out.println("multipleScheme--->>["
+ multipleScheme + "]");
if ("FOUND".equalsIgnoreCase(multipleScheme)) {
errCode = "VTITEM10"; // Multiple Scheme
errCode = "VTITEM10"; // Multiple
// Scheme
// Code !
errString = itmdbAccess1.getErrorString("",
errCode, "", "", conn);
......@@ -605,18 +613,34 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
netPTS = chargQty
/ (chargQty + freeQty)
* priceListRate;
System.out.println("chargQty ---> ["+chargQty+"]");
System.out.println("freeQty ----> ["+freeQty+"]");
System.out.println("priceListRate>["+priceListRate+"]");
System.out.println("Equation ==> netPTS = ("+chargQty+"/ ("+chargQty+" + "+freeQty+") *"+priceListRate+" )");
System.out.println("chargQty ---> ["
+ chargQty + "]");
System.out.println("freeQty ----> ["
+ freeQty + "]");
System.out.println("priceListRate>["
+ priceListRate + "]");
System.out
.println("Equation ==> netPTS = ("
+ chargQty
+ "/ ("
+ chargQty
+ " + "
+ freeQty
+ ") *"
+ priceListRate + " )");
System.out
.println("Net PTS rate----->>["
+ netPTS + "]");
actualRate = netPTS - invRate;
System.out.println("invRate == > "+invRate);
System.out.println("Second Equation ==> actualRate = "+netPTS+" - "+invRate+" ");
System.out.println("invRate == > "
+ invRate);
System.out
.println("Second Equation ==> actualRate = "
+ netPTS
+ " - "
+ invRate + " ");
System.out
.println("actualRate-------->>["
+ actualRate + "]");
......@@ -633,16 +657,16 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
}
detail3Amt = actualRate * invQty;
System.out
.println("Debit note amount-------->>["
.println("Debit note amount-->>["
+ detail3Amt + "]");
detail3AmtT = detail3AmtT + detail3Amt;
/*
* [START][17-JUL-15] Sanket Girme To
* ROunding of the Debit Note Example if
* Debit Note Amount is 0.49 then Round
* off to 0.490
* Rounding off the Debit Note Example
* if Debit Note Amount is 0.49 then
* Round off to 0.490
*
*/
String debitnt = df.format(detail3Amt) == null ? "0"
......@@ -653,7 +677,9 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
.println("Formated Approved Rate---->>["
+ detail3Amt + "]");
/* [END] [17-JUL-15] Sanket Girme */
/*
* [END] [17-JUL-15] Sanket Girme
*/
lineNo++;
detail2xmlString = detail2xmlString
......@@ -675,7 +701,8 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
System.out.println("actualRate-------->>["
+ actualRate + "]");
if (actualRate <= 0) {
errCode = "VTNGAMTE"; // negative rate
errCode = "VTNGAMTE"; // negative
// rate
errString = itmdbAccess1.getErrorString("",
errCode, "", "", conn);
errString = newErrorMessage(errString,
......@@ -715,8 +742,8 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
actualRate, invQty, lotNo,
lotSl, itemCode, detail3Amt);
} // end isSchemeApply
} // end while invoice trace
}
}// End while Loop rs2
if (rs != null) {
rs.close();
rs = null;
......@@ -725,6 +752,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
pstmt.close();
pstmt = null;
}
System.out.println("Detail2 xml-------->>[["
+ detail2xmlString + "]");
if (detail3AmtT > 0) {
......@@ -736,47 +764,71 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
"curr_code").toString()); // xmlStringAll
ExchRate = Double.parseDouble(invoiceDetailsMap
.get("exch_rate").toString());
errString = podC.genDebitNote("PRC", invoiceId,
custCode, siteCode, xtraParams, currCode,
ExchRate, detail2xmlString, detail3AmtT,
conn);
System.out
.println("------Error string after DN save--->>["
+ errString + "]");
if (errString.indexOf("Success") > -1) {
System.out
.println("Tran id for Misc. debit note------->>["
+ (podC.debitNoteTranID).trim()
+ "]");
MiscDrCrRcpConf confDebitNote = new MiscDrCrRcpConf();
errString = confDebitNote.confirm(
(podC.debitNoteTranID).trim(),
xtraParams, "", conn);
// END OF IF DB AMT CONDTION START
invstatus = checkDebitAmt(invoiceId, conn);
System.out.println("For Invoce ID = > " + invoiceId
+ "invstatus =>" + invstatus);
if (invstatus) {
errString = podC.genDebitNote("PRC", invoiceId,
custCode, siteCode, xtraParams,
currCode, ExchRate, detail2xmlString,
detail3AmtT, conn);
System.out
.println("Error String on DB Confirmation: "
+ errString);
if ((errString != null)
&& errString.indexOf("CONFSUCCES") > -1) {
int cnt = insertDataInPodTrace(conn1,
invoiceId, podC.xmlStringAll,
scheme, "N", "Y");
noOfInvoicePrc++;
if (noOfInvoicePrc == totalInvoice) {
invdoneCnt = 1;
.println("------Error string after DN save--->>["
+ errString + "]");
// }else{
// errString="Invalid Debit";
// }
if (errString.indexOf("Success") > -1) {
System.out
.println("Tran id for Misc. debit note------->>["
+ (podC.debitNoteTranID)
.trim() + "]");
MiscDrCrRcpConf confDebitNote = new MiscDrCrRcpConf();
errString = confDebitNote.confirm(
(podC.debitNoteTranID).trim(),
xtraParams, "", conn);
System.out
.println("Error String on DB Confirmation: "
+ errString);
if ((errString != null)
&& errString.indexOf("CONFSUCCES") > -1) {
int cnt = insertDataInPodTrace(conn1,
invoiceId, podC.xmlStringAll,
scheme, "N", "Y");
noOfInvoicePrc++;
if (noOfInvoicePrc == totalInvoice) {
invdoneCnt = 1;
/*
* errCode="VTPRCCSF"; errString =
* itmdbAccess1.getErrorString("",
* errCode, "", "", conn); return
* errString;
*/
}
if (cnt > 0) {
conn1.commit();
}
// conn.commit();------------commited
// when
// partial invoice end
} else {
conn.rollback();
/*
* errCode="VTPRCCSF"; errString =
* itmdbAccess1.getErrorString("",
* errCode, "", "", conn); return
* errString;
* int cnt=insertDataInPodTrace(conn1,
* invoiceId, podC.xmlStringAll,
* schemeMap, partialMap,"N"); if(cnt >
* 1) conn1.commit();
*/
errString = newErrorMessage(errString,
invoiceId);
return errString;
}
if (cnt > 0) {
conn1.commit();
}
// conn.commit();------------commited when
// partial invoice end
} else {
conn.rollback();
/*
......@@ -790,15 +842,9 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
return errString;
}
} else {
conn.rollback();
/*
* int cnt=insertDataInPodTrace(conn1,
* invoiceId, podC.xmlStringAll, schemeMap,
* partialMap,"N"); if(cnt > 1) conn1.commit();
*/
errString = newErrorMessage(errString,
invoiceId);
return errString;
System.out
.println("The debit Note Not generated for the Invoice Id=> "
+ invoiceId+" Due to total debil amt below then 100!");
}
} else {// end detail3AmtT > 0 condition
......@@ -994,6 +1040,51 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
}
// Created By Sanket Girme to Check the debit note amount is greater than
// 100 or not
public boolean checkDebitAmt(String InvId, Connection conn) throws SQLException {
PreparedStatement pstmt2 = null;
ResultSet rs2 = null;
int sumDebitNote = 0;
boolean errFlag = false;
String sql2 = "SELECT SUM(D.DEBIT_NOTE_AMT) from spl_sales_por_hdr h,spl_sales_por_det d WHERE H.TRAN_ID = D.TRAN_ID AND H.INVOICE_ID =?";
try {
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1, InvId);
rs2 = pstmt2.executeQuery();
if (rs2.next()) {
System.out
.println(" **** Inside checkDebitAmt While loop **** ");
sumDebitNote = rs2.getInt(1);
System.out.println(" FOr invoice ID => " + InvId
+ "sumDebitNote is ==> " + sumDebitNote);
if (sumDebitNote >= 100) {
errFlag = true;
}
}
} catch (Exception e) {
System.out.println("Exception in checkDebitAmt!!> " + e);
e.printStackTrace();
}
finally
{
if (rs2 != null) {
rs2.close();
rs2 = null;
}
if (pstmt2 != null) {
pstmt2.close();
pstmt2 = null;
}
}
return false;
}
private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,
ArrayList<String> inv45dayListL) {
System.out
......@@ -1502,6 +1593,9 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
pstmt.setString(1, id);
rs = pstmt.executeQuery();
while (rs.next()) {
System.out
.println("Inside 1st while Loop of generateDebitNote!!!");
// lineNoTrace=rs.getInt(1);
qty = rs.getDouble(1);
itemCode = rs.getString(2);
......@@ -1536,72 +1630,51 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
// Ingnore the invoice having Debit Note less than
// 100
String sql2 = "SELECT SUM(D.DEBIT_NOTE_AMT) from spl_sales_por_hdr h,spl_sales_por_det d WHERE H.TRAN_ID = D.TRAN_ID AND H.INVOICE_ID =?";
pstmt2 = conn.prepareStatement(sql1);
pstmt2.setString(1, id);
rs2 = pstmt2.executeQuery();
while (rs2.next()) {
sumDebitNote = rs2.getInt(1);
if (sumDebitNote > 100) {
qtyM = rs1.getDouble(1);
itemCodeM = rs1.getString(2);
lotNoM = rs1.getString(3);
lotSlM = rs1.getString(4);
itemCodeM = itemCodeM == null ? ""
: itemCodeM.trim();
lotNoM = lotNoM == null ? "" : lotNoM
.trim();
lotSlM = lotSlM == null ? "" : lotSlM
.trim();
System.out.println("itemCode-->>["
+ itemCode + "] itemCodeM-->["
+ itemCodeM + "]");
System.out.println("lotNo-->>[" + lotNo
+ "] lotNoM-->[" + lotNoM + "]");
System.out.println("lotSl-->>[" + lotSl
+ "] lotSlM-->[" + lotSlM + "]");
System.out.println("qty-->>[" + qty
+ "] qtyM-->[" + qtyM + "]");
if (qtyM < qty
&& itemCode
.equalsIgnoreCase(itemCodeM)
&& lotNoM.equalsIgnoreCase(lotNo)
&& lotSlM.equalsIgnoreCase(lotSl)) {
InvIDTemp.add(id);
partialInvoiceMapG.put(id + ":"
+ itemCode + ":" + lotNoM + ":"
+ lotSlM, qty - qtyM);
System.out
.println("partial map11111----->>["
+ partialInvoiceMapG
+ "]");
} else {
System.out
.println("deleted ID--------->>["
+ deleteId + "]");
if (deleteId == 1) {
System.out
.println("----in remove iterator condition--------");
it.remove();
// break;
}
deleteId++;
// inv45dayListL.remove(id);
System.out
.println("*** Generating Debit Note for Invoice having debit Amount greater than 100/-!");
}
// ENF OF IF DR_AMT<100
qtyM = rs1.getDouble(1);
itemCodeM = rs1.getString(2);
lotNoM = rs1.getString(3);
lotSlM = rs1.getString(4);
itemCodeM = itemCodeM == null ? "" : itemCodeM
.trim();
lotNoM = lotNoM == null ? "" : lotNoM.trim();
lotSlM = lotSlM == null ? "" : lotSlM.trim();
System.out.println("itemCode-->>[" + itemCode
+ "] itemCodeM-->[" + itemCodeM + "]");
System.out.println("lotNo-->>[" + lotNo
+ "] lotNoM-->[" + lotNoM + "]");
System.out.println("lotSl-->>[" + lotSl
+ "] lotSlM-->[" + lotSlM + "]");
System.out.println("qty-->>[" + qty + "] qtyM-->["
+ qtyM + "]");
if (qtyM < qty
&& itemCode.equalsIgnoreCase(itemCodeM)
&& lotNoM.equalsIgnoreCase(lotNo)
&& lotSlM.equalsIgnoreCase(lotSl)) {
InvIDTemp.add(id);
partialInvoiceMapG.put(id + ":" + itemCode
+ ":" + lotNoM + ":" + lotSlM, qty
- qtyM);
System.out.println("partial map11111----->>["
+ partialInvoiceMapG + "]");
} else {
} else {
System.out.println("deleted ID--------->>["
+ deleteId + "]");
if (deleteId == 1) {
System.out
.println("Debit_Note Amount is less than 100 =>"
+ sumDebitNote);
.println("----in remove iterator condition--------");
it.remove();
// break;
}
}// End of While rs2
deleteId++;
// inv45dayListL.remove(id);
}
// ENF OF IF DR_AMT<100
} // end while 3
if (rs1 != null) {
......@@ -1886,6 +1959,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
ProofOfDeliveryConf podC = ProofOfDeliveryConf.getInstance();
int count = 0, cnt1 = 0, cnt2 = 0, itemCnt = 0;
Connection conn1 = null;
boolean invstatus;
ConnDriver connDriver1 = new ConnDriver();
try {
conn1 = connDriver1.getConnectDB("DriverITM");
......@@ -2044,8 +2118,9 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
netPTS = chargQty / (chargQty + freeQty)
* priceListRate;
System.out.println("Net PTS rate----->>["
+ netPTS + "]");
System.out
.println("Net PchangeEditable(this)TS rate----->>["
+ netPTS + "]");
actualRate = netPTS - invRate;
detail3Amt = actualRate * invQty;
detail3AmtT = detail3AmtT + detail3Amt;
......@@ -2105,11 +2180,23 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
.toString()); // xmlStringAll
ExchRate = Double.parseDouble(invoiceDetailsMap.get(
"exch_rate").toString());
errString = podC.genDebitNote("PRC", invIdPartial,
custCode, siteCodeG, xtraParamsG, currCode,
ExchRate, detail2xmlString, detail3AmtT, conn);
System.out.println("------Error string after DN save--->>["
+ errString + "]");
// check the debit note is greater than 100 or not
invstatus = checkDebitAmt(invIdPartial, conn);
System.out.println("invstatus invIdPartial =>"
+ invIdPartial);
if (invstatus) {
errString = podC.genDebitNote("PRC", invIdPartial,
custCode, siteCodeG, xtraParamsG, currCode,
ExchRate, detail2xmlString, detail3AmtT, conn);
System.out
.println("------Error string after DN save--->>["
+ errString + "]");
} else {
errString = "Invalid Debit";
}
if (errString.indexOf("Success") > -1) {
System.out
.println("Tran id for Misc. debit note------->>["
......
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