IDEMPIERE-2312 Dcoument number can have 'null' in prefix or suffix / based on patch from Nicolas Micoud (nmicoud)

This commit is contained in:
Carlos Ruiz 2014-11-13 13:01:31 -05:00
parent 792eb8c368
commit 913b77387b
1 changed files with 14 additions and 5 deletions

View File

@ -41,6 +41,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.util.Util;
/** /**
* Sequence Model. * Sequence Model.
@ -519,15 +520,23 @@ public class MSequence extends X_AD_Sequence
// create DocumentNo // create DocumentNo
StringBuilder doc = new StringBuilder(); StringBuilder doc = new StringBuilder();
if (prefix != null && prefix.length() > 0) if (prefix != null && prefix.length() > 0) {
doc.append(Env.parseVariable(prefix, po, trxName, false)); String prefixValue = Env.parseVariable(prefix, po, trxName, false);
if (Util.isEmpty(prefixValue))
doc.append(prefixValue);
}
if (decimalPattern != null && decimalPattern.length() > 0) if (decimalPattern != null && decimalPattern.length() > 0)
doc.append(new DecimalFormat(decimalPattern).format(next)); doc.append(new DecimalFormat(decimalPattern).format(next));
else else
doc.append(next); doc.append(next);
if (suffix != null && suffix.length() > 0)
doc.append(Env.parseVariable(suffix, po, trxName, false)); if (suffix != null && suffix.length() > 0) {
String suffixValue = Env.parseVariable(suffix, po, trxName, false);
if (Util.isEmpty(suffixValue))
doc.append(suffixValue);
}
String documentNo = doc.toString(); String documentNo = doc.toString();
if (s_log.isLoggable(Level.FINER)) s_log.finer (documentNo + " (" + incrementNo + ")" if (s_log.isLoggable(Level.FINER)) s_log.finer (documentNo + " (" + incrementNo + ")"
+ " - Sequence=" + AD_Sequence_ID + " [" + trx + "]"); + " - Sequence=" + AD_Sequence_ID + " [" + trx + "]");