IDEMPIERE-5474 Fixed Assets don't allow depreciation on 18 months (#1562)

This commit is contained in:
Carlos Ruiz 2022-11-16 08:47:36 +01:00 committed by GitHub
parent f76c39889c
commit 4d9bc5340c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 607 additions and 231 deletions

View File

@ -0,0 +1,106 @@
-- IDEMPIERE-5474 Fixed Assets don't allow depreciation on 18 months
SELECT register_migration_script('202211112236_IDEMPIERE-5474.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Nov 11, 2022, 10:36:25 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56032
;
-- Nov 11, 2022, 10:36:27 PM CET
ALTER TABLE I_Asset MODIFY UseLifeYears NUMBER DEFAULT NULL
;
-- Nov 11, 2022, 10:36:35 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55863
;
-- Nov 11, 2022, 10:36:36 PM CET
ALTER TABLE A_Asset_Change MODIFY UseLifeYears NUMBER DEFAULT NULL
;
-- Nov 11, 2022, 10:36:42 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55772
;
-- Nov 11, 2022, 10:36:43 PM CET
ALTER TABLE A_Asset_Group_Acct MODIFY UseLifeYears NUMBER DEFAULT NULL
;
-- Nov 11, 2022, 10:36:49 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:36:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59281
;
-- Nov 11, 2022, 10:36:50 PM CET
ALTER TABLE A_Depreciation_Workfile MODIFY UseLifeYears NUMBER DEFAULT 0
;
-- Nov 11, 2022, 10:36:50 PM CET
UPDATE A_Depreciation_Workfile SET UseLifeYears=0 WHERE UseLifeYears IS NULL
;
-- Nov 11, 2022, 10:37:01 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:37:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=8046
;
-- Nov 11, 2022, 10:37:02 PM CET
ALTER TABLE A_Asset MODIFY UseLifeYears NUMBER DEFAULT NULL
;
-- Nov 11, 2022, 10:42:59 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:42:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59408
;
-- Nov 11, 2022, 10:43:01 PM CET
ALTER TABLE A_Asset_Group_Acct MODIFY UseLifeYears_F NUMBER DEFAULT 0
;
-- Nov 11, 2022, 10:43:01 PM CET
UPDATE A_Asset_Group_Acct SET UseLifeYears_F=0 WHERE UseLifeYears_F IS NULL
;
-- Nov 11, 2022, 10:43:08 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:43:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59283
;
-- Nov 11, 2022, 10:43:09 PM CET
ALTER TABLE A_Depreciation_Workfile MODIFY UseLifeYears_F NUMBER DEFAULT 0
;
-- Nov 11, 2022, 10:43:09 PM CET
UPDATE A_Depreciation_Workfile SET UseLifeYears_F=0 WHERE UseLifeYears_F IS NULL
;
-- Nov 11, 2022, 10:44:51 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:44:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59279
;
-- Nov 11, 2022, 10:44:52 PM CET
ALTER TABLE A_Depreciation_Workfile MODIFY A_Asset_Life_Years_F NUMBER DEFAULT 0
;
-- Nov 11, 2022, 10:44:52 PM CET
UPDATE A_Depreciation_Workfile SET A_Asset_Life_Years_F=0 WHERE A_Asset_Life_Years_F IS NULL
;
-- Nov 11, 2022, 10:44:59 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:44:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55997
;
-- Nov 11, 2022, 10:45:01 PM CET
ALTER TABLE I_Asset MODIFY A_Asset_Life_Years NUMBER DEFAULT NULL
;
-- Nov 11, 2022, 10:45:06 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:45:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55418
;
-- Nov 11, 2022, 10:45:08 PM CET
ALTER TABLE A_Depreciation_Workfile MODIFY A_Asset_Life_Years NUMBER DEFAULT 0
;
-- Nov 11, 2022, 10:45:08 PM CET
UPDATE A_Depreciation_Workfile SET A_Asset_Life_Years=0 WHERE A_Asset_Life_Years IS NULL
;

View File

@ -0,0 +1,103 @@
-- IDEMPIERE-5474 Fixed Assets don't allow depreciation on 18 months
SELECT register_migration_script('202211112236_IDEMPIERE-5474.sql') FROM dual;
-- Nov 11, 2022, 10:36:25 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=56032
;
-- Nov 11, 2022, 10:36:27 PM CET
INSERT INTO t_alter_column values('i_asset','UseLifeYears','NUMERIC',null,'NULL')
;
-- Nov 11, 2022, 10:36:35 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55863
;
-- Nov 11, 2022, 10:36:36 PM CET
INSERT INTO t_alter_column values('a_asset_change','UseLifeYears','NUMERIC',null,'NULL')
;
-- Nov 11, 2022, 10:36:42 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:36:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55772
;
-- Nov 11, 2022, 10:36:43 PM CET
INSERT INTO t_alter_column values('a_asset_group_acct','UseLifeYears','NUMERIC',null,'NULL')
;
-- Nov 11, 2022, 10:36:49 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:36:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59281
;
-- Nov 11, 2022, 10:36:50 PM CET
INSERT INTO t_alter_column values('a_depreciation_workfile','UseLifeYears','NUMERIC',null,'0')
;
-- Nov 11, 2022, 10:36:50 PM CET
UPDATE A_Depreciation_Workfile SET UseLifeYears=0 WHERE UseLifeYears IS NULL
;
-- Nov 11, 2022, 10:37:01 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:37:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=8046
;
-- Nov 11, 2022, 10:37:02 PM CET
INSERT INTO t_alter_column values('a_asset','UseLifeYears','NUMERIC',null,'NULL')
;
-- Nov 11, 2022, 10:42:59 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:42:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59408
;
-- Nov 11, 2022, 10:43:01 PM CET
INSERT INTO t_alter_column values('a_asset_group_acct','UseLifeYears_F','NUMERIC',null,'0')
;
-- Nov 11, 2022, 10:43:01 PM CET
UPDATE A_Asset_Group_Acct SET UseLifeYears_F=0 WHERE UseLifeYears_F IS NULL
;
-- Nov 11, 2022, 10:43:08 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:43:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59283
;
-- Nov 11, 2022, 10:43:09 PM CET
INSERT INTO t_alter_column values('a_depreciation_workfile','UseLifeYears_F','NUMERIC',null,'0')
;
-- Nov 11, 2022, 10:43:09 PM CET
UPDATE A_Depreciation_Workfile SET UseLifeYears_F=0 WHERE UseLifeYears_F IS NULL
;
-- Nov 11, 2022, 10:44:51 PM CET
UPDATE AD_Column SET AD_Reference_ID=22, IsToolbarButton='N',Updated=TO_TIMESTAMP('2022-11-11 22:44:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59279
;
-- Nov 11, 2022, 10:44:52 PM CET
INSERT INTO t_alter_column values('a_depreciation_workfile','A_Asset_Life_Years_F','NUMERIC',null,'0')
;
-- Nov 11, 2022, 10:44:52 PM CET
UPDATE A_Depreciation_Workfile SET A_Asset_Life_Years_F=0 WHERE A_Asset_Life_Years_F IS NULL
;
-- Nov 11, 2022, 10:44:59 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:44:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55997
;
-- Nov 11, 2022, 10:45:01 PM CET
INSERT INTO t_alter_column values('i_asset','A_Asset_Life_Years','NUMERIC',null,'NULL')
;
-- Nov 11, 2022, 10:45:06 PM CET
UPDATE AD_Column SET AD_Reference_ID=22,Updated=TO_TIMESTAMP('2022-11-11 22:45:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55418
;
-- Nov 11, 2022, 10:45:08 PM CET
INSERT INTO t_alter_column values('a_depreciation_workfile','A_Asset_Life_Years','NUMERIC',null,'0')
;
-- Nov 11, 2022, 10:45:08 PM CET
UPDATE A_Depreciation_Workfile SET A_Asset_Life_Years=0 WHERE A_Asset_Life_Years IS NULL
;

View File

@ -146,7 +146,7 @@ public class Doc_AssetAddition extends Doc
{
MAssetAddition assetAdd = getAssetAddition();
int acct_id = MAssetAcct
.forA_Asset_ID(getCtx(), as.get_ID(), assetAdd.getA_Asset_ID(), assetAdd.getPostingType(), assetAdd.getDateAcct(), null)
.forA_Asset_ID(getCtx(), as.get_ID(), assetAdd.getA_Asset_ID(), assetAdd.getPostingType(), assetAdd.getDateAcct(), assetAdd.get_TrxName())
.getA_Asset_Acct();
return MAccount.get(getCtx(), acct_id);
}

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for A_Asset
* @author iDempiere (generated)
* @version Release 9
* @version Release 10
*/
public interface I_A_Asset
{
@ -148,8 +148,8 @@ public interface I_A_Asset
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
/** Get Tenant.
* Tenant for this installation.
*/
public int getAD_Client_ID();
@ -157,12 +157,12 @@ public interface I_A_Asset
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public int getAD_Org_ID();
@ -694,13 +694,13 @@ public interface I_A_Asset
/** Column name NextMaintenenceDate */
public static final String COLUMNNAME_NextMaintenenceDate = "NextMaintenenceDate";
/** Set Next Maintenence.
* Next Maintenence Date
/** Set Next Maintenance.
* Next Maintenance Date
*/
public void setNextMaintenenceDate (Timestamp NextMaintenenceDate);
/** Get Next Maintenence.
* Next Maintenence Date
/** Get Next Maintenance.
* Next Maintenance Date
*/
public Timestamp getNextMaintenenceDate();
@ -800,12 +800,12 @@ public interface I_A_Asset
/** Set Usable Life - Years.
* Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears);
public void setUseLifeYears (BigDecimal UseLifeYears);
/** Get Usable Life - Years.
* Years of the usable life of the asset
*/
public int getUseLifeYears();
public BigDecimal getUseLifeYears();
/** Column name UseUnits */
public static final String COLUMNNAME_UseUnits = "UseUnits";

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for A_Asset_Change
* @author iDempiere (generated)
* @version Release 9
* @version Release 10
*/
public interface I_A_Asset_Change
{
@ -148,8 +148,8 @@ public interface I_A_Asset_Change
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
/** Get Tenant.
* Tenant for this installation.
*/
public int getAD_Client_ID();
@ -228,12 +228,12 @@ public interface I_A_Asset_Change
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public int getAD_Org_ID();
@ -419,19 +419,19 @@ public interface I_A_Asset_Change
/** Column name AssetAccumDepreciationAmt */
public static final String COLUMNNAME_AssetAccumDepreciationAmt = "AssetAccumDepreciationAmt";
/** Set AssetAccumDepreciationAmt */
/** Set Asset Accum Depreciation Amt */
public void setAssetAccumDepreciationAmt (BigDecimal AssetAccumDepreciationAmt);
/** Get AssetAccumDepreciationAmt */
/** Get Asset Accum Depreciation Amt */
public BigDecimal getAssetAccumDepreciationAmt();
/** Column name AssetBookValueAmt */
public static final String COLUMNNAME_AssetBookValueAmt = "AssetBookValueAmt";
/** Set AssetBookValueAmt */
/** Set Asset Book Value Amt */
public void setAssetBookValueAmt (BigDecimal AssetBookValueAmt);
/** Get AssetBookValueAmt */
/** Get Asset Book Value Amt */
public BigDecimal getAssetBookValueAmt();
/** Column name AssetDepreciationDate */
@ -547,28 +547,28 @@ public interface I_A_Asset_Change
/** Column name ChangeAmt */
public static final String COLUMNNAME_ChangeAmt = "ChangeAmt";
/** Set ChangeAmt */
/** Set Change Amt */
public void setChangeAmt (BigDecimal ChangeAmt);
/** Get ChangeAmt */
/** Get Change Amt */
public BigDecimal getChangeAmt();
/** Column name ChangeDate */
public static final String COLUMNNAME_ChangeDate = "ChangeDate";
/** Set ChangeDate */
/** Set Change Date */
public void setChangeDate (Timestamp ChangeDate);
/** Get ChangeDate */
/** Get Change Date */
public Timestamp getChangeDate();
/** Column name ChangeType */
public static final String COLUMNNAME_ChangeType = "ChangeType";
/** Set ChangeType */
/** Set Change Type */
public void setChangeType (String ChangeType);
/** Get ChangeType */
/** Get Change Type */
public String getChangeType();
/** Column name C_Location_ID */
@ -737,12 +737,12 @@ public interface I_A_Asset_Change
/** Column name PostingType */
public static final String COLUMNNAME_PostingType = "PostingType";
/** Set PostingType.
/** Set Posting Type.
* The type of posted amount for the transaction
*/
public void setPostingType (String PostingType);
/** Get PostingType.
/** Get Posting Type.
* The type of posted amount for the transaction
*/
public String getPostingType();
@ -804,12 +804,12 @@ public interface I_A_Asset_Change
/** Set Usable Life - Years.
* Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears);
public void setUseLifeYears (BigDecimal UseLifeYears);
/** Get Usable Life - Years.
* Years of the usable life of the asset
*/
public int getUseLifeYears();
public BigDecimal getUseLifeYears();
/** Column name UseUnits */
public static final String COLUMNNAME_UseUnits = "UseUnits";

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for A_Asset_Group_Acct
* @author iDempiere (generated)
* @version Release 9
* @version Release 10
*/
public interface I_A_Asset_Group_Acct
{
@ -99,8 +99,8 @@ public interface I_A_Asset_Group_Acct
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
/** Get Tenant.
* Tenant for this installation.
*/
public int getAD_Client_ID();
@ -265,12 +265,12 @@ public interface I_A_Asset_Group_Acct
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public int getAD_Org_ID();
@ -394,12 +394,12 @@ public interface I_A_Asset_Group_Acct
/** Column name PostingType */
public static final String COLUMNNAME_PostingType = "PostingType";
/** Set PostingType.
/** Set Posting Type.
* The type of posted amount for the transaction
*/
public void setPostingType (String PostingType);
/** Get PostingType.
/** Get Posting Type.
* The type of posted amount for the transaction
*/
public String getPostingType();
@ -457,19 +457,19 @@ public interface I_A_Asset_Group_Acct
/** Set Usable Life - Years.
* Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears);
public void setUseLifeYears (BigDecimal UseLifeYears);
/** Get Usable Life - Years.
* Years of the usable life of the asset
*/
public int getUseLifeYears();
public BigDecimal getUseLifeYears();
/** Column name UseLifeYears_F */
public static final String COLUMNNAME_UseLifeYears_F = "UseLifeYears_F";
/** Set Use Life - Years (fiscal) */
public void setUseLifeYears_F (int UseLifeYears_F);
public void setUseLifeYears_F (BigDecimal UseLifeYears_F);
/** Get Use Life - Years (fiscal) */
public int getUseLifeYears_F();
public BigDecimal getUseLifeYears_F();
}

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for A_Depreciation_Workfile
* @author iDempiere (generated)
* @version Release 9
* @version Release 10
*/
public interface I_A_Depreciation_Workfile
{
@ -96,19 +96,19 @@ public interface I_A_Depreciation_Workfile
public static final String COLUMNNAME_A_Asset_Life_Years = "A_Asset_Life_Years";
/** Set Life Years */
public void setA_Asset_Life_Years (int A_Asset_Life_Years);
public void setA_Asset_Life_Years (BigDecimal A_Asset_Life_Years);
/** Get Life Years */
public int getA_Asset_Life_Years();
public BigDecimal getA_Asset_Life_Years();
/** Column name A_Asset_Life_Years_F */
public static final String COLUMNNAME_A_Asset_Life_Years_F = "A_Asset_Life_Years_F";
/** Set Life Years (fiscal) */
public void setA_Asset_Life_Years_F (int A_Asset_Life_Years_F);
public void setA_Asset_Life_Years_F (BigDecimal A_Asset_Life_Years_F);
/** Get Life Years (fiscal) */
public int getA_Asset_Life_Years_F();
public BigDecimal getA_Asset_Life_Years_F();
/** Column name A_Asset_Remaining */
public static final String COLUMNNAME_A_Asset_Remaining = "A_Asset_Remaining";
@ -167,8 +167,8 @@ public interface I_A_Depreciation_Workfile
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
/** Get Tenant.
* Tenant for this installation.
*/
public int getAD_Client_ID();
@ -194,12 +194,12 @@ public interface I_A_Depreciation_Workfile
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public int getAD_Org_ID();
@ -443,12 +443,12 @@ public interface I_A_Depreciation_Workfile
/** Column name PostingType */
public static final String COLUMNNAME_PostingType = "PostingType";
/** Set PostingType.
/** Set Posting Type.
* The type of posted amount for the transaction
*/
public void setPostingType (String PostingType);
/** Get PostingType.
/** Get Posting Type.
* The type of posted amount for the transaction
*/
public String getPostingType();
@ -519,19 +519,19 @@ public interface I_A_Depreciation_Workfile
/** Set Usable Life - Years.
* Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears);
public void setUseLifeYears (BigDecimal UseLifeYears);
/** Get Usable Life - Years.
* Years of the usable life of the asset
*/
public int getUseLifeYears();
public BigDecimal getUseLifeYears();
/** Column name UseLifeYears_F */
public static final String COLUMNNAME_UseLifeYears_F = "UseLifeYears_F";
/** Set Use Life - Years (fiscal) */
public void setUseLifeYears_F (int UseLifeYears_F);
public void setUseLifeYears_F (BigDecimal UseLifeYears_F);
/** Get Use Life - Years (fiscal) */
public int getUseLifeYears_F();
public BigDecimal getUseLifeYears_F();
}

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for I_Asset
* @author iDempiere (generated)
* @version Release 9
* @version Release 10
*/
public interface I_I_Asset
{
@ -122,10 +122,10 @@ public interface I_I_Asset
public static final String COLUMNNAME_A_Asset_Life_Years = "A_Asset_Life_Years";
/** Set Life Years */
public void setA_Asset_Life_Years (int A_Asset_Life_Years);
public void setA_Asset_Life_Years (BigDecimal A_Asset_Life_Years);
/** Get Life Years */
public int getA_Asset_Life_Years();
public BigDecimal getA_Asset_Life_Years();
/** Column name A_Base_Amount */
public static final String COLUMNNAME_A_Base_Amount = "A_Base_Amount";
@ -166,8 +166,8 @@ public interface I_I_Asset
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
/** Get Tenant.
* Tenant for this installation.
*/
public int getAD_Client_ID();
@ -224,12 +224,12 @@ public interface I_I_Asset
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
* Organizational entity within tenant
*/
public int getAD_Org_ID();
@ -734,12 +734,12 @@ public interface I_I_Asset
/** Column name PostingType */
public static final String COLUMNNAME_PostingType = "PostingType";
/** Set PostingType.
/** Set Posting Type.
* The type of posted amount for the transaction
*/
public void setPostingType (String PostingType);
/** Get PostingType.
/** Get Posting Type.
* The type of posted amount for the transaction
*/
public String getPostingType();
@ -814,12 +814,12 @@ public interface I_I_Asset
/** Set Usable Life - Years.
* Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears);
public void setUseLifeYears (BigDecimal UseLifeYears);
/** Get Usable Life - Years.
* Years of the usable life of the asset
*/
public int getUseLifeYears();
public BigDecimal getUseLifeYears();
/** Column name UseUnits */
public static final String COLUMNNAME_UseUnits = "UseUnits";

View File

@ -390,8 +390,8 @@ public class MAsset extends X_A_Asset {
DB.executeUpdateEx("UPDATE A_Asset SET IsDepreciated='" + isDepreciated + "', isOwned ='" + isOwned + "' WHERE A_Asset_ID=" + getA_Asset_ID(), get_TrxName());
//end @win
// for each asset group acounting create an asset accounting and a workfile too
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), getA_Asset_Group_ID()))
// for each asset group accounting create an asset accounting and a workfile too
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), getA_Asset_Group_ID(), null, get_TrxName()))
{
if (assetgrpacct.getAD_Org_ID() == 0 || assetgrpacct.getAD_Org_ID() == getAD_Org_ID())
{

View File

@ -634,7 +634,7 @@ public class MAssetAddition extends X_A_Asset_Addition
MDepreciationWorkfile assetwk = MDepreciationWorkfile.get(getCtx(), getA_Asset_ID(), getPostingType(), get_TrxName());
if (assetwk == null)
{
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), asset.getA_Asset_Group_ID(), getPostingType()))
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), asset.getA_Asset_Group_ID(), getPostingType(), get_TrxName()))
{
if (A_SOURCETYPE_Imported.equals(getA_SourceType()) && assetgrpacct.getC_AcctSchema_ID() != getI_FixedAsset().getC_AcctSchema_ID())
continue;

View File

@ -177,7 +177,7 @@ public class MAssetGroup extends X_A_Asset_Group implements ImmutablePOSupport
int default_id = getDefault_ID(SetGetUtil.wrap(this));
if (default_id > 0 && default_id != get_ID())
{
for (MAssetGroupAcct acct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), default_id))
for (MAssetGroupAcct acct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), default_id, null, get_TrxName()))
{
MAssetGroupAcct newAcct = acct.copy(this);
newAcct.saveEx(get_TrxName());

View File

@ -2,6 +2,7 @@ package org.compiere.model;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -15,30 +16,51 @@ import org.idempiere.fa.feature.UseLifeImpl;
public class MAssetGroupAcct extends X_A_Asset_Group_Acct
implements UseLife
{
/**
*
*/
private static final long serialVersionUID = -3458020679308192943L;
private static final long serialVersionUID = -2436949294592742530L;
/**
* Get Asset Group Accountings for given group
*/
/**
* @param ctx
* @param A_Asset_Group_ID
* @return
* @deprecated use the version with postingType and trxName
*/
public static List<MAssetGroupAcct> forA_Asset_Group_ID(Properties ctx, int A_Asset_Group_ID)
{
return new Query(ctx, Table_Name, COLUMNNAME_A_Asset_Group_ID+"=?", null)
.setParameters(new Object[]{A_Asset_Group_ID})
.list();
return forA_Asset_Group_ID(ctx, A_Asset_Group_ID, null, null);
}
/**
* Get Asset Group Accountings for given group
* @param ctx
* @param A_Asset_Group_ID
* @param postingType
* @return
* @deprecated use the version with trxName
*/
public static List<MAssetGroupAcct> forA_Asset_Group_ID(Properties ctx, int A_Asset_Group_ID, String postingType)
{
final String whereClause = COLUMNNAME_A_Asset_Group_ID+"=? AND "+COLUMNNAME_PostingType+"=?";
return new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{A_Asset_Group_ID, postingType})
return forA_Asset_Group_ID(ctx, A_Asset_Group_ID, postingType, null);
}
/**
* Get Asset Group Accountings for given group
*/
public static List<MAssetGroupAcct> forA_Asset_Group_ID(Properties ctx, int A_Asset_Group_ID, String postingType, String trxName)
{
List<Object> params = new ArrayList<Object>();
StringBuilder whereClause = new StringBuilder("A_Asset_Group_ID=?");
params.add(A_Asset_Group_ID);
if (postingType != null) {
whereClause.append(" AND PostingType=?");
params.add(postingType);
}
return new Query(ctx, Table_Name, whereClause.toString(), trxName)
.setParameters(params)
.list();
}
@ -102,6 +124,10 @@ public class MAssetGroupAcct extends X_A_Asset_Group_Acct
{
return false;
}
if (! UseLifeImpl.get(this, true).validate())
{
return false;
}
return true;
}

View File

@ -25,7 +25,7 @@ import org.compiere.util.Env;
/** Generated Model for A_Asset
* @author iDempiere (generated)
* @version Release 9 - $Id$ */
* @version Release 10 - $Id$ */
@org.adempiere.base.Model(table="A_Asset")
public class X_A_Asset extends PO implements I_A_Asset, I_Persistent
{
@ -33,7 +33,7 @@ public class X_A_Asset extends PO implements I_A_Asset, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20220116L;
private static final long serialVersionUID = 20221111L;
/** Standard Constructor */
public X_A_Asset (Properties ctx, int A_Asset_ID, String trxName)
@ -1153,16 +1153,16 @@ public class X_A_Asset extends PO implements I_A_Asset, I_Persistent
return (String)get_Value(COLUMNNAME_Name);
}
/** Set Next Maintenence.
@param NextMaintenenceDate Next Maintenence Date
/** Set Next Maintenance.
@param NextMaintenenceDate Next Maintenance Date
*/
public void setNextMaintenenceDate (Timestamp NextMaintenenceDate)
{
set_Value (COLUMNNAME_NextMaintenenceDate, NextMaintenenceDate);
}
/** Get Next Maintenence.
@return Next Maintenence Date
/** Get Next Maintenance.
@return Next Maintenance Date
*/
public Timestamp getNextMaintenenceDate()
{
@ -1290,20 +1290,20 @@ public class X_A_Asset extends PO implements I_A_Asset, I_Persistent
/** Set Usable Life - Years.
@param UseLifeYears Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears)
public void setUseLifeYears (BigDecimal UseLifeYears)
{
set_Value (COLUMNNAME_UseLifeYears, Integer.valueOf(UseLifeYears));
set_Value (COLUMNNAME_UseLifeYears, UseLifeYears);
}
/** Get Usable Life - Years.
@return Years of the usable life of the asset
*/
public int getUseLifeYears()
public BigDecimal getUseLifeYears()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Use units.

View File

@ -26,7 +26,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Model for A_Asset_Change
* @author iDempiere (generated)
* @version Release 9 - $Id$ */
* @version Release 10 - $Id$ */
@org.adempiere.base.Model(table="A_Asset_Change")
public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persistent
{
@ -34,7 +34,7 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
/**
*
*/
private static final long serialVersionUID = 20220116L;
private static final long serialVersionUID = 20221111L;
/** Standard Constructor */
public X_A_Asset_Change (Properties ctx, int A_Asset_Change_ID, String trxName)
@ -832,16 +832,16 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
return bd;
}
/** Set AssetAccumDepreciationAmt.
@param AssetAccumDepreciationAmt AssetAccumDepreciationAmt
/** Set Asset Accum Depreciation Amt.
@param AssetAccumDepreciationAmt Asset Accum Depreciation Amt
*/
public void setAssetAccumDepreciationAmt (BigDecimal AssetAccumDepreciationAmt)
{
set_ValueNoCheck (COLUMNNAME_AssetAccumDepreciationAmt, AssetAccumDepreciationAmt);
}
/** Get AssetAccumDepreciationAmt.
@return AssetAccumDepreciationAmt */
/** Get Asset Accum Depreciation Amt.
@return Asset Accum Depreciation Amt */
public BigDecimal getAssetAccumDepreciationAmt()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_AssetAccumDepreciationAmt);
@ -850,16 +850,16 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
return bd;
}
/** Set AssetBookValueAmt.
@param AssetBookValueAmt AssetBookValueAmt
/** Set Asset Book Value Amt.
@param AssetBookValueAmt Asset Book Value Amt
*/
public void setAssetBookValueAmt (BigDecimal AssetBookValueAmt)
{
set_ValueNoCheck (COLUMNNAME_AssetBookValueAmt, AssetBookValueAmt);
}
/** Get AssetBookValueAmt.
@return AssetBookValueAmt */
/** Get Asset Book Value Amt.
@return Asset Book Value Amt */
public BigDecimal getAssetBookValueAmt()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_AssetBookValueAmt);
@ -1038,16 +1038,16 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
return ii.intValue();
}
/** Set ChangeAmt.
@param ChangeAmt ChangeAmt
/** Set Change Amt.
@param ChangeAmt Change Amt
*/
public void setChangeAmt (BigDecimal ChangeAmt)
{
set_ValueNoCheck (COLUMNNAME_ChangeAmt, ChangeAmt);
}
/** Get ChangeAmt.
@return ChangeAmt */
/** Get Change Amt.
@return Change Amt */
public BigDecimal getChangeAmt()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ChangeAmt);
@ -1056,16 +1056,16 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
return bd;
}
/** Set ChangeDate.
@param ChangeDate ChangeDate
/** Set Change Date.
@param ChangeDate Change Date
*/
public void setChangeDate (Timestamp ChangeDate)
{
set_ValueNoCheck (COLUMNNAME_ChangeDate, ChangeDate);
}
/** Get ChangeDate.
@return ChangeDate */
/** Get Change Date.
@return Change Date */
public Timestamp getChangeDate()
{
return (Timestamp)get_Value(COLUMNNAME_ChangeDate);
@ -1101,8 +1101,8 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
public static final String CHANGETYPE_Update = "UPD";
/** Usage = USE */
public static final String CHANGETYPE_Usage = "USE";
/** Set ChangeType.
@param ChangeType ChangeType
/** Set Change Type.
@param ChangeType Change Type
*/
public void setChangeType (String ChangeType)
{
@ -1110,8 +1110,8 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
set_ValueNoCheck (COLUMNNAME_ChangeType, ChangeType);
}
/** Get ChangeType.
@return ChangeType */
/** Get Change Type.
@return Change Type */
public String getChangeType()
{
return (String)get_Value(COLUMNNAME_ChangeType);
@ -1351,7 +1351,7 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
public static final String POSTINGTYPE_Reservation = "R";
/** Statistical = S */
public static final String POSTINGTYPE_Statistical = "S";
/** Set PostingType.
/** Set Posting Type.
@param PostingType The type of posted amount for the transaction
*/
public void setPostingType (String PostingType)
@ -1360,7 +1360,7 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
set_Value (COLUMNNAME_PostingType, PostingType);
}
/** Get PostingType.
/** Get Posting Type.
@return The type of posted amount for the transaction
*/
public String getPostingType()
@ -1421,20 +1421,20 @@ public class X_A_Asset_Change extends PO implements I_A_Asset_Change, I_Persiste
/** Set Usable Life - Years.
@param UseLifeYears Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears)
public void setUseLifeYears (BigDecimal UseLifeYears)
{
set_ValueNoCheck (COLUMNNAME_UseLifeYears, Integer.valueOf(UseLifeYears));
set_ValueNoCheck (COLUMNNAME_UseLifeYears, UseLifeYears);
}
/** Get Usable Life - Years.
@return Years of the usable life of the asset
*/
public int getUseLifeYears()
public BigDecimal getUseLifeYears()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Use units.

View File

@ -25,7 +25,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Model for A_Asset_Group_Acct
* @author iDempiere (generated)
* @version Release 9 - $Id$ */
* @version Release 10 - $Id$ */
@org.adempiere.base.Model(table="A_Asset_Group_Acct")
public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_Persistent
{
@ -33,7 +33,7 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
/**
*
*/
private static final long serialVersionUID = 20220116L;
private static final long serialVersionUID = 20221111L;
/** Standard Constructor */
public X_A_Asset_Group_Acct (Properties ctx, int A_Asset_Group_Acct_ID, String trxName)
@ -57,7 +57,7 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
// 'A'
setUseLifeMonths_F (0);
// 0
setUseLifeYears_F (0);
setUseLifeYears_F (Env.ZERO);
// 0
} */
}
@ -84,7 +84,7 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
// 'A'
setUseLifeMonths_F (0);
// 0
setUseLifeYears_F (0);
setUseLifeYears_F (Env.ZERO);
// 0
} */
}
@ -800,7 +800,7 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
public static final String POSTINGTYPE_Reservation = "R";
/** Statistical = S */
public static final String POSTINGTYPE_Statistical = "S";
/** Set PostingType.
/** Set Posting Type.
@param PostingType The type of posted amount for the transaction
*/
public void setPostingType (String PostingType)
@ -809,7 +809,7 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
set_Value (COLUMNNAME_PostingType, PostingType);
}
/** Get PostingType.
/** Get Posting Type.
@return The type of posted amount for the transaction
*/
public String getPostingType()
@ -879,37 +879,37 @@ public class X_A_Asset_Group_Acct extends PO implements I_A_Asset_Group_Acct, I_
/** Set Usable Life - Years.
@param UseLifeYears Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears)
public void setUseLifeYears (BigDecimal UseLifeYears)
{
set_Value (COLUMNNAME_UseLifeYears, Integer.valueOf(UseLifeYears));
set_Value (COLUMNNAME_UseLifeYears, UseLifeYears);
}
/** Get Usable Life - Years.
@return Years of the usable life of the asset
*/
public int getUseLifeYears()
public BigDecimal getUseLifeYears()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Use Life - Years (fiscal).
@param UseLifeYears_F Use Life - Years (fiscal)
*/
public void setUseLifeYears_F (int UseLifeYears_F)
public void setUseLifeYears_F (BigDecimal UseLifeYears_F)
{
set_Value (COLUMNNAME_UseLifeYears_F, Integer.valueOf(UseLifeYears_F));
set_Value (COLUMNNAME_UseLifeYears_F, UseLifeYears_F);
}
/** Get Use Life - Years (fiscal).
@return Use Life - Years (fiscal) */
public int getUseLifeYears_F()
public BigDecimal getUseLifeYears_F()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears_F);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears_F);
if (bd == null)
return Env.ZERO;
return bd;
}
}

View File

@ -26,7 +26,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Model for A_Depreciation_Workfile
* @author iDempiere (generated)
* @version Release 9 - $Id$ */
* @version Release 10 - $Id$ */
@org.adempiere.base.Model(table="A_Depreciation_Workfile")
public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Workfile, I_Persistent
{
@ -34,7 +34,7 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
/**
*
*/
private static final long serialVersionUID = 20220116L;
private static final long serialVersionUID = 20221111L;
/** Standard Constructor */
public X_A_Depreciation_Workfile (Properties ctx, int A_Depreciation_Workfile_ID, String trxName)
@ -51,9 +51,9 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
setA_Asset_ID (0);
setA_Asset_Life_Current_Year (Env.ZERO);
// 0
setA_Asset_Life_Years (0);
setA_Asset_Life_Years (Env.ZERO);
// 0
setA_Asset_Life_Years_F (0);
setA_Asset_Life_Years_F (Env.ZERO);
// 0
setA_Curr_Dep_Exp (Env.ZERO);
// 0
@ -73,9 +73,9 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
// 0
setUseLifeMonths_F (0);
// 0
setUseLifeYears (0);
setUseLifeYears (Env.ZERO);
// 0
setUseLifeYears_F (0);
setUseLifeYears_F (Env.ZERO);
// 0
} */
}
@ -95,9 +95,9 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
setA_Asset_ID (0);
setA_Asset_Life_Current_Year (Env.ZERO);
// 0
setA_Asset_Life_Years (0);
setA_Asset_Life_Years (Env.ZERO);
// 0
setA_Asset_Life_Years_F (0);
setA_Asset_Life_Years_F (Env.ZERO);
// 0
setA_Curr_Dep_Exp (Env.ZERO);
// 0
@ -117,9 +117,9 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
// 0
setUseLifeMonths_F (0);
// 0
setUseLifeYears (0);
setUseLifeYears (Env.ZERO);
// 0
setUseLifeYears_F (0);
setUseLifeYears_F (Env.ZERO);
// 0
} */
}
@ -255,37 +255,37 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
/** Set Life Years.
@param A_Asset_Life_Years Life Years
*/
public void setA_Asset_Life_Years (int A_Asset_Life_Years)
public void setA_Asset_Life_Years (BigDecimal A_Asset_Life_Years)
{
set_Value (COLUMNNAME_A_Asset_Life_Years, Integer.valueOf(A_Asset_Life_Years));
set_Value (COLUMNNAME_A_Asset_Life_Years, A_Asset_Life_Years);
}
/** Get Life Years.
@return Life Years */
public int getA_Asset_Life_Years()
public BigDecimal getA_Asset_Life_Years()
{
Integer ii = (Integer)get_Value(COLUMNNAME_A_Asset_Life_Years);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_A_Asset_Life_Years);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Life Years (fiscal).
@param A_Asset_Life_Years_F Life Years (fiscal)
*/
public void setA_Asset_Life_Years_F (int A_Asset_Life_Years_F)
public void setA_Asset_Life_Years_F (BigDecimal A_Asset_Life_Years_F)
{
set_Value (COLUMNNAME_A_Asset_Life_Years_F, Integer.valueOf(A_Asset_Life_Years_F));
set_Value (COLUMNNAME_A_Asset_Life_Years_F, A_Asset_Life_Years_F);
}
/** Get Life Years (fiscal).
@return Life Years (fiscal) */
public int getA_Asset_Life_Years_F()
public BigDecimal getA_Asset_Life_Years_F()
{
Integer ii = (Integer)get_Value(COLUMNNAME_A_Asset_Life_Years_F);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_A_Asset_Life_Years_F);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Remaining Amt.
@ -833,7 +833,7 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
public static final String POSTINGTYPE_Reservation = "R";
/** Statistical = S */
public static final String POSTINGTYPE_Statistical = "S";
/** Set PostingType.
/** Set Posting Type.
@param PostingType The type of posted amount for the transaction
*/
public void setPostingType (String PostingType)
@ -842,7 +842,7 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
set_Value (COLUMNNAME_PostingType, PostingType);
}
/** Get PostingType.
/** Get Posting Type.
@return The type of posted amount for the transaction
*/
public String getPostingType()
@ -935,37 +935,37 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
/** Set Usable Life - Years.
@param UseLifeYears Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears)
public void setUseLifeYears (BigDecimal UseLifeYears)
{
set_Value (COLUMNNAME_UseLifeYears, Integer.valueOf(UseLifeYears));
set_Value (COLUMNNAME_UseLifeYears, UseLifeYears);
}
/** Get Usable Life - Years.
@return Years of the usable life of the asset
*/
public int getUseLifeYears()
public BigDecimal getUseLifeYears()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Use Life - Years (fiscal).
@param UseLifeYears_F Use Life - Years (fiscal)
*/
public void setUseLifeYears_F (int UseLifeYears_F)
public void setUseLifeYears_F (BigDecimal UseLifeYears_F)
{
set_Value (COLUMNNAME_UseLifeYears_F, Integer.valueOf(UseLifeYears_F));
set_Value (COLUMNNAME_UseLifeYears_F, UseLifeYears_F);
}
/** Get Use Life - Years (fiscal).
@return Use Life - Years (fiscal) */
public int getUseLifeYears_F()
public BigDecimal getUseLifeYears_F()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears_F);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears_F);
if (bd == null)
return Env.ZERO;
return bd;
}
}

View File

@ -26,7 +26,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Model for I_Asset
* @author iDempiere (generated)
* @version Release 9 - $Id$ */
* @version Release 10 - $Id$ */
@org.adempiere.base.Model(table="I_Asset")
public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
{
@ -34,7 +34,7 @@ public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20220116L;
private static final long serialVersionUID = 20221111L;
/** Standard Constructor */
public X_I_Asset (Properties ctx, int I_Asset_ID, String trxName)
@ -239,19 +239,19 @@ public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
/** Set Life Years.
@param A_Asset_Life_Years Life Years
*/
public void setA_Asset_Life_Years (int A_Asset_Life_Years)
public void setA_Asset_Life_Years (BigDecimal A_Asset_Life_Years)
{
set_Value (COLUMNNAME_A_Asset_Life_Years, Integer.valueOf(A_Asset_Life_Years));
set_Value (COLUMNNAME_A_Asset_Life_Years, A_Asset_Life_Years);
}
/** Get Life Years.
@return Life Years */
public int getA_Asset_Life_Years()
public BigDecimal getA_Asset_Life_Years()
{
Integer ii = (Integer)get_Value(COLUMNNAME_A_Asset_Life_Years);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_A_Asset_Life_Years);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set A_Base_Amount.
@ -1252,7 +1252,7 @@ public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
public static final String POSTINGTYPE_Reservation = "R";
/** Statistical = S */
public static final String POSTINGTYPE_Statistical = "S";
/** Set PostingType.
/** Set Posting Type.
@param PostingType The type of posted amount for the transaction
*/
public void setPostingType (String PostingType)
@ -1261,7 +1261,7 @@ public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
set_Value (COLUMNNAME_PostingType, PostingType);
}
/** Get PostingType.
/** Get Posting Type.
@return The type of posted amount for the transaction
*/
public String getPostingType()
@ -1352,20 +1352,20 @@ public class X_I_Asset extends PO implements I_I_Asset, I_Persistent
/** Set Usable Life - Years.
@param UseLifeYears Years of the usable life of the asset
*/
public void setUseLifeYears (int UseLifeYears)
public void setUseLifeYears (BigDecimal UseLifeYears)
{
set_Value (COLUMNNAME_UseLifeYears, Integer.valueOf(UseLifeYears));
set_Value (COLUMNNAME_UseLifeYears, UseLifeYears);
}
/** Get Usable Life - Years.
@return Years of the usable life of the asset
*/
public int getUseLifeYears()
public BigDecimal getUseLifeYears()
{
Integer ii = (Integer)get_Value(COLUMNNAME_UseLifeYears);
if (ii == null)
return 0;
return ii.intValue();
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_UseLifeYears);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Use units.

