Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String getDocumentNo(DocumentType docType, String strTableName, boolean updateNext) {
- if (docType == null) {
- return "";
- }
- Sequence seq = docType.getDocumentSequence();
- if (seq == null && strTableName != null) {
- OBCriteria<Sequence> obcSeq = OBDal.getInstance().createCriteria(Sequence.class);
- obcSeq.add(Restrictions.eq(Sequence.PROPERTY_NAME, "DocumentNo_" + strTableName));
- if (obcSeq != null && obcSeq.list().size() > 0) {
- seq = obcSeq.list().get(0);
- }
- }
- if (seq == null) {
- return "";
- }
- String nextDocNumber = "";
- if (seq.getPrefix() != null) {
- nextDocNumber = seq.getPrefix();
- }
- nextDocNumber += seq.getNextAssignedNumber().toString();
- if (seq.getSuffix() != null) {
- nextDocNumber += seq.getSuffix();
- }
- if (updateNext) {
- seq.setNextAssignedNumber(seq.getNextAssignedNumber() + seq.getIncrementBy());
- try {
- OBContext.setAdminMode(false);
- OBDal.getInstance().save(seq);
- OBDal.getInstance().flush();
- } finally {
- OBContext.restorePreviousMode();
- }
- }
- return nextDocNumber;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement