diff --git a/migration/i6.2z/oracle/201904101655_IDEMPIERE-3947.sql b/migration/i6.2z/oracle/201904101655_IDEMPIERE-3947.sql new file mode 100644 index 0000000000..4a2e2d8b4f --- /dev/null +++ b/migration/i6.2z/oracle/201904101655_IDEMPIERE-3947.sql @@ -0,0 +1,93 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Oct 11, 2018 8:41:01 PM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213700,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53116,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2018-10-11 20:40:59','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-10-11 20:40:59','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','c62177d9-97f4-4c03-bc74-05a9f5609c95','Y',0,'N','N','C') +; + +-- Oct 11, 2018 8:41:16 PM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_ADepreciationWorkf', FKConstraintType='C',Updated=TO_DATE('2018-10-11 20:41:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213700 +; + +-- Oct 11, 2018 8:41:16 PM SGT +ALTER TABLE A_Depreciation_Workfile ADD C_AcctSchema_ID NUMBER(10) DEFAULT NULL +; + +-- Oct 11, 2018 8:41:17 PM SGT +ALTER TABLE A_Depreciation_Workfile ADD CONSTRAINT CAcctSchema_ADepreciationWorkf FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Oct 11, 2018 8:46:13 PM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213701,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53115,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2018-10-11 20:46:12','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-10-11 20:46:12','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','b0851cce-d266-461b-a47c-4cf19ad6b3af','Y',0,'N','N','C') +; + +-- Oct 11, 2018 8:46:18 PM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_ADepreciationExp', FKConstraintType='C',Updated=TO_DATE('2018-10-11 20:46:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213701 +; + +-- Oct 11, 2018 8:46:18 PM SGT +ALTER TABLE A_Depreciation_Exp ADD C_AcctSchema_ID NUMBER(10) DEFAULT NULL +; + +-- Oct 11, 2018 8:46:18 PM SGT +ALTER TABLE A_Depreciation_Exp ADD CONSTRAINT CAcctSchema_ADepreciationExp FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Oct 11, 2018 8:55:01 PM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (205838,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53322,213701,'Y',0,260,0,'N','N','N','N',0,0,'Y',TO_DATE('2018-10-11 20:55:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-10-11 20:55:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','010b6a0d-e47f-4a41-a6f7-0368373a9e62','Y',260,1,1,1,'N','N','N') +; + +-- Oct 11, 2018 8:57:59 PM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (205839,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53162,213700,'Y',0,240,0,'N','N','N','N',0,0,'Y',TO_DATE('2018-10-11 20:57:59','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-10-11 20:57:59','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','266fd230-5a9e-4d4e-83d5-9a5a62c6b753','Y',230,1,1,1,'N','N','N') +; + +-- Oct 23, 2018 12:01:33 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:01:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59384 +; + +-- Oct 23, 2018 12:01:41 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:01:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59385 +; + +-- Oct 23, 2018 12:01:47 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:01:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59386 +; + +-- Oct 23, 2018 12:02:02 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:02:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59387 +; + +-- Oct 23, 2018 12:02:10 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:02:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59388 +; + +-- Oct 23, 2018 12:02:16 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-10-23 12:02:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59389 +; + +-- Oct 23, 2018 12:06:01 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:06:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59463 +; + +-- Oct 23, 2018 12:06:31 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:06:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59464 +; + +-- Oct 23, 2018 12:07:20 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:07:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59475 +; + +-- Oct 23, 2018 12:09:27 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:09:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59469 +; + +-- Oct 23, 2018 12:09:45 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:09:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59470 +; + +-- Oct 23, 2018 12:09:55 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_DATE('2018-10-23 12:09:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59478 +; + +SELECT register_migration_script('201904101655_IDEMPIERE-3947.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i6.2z/postgresql/201904101655_IDEMPIERE-3947.sql b/migration/i6.2z/postgresql/201904101655_IDEMPIERE-3947.sql new file mode 100644 index 0000000000..a7df2848aa --- /dev/null +++ b/migration/i6.2z/postgresql/201904101655_IDEMPIERE-3947.sql @@ -0,0 +1,90 @@ +-- Oct 11, 2018 8:41:01 PM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213700,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53116,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2018-10-11 20:40:59','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-10-11 20:40:59','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','c62177d9-97f4-4c03-bc74-05a9f5609c95','Y',0,'N','N','C') +; + +-- Oct 11, 2018 8:41:16 PM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_ADepreciationWorkf', FKConstraintType='C',Updated=TO_TIMESTAMP('2018-10-11 20:41:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213700 +; + +-- Oct 11, 2018 8:41:16 PM SGT +ALTER TABLE A_Depreciation_Workfile ADD COLUMN C_AcctSchema_ID NUMERIC(10) DEFAULT NULL +; + +-- Oct 11, 2018 8:41:17 PM SGT +ALTER TABLE A_Depreciation_Workfile ADD CONSTRAINT CAcctSchema_ADepreciationWorkf FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Oct 11, 2018 8:46:13 PM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType) VALUES (213701,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53115,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2018-10-11 20:46:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-10-11 20:46:12','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','b0851cce-d266-461b-a47c-4cf19ad6b3af','Y',0,'N','N','C') +; + +-- Oct 11, 2018 8:46:18 PM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_ADepreciationExp', FKConstraintType='C',Updated=TO_TIMESTAMP('2018-10-11 20:46:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213701 +; + +-- Oct 11, 2018 8:46:18 PM SGT +ALTER TABLE A_Depreciation_Exp ADD COLUMN C_AcctSchema_ID NUMERIC(10) DEFAULT NULL +; + +-- Oct 11, 2018 8:46:18 PM SGT +ALTER TABLE A_Depreciation_Exp ADD CONSTRAINT CAcctSchema_ADepreciationExp FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Oct 11, 2018 8:55:01 PM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (205838,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53322,213701,'Y',0,260,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-10-11 20:55:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-10-11 20:55:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','010b6a0d-e47f-4a41-a6f7-0368373a9e62','Y',260,1,1,1,'N','N','N') +; + +-- Oct 11, 2018 8:57:59 PM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (205839,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53162,213700,'Y',0,240,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-10-11 20:57:59','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-10-11 20:57:59','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','266fd230-5a9e-4d4e-83d5-9a5a62c6b753','Y',230,1,1,1,'N','N','N') +; + +-- Oct 23, 2018 12:01:33 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:01:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59384 +; + +-- Oct 23, 2018 12:01:41 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:01:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59385 +; + +-- Oct 23, 2018 12:01:47 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:01:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59386 +; + +-- Oct 23, 2018 12:02:02 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:02:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59387 +; + +-- Oct 23, 2018 12:02:10 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:02:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59388 +; + +-- Oct 23, 2018 12:02:16 PM SGT +UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-10-23 12:02:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59389 +; + +-- Oct 23, 2018 12:06:01 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:06:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59463 +; + +-- Oct 23, 2018 12:06:31 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:06:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59464 +; + +-- Oct 23, 2018 12:07:20 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:07:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59475 +; + +-- Oct 23, 2018 12:09:27 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:09:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59469 +; + +-- Oct 23, 2018 12:09:45 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:09:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59470 +; + +-- Oct 23, 2018 12:09:55 PM SGT +UPDATE AD_Column SET IsActive='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2018-10-23 12:09:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59478 +; + +SELECT register_migration_script('201904101655_IDEMPIERE-3947.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AssetAddition.java b/org.adempiere.base/src/org/compiere/acct/Doc_AssetAddition.java index 61e9924add..041df04f1f 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AssetAddition.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AssetAddition.java @@ -62,10 +62,10 @@ public class Doc_AssetAddition extends Doc return facts; } // - BigDecimal assetValueAmt = assetAdd.getAssetValueAmt(); + BigDecimal assetValueAmt = assetAdd.getAssetSourceAmt(); FactLine[] fls = FactUtil.createSimpleOperation(fact, null, - getA_Asset_Acct(), getP_Asset_Acct(as), - as.getC_Currency_ID(), + getA_Asset_Acct(as), getP_Asset_Acct(as), + getC_Currency_ID(), assetValueAmt, false); // Set BPartner and C_Project dimension for "Imobilizari in curs / Property Being" @@ -142,11 +142,11 @@ public class Doc_AssetAddition extends Doc return MAccount.get(getCtx(), acct_id); } - private MAccount getA_Asset_Acct() + private MAccount getA_Asset_Acct(MAcctSchema as) { MAssetAddition assetAdd = getAssetAddition(); int acct_id = MAssetAcct - .forA_Asset_ID(getCtx(), assetAdd.getA_Asset_ID(), assetAdd.getPostingType(), assetAdd.getDateAcct(), null) + .forA_Asset_ID(getCtx(), as.get_ID(), assetAdd.getA_Asset_ID(), assetAdd.getPostingType(), assetAdd.getDateAcct(), null) .getA_Asset_Acct(); return MAccount.get(getCtx(), acct_id); } diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AssetDisposed.java b/org.adempiere.base/src/org/compiere/acct/Doc_AssetDisposed.java index 5527c497ef..0d3b88a3fe 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AssetDisposed.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AssetDisposed.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import org.compiere.model.MAccount; import org.compiere.model.MAcctSchema; import org.compiere.model.MAssetAcct; +import org.compiere.model.MAssetChange; import org.compiere.model.MAssetDisposed; import org.compiere.model.MDocType; import org.compiere.util.Env; @@ -49,24 +50,25 @@ public class Doc_AssetDisposed extends Doc ArrayList facts = new ArrayList(); Fact fact = new Fact(this, as, assetDisp.getPostingType()); facts.add(fact); + MAssetChange ac = MAssetChange.get(getCtx(), assetDisp.getA_Asset_ID(), MAssetChange.CHANGETYPE_Disposal,getTrxName(), as.getC_AcctSchema_ID()); // - fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Asset_Acct) - , as.getC_Currency_ID() - , Env.ZERO, assetDisp.getA_Disposal_Amt()); - fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Accumdepreciation_Acct) - , as.getC_Currency_ID() - , assetDisp.getA_Accumulated_Depr_Delta(), Env.ZERO); - fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Disposal_Loss_Acct) - , as.getC_Currency_ID() - , assetDisp.getExpense(), Env.ZERO); + fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Asset_Acct, as) + , ac.getC_AcctSchema().getC_Currency_ID() + , Env.ZERO, ac.getAssetValueAmt()); + fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Accumdepreciation_Acct, as) + , ac.getC_AcctSchema().getC_Currency_ID() + , ac.getAssetAccumDepreciationAmt(), Env.ZERO); + fact.createLine(null, getAccount(MAssetAcct.COLUMNNAME_A_Disposal_Loss_Acct, as) + , ac.getC_AcctSchema().getC_Currency_ID() + , ac.getAssetBookValueAmt(), Env.ZERO); // return facts; } - private MAccount getAccount(String accountName) + private MAccount getAccount(String accountName, MAcctSchema as) { MAssetDisposed assetDisp = (MAssetDisposed)getPO(); - MAssetAcct assetAcct = MAssetAcct.forA_Asset_ID(getCtx(), assetDisp.getA_Asset_ID(), assetDisp.getPostingType(), assetDisp.getDateAcct(),null); + MAssetAcct assetAcct = MAssetAcct.forA_Asset_ID(getCtx(), as.get_ID(), assetDisp.getA_Asset_ID(), assetDisp.getPostingType(), assetDisp.getDateAcct(),null); int account_id = (Integer)assetAcct.get_Value(accountName); return MAccount.get(getCtx(), account_id); } diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AssetReval.java b/org.adempiere.base/src/org/compiere/acct/Doc_AssetReval.java index 7260f13f17..15ce596517 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AssetReval.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AssetReval.java @@ -29,7 +29,7 @@ public class Doc_AssetReval extends Doc public ArrayList createFacts(MAcctSchema as) { - MAssetAcct assetAcct = getAssetAcct(); + MAssetAcct assetAcct = getAssetAcct(as); MAssetReval assetRe = getAssetReval(); ArrayList facts = new ArrayList(); @@ -67,9 +67,9 @@ public class Doc_AssetReval extends Doc return POSTINGTYPE_Actual; } - private MAssetAcct getAssetAcct() + private MAssetAcct getAssetAcct(MAcctSchema as) { - return MAssetAcct.forA_Asset_ID(getCtx(), getA_Asset_ID(), getPostingType() , getDateAcct(), null); + return MAssetAcct.forA_Asset_ID(getCtx(),as.get_ID(), getA_Asset_ID(), getPostingType() , getDateAcct(), null); } private MAssetReval getAssetReval() { diff --git a/org.adempiere.base/src/org/compiere/model/I_A_Asset_Addition.java b/org.adempiere.base/src/org/compiere/model/I_A_Asset_Addition.java index d7f024b255..c43dcdf897 100644 --- a/org.adempiere.base/src/org/compiere/model/I_A_Asset_Addition.java +++ b/org.adempiere.base/src/org/compiere/model/I_A_Asset_Addition.java @@ -41,33 +41,6 @@ public interface I_A_Asset_Addition /** Load Meta Data */ - /** Column name A_Accumulated_Depr */ - public static final String COLUMNNAME_A_Accumulated_Depr = "A_Accumulated_Depr"; - - /** Set Accumulated Depreciation */ - public void setA_Accumulated_Depr (BigDecimal A_Accumulated_Depr); - - /** Get Accumulated Depreciation */ - public BigDecimal getA_Accumulated_Depr(); - - /** Column name A_Accumulated_Depr_Adjust */ - public static final String COLUMNNAME_A_Accumulated_Depr_Adjust = "A_Accumulated_Depr_Adjust"; - - /** Set Adjust Accumulated Depreciation */ - public void setA_Accumulated_Depr_Adjust (boolean A_Accumulated_Depr_Adjust); - - /** Get Adjust Accumulated Depreciation */ - public boolean isA_Accumulated_Depr_Adjust(); - - /** Column name A_Accumulated_Depr_F */ - public static final String COLUMNNAME_A_Accumulated_Depr_F = "A_Accumulated_Depr_F"; - - /** Set Accumulated Depreciation (fiscal) */ - public void setA_Accumulated_Depr_F (BigDecimal A_Accumulated_Depr_F); - - /** Get Accumulated Depreciation (fiscal) */ - public BigDecimal getA_Accumulated_Depr_F(); - /** Column name A_Asset_Addition_ID */ public static final String COLUMNNAME_A_Asset_Addition_ID = "A_Asset_Addition_ID"; @@ -158,15 +131,6 @@ public interface I_A_Asset_Addition /** Get Life periods (min) */ public int getA_Life_Period_Min(); - /** Column name A_Period_Start */ - public static final String COLUMNNAME_A_Period_Start = "A_Period_Start"; - - /** Set A_Period_Start */ - public void setA_Period_Start (int A_Period_Start); - - /** Get A_Period_Start */ - public int getA_Period_Start(); - /** Column name A_QTY_Current */ public static final String COLUMNNAME_A_QTY_Current = "A_QTY_Current"; @@ -385,28 +349,6 @@ public interface I_A_Asset_Addition */ public Timestamp getDateDoc(); - /** Column name DeltaUseLifeYears */ - public static final String COLUMNNAME_DeltaUseLifeYears = "DeltaUseLifeYears"; - - /** Set Delta Use Life Years */ - public void setDeltaUseLifeYears (int DeltaUseLifeYears); - - /** Get Delta Use Life Years */ - public int getDeltaUseLifeYears(); - - /** Column name DeltaUseLifeYears_F */ - public static final String COLUMNNAME_DeltaUseLifeYears_F = "DeltaUseLifeYears_F"; - - /** Set Delta Use Life Years (fiscal). - * Delta Use Life Years (fiscal) - */ - public void setDeltaUseLifeYears_F (int DeltaUseLifeYears_F); - - /** Get Delta Use Life Years (fiscal). - * Delta Use Life Years (fiscal) - */ - public int getDeltaUseLifeYears_F(); - /** Column name Description */ public static final String COLUMNNAME_Description = "Description"; diff --git a/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Exp.java b/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Exp.java index c894b1bca3..5c8fe76ce1 100644 --- a/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Exp.java +++ b/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Exp.java @@ -229,6 +229,21 @@ public interface I_A_Depreciation_Exp /** Get Asset Period */ public int getA_Period(); + /** Column name C_AcctSchema_ID */ + public static final String COLUMNNAME_C_AcctSchema_ID = "C_AcctSchema_ID"; + + /** Set Accounting Schema. + * Rules for accounting + */ + public void setC_AcctSchema_ID (int C_AcctSchema_ID); + + /** Get Accounting Schema. + * Rules for accounting + */ + public int getC_AcctSchema_ID(); + + public org.compiere.model.I_C_AcctSchema getC_AcctSchema() throws RuntimeException; + /** Column name CR_Account_ID */ public static final String COLUMNNAME_CR_Account_ID = "CR_Account_ID"; diff --git a/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Workfile.java b/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Workfile.java index be97a2472f..82f90ebd81 100644 --- a/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Workfile.java +++ b/org.adempiere.base/src/org/compiere/model/I_A_Depreciation_Workfile.java @@ -357,6 +357,21 @@ public interface I_A_Depreciation_Workfile /** Get Third contribution */ public BigDecimal getA_Valoare_Tert(); + /** Column name C_AcctSchema_ID */ + public static final String COLUMNNAME_C_AcctSchema_ID = "C_AcctSchema_ID"; + + /** Set Accounting Schema. + * Rules for accounting + */ + public void setC_AcctSchema_ID (int C_AcctSchema_ID); + + /** Get Accounting Schema. + * Rules for accounting + */ + public int getC_AcctSchema_ID(); + + public org.compiere.model.I_C_AcctSchema getC_AcctSchema() throws RuntimeException; + /** Column name Created */ public static final String COLUMNNAME_Created = "Created"; diff --git a/org.adempiere.base/src/org/compiere/model/MAsset.java b/org.adempiere.base/src/org/compiere/model/MAsset.java index 709abfe1b8..f27d6f230f 100644 --- a/org.adempiere.base/src/org/compiere/model/MAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MAsset.java @@ -100,7 +100,8 @@ public class MAsset extends X_A_Asset setIsOwned(true); setIsInPosession(true); setA_Asset_CreateDate(inoutLine.getM_InOut().getMovementDate()); - + //Fixed Asset should created in Organization as per the PO, MR, invoice and the asset addition document was recorded in. + setAD_Org_ID(invoiceLine.getAD_Org_ID()); // Asset Group: int A_Asset_Group_ID = invoiceLine.getA_Asset_Group_ID(); MProduct product = MProduct.get(getCtx(), invoiceLine.getM_Product_ID()); @@ -410,22 +411,25 @@ public class MAsset extends X_A_Asset // 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())) { - // Asset Accounting - MAssetAcct assetacct = new MAssetAcct(this, assetgrpacct); - assetacct.setAD_Org_ID(getAD_Org_ID()); //added by @win - assetacct.saveEx(); - - // Asset Depreciation Workfile - MDepreciationWorkfile assetwk = new MDepreciationWorkfile(this, assetacct.getPostingType(), assetgrpacct); - assetwk.setAD_Org_ID(getAD_Org_ID()); //added by @win - assetwk.setUseLifeYears(0); - assetwk.setUseLifeMonths(0); - assetwk.setUseLifeYears_F(0); - assetwk.setUseLifeMonths_F(0); - assetwk.saveEx(); - - // Change Log - MAssetChange.createAndSave(getCtx(), "CRT", new PO[]{this, assetwk, assetacct}, null); + if (assetgrpacct.getAD_Org_ID() == 0 || assetgrpacct.getAD_Org_ID() == getAD_Org_ID()) + { + // Asset Accounting + MAssetAcct assetacct = new MAssetAcct(this, assetgrpacct); + assetacct.setAD_Org_ID(getAD_Org_ID()); //added by @win + assetacct.saveEx(); + + // Asset Depreciation Workfile + MDepreciationWorkfile assetwk = new MDepreciationWorkfile(this, assetacct.getPostingType(), assetgrpacct); + assetwk.setAD_Org_ID(getAD_Org_ID()); //added by @win + assetwk.setUseLifeYears(assetgrpacct.getUseLifeYears()); + assetwk.setUseLifeMonths(assetgrpacct.getUseLifeMonths()); + assetwk.setUseLifeYears_F(assetgrpacct.getUseLifeYears_F()); + assetwk.setUseLifeMonths_F(assetgrpacct.getUseLifeMonths_F()); + assetwk.saveEx(); + + // Change Log + MAssetChange.createAndSave(getCtx(), "CRT", new PO[]{this, assetwk, assetacct}, null); + } } } diff --git a/org.adempiere.base/src/org/compiere/model/MAssetAcct.java b/org.adempiere.base/src/org/compiere/model/MAssetAcct.java index 68081eaee3..cc7cfa8ead 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetAcct.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetAcct.java @@ -74,13 +74,14 @@ public class MAssetAcct extends X_A_Asset_Acct * @param dateAcct check ValidFrom * @return asset accounting for the given asset */ - public static MAssetAcct forA_Asset_ID (Properties ctx, int A_Asset_ID, String postingType, Timestamp dateAcct, String trxName) + public static MAssetAcct forA_Asset_ID (Properties ctx, int C_AcctSchema_ID, int A_Asset_ID, String postingType, Timestamp dateAcct, String trxName) { // ArrayList params = new ArrayList(); - StringBuilder whereClause = new StringBuilder(COLUMNNAME_A_Asset_ID+"=? AND "+COLUMNNAME_PostingType+"=?"); + StringBuilder whereClause = new StringBuilder(COLUMNNAME_A_Asset_ID+"=? AND "+COLUMNNAME_PostingType+"=? AND " + COLUMNNAME_C_AcctSchema_ID +"=? " ); params.add(A_Asset_ID); params.add(postingType); + params.add(C_AcctSchema_ID); if (dateAcct != null) { whereClause.append(" AND " + COLUMNNAME_ValidFrom).append("<=?"); diff --git a/org.adempiere.base/src/org/compiere/model/MAssetAddition.java b/org.adempiere.base/src/org/compiere/model/MAssetAddition.java index a8d70bdb53..2f7c1d9deb 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetAddition.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetAddition.java @@ -122,9 +122,7 @@ public class MAssetAddition extends X_A_Asset_Addition MAsset asset = assetAdd.createAsset(); asset.dump(); //@win add - MAssetGroupAcct assetgrpacct = MAssetGroupAcct.forA_Asset_Group_ID(asset.getCtx(), asset.getA_Asset_Group_ID(), assetAdd.getPostingType()); - assetAdd.setDeltaUseLifeYears(assetgrpacct.getUseLifeYears()); - assetAdd.setDeltaUseLifeYears_F(assetgrpacct.getUseLifeYears_F()); + } else { assetAdd.setA_Asset_ID(match.getC_InvoiceLine().getA_Asset_ID()); assetAdd.setA_CreateAsset(false); @@ -179,10 +177,6 @@ public class MAssetAddition extends X_A_Asset_Addition asset.saveEx(); asset.dump(); - // Copy UseLife values from asset group to workfile - MAssetGroupAcct assetgrpacct = MAssetGroupAcct.forA_Asset_Group_ID(asset.getCtx(), asset.getA_Asset_Group_ID(), assetAdd.getPostingType()); - assetAdd.setDeltaUseLifeYears(assetgrpacct.getUseLifeYears()); - assetAdd.setDeltaUseLifeYears_F(assetgrpacct.getUseLifeYears_F()); assetAdd.setA_Asset(asset); assetAdd.saveEx(); //@win add @@ -262,8 +256,7 @@ public class MAssetAddition extends X_A_Asset_Addition setSourceAmt(project.getProjectBalanceAmt()); setDateDoc(new Timestamp (System.currentTimeMillis())); setA_CreateAsset(true); //added by @win as create from project will certainly for createnew - setDeltaUseLifeYears(I_ZERO); - setDeltaUseLifeYears_F(I_ZERO); + setC_DocType_ID(); Timestamp dateAcct = new Timestamp (System.currentTimeMillis()); @@ -304,14 +297,7 @@ public class MAssetAddition extends X_A_Asset_Addition setDateDoc(ifa.getAssetServiceDate()); setM_Locator_ID(ifa.getM_Locator_ID()); - boolean isAccmDeprAdjust = (ifa.getA_Accumulated_Depr().compareTo(Env.ZERO) > 0) ? true : false; - setA_Accumulated_Depr_Adjust(isAccmDeprAdjust); - setA_Period_Start(ifa.getA_Current_Period()); - - setA_Accumulated_Depr(ifa.getA_Accumulated_Depr()); - setA_Accumulated_Depr_F(ifa.getA_Accumulated_Depr_F()); - setDeltaUseLifeYears((int)(ifa.getUseLifeMonths() / 12)); - setDeltaUseLifeYears_F((int)(ifa.getUseLifeMonths_F() / 12)); + setA_CapvsExp(MAssetAddition.A_CAPVSEXP_Capital); //added by zuhri, import must be in Capital setA_CreateAsset(true); //added by zuhri, import must be create asset @@ -367,7 +353,8 @@ public class MAssetAddition extends X_A_Asset_Addition setC_Currency_ID(mi.getC_InvoiceLine().getC_Invoice().getC_Currency_ID()); setC_ConversionType_ID(mi.getC_InvoiceLine().getC_Invoice().getC_ConversionType_ID()); setDateDoc(mi.getM_InOutLine().getM_InOut().getMovementDate()); - setDateAcct(mi.getM_InOutLine().getM_InOut().getMovementDate()); + setDateAcct(mi.getDateAcct()); + setAD_Org_ID(mi.getAD_Org_ID()); m_cacheMatchInv.set(mi); } @@ -662,7 +649,11 @@ public class MAssetAddition extends X_A_Asset_Addition MDepreciationWorkfile assetwk = MDepreciationWorkfile.get(getCtx(), getA_Asset_ID(), getPostingType(), get_TrxName()); if (assetwk == null) { - assetwk = new MDepreciationWorkfile(asset, getPostingType(), null); + + for (MAssetGroupAcct assetgrpacct : MAssetGroupAcct.forA_Asset_Group_ID(getCtx(), asset.getA_Asset_Group_ID(), getPostingType())) + { + assetwk = new MDepreciationWorkfile(asset, getPostingType(), assetgrpacct); + } } if (log.isLoggable(Level.FINE)) log.fine("workfile: " + assetwk); // @@ -674,20 +665,53 @@ public class MAssetAddition extends X_A_Asset_Addition } */ // - // Do we have entries that are not processed and before this date: - if (this.getA_CapvsExp().equals(A_CAPVSEXP_Capital)) { - //@win modification to asset value and use life should be restricted to Capital - MDepreciationExp.checkExistsNotProcessedEntries(assetwk.getCtx(), assetwk.getA_Asset_ID(), getDateAcct(), assetwk.getPostingType(), assetwk.get_TrxName()); - // - if (this.getA_Salvage_Value().signum() > 0) { - assetwk.setA_Salvage_Value(this.getA_Salvage_Value()); - } - assetwk.adjustCost(getAssetValueAmt(), getA_QTY_Current(), isA_CreateAsset()); // reset if isA_CreateAsset - assetwk.adjustUseLife(getDeltaUseLifeYears(), getDeltaUseLifeYears_F(), isA_CreateAsset()); // reset if isA_CreateAsset - assetwk.setDateAcct(getDateAcct()); - assetwk.setProcessed(true); - assetwk.saveEx(); - } + for (MDepreciationWorkfile assetworkFile : MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName())) + { + assetworkFile.setDateAcct(getDateAcct()); + if (assetworkFile.getC_AcctSchema().getC_Currency_ID() != getC_Currency_ID()) + { + BigDecimal convertedAssetCost = MConversionRate.convert(getCtx(), getAssetSourceAmt(), + getC_Currency_ID(), assetworkFile.getC_AcctSchema().getC_Currency_ID() , + getDateAcct(), getC_ConversionType_ID(), + getAD_Client_ID(), getAD_Org_ID()); + assetworkFile.adjustCost(convertedAssetCost, getA_QTY_Current(), isA_CreateAsset()); // reset if isA_CreateAsset + } else { + assetworkFile.adjustCost(getAssetSourceAmt(), getA_QTY_Current(), isA_CreateAsset()); // reset if isA_CreateAsset + + } + // Do we have entries that are not processed and before this date: + if (this.getA_CapvsExp().equals(A_CAPVSEXP_Capital)) { + //@win modification to asset value and use life should be restricted to Capital + MDepreciationExp.checkExistsNotProcessedEntries(assetworkFile.getCtx(), assetworkFile.getA_Asset_ID(), getDateAcct(), assetworkFile.getPostingType(), assetworkFile.get_TrxName()); + // + if (this.getA_Salvage_Value().signum() > 0) { + if (assetworkFile.getC_AcctSchema().getC_Currency_ID() != getC_Currency_ID()) + { + BigDecimal salvageValue = MConversionRate.convert(getCtx(), this.getA_Salvage_Value(), + getC_Currency_ID(), assetworkFile.getC_AcctSchema().getC_Currency_ID() , + getDateAcct(), getC_ConversionType_ID(), + getAD_Client_ID(), getAD_Org_ID()); + assetworkFile.setA_Salvage_Value(salvageValue); + } else{ + assetworkFile.setA_Salvage_Value(this.getA_Salvage_Value()); + } + } + assetworkFile.setDateAcct(getDateAcct()); + assetworkFile.setProcessed(true); + assetworkFile.saveEx(); + } + //@win set initial depreciation period = 1 + if (isA_CreateAsset()) + { + assetworkFile.setA_Current_Period(1); + assetworkFile.saveEx(); + } + // + // Rebuild depreciation: + assetworkFile.buildDepreciation(); + } + + MAssetChange.createAddition(this, assetwk); // Setting locator if is CreateAsset @@ -707,24 +731,7 @@ public class MAssetAddition extends X_A_Asset_Addition asset.changeStatus(MAsset.A_ASSET_STATUS_Activated, getDateAcct()); asset.saveEx(); - //@win set initial depreciation period = 1 - if (isA_CreateAsset() && !isA_Accumulated_Depr_Adjust()) - { - assetwk.setA_Current_Period(1); - assetwk.saveEx(); - } - // - if (isA_Accumulated_Depr_Adjust()) - { - if (isA_CreateAsset() && isA_Accumulated_Depr_Adjust()) - { - assetwk.setA_Current_Period(getA_Period_Start()); - assetwk.setA_Accumulated_Depr(getA_Accumulated_Depr()); - assetwk.setA_Accumulated_Depr_F(getA_Accumulated_Depr_F()); - assetwk.saveEx(); - } - } // Accumulated depreciation (if any): /* @@ -752,8 +759,6 @@ public class MAssetAddition extends X_A_Asset_Addition } */ - // Rebuild depreciation: - assetwk.buildDepreciation(); // updateSourceDocument(false); @@ -827,7 +832,6 @@ public class MAssetAddition extends X_A_Asset_Addition // adjust the asset value assetwk.adjustCost(getAssetValueAmt().negate(), getA_QTY_Current().negate(), false); - assetwk.adjustUseLife(0 - getDeltaUseLifeYears(), 0 - getDeltaUseLifeYears_F(), false); assetwk.saveEx(); // @@ -1130,9 +1134,7 @@ public class MAssetAddition extends X_A_Asset_Addition public boolean hasZeroValues() { - return - getDeltaUseLifeYears() <= 0 || getDeltaUseLifeYears_F() <= 0 - || getDeltaUseLifeYears() != getDeltaUseLifeYears_F() || + return getAssetValueAmt().signum() <= 0 ; } diff --git a/org.adempiere.base/src/org/compiere/model/MAssetChange.java b/org.adempiere.base/src/org/compiere/model/MAssetChange.java index 8b6f93ade4..44c6dba37d 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetChange.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetChange.java @@ -147,4 +147,36 @@ public class MAssetChange extends X_A_Asset_Change if (log.isLoggable(Level.FINE)) log.fine("Leaving: po=" + po); } /** ARHIPAC: TEO: END ------------------------------------------------------------------ */ + + /** + * + * @param ctx + * @param A_Asset_ID + * @param postingType + * @param trxName + * @param Account Schema + * @return assetChange + * @see #get(Properties, int, String, String) + */ + public static MAssetChange get (Properties ctx, int A_Asset_ID, String changeType, String trxName, int C_AcctSchema_ID) + { + if (A_Asset_ID <= 0 || changeType == null) + { + return null; + } + + + final String whereClause = COLUMNNAME_A_Asset_ID+"=? AND " + +COLUMNNAME_ChangeType+"=? AND " + +COLUMNNAME_C_AcctSchema_ID + "=?" ; + + + MAssetChange ac = new Query(ctx, MAssetChange.Table_Name, whereClause, trxName) + .setParameters(new Object[]{A_Asset_ID, changeType,C_AcctSchema_ID}) + .firstOnly(); + + + + return ac; + } } // MAssetChange \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/MAssetDisposed.java b/org.adempiere.base/src/org/compiere/model/MAssetDisposed.java index 050311f78e..078701aa8f 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetDisposed.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetDisposed.java @@ -414,11 +414,40 @@ implements DocAction private void createDisposal() { - MDepreciationWorkfile assetwk = MDepreciationWorkfile.get(getCtx(), getA_Asset_ID(), getPostingType(), get_TrxName()); - assetwk.adjustCost(getA_Disposal_Amt().negate(), Env.ZERO, false); - assetwk.adjustAccumulatedDepr(getA_Accumulated_Depr_Delta().negate(), getA_Accumulated_Depr_Delta().negate(), false); - assetwk.saveEx(); - assetwk.buildDepreciation(); + for (MDepreciationWorkfile assetwk : MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName())) + { + BigDecimal disposalAmt = Env.ZERO; + BigDecimal accumDeprAmt = Env.ZERO; + if (assetwk.getC_AcctSchema().getC_Currency_ID() != getC_Currency_ID()) + { + disposalAmt = assetwk.getA_Asset_Cost(); + accumDeprAmt = assetwk.getA_Accumulated_Depr(); + } else + { + disposalAmt = getA_Disposal_Amt(); + accumDeprAmt = getA_Accumulated_Depr_Delta(); + } + + MAssetChange change = new MAssetChange (getCtx(), 0, get_TrxName()); + change.setAD_Org_ID(getAD_Org_ID()); + change.setA_Asset_ID(getA_Asset_ID()); + change.setChangeType(MAssetChange.CHANGETYPE_Disposal); + change.setTextDetails(MRefList.getListDescription (getCtx(),"A_Update_Type" , MAssetChange.CHANGETYPE_Disposal)); + change.setPostingType(assetwk.getPostingType()); + change.setAssetValueAmt(disposalAmt); + change.setAssetBookValueAmt(assetwk.getA_Asset_Remaining()); + change.setAssetAccumDepreciationAmt(accumDeprAmt); + change.setA_QTY_Current(assetwk.getA_QTY_Current()); + change.setC_AcctSchema_ID(assetwk.getC_AcctSchema_ID()); + change.setAssetDisposalDate(getA_Disposed_Date()); + change.setIsDisposed(true); + change.saveEx(get_TrxName()); + + assetwk.adjustCost(disposalAmt.negate(), Env.ZERO, false); + assetwk.adjustAccumulatedDepr(accumDeprAmt.negate(), accumDeprAmt.negate(), false); + assetwk.saveEx(); + assetwk.buildDepreciation(); + } // // Delete not processed expense entries List list = MDepreciationExp.getNotProcessedEntries(getCtx(), getA_Asset_ID(), getPostingType(), get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MAssetGroupAcct.java b/org.adempiere.base/src/org/compiere/model/MAssetGroupAcct.java index a3c588f90f..39530adb7b 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetGroupAcct.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetGroupAcct.java @@ -35,12 +35,12 @@ public class MAssetGroupAcct extends X_A_Asset_Group_Acct /** * Get Asset Group Accountings for given group */ - public static MAssetGroupAcct forA_Asset_Group_ID(Properties ctx, int A_Asset_Group_ID, String postingType) + public static List 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}) - .firstOnly(); + .list(); } /** @@ -138,4 +138,17 @@ public class MAssetGroupAcct extends X_A_Asset_Group_Acct return false; return is_ValueChanged(index); } + /** + * Get Asset Group Accountings for given group + */ + public static MAssetGroupAcct forA_Asset_Group_ID(Properties ctx, int A_Asset_Group_ID, String postingType, + int C_AcctSchema_ID) { + final String whereClause = COLUMNNAME_A_Asset_Group_ID+"=? AND "+COLUMNNAME_PostingType+"=? AND " + COLUMNNAME_C_AcctSchema_ID +"=? " ; + return new Query(ctx, Table_Name, whereClause, null) + .setParameters(new Object[]{A_Asset_Group_ID, postingType, C_AcctSchema_ID}) + .firstOnly(); + } + + + } // MAssetGroupAcct diff --git a/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java b/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java index fd67fe9689..0aa7da5027 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java @@ -142,7 +142,7 @@ implements DocAction } // Check if the accounts have changed in the meantime - MAssetAcct assetAcct = MAssetAcct.forA_Asset_ID(getCtx(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); + MAssetAcct assetAcct = MAssetAcct.forA_Asset_ID(getCtx(), getC_AcctSchema_ID(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); if (assetAcct.getA_Asset_Acct() != getA_Asset_Acct() || assetAcct.getA_Accumdepreciation_Acct() != getA_Accumdepreciation_Acct() || assetAcct.getA_Depreciation_Acct() != getA_Depreciation_Acct() @@ -154,7 +154,7 @@ implements DocAction } //Check that at least one account is changed { - MAssetAcct acct = MAssetAcct.forA_Asset_ID(getCtx(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); + MAssetAcct acct = MAssetAcct.forA_Asset_ID(getCtx(), getC_AcctSchema_ID(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); if (acct.getA_Asset_Acct() == getA_Asset_New_Acct() && acct.getA_Accumdepreciation_Acct() == getA_Accumdepreciation_New_Acct() && acct.getA_Depreciation_Acct() == getA_Depreciation_New_Acct() @@ -205,7 +205,7 @@ implements DocAction // create new MAssetAcct - MAssetAcct assetAcctPrev = MAssetAcct.forA_Asset_ID(getCtx(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); + MAssetAcct assetAcctPrev = MAssetAcct.forA_Asset_ID(getCtx(), getC_AcctSchema_ID(), getA_Asset_ID(), getPostingType(), getDateAcct(), get_TrxName()); MAssetAcct assetAcct = new MAssetAcct(getCtx(), 0, get_TrxName()); PO.copyValues(assetAcctPrev, assetAcct); assetAcct.setA_Asset_Acct(getA_Asset_New_Acct()); diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationEntry.java b/org.adempiere.base/src/org/compiere/model/MDepreciationEntry.java index 0fc1f397b4..ca8f5f86b4 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationEntry.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationEntry.java @@ -72,7 +72,7 @@ implements DocAction { return false; } - if (!isProcessed() && (newRecord || is_ValueChanged(COLUMNNAME_DateAcct))) + if (!isProcessed() && (newRecord || is_ValueChanged(COLUMNNAME_DateAcct) || is_ValueChanged(COLUMNNAME_C_AcctSchema_ID))) { selectLines(); } @@ -126,10 +126,11 @@ implements DocAction + " WHERE " + MDepreciationExp.COLUMNNAME_A_Depreciation_Entry_ID + " IS NULL" + " AND TRUNC("+MDepreciationExp.COLUMNNAME_DateAcct+",'MONTH') = ?" - + " AND AD_Client_ID=? AND AD_Org_ID=?"; + + " AND AD_Client_ID=? AND AD_Org_ID=?" + + " AND " + MDepreciationExp.COLUMNNAME_C_AcctSchema_ID +"=?" ; ; Timestamp dateAcct = TimeUtil.trunc(getDateAcct(), TimeUtil.TRUNC_MONTH); - int no = DB.executeUpdateEx(sql, new Object[]{get_ID(), dateAcct, getAD_Client_ID(), getAD_Org_ID()}, get_TrxName()); + int no = DB.executeUpdateEx(sql, new Object[]{get_ID(), dateAcct, getAD_Client_ID(), getAD_Org_ID(), getC_AcctSchema_ID()}, get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Updated #" + no); } @@ -140,8 +141,9 @@ implements DocAction { final String trxName = get_TrxName(); final List params = new ArrayList(); - String whereClause = MDepreciationExp.COLUMNNAME_A_Depreciation_Entry_ID+"=?"; + String whereClause = MDepreciationExp.COLUMNNAME_A_Depreciation_Entry_ID+"=? AND " + MDepreciationExp.COLUMNNAME_C_AcctSchema_ID + "=?" ; params.add(get_ID()); + params.add(getC_AcctSchema_ID()); if (onlyNotProcessed) { diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationExp.java b/org.adempiere.base/src/org/compiere/model/MDepreciationExp.java index a25e039b0d..58098faf65 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationExp.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationExp.java @@ -92,6 +92,7 @@ public class MDepreciationExp extends X_A_Depreciation_Exp depexp.setA_Period(A_Period); depexp.setIsDepreciated(true); depexp.setDateAcct(DateAcct); + depexp.setC_AcctSchema_ID(assetwk.getC_AcctSchema_ID()); // depexp.updateFrom(assetwk); // @@ -114,11 +115,6 @@ public class MDepreciationExp extends X_A_Depreciation_Exp setA_Asset_Remaining_F(wk.getA_Asset_Remaining_F()); } - private MDepreciationWorkfile getA_Depreciation_Workfile() - { - return MDepreciationWorkfile.get(getCtx(), getA_Asset_ID(), getPostingType(), get_TrxName()); - } - /** Create Depreciation Entries * Produce record: *
@@ -171,7 +167,7 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
 		}
 		
 		//
-		MDepreciationWorkfile assetwk = getA_Depreciation_Workfile();
+		MDepreciationWorkfile assetwk = MDepreciationWorkfile.get(getCtx(), getA_Asset_ID(), getPostingType(),get_TrxName(), getC_AcctSchema_ID());
 		if (assetwk == null)
 		{
 			throw new AssetException("@NotFound@ @A_Depreciation_Workfile_ID@");
@@ -188,8 +184,12 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
 				throw new AssetNotActiveException(assetwk.getAsset().get_ID());
 			}
 			//
-			setDateAcct(assetwk.getDateAcct());
 			assetwk.adjustAccumulatedDepr(getExpense(), getExpense_F(), false);
+			// Update workfile - Remaining asset cost
+			assetwk.setA_Current_Period();
+			assetwk.saveEx();
+			//adjust to the last day of the month in before save assetwk.
+			setDateAcct(assetwk.getDateAcct());
 		}
 		else
 		{
@@ -201,9 +201,7 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
 		saveEx();
 
 		//
-		// Update workfile
-		assetwk.setA_Current_Period();
-		assetwk.saveEx();
+		
 	}
 	
 	
