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 printTotals() { if (ticket.getLinesCount() > 0) { m_jSubtotalEuros.setText(Formats.CURRENCY.formatValue(new Double(ticket.getSubTotal()))); m_jTaxesEuros.setText(Formats.CURRENCY.formatValue(new Double(ticket.getTax()))); m_jTotalEuros.setText(Formats.CURRENCY.formatValue(new Double(ticket.getTotal()))); } else { m_jSubtotalEuros.setText(null); m_jTaxesEuros.setText(null); m_jTotalEuros.setText(null); } }
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