POS - Add a note to cashin cashout
Code snippetName: POS - Add a note to cash in and cash out
|
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)
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;