@@ -211,10 +209,13 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
 	{
 		if (isProcessed())
 		{
-			// TODO : check if we can reverse it (check period, check dateacct etc)
-			MDepreciationWorkfile assetwk = getA_Depreciation_Workfile();
-			assetwk.adjustAccumulatedDepr(getA_Accumulated_Depr().negate(), getA_Accumulated_Depr_F().negate(), false);
-			assetwk.saveEx();
+			Collection workFiles = MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName());
+			for(MDepreciationWorkfile assetwk : workFiles) {	
+				// TODO : check if we can reverse it (check period, check dateacct etc)
+				//MDepreciationWorkfile assetwk = getA_Depreciation_Workfile();
+				assetwk.adjustAccumulatedDepr(getA_Accumulated_Depr().negate(), getA_Accumulated_Depr_F().negate(), false);
+				assetwk.saveEx();
+			}
 		}
 		// Try to delete postings
 		if (isPosted())
@@ -236,9 +237,12 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
 		// If it was processed, we need to update workfile's current period
 		if (isProcessed())
 		{
-			MDepreciationWorkfile wk = getA_Depreciation_Workfile();
-			wk.setA_Current_Period();
-			wk.saveEx();
+			Collection workFiles = MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName());
+			for(MDepreciationWorkfile wk : workFiles) {	
+				//MDepreciationWorkfile wk = getA_Depreciation_Workfile();
+				wk.setA_Current_Period();
+				wk.saveEx();
+			}
 		}
 		//
 		return true;
diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java
index 6d7b34e866..880f8ae226 100644
--- a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java
+++ b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java
@@ -205,9 +205,13 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 			return false;
 		}
 		
+		Collection workFiles = MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName());
+		for(MDepreciationWorkfile assetwk : workFiles) {	
 		// check if is fully depreciated
-		BigDecimal remainingAmt_C = getRemainingCost(null, false);
-		BigDecimal remainingAmt_F = getRemainingCost(null, true);
+			BigDecimal remainingAmt_C = assetwk.getA_Depreciation_Workfile_ID() == getA_Depreciation_Workfile_ID() 
+					? getRemainingCost(null, false) : assetwk.getRemainingCost(null, false);
+			BigDecimal remainingAmt_F = assetwk.getA_Depreciation_Workfile_ID() == getA_Depreciation_Workfile_ID()
+					? getRemainingCost(null, true) : assetwk.getRemainingCost(null, true);
 		if(remainingAmt_C.signum() == 0 && remainingAmt_F.signum() == 0)
 		{
 			//if A_Asset_Cost is 0 have a voided addition, in this case asset is not full depreciated 
@@ -215,11 +219,14 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 			{
 			 return false;	
 			}
-			//
-			return true;
+		}
+			else
+			{
+				return false;
+			}
 		}
 		
