use of org.compiere.model.MDepreciationWorkfile in project adempiere by adempiere.
the class A_Depreciation_Workfile_Build method doIt.
protected String doIt() throws Exception {
int cnt_all = 0;
if (A_Depreciation_Workfile_ID > 0) {
MDepreciationWorkfile wk = new MDepreciationWorkfile(getCtx(), A_Depreciation_Workfile_ID, get_TrxName());
wk.buildDepreciation();
wk.saveEx();
cnt_all = 1;
} else {
String whereClause = MDepreciationWorkfile.COLUMNNAME_IsDepreciated + "='Y'";
POResultSet<MDepreciationWorkfile> rs = new Query(getCtx(), MDepreciationWorkfile.Table_Name, whereClause, get_TrxName()).scroll();
try {
while (rs.hasNext()) {
MDepreciationWorkfile wk = rs.next();
wk.buildDepreciation();
wk.saveEx();
}
} finally {
DB.close(rs);
rs = null;
}
}
//
return "@Processed@ #" + cnt_all;
}
use of org.compiere.model.MDepreciationWorkfile 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.MDepreciationWorkfile in project adempiere by adempiere.
the class CalloutA_Asset_Reval method asset.
public String asset(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
if (isCalloutActive())
return "";
//
I_A_Asset_Reval model = GridTabWrapper.create(mTab, I_A_Asset_Reval.class);
if (model.getA_Asset_ID() <= 0) {
return "";
}
MDepreciationWorkfile amount = MDepreciationWorkfile.get(ctx, model.getA_Asset_ID(), model.getPostingType(), null);
if (amount == null) {
return "@NotFound@ @A_Asset_ID@";
}
//
model.setA_Asset_Cost(amount.getA_Asset_Cost());
model.setA_Asset_Cost_Change(amount.getA_Asset_Cost());
model.setA_Accumulated_Depr(amount.getA_Accumulated_Depr());
model.setA_Change_Acumulated_Depr(amount.getA_Accumulated_Depr());
return "";
}
use of org.compiere.model.MDepreciationWorkfile in project adempiere by adempiere.
the class Doc_AssetTransfer method createFacts.
/**
* Produce inregistrarea:
* <pre>
* 20.., 21..[A_Asset_New_Acct] = 23..[A_Asset_Acct]
* </pre>
*/
public ArrayList<Fact> createFacts(MAcctSchema as) {
MAssetTransfer assetTr = getAssetTransfer();
MDepreciationWorkfile wk = getAssetWorkfile();
//MDepreciationExp exp = getExpense();
ArrayList<Fact> facts = new ArrayList<Fact>();
Fact fact = new Fact(this, as, assetTr.getPostingType());
facts.add(fact);
// Change Asset Account
if (assetTr.getA_Asset_New_Acct() != assetTr.getA_Asset_Acct()) {
MAccount dr = MAccount.get(getCtx(), assetTr.getA_Asset_New_Acct());
MAccount cr = MAccount.get(getCtx(), assetTr.getA_Asset_Acct());
FactUtil.createSimpleOperation(fact, null, dr, cr, as.getC_Currency_ID(), wk.getA_Asset_Cost(), false);
}
// Change Asset Accum. Depr. Account
if (assetTr.getA_Accumdepreciation_New_Acct() != assetTr.getA_Accumdepreciation_Acct()) {
MAccount cr = MAccount.get(getCtx(), assetTr.getA_Accumdepreciation_New_Acct());
MAccount dr = MAccount.get(getCtx(), assetTr.getA_Accumdepreciation_Acct());
FactUtil.createSimpleOperation(fact, null, dr, cr, as.getC_Currency_ID(), wk.getA_Accumulated_Depr(), false);
//exp.getA_Accumulated_Depr(), false);
}
//
return facts;
}
Aggregations