View File

@ -3,18 +3,20 @@
*/
package org.idempiere.fa.feature;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
//import org.compiere.model.MAssetClass; //commented by @win
import org.compiere.model.MAssetGroup;
import org.compiere.model.PO;
import org.compiere.model.SetGetModel;
import org.compiere.model.SetGetUtil;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
@ -31,6 +33,7 @@ public class UseLifeImpl
private final static String FIELD_UseLifeYears = "UseLifeYears";
private final static String FIELD_UseLifeMonths = "UseLifeMonths";
private final static String FIELD_FiscalPostfix = "_F";
private static final BigDecimal TWELVE = BigDecimal.valueOf(12.0);
private SetGetModel m_obj = null;
private CLogger log = CLogger.getCLogger(getClass());
@ -116,7 +119,7 @@ public class UseLifeImpl
public void setUseLifeMonths(int value) {
if (log.isLoggable(Level.FINE)) log.fine("Entering: value=" + value + ", " + this);
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeMonths, fiscal), Integer.valueOf(value));
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeYears, fiscal), Integer.valueOf(value/12));
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeYears, fiscal), BigDecimal.valueOf(value).setScale(12).divide(TWELVE, RoundingMode.HALF_UP));
if (log.isLoggable(Level.FINE)) log.fine("Leaving: value=" + value + ", " + this);
}
@ -134,22 +137,22 @@ public class UseLifeImpl
/** Set UseLifeYears and UseLifeMonths
* @param value use life years
*/
public void setUseLifeYears(int value) {
public void setUseLifeYears(BigDecimal value) {
if (log.isLoggable(Level.FINE)) log.fine("Entering: value=" + value + ", " + this);
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeYears, fiscal), Integer.valueOf(value));
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeMonths, fiscal), Integer.valueOf(value*12));
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeYears, fiscal), value);
m_obj.set_AttrValue(getFieldName(FIELD_UseLifeMonths, fiscal), value.multiply(TWELVE).setScale(0, RoundingMode.HALF_UP));
if (log.isLoggable(Level.FINE)) log.fine("Leaving: value=" + value + ", " + this);
}
/**
* @return use life years
*/
public int getUseLifeYears() {
public BigDecimal getUseLifeYears() {
Object obj = m_obj.get_AttrValue(getFieldName(FIELD_UseLifeYears, fiscal));
if (obj != null && obj instanceof Number) {
return ((Number)obj).intValue();
if (obj != null && obj instanceof BigDecimal) {
return (BigDecimal) obj;
}
return 0;
return Env.ZERO;
}
/**
@ -159,8 +162,8 @@ public class UseLifeImpl
*/
public void adjustUseLifeYears(int deltaUseLifeYears, boolean reset)
{
int uselife = (reset ? 0 : getUseLifeYears());
int new_uselife = uselife + deltaUseLifeYears;
BigDecimal uselife = (reset ? Env.ZERO : getUseLifeYears());
BigDecimal new_uselife = uselife.add(BigDecimal.valueOf(deltaUseLifeYears));
setUseLifeYears(new_uselife);
if (log.isLoggable(Level.FINE)) log.fine("UseLifeYears=" + uselife + ", delta=" + deltaUseLifeYears + " => new UseLifeYears=" + new_uselife + " (isFiscal=" + isFiscal() + ")");
}
@ -220,21 +223,15 @@ public class UseLifeImpl
public boolean validate(boolean saveError) {
if (log.isLoggable(Level.FINE)) log.fine("Entering: " + this);
int useLifeYears = 0;
BigDecimal useLifeYears = Env.ZERO;
int useLifeMonths = 0;
useLifeYears = getUseLifeYears();
useLifeMonths = getUseLifeMonths();
if (useLifeMonths == 0) {
useLifeMonths = useLifeYears * 12;
}
if (useLifeMonths % 12 != 0) {
if(saveError) log.saveError("Error", "@Invalid@ @UseLifeMonths@=" + useLifeMonths + "(@Diff@=" + (useLifeMonths % 12) + ")" );
return false;
}
if (useLifeYears == 0) {
useLifeYears = (int)(useLifeMonths / 12);
useLifeMonths = useLifeYears.multiply(TWELVE).intValue();
}
useLifeYears = BigDecimal.valueOf(useLifeMonths).setScale(12).divide(TWELVE, RoundingMode.HALF_UP);
/* commented out by @win
int A_Asset_Class_ID = getA_Asset_Class_ID();
if (A_Asset_Class_ID > 0 && (useLifeMonths == 0 || useLifeYears == 0)) {

View File

@ -1,6 +1,7 @@
package org.idempiere.fa.model;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Properties;
import org.compiere.model.CalloutEngine;
@ -15,6 +16,8 @@ import org.compiere.model.SetGetUtil;
*/
public class CalloutA_Depreciation_Workfile extends CalloutEngine
{
private static final BigDecimal TWELVE = BigDecimal.valueOf(12.0);
public String A_Valoare_Cofinantare (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (isCalloutActive())
@ -28,26 +31,26 @@ public class CalloutA_Depreciation_Workfile extends CalloutEngine
BigDecimal uselife = null;
if (MDepreciationWorkfile.COLUMNNAME_UseLifeYears.equals(mField.getColumnName()))
{
uselife = new BigDecimal(value.toString()).multiply(BigDecimal.valueOf(12.0));
uselife = new BigDecimal(value.toString()).multiply(TWELVE);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, value);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths, uselife);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, uselife);
} else if (MDepreciationWorkfile.COLUMNNAME_UseLifeMonths.equals(mField.getColumnName()))
{
uselife = new BigDecimal(value.toString()).divide(BigDecimal.valueOf(12.0));
uselife = new BigDecimal(value.toString()).setScale(12).divide(TWELVE, RoundingMode.HALF_UP);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears, uselife);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, uselife);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, value);
} else if (MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F.equals(mField.getColumnName()))
{
uselife = new BigDecimal(value.toString()).multiply(BigDecimal.valueOf(12.0));
uselife = new BigDecimal(value.toString()).multiply(TWELVE);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F, uselife);
} else if (MDepreciationWorkfile.COLUMNNAME_UseLifeMonths_F.equals(mField.getColumnName()))
{
uselife = new BigDecimal(value.toString()).divide(BigDecimal.valueOf(12.0));
uselife = new BigDecimal(value.toString()).setScale(12).divide(TWELVE, RoundingMode.HALF_UP);
mTab.setValue(MDepreciationWorkfile.COLUMNNAME_UseLifeYears_F, uselife);
}