-		return false;
+		return true;
 	}
 	
 	/**
@@ -228,6 +235,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 	public MDepreciationWorkfile(MAsset asset, String postingType, MAssetGroupAcct assetgrpacct)
 	{
 		this(asset.getCtx(), 0, asset.get_TrxName());
+		setC_AcctSchema_ID(assetgrpacct.getC_AcctSchema_ID());
 		setA_Asset_ID(asset.getA_Asset_ID());
 		setAD_Org_ID(asset.getAD_Org_ID()); //@win added
 		setA_Asset_Cost(asset.getA_Asset_Cost());
@@ -239,10 +247,6 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 		setPostingType(postingType);
 		//
 		// Copy UseLife values from asset group to workfile
-		if (assetgrpacct == null)
-		{
-			assetgrpacct = MAssetGroupAcct.forA_Asset_Group_ID(asset.getCtx(), asset.getA_Asset_Group_ID(), postingType);
-		}
 		UseLifeImpl.copyValues(this, assetgrpacct);
 		
 		//
@@ -291,14 +295,16 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 	}
 	
 	/**
-	 * Get/load workfile from cache (if trxName is null)
+	 * 
 	 * @param ctx
 	 * @param A_Asset_ID
 	 * @param postingType
 	 * @param trxName
+	 * @param Account Schema
 	 * @return workfile
+	 * @see #get(Properties, int, String, String)
 	 */
