Commit 037a7970 authored by pdas's avatar pdas

The sitecode to be considered from Receipt and not invoice.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98785 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 36a8ba6d
...@@ -336,7 +336,7 @@ public class CalculateCommission ...@@ -336,7 +336,7 @@ public class CalculateCommission
String commCalc = ""; String commCalc = "";
String errString = ""; String errString = "";
String keyString = ""; String keyString = "";
String sql = ""; String sql = "",sql1="";
String refSer = ""; String refSer = "";
String acctcodeExp = ""; String acctcodeExp = "";
String cctrcodeExp = ""; String cctrcodeExp = "";
...@@ -454,8 +454,8 @@ public class CalculateCommission ...@@ -454,8 +454,8 @@ public class CalculateCommission
double invDisc = 0.0; double invDisc = 0.0;
double discount = 0.0; double discount = 0.0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null,pstmt1 =null;
ResultSet rs = null; ResultSet rs = null,rs1 =null;
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
...@@ -689,11 +689,25 @@ public class CalculateCommission ...@@ -689,11 +689,25 @@ public class CalculateCommission
if("Y".equalsIgnoreCase(commHdr)) if("Y".equalsIgnoreCase(commHdr))
{ {
sql = "select invoice_id, ref_line_no, inv_amt, frt_amt, item_ser, tran_date, eff_date, curr_code, exch_rate, fin_entity, site_code," + sql1 = "Select site_code from receipt where tran_id =?" ;//sitecode to be taken from receipt not invoice Added by Priyanka Das
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdRcp);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
siteCode = rs1.getString(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql = "select invoice_id, ref_line_no, inv_amt, frt_amt, item_ser, tran_date, eff_date, curr_code, exch_rate, fin_entity," +
" sales_pers,comm_perc__on,comm_perc,dlv_term, ord_amt, insu_amt,sorder_no, curr_code_sp, exch_rate_sp,comm_amt from (" + " sales_pers,comm_perc__on,comm_perc,dlv_term, ord_amt, insu_amt,sorder_no, curr_code_sp, exch_rate_sp,comm_amt from (" +
" select DISTINCT a.invoice_id, 1 as ref_line_no, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt," + " select DISTINCT a.invoice_id, 1 as ref_line_no, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt," +
" a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date,a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity," + " a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date,a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity," +
" a.site_code site_code,d.sales_pers sales_pers,(case when (case when d.comm_perc__on is null then ' ' else d.comm_perc__on end) = ' ' " + " d.sales_pers sales_pers,(case when (case when d.comm_perc__on is null then ' ' else d.comm_perc__on end) = ' ' " +
" then c.comm_perc_on_1 else d.comm_perc__on end) comm_perc__on, (case when (case when c.comm_perc_1 is null then 0 else c.comm_perc_1 end) = 0 " + " then c.comm_perc_on_1 else d.comm_perc__on end) comm_perc__on, (case when (case when c.comm_perc_1 is null then 0 else c.comm_perc_1 end) = 0 " +
" then (case when d.comm_perc is null then 0 else d.comm_perc end) else (case when c.comm_perc_1 is null then 0 else c.comm_perc_1 end) end) comm_perc," + " then (case when d.comm_perc is null then 0 else d.comm_perc end) else (case when c.comm_perc_1 is null then 0 else c.comm_perc_1 end) end) comm_perc," +
" d.dlv_term dlv_term, d.ord_amt ord_amt, (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm) insu_amt,d.sale_order sorder_no, d.curr_code__comm curr_code_sp, " + " d.dlv_term dlv_term, d.ord_amt ord_amt, (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm) insu_amt,d.sale_order sorder_no, d.curr_code__comm curr_code_sp, " +
...@@ -702,7 +716,7 @@ public class CalculateCommission ...@@ -702,7 +716,7 @@ public class CalculateCommission
" and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? and " + " and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? and " +
" (case when d.sales_pers is null then ' ' else d.sales_pers end) <> ' ' UNION ALL select DISTINCT a.invoice_id, 2 as ref_line_no, a.inv_amt inv_amt," + " (case when d.sales_pers is null then ' ' else d.sales_pers end) <> ' ' UNION ALL select DISTINCT a.invoice_id, 2 as ref_line_no, a.inv_amt inv_amt," +
" a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate," + " a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate," +
" a.fin_entity fin_entity, a.site_code site_code, d.sales_pers__1 sales_pers, (case when (case when d.comm_perc_on_1 is null then ' ' else d.comm_perc_on_1 end) = ' ' " + " a.fin_entity fin_entity, d.sales_pers__1 sales_pers, (case when (case when d.comm_perc_on_1 is null then ' ' else d.comm_perc_on_1 end) = ' ' " +
" then c.comm_perc_on_2 else d.comm_perc_on_1 end) comm_perc__on, (case when (case when c.comm_perc_2 is null then 0 else c.comm_perc_2 end) = 0 then " + " then c.comm_perc_on_2 else d.comm_perc_on_1 end) comm_perc__on, (case when (case when c.comm_perc_2 is null then 0 else c.comm_perc_2 end) = 0 then " +
" (case when d.comm_perc_1 is null then 0 else d.comm_perc_1 end) else (case when c.comm_perc_2 is null then 0 else c.comm_perc_2 end) end) comm_perc," + " (case when d.comm_perc_1 is null then 0 else d.comm_perc_1 end) else (case when c.comm_perc_2 is null then 0 else c.comm_perc_2 end) end) comm_perc," +
" d.dlv_term dlv_term, d.ord_amt ord_amt, (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm_1) insu_amt, d.sale_order sorder_no, d.curr_code__comm_1 curr_code_sp, " + " d.dlv_term dlv_term, d.ord_amt ord_amt, (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm_1) insu_amt, d.sale_order sorder_no, d.curr_code__comm_1 curr_code_sp, " +
...@@ -711,7 +725,7 @@ public class CalculateCommission ...@@ -711,7 +725,7 @@ public class CalculateCommission
" and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? " + " and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? " +
" and (case when d.sales_pers__1 is null then ' ' else d.sales_pers__1 end) <> ' ' UNION ALL SELECT DISTINCT a.invoice_id, 3 as ref_line_no, " + " and (case when d.sales_pers__1 is null then ' ' else d.sales_pers__1 end) <> ' ' UNION ALL SELECT DISTINCT a.invoice_id, 3 as ref_line_no, " +
" a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code," + " a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code," +
" a.exch_rate exch_rate, a.fin_entity fin_entity, a.site_code site_code, d.sales_pers__2 sales_pers, (case when (case when d.comm_perc_on_2 is null then ' ' else d.comm_perc_on_2 end) = ' ' " + " a.exch_rate exch_rate, a.fin_entity fin_entity, d.sales_pers__2 sales_pers, (case when (case when d.comm_perc_on_2 is null then ' ' else d.comm_perc_on_2 end) = ' ' " +
" then c.comm_perc_on_3 else d.comm_perc_on_2 end) comm_perc__on, (case when (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) = 0 then " + " then c.comm_perc_on_3 else d.comm_perc_on_2 end) comm_perc__on, (case when (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) = 0 then " +
" (case when d.comm_perc_2 is null then 0 else d.comm_perc_2 end) else (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) end) comm_perc, d.dlv_term dlv_term, d.ord_amt ord_amt, " + " (case when d.comm_perc_2 is null then 0 else d.comm_perc_2 end) else (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) end) comm_perc, d.dlv_term dlv_term, d.ord_amt ord_amt, " +
" (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm_2) insu_amt , d.sale_order sorder_no, d.curr_code__comm_2 curr_code_sp, d.exch_rate__comm_2 exch_rate_sp," + " (d.ins_amt * d.exch_rate__ins / d.exch_rate__comm_2) insu_amt , d.sale_order sorder_no, d.curr_code__comm_2 curr_code_sp, d.exch_rate__comm_2 exch_rate_sp," +
...@@ -721,6 +735,7 @@ public class CalculateCommission ...@@ -721,6 +735,7 @@ public class CalculateCommission
"((case when sales_pers is null then ' ' else sales_pers end) <> ' ') and ((case when comm_perc__on is null then ' ' else comm_perc__on end) <> ' ') " + "((case when sales_pers is null then ' ' else sales_pers end) <> ' ') and ((case when comm_perc__on is null then ' ' else comm_perc__on end) <> ' ') " +
" and comm_amt > 0 order by invoice_id, sales_pers, comm_perc__on"; " and comm_amt > 0 order by invoice_id, sales_pers, comm_perc__on";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceNo); pstmt.setString(1, invoiceNo);
pstmt.setString(2, invoiceNo); pstmt.setString(2, invoiceNo);
...@@ -742,7 +757,8 @@ public class CalculateCommission ...@@ -742,7 +757,8 @@ public class CalculateCommission
commMap.put("curr_code" ,rs.getString("curr_code")); commMap.put("curr_code" ,rs.getString("curr_code"));
commMap.put("exch_rate" , rs.getDouble("exch_rate")); commMap.put("exch_rate" , rs.getDouble("exch_rate"));
commMap.put("fin_entity" , rs.getString("fin_entity")); commMap.put("fin_entity" , rs.getString("fin_entity"));
commMap.put("site_code" , rs.getString("site_code")); //commMap.put("site_code" , rs.getString("site_code"));
commMap.put("site_code" , siteCode);
commMap.put("sales_pers" , rs.getString("sales_pers")); commMap.put("sales_pers" , rs.getString("sales_pers"));
commMap.put("comm_perc__on" , rs.getString("comm_perc__on")); commMap.put("comm_perc__on" , rs.getString("comm_perc__on"));
commMap.put("comm_perc" , rs.getDouble("comm_perc")); commMap.put("comm_perc" , rs.getDouble("comm_perc"));
...@@ -762,10 +778,26 @@ public class CalculateCommission ...@@ -762,10 +778,26 @@ public class CalculateCommission
} }
else else
{ {
sql = "select ref_line_no , invoice_id, inv_amt, frt_amt, item_ser, tran_date, eff_date, curr_code, exch_rate, fin_entity, site_code, line_no__inv, item_code, net_amt, " +
System.out.println("in else>>>>>");
sql1 = "Select site_code from receipt where tran_id =?" ;//sitecode to be taken from receipt not invoice
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdRcp);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
siteCode = rs1.getString(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("in else>>>>>"+siteCode);
sql = "select ref_line_no , invoice_id, inv_amt, frt_amt, item_ser, tran_date, eff_date, curr_code, exch_rate, fin_entity, line_no__inv, item_code, net_amt, " +
" quantity__stduom, rate__stduom, inv_disc, comm_frt, comm_insu, amt_inv, sales_pers, comm_perc__on, comm_perc, dlv_term, ord_amt, insu_amt, sorder_no, " + " quantity__stduom, rate__stduom, inv_disc, comm_frt, comm_insu, amt_inv, sales_pers, comm_perc__on, comm_perc, dlv_term, ord_amt, insu_amt, sorder_no, " +
" sline_no, curr_code_sp, exch_rate_sp, comm_amt from ( select 1 as ref_line_no,a.invoice_id, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt," + " sline_no, curr_code_sp, exch_rate_sp, comm_amt from ( select 1 as ref_line_no,a.invoice_id, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt," +
" a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity, a.site_code site_code, " + " a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity," +
" b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom, b.discount inv_disc,(case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) " + " b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom, b.discount inv_disc,(case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) " +
" / a.inv_amt * a.frt_amt end) comm_frt, (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, " + " / a.inv_amt * a.frt_amt end) comm_frt, (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, " +
" b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv,b.sord_line_no sline_no, d.sales_pers sales_pers,(case when (case when d.comm_perc__on is null then ' ' " + " b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv,b.sord_line_no sline_no, d.sales_pers sales_pers,(case when (case when d.comm_perc__on is null then ' ' " +
...@@ -775,7 +807,7 @@ public class CalculateCommission ...@@ -775,7 +807,7 @@ public class CalculateCommission
" (case when b.sales_pers_comm_1 is null then 0 else b.sales_pers_comm_1 end) comm_amt from invoice a, invdet b, sorddet c, sorder d where a.invoice_id = b.invoice_id " + " (case when b.sales_pers_comm_1 is null then 0 else b.sales_pers_comm_1 end) comm_amt from invoice a, invdet b, sorddet c, sorder d where a.invoice_id = b.invoice_id " +
" and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? and (case when d.sales_pers is null then ' ' else d.sales_pers end) <> ' ' " + " and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order and a.invoice_id = ? and (case when d.sales_pers is null then ' ' else d.sales_pers end) <> ' ' " +
" union all select 2 as ref_line_no, a.invoice_id, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date," + " union all select 2 as ref_line_no, a.invoice_id, a.inv_amt inv_amt, a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt, a.item_ser item_ser, a.tran_date tran_date," +
" a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity, a.site_code site_code,b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom," + " a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity,b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom," +
" b.discount inv_disc, (case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / a.inv_amt * a.frt_amt end) comm_frt, " + " b.discount inv_disc, (case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / a.inv_amt * a.frt_amt end) comm_frt, " +
" (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv," + " (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv," +
" b.sord_line_no sline_no, d.sales_pers__1 sales_pers, (case when (case when d.comm_perc_on_1 is null then ' ' else d.comm_perc_on_1 end) = ' ' then c.comm_perc_on_2 else d.comm_perc_on_1 end) " + " b.sord_line_no sline_no, d.sales_pers__1 sales_pers, (case when (case when d.comm_perc_on_1 is null then ' ' else d.comm_perc_on_1 end) = ' ' then c.comm_perc_on_2 else d.comm_perc_on_1 end) " +
...@@ -785,7 +817,7 @@ public class CalculateCommission ...@@ -785,7 +817,7 @@ public class CalculateCommission
" from invoice a, invdet b, sorddet c, sorder d where a.invoice_id = b.invoice_id and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order " + " from invoice a, invdet b, sorddet c, sorder d where a.invoice_id = b.invoice_id and b.sord_no = c.sale_order and b.sord_line_no = c.line_no and c.sale_order = d.sale_order " +
" and a.invoice_id = ? and (case when d.sales_pers__1 is null then ' ' else d.sales_pers__1 end) <> ' ' union all select 3 as ref_line_no, a.invoice_id, a.inv_amt inv_amt, " + " and a.invoice_id = ? and (case when d.sales_pers__1 is null then ' ' else d.sales_pers__1 end) <> ' ' union all select 3 as ref_line_no, a.invoice_id, a.inv_amt inv_amt, " +
" a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt , a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity, " + " a.frt_amt * d.exch_rate__frt / a.exch_rate frt_amt , a.item_ser item_ser, a.tran_date tran_date, a.eff_date eff_date, a.curr_code curr_code, a.exch_rate exch_rate, a.fin_entity fin_entity, " +
" a.site_code site_code, b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom, b.discount inv_disc, (case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt)" + " b.line_no line_no__inv, b.item_code, b.net_amt, b.quantity__stduom, b.rate__stduom, b.discount inv_disc, (case when a.inv_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt)" +
" / a.inv_amt * a.frt_amt end) comm_frt, (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, " + " / a.inv_amt * a.frt_amt end) comm_frt, (case when d.ord_amt = 0 then 0 else (b.quantity__stduom * b.rate__stduom - b.disc_amt) / d.ord_amt * d.ins_amt end) comm_insu, " +
" b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv, b.sord_line_no sline_no, d.sales_pers__2 sales_pers, (case when (case when d.comm_perc_on_2 is null then ' ' else d.comm_perc_on_2 end) = ' ' " + " b.quantity__stduom * b.rate__stduom - b.disc_amt amt_inv, b.sord_line_no sline_no, d.sales_pers__2 sales_pers, (case when (case when d.comm_perc_on_2 is null then ' ' else d.comm_perc_on_2 end) = ' ' " +
" then c.comm_perc_on_3 else d.comm_perc_on_2 end) comm_perc__on, (case when (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) = 0 then (case when d.comm_perc_2 is null then 0 else d.comm_perc_2 end) else " + " then c.comm_perc_on_3 else d.comm_perc_on_2 end) comm_perc__on, (case when (case when c.comm_perc_3 is null then 0 else c.comm_perc_3 end) = 0 then (case when d.comm_perc_2 is null then 0 else d.comm_perc_2 end) else " +
...@@ -814,7 +846,9 @@ public class CalculateCommission ...@@ -814,7 +846,9 @@ public class CalculateCommission
commMap.put("curr_code" , rs.getString("curr_code")); commMap.put("curr_code" , rs.getString("curr_code"));
commMap.put("exch_rate" , rs.getDouble("exch_rate")); commMap.put("exch_rate" , rs.getDouble("exch_rate"));
commMap.put("fin_entity" , rs.getString("fin_entity")); commMap.put("fin_entity" , rs.getString("fin_entity"));
commMap.put("site_code" , rs.getString("site_code")); //commMap.put("site_code" , rs.getString("site_code"));
commMap.put("site_code" , siteCode);//sitecode to be taken from receipt not invoice
//commMap.put("site_code" , rs.getString("site_code"));
commMap.put("line_no__inv" , rs.getInt("line_no__inv")); commMap.put("line_no__inv" , rs.getInt("line_no__inv"));
commMap.put("item_code" , rs.getString("item_code")); commMap.put("item_code" , rs.getString("item_code"));
commMap.put("net_amt" , rs.getInt("net_amt")); commMap.put("net_amt" , rs.getInt("net_amt"));
......
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