View File

@ -453,7 +453,7 @@ public class ImportFixedAsset extends SvrProcess
if (isUpdate)
{
MAsset asset = MAsset.get(getCtx(), ifa.getA_Asset_ID(), get_TrxName());
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), asset.getA_Asset_Group_ID()))
for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), asset.getA_Asset_Group_ID(), null, get_TrxName()))
{
if (assetgrpacct.getAD_Org_ID() == 0 || assetgrpacct.getAD_Org_ID() == asset.getAD_Org_ID())
{

View File

@ -34,6 +34,26 @@ public final class DictionaryIDs {
private DictionaryIDs() {
}
public enum A_Asset_Group {
EQUIPMENT(50007);
public final int id;
private A_Asset_Group(int id) {
this.id = id;
}
}
public enum A_Asset_Group_Acct {
EQUIPMENT_DOLLAR(200002);
public final int id;
private A_Asset_Group_Acct(int id) {
this.id = id;
}
}
public enum AD_Org {
HQ(11),
STORE_CENTRAL(12),
@ -74,7 +94,17 @@ public final class DictionaryIDs {
this.id = id;
}
}
public enum C_AcctSchema {
DOLLAR(101);
public final int id;
private C_AcctSchema(int id) {
this.id = id;
}
}
public enum C_BankAccount {
ACCOUNT_1234(100),
ACCOUNT_5678(101),
@ -422,7 +452,8 @@ public final class DictionaryIDs {
PATIOSET(145),
DOC(146),
TSHIRT_RL(147),
TSHIRT_GL(148);
TSHIRT_GL(148),
ASSET_VEHICLE(200001);
public final int id;

View File

@ -0,0 +1,110 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Carlos Ruiz - globalqss - bxservice *
**********************************************************************/
package org.idempiere.test.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.model.MAsset;
import org.compiere.model.MAssetAddition;
import org.compiere.model.MAssetGroupAcct;
import org.compiere.process.DocAction;
import org.compiere.process.ProcessInfo;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
public class FixedAssetsTest extends AbstractTestCase {
public FixedAssetsTest() {
}
/**
* IDEMPIERE-5474 - depreciation on 18 months
*/
@Test
public void test18MonthsDepreciation() {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
MAssetGroupAcct aga = new MAssetGroupAcct(ctx, DictionaryIDs.A_Asset_Group_Acct.EQUIPMENT_DOLLAR.id, trxName);
aga.setUseLifeMonths(18);
aga.setUseLifeYears(Env.ZERO);
aga.setUseLifeMonths_F(18);
aga.setUseLifeYears_F(Env.ZERO);
aga.saveEx();
aga.load(trxName);
assertTrue( ( new BigDecimal("1.5").compareTo(aga.getUseLifeYears()) == 0 ) );
assertTrue( ( new BigDecimal("1.5").compareTo(aga.getUseLifeYears_F()) == 0 ) );
MAsset a = new MAsset(ctx, 0, trxName);
a.setValue("test_18_m");
a.setName("test_18_m");
a.setA_Asset_Group_ID(DictionaryIDs.A_Asset_Group.EQUIPMENT.id);
a.setM_Product_ID(DictionaryIDs.M_Product.ASSET_VEHICLE.id);
a.setIsOwned(true);
a.setIsDepreciated(true);
a.saveEx();
MAssetAddition aa = new MAssetAddition(ctx, 0, trxName);
aa.setA_Asset_ID(a.getA_Asset_ID());
aa.setDateDoc(new Timestamp(System.currentTimeMillis()));
aa.setA_SourceType(MAssetAddition.A_SOURCETYPE_Manual);
aa.setAssetAmtEntered(new BigDecimal("12000.0"));
aa.setAssetSourceAmt(aa.getAssetAmtEntered());
aa.setA_Salvage_Value(new BigDecimal("2000.0"));
aa.saveEx();
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(aa, DocAction.ACTION_Complete);
aa.load(getTrxName());
assertFalse(info.isError(), "Error processing asset addition: " + info.getSummary());
assertEquals(DocAction.STATUS_Completed, aa.getDocStatus(), "Asset addition status is not completed: " + aa.getDocStatus());
assertTrue(aa.isPosted(), "Asset addition not posted");
final String sqlCnt = ""
+ "SELECT COUNT(*) "
+ "FROM A_Depreciation_Exp "
+ "WHERE A_Asset_ID=? AND C_AcctSchema_ID=?";
int cnt = DB.getSQLValueEx(trxName, sqlCnt, a.getA_Asset_ID(), DictionaryIDs.C_AcctSchema.DOLLAR.id);
assertEquals(18, cnt);
final String sqlSumExp = ""
+ "SELECT SUM(Expense) "
+ "FROM A_Depreciation_Exp "
+ "WHERE A_Asset_ID=? AND C_AcctSchema_ID=?";
BigDecimal sumExp = DB.getSQLValueBDEx(trxName, sqlSumExp, a.getA_Asset_ID(), DictionaryIDs.C_AcctSchema.DOLLAR.id);
assertTrue( ( new BigDecimal("10000.0").compareTo(sumExp) == 0 ) );
}
}