Commit c63cc316 authored by rtiwari's avatar rtiwari

invoice not consider if sreturn genreted of full qty


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100296 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 915fd56c
......@@ -51,7 +51,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
String windowName, String xtraParams) throws RemoteException,
ITMException {
System.out.println("enter in process(212....................");
System.out.println("enter in process(21....................");
String retStr = "";
Document detailDom = null;
Document headerDom = null;
......@@ -124,7 +124,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
custCodeFrm = custCodeFrm == null ? "" : custCodeFrm.trim();
custCodeTo = custCodeTo == null ? "" : custCodeTo.trim();
invType = invType == null ? "" : invType.trim();
System.out.println("SiteCode-133-->>[" + siteCode + "]");
System.out.println("SiteCode--133-->>[" + siteCode + "]");
System.out.println("custCodeFrm--->>[" + custCodeFrm + "]");
System.out.println("custCodeTo--->>[" + custCodeTo + "]");
System.out.println("invType--->>[" + invType + "]");
......@@ -229,7 +229,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
// sql = "select invoice_id from invoice where site_code = ?
// and confirmed = ?"
// + " and sysdate - conf_date > 45 and inv_type = ?";
// + " and sysdate - conf_date > 45 and inv_type = ?";base'
sql = "select invoice_id from invoice where site_code = ? and confirmed = ?"
+ " and conf_date > '"
......@@ -265,12 +265,12 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
pstmt.setString(4, "Y");
pstmt.setString(5, invType);
}
// ADD CONDITION TO FILTER INVOICE ID WHICH HAS SALE RETURN GENERATED ON 25/FEB/2016.
rs = pstmt.executeQuery();
while (rs.next()) {
invoiceId = rs.getString(1);
invoiceId = invoiceId == null ? "" : invoiceId.trim();
inv45dayList.add(invoiceId);
inv45dayList.add(invoiceId);
}
rs.close();
rs = null;
......@@ -430,6 +430,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
+ partialInvoiceMapG.size() + "]");
if (totalInvoice > 0 || partialInvoiceMapG.size() > 0) {
if (totalInvoice > 0) {
podProcessInvIDListL = getInvFromSalesReturn(podProcessInvIDListL, conn);
for (String invoiceId : podProcessInvIDListL) {
detail2xmlString = "";
lineNo = 0;
......@@ -629,8 +630,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
+ ") *"
+ priceListRate + " )");
System.out
.println("Net PTS rate----->>["
System.out.println("Net PTS rate----->>["
+ netPTS + "]");
actualRate = netPTS - invRate;
......@@ -772,16 +772,22 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
+ " Invoice status =>" + invstatus);
if (detail3AmtT>=100) {*/
errString = podC.genDebitNote("PRC", invoiceId,
custCode, siteCode, xtraParams,
currCode, ExchRate, detail2xmlString,
detail3AmtT, conn);
System.out
.println("------Error string after DN save--->>["
+ errString + "]");
// }else{
// errString="Invalid Debit";
// }
// boolean invSreturn = checkSalesReturn(invoiceId, conn);
// System.out.println("inv Sreturn invoiceId status =>"
// + invSreturn);
// System.out.println("InvoiceId "+invoiceId+" Sales retrun status:"+invSreturn);
// if (invSreturn) {
errString = podC.genDebitNote("PRC", invoiceId,
custCode, siteCode, xtraParams,
currCode, ExchRate, detail2xmlString,
detail3AmtT, conn);
System.out.println("------Error string after DN save--->>["
+ errString + "]");
// }else{
// errcode = "vtngamte"; //invalid debit
// errstring = itmdbaccess1.geterrorstring("",
// errcode, "", "", conn);
// }
if (errString.indexOf("Success") > -1) {
System.out
......@@ -842,12 +848,19 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
invoiceId);
return errString;
}
/*} else {
System.out
.println("The debit Note Not generated for the Invoice Id=> "
+ invoiceId+" Due to total debit amount below then 100!");
}*/
// }
// else {
//
// System.out
// .println("The debit Note Not generated for the Invoice Id=> "
// + invoiceId+" Due to total debit amount below then 100!");
// errCode = "VTNGAMTE"; // negative amountbase
//
// errString = itmdbAccess1.getErrorString("",
// errCode, "", "", conn);
// errString = newErrorMessage(errString, invoiceId);
// return errString;
// }
} else {// end detail3AmtT > 0 condition
errCode = "VTNGAMTE"; // negative amount
......@@ -1654,8 +1667,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
+ "] lotNoM-->[" + lotNoM + "]");
System.out.println("lotSl-->>[" + lotSl
+ "] lotSlM-->[" + lotSlM + "]");
System.out.println("qty-->>[" + qty + "] qtyM-->["
+ qtyM + "]");
System.out.println("qty-->>[" + qty + "] qtyM-->["+ qtyM + "]");
if (qtyM < qty
&& itemCode.equalsIgnoreCase(itemCodeM)
&& lotNoM.equalsIgnoreCase(lotNo)
......@@ -1666,7 +1678,6 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
- qtyM);
System.out.println("partial map11111----->>["
+ partialInvoiceMapG + "]");
} else {
System.out.println("deleted ID--------->>["
+ deleteId + "]");
......@@ -1759,7 +1770,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
lineNoT = rs.getString(5) == null ? "" : rs.getString(5)
.trim();
sql1 = "select sum(d.quantity) as Quantity,d.item_code,d.lot_no,d.lot_sl,d.line_no__invtrace from misc_drcr_rcp h,misc_drcr_rdet d "
sql1 = " select sum(d.quantity) as Quantity,d.item_code,d.lot_no,d.lot_sl,d.line_no__invtrace from misc_drcr_rcp h,misc_drcr_rdet d "
+ "where h.tran_id = d.tran_id and h.remarks like ? and quantity is not null "
+ "group by d.item_code,d.lot_no,d.lot_sl,d.line_no__invtrace";
......@@ -1768,44 +1779,29 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
rs1 = pstmt1.executeQuery();
while (rs1.next()) {
quantityM = rs1.getDouble(1);
itemCodeM = rs1.getString(2) == null ? "" : rs1
.getString(2).trim();
lotNoM = rs1.getString(3) == null ? "" : rs1.getString(
3).trim();
lotSlM = rs1.getString(4) == null ? "" : rs1.getString(
4).trim();
lineNoM = rs1.getString(5) == null ? "" : rs1
.getString(5).trim();
System.out.println("count1--------------->>[" + count
+ "]");
System.out.println("quantityT--->>[" + quantityT
+ "] quantityM-->[" + quantityM + "]");
System.out.println("itemCodeT--->>[" + itemCodeT
+ "] itemCodeM-->[" + itemCodeM + "]");
System.out.println("lotNoT--->>[" + lotNoT
+ "] lotNoM-->[" + lotNoM + "]");
System.out.println("lotSlT--->>[" + lotSlT
+ "] lotSlM-->[" + lotSlM + "]");
System.out.println("lineNoT--->>[" + lineNoT
+ "] lineNoM-->[" + lineNoM + "]");
itemCodeM = rs1.getString(2) == null ? "" : rs1.getString(2).trim();
lotNoM = rs1.getString(3) == null ? "" : rs1.getString(3).trim();
lotSlM = rs1.getString(4) == null ? "" : rs1.getString(4).trim();
lineNoM = rs1.getString(5)== null? "" : rs1.getString(5).trim();
System.out.println("count1--------------->>[" + count+ "]");
System.out.println("quantityT--->>[" + quantityT+ "] quantityM-->[" + quantityM + "]");
System.out.println("itemCodeT--->>[" + itemCodeT+ "] itemCodeM-->[" + itemCodeM + "]");
System.out.println("lotNoT--->>[" + lotNoT+ "] lotNoM-->[" + lotNoM + "]");
System.out.println("lotSlT--->>[" + lotSlT+ "] lotSlM-->[" + lotSlM + "]");
System.out.println("lineNoT--->>[" + lineNoT+ "] lineNoM-->[" + lineNoM + "]");
if (itemCodeT.equalsIgnoreCase(itemCodeM)
&& lotNoT.equalsIgnoreCase(lotNoM)) {
if (lotSlT.equalsIgnoreCase(lotSlM)
&& lineNoT.equalsIgnoreCase(lineNoM)) {
if (quantityM < quantityT) {
System.out
.println("record matched........at count "
+ count);
System.out.println("record matched........at count "+ count);
partialInvID.add(invoiceId);
partialInvoiceMapG.put(invoiceId + ":"
+ itemCodeT + ":" + lotNoT + ":"
partialInvoiceMapG.put(invoiceId + ":"+ itemCodeT + ":" + lotNoT + ":"
+ lotSlT, quantityT - quantityM);
noOfRecordMatched++;
}
if (quantityM == quantityT) {
System.out
.println("Quantity matched for inv id....."
System.out.println("Quantity matched for inv id....."
+ invoiceId);
partialInvID.add(invoiceId);
}
......@@ -1966,6 +1962,7 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
int count = 0, cnt1 = 0, cnt2 = 0, itemCnt = 0;
Connection conn1 = null;
boolean invstatus;
boolean invSreturn = false;
ConnDriver connDriver1 = new ConnDriver();
try {
conn1 = connDriver1.getConnectDB("DriverITM");
......@@ -1996,6 +1993,8 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
totalInvoice = partialID.size();
System.out.println("totalInvoice partial--->>[" + totalInvoice
+ "]");
//partialID = getInvFromSalesReturn(partialID, conn);
for (String invIdPartial : partialID) {
// itemCode=partialItem.get(itemCnt)==null ? ""
// :partialItem.get(itemCnt).trim();
......@@ -2187,13 +2186,14 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
ExchRate = Double.parseDouble(invoiceDetailsMap.get(
"exch_rate").toString());
// check the debit note is greater than 100 or not
// check the debit note is greater than 100 or not added by sanket on Nov 2015
invstatus = checkDebitAmt(invIdPartial, conn);
// check wheather the sreturn is generated for all qty. added by ritesh on 29 feb 16
invSreturn = checkSalesReturn(invIdPartial, conn);
System.out.println("invstatus invIdPartial =>"
+ invIdPartial);
if (invstatus) {
System.out.println("Debit Amt status:"+invSreturn+":"+"Slae retrun status:"+invSreturn);
if (invstatus && invSreturn) {
errString = podC.genDebitNote("PRC", invIdPartial,
custCode, siteCodeG, xtraParamsG, currCode,
ExchRate, detail2xmlString, detail3AmtT, conn);
......@@ -2287,6 +2287,136 @@ public class PODProcess extends ProcessEJB implements PODProcessLocal,
}
private boolean checkSalesReturn(String invIdPartial, Connection conn) throws SQLException {
ResultSet rs = null, rs1 = null;
PreparedStatement pstmt = null, pstmt1 = null;
String sql = "", sql1 = "";
double invQty = 0d,sreturnQuantity=0d;
boolean isInvoice = true;
// ProofOfDelivery pod = ProofOfDelivery.getInstance();
try {
sql = "select sum(quantity) from invoice_trace where invoice_id = ? order by inv_line_no";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invIdPartial);
rs = pstmt.executeQuery();
while (rs.next())
{
invQty = rs.getDouble(1);
}
System.out.println("-----Got sales return tran id-----------");
sql1 = "select nvl(sum(d.quantity),0) from sreturndet d ,sreturn h where d.tran_id = h.tran_id and h.invoice_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, invIdPartial);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
sreturnQuantity = rs1.getDouble(1);
}
System.out.println("Sales return------>>["
+ sreturnQuantity + "]");
invQty = invQty - sreturnQuantity;
if(invQty <= 0)
{
isInvoice = false; // Sale return generated for all qty.
}
} catch (Exception e) {
e.printStackTrace();
}
finally
{
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
}
return isInvoice;
}
private ArrayList<String> getInvFromSalesReturn(ArrayList<String> invoiceList, Connection conn) throws SQLException {
ResultSet rs = null, rs1 = null;
PreparedStatement pstmt = null, pstmt1 = null;
String sql = "", sql1 = "";
double invQty = 0d,sreturnQuantity=0d;
boolean isInvoice = true;
ArrayList<String> invoiceRmvList = new ArrayList();
try {
for(String invIdPartial : invoiceList)
{
sql = "select sum(quantity) from invoice_trace where invoice_id = ? order by inv_line_no";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invIdPartial);
rs = pstmt.executeQuery();
while (rs.next())
{
invQty = rs.getDouble(1);
}
System.out.println("-----Got sales return tran id-----------");
sql1 = "select nvl(sum(d.quantity),0) from sreturndet d ,sreturn h where d.tran_id = h.tran_id and h.invoice_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, invIdPartial);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
sreturnQuantity = rs1.getDouble(1);
}
System.out.println("Sales return------>>["
+ sreturnQuantity + "]");
invQty = invQty - sreturnQuantity;
if(invQty <= 0)
{
isInvoice = false; // Sale return generated for all qty.
invoiceRmvList.add(invIdPartial);
System.out.println("Removed invoice id from sreturn ::"+invIdPartial);
}
}
invoiceList.removeAll(invoiceRmvList);
} catch (Exception e) {
e.printStackTrace();
}
finally
{
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
}
System.out.println("Returning invoice list from sreturn::"+invoiceList.toString());
return invoiceList;
}
public void partialInvDebitNote(Connection conn,
ArrayList<String> invIdPartial) {
ResultSet rs = null, rs1 = null;
......
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