Package com.openbravo.data.gui

Examples of com.openbravo.data.gui.MessageInf


            this.label.setText("Sync in progress ...\n\r"+this.name);
            this.frame.repaint();

            try {

                MessageInf m = pa.execute();

                this.ii = ImageLoader.getImage(SyncThread.class, "end.gif");
                this.imageLabel.setIcon(new ImageIcon(this.ii));

                if ( m.getSignalWord()==MessageInf.SGN_SUCCESS) {
                    this.label.setBackground(Color.green);
                } else {
                    this.label.setBackground(Color.red);
                }
                this.label.setText(m.getMessageMsg()+"\n\r"+m.getCause().toString());
                this.frame.repaint();

            } catch (BasicException ex) {
                this.ii = ImageLoader.getImage(SyncThread.class, "end.gif");
                this.imageLabel.setIcon(new ImageIcon(this.ii));
View Full Code Here


                try {
                   
                    m_dlSystem.execChangePassword(new Object[] {sNewPassword, m_appuser.getId()});
                    m_appuser.setPassword(sNewPassword);
                } catch (BasicException e) {
                    JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotchangepassword")));            
                }
            }
        }
View Full Code Here

                ticket.setPayments(dlintegration.getTicketPayments(ticket.getId()));
            }
           
            if (ticketlist.size() == 0) {
               
                return new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.zeroorders"));
            } else {

                // transformo tickets en ordenes
                Order[] orders = transformTickets(ticketlist);

                //uploads orders and return boolean as a result
                if(!externalsales.uploadOrders(orders))
                    throw new BasicException(AppLocal.getIntString("message.returnnull"));

                // actualizo los tickets como subidos
                dlintegration.execTicketUpdate();

                return new MessageInf(MessageInf.SGN_SUCCESS, AppLocal.getIntString("message.syncordersok"), AppLocal.getIntString("message.syncordersinfo", orders.length));
            }

        } catch (ServiceException e) {           
            throw new BasicException(AppLocal.getIntString("message.serviceexception"), e);
        } catch (RemoteException e){
View Full Code Here

            if (externalsales == null) {
                externalsales = new ExternalSalesHelper(dlsystem);
            }

            if (!externalsales.checkConnection()) {
                return new MessageInf(MessageInf.SGN_WARNING, "System offline ? ", "Error connecting to website ");
            }

            try {
                // CHECK POS ID
                externalsales.checkPosID();
            } catch (RemoteException re) {
                try {
                    externalsales.checkPosID();
                } catch (RemoteException re1) {
                    return new MessageInf(MessageInf.SGN_WARNING, "Error while checking pos id ", re.toString());
                }
            }

            // SYNC PRODUCTS
            if (WSInfo.isWsproductpre()) {
                System.gc();
                System.runFinalization();
                ProductsSync bean = new ProductsSync(dlsystem, dlintegration, dlsales, "0");
                bean.execute();
                System.gc();
                System.runFinalization();
            }

            // SYNC USERS
            if (WSInfo.isWsuserpre()) {
                System.gc();
                System.runFinalization();
                UsersSync usc = new UsersSync(dlsystem, dlintegration, dlsales, "0");
                usc.execute();
                System.gc();
                System.runFinalization();
            }

            dlintegration.syncOrdersBefore();

            // Obtenemos los tickets
            List<TicketInfo> ticketlist = dlintegration.getTicketsByHostname(TicketInfo.getHostname());

            if (ticketlist.size() == 0) {
                // return new MessageInf(MessageInf.SGN_SUCCESS, AppLocal.getIntString("message.syncordersok"), AppLocal.getIntString("message.zeroorders"));
            } else {
                for (TicketInfo ticket : ticketlist) {
                    ticket.setLines(dlintegration.getTicketLines(ticket.getId()));
                    ticket.setPayments(dlintegration.getTicketPayments(ticket.getId()));
                }
                HashMap<String, String> usersMap = new HashMap<String, String>();

                List<UserInfo> localUsers;
                User[] remoteUsers = externalsales.getUsers();
                localUsers = dlintegration.getUsers();
                for (UserInfo localUser : localUsers) {
                    for (User user : remoteUsers) {
                        if (user.getLogin().equals(localUser.getName())) {
                            usersMap.put(localUser.getId(), user.getId());
                            break;
                        }
                    }
                }
                HashMap<String, String> productsMap = new HashMap<String, String>();

                Produit[] remoteProducts = externalsales.getProductsCatalog();

                List<ProductInfoExt> localProducts = dlsales.getProductList().list();

                for (ProductInfoExt localProduct : localProducts) {
                    for (Produit produit : remoteProducts) {
                        if (produit.getProduct_sku().equals(localProduct.getCode())) {
                            productsMap.put(localProduct.getID(), produit.getId());
                            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++;

                        // Set status as orderID from the website (correlation)
                        externalsales.updateStatus(orderID, ticket.getDate(), ticket.getDateReturn());


                        if (totalpaid >= Math.round((ticket.getTotal() * 100))) {
                            //Payment made set as paid on website
                            externalsales.setPaid(orderID, ticket.getDate());
                        }
                        if (ticket.getTicketType() == TicketInfo.RECEIPT_REFUND) {
                            //The ticket is a refund, Add return date locally and update website status
                            dlintegration.execUpdateTicketsRefundPayment(String.valueOf(ticket.getTicketType()), String.valueOf(ticket.getStatus()));
                            externalsales.setRendu(orderID);
                        } else if (ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL) // Normal ticket > Update status to website orderId
                        {
                            dlintegration.execUpdateTicket(String.valueOf(ticket.getTicketId()), orderID);
                        }
                    }
                }
            }
            //PAYMENTS
            List<Integer> orderids = dlintegration.getTicketsPayments();

            if (orderids.size() > 0) {

                for (Integer oid : orderids) {
                    // List<Double> dd = dlintegration.getDebt(oid);

                    double dd = Math.round(dlintegration.getDebt(String.valueOf(oid)) * 100) / 100;
                    double dp = Math.round(dlintegration.getPaid(String.valueOf(oid)) * 100) / 100;

                    if ((dd + dp) <= 0.0) {
                        //for each ticket of paid type set paid on website
                        externalsales.setPaid(String.valueOf(oid), null);
                        // then update the date return to know it was updated on the website
                        dlintegration.execUpdateTicketsRefundPayment(String.valueOf(TicketInfo.RECEIPT_PAYMENT), String.valueOf(oid));
                        dlintegration.execUpdateTicketsRefundPayment(String.valueOf(TicketInfo.RECEIPT_REFUND), String.valueOf(oid));
                    }
                }
            }

            //RETURNS
            List<TicketInfo> ticketlistr = dlintegration.getTicketsReturned();

            if (ticketlistr.size() > 0) {

                for (TicketInfo ticket : ticketlistr) {
                    //each returned tickets are updated as returned on the website
                    if (ticket.getTicketType() == 0 && externalsales.setRendu(String.valueOf(ticket.getStatus()))) {
                        if (WSInfo.isWsdeletert()) {
                            dlsales.deleteTicket(ticket, "0");
                        }
                    } else {
                        if (WSInfo.isWsdeletert()) {
                            dlsales.deleteTicket(ticket, "0");
                        }
                    }
                }
            }

        } catch (ServiceException e) {
            throw new BasicException(AppLocal.getIntString("message.serviceexception"), e);
        } catch (RemoteException e) {
            throw new BasicException(AppLocal.getIntString("message.remoteexception"), e);
        } catch (MalformedURLException e) {
            throw new BasicException(AppLocal.getIntString("message.malformedurlexception"), e);
        }

// DELETE OLD RETURNED TICKETS
//        if (WSInfo.isWsdeletert()) {
//            try {
//
//                List<TicketInfo> ticketlist = dlintegration.getTicketsToDelete();
//
//                System.out.println("> "+ticketlist.size());
//
//                if (ticketlist.size() > 0) {
//
//                    for (TicketInfo ticket : ticketlist) {
//
//                        System.out.println("deleting "+ticket.getId()+" "+ticket.getDateRendu()+" "+ticket.getStatus());
//
//                        ticket.setLines(dlintegration.getTicketLines(ticket.getId()));
//                        ticket.setPayments(dlintegration.getTicketPayments(ticket.getId()));
//
//                        dlsales.deleteTicket(ticket, "0");
//
//                    }
//                }
//            } catch (BasicException be) {
//                  System.out.println("Error deleting !");
//                  be.printStackTrace();
//            }
//
//        }

        return new MessageInf(MessageInf.SGN_SUCCESS, AppLocal.getIntString("message.syncordersok"), AppLocal.getIntString("message.syncordersinfo", cpt));
    }
