NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public boolean addNewInvoice(String jsonData, int pk_invoice_id) {


System.out.println(jsonData);
trn_customer customerObj = new trn_customer();
trn_invoice_type invoiceTypeObj = new trn_invoice_type();
trn_posting_key postingKeyObj = new trn_posting_key();
ArrayList<trn_customer> list = new ArrayList<trn_customer>();
ArrayList<trn_invoice_type> list1 = new ArrayList<trn_invoice_type>();
ArrayList<trn_posting_key> list2 = new ArrayList<trn_posting_key>();

Transaction tx = null;
Session session=getSession();
try {
tx = session.beginTransaction();
HashMap<String,String> map = new Gson().fromJson(jsonData, new TypeToken<HashMap<String, String>>(){}.getType());
// map.get("due_date");

String hql="FROM trn_customer c WHERE c.customerName LIKE '"+map.get("fkCustomerId.customerName")+"'";
String hql2="FROM trn_invoice_type i WHERE i.invoiceType LIKE '"+map.get("fkInvoiceType.invoiceType")+"'";
String hql3="FROM trn_posting_key p WHERE p.description LIKE '"+map.get("fkPostingKey.description")+"'";

StringBuffer hql1 = new StringBuffer("FROM trn_customer c WHERE c.customerName LIKE '");


hql1.append(map.get("customerObj.customerName"));
hql1.append("'");

SimpleDateFormat format1=new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat format2=new SimpleDateFormat("dd-MM-yyyy");
Date createdDate = null,dueDate = null;
if(map.get("invoice_created_date")!="") {
createdDate=format1.parse(map.get("invoice_created_date"));

System.out.println(createdDate);
}
if(map.get("due_date")!="") {
dueDate=format1.parse(map.get("due_date"));
System.out.println(dueDate);
};

Query q = getSession().createQuery(hql.toString());
list = (ArrayList<trn_customer>)q.list();

customerObj=list.get(0);
System.out.println("customerObj:"+customerObj.getPk_customer_map_id());


Query q1 = getSession().createQuery(hql2.toString());
list1 = (ArrayList<trn_invoice_type>)q1.list();

invoiceTypeObj=list1.get(0);

System.out.println("invoiceTypeObj:"+invoiceTypeObj.getPk_invoice_type_map_id());


Query q2 = getSession().createQuery(hql3.toString());

list2 = (ArrayList<trn_posting_key>)q2.list();

postingKeyObj=list2.get(0);
System.out.println("postingKeyObj:"+postingKeyObj.getPk_posting_key_id());

trn_invoice invoiceObj = new trn_invoice();
String id = map.get("pk_invoice_id");

if(pk_invoice_id!=0)
{
invoiceObj = (trn_invoice)session.get(trn_invoice.class, pk_invoice_id); }


invoiceObj.setInvoice_number(map.get("invoice_number"));
invoiceObj.setCompany_code(map.get("company_code"));
invoiceObj.setFiscal_year(map.get("fiscal_year"));
invoiceObj.setItem_number(map.get("item_number"));
invoiceObj.setInvoice_total_amount(Double.parseDouble(map.get("invoice_total_amount")));
invoiceObj.setInvoice_due_amount(Double.parseDouble(map.get("invoice_due_amount")));
invoiceObj.setInvoice_created_date(createdDate);
invoiceObj.setDue_date(dueDate);
invoiceObj.setDiscount_1_percentage(Integer.parseInt(map.get("discount_1_percentage")));
invoiceObj.setDiscount_2_percentage(Integer.parseInt(map.get("discount_2_percentage")));
invoiceObj.setDiscount_3_percentage(Integer.parseInt(map.get("discount_3_percentage")));
invoiceObj.setDebit_credit_indicator(map.get("debit_credit_indicator"));
invoiceObj.setFkCustomerId(customerObj);
invoiceObj.setFkPostingKey(postingKeyObj);
invoiceObj.setFkInvoiceType(invoiceTypeObj);
invoiceObj.setCustomer_id(customerObj.getPk_customer_map_id());
invoiceObj.setInvoice_type(invoiceTypeObj.getPk_invoice_type_map_id());
invoiceObj.setPosting_key(postingKeyObj.getPk_posting_key_id());
invoiceObj.setIs_open(1);
invoiceObj.setAccount_id(75);

session.saveOrUpdate(invoiceObj);
tx.commit();


return true;
} catch (Exception e) {
System.out.println("e");
if (tx!=null) tx.rollback();
LOGGER.error("Error while saving entry : ",e);
}
finally{
session.close();
System.out.println("15");
}
return false;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.