parent
13b45f4bbd
commit
df5dda63c7
|
|
@ -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<MDepreciationExp>
|
||||
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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue