Commit 034dcde8 authored by mjadhav's avatar mjadhav

date format changes for invoice


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97021 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a8a2406c
...@@ -14,6 +14,7 @@ import java.sql.DriverManager; ...@@ -14,6 +14,7 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -32,6 +33,7 @@ import org.w3c.dom.Document; ...@@ -32,6 +33,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import ibase.webitm.ejb.sys.UtilMethods;
public class GenInvoiceSchedule implements Schedule { public class GenInvoiceSchedule implements Schedule {
...@@ -315,6 +317,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -315,6 +317,7 @@ public class GenInvoiceSchedule implements Schedule {
catch (ParserConfigurationException pce) catch (ParserConfigurationException pce)
{ {
pce.printStackTrace(); pce.printStackTrace();
System.out.println("ParserConfigurationException :"+pce.getMessage());
errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", ""); errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", "");
return errString; return errString;
...@@ -322,12 +325,15 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -322,12 +325,15 @@ public class GenInvoiceSchedule implements Schedule {
catch (TransformerException tfe) catch (TransformerException tfe)
{ {
tfe.printStackTrace(); tfe.printStackTrace();
System.out.println("TransformerException :"+tfe.getMessage());
errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", ""); errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", "");
return errString; return errString;
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace();
System.out.println("Exception :"+e.getMessage());
errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", ""); errString = itmDBAccessLocal.getErrorString("", "VTTRINERR", "");
return errString; return errString;
...@@ -352,6 +358,10 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -352,6 +358,10 @@ public class GenInvoiceSchedule implements Schedule {
ResultSet rs = null; ResultSet rs = null;
String sql="",invType="",currencyCode="",invoiceISOCode=""; String sql="",invType="",currencyCode="",invoiceISOCode="";
double invAmt=0.0,netAmt=0.0; double invAmt=0.0,netAmt=0.0;
DecimalFormat twoDf = new DecimalFormat("#.00");
DecimalFormat fourDf = new DecimalFormat("#.0000");
DecimalFormat sixDf = new DecimalFormat("#.000000");
UtilMethods utilMethods= new UtilMethods();
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=? " ;
...@@ -407,22 +417,24 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -407,22 +417,24 @@ public class GenInvoiceSchedule implements Schedule {
fileHeader.appendChild(getElementValue(doc, fileHeader, "Modality", "I")); fileHeader.appendChild(getElementValue(doc, fileHeader, "Modality", "I"));
fileHeader.appendChild(getElementValue(doc, fileHeader, "InvoiceIssuerType", "EM")); 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",invoiceId));
batch.appendChild(getElementValue(doc, fileHeader, "InvoicesCount"," ")); batch.appendChild(getElementValue(doc, fileHeader, "InvoicesCount","1"));
Element totalInvoicesAmount = doc.createElement("TotalInvoicesAmount"); Element totalInvoicesAmount = doc.createElement("TotalInvoicesAmount");
totalInvoicesAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(invAmt))); // totalInvoicesAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(twoDf.format(invAmt))));
totalInvoicesAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",utilMethods.getReqDecString(invAmt, 2)));
batch.appendChild(totalInvoicesAmount); batch.appendChild(totalInvoicesAmount);
Element totalOutstandingAmount = doc.createElement("TotalOutstandingAmount"); Element totalOutstandingAmount = doc.createElement("TotalOutstandingAmount");
totalOutstandingAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(netAmt))); totalOutstandingAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",utilMethods.getReqDecString(netAmt, 2)));
batch.appendChild(totalOutstandingAmount); batch.appendChild(totalOutstandingAmount);
Element totalExecutableAmount = doc.createElement("TotalExecutableAmount"); Element totalExecutableAmount = doc.createElement("TotalExecutableAmount");
totalExecutableAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",String.valueOf(netAmt))); totalExecutableAmount.appendChild(getElementValue(doc, fileHeader, "TotalAmount",utilMethods.getReqDecString(netAmt, 2)));
batch.appendChild(totalOutstandingAmount); batch.appendChild(totalExecutableAmount);
batch.appendChild(getElementValue(doc, fileHeader, "InvoiceCurrencyCode",invoiceISOCode)); batch.appendChild(getElementValue(doc, fileHeader, "InvoiceCurrencyCode",invoiceISOCode));
//batch.appendChild(getElementValue(doc, fileHeader, "InvoiceCurrencyCode","EUR"));
fileHeader.appendChild(batch); fileHeader.appendChild(batch);
return fileHeader; return fileHeader;
} }
...@@ -499,7 +511,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -499,7 +511,7 @@ public class GenInvoiceSchedule implements Schedule {
sql = "select reg_no from siteregno where site_code=?" ; sql = "select reg_no from siteregno where site_code=? and REF_CODE='TAXNO' " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
...@@ -645,7 +657,10 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -645,7 +657,10 @@ public class GenInvoiceSchedule implements Schedule {
admCustDlv.appendChild(getElementValue(doc, parties, "CentreCode", custCodeDlv)); admCustDlv.appendChild(getElementValue(doc, parties, "CentreCode", custCodeDlv));
admCustDlv.appendChild(getElementValue(doc, parties, "RoleTypeCode", "01")); admCustDlv.appendChild(getElementValue(doc, parties, "RoleTypeCode", "01"));
// administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
if(custName != "")
{
admCustDlv.appendChild(getElementValue(doc, parties, "Name", custName)); admCustDlv.appendChild(getElementValue(doc, parties, "Name", custName));
}
Element addCustDlv = doc.createElement("AddressInSpain"); Element addCustDlv = doc.createElement("AddressInSpain");
addCustDlv.appendChild(getElementValue(doc, parties, "Address", dlvAdd1)); addCustDlv.appendChild(getElementValue(doc, parties, "Address", dlvAdd1));
addCustDlv.appendChild(getElementValue(doc, parties, "PostCode", dlvPin)); addCustDlv.appendChild(getElementValue(doc, parties, "PostCode", dlvPin));
...@@ -658,10 +673,16 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -658,10 +673,16 @@ public class GenInvoiceSchedule implements Schedule {
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
Element admCustBill = doc.createElement("AdministrativeCentres"); Element admCustBill = doc.createElement("AdministrativeCentres");
if(custCodeBill != "")
{
admCustBill.appendChild(getElementValue(doc, parties, "CentreCode", custCodeBill)); admCustBill.appendChild(getElementValue(doc, parties, "CentreCode", custCodeBill));
}
admCustBill.appendChild(getElementValue(doc, parties, "RoleTypeCode", "02")); admCustBill.appendChild(getElementValue(doc, parties, "RoleTypeCode", "02"));
// administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
if(custName != "")
{
admCustBill.appendChild(getElementValue(doc, parties, "Name", custName)); admCustBill.appendChild(getElementValue(doc, parties, "Name", custName));
}
Element addCustBill = doc.createElement("AddressInSpain"); Element addCustBill = doc.createElement("AddressInSpain");
addCustBill.appendChild(getElementValue(doc, parties, "Address", custAdd1)); addCustBill.appendChild(getElementValue(doc, parties, "Address", custAdd1));
addCustBill.appendChild(getElementValue(doc, parties, "PostCode", custPin)); addCustBill.appendChild(getElementValue(doc, parties, "PostCode", custPin));
...@@ -678,7 +699,10 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -678,7 +699,10 @@ public class GenInvoiceSchedule implements Schedule {
administrativeCentres.appendChild(getElementValue(doc, parties, "CentreCode", custCode)); 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")); // administrativeCentres.appendChild(getElementValue(doc, parties, "RoleTypeCode", "03"));
if(custName != "")
{
administrativeCentres.appendChild(getElementValue(doc, parties, "Name", custName)); administrativeCentres.appendChild(getElementValue(doc, parties, "Name", custName));
}
Element addressbuyer = doc.createElement("AddressInSpain"); Element addressbuyer = doc.createElement("AddressInSpain");
addressbuyer.appendChild(getElementValue(doc, parties, "Address", custAdd1)); addressbuyer.appendChild(getElementValue(doc, parties, "Address", custAdd1));
addressbuyer.appendChild(getElementValue(doc, parties, "PostCode", custPin)); addressbuyer.appendChild(getElementValue(doc, parties, "PostCode", custPin));
...@@ -735,12 +759,17 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -735,12 +759,17 @@ public class GenInvoiceSchedule implements Schedule {
HashMap<String, String> tempMap = new HashMap<String, String>(); HashMap<String, String> tempMap = new HashMap<String, String>();
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
Date invoiceDtHd=null; Date invoiceDtHd=null;
DecimalFormat twoDf = new DecimalFormat("#.00");
DecimalFormat fourDf = new DecimalFormat("#.0000");
DecimalFormat sixDf = new DecimalFormat("#.000000");
UtilMethods utilMethods= new UtilMethods();
try try
{ {
System.out.println("getInvoiceElement@@@@@@@@@@@@"); System.out.println("getInvoiceElement@@@@@@@@@@@@");
genericUtility = new GenericUtility(); genericUtility = new GenericUtility();
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat()); //sdf=new SimpleDateFormat("yyyy-mm-dd");
sdf=new SimpleDateFormat("yyyy-MM-dd");
sql = " select INV_AMT,TAX_AMT,DISC_AMT,NET_AMT,CURR_CODE,TRAN_DATE ,SITE_CODE ,DOC_STATUS from invoice " + sql = " select INV_AMT,TAX_AMT,DISC_AMT,NET_AMT,CURR_CODE,TRAN_DATE ,SITE_CODE ,DOC_STATUS from invoice " +
...@@ -765,6 +794,9 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -765,6 +794,9 @@ public class GenInvoiceSchedule implements Schedule {
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
//2014-03-12
System.out.println("invoiceDtHd : "+invoiceDtHd);
paymentMeans=getSiteRegvalue(conn,"IBAN",siteCode); paymentMeans=getSiteRegvalue(conn,"IBAN",siteCode);
accToBeCredited=getSiteRegvalue(conn,"ACCTNO",siteCode); accToBeCredited=getSiteRegvalue(conn,"ACCTNO",siteCode);
...@@ -830,11 +862,12 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -830,11 +862,12 @@ 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, String.valueOf(rateDet));
tempMap.put("discount" + cnt, String.valueOf(discountDet)); tempMap.put("rate" + cnt, utilMethods.getReqDecString(rateDet, 6));
tempMap.put("tax_amt" + cnt, String.valueOf(taxAmtDet)); tempMap.put("discount" + cnt, utilMethods.getReqDecString(discountDet, 4));
tempMap.put("net_amt" + cnt, String.valueOf(netAmtDet)); tempMap.put("tax_amt" + cnt, utilMethods.getReqDecString(taxAmtDet,2));
tempMap.put("disc_amt" + cnt, String.valueOf(discAmtDet)); tempMap.put("net_amt" + cnt, utilMethods.getReqDecString(netAmtDet,2));
tempMap.put("disc_amt" + cnt, utilMethods.getReqDecString(discAmtDet,2));
tempMap.put("installment_amt" + cnt, instAmtDet); tempMap.put("installment_amt" + cnt, instAmtDet);
tempMap.put("acc_code" + cnt, accDet); tempMap.put("acc_code" + cnt, accDet);
...@@ -871,24 +904,6 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -871,24 +904,6 @@ public class GenInvoiceSchedule implements Schedule {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
/*if(taxEffects.equalsIgnoreCase("+"))
{
taxEffects="Chargeable Tax";
}
if(taxEffects.equalsIgnoreCase("-"))
{
taxEffects="Not Liable For Tax";
}
if(taxEffects.equalsIgnoreCase("N"))
{
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(); currCodeHd = currCodeHd == null ? " " : currCodeHd.trim();
invoiceISOCode = invoiceISOCode == null ? " " : invoiceISOCode.trim(); invoiceISOCode = invoiceISOCode == null ? " " : invoiceISOCode.trim();
paymentMeans = paymentMeans == null ? " " : paymentMeans.trim(); paymentMeans = paymentMeans == null ? " " : paymentMeans.trim();
...@@ -915,15 +930,14 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -915,15 +930,14 @@ public class GenInvoiceSchedule implements Schedule {
System.out.println("***************InvoiceHeader***********************");
Element invoiceParent = doc.createElement("Invoices"); Element invoiceParent = doc.createElement("Invoices");
Element invoice = doc.createElement("Invoice"); Element invoice = doc.createElement("Invoice");
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, "InvoiceDocumentType","FC" ));
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceDocumentType",docStatus )); invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceClass", "OO"));
invoiceHeader.appendChild(getElementValue(doc, invoiceParent, "InvoiceClass", ""));
invoice.appendChild(invoiceHeader); invoice.appendChild(invoiceHeader);
Element invoiceIssueData = doc.createElement("InvoiceIssueData"); Element invoiceIssueData = doc.createElement("InvoiceIssueData");
...@@ -933,26 +947,30 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -933,26 +947,30 @@ public class GenInvoiceSchedule implements Schedule {
invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "EndDate",sdf.format(invoiceDtHd))); invoicingPeriod.appendChild(getElementValue(doc, invoiceParent, "EndDate",sdf.format(invoiceDtHd)));
invoiceIssueData.appendChild(invoicingPeriod); invoiceIssueData.appendChild(invoicingPeriod);
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "InvoiceCurrencyCode", invoiceISOCode)); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "InvoiceCurrencyCode", invoiceISOCode));
//invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "InvoiceCurrencyCode", "EUR"));
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "TaxCurrencyCode", "EUR")); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "TaxCurrencyCode", "EUR"));
invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "LanguageName", "es")); invoiceIssueData.appendChild(getElementValue(doc, invoiceParent, "LanguageName", "es"));
invoice.appendChild(invoiceIssueData); invoice.appendChild(invoiceIssueData);
System.out.println("***************TaxesOutputs***********************");
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", "01")); tax.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "01"));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxRate", String.valueOf(taxPersc))); System.out.println("test 000");
//tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", taxBaseAmt)); tax.appendChild(getElementValue(doc, invoiceParent, "TaxRate", utilMethods.getReqDecString(taxPersc,2)));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", String.valueOf(taxBaseAmt))); tax.appendChild(getElementValue(doc, invoiceParent, "TaxableBase",utilMethods.getReqDecString(taxBaseAmt,2)));
tax.appendChild(getElementValue(doc, invoiceParent, "TaxAmount",String.valueOf(taxAmt))); tax.appendChild(getElementValue(doc, invoiceParent, "TaxAmount",utilMethods.getReqDecString(taxAmt,2)));
tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", "")); //tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurcharge", ""));
tax.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", "0.00"));
Element equivalenceSurcharge = doc.createElement("EquivalenceSurcharge");
equivalenceSurcharge.appendChild(getElementValue(doc, invoiceParent, "EquivalenceSurchargeAmount", "0.00"));
tax.appendChild(equivalenceSurcharge);
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","00" )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode","01" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxRate","0.00" )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxRate","0.00" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", "0.00" )); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", "0.00" ));
taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxAmount","0.00")); taxHeld.appendChild(getElementValue(doc, invoiceParent, "TaxAmount","0.00"));
...@@ -960,31 +978,24 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -960,31 +978,24 @@ public class GenInvoiceSchedule implements Schedule {
invoice.appendChild(taxesWithheld); invoice.appendChild(taxesWithheld);
Element invoiceTotals = doc.createElement("InvoiceTotals"); Element invoiceTotals = doc.createElement("InvoiceTotals");
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmount", String.valueOf(NetAmtHd))); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmount",utilMethods.getReqDecString(NetAmtHd,2)));
Element generalDiscounts = doc.createElement("GeneralDiscounts"); Element generalDiscounts = doc.createElement("GeneralDiscounts");
Element discount = doc.createElement("Discount"); Element discount = doc.createElement("Discount");
if(String.valueOf(discAmtHd).equalsIgnoreCase("0.0"))
{
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", ""));
}
else
{
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions")); discount.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions"));
}
discount.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", "")); discount.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", utilMethods.getReqDecString(discAmtHd,2)));
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", String.valueOf(discAmtHd))); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralDiscounts", utilMethods.getReqDecString(discAmtHd,2)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralSurcharges", "0.00")); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGeneralSurcharges", "0.00"));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmountBeforeTaxes", String.valueOf(NetAmtHd))); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalGrossAmountBeforeTaxes", utilMethods.getReqDecString(NetAmtHd,2)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxOutputs", String.valueOf(taxAmtHd) )); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxOutputs",utilMethods.getReqDecString(taxAmtHd,2)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxesWithheld","0.00" )); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalTaxesWithheld","0.00" ));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalOutstandingAmount", String.valueOf(NetAmtHd))); invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalOutstandingAmount",utilMethods.getReqDecString(NetAmtHd,2)));
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalExecutableAmount", String.valueOf(NetAmtHd)));
invoice.appendChild(invoiceTotals);
invoiceTotals.appendChild(getElementValue(doc, invoiceParent, "TotalExecutableAmount",utilMethods.getReqDecString(NetAmtHd,2)));
invoice.appendChild(invoiceTotals);
System.out.println("cnt !!!!!! "+cnt);
for(int i = 1; i<= cnt ; i++) for(int i = 1; i<= cnt ; i++)
{ {
...@@ -996,32 +1007,32 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -996,32 +1007,32 @@ public class GenInvoiceSchedule implements Schedule {
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, "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");
if(tempMap.get("disc_amt" + cnt).equalsIgnoreCase("0.0"))
{
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", ""));
}
else
{
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions")); discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountReason", "Sales Promotions"));
}
if(!(tempMap.get("disc_amt" + cnt).equalsIgnoreCase("0.0")))
{
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", (String) tempMap.get("discount" + cnt))); discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountRate", (String) tempMap.get("discount" + cnt)));
}
discountItem.appendChild(getElementValue(doc, invoiceParent, "DiscountAmount", (String) tempMap.get("disc_amt" + 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", "0.00")); charge.appendChild(getElementValue(doc, invoiceParent, "ChargeRate", "0.00"));
charge.appendChild(getElementValue(doc, invoiceParent, "ChargeAmount", "0.00")); 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)));
...@@ -1029,9 +1040,11 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -1029,9 +1040,11 @@ 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", "00")); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "01"));
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", "0.00")); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", "0.00"));
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase","0.00")); Element taxableTotAmt = doc.createElement("TotalAmount");
taxableTotAmt.appendChild(getElementValue(doc, invoiceParent, "TaxableBase","0.00"));
taxableTotAmt.appendChild(taxesWithheldItem);
taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", "0.00")); taxHeldItem.appendChild(getElementValue(doc, invoiceParent, "TaxAmount", "0.00"));
taxesWithheldItem.appendChild(taxHeldItem); taxesWithheldItem.appendChild(taxHeldItem);
invoiceLine.appendChild(taxesWithheldItem); invoiceLine.appendChild(taxesWithheldItem);
...@@ -1042,20 +1055,17 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -1042,20 +1055,17 @@ 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", "01")); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxTypeCode", "01"));
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate", String.valueOf(taxPersc))); taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxRate",utilMethods.getReqDecString(taxPersc,2)));
taxItem.appendChild(getElementValue(doc, invoiceParent, "TaxableBase", String.valueOf(taxBaseAmt))); Element taxableTotAmtOutputs = doc.createElement("TotalAmount");
taxableTotAmtOutputs.appendChild(getElementValue(doc, invoiceParent, "TaxableBase",utilMethods.getReqDecString(taxBaseAmt,2)));
taxItem.appendChild(taxableTotAmtOutputs);
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, "EquivalenceSurchargeAmount", "0.00"));
taxesOutputsItem.appendChild(taxItem); taxesOutputsItem.appendChild(taxItem);
invoiceLine.appendChild(taxesOutputsItem); invoiceLine.appendChild(taxesOutputsItem);
//invoiceLine.appendChild(getElementValue(doc, invoiceParent, "AdditionalLineItemInformation", " ")); //invoiceLine.appendChild(getElementValue(doc, invoiceParent, "AdditionalLineItemInformation", " "));
...@@ -1068,7 +1078,7 @@ public class GenInvoiceSchedule implements Schedule { ...@@ -1068,7 +1078,7 @@ public class GenInvoiceSchedule implements Schedule {
Element installment = doc.createElement("Installment"); Element installment = doc.createElement("Installment");
installment.appendChild(getElementValue(doc, invoiceParent, "InstallmentDueDate", sdf.format(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", paymentMeans)); installment.appendChild(getElementValue(doc, invoiceParent, "PaymentMeans", "04"));
Element accountToBeCredited = doc.createElement("AccountToBeCredited"); Element accountToBeCredited = doc.createElement("AccountToBeCredited");
accountToBeCredited.appendChild(getElementValue(doc, invoiceParent, "IBAN",accToBeCredited)); accountToBeCredited.appendChild(getElementValue(doc, invoiceParent, "IBAN",accToBeCredited));
......
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