-	public static MDepreciationWorkfile get (Properties ctx, int A_Asset_ID, String postingType, String trxName)
+	public static MDepreciationWorkfile get (Properties ctx, int A_Asset_ID, String postingType,  String trxName, int C_AcctSchema_ID)
 	{
 		if (A_Asset_ID <= 0 || postingType == null)
 		{
@@ -320,9 +326,11 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 											.firstOnly();
 		*/
 		final String whereClause = COLUMNNAME_A_Asset_ID+"=?"
-									+" AND "+COLUMNNAME_PostingType+"=? ";
+									+" AND "+COLUMNNAME_PostingType+"=? AND " +  COLUMNNAME_C_AcctSchema_ID + "=?" ;
+
+		int acctSchemaId =  C_AcctSchema_ID==0 ? MClient.get(ctx).getAcctSchema().get_ID() : C_AcctSchema_ID;
 		MDepreciationWorkfile wk = new Query(ctx, MDepreciationWorkfile.Table_Name, whereClause, trxName)
-				.setParameters(new Object[]{A_Asset_ID, postingType})
+				.setParameters(new Object[]{A_Asset_ID, postingType,acctSchemaId})
 				.firstOnly();
 		
 		
@@ -332,6 +340,19 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 		}
 		return wk;
 	}