View Full Code Here

            ticket.setDateReturn(paymentdialog.getrDate());

            try {
                dlsales.saveTicket(ticket, app.getInventoryLocation());
            } catch (BasicException eData) {
                MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
                msg.show(this);
            }


            // reload customer
            CustomerInfoExt c;
            try {
                c = dlsales.loadCustomerExt(customerext.getId());
                if (c == null) {
                    MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"));
                    msg.show(this);
                } else {
                    editCustomer(c);
                }
            } catch (BasicException ex) {
                c = null;
                MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex);
                msg.show(this);
            }

            printTicket(paymentdialog.isPrintSelected()
                    ? "Printer.CustomerPaid"
                    : "Printer.CustomerPaid2",
View Full Code Here

            ticket.setDateReturn(paymentdialogCredit.getrDate());

            try {
                dlsales.saveTicket(ticket, app.getInventoryLocation());
            } catch (BasicException eData) {
                MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
                msg.show(this);
            }


            // reload customer
            CustomerInfoExt c;
            try {
                c = dlsales.loadCustomerExt(customerext.getId());
                if (c == null) {
                    MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"));
                    msg.show(this);
                } else {
                    editCustomer(c);
                }
            } catch (BasicException ex) {
                c = null;
                MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex);
                msg.show(this);
            }

            printTicket(paymentdialogCredit.isPrintSelected()
                    ? "Printer.CustomerPaid"
                    : "Printer.CustomerPaid2",
View Full Code Here

        List a;
       
        try {
            a = taxparentsent.list();
        } catch (BasicException eD) {
            MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotloadlists"), eD);
            msg.show(this);
            a = new ArrayList();
        }
       
        a.add(0, null); // The null item
        taxparentmodel = new ComboBoxValModel(a);
View Full Code Here

            try {
                ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL);
                script.put("payment", new ScriptPaymentCash(dlSystem));   
                script.eval(code);
            } catch (ScriptException e) {
                MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotexecute"), e);
                msg.show(this);
            }
        }
        m_paymentgateway = PaymentGatewayFac.getPaymentGateway(app.getProperties());
       
//        if (m_paymentgateway == null) {
View Full Code Here

        List a;
       
        try {
            a = m_sentcat.list();
        } catch (BasicException eD) {
            MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotloadlists"), eD);
            msg.show(this);
            a = new ArrayList();
        }
       
        a.add(0, null); // The null item
        m_CategoryModel = new ComboBoxValModel(a);
View Full Code Here

    private void m_jCatalogDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCatalogDeleteActionPerformed

        try {
            m_sentdel.exec(m_id);
        } catch (BasicException e) {
            JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e));
        }
       
    }//GEN-LAST:event_m_jCatalogDeleteActionPerformed
View Full Code Here

TOP

Related Classes of com.openbravo.data.gui.MessageInf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.