break;
}
}
}
CreateOrderInput orders;
for (int i = 0; i < ticketlist.size(); i++) {
TicketInfo ticket = ticketlist.get(i);
String userID = usersMap.get(ticket.getCustomerId());
orders = new CreateOrderInput();
orders.setPayment_method_id(externalsales.getWsPayID());
orders.setPrice_including_tax(String.valueOf(ticket.getTotal()));
orders.setProduct_currency("EUR");
orders.setShipping_carrier_name("0");
orders.setShipping_method("0");
orders.setShipping_price("0");
orders.setShipping_rate_id("0");
orders.setShipping_rate_name("0");
orders.setUser_id(userID);
orders.setVendor_id(externalsales.getWsPosid());
Product[] products = new Product[ticket.getLines().size()];
for (int j = 0; j < ticket.getLines().size(); j++) {
TicketLineInfo line = ticket.getLines().get(j);
// String pDesc = line.getProductName();
String pDesc = "";
products[j] = new Product();
System.out.println("> " + line.getProductName());
try {
if (line.getProductID().equals("0")) {
pDesc = line.getProductName();
products[j].setProduct_id(productsMap.get(line.getProductID()));
products[j].setQuantity(String.valueOf(line.getMultiply() * line.getPriceTax() * 100));
//pDesc += " " + String.valueOf(line.getMultiply()) + " > " + line.getPriceTax();
} else {
products[j].setProduct_id(productsMap.get(line.getProductID()));
products[j].setQuantity(String.valueOf(line.getMultiply()));
}
} catch (NullPointerException npe) {
pDesc = line.getProductName();
products[j].setProduct_id(productsMap.get("0"));
products[j].setQuantity(String.valueOf(line.getMultiply() * line.getPriceTax() * 100));
}
if (line.getProductAttSetInstDesc() != null && !line.getProductAttSetInstDesc().equals("")) {
if (pDesc.equalsIgnoreCase("")) {
pDesc += ", ";
}
pDesc += line.getProductAttSetInstDesc();
}
products[j].setDescription(pDesc);
//System.out.println(products[j].getProduct_id()+" "+products[j].getDescription());
}
orders.setCoupon_code("0");
orders.setProducts(products);
Double totalpaid = 0.0;
for (int j = 0; j < ticket.getPayments().size(); j++) {
PaymentInfo payment = ticket.getPayments().get(j);
if (("magcard".equals(payment.getName()))
|| ("cheque".equals(payment.getName()))
|| ("cash".equals(payment.getName()))) {
totalpaid += payment.getTotal();
}
}
totalpaid = (Math.round(totalpaid * 100.0)) / 1.0;
String note = ("TicketID=" + ticket.printId() + ",TotalPaid=" + (totalpaid / 100) + ",Vendeur=" + ticket.printUser());
// + ".Date." + ticket.printDate() + ".DateRetour." + ticket.printDateReturn() + ".DateRendu." + ticket.printDateRendu());
orders.setCustomer_note(note);
String orderID = externalsales.uploadOrders(orders);
if (!orderID.equals("")) {
cpt++;