+	
+	/**
+	 * Get/load workfile from cache (if trxName is null)
+	 * @param ctx
+	 * @param A_Asset_ID
+	 * @param postingType
+	 * @param trxName
+	 * @return workfile
+	 */
+	public static MDepreciationWorkfile get (Properties ctx, int A_Asset_ID, String postingType, String trxName)
+	{
+		return get(ctx, A_Asset_ID, postingType, trxName, 0);		
+	}
 	/** Static cache: Asset/PostingType -> Workfile */
 	private static CCache
 	s_cacheAsset = new CCache(Table_Name, Table_Name+"_Asset", 10); 
@@ -362,7 +383,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 	 */
 	public MAssetAcct getA_AssetAcct(Timestamp dateAcct, String trxName)
 	{
-		return MAssetAcct.forA_Asset_ID(getCtx(), getA_Asset_ID(), getPostingType(), dateAcct, trxName);
+		return MAssetAcct.forA_Asset_ID(getCtx(), getC_AcctSchema_ID(), getA_Asset_ID(), getPostingType(), dateAcct, trxName);
 	}
 
 	/**	Returns the current cost of FAs. It is calculated as the difference between acquisition value and the value that you (A_Salvage_Value)
@@ -562,10 +583,11 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 		String whereClause = MDepreciationExp.COLUMNNAME_A_Asset_ID+"=?"
 					+" AND "+MDepreciationExp.COLUMNNAME_PostingType+"=?"
 					+" AND "+MDepreciationExp.COLUMNNAME_Processed+"=? AND IsActive=?"
+					+" AND "+MDepreciationExp.COLUMNNAME_C_AcctSchema_ID+"=?"
 		;
 		//
 		MDepreciationExp depexp = new Query(getCtx(), MDepreciationExp.Table_Name, whereClause, get_TrxName())
-									.setParameters(new Object[]{getA_Asset_ID(), getPostingType(), true, true})
+									.setParameters(new Object[]{getA_Asset_ID(), getPostingType(), true, true, getC_AcctSchema_ID()})
 									.setOrderBy(MDepreciationExp.COLUMNNAME_A_Period+" DESC"
 												+","+MDepreciationExp.COLUMNNAME_DateAcct+" DESC")
 									.first();
@@ -701,8 +723,9 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
 							+" AND "+MDepreciationExp.COLUMNNAME_A_Period+">=?"
 							+" AND "+MDepreciationExp.COLUMNNAME_A_Asset_ID+"=?"
 							+" AND "+MDepreciationExp.COLUMNNAME_PostingType+"=?"
+							+" AND "+MDepreciationExp.COLUMNNAME_C_AcctSchema_ID+"=?"
 		;
-		Object[] params = new Object[]{false, A_Current_Period, getA_Asset_ID(), getPostingType()};
+		Object[] params = new Object[]{false, A_Current_Period, getA_Asset_ID(), getPostingType(), getC_AcctSchema_ID()};
 		int no = DB.executeUpdateEx(sql, params, trxName);
 		if (log.isLoggable(Level.FINE)) log.fine("sql=" + sql + "\nDeleted #" + no);
 	}	//	truncDepreciation
diff --git a/org.adempiere.base/src/org/compiere/model/X_A_Asset_Addition.java b/org.adempiere.base/src/org/compiere/model/X_A_Asset_Addition.java
index d8a0c78954..1521549c77 100644
--- a/org.adempiere.base/src/org/compiere/model/X_A_Asset_Addition.java
+++ b/org.adempiere.base/src/org/compiere/model/X_A_Asset_Addition.java
@@ -33,7 +33,7 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
 	/**
 	 *
 	 */
