use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class MDepreciationEntry method completeIt.
// rejectIt
public String completeIt() {
// Re-Check
if (!m_justPrepared) {
String status = prepareIt();
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Implicit Approval
if (!isApproved()) {
approveIt();
}
final MPeriod period = MPeriod.get(getCtx(), getC_Period_ID());
final ArrayList<Exception> errors = new ArrayList<Exception>();
final Iterator<MDepreciationExp> it = getLinesIterator(true);
//
while (it.hasNext()) {
try {
Trx.run(get_TrxName(), new TrxRunnable() {
public void run(String trxName) {
MDepreciationExp depexp = it.next();
// Check if is in Period
if (!period.isInPeriod(depexp.getDateAcct())) {
throw new AssetException("The date is not within this Period" + " (" + depexp + ", Data=" + depexp.getDateAcct() + ", Period=" + period.getName() + // TODO: translate
")");
}
depexp.process();
}
});
} catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
errors.add(e);
}
}
//
if (errors.size() > 0) {
throw new AssetArrayException(errors);
}
// User Validation
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (valid != null) {
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
setProcessed(true);
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
}
Aggregations