View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

POS - How to add values in receipt

How to add & retrieve the values from database and display in the receipt. 1. Insert into Database

  ALTER TABLE payments ADD COLUMN cardname character varying(20);
  ALTER TABLE payments ALTER COLUMN cardname SET STORAGE EXTENDED; 
  SentenceExec paymentinsert = new PreparedSentence(s
                   , "INSERT INTO PAYMENTS (ID, RECEIPT, PAYMENT, TOTAL, TRANSID, RETURNMSG, CARDNAME) VALUES (?, ?, ?, ?, ?, ?, ?)"
                   , SerializerWriteParams.INSTANCE);
               for (final PaymentInfo p : ticket.getPayments()) {
                   paymentinsert.exec(new DataParams() { public void writeValues() throws BasicException {
                       setString(1, UUID.randomUUID().toString());
                       setString(2, ticket.getId());
                       setString(3, p.getName());
                       setDouble(4, p.getTotal());
                       setString(5, ticket.getTransactionID());
                       setBytes(6, (byte[]) Formats.BYTEA.parseValue(ticket.getReturnMessage()));
                      setString(7, p.getCardName());
                   }});
  public abstract String getCardName();

Override this method in all the payments java files (PaymentInfoCash.java, PaymentInfoFree.java , PaymentInfoTicket.java)

   private String m_dCardName =null;
   private String m_dCardName =null;
   public String getCardName() {
       return m_dCardName;
   }

But In PaymentInfoMagcard.java

  protected String m_dCardName =null; 
  public String getCardName() {
       return getCardType(m_sCardNumber);
   }
   public String getCardType(String sCardNumber){
       c = "UNKNOWN";
       if (sCardNumber.startsWith("4")) {
           c = "VISA";
       } else if (sCardNumber.startsWith("6")) {
           c = "DISC";
       } else if (sCardNumber.startsWith("5")) {
           c = "MAST";
       } else if (sCardNumber.startsWith("34") || sCardNumber.startsWith("37")) {
           c = "AMEX";
       } else if (sCardNumber.startsWith("3528") || sCardNumber.startsWith("3589")) {
           c = "JCB";
       } else if (sCardNumber.startsWith("3")) {
           c = "DINE";
       }
       m_dCardName = c;
       return c;
   }

Using these activities we saved our card type in the database.

2.Retrieve from the database.

change this sentence

ticket.setLines(new PreparedSentence(s
               , "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.CUSTCATEGORY, T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " +
                 "FROM TICKETLINES L, TAXES T WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE"
               , SerializerWriteString.INSTANCE
               , new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId()));
           ticket.setPayments(new PreparedSentence(s
               , "SELECT PAYMENT, TOTAL, TRANSID FROM PAYMENTS WHERE RECEIPT = ?"
               , SerializerWriteString.INSTANCE
               , new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId()));


As a

ticket.setLines(new PreparedSentence(s
               , "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.CUSTCATEGORY, T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " +
                 "FROM TICKETLINES L, TAXES T WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE"
               , SerializerWriteString.INSTANCE
               , new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId()));
           ticket.setPayments(new PreparedSentence(s
               , "SELECT PAYMENT, TOTAL, TRANSID, CARDNAME FROM PAYMENTS WHERE RECEIPT = ?"
               , SerializerWriteString.INSTANCE
               , new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId()));


Add this ( m_dCardName = dr.getString(4);) line in the readValues(..) method.

public void readValues(DataRead dr) throws BasicException {
       m_sName = dr.getString(1);
       m_dTicket = dr.getDouble(2).doubleValue();
       m_transactionID = dr.getString(3);
       m_dCardName = dr.getString(4);
   }

3. Display in Receipt.

<line> <text>Card Type</text> </line> <line> <text>${paymentline.getCardName()}</text> </line>

Using this we can get card type in the receipt at any time.

Retrieved from "http://wiki.openbravo.com/wiki/POS_-_How_to_add_values_in_receipt"

This page has been accessed 12,522 times. This page was last modified on 31 August 2009, at 13:30. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.