-	private static final long serialVersionUID = 20190106L;
+	private static final long serialVersionUID = 20190409L;
 
     /** Standard Constructor */
     public X_A_Asset_Addition (Properties ctx, int A_Asset_Addition_ID, String trxName)
@@ -41,20 +41,12 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
       super (ctx, A_Asset_Addition_ID, trxName);
       /** if (A_Asset_Addition_ID == 0)
         {
-			setA_Accumulated_Depr (Env.ZERO);
-// 0
-			setA_Accumulated_Depr_Adjust (false);
-// N
-			setA_Accumulated_Depr_F (Env.ZERO);
-// 0
 			setA_Asset_Addition_ID (0);
 			setA_Asset_ID (0);
 			setA_CapvsExp (null);
 // 'Cap'
 			setA_CreateAsset (false);
 // 'N'
-			setA_Period_Start (0);
-// 0
 			setA_QTY_Current (Env.ZERO);
 // 0
 			setA_SourceType (null);
@@ -66,10 +58,6 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
 			setC_Currency_ID (0);
 			setDateDoc (new Timestamp( System.currentTimeMillis() ));
 // @#Date@
-			setDeltaUseLifeYears (0);
-// 0
-			setDeltaUseLifeYears_F (0);
-// 0
 			setDocStatus (null);
 // 'DR'
 			setIsApproved (false);
@@ -111,61 +99,6 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
       return sb.toString();
     }
 
-	/** Set Accumulated Depreciation.
-		@param A_Accumulated_Depr Accumulated Depreciation	  */
-	public void setA_Accumulated_Depr (BigDecimal A_Accumulated_Depr)
-	{
-		set_Value (COLUMNNAME_A_Accumulated_Depr, A_Accumulated_Depr);
-	}
-
-	/** Get Accumulated Depreciation.
-		@return Accumulated Depreciation	  */
-	public BigDecimal getA_Accumulated_Depr () 
-	{
-		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_A_Accumulated_Depr);
-		if (bd == null)
-			 return Env.ZERO;
-		return bd;
-	}
-
-	/** Set Adjust Accumulated Depreciation.
-		@param A_Accumulated_Depr_Adjust Adjust Accumulated Depreciation	  */
-	public void setA_Accumulated_Depr_Adjust (boolean A_Accumulated_Depr_Adjust)
-	{
-		set_Value (COLUMNNAME_A_Accumulated_Depr_Adjust, Boolean.valueOf(A_Accumulated_Depr_Adjust));
-	}
-
-	/** Get Adjust Accumulated Depreciation.
-		@return Adjust Accumulated Depreciation	  */
-	public boolean isA_Accumulated_Depr_Adjust () 
-	{
-		Object oo = get_Value(COLUMNNAME_A_Accumulated_Depr_Adjust);
-		if (oo != null) 
-		{
-			 if (oo instanceof Boolean) 
-				 return ((Boolean)oo).booleanValue(); 
-			return "Y".equals(oo);
-		}
-		return false;
-	}
-
-	/** Set Accumulated Depreciation (fiscal).
-		@param A_Accumulated_Depr_F Accumulated Depreciation (fiscal)	  */
-	public void setA_Accumulated_Depr_F (BigDecimal A_Accumulated_Depr_F)
-	{
-		set_Value (COLUMNNAME_A_Accumulated_Depr_F, A_Accumulated_Depr_F);
-	}
-
-	/** Get Accumulated Depreciation (fiscal).
-		@return Accumulated Depreciation (fiscal)	  */
-	public BigDecimal getA_Accumulated_Depr_F () 
-	{
-		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_A_Accumulated_Depr_F);
-		if (bd == null)
-			 return Env.ZERO;
-		return bd;
-	}
-
 	/** Set Asset Addition.
 		@param A_Asset_Addition_ID Asset Addition	  */
 	public void setA_Asset_Addition_ID (int A_Asset_Addition_ID)
@@ -302,23 +235,6 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
 		return ii.intValue();
 	}
 
-	/** Set A_Period_Start.
-		@param A_Period_Start A_Period_Start	  */
-	public void setA_Period_Start (int A_Period_Start)
-	{
-		set_Value (COLUMNNAME_A_Period_Start, Integer.valueOf(A_Period_Start));
-	}
-
-	/** Get A_Period_Start.
-		@return A_Period_Start	  */
-	public int getA_Period_Start () 
-	{
-		Integer ii = (Integer)get_Value(COLUMNNAME_A_Period_Start);
-		if (ii == null)
-			 return 0;
-		return ii.intValue();
-	}
-
 	/** Set Current Qty.
 		@param A_QTY_Current Current Qty	  */
 	public void setA_QTY_Current (BigDecimal A_QTY_Current)
@@ -684,43 +600,6 @@ public class X_A_Asset_Addition extends PO implements I_A_Asset_Addition, I_Pers
 		return (Timestamp)get_Value(COLUMNNAME_DateDoc);
 	}
 
-	/** Set Delta Use Life Years.
-		@param DeltaUseLifeYears Delta Use Life Years	  */
-	public void setDeltaUseLifeYears (int DeltaUseLifeYears)
-	{
-		set_Value (COLUMNNAME_DeltaUseLifeYears, Integer.valueOf(DeltaUseLifeYears));
-	}
-
-	/** Get Delta Use Life Years.
-		@return Delta Use Life Years	  */
-	public int getDeltaUseLifeYears () 
-	{
-		Integer ii = (Integer)get_Value(COLUMNNAME_DeltaUseLifeYears);
-		if (ii == null)
-			 return 0;
-		return ii.intValue();
-	}
-
-	/** Set Delta Use Life Years (fiscal).
-		@param DeltaUseLifeYears_F 
-		Delta Use Life Years (fiscal)
-	  */
-	public void setDeltaUseLifeYears_F (int DeltaUseLifeYears_F)
-	{
-		set_Value (COLUMNNAME_DeltaUseLifeYears_F, Integer.valueOf(DeltaUseLifeYears_F));
-	}
-
-	/** Get Delta Use Life Years (fiscal).
-		@return Delta Use Life Years (fiscal)
-	  */
-	public int getDeltaUseLifeYears_F () 
-	{
-		Integer ii = (Integer)get_Value(COLUMNNAME_DeltaUseLifeYears_F);
-		if (ii == null)
-			 return 0;
-		return ii.intValue();
-	}
-
 	/** Set Description.
 		@param Description 
 		Optional short description of the record
diff --git a/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Exp.java b/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Exp.java
index 64252b381f..633cb32632 100644
--- a/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Exp.java
+++ b/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Exp.java
@@ -33,7 +33,7 @@ public class X_A_Depreciation_Exp extends PO implements I_A_Depreciation_Exp, I_
 	/**
 	 *
 	 */
-	private static final long serialVersionUID = 20190106L;
+	private static final long serialVersionUID = 20190409L;
 
     /** Standard Constructor */
     public X_A_Depreciation_Exp (Properties ctx, int A_Depreciation_Exp_ID, String trxName)
@@ -438,6 +438,34 @@ public class X_A_Depreciation_Exp extends PO implements I_A_Depreciation_Exp, I_
 		return ii.intValue();
 	}
 
+	public org.compiere.model.I_C_AcctSchema getC_AcctSchema() throws RuntimeException
+    {
+		return (org.compiere.model.I_C_AcctSchema)MTable.get(getCtx(), org.compiere.model.I_C_AcctSchema.Table_Name)
+			.getPO(getC_AcctSchema_ID(), get_TrxName());	}
+
+	/** Set Accounting Schema.
+		@param C_AcctSchema_ID 
+		Rules for accounting
+	  */
+	public void setC_AcctSchema_ID (int C_AcctSchema_ID)
+	{
+		if (C_AcctSchema_ID < 1) 
+			set_ValueNoCheck (COLUMNNAME_C_AcctSchema_ID, null);
+		else 
+			set_ValueNoCheck (COLUMNNAME_C_AcctSchema_ID, Integer.valueOf(C_AcctSchema_ID));
+	}
+
+	/** Get Accounting Schema.
+		@return Rules for accounting
+	  */
+	public int getC_AcctSchema_ID () 
+	{
+		Integer ii = (Integer)get_Value(COLUMNNAME_C_AcctSchema_ID);
+		if (ii == null)
+			 return 0;
+		return ii.intValue();
+	}
+
 	public I_C_ValidCombination getCR_Account() throws RuntimeException
     {
 		return (I_C_ValidCombination)MTable.get(getCtx(), I_C_ValidCombination.Table_Name)
diff --git a/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Workfile.java b/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Workfile.java
index fb5af0cadf..7f89eba3fb 100644
--- a/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Workfile.java
+++ b/org.adempiere.base/src/org/compiere/model/X_A_Depreciation_Workfile.java
@@ -33,7 +33,7 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
 	/**
 	 *
 	 */
-	private static final long serialVersionUID = 20190106L;
+	private static final long serialVersionUID = 20190409L;
 
     /** Standard Constructor */
     public X_A_Depreciation_Workfile (Properties ctx, int A_Depreciation_Workfile_ID, String trxName)
@@ -666,6 +666,34 @@ public class X_A_Depreciation_Workfile extends PO implements I_A_Depreciation_Wo
 		return bd;
 	}
 
