private ProductInfoExt init(DataLogicSales dlSales, int productsType) { initComponents(); jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); // ProductFilter jproductfilter = new ProductFilter(app); ProductFilterSales jproductfilter = new ProductFilterSales(dlSales, this, m_jKeys); jproductfilter.activate(); m_jProductSelect.add(jproductfilter, BorderLayout.CENTER); switch (productsType) { case PRODUCT_NORMAL: lpr = new ListProviderCreator(dlSales.getProductListNormal(), jproductfilter); break; case PRODUCT_AUXILIAR: lpr = new ListProviderCreator(dlSales.getProductListAuxiliar(), jproductfilter); break; default: // PRODUCT_ALL lpr = new ListProviderCreator(dlSales.getProductList(), jproductfilter); break; } jListProducts.setCellRenderer(new ProductRenderer()); getRootPane().setDefaultButton(jcmdOK); m_ReturnProduct = null; // show(); setVisible(true); return m_ReturnProduct; }
public void checkout(TicketInfo ticket, String place) throws BasicException { appView = AppViewImpl.getInstance(); DataLogicSales dlSales = appView.getBean(DataLogicSales.class); try { // reset the payment info TaxesLogic taxesLogic = new TaxesLogic(dlSales.getTaxList().list()); taxesLogic.calculateTaxes(ticket); if (ticket.getTotal() >= 0.0) { ticket.resetPayments(); // Only reset if is sale } // assign the payments selected and calculate taxes. List<PaymentInfo> payments = new ArrayList<PaymentInfo>(); payments.add(new PaymentInfoCash(ticket.getTotal(), ticket.getTotalPaid())); ticket.setPayments(payments); // Asigno los valores definitivos del ticket... ticket.setUser(appView.getAppUserView().getUser().getUserInfo()); // El usuario que lo cobra ticket.setActiveCash(appView.getActiveCashIndex()); ticket.setDate(new Date()); // Le pongo la fecha de cobro // Save the receipt and assign a receipt number try { dlSales.saveTicket(ticket, appView.getInventoryLocation()); } catch (BasicException eData) { eData.printStackTrace(); } } catch (TaxesException e) { e.printStackTrace(); } }
private void readTicket(int iTicketid, int iTickettype) { Integer findTicket = 0; try { findTicket = m_jTicketEditor.getValueInteger(); } catch (BasicException e) { } try { TicketInfo ticket = (iTicketid == -1) ? m_dlSales.loadTicket(iTickettype, findTicket) : m_dlSales.loadTicket(iTickettype, iTicketid); if (ticket == null) { // MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, // AppLocal.getIntString("message.notexiststicket")); // msg.show(this); JFrame frame = new JFrame(); JOptionPane.showMessageDialog( frame, AppLocal.getIntString("message.notexiststicket"), AppLocal.getIntString("message.notexiststickettitle"), JOptionPane.WARNING_MESSAGE); } else { m_ticket = ticket; m_ticketCopy = null; // se asigna al pulsar el boton de editar o devolver try { taxeslogic.calculateTaxes(m_ticket); TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); // taxcollection = new ListKeyed<TaxInfo>(taxlist); } catch (TaxesException ex) { } printTicket(); } } catch (BasicException e) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e); msg.show(this); } m_jTicketEditor.reset(); m_jTicketEditor.activate(); }
private void editCustomer(CustomerInfoExt customer) { customerext = customer; txtTaxId.setText(customer.getTaxid()); txtName.setText(customer.getName()); txtCard.setText(customer.getCard()); txtNotes.reset(); txtNotes.setText(customer.getNotes()); txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer.getMaxdebt())); txtCurdebt.setText(Formats.CURRENCY.formatValue(customer.getCurdebt())); txtCurdate.setText(Formats.DATE.formatValue(customer.getCurdate())); txtNotes.setEnabled(true); dirty.setDirty(false); btnSave.setEnabled(true); // btnPay.setEnabled(customer.getCurdebt() != null && customer.getCurdebt().doubleValue() > // 0.0); // MSL : get active not paid tickets m_sentticket = dlsales.getTicketsListCustomer(customer.getId(), 9); try { // m_TicketModel = new ComboBoxValModel(m_sentticket.list()); btnPay.setEnabled(m_sentticket.list().isEmpty() == false); jList1.setModel(new MyListData(m_sentticket.list())); } catch (BasicException e) { } }
private void btnCustomerActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnCustomerActionPerformed JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlcustomers); finder.search(null); finder.setVisible(true); CustomerInfo customer = finder.getSelectedCustomer(); if (customer != null) { try { CustomerInfoExt c = dlsales.loadCustomerExt(customer.getId()); if (c == null) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); msg.show(this); } else { editCustomer(c); } } catch (BasicException ex) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); msg.show(this); } } editorcard.reset(); editorcard.activate(); } // GEN-LAST:event_btnCustomerActionPerformed
/** * Creates new form JTicketsBagTicket * * @param app * @param panelticket */ public JTicketsBagTicket(AppView app, JPanelTicketEdits panelticket) { super(app, panelticket); m_panelticketedit = panelticket; m_dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem"); m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales"); dlCustomers = (DataLogicCustomers) m_App.getBean("com.openbravo.pos.customers.DataLogicCustomers"); // Inicializo la impresora... // JG July 2014 - Thank you Ron Isaacson m_TP = new DeviceTicket(); m_TP = new DeviceTicket(app.getProperties()); // Inicializo el parser de documentos de ticket m_TTP = new TicketParser(m_TP, m_dlSystem); // para visualizar el ticket m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); // para imprimir el ticket initComponents(); m_TicketsBagTicketBag = new JTicketsBagTicketBag(this); m_jTicketEditor.addEditorKeys(m_jKeys); // Este deviceticket solo tiene una impresora, la de pantalla m_jPanelTicket.add(m_TP.getDevicePrinter("1").getPrinterComponent(), BorderLayout.CENTER); try { taxeslogic = new TaxesLogic(m_dlSales.getTaxList().list()); } catch (BasicException ex) { } }
/** @throws BasicException */ @Override public void loadCatalog() throws BasicException { m_jProducts.removeAll(); m_productsset.clear(); m_categoriesset.clear(); // Load the taxes logic taxeslogic = new TaxesLogic(m_dlSales.getTaxList().list()); buildProductPanel(); }
@Override protected void init() { m_dlSales = (DataLogicSales) app.getBean(DataLogicSales.class.getName()); jproductfilter = new ProductFilter(); jproductfilter.init(app); row = m_dlSales.getProductsRow(); lpr = new ListProviderCreator(m_dlSales.getProductCatQBF(), jproductfilter); spr = new SaveProvider( m_dlSales.getProductCatUpdate(), m_dlSales.getProductCatInsert(), m_dlSales.getProductCatDelete()); // el panel del editor jeditor = new ProductsEditor(app, m_dlSales, dirty); }
/** Creates new form PlacesEditor */ public PlacesEditor(DataLogicSales dlSales, DirtyManager dirty) { initComponents(); m_sentfloor = dlSales.getFloorsList(); m_FloorModel = new ComboBoxValModel(); m_jName.getDocument().addDocumentListener(dirty); m_jFloor.addActionListener(dirty); m_jX.getDocument().addDocumentListener(dirty); m_jY.getDocument().addDocumentListener(dirty); writeValueEOF(); }
private void showProductPanel(String id) { ProductInfoExt product = m_productsset.get(id); if (product == null) { if (m_productsset.containsKey(id)) { } else { try { java.util.List<ProductInfoExt> products = m_dlSales.getProductComments(id); if (products.isEmpty()) { m_productsset.put(id, null); } else { product = m_dlSales.getProductInfo(id); m_productsset.put(id, product); JCatalogTab jcurrTab = new JCatalogTab(); jcurrTab.applyComponentOrientation(getComponentOrientation()); m_jProducts.add(jcurrTab, "PRODUCT." + id); // Add products for (ProductInfoExt prod : products) { jcurrTab.addButton( new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), getProductLabel(prod))), new SelectedAction(prod), prod.getTextTip(), ""); } CardLayout cl = (CardLayout) (m_jProducts.getLayout()); cl.show(m_jProducts, "PRODUCT." + id); } } catch (BasicException eb) { m_productsset.put(id, null); } } } else { CardLayout cl = (CardLayout) (m_jProducts.getLayout()); cl.show(m_jProducts, "PRODUCT." + id); } }
private void buildProductPanel() { try { JCatalogTab jcurrTab = new JCatalogTab(); m_jProducts.add(jcurrTab, ""); java.util.List<ProductInfoExt> prods = m_dlSales.getAllProductCatalog(); for (ProductInfoExt prod : prods) { newColour = m_dlSales.getCategoryColour(prod.getCategoryID()); String sColour = (String) newColour; if (sColour == null) { sColour = ""; } jcurrTab.addButton( new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), getProductLabel(prod))), new SelectedAction(prod), prod.getTextTip(), sColour); } } catch (BasicException e) { JMessageDialog.showMessage( this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e)); } }
private void assignProductByReference() { try { ProductInfoExt oProduct = m_dlSales.getProductInfoByReference(m_jreference.getText()); if (oProduct == null) { assignProduct(null); Toolkit.getDefaultToolkit().beep(); } else { // Se anade directamente una unidad con el precio y todo assignProduct(oProduct); } } catch (BasicException eData) { assignProduct(null); MessageInf msg = new MessageInf(eData); msg.show(this); } }
@Override public void deleteTicket() { if (m_ticketCopy != null) { // Para editar borramos el ticket anterior try { m_dlSales.deleteTicket(m_ticketCopy, m_App.getInventoryLocation()); } catch (BasicException eData) { MessageInf msg = new MessageInf( MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); msg.show(this); } } m_ticket = null; m_ticketCopy = null; resetToTicket(); }
/** Creates new form StockDiaryEditor */ public StockDiaryEditor(AppView app, DirtyManager dirty) { m_App = app; m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales"); // MSL m_dlSuppliers = (DataLogicSuppliers) m_App.getBean("com.openbravo.pos.suppliers.DataLogicSuppliers"); initComponents(); m_cat = new JCatalog(m_dlSales, true); m_cat.getComponent().setPreferredSize(new Dimension(0, 245)); m_cat.addActionListener(new CatalogListener()); add(m_cat.getComponent(), BorderLayout.SOUTH); // El modelo de locales m_sentlocations = m_dlSales.getLocationsList(); m_LocationsModel = new ComboBoxValModel(); m_ReasonModel = new ComboBoxValModel(); m_ReasonModel.add(MovementReason.IN_PURCHASE); m_ReasonModel.add(MovementReason.IN_REFUND); m_ReasonModel.add(MovementReason.IN_MOVEMENT); m_ReasonModel.add(MovementReason.OUT_SALE); m_ReasonModel.add(MovementReason.OUT_REFUND); m_ReasonModel.add(MovementReason.OUT_BREAK); m_ReasonModel.add(MovementReason.OUT_MOVEMENT); m_jreason.setModel(m_ReasonModel); m_jdate.getDocument().addDocumentListener(dirty); m_jreason.addActionListener(dirty); m_jLocation.addActionListener(dirty); jproduct.getDocument().addDocumentListener(dirty); jattributes.getDocument().addDocumentListener(dirty); m_junits.getDocument().addDocumentListener(dirty); m_jprice.getDocument().addDocumentListener(dirty); writeValueEOF(); }
private void printTicket() { // imprimo m_ticket try { m_jEdit.setEnabled( m_ticket != null && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL || m_ticket.getTicketType() == TicketInfo.RECEIPT_REFUND) && m_dlSales.isCashActive(m_ticket.getActiveCash())); } catch (BasicException e) { m_jEdit.setEnabled(false); } m_jRefund.setEnabled(m_ticket != null && m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL); m_jPrint.setEnabled(m_ticket != null); // Este deviceticket solo tiene una impresora, la de pantalla m_TP.getDevicePrinter("1").reset(); if (m_ticket == null) { m_jTicketId.setText(null); } else { m_jTicketId.setText(m_ticket.getName()); try { ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); script.put("ticket", m_ticket); script.put("taxes", m_ticket.getTaxLines()); m_TTP.printTicket( script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); } catch (ScriptException | TicketPrinterException e) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); msg.show(this); } } }
private void readCustomer() { try { CustomerInfoExt customer = dlsales.findCustomerExt(editorcard.getText()); if (customer == null) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); msg.show(this); } else { editCustomer(customer); } } catch (BasicException ex) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); msg.show(this); } editorcard.reset(); editorcard.activate(); }
/** * Creates new form StockDiaryEditor * * @param app * @param dirty * @throws com.openbravo.basic.BasicException */ public StockDiaryEditor(AppView app, DirtyManager dirty) throws BasicException { m_App = app; m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales"); initComponents(); // El modelo de locales m_sentlocations = m_dlSales.getLocationsList(); m_LocationsModel = new ComboBoxValModel(); m_ReasonModel = new ComboBoxValModel(); m_ReasonModel.add(MovementReason.IN_PURCHASE); m_ReasonModel.add(MovementReason.IN_REFUND); m_ReasonModel.add(MovementReason.IN_MOVEMENT); m_ReasonModel.add(MovementReason.OUT_SALE); m_ReasonModel.add(MovementReason.OUT_REFUND); m_ReasonModel.add(MovementReason.OUT_BREAK); m_ReasonModel.add(MovementReason.OUT_MOVEMENT); m_jreason.setModel(m_ReasonModel); m_cat = new JCatalog(m_dlSales); m_cat.addActionListener(new CatalogListener()); catcontainer.add(m_cat.getComponent(), BorderLayout.CENTER); m_jdate.getDocument().addDocumentListener(dirty); m_jreason.addActionListener(dirty); m_jLocation.addActionListener(dirty); jproduct.getDocument().addDocumentListener(dirty); jattributes.getDocument().addDocumentListener(dirty); m_junits.getDocument().addDocumentListener(dirty); m_jprice.getDocument().addDocumentListener(dirty); writeValueEOF(); }
private void btnPayActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnPayActionPerformed paymentdialog.setPrintSelected(true); // MSL : get total of selected tickets double tt = 0; for (Object tl : jList1.getSelectedValues()) { FindTicketsInfoCustomer sTicket = (FindTicketsInfoCustomer) tl; TicketInfo t = new TicketInfo(); try { t = dlsales.loadTicket(0, sTicket.getTicketId()); tt = tt + t.getTotal(); // - t.getTotalPaid(); } catch (BasicException e) { } } // ------------- // if (paymentdialog.showDialog(customerext.getCurdebt(), null)) { if (paymentdialog.showDialog(tt, null)) { // Save the ticket /*TicketInfo ticket = new TicketInfo(); ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); List<PaymentInfo> payments = paymentdialog.getSelectedPayments(); double total = 0.0; for (PaymentInfo p : payments) { total += p.getTotal(); } payments.add(new PaymentInfoTicket(-total, "debtpaid")); ticket.setPayments(payments); ticket.setUser(app.getAppUserView().getUser().getUserInfo()); ticket.setActiveCash(app.getActiveCashIndex()); ticket.setDate(new Date()); ticket.setCustomer(customerext); try { dlsales.saveTicket(ticket, app.getInventoryLocation()); } catch (BasicException eData) { MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); msg.show(this); } * */ // Save the ticket TicketInfo ticket = new TicketInfo(); ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); List<PaymentInfo> payments = paymentdialog.getSelectedPayments(); double total = 0.0; for (PaymentInfo p : payments) { total += p.getTotal(); } double reste = total; for (Object tl : jList1.getSelectedValues()) { FindTicketsInfoCustomer sTicket = (FindTicketsInfoCustomer) tl; TicketInfo t = new TicketInfo(); if (reste > 0) { try { t = dlsales.loadTicket(0, sTicket.getTicketId()); payments.add(new PaymentInfoTicket(-t.getTotal(), "debtpaid")); reste = total - t.getTotal(); ticket.setPayments(payments); ticket.setUser(app.getAppUserView().getUser().getUserInfo()); ticket.setActiveCash(app.getActiveCashIndex()); ticket.setDate(new Date()); ticket.setCustomer(customerext); dlsales.saveTicket(ticket, app.getInventoryLocation()); new StaticSentence( this.app.getSession(), "UPDATE TICKETS Set STATUS=9 WHERE ID = ?", SerializerWriteString.INSTANCE) .exec(t.getId()); // MSL : break the system : set the receipt with original one // TODO : split the amount paid to the ticket values /*new StaticSentence(this.app.getSession() , "UPDATE RECEIPTS Set ID=? WHERE ID = ?" , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})) .exec(new Object[] {t.getId(), ticket.getId()}); */ new StaticSentence( this.app.getSession(), "UPDATE PAYMENTS Set TICKETID=? WHERE RECEIPT = ?", new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})) .exec(new Object[] {t.getId(), ticket.getId()}); } catch (BasicException eData) { MessageInf msg = new MessageInf( MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); msg.show(this); } } } // MSL : no tickets selected if ((jList1.getSelectedValues() == null) || (reste > 0)) { payments.add(new PaymentInfoTicket(-reste, "debtpaid")); ticket.setPayments(payments); ticket.setUser(app.getAppUserView().getUser().getUserInfo()); ticket.setActiveCash(app.getActiveCashIndex()); ticket.setDate(new Date()); ticket.setCustomer(customerext); 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", ticket, c); } editorcard.reset(); editorcard.activate(); } // GEN-LAST:event_btnPayActionPerformed
public ListProvider getListProvider() { return new ListProviderCreator(m_dlSales.getCompositionQBF(), jcompositionfilter); }
public SaveProvider getSaveProvider() { return new SaveProvider( m_dlSales.getCompositionUpdate(), m_dlSales.getCompositionInsert(), m_dlSales.getCompositionDelete()); }
protected void init() { DataLogicSales dlSales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales"); ttaxcategories = dlSales.getTableTaxCategories(); jeditor = new TaxCustCategoriesEditor(dirty); }
public SaveProvider getSaveProvider() { return new SaveProvider(null, m_dlSales.getStockDiaryInsert(), m_dlSales.getStockDiaryDelete()); }