From df5dda63c7146e8657c265187a30e439c9bef031 Mon Sep 17 00:00:00 2001 From: hodianto Date: Fri, 28 Dec 2018 14:08:16 +0700 Subject: [PATCH] Add Close to Asset Addition --HG-- branch : EDII --- .../midsuit/model/MID_MAssetAddition.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MAssetAddition.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MAssetAddition.java index 4e8d240..604f20e 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MAssetAddition.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MAssetAddition.java @@ -7,7 +7,6 @@ import java.util.Properties; import org.adempiere.exceptions.AdempiereException; import org.compiere.model.MAsset; import org.compiere.model.MAssetAddition; -import org.compiere.model.MDepreciation; import org.compiere.model.MDepreciationExp; import org.compiere.model.MFactAcct; import org.compiere.model.MInvoiceLine; @@ -54,13 +53,38 @@ public class MID_MAssetAddition extends MAssetAddition implements DocOptions{ } else if (docStatus.equals(DocAction.STATUS_Invalid)) { options[index++] = DocAction.ACTION_Complete; options[index++] = DocAction.ACTION_Void; - } else if (docStatus.equals(DocAction.STATUS_Completed)) + } else if (docStatus.equals(DocAction.STATUS_Completed)) { options[index++] = DocAction.ACTION_Void; + options[index++] = DocAction.ACTION_Close; + } return index; } + @Override + public boolean closeIt() { + final String whereClause = MDepreciationExp.COLUMNNAME_A_Asset_ID+" =? AND "+MDepreciationExp.COLUMNNAME_PostingType+"=? AND A_Depreciation_Entry_ID IS NULL"; + List + list = new Query(getCtx(), MDepreciationExp.Table_Name, whereClause, get_TrxName()) + .setParameters(new Object[]{ getA_Asset_ID(), MDepreciationExp.POSTINGTYPE_Actual}) + .setOrderBy(MDepreciationExp.COLUMNNAME_DateAcct+" DESC, "+MDepreciationExp.COLUMNNAME_A_Depreciation_Exp_ID+" DESC") + .list(); + for (MDepreciationExp depexp: list) { + depexp.deleteEx(true); + } + + updateSourceDocument(true); + + if(getA_Asset_ID()>0) { + MAsset asset = new MAsset(getCtx(), getA_Asset_ID(), get_TrxName()); + asset.setIsActive(false); + asset.setA_Asset_Status(MAsset.A_ASSET_STATUS_Retired); + asset.saveEx(); + } + return super.closeIt(); + } + @Override public boolean voidIt() { if(!getDocStatus().equals(DocAction.STATUS_Completed))