+	public org.compiere.model.I_C_AcctSchema getC_AcctSchema() throws RuntimeException
+    {
+		return (org.compiere.model.I_C_AcctSchema)MTable.get(getCtx(), org.compiere.model.I_C_AcctSchema.Table_Name)
+			.getPO(getC_AcctSchema_ID(), get_TrxName());	}
+
+	/** Set Accounting Schema.
+		@param C_AcctSchema_ID 
+		Rules for accounting
+	  */
+	public void setC_AcctSchema_ID (int C_AcctSchema_ID)
+	{
+		if (C_AcctSchema_ID < 1) 
+			set_ValueNoCheck (COLUMNNAME_C_AcctSchema_ID, null);
+		else 
+			set_ValueNoCheck (COLUMNNAME_C_AcctSchema_ID, Integer.valueOf(C_AcctSchema_ID));
+	}
+
+	/** Get Accounting Schema.
+		@return Rules for accounting
+	  */
+	public int getC_AcctSchema_ID () 
+	{
+		Integer ii = (Integer)get_Value(COLUMNNAME_C_AcctSchema_ID);
+		if (ii == null)
+			 return 0;
+		return ii.intValue();
+	}
+
 	/** Set Account Date.
 		@param DateAcct 
 		Accounting Date
diff --git a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Addition.java b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Addition.java
index 5796e05d46..0fb613dfcc 100644
--- a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Addition.java
+++ b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Addition.java
@@ -60,22 +60,15 @@ public class CalloutA_Asset_Addition extends CalloutEngine
 	{
 		if (isCalloutActive())
 			return "";
-		//
-		String columnName = mField.getColumnName();
-		if (MAssetAddition.COLUMNNAME_A_Accumulated_Depr.equals(columnName))
-		{
-			mTab.setValue(MAssetAddition.COLUMNNAME_A_Accumulated_Depr_F, value);
-		}
-		else
-		{
-			BigDecimal amtEntered = (BigDecimal) mTab.getValue(MAssetAddition.COLUMNNAME_AssetAmtEntered);
-			mTab.setValue(MAssetAddition.COLUMNNAME_AssetSourceAmt, amtEntered);
-			MConversionRateUtil.convertBase(SetGetUtil.wrap(mTab),
-					MAssetAddition.COLUMNNAME_DateAcct,
-					MAssetAddition.COLUMNNAME_AssetSourceAmt,
-					MAssetAddition.COLUMNNAME_AssetValueAmt,
-					mField.getColumnName());
-		}
+		//		
+		BigDecimal amtEntered = (BigDecimal) mTab.getValue(MAssetAddition.COLUMNNAME_AssetAmtEntered);
+		mTab.setValue(MAssetAddition.COLUMNNAME_AssetSourceAmt, amtEntered);
+		MConversionRateUtil.convertBase(SetGetUtil.wrap(mTab),
+				MAssetAddition.COLUMNNAME_DateAcct,
+				MAssetAddition.COLUMNNAME_AssetSourceAmt,
+				MAssetAddition.COLUMNNAME_AssetValueAmt,
+				mField.getColumnName());
+		
 		//
 		return "";
 	}
@@ -91,10 +84,7 @@ public class CalloutA_Asset_Addition extends CalloutEngine
 	
 	public String uselife(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
 	{
-		if (MAssetAddition.COLUMNNAME_DeltaUseLifeYears.equals(mField.getColumnName()))
-		{
-			mTab.setValue(MAssetAddition.COLUMNNAME_DeltaUseLifeYears_F, value);
-		}
+		
 		return "";
 	}
 	
@@ -102,10 +92,7 @@ public class CalloutA_Asset_Addition extends CalloutEngine
 	public String periodOffset(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
 	{
 		I_A_Asset_Addition aa = GridTabWrapper.create(mTab, I_A_Asset_Addition.class);
-		if (!aa.isA_Accumulated_Depr_Adjust())
-		{
-			return "";
-		}
+	
 		
 		int periods = TimeUtil.getMonthsBetween(aa.getDateDoc(), aa.getDateAcct());
 		if (periods <= 0)
@@ -113,16 +100,7 @@ public class CalloutA_Asset_Addition extends CalloutEngine
 			return "";
 		}
 		
-		int uselifeMonths = aa.getDeltaUseLifeYears() * 12;
-		if (uselifeMonths == 0)
-		{
-			return "";
-		}
-		double monthlyExpenseSL = aa.getAssetValueAmt().doubleValue() / uselifeMonths * periods;
 		
-		aa.setA_Period_Start(periods + 1);
-		aa.setA_Accumulated_Depr(BigDecimal.valueOf(monthlyExpenseSL));
-		aa.setA_Accumulated_Depr_F(BigDecimal.valueOf(monthlyExpenseSL));
 		
 		return "";
 	}
diff --git a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Transfer.java b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Transfer.java
index 01bcade2ab..d96ed6a5d3 100644
--- a/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Transfer.java
+++ b/org.adempiere.base/src/org/idempiere/fa/model/CalloutA_Asset_Transfer.java
@@ -32,7 +32,7 @@ public class CalloutA_Asset_Transfer extends CalloutEngine
 	    {
 	    	return "";
 	    }
-    	MAssetAcct acct = MAssetAcct.forA_Asset_ID(ctx, model.getA_Asset_ID(), model.getPostingType(), model.getDateAcct(), null);
+    	MAssetAcct acct = MAssetAcct.forA_Asset_ID(ctx,model.getC_AcctSchema_ID(),  model.getA_Asset_ID(), model.getPostingType(), model.getDateAcct(), null);
     	if (acct == null)
     	{
     		return "@NotFound@ @A_Asset_Acct_ID@";
diff --git a/org.adempiere.base/src/org/idempiere/fa/process/ProjectCreateAsset.java b/org.adempiere.base/src/org/idempiere/fa/process/ProjectCreateAsset.java
index e5360b402f..f8ec8e355c 100644
--- a/org.adempiere.base/src/org/idempiere/fa/process/ProjectCreateAsset.java
+++ b/org.adempiere.base/src/org/idempiere/fa/process/ProjectCreateAsset.java
@@ -20,10 +20,10 @@ package org.idempiere.fa.process;
 import java.sql.Timestamp;
 import java.util.logging.Level;
 
+import org.compiere.model.MAssetAddition;
+import org.compiere.model.MProduct;
 import org.compiere.model.MProductCategory;
 import org.compiere.model.MProject;
-import org.compiere.model.MProduct;
-import org.compiere.model.MAssetAddition;
 import org.compiere.process.DocAction;
 import org.compiere.process.ProcessInfoParameter;
 import org.compiere.process.SvrProcess;
@@ -42,11 +42,7 @@ public class ProjectCreateAsset extends SvrProcess
 	
 	/**	Product 			*/
 	private int 		m_Product_ID = 0;
-	
-	/**	Use Life Years 			*/
-	private int 		m_UseLifeYears = 0;
-	
-	
+		
 	/** DateTrx for create asset	*/
 	private Timestamp	m_DateTrx = null;
 	
@@ -70,7 +66,7 @@ public class ProjectCreateAsset extends SvrProcess
 				m_Product_ID = para[i].getParameterAsInt();
 			}
 			else if (para[i].getParameterName().equalsIgnoreCase("UseLifeYears")) {
-					m_UseLifeYears = para[i].getParameterAsInt();
+				;
 			}
 			else if (para[i].getParameterName().equalsIgnoreCase("DateTrx")) {
 				m_DateTrx = (Timestamp)para[i].getParameter();
@@ -106,10 +102,7 @@ public class ProjectCreateAsset extends SvrProcess
 		assetAdd.setDateAcct(m_DateTrx);
 		assetAdd.setDateDoc(m_DateTrx);
 		assetAdd.setM_Product_ID(m_Product_ID);
-		if(m_UseLifeYears > 0) {
-			assetAdd.setDeltaUseLifeYears(m_UseLifeYears);
-			assetAdd.setDeltaUseLifeYears_F(m_UseLifeYears);
-		}
+		
 		assetAdd.saveEx();
 		if (!assetAdd.processIt(DocAction.ACTION_Complete)) {
 			return "Error Process Asset Addition";