View source | Discuss this page | Page history | Printable version   

POS - Add a note to cashin cashout

Code snippet

Name: POS - Add a note to cash in and cash out
Version: POS 2.30
Author: Henri Azar



This functionality allows a user to enter a note when cashing in/out


This code is based on this forum thread.


1. Add a column NOTES in table PAYMENTS (varchar255, nulls allowed)


2. In DataLogicSales.java add
Datas.STRING
at the end of
paymenttabledatas = new Datas[] {...}

and modify the getPaymentMovementInsert() method:

 
        public final SentenceExec getPaymentMovementInsert() {
        return new SentenceExecTransaction(s) {
            public int execInTransaction(Object params) throws BasicException {
                new PreparedSentence(s
                    , "INSERT INTO RECEIPTS (ID, MONEY, DATENEW) VALUES (?, ?, ?)"
                    , new SerializerWriteBasicExt(paymenttabledatas, new int[] {0, 1, 2})).exec(params);
                
                return new PreparedSentence(s
                    // LINES MODIFIED
                    , "INSERT INTO PAYMENTS (ID, RECEIPT, PAYMENT, TOTAL, NOTES) VALUES (?, ?, ?, ?, ?)"
                    , new SerializerWriteBasicExt(paymenttabledatas, new int[] {3, 0, 4, 5, 6})).exec(params);
            }
        };
    }


3. In PaymentsEditor.java design view (com.openbravo.pos.panels) create a JTextField named JNotes.

4. Switch to source mode and add the following:

 
        private String m_sNotes;

5. In writeValueEOF() method

 
        m_sNotes = null;
        jNotes.setEnabled(false);

6. In writeValueInsert() method

 
        m_sNotes = null;
        jNotes.setEnabled(true);
        jNotes.setText(m_sNotes);

7. In writeValueDelete(Object value) method

 
        m_sNotes = (String) payment[6];
        jNotes.setEnabled(false);

8. In writeValueEdit(Object value) method

 
        m_sNotes = (String) payment[6];
        jNotes.setEnabled(false);

9. In createValue() method

 
        // line is modified
        Object[] payment = new Object[7];
        ...
        //add before "return payment;" line
        String snotes = "";
        m_sNotes = jNotes.getText();
        payment[6] = m_sNotes == null ? snotes : m_sNotes;

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

This page has been accessed 11,780 times. This page was last modified on 28 September 2009, at 12:14. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.