Commit c7b8883f authored by mjadhav's avatar mjadhav

changes done for tax


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96994 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b1a34d8b
...@@ -158,7 +158,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -158,7 +158,7 @@ public class GenInvoiceSchedule implements Schedule {
java.sql.Timestamp currentDt=java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0"); java.sql.Timestamp currentDt=java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
System.out.println(">>>>INVOICE success execute update query!!!!!!!!!"); System.out.println(">>>>INVOICE execute update query!!!!!!!!!");
sql="update invoice set DOWNLOAD_FLAG='Y',INV_EXP_DATE=? where INVOICE_ID =?"; sql="update invoice set DOWNLOAD_FLAG='Y',INV_EXP_DATE=? where INVOICE_ID =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, currentDt); pstmt.setTimestamp(1, currentDt);
...@@ -350,7 +350,8 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -350,7 +350,8 @@ public class GenInvoiceSchedule implements Schedule {
private static Node getFileHeader(Document doc,String invoiceId ,Connection conn) { private static Node getFileHeader(Document doc,String invoiceId ,Connection conn) {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql="",invAmt="",invType="",netAmt="",currencyCode=""; String sql="",invType="",currencyCode="",invoiceISOCode="";
double invAmt=0.0,netAmt=0.0;
try try
{ {
sql = "select INV_AMT,INV_TYPE ,NET_AMT,CURR_CODE from invoice where invoice_id=? " ; sql = "select INV_AMT,INV_TYPE ,NET_AMT,CURR_CODE from invoice where invoice_id=? " ;
...@@ -360,9 +361,9 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -360,9 +361,9 @@ public class GenInvoiceSchedule implements Schedule {
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
invAmt = rs.getString("INV_AMT"); invAmt = rs.getDouble("INV_AMT");
invType = rs.getString("INV_TYPE"); invType = rs.getString("INV_TYPE");
netAmt=rs.getString("NET_AMT"); netAmt=rs.getDouble("NET_AMT");
currencyCode=rs.getString("CURR_CODE"); currencyCode=rs.getString("CURR_CODE");
} }
...@@ -371,9 +372,27 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -371,9 +372,27 @@ public class GenInvoiceSchedule implements Schedule {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
invAmt = invAmt == null ? " " : invAmt.trim();
sql = "select iso4217 from TARODEV.currency where curr_code=? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currencyCode);
rs = pstmt.executeQuery();
if (rs.next())
{
invoiceISOCode = rs.getString("iso4217");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//invAmt = invAmt == null ? " " : invAmt.trim();
invType = invType == null ? " " : invType.trim(); invType = invType == null ? " " : invType.trim();
currencyCode = currencyCode == null ? " " : currencyCode.trim(); currencyCode = currencyCode == null ? " " : currencyCode.trim();
invoiceISOCode = invoiceISOCode == null ? " " : invoiceISOCode.trim();
} }
catch(Exception e) catch(Exception e)
...@@ -386,14 +405,24 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -386,14 +405,24 @@ public class GenInvoiceSchedule implements Schedule {
// fileHeader.setAttribute("id", id); // fileHeader.setAttribute("id", id);
fileHeader.appendChild(getElementValue(doc, fileHeader, "SchemaVersion", "3.2")); fileHeader.appendChild(getElementValue(doc, fileHeader, "SchemaVersion", "3.2"));
fileHeader.appendChild(getElementValue(doc, fileHeader, "Modality", "I")); fileHeader.appendChild(getElementValue(doc, fileHeader, "Modality", "I"));
fileHeader.appendChild(getElementValue(doc, fileHeader, "InvoiceIssuerType", invType)); fileHeader.appendChild(getElementValue(doc, fileHeader, "InvoiceIssuerType", "EM"));
Element batch = doc.createElement("Batch"); Element batch = doc.createElement("Batch");
batch.appendChild(getElementValue(doc, fileHeader, "BatchIdentifier"," ")); batch.appendChild(getElementValue(doc, fileHeader, "BatchIdentifier"," "));
batch.appendChild(getElementValue(doc, fileHeader, "InvoicesCount"," ")); batch.appendChild(getElementValue(doc, fileHeader, "InvoicesCount"," "));
batch.appendChild(getElementValue(doc, fileHeader, "TotalInvoicesAmount",invAmt));
batch.appendChild(getElementValue(doc, fileHeader, "TotalOutstandingAmount",netAmt)); Element totalInvoicesAmount = doc.createElement("TotalInvoicesAmount");
batch.appendChild(getElementValue(doc, fileHeader, "TotalExecutableAmount",netAmt)); totalInvoicesAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(invAmt)));
batch.appendChild(getElementValue(doc, fileHeader, "InvoiceCurrencyCode",currencyCode)); batch.appendChild(totalInvoicesAmount);
Element totalOutstandingAmount = doc.createElement("TotalOutstandingAmount");
totalOutstandingAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(netAmt)));
batch.appendChild(totalOutstandingAmount);
Element totalExecutableAmount = doc.createElement("TotalExecutableAmount");
totalExecutableAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(netAmt)));
batch.appendChild(totalOutstandingAmount);
batch.appendChild(getElementValue(doc, fileHeader, "InvoiceCurrencyCode",invoiceISOCode));
fileHeader.appendChild(batch); fileHeader.appendChild(batch);
return fileHeader; return fileHeader;
} }
...@@ -405,13 +434,14 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -405,13 +434,14 @@ public class GenInvoiceSchedule implements Schedule {
String sql=""; String sql="";
String custCode="",siteCode="",custCodeBil=""; String custCode="",siteCode="",custCodeBil="";
String siteAreaCode="",siteAdd1="",siteAdd2="",sitecity="",sitePin="",siteStateCode="",siteRegNo="",siteContactPersion=""; String siteAreaCode="",siteAdd1="",siteAdd2="",sitecity="",sitePin="",siteStateCode="",siteRegNo="",siteContactPersion="";
String custAdd1="",custAdd2="",custCity="",custState="",custPin="",custPanNo="",custType="",custName="",custCountrtCode=""; String custAdd1="",custAdd2="",custCity="",custState="",custPin="",custTaxreg="",custType="",custName="",custCountrtCode="";
String rate="",unitRate="",discountInv="",siteDescr="",custCodeBill=""; String rate="",unitRate="",discountInv="",siteDescr="",custCodeBill="",custCodeDlv="";
String dlvAdd1="",dlvAdd2="",dlvCity="",dlvPin="",dlvCountryCode="";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
sql = "select SITE_CODE,CUST_CODE,CUST_CODE__BIL from invoice where invoice_id=? " ; /*sql = "select SITE_CODE,CUST_CODE,CUST_CODE__BIL from invoice where invoice_id=? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId); pstmt.setString(1, invoiceId);
...@@ -428,6 +458,45 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -428,6 +458,45 @@ public class GenInvoiceSchedule implements Schedule {
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
*/
/*sql = " select i.SITE_CODE,i.CUST_CODE,i.CUST_CODE__BIL,d.cust_code__dlv ,d.DLV_ADD1 " +
",d.DLV_ADD2 , d.DLV_CITY , d.DLV_PIN ,d.COUNT_CODE__DLV " +
"from invoice i, DESPATCH d , " +
"despatchdet det where i.invoice_id=det.invoice_id " +
"and d.desp_id=det.desp_id and det.invoice_id= ? " ;*/
sql = " select i.SITE_CODE,i.CUST_CODE,i.CUST_CODE__BIL,d.cust_code__dlv ,d.DLV_ADD1, "+
" d.DLV_ADD2 , d.DLV_CITY , d.DLV_PIN ,d.COUNT_CODE__DLV "+
" from invoice i, DESPATCH d "+
" where i.desp_id=d.desp_id and i.invoice_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId);
rs = pstmt.executeQuery();
if (rs.next())
{
custCode = rs.getString("cust_code");
siteCode=rs.getString("SITE_CODE");
custCodeBil=rs.getString("CUST_CODE__BIL");
custCodeDlv=rs.getString("cust_code__dlv");
dlvAdd1=rs.getString("DLV_ADD1");
dlvAdd2=rs.getString("DLV_ADD2");
dlvCity=rs.getString("DLV_CITY");
dlvPin=rs.getString("DLV_PIN");
dlvCountryCode=rs.getString("COUNT_CODE__DLV");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select reg_no from siteregno where site_code=?" ; sql = "select reg_no from siteregno where site_code=?" ;
...@@ -471,7 +540,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -471,7 +540,7 @@ public class GenInvoiceSchedule implements Schedule {
sql = "select ADDR1,ADDR2,CITY,STATE_CODE,PIN,pan_no,cust_type,CUST_NAME,COUNT_CODE,CUST_CODE__BIL from customer where CUST_CODE=?" ; sql = "select ADDR1,ADDR2,CITY,STATE_CODE,PIN,pan_no,cust_type,CUST_NAME,COUNT_CODE,CUST_CODE__BIL,TAX_REG_1 from customer where CUST_CODE=?" ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode); pstmt.setString(1, custCode);
...@@ -483,7 +552,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -483,7 +552,7 @@ public class GenInvoiceSchedule implements Schedule {
custCity = rs.getString("CITY"); custCity = rs.getString("CITY");
custState = rs.getString("STATE_CODE"); custState = rs.getString("STATE_CODE");
custPin = rs.getString("PIN"); custPin = rs.getString("PIN");
custPanNo = rs.getString("pan_no"); custTaxreg = rs.getString("TAX_REG_1");
custType = rs.getString("cust_type"); custType = rs.getString("cust_type");
custName = rs.getString("CUST_NAME"); custName = rs.getString("CUST_NAME");
custCountrtCode = rs.getString("COUNT_CODE"); custCountrtCode = rs.getString("COUNT_CODE");
...@@ -508,6 +577,12 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -508,6 +577,12 @@ public class GenInvoiceSchedule implements Schedule {
custCode = custCode == null ? " " : custCode.trim(); custCode = custCode == null ? " " : custCode.trim();
siteCode = siteCode == null ? " " : siteCode.trim(); siteCode = siteCode == null ? " " : siteCode.trim();
custCodeBil = custCodeBil == null ? " " : custCodeBil.trim(); custCodeBil = custCodeBil == null ? " " : custCodeBil.trim();
custCodeDlv = custCodeDlv == null ? " " : custCodeDlv.trim();
dlvAdd1 = dlvAdd1 == null ? " " : dlvAdd1.trim();
dlvAdd2 = dlvAdd2 == null ? " " : dlvAdd2.trim();
dlvCity = dlvCity == null ? " " : dlvCity.trim();
dlvPin = dlvPin == null ? " " : dlvPin.trim();
dlvCountryCode = dlvCountryCode == null ? " " : dlvCountryCode.trim();
siteRegNo = siteRegNo == null ? " " : siteRegNo.trim(); siteRegNo = siteRegNo == null ? " " : siteRegNo.trim();
siteAreaCode = siteAreaCode == null ? " " : siteAreaCode.trim(); siteAreaCode = siteAreaCode == null ? " " : siteAreaCode.trim();
siteAdd1 = siteAdd1 == null ? " " : siteAdd1.trim(); siteAdd1 = siteAdd1 == null ? " " : siteAdd1.trim();
...@@ -523,7 +598,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -523,7 +598,7 @@ public class GenInvoiceSchedule implements Schedule {
custCity = custCity == null ? " " : custCity.trim(); custCity = custCity == null ? " " : custCity.trim();
custState = custState == null ? " " : custState.trim(); custState = custState == null ? " " : custState.trim();
custPin = custPin == null ? " " : custPin.trim(); custPin = custPin == null ? " " : custPin.trim();
custPanNo = custPanNo == null ? " " : custPanNo.trim(); custTaxreg = custTaxreg == null ? " " : custTaxreg.trim();
custType = custType == null ? " " : custType.trim(); custType = custType == null ? " " : custType.trim();
custName = custName == null ? " " : custName.trim(); custName = custName == null ? " " : custName.trim();
custCountrtCode = custCountrtCode == null ? " " : custCountrtCode.trim(); custCountrtCode = custCountrtCode == null ? " " : custCountrtCode.trim();
...@@ -537,21 +612,19 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -537,21 +612,19 @@ public class GenInvoiceSchedule implements Schedule {
/*-----------------------Element for seller party,start-----------------------------*/ /*-----------------------Element for seller party,start-----------------------------*/
Element sellerParty = doc.createElement("SellerParty"); Element sellerParty = doc.createElement("SellerParty");
Element taxIdentification = doc.createElement("TaxIdentification"); Element taxIdentification = doc.createElement("TaxIdentification");
taxIdentification.appendChild(getElementValue(doc, parties, "PersonTypeCode", "F")); taxIdentification.appendChild(getElementValue(doc, parties, "PersonTypeCode", "J"));
taxIdentification.appendChild(getElementValue(doc, parties, "ResidenceTypeCode", "R")); taxIdentification.appendChild(getElementValue(doc, parties, "ResidenceTypeCode", "R"));
taxIdentification.appendChild(getElementValue(doc, parties, "TaxIdentificationNumber", siteRegNo)); taxIdentification.appendChild(getElementValue(doc, parties, "TaxIdentificationNumber", siteRegNo));
sellerParty.appendChild(taxIdentification); sellerParty.appendChild(taxIdentification);
Element individual = doc.createElement("Individual"); Element individual = doc.createElement("LegalEntity");
individual.appendChild(getElementValue(doc, parties, "Name", siteContactPersion)); individual.appendChild(getElementValue(doc, parties, "CorporateName", siteDescr));
individual.appendChild(getElementValue(doc, parties, "FirstSurname", " "));
individual.appendChild(getElementValue(doc, parties, "SecondSurname", siteContactPersion));
Element addressInSpain = doc.createElement("AddressInSpain"); Element addressInSpain = doc.createElement("AddressInSpain");
addressInSpain.appendChild(getElementValue(doc, parties, "Address", siteAdd1)); addressInSpain.appendChild(getElementValue(doc, parties, "Address", siteAdd1));
addressInSpain.appendChild(getElementValue(doc, parties, "PostCode", sitePin)); addressInSpain.appendChild(getElementValue(doc, parties, "PostCode", sitePin));
addressInSpain.appendChild(getElementValue(doc, parties, "Town", sitecity)); addressInSpain.appendChild(getElementValue(doc, parties, "Town", sitecity));
addressInSpain.appendChild(getElementValue(doc, parties, "Province", siteStateCode)); addressInSpain.appendChild(getElementValue(doc, parties, "Province", siteStateCode));
addressInSpain.appendChild(getElementValue(doc, parties, "CountryCode", " ")); addressInSpain.appendChild(getElementValue(doc, parties, "CountryCode", "ESP"));
individual.appendChild(addressInSpain); individual.appendChild(addressInSpain);
sellerParty.appendChild(individual); sellerParty.appendChild(individual);
parties.appendChild(sellerParty); parties.appendChild(sellerParty);
...@@ -563,27 +636,30 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -563,27 +636,30 @@ public class GenInvoiceSchedule implements Schedule {
Element taxIdfbuyerParty = doc.createElement("TaxIdentification"); Element taxIdfbuyerParty = doc.createElement("TaxIdentification");
taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "PersonTypeCode", "J")); taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "PersonTypeCode", "J"));
taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "ResidenceTypeCode", "R")); taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "ResidenceTypeCode", "R"));
taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "TaxIdentificationNumber", custPanNo)); taxIdfbuyerParty.appendChild(getElementValue(doc, parties, "TaxIdentificationNumber", custTaxreg));
buyerParty.appendChild(taxIdfbuyerParty); buyerParty.appendChild(taxIdfbuyerParty);
Element administrativeCentresparent = doc.createElement("AdministrativeCentres"); Element administrativeCentresparent = doc.createElement("AdministrativeCentres");
Element administrativeCentres = doc.createElement("AdministrativeCentres");
administrativeCentres.appendChild(getElementValue(doc, parties, "CentreCode", custCode)); Element admCustDlv = doc.createElement("AdministrativeCentres");
administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", custType)); admCustDlv.appendChild(getElementValue(doc, parties, "CentreCode", custCodeDlv));
admCustDlv.appendChild(getElementValue(doc, parties, "RoleTypeCode", "01"));
// administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
administrativeCentres.appendChild(getElementValue(doc, parties, "Name", custName)); admCustDlv.appendChild(getElementValue(doc, parties, "Name", custName));
Element addressbuyer = doc.createElement("AddressInSpain"); Element addCustDlv = doc.createElement("AddressInSpain");
addressbuyer.appendChild(getElementValue(doc, parties, "Address", custAdd1)); addCustDlv.appendChild(getElementValue(doc, parties, "Address", dlvAdd1));
addressbuyer.appendChild(getElementValue(doc, parties, "PostCode", custPin)); addCustDlv.appendChild(getElementValue(doc, parties, "PostCode", dlvPin));
addressbuyer.appendChild(getElementValue(doc, parties, "Town", custCity)); addCustDlv.appendChild(getElementValue(doc, parties, "Town", dlvCity));
addressbuyer.appendChild(getElementValue(doc, parties, "Province", custState)); addCustDlv.appendChild(getElementValue(doc, parties, "Province", custState));
addressbuyer.appendChild(getElementValue(doc, parties, "CountryCode", custCountrtCode)); //addCustDlv.appendChild(getElementValue(doc, parties, "CountryCode", dlvCountryCode));
administrativeCentres.appendChild(addressbuyer); addCustDlv.appendChild(getElementValue(doc, parties, "CountryCode", "ESP"));
administrativeCentresparent.appendChild(administrativeCentres); admCustDlv.appendChild(addCustDlv);
administrativeCentresparent.appendChild(admCustDlv);
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
Element admCustBill = doc.createElement("AdministrativeCentres"); Element admCustBill = doc.createElement("AdministrativeCentres");
admCustBill.appendChild(getElementValue(doc, parties, "CentreCode", custCodeBill)); admCustBill.appendChild(getElementValue(doc, parties, "CentreCode", custCodeBill));
admCustBill.appendChild(getElementValue(doc, parties, "RoleTypeCode", custType)); admCustBill.appendChild(getElementValue(doc, parties, "RoleTypeCode", "02"));
// administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
admCustBill.appendChild(getElementValue(doc, parties, "Name", custName)); admCustBill.appendChild(getElementValue(doc, parties, "Name", custName));
Element addCustBill = doc.createElement("AddressInSpain"); Element addCustBill = doc.createElement("AddressInSpain");
...@@ -591,29 +667,45 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -591,29 +667,45 @@ public class GenInvoiceSchedule implements Schedule {
addCustBill.appendChild(getElementValue(doc, parties, "PostCode", custPin)); addCustBill.appendChild(getElementValue(doc, parties, "PostCode", custPin));
addCustBill.appendChild(getElementValue(doc, parties, "Town", custCity)); addCustBill.appendChild(getElementValue(doc, parties, "Town", custCity));
addCustBill.appendChild(getElementValue(doc, parties, "Province", custState)); addCustBill.appendChild(getElementValue(doc, parties, "Province", custState));
addCustBill.appendChild(getElementValue(doc, parties, "CountryCode", custCountrtCode)); //addCustBill.appendChild(getElementValue(doc, parties, "CountryCode", custCountrtCode));
addCustBill.appendChild(getElementValue(doc, parties, "CountryCode", "ESP"));
admCustBill.appendChild(addCustBill); admCustBill.appendChild(addCustBill);
administrativeCentresparent.appendChild(admCustBill); administrativeCentresparent.appendChild(admCustBill);
Element admCustDlv = doc.createElement("AdministrativeCentres");
admCustDlv.appendChild(getElementValue(doc, parties, "CentreCode", custCode)); Element administrativeCentres = doc.createElement("AdministrativeCentres");
admCustDlv.appendChild(getElementValue(doc, parties, "RoleTypeCode", custType)); administrativeCentres.appendChild(getElementValue(doc, parties, "CentreCode", custCode));
administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
// administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
admCustDlv.appendChild(getElementValue(doc, parties, "Name", custName)); administrativeCentres.appendChild(getElementValue(doc, parties, "Name", custName));
Element addCustDlv = doc.createElement("AddressInSpain"); Element addressbuyer = doc.createElement("AddressInSpain");
addCustDlv.appendChild(getElementValue(doc, parties, "Address", custAdd1)); addressbuyer.appendChild(getElementValue(doc, parties, "Address", custAdd1));
addCustDlv.appendChild(getElementValue(doc, parties, "PostCode", custPin)); addressbuyer.appendChild(getElementValue(doc, parties, "PostCode", custPin));
addCustDlv.appendChild(getElementValue(doc, parties, "Town", custCity)); addressbuyer.appendChild(getElementValue(doc, parties, "Town", custCity));
addCustDlv.appendChild(getElementValue(doc, parties, "Province", custState)); addressbuyer.appendChild(getElementValue(doc, parties, "Province", custState));
addCustDlv.appendChild(getElementValue(doc, parties, "CountryCode", custCountrtCode)); // addressbuyer.appendChild(getElementValue(doc, parties, "CountryCode", custCountrtCode));
admCustDlv.appendChild(addCustDlv); addressbuyer.appendChild(getElementValue(doc, parties, "CountryCode", "ESP"));
administrativeCentresparent.appendChild(admCustDlv); administrativeCentres.appendChild(addressbuyer);
administrativeCentresparent.appendChild(administrativeCentres);
/*------------------------------------------------------------------*/
buyerParty.appendChild(administrativeCentresparent); buyerParty.appendChild(administrativeCentresparent);
/*------------------------------------------------------------------*/
Element legalEntity = doc.createElement("LegalEntity");
legalEntity.appendChild(getElementValue(doc, parties, "CorporateName", siteDescr));
//legalEntity.appendChild(getElementValue(doc, parties, "TradeName", ""));
Element addlegalEntity = doc.createElement("AddressInSpain");
addlegalEntity.appendChild(getElementValue(doc, parties, "Address",siteAdd1));
addlegalEntity.appendChild(getElementValue(doc, parties, "PostCode", sitePin));
addlegalEntity.appendChild(getElementValue(doc, parties, "Town", sitecity));
addlegalEntity.appendChild(getElementValue(doc, parties, "Province", siteStateCode));
addlegalEntity.appendChild(getElementValue(doc, parties, "CountryCode","ESP"));
legalEntity.appendChild(addlegalEntity);
buyerParty.appendChild(legalEntity);
parties.appendChild(buyerParty); parties.appendChild(buyerParty);
/*-----------------------Element for buyer party,end-----------------------------*/ /*-----------------------Element for buyer party,end-----------------------------*/
...@@ -629,24 +721,29 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -629,24 +721,29 @@ public class GenInvoiceSchedule implements Schedule {
String sql=""; String sql="";
String custCode="",currencyCode="",itemCode="",itemDescr="",quantity="",unit=""; String custCode="",currencyCode="",itemCode="",itemDescr="",quantity="",unit="";
String taxCode="",taxClass="",taxBase="",taxChap="",taxEnv="",taxAmt="",exchRate="",discAmt="",taxBaseAmt="",taxPersc=""; String taxCode="",taxClass="",taxBase="",taxChap="",taxEnv="",exchRate="",discAmt="";
String invoiceAmtHd="",taxAmtHd="",discAmtHd="",NetAmtHd="",currCodeHd="",invoiceDtHd=""; String currCodeHd="",invoiceISOCode="";
String itemCodeDet="",itemDescrDet="",quantityDet="",unitDet="",rateDet="",discountDet="",taxAmtDet="",discAmtDet="",accDet="",instAmtDet="",netAmtDet=""; String itemCodeDet="",itemDescrDet="",quantityDet="",unitDet="",accDet="",instAmtDet="";
String rate="",unitRate="",discountInv="",taxEffects=""; String rate="",unitRate="",discountInv="",taxEffects="",siteCode="",paymentMeans="",accToBeCredited="",docStatus="";
double taxBaseAmt=0.00,taxAmtHd=0.00 ,NetAmtHd=0.00,discAmtHd=0.00,invoiceAmtHd=0.00,rateDet=0.00;
double taxAmtDet=0.00,netAmtDet=0.00,discAmtDet=0.00,taxAmt=0.00,taxPersc=0.00,discountDet=0.00;
GenericUtility genericUtility = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
int cnt=0; int cnt=0;
int totalAmt=0,amtWitoutTax=0; int totalAmt=0,amtWitoutTax=0;
HashMap<String, String> tempMap = new HashMap<String, String>(); HashMap<String, String> tempMap = new HashMap<String, String>();
SimpleDateFormat sdf = null;
Date invoiceDtHd=null;
try try
{ {
System.out.println("getInvoiceElement@@@@@@@@@@@@"); System.out.println("getInvoiceElement@@@@@@@@@@@@");
genericUtility = new GenericUtility();
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
sql = " select INV_AMT,TAX_AMT,DISC_AMT,NET_AMT,CURR_CODE,TRAN_DATE from invoice " + sql = " select INV_AMT,TAX_AMT,DISC_AMT,NET_AMT,CURR_CODE,TRAN_DATE ,SITE_CODE ,DOC_STATUS from invoice " +
"where invoice_id=?" ; "where invoice_id=?" ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -654,14 +751,36 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -654,14 +751,36 @@ public class GenInvoiceSchedule implements Schedule {
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
invoiceDtHd = rs.getString("TRAN_DATE"); invoiceDtHd = rs.getDate("TRAN_DATE");
invoiceAmtHd = rs.getString("INV_AMT"); invoiceAmtHd = rs.getDouble("INV_AMT");
taxAmtHd = rs.getString("TAX_AMT"); taxAmtHd = rs.getDouble("TAX_AMT");
discAmtHd = rs.getString("DISC_AMT"); discAmtHd = rs.getDouble("DISC_AMT");
NetAmtHd = rs.getString("NET_AMT"); NetAmtHd = rs.getDouble("NET_AMT");
currCodeHd = rs.getString("CURR_CODE"); currCodeHd = rs.getString("CURR_CODE");
siteCode= rs.getString("SITE_CODE");
docStatus= rs.getString("DOC_STATUS");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
paymentMeans=getSiteRegvalue(conn,"IBAN",siteCode);
accToBeCredited=getSiteRegvalue(conn,"ACCTNO",siteCode);
System.out.println("paymentMeans : "+paymentMeans);
System.out.println("accToBeCredited : "+accToBeCredited);
sql = "select iso4217 from currency where curr_code=? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currencyCode);
rs = pstmt.executeQuery();
if (rs.next())
{
invoiceISOCode = rs.getString("iso4217");
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -684,11 +803,11 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -684,11 +803,11 @@ public class GenInvoiceSchedule implements Schedule {
itemDescrDet = rs.getString("ITEM_DESCR"); itemDescrDet = rs.getString("ITEM_DESCR");
quantityDet = rs.getString("QUANTITY"); quantityDet = rs.getString("QUANTITY");
unitDet = rs.getString("UNIT"); unitDet = rs.getString("UNIT");
rateDet = rs.getString("RATE"); rateDet = rs.getDouble("RATE");
discountDet = rs.getString("DISCOUNT"); discountDet = rs.getDouble("DISCOUNT");
taxAmtDet = rs.getString("TAX_AMT"); taxAmtDet = rs.getDouble("TAX_AMT");
netAmtDet = rs.getString("NET_AMT"); netAmtDet = rs.getDouble("NET_AMT");
discAmtDet = rs.getString("DISC_AMT"); discAmtDet = rs.getDouble("DISC_AMT");
instAmtDet = rs.getString("INST_AMOUNT"); instAmtDet = rs.getString("INST_AMOUNT");
accDet = rs.getString("ACC_CODE__ITEM"); accDet = rs.getString("ACC_CODE__ITEM");
...@@ -697,11 +816,11 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -697,11 +816,11 @@ public class GenInvoiceSchedule implements Schedule {
itemDescrDet = itemDescrDet == null ? " " : itemDescrDet.trim(); itemDescrDet = itemDescrDet == null ? " " : itemDescrDet.trim();
quantityDet = quantityDet == null ? " " : quantityDet.trim(); quantityDet = quantityDet == null ? " " : quantityDet.trim();
unitDet = unitDet == null ? " " : unitDet.trim(); unitDet = unitDet == null ? " " : unitDet.trim();
rateDet = rateDet == null ? " " : rateDet.trim(); // rateDet = rateDet == null ? " " : rateDet.trim();
discountDet = discountDet == null ? " " : discountDet.trim(); //discountDet = discountDet == null ? " " : discountDet.trim();
taxAmtDet = taxAmtDet == null ? " " : taxAmtDet.trim(); //taxAmtDet = taxAmtDet == null ? " " : taxAmtDet.trim();
netAmtDet = netAmtDet == null ? " " : netAmtDet.trim(); //netAmtDet = netAmtDet == null ? " " : netAmtDet.trim();
discAmtDet = discAmtDet == null ? " " : discAmtDet.trim(); // discAmtDet = discAmtDet == null ? " " : discAmtDet.trim();
instAmtDet = instAmtDet == null ? " " : instAmtDet.trim(); instAmtDet = instAmtDet == null ? " " : instAmtDet.trim();
accDet = accDet == null ? " " : accDet.trim(); accDet = accDet == null ? " " : accDet.trim();
...@@ -711,11 +830,11 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -711,11 +830,11 @@ public class GenInvoiceSchedule implements Schedule {
tempMap.put("item_descr" + cnt, itemDescrDet); tempMap.put("item_descr" + cnt, itemDescrDet);
tempMap.put("quantity" + cnt, quantityDet); tempMap.put("quantity" + cnt, quantityDet);
tempMap.put("unit" + cnt, unitDet); tempMap.put("unit" + cnt, unitDet);
tempMap.put("rate" + cnt, rateDet); tempMap.put("rate" + cnt, String.valueOf(rateDet));
tempMap.put("discount" + cnt, discountDet); tempMap.put("discount" + cnt, String.valueOf(discountDet));
tempMap.put("tax_amt" + cnt, taxAmtDet); tempMap.put("tax_amt" + cnt, String.valueOf(taxAmtDet));
tempMap.put("net_amt" + cnt, netAmtDet); tempMap.put("net_amt" + cnt, String.valueOf(netAmtDet));
tempMap.put("disc_amt" + cnt, discAmtDet); tempMap.put("disc_amt" + cnt, String.valueOf(discAmtDet));
tempMap.put("installment_amt" + cnt, instAmtDet); tempMap.put("installment_amt" + cnt, instAmtDet);
tempMap.put("acc_code" + cnt, accDet); tempMap.put("acc_code" + cnt, accDet);
...@@ -738,12 +857,12 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -738,12 +857,12 @@ public class GenInvoiceSchedule implements Schedule {
{ {
taxCode = rs.getString("TAX_CODE"); taxCode = rs.getString("TAX_CODE");
taxClass = rs.getString("TAX_CLASS"); taxClass = rs.getString("TAX_CLASS");
taxBaseAmt = rs.getString("TAXABLE_AMT"); taxBaseAmt = rs.getDouble("TAXABLE_AMT");
taxChap = rs.getString("TAX_CHAP"); taxChap = rs.getString("TAX_CHAP");
taxEnv = rs.getString("TAX_ENV"); taxEnv = rs.getString("TAX_ENV");
taxAmt = rs.getString("TAX_AMT"); taxAmt = rs.getDouble("TAX_AMT");
exchRate = rs.getString("EXCH_RATE"); exchRate = rs.getString("EXCH_RATE");
taxPersc = rs.getString("TAX_PERC"); taxPersc = rs.getDouble("TAX_PERC");
taxEffects = rs.getString("EFFECT"); taxEffects = rs.getString("EFFECT");
} }
...@@ -752,7 +871,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -752,7 +871,7 @@ public class GenInvoiceSchedule implements Schedule {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(taxEffects.equalsIgnoreCase("+")) /*if(taxEffects.equalsIgnoreCase("+"))
{ {
taxEffects="Chargeable Tax"; taxEffects="Chargeable Tax";
} }
...@@ -763,23 +882,27 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -763,23 +882,27 @@ public class GenInvoiceSchedule implements Schedule {
if(taxEffects.equalsIgnoreCase("N")) if(taxEffects.equalsIgnoreCase("N"))
{ {
taxEffects="Exempt From Tax"; taxEffects="Exempt From Tax";
} }*/
invoiceDtHd = invoiceDtHd == null ? " " : invoiceDtHd.trim();
invoiceAmtHd = invoiceAmtHd == null ? " " : invoiceAmtHd.trim();
taxAmtHd = taxAmtHd == null ? " " : taxAmtHd.trim();
discAmtHd = discAmtHd == null ? " " : discAmtHd.trim();
NetAmtHd = NetAmtHd == null ? " " : NetAmtHd.trim();
currCodeHd = currCodeHd == null ? " " : currCodeHd.trim();
//invoiceDtHd = invoiceDtHd == null ? " " : invoiceDtHd.trim();
//invoiceAmtHd = invoiceAmtHd == null ? " " : invoiceAmtHd.trim();
//taxAmtHd = taxAmtHd == null ? " " : taxAmtHd.trim();
//discAmtHd = discAmtHd == null ? " " : discAmtHd.trim();
//NetAmtHd = NetAmtHd == null ? " " : NetAmtHd.trim();
currCodeHd = currCodeHd == null ? " " : currCodeHd.trim();
invoiceISOCode = invoiceISOCode == null ? " " : invoiceISOCode.trim();
paymentMeans = paymentMeans == null ? " " : paymentMeans.trim();
accToBeCredited = accToBeCredited == null ? " " : accToBeCredited.trim();
taxCode = taxCode == null ? " " : taxCode.trim(); taxCode = taxCode == null ? " " : taxCode.trim();
taxClass = taxClass == null ? " " : taxClass.trim(); taxClass = taxClass == null ? " " : taxClass.trim();
taxBaseAmt = taxBaseAmt == null ? " " : taxBaseAmt.trim(); //taxBaseAmt = taxBaseAmt == null ? " " : taxBaseAmt.trim();
taxChap = taxChap == null ? " " : taxChap.trim(); taxChap = taxChap == null ? " " : taxChap.trim();
taxEnv = taxEnv == null ? " " : taxEnv.trim(); taxEnv = taxEnv == null ? " " : taxEnv.trim();
taxAmt = taxAmt == null ? " " : taxAmt.trim(); //taxAmt = taxAmt == null ? " " : taxAmt.trim();
exchRate = exchRate == null ? " " : exchRate.trim(); exchRate = exchRate == null ? " " : exchRate.trim();
taxPersc = taxPersc == null ? " " : taxPersc.trim(); //taxPersc = taxPersc == null ? " " : taxPersc.trim();
taxEffects= taxEffects == null ? " " : taxEffects.trim(); taxEffects= taxEffects == null ? " " : taxEffects.trim();
docStatus= docStatus == null ? " " : docStatus.trim();
...@@ -798,100 +921,105 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -798,100 +921,105 @@ public class GenInvoiceSchedule implements Schedule {
Element invoiceHeader = doc.createElement("InvoiceHeader"); Element invoiceHeader = doc.createElement("InvoiceHeader");
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceNumber", invoiceId)); invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceNumber", invoiceId));
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceSeriesCode", " ")); //invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceSeriesCode", " "));
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceDocumentType","" )); invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceDocumentType",docStatus ));
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceClass", "")); invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceClass", ""));
invoice.appendChild(invoiceHeader); invoice.appendChild(invoiceHeader);
Element invoiceIssueData = doc.createElement("InvoiceIssueData"); Element invoiceIssueData = doc.createElement("InvoiceIssueData");
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "IssueDate", invoiceDtHd)); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "IssueDate",sdf.format(invoiceDtHd)));
Element invoicingPeriod = doc.createElement("InvoicingPeriod"); Element invoicingPeriod = doc.createElement("InvoicingPeriod");
invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "StartDate", invoiceDtHd)); invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "StartDate",sdf.format(invoiceDtHd)));
invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "EndDate", invoiceDtHd)); invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "EndDate",sdf.format(invoiceDtHd)));
invoiceIssueData.appendChild(invoicingPeriod); invoiceIssueData.appendChild(invoicingPeriod);
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "InvoiceCurrencyCode", currCodeHd)); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "InvoiceCurrencyCode", invoiceISOCode));
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "TaxCurrencyCode", currCodeHd)); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "TaxCurrencyCode", "EUR"));
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "LanguageName", " ")); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "LanguageName", "es"));
invoice.appendChild(invoiceIssueData); invoice.appendChild(invoiceIssueData);
Element taxesOutputs = doc.createElement("TaxesOutputs"); Element taxesOutputs = doc.createElement("TaxesOutputs");
Element tax = doc.createElement("Tax"); Element tax = doc.createElement("Tax");
tax.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", taxEffects)); tax.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "01"));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxRate", taxPersc)); tax.appendChild(getElementValue(doc, invoiceParent, "TaxRate", String.valueOf(taxPersc)));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", taxBaseAmt)); //tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", taxBaseAmt));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxAmount",taxAmt)); tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", String.valueOf(taxBaseAmt)));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxAmount",String.valueOf(taxAmt)));
tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", "")); tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", ""));
tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", "")); tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", "0.00"));
taxesOutputs.appendChild(tax); taxesOutputs.appendChild(tax);
invoice.appendChild(taxesOutputs); invoice.appendChild(taxesOutputs);
Element taxesWithheld = doc.createElement("TaxesWithheld"); Element taxesWithheld = doc.createElement("TaxesWithheld");
Element taxHeld = doc.createElement("TaxesWithheld"); Element taxHeld = doc.createElement("TaxesWithheld");
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode",taxEffects )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode","00" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxRate",taxPersc )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxRate","0.00" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxableBase",taxBaseAmt )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", "0.00" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxAmount",taxAmt)); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxAmount","0.00"));
taxesWithheld.appendChild(taxHeld); taxesWithheld.appendChild(taxHeld);
invoice.appendChild(taxesWithheld); invoice.appendChild(taxesWithheld);
Element invoiceTotals = doc.createElement("InvoiceTotals"); Element invoiceTotals = doc.createElement("InvoiceTotals");
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmount", NetAmtHd)); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmount", String.valueOf(NetAmtHd)));
Element generalDiscounts = doc.createElement("GeneralDiscounts"); Element generalDiscounts = doc.createElement("GeneralDiscounts");
Element discount = doc.createElement("Discount"); Element discount = doc.createElement("Discount");
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", " ")); if(String.valueOf(discAmtHd).equalsIgnoreCase("0.0"))
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", " ")); {
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", discAmtHd)); discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", ""));
}
else
{
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions"));
}
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", ""));
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", String.valueOf(discAmtHd)));
generalDiscounts.appendChild(discount); generalDiscounts.appendChild(discount);
invoiceTotals.appendChild(generalDiscounts); invoiceTotals.appendChild(generalDiscounts);
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralDiscounts", discAmtHd)); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralDiscounts", String.valueOf(discAmtHd)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralSurcharges", "0.00")); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralSurcharges", "0.00"));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmountBeforeTaxes", NetAmtHd)); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmountBeforeTaxes", String.valueOf(NetAmtHd)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxOutputs", taxAmtHd )); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxOutputs", String.valueOf(taxAmtHd) ));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxesWithheld", taxAmtHd )); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxesWithheld","0.00" ));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalOutstandingAmount", NetAmtHd)); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalOutstandingAmount", String.valueOf(NetAmtHd)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalExecutableAmount", NetAmtHd)); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalExecutableAmount", String.valueOf(NetAmtHd)));
invoice.appendChild(invoiceTotals); invoice.appendChild(invoiceTotals);
for(int i = 1; i<= cnt ; i++) for(int i = 1; i<= cnt ; i++)
{ {
/*if(tempMap.get("tax_amt" + cnt) != "")
{
totalAmt=Integer.parseInt(tempMap.get("tax_amt" + cnt))+Integer.parseInt(tempMap.get("net_amt" + cnt));
amtWitoutTax=totalAmt - Integer.parseInt(tempMap.get("tax_amt" + cnt));
System.out.println("totalAmt ! "+totalAmt);
}
else
{
totalAmt=Integer.parseInt(tempMap.get("net_amt" + cnt));
amtWitoutTax=totalAmt;
System.out.println("totalAmt "+totalAmt);
}*/
Element items = doc.createElement("Items"); Element items = doc.createElement("Items");
Element invoiceLine = doc.createElement("InvoiceLine"); Element invoiceLine = doc.createElement("InvoiceLine");
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "ItemDescription", (String) tempMap.get("item_descr" + cnt))); invoiceLine.appendChild(getElementValue(doc, invoiceParent, "ItemDescription", (String) tempMap.get("item_descr" + cnt)));
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "Quantity", (String) tempMap.get("quantity" + cnt))); invoiceLine.appendChild(getElementValue(doc, invoiceParent, "Quantity", (String) tempMap.get("quantity" + cnt)));
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "UnitOfMeasure", (String) tempMap.get("unit" + cnt))); //invoiceLine.appendChild(getElementValue(doc, invoiceParent, "UnitOfMeasure", (String) tempMap.get("unit" + cnt)));
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "UnitOfMeasure", "01"));
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "UnitPriceWithoutTax", (String) tempMap.get("rate" + cnt))); invoiceLine.appendChild(getElementValue(doc, invoiceParent, "UnitPriceWithoutTax", (String) tempMap.get("rate" + cnt)));
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "TotalCost",(String) tempMap.get("net_amt" + cnt) )); invoiceLine.appendChild(getElementValue(doc, invoiceParent, "TotalCost",(String) tempMap.get("net_amt" + cnt) ));
Element discountsAndRebates = doc.createElement("DiscountsAndRebates"); Element discountsAndRebates = doc.createElement("DiscountsAndRebates");
Element discountItem = doc.createElement("Discount"); Element discountItem = doc.createElement("Discount");
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "descuento")); if(tempMap.get("disc_amt" + cnt).equalsIgnoreCase("0.0"))
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", " ")); {
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", discAmt)); discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", ""));
}
else
{
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions"));
}
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", (String) tempMap.get("discount" + cnt)));
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", (String) tempMap.get("disc_amt" + cnt)));
discountsAndRebates.appendChild(discountItem); discountsAndRebates.appendChild(discountItem);
invoiceLine.appendChild(discountsAndRebates); invoiceLine.appendChild(discountsAndRebates);
Element charges = doc.createElement("Charges"); Element charges = doc.createElement("Charges");
Element charge = doc.createElement("Charge"); Element charge = doc.createElement("Charge");
charge.appendChild(getElementValue(doc, invoiceParent, "ChargeReason", " ")); charge.appendChild(getElementValue(doc, invoiceParent, "ChargeReason", ""));
charge.appendChild(getElementValue(doc, invoiceParent, "ChargeRate", " ")); charge.appendChild(getElementValue(doc, invoiceParent, "ChargeRate", "0.00"));
charge.appendChild(getElementValue(doc, invoiceParent, "ChargeAmount", " ")); charge.appendChild(getElementValue(doc, invoiceParent, "ChargeAmount", "0.00"));
charges.appendChild(charge); charges.appendChild(charge);
invoiceLine.appendChild(charges); invoiceLine.appendChild(charges);
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "GrossAmount", (String) tempMap.get("net_amt" + cnt))); invoiceLine.appendChild(getElementValue(doc, invoiceParent, "GrossAmount", (String) tempMap.get("net_amt" + cnt)));
...@@ -901,10 +1029,10 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -901,10 +1029,10 @@ public class GenInvoiceSchedule implements Schedule {
Element taxesWithheldItem = doc.createElement("TaxesWithheld"); Element taxesWithheldItem = doc.createElement("TaxesWithheld");
Element taxHeldItem = doc.createElement("TaxesWithheld"); Element taxHeldItem = doc.createElement("TaxesWithheld");
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", taxEffects)); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "00"));
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", taxPersc)); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", "0.00"));
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase",taxBaseAmt)); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase","0.00"));
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", (String) tempMap.get("tax_amt" + cnt))); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", "0.00"));
taxesWithheldItem.appendChild(taxHeldItem); taxesWithheldItem.appendChild(taxHeldItem);
invoiceLine.appendChild(taxesWithheldItem); invoiceLine.appendChild(taxesWithheldItem);
...@@ -913,12 +1041,12 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -913,12 +1041,12 @@ public class GenInvoiceSchedule implements Schedule {
Element taxesOutputsItem = doc.createElement("TaxesOutputs"); Element taxesOutputsItem = doc.createElement("TaxesOutputs");
Element taxItem = doc.createElement("Tax"); Element taxItem = doc.createElement("Tax");
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", taxEffects)); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "01"));
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", taxPersc)); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", String.valueOf(taxPersc)));
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", taxBaseAmt)); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", String.valueOf(taxBaseAmt)));
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", (String) tempMap.get("tax_amt" + cnt))); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", (String) tempMap.get("tax_amt" + cnt)));
taxItem.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", " ")); taxItem.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", " "));
taxItem.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", " ")); taxItem.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", "0.00"));
taxesOutputsItem.appendChild(taxItem); taxesOutputsItem.appendChild(taxItem);
invoiceLine.appendChild(taxesOutputsItem); invoiceLine.appendChild(taxesOutputsItem);
...@@ -928,7 +1056,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -928,7 +1056,7 @@ public class GenInvoiceSchedule implements Schedule {
invoiceLine.appendChild(getElementValue(doc, invoiceParent, "AdditionalLineItemInformation", " ")); //invoiceLine.appendChild(getElementValue(doc, invoiceParent, "AdditionalLineItemInformation", " "));
items.appendChild(invoiceLine); items.appendChild(invoiceLine);
...@@ -938,11 +1066,11 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -938,11 +1066,11 @@ public class GenInvoiceSchedule implements Schedule {
Element paymentDetails = doc.createElement("PaymentDetails"); Element paymentDetails = doc.createElement("PaymentDetails");
Element installment = doc.createElement("Installment"); Element installment = doc.createElement("Installment");
installment.appendChild(getElementValue(doc, invoiceParent, "InstallmentDueDate", invoiceDtHd)); installment.appendChild(getElementValue(doc, invoiceParent, "InstallmentDueDate", sdf.format(invoiceDtHd)));
installment.appendChild(getElementValue(doc, invoiceParent, "InstallmentAmount", (String) tempMap.get("net_amt1"))); installment.appendChild(getElementValue(doc, invoiceParent, "InstallmentAmount", (String) tempMap.get("net_amt1")));
installment.appendChild(getElementValue(doc, invoiceParent, "PaymentMeans", " ")); installment.appendChild(getElementValue(doc, invoiceParent, "PaymentMeans", paymentMeans));
Element accountToBeCredited = doc.createElement("AccountToBeCredited"); Element accountToBeCredited = doc.createElement("AccountToBeCredited");
accountToBeCredited.appendChild(getElementValue(doc, invoiceParent, "IBAN", " ")); accountToBeCredited.appendChild(getElementValue(doc, invoiceParent, "IBAN",accToBeCredited));
installment.appendChild(accountToBeCredited); installment.appendChild(accountToBeCredited);
paymentDetails.appendChild(installment); paymentDetails.appendChild(installment);
...@@ -968,6 +1096,38 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -968,6 +1096,38 @@ public class GenInvoiceSchedule implements Schedule {
} }
public static String getSiteRegvalue(Connection conn,String col1,String siteCode)
{
String result="",sql="";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = "select reg_no from siteregno where site_code=? and REF_CODE=?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, col1);
rs = pstmt.executeQuery();
if (rs.next())
{
result = rs.getString("reg_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return result;
}
} }
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