Search in sources :

Example 1 with AssetArrayException

use of org.compiere.FA.exceptions.AssetArrayException 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;
}
Also used : AssetArrayException(org.compiere.FA.exceptions.AssetArrayException) AssetException(org.compiere.FA.exceptions.AssetException) ArrayList(java.util.ArrayList) TrxRunnable(org.compiere.util.TrxRunnable) AdempiereException(org.adempiere.exceptions.AdempiereException) AssetArrayException(org.compiere.FA.exceptions.AssetArrayException) AssetException(org.compiere.FA.exceptions.AssetException)

Aggregations

ArrayList (java.util.ArrayList)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 AssetArrayException (org.compiere.FA.exceptions.AssetArrayException)1 AssetException (org.compiere.FA.exceptions.AssetException)1 TrxRunnable (org.compiere.util.TrxRunnable)1