use of org.compiere.model.MDepreciationExp in project adempiere by adempiere.
the class A_Depreciation_Exp_Check method fixDepreciation.
private void fixDepreciation(int A_Asset_ID) {
MAsset asset = MAsset.get(getCtx(), A_Asset_ID, get_TrxName());
List<MDepreciationExp> depreciations = getDepreciation(asset);
// if exist depreciations with period 0
if (depreciations.get(0).getA_Period() == 0) {
fixDepreciationExp(depreciations.get(0), TimeUtil.getMonthLastDay(asset.getAssetServiceDate()));
Timestamp tms = depreciations.get(0).getDateAcct();
for (int i = 1; i < depreciations.size(); i++) {
fixDepreciationExp(depreciations.get(i), TimeUtil.getMonthLastDay(TimeUtil.addMonths(tms, 1)));
tms = depreciations.get(i).getDateAcct();
}
} else {
fixDepreciationExp(depreciations.get(0), TimeUtil.getMonthLastDay(TimeUtil.addMonths(asset.getAssetServiceDate(), 1)));
Timestamp tms = depreciations.get(0).getDateAcct();
for (int i = 1; i < depreciations.size(); i++) {
fixDepreciationExp(depreciations.get(i), TimeUtil.getMonthLastDay(TimeUtil.addMonths(tms, 1)));
tms = depreciations.get(i).getDateAcct();
}
}
//
for (MDepreciationWorkfile wk : MDepreciationWorkfile.forA_Asset_ID(getCtx(), A_Asset_ID, get_TrxName())) {
wk.setA_Current_Period();
wk.saveEx();
addLog("" + wk + ": Period=" + wk.getA_Current_Period() + ", DateAcct=" + wk.getDateAcct());
}
}
use of org.compiere.model.MDepreciationExp in project adempiere by adempiere.
the class A_Depreciation_Exp_Process method doIt.
protected String doIt() throws Exception {
MDepreciationExp depexp = new MDepreciationExp(getCtx(), getRecord_ID(), get_TrxName());
depexp.process();
return "@Processed@";
}
use of org.compiere.model.MDepreciationExp in project adempiere by adempiere.
the class Doc_DepreciationEntry method createFacts.
// getBalance
public ArrayList<Fact> createFacts(MAcctSchema as) {
ArrayList<Fact> facts = new ArrayList<Fact>();
// Other Acct Schema
if (as.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
return facts;
// create Fact Header
Fact fact = new Fact(this, as, m_PostingType);
MDepreciationEntry entry = (MDepreciationEntry) getPO();
Iterator<MDepreciationExp> it = entry.getLinesIterator(false);
while (it.hasNext()) {
MDepreciationExp depexp = it.next();
DocLine line = createLine(depexp);
BigDecimal expenseAmt = depexp.getExpense();
//
MAccount dr_acct = MAccount.get(getCtx(), depexp.getDR_Account_ID());
MAccount cr_acct = MAccount.get(getCtx(), depexp.getCR_Account_ID());
FactUtil.createSimpleOperation(fact, line, dr_acct, cr_acct, as.getC_Currency_ID(), expenseAmt, false);
}
//
facts.add(fact);
return facts;
}
use of org.compiere.model.MDepreciationExp in project adempiere by adempiere.
the class A_Depreciation_Exp_Modify method doIt.
protected String doIt() throws Exception {
//
if (p_A_Depreciation_Exp_ID <= 0) {
throw new FillMandatoryException("A_Depreciation_Exp_ID");
}
//
MDepreciationExp exp = new MDepreciationExp(getCtx(), p_A_Depreciation_Exp_ID, get_TrxName());
if (exp.get_ID() != p_A_Depreciation_Exp_ID) {
throw new AdempiereException("@NotFound@ @A_Depreciation_Exp_ID@ = " + p_A_Depreciation_Exp_ID);
}
//
MDepreciationEntry.deleteFacts(exp);
exp.setDR_Account_ID(p_DR_Account_ID);
exp.setCR_Account_ID(p_CR_Account_ID);
exp.saveEx();
//
if (p_IsTest) {
rollback();
}
//
return "Ok";
}
Aggregations