From 2cbed92cc4188c7b84f4e00f90eab5152e2c69ff Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 23 Mar 2020 19:12:13 +0100 Subject: [PATCH 1/8] IDEMPIERE-4218 Note and attachment from scheduler created in wrong client / IDEMPIERE-3977 --- .../server/org/compiere/server/AlertProcessor.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index 807ded2d66..7f0f8357f5 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -133,7 +133,7 @@ public class AlertProcessor extends AdempiereServer if (log.isLoggable(Level.INFO)) log.info("" + alert); MSystem system = MSystem.get(Env.getCtx()); - MClient client = MClient.get(Env.getCtx()); + MClient client = MClient.get(Env.getCtx(), alert.getAD_Client_ID()); // parse variables from Client, then from System String alertMessage = Env.parseVariable(alert.getAlertMessage(), client, null, true); alertMessage = Env.parseVariable(alertMessage, system, null, true); @@ -240,7 +240,7 @@ public class AlertProcessor extends AdempiereServer // parse variables from Client, then from System String alertSubject = Env.parseVariable(alert.getAlertSubject(), client, null, true); alertSubject = Env.parseVariable(alertSubject, system, null, true); - int countMail = notifyUsers(users, alertSubject, message.toString(), attachments); + int countMail = notifyUsers(users, alertSubject, message.toString(), attachments, alert); // IDEMPIERE-2864 for(File attachment : attachments) @@ -259,9 +259,10 @@ public class AlertProcessor extends AdempiereServer * @param subject email subject * @param message email message * @param attachments + * @param alert * @return how many email were sent */ - protected int notifyUsers(Collection users, String subject, String message, Collection attachments) + protected int notifyUsers(Collection users, String subject, String message, Collection attachments, MAlert alert) { int countMail = 0; for (int user_id : users) { @@ -282,14 +283,14 @@ public class AlertProcessor extends AdempiereServer // Notice int AD_Message_ID = 52244; /* TODO - Hardcoded message=notes */ MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName()); - note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); + note.setClientOrg(alert.getAD_Client_ID(), alert.getAD_Org_ID()); note.setTextMsg(message); note.setDescription(subject); note.saveEx(); if (attachments.size() > 0) { // Attachment MAttachment attachment = new MAttachment (getCtx(), MNote.Table_ID, note.getAD_Note_ID(), trx.getTrxName()); - attachment.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); + attachment.setClientOrg(alert.getAD_Client_ID(), alert.getAD_Org_ID()); for (File f : attachments) { attachment.addEntry(f); } From e32ed5c5cdb382e0b282e4a43afd7df8b3ab9cbe Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 23 Mar 2020 20:39:11 +0100 Subject: [PATCH 2/8] IDEMPIERE-4218 Note and attachment from scheduler created in wrong client / also cross-tenant AD_UserMail --- org.adempiere.base/src/org/compiere/model/SystemIDs.java | 1 + .../src/main/server/org/compiere/server/AlertProcessor.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/SystemIDs.java b/org.adempiere.base/src/org/compiere/model/SystemIDs.java index 82ad176a9c..bf6bb08f57 100644 --- a/org.adempiere.base/src/org/compiere/model/SystemIDs.java +++ b/org.adempiere.base/src/org/compiere/model/SystemIDs.java @@ -56,6 +56,7 @@ public class SystemIDs public final static int MESSAGE_REQUESTUPDATE = 834; public final static int MESSAGE_WORKFLOWRESULT = 753; + public final static int MESSAGE_NOTES = 52244; public final static int PRINTFORMAT_STATEMENTOFACCOUNT = 134; public final static int PRINTFORMAT_ORDER_HEADER_TEMPLATE = 100; diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index 7f0f8357f5..14c9461d24 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -37,6 +37,7 @@ import org.compiere.model.MNote; import org.compiere.model.MSysConfig; import org.compiere.model.MSystem; import org.compiere.model.MUser; +import org.compiere.model.SystemIDs; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; @@ -269,7 +270,8 @@ public class AlertProcessor extends AdempiereServer MUser user = MUser.get(getCtx(), user_id); if (user.isNotificationEMail()) { String messageHTML = message.replaceAll(Env.NL, "
"); - if (m_client.sendEMailAttachments (user_id, subject, messageHTML, attachments, true)) + MClient client = MClient.get(Env.getCtx(), alert.getAD_Client_ID()); + if (client.sendEMailAttachments (user_id, subject, messageHTML, attachments, true)) { countMail++; } @@ -281,7 +283,7 @@ public class AlertProcessor extends AdempiereServer trx = Trx.get(Trx.createTrxName("AP_NU"), true); trx.setDisplayName(getClass().getName()+"_"+m_model.getName()+"_notifyUsers"); // Notice - int AD_Message_ID = 52244; /* TODO - Hardcoded message=notes */ + int AD_Message_ID = SystemIDs.MESSAGE_NOTES; /* TODO - Hardcoded message=notes */ MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName()); note.setClientOrg(alert.getAD_Client_ID(), alert.getAD_Org_ID()); note.setTextMsg(message); From 1414928029c7d1c14f5ee677c31d3afde1d06f25 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 23 Mar 2020 21:53:49 +0100 Subject: [PATCH 3/8] IDEMPIERE-4219 Alert query in Replica database (FHCA-1200) --- .../src/main/server/org/compiere/server/AlertProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index 14c9461d24..45169530ae 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -326,7 +326,7 @@ public class AlertProcessor extends AdempiereServer Exception error = null; try { - pstmt = DB.prepareStatement (sql, trxName); + pstmt = DB.prepareNormalReadReplicaStatement(sql, trxName); rs = pstmt.executeQuery (); ResultSetMetaData meta = rs.getMetaData(); boolean isFirstRow = true; @@ -389,7 +389,7 @@ public class AlertProcessor extends AdempiereServer Exception error = null; try { - pstmt = DB.prepareStatement (sql, trxName); + pstmt = DB.prepareNormalReadReplicaStatement(sql, trxName); rs = pstmt.executeQuery (); ResultSetMetaData meta = rs.getMetaData(); while (rs.next ()) From 41b8e0e62b932b3b306d86ba42c5c62d4ef05891 Mon Sep 17 00:00:00 2001 From: hengsin Date: Tue, 24 Mar 2020 18:35:08 +0800 Subject: [PATCH 4/8] IDEMPIERE-3947 Fixed Asset bugs and enhancements. Implement import fixed asset for multiple accounting schema. --- .../oracle/202003021203_IDEMPIERE-3947.sql | 594 ++++++++++++++++++ .../202003021203_IDEMPIERE-3947.sql | 591 +++++++++++++++++ .../org/compiere/model/I_I_FixedAsset.java | 74 +++ .../src/org/compiere/model/MAsset.java | 9 + .../org/compiere/model/MAssetAddition.java | 71 ++- .../compiere/model/MDepreciationWorkfile.java | 18 +- .../org/compiere/model/X_I_FixedAsset.java | 130 +++- .../fa/process/ImportFixedAsset.java | 249 ++++++-- 8 files changed, 1669 insertions(+), 67 deletions(-) create mode 100644 migration/i7.1/oracle/202003021203_IDEMPIERE-3947.sql create mode 100644 migration/i7.1/postgresql/202003021203_IDEMPIERE-3947.sql diff --git a/migration/i7.1/oracle/202003021203_IDEMPIERE-3947.sql b/migration/i7.1/oracle/202003021203_IDEMPIERE-3947.sql new file mode 100644 index 0000000000..db591f5760 --- /dev/null +++ b/migration/i7.1/oracle/202003021203_IDEMPIERE-3947.sql @@ -0,0 +1,594 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3947 Fixed Asset bugs and enhancements +-- Feb 11, 2020, 11:36:17 AM 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,IsHtml) VALUES (214180,0,'ISO Currency Code','Three letter ISO 4217 Code of the Currency','For details - http://www.unece.org/trade/rec/rec09en.htm',53277,'ISO_Code',3,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2020-02-11 11:36:15','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:36:15','YYYY-MM-DD HH24:MI:SS'),100,328,'Y','N','D','N','N','N','Y','d3b4c038-fcfd-4276-bee8-b879cc870806','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:36:26 AM SGT +ALTER TABLE I_FixedAsset ADD ISO_Code VARCHAR2(3) DEFAULT NULL +; + +-- Feb 11, 2020, 11:37:03 AM 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,IsHtml) VALUES (214181,0,'Currency','The Currency for this record','Indicates the Currency to be used when processing or reporting on this record',53277,'C_Currency_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2020-02-11 11:37:02','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:37:02','YYYY-MM-DD HH24:MI:SS'),100,193,'Y','N','D','N','N','N','Y','e7596989-7e4c-43f8-9e55-f20866d5c12d','Y',0,'N','N','N','N') +; + +-- Feb 11, 2020, 11:40:00 AM SGT +UPDATE AD_Column SET FKConstraintName='CCurrency_IFixedAsset', FKConstraintType='N',Updated=TO_DATE('2020-02-11 11:40:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214181 +; + +-- Feb 11, 2020, 11:40:00 AM SGT +ALTER TABLE I_FixedAsset ADD C_Currency_ID NUMBER(10) DEFAULT NULL +; + +-- Feb 11, 2020, 11:40:00 AM SGT +ALTER TABLE I_FixedAsset ADD CONSTRAINT CCurrency_IFixedAsset FOREIGN KEY (C_Currency_ID) REFERENCES c_currency(c_currency_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Feb 11, 2020, 11:40:46 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,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,IsHtml) VALUES (214182,0,'Entered Amount',53277,'AssetAmtEntered','0',10,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_DATE('2020-02-11 11:40:45','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:40:45','YYYY-MM-DD HH24:MI:SS'),100,54207,'Y','N','D','N','N','N','Y','bc12181f-f685-46fe-9c76-b2468ad29e9b','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:40:51 AM SGT +UPDATE AD_Column SET IsMandatory='Y',Updated=TO_DATE('2020-02-11 11:40:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214182 +; + +-- Feb 11, 2020, 11:40:57 AM SGT +ALTER TABLE I_FixedAsset ADD AssetAmtEntered NUMBER DEFAULT 0 NOT NULL +; + +-- Feb 11, 2020, 11:41:51 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,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,IsHtml) VALUES (214183,0,'Source Amount',53277,'AssetSourceAmt','0',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_DATE('2020-02-11 11:41:50','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:41:50','YYYY-MM-DD HH24:MI:SS'),100,54202,'Y','N','D','N','N','N','Y','43286a53-e708-431f-978e-1b7a25ec3841','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:42:15 AM SGT +ALTER TABLE I_FixedAsset ADD AssetSourceAmt NUMBER DEFAULT 0 NOT NULL +; + +-- Feb 11, 2020, 11:42:52 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,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,IsHtml) VALUES (214184,0,'Account Schema Name','Name of the Accounting Schema',53277,'AcctSchemaName',120,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2020-02-11 11:42:51','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:42:51','YYYY-MM-DD HH24:MI:SS'),100,2084,'Y','Y','D','N','N','N','Y','63f665c5-5085-4c7e-9f2c-b5ae163de16e','Y',10,'N','N','N') +; + +-- Feb 11, 2020, 11:42:58 AM SGT +ALTER TABLE I_FixedAsset ADD AcctSchemaName VARCHAR2(120) DEFAULT NULL +; + +-- Feb 11, 2020, 11:43:45 AM 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,IsHtml) VALUES (214185,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53277,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2020-02-11 11:43:45','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:43:45','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','bf429587-d193-4190-a32d-8503ce63c2d3','Y',0,'N','N','C','N') +; + +-- Feb 11, 2020, 11:43:51 AM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_IFixedAsset', FKConstraintType='C',Updated=TO_DATE('2020-02-11 11:43:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214185 +; + +-- Feb 11, 2020, 11:43:51 AM SGT +ALTER TABLE I_FixedAsset ADD C_AcctSchema_ID NUMBER(10) DEFAULT NULL +; + +-- Feb 11, 2020, 11:43:51 AM SGT +ALTER TABLE I_FixedAsset ADD CONSTRAINT CAcctSchema_IFixedAsset FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Feb 11, 2020, 11:44:43 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206390,'ISO Currency Code','Three letter ISO 4217 Code of the Currency','For details - http://www.unece.org/trade/rec/rec09en.htm',53334,214180,'Y',3,310,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:42','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','7236b757-b73a-450a-9c85-98a8ab08389d','Y',310,2) +; + +-- Feb 11, 2020, 11:44:44 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206391,'Currency','The Currency for this record','Indicates the Currency to be used when processing or reporting on this record',53334,214181,'Y',22,320,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:43','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:43','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','11bdfc71-4d1f-4d31-9b3a-b88d75406bd8','Y',320,2) +; + +-- Feb 11, 2020, 11:44:45 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206392,'Entered Amount',53334,214182,'Y',10,330,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','bfe5930e-9348-4b2a-9087-a4d0461d3fc2','Y',330,2) +; + +-- Feb 11, 2020, 11:44:46 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206393,'Source Amount',53334,214183,'Y',22,340,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','e2b58b61-b516-4f16-b282-f861cc3248bb','Y',340,2) +; + +-- Feb 11, 2020, 11:44:47 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206394,'Account Schema Name','Name of the Accounting Schema',53334,214184,'Y',120,350,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','3e4eaad8-098f-418d-a9be-3deb18a4e00b','Y',350,5) +; + +-- Feb 11, 2020, 11:44:48 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206395,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53334,214185,'Y',22,360,'N','N','N','N',0,0,'Y',TO_DATE('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','0adfa648-05b8-415f-a655-3ca44584dfc9','Y',360,2) +; + +-- Feb 11, 2020, 11:46:29 AM SGT +UPDATE AD_Field SET SeqNo=320, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 11:46:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:46:29 AM SGT +UPDATE AD_Field SET SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 11:46:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:46:30 AM SGT +UPDATE AD_Field SET SeqNo=350, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 11:46:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:46:30 AM SGT +UPDATE AD_Field SET SeqNo=360, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 11:46:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 11, 2020, 11:47:45 AM SGT +UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 11, 2020, 11:47:58 AM SGT +UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59485 +; + +-- Feb 11, 2020, 11:47:58 AM SGT +UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59498 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59474 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59494 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59497 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59493 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59470 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=130,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=140,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=150,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=160,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=170,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=180,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=190,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=200,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=210,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=220,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=230,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=240,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=250,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=260,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=270,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=280,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=290,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=300,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=310,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=320,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=330,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=340,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=350,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 11, 2020, 12:00:51 PM SGT +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 12:00:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59494 +; + +-- Feb 11, 2020, 12:00:51 PM SGT +UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 12:00:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 2:40:01 PM SGT +UPDATE AD_Field SET SeqNo=290, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:40:01 PM SGT +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=300, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 2:40:01 PM SGT +UPDATE AD_Field SET SeqNo=330, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 2:40:02 PM SGT +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 2:40:43 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=280, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:40:48 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=290, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 2:40:59 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=320, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:40:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 2:41:05 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=330, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:41:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 2:48:27 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, MandatoryLogic='@C_Currency_ID@=0 & @ISO_Code@=''''', IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:48:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:54:44 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:54:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 2:55:03 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 14:55:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:22 PM SGT +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:09:22 PM SGT +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=130,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=140,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=150,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=160,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=170,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=180,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=190,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=200,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=210,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=220,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=230,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=240,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=250,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=260,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=270,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=280,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=290,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=300,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=310,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=320,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=330,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=340,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=350,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=360,IsDisplayedGrid='Y', Updated=sysdate, UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 27, 2020, 3:10:13 PM SGT +UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 15:10:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:15:38 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-27 15:15:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 17, 2020, 5:43:36 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-02-17 17:43:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59493 +; + +-- Feb 17, 2020, 5:51:40 PM SGT +UPDATE AD_Column SET IsAllowCopy='N', IsToolbarButton='N',Updated=TO_DATE('2020-02-17 17:51:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59521 +; + +-- Feb 17, 2020, 5:55:28 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@Processed@=''Y''', IsToolbarButton=NULL,Updated=TO_DATE('2020-02-17 17:55:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 17, 2020, 6:15:27 PM SGT +UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_DATE('2020-02-17 18:15:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214185 +; + +SELECT register_migration_script('202003021203_IDEMPIERE-3947.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i7.1/postgresql/202003021203_IDEMPIERE-3947.sql b/migration/i7.1/postgresql/202003021203_IDEMPIERE-3947.sql new file mode 100644 index 0000000000..b8c034b911 --- /dev/null +++ b/migration/i7.1/postgresql/202003021203_IDEMPIERE-3947.sql @@ -0,0 +1,591 @@ +-- IDEMPIERE-3947 Fixed Asset bugs and enhancements +-- Feb 11, 2020, 11:36:17 AM 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,IsHtml) VALUES (214180,0,'ISO Currency Code','Three letter ISO 4217 Code of the Currency','For details - http://www.unece.org/trade/rec/rec09en.htm',53277,'ISO_Code',3,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:36:15','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:36:15','YYYY-MM-DD HH24:MI:SS'),100,328,'Y','N','D','N','N','N','Y','d3b4c038-fcfd-4276-bee8-b879cc870806','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:36:26 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN ISO_Code VARCHAR(3) DEFAULT NULL +; + +-- Feb 11, 2020, 11:37:03 AM 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,IsHtml) VALUES (214181,0,'Currency','The Currency for this record','Indicates the Currency to be used when processing or reporting on this record',53277,'C_Currency_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:37:02','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:37:02','YYYY-MM-DD HH24:MI:SS'),100,193,'Y','N','D','N','N','N','Y','e7596989-7e4c-43f8-9e55-f20866d5c12d','Y',0,'N','N','N','N') +; + +-- Feb 11, 2020, 11:40:00 AM SGT +UPDATE AD_Column SET FKConstraintName='CCurrency_IFixedAsset', FKConstraintType='N',Updated=TO_TIMESTAMP('2020-02-11 11:40:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214181 +; + +-- Feb 11, 2020, 11:40:00 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN C_Currency_ID NUMERIC(10) DEFAULT NULL +; + +-- Feb 11, 2020, 11:40:00 AM SGT +ALTER TABLE I_FixedAsset ADD CONSTRAINT CCurrency_IFixedAsset FOREIGN KEY (C_Currency_ID) REFERENCES c_currency(c_currency_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Feb 11, 2020, 11:40:46 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,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,IsHtml) VALUES (214182,0,'Entered Amount',53277,'AssetAmtEntered','0',10,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:40:45','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:40:45','YYYY-MM-DD HH24:MI:SS'),100,54207,'Y','N','D','N','N','N','Y','bc12181f-f685-46fe-9c76-b2468ad29e9b','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:40:51 AM SGT +UPDATE AD_Column SET IsMandatory='Y',Updated=TO_TIMESTAMP('2020-02-11 11:40:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214182 +; + +-- Feb 11, 2020, 11:40:57 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN AssetAmtEntered NUMERIC DEFAULT '0' NOT NULL +; + +-- Feb 11, 2020, 11:41:51 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,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,IsHtml) VALUES (214183,0,'Source Amount',53277,'AssetSourceAmt','0',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:41:50','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:41:50','YYYY-MM-DD HH24:MI:SS'),100,54202,'Y','N','D','N','N','N','Y','43286a53-e708-431f-978e-1b7a25ec3841','Y',0,'N','N','N') +; + +-- Feb 11, 2020, 11:42:15 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN AssetSourceAmt NUMERIC DEFAULT '0' NOT NULL +; + +-- Feb 11, 2020, 11:42:52 AM SGT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,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,IsHtml) VALUES (214184,0,'Account Schema Name','Name of the Accounting Schema',53277,'AcctSchemaName',120,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:42:51','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:42:51','YYYY-MM-DD HH24:MI:SS'),100,2084,'Y','Y','D','N','N','N','Y','63f665c5-5085-4c7e-9f2c-b5ae163de16e','Y',10,'N','N','N') +; + +-- Feb 11, 2020, 11:42:58 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN AcctSchemaName VARCHAR(120) DEFAULT NULL +; + +-- Feb 11, 2020, 11:43:45 AM 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,IsHtml) VALUES (214185,0,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53277,'C_AcctSchema_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2020-02-11 11:43:45','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:43:45','YYYY-MM-DD HH24:MI:SS'),100,181,'N','N','D','N','N','N','Y','bf429587-d193-4190-a32d-8503ce63c2d3','Y',0,'N','N','C','N') +; + +-- Feb 11, 2020, 11:43:51 AM SGT +UPDATE AD_Column SET FKConstraintName='CAcctSchema_IFixedAsset', FKConstraintType='C',Updated=TO_TIMESTAMP('2020-02-11 11:43:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214185 +; + +-- Feb 11, 2020, 11:43:51 AM SGT +ALTER TABLE I_FixedAsset ADD COLUMN C_AcctSchema_ID NUMERIC(10) DEFAULT NULL +; + +-- Feb 11, 2020, 11:43:51 AM SGT +ALTER TABLE I_FixedAsset ADD CONSTRAINT CAcctSchema_IFixedAsset FOREIGN KEY (C_AcctSchema_ID) REFERENCES c_acctschema(c_acctschema_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +; + +-- Feb 11, 2020, 11:44:43 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206390,'ISO Currency Code','Three letter ISO 4217 Code of the Currency','For details - http://www.unece.org/trade/rec/rec09en.htm',53334,214180,'Y',3,310,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','7236b757-b73a-450a-9c85-98a8ab08389d','Y',310,2) +; + +-- Feb 11, 2020, 11:44:44 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206391,'Currency','The Currency for this record','Indicates the Currency to be used when processing or reporting on this record',53334,214181,'Y',22,320,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:43','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:43','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','11bdfc71-4d1f-4d31-9b3a-b88d75406bd8','Y',320,2) +; + +-- Feb 11, 2020, 11:44:45 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206392,'Entered Amount',53334,214182,'Y',10,330,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','bfe5930e-9348-4b2a-9087-a4d0461d3fc2','Y',330,2) +; + +-- Feb 11, 2020, 11:44:46 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206393,'Source Amount',53334,214183,'Y',22,340,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:45','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','e2b58b61-b516-4f16-b282-f861cc3248bb','Y',340,2) +; + +-- Feb 11, 2020, 11:44:47 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206394,'Account Schema Name','Name of the Accounting Schema',53334,214184,'Y',120,350,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','3e4eaad8-098f-418d-a9be-3deb18a4e00b','Y',350,5) +; + +-- Feb 11, 2020, 11:44:48 AM SGT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206395,'Accounting Schema','Rules for accounting','An Accounting Schema defines the rules used in accounting such as costing method, currency and calendar',53334,214185,'Y',22,360,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-02-11 11:44:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','0adfa648-05b8-415f-a655-3ca44584dfc9','Y',360,2) +; + +-- Feb 11, 2020, 11:46:29 AM SGT +UPDATE AD_Field SET SeqNo=320, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 11:46:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:46:29 AM SGT +UPDATE AD_Field SET SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 11:46:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:46:30 AM SGT +UPDATE AD_Field SET SeqNo=350, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 11:46:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:46:30 AM SGT +UPDATE AD_Field SET SeqNo=360, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 11:46:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:47:44 AM SGT +UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:47:45 AM SGT +UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 11, 2020, 11:47:45 AM SGT +UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 11, 2020, 11:47:58 AM SGT +UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59485 +; + +-- Feb 11, 2020, 11:47:58 AM SGT +UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59498 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59474 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59494 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59497 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59493 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59470 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 11, 2020, 11:47:59 AM SGT +UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=130,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=140,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=150,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=160,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=170,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=180,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=190,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=200,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 11, 2020, 11:48:00 AM SGT +UPDATE AD_Field SET SeqNoGrid=210,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=220,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=230,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=240,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=250,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=260,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=270,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=280,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 11, 2020, 11:48:01 AM SGT +UPDATE AD_Field SET SeqNoGrid=290,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=300,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=310,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=320,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=330,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=340,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 11, 2020, 11:48:02 AM SGT +UPDATE AD_Field SET SeqNoGrid=350,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 11, 2020, 12:00:51 PM SGT +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 12:00:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59494 +; + +-- Feb 11, 2020, 12:00:51 PM SGT +UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 12:00:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 11, 2020, 12:00:52 PM SGT +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-11 12:00:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 2:40:01 PM SGT +UPDATE AD_Field SET SeqNo=290, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:40:01 PM SGT +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=300, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 2:40:02 PM SGT +UPDATE AD_Field SET SeqNo=330, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 2:40:02 PM SGT +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 2:40:43 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=280, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:40:48 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=290, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 2:40:59 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=320, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:40:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 2:41:05 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, SeqNoGrid=330, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:41:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 2:48:27 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, MandatoryLogic='@C_Currency_ID@=0 & @ISO_Code@=''''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:48:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 2:54:44 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:54:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 2:55:03 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 14:55:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:22 PM SGT +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:09:22 PM SGT +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 27, 2020, 3:09:23 PM SGT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 27, 2020, 3:09:24 PM SGT +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 3:09:25 PM SGT +UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 27, 2020, 3:09:26 PM SGT +UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59478 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59479 +; + +-- Feb 27, 2020, 3:09:39 PM SGT +UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59481 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=130,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59482 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=140,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59501 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=150,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59502 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=160,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59488 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=170,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59507 +; + +-- Feb 27, 2020, 3:09:40 PM SGT +UPDATE AD_Field SET SeqNoGrid=180,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59506 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=190,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59495 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=200,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59496 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=210,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59503 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=220,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59476 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=230,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=200161 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=240,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59508 +; + +-- Feb 27, 2020, 3:09:41 PM SGT +UPDATE AD_Field SET SeqNoGrid=250,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59509 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=260,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59486 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=270,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59471 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=280,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59472 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=290,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206391 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=300,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206390 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=310,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206392 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=320,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206393 +; + +-- Feb 27, 2020, 3:09:42 PM SGT +UPDATE AD_Field SET SeqNoGrid=330,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206395 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=340,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206394 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=350,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 27, 2020, 3:09:43 PM SGT +UPDATE AD_Field SET SeqNoGrid=360,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=59499 +; + +-- Feb 27, 2020, 3:10:13 PM SGT +UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 15:10:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 27, 2020, 3:15:38 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-27 15:15:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59477 +; + +-- Feb 17, 2020, 5:43:36 PM SGT +UPDATE AD_Field SET IsMandatory='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-17 17:43:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59493 +; + +-- Feb 17, 2020, 5:51:40 PM SGT +UPDATE AD_Column SET IsAllowCopy='N', IsToolbarButton='N',Updated=TO_TIMESTAMP('2020-02-17 17:51:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59521 +; + +-- Feb 17, 2020, 5:55:28 PM SGT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@Processed@=''Y''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-02-17 17:55:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=59489 +; + +-- Feb 17, 2020, 6:15:27 PM SGT +UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_TIMESTAMP('2020-02-17 18:15:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214185 +; + +SELECT register_migration_script('202003021203_IDEMPIERE-3947.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/I_I_FixedAsset.java b/org.adempiere.base/src/org/compiere/model/I_I_FixedAsset.java index 1847294efb..9e495c51c2 100644 --- a/org.adempiere.base/src/org/compiere/model/I_I_FixedAsset.java +++ b/org.adempiere.base/src/org/compiere/model/I_I_FixedAsset.java @@ -147,6 +147,19 @@ public interface I_I_FixedAsset /** Get Asset Type Value */ public String getA_Asset_Type_Value(); + /** Column name AcctSchemaName */ + public static final String COLUMNNAME_AcctSchemaName = "AcctSchemaName"; + + /** Set Account Schema Name. + * Name of the Accounting Schema + */ + public void setAcctSchemaName (String AcctSchemaName); + + /** Get Account Schema Name. + * Name of the Accounting Schema + */ + public String getAcctSchemaName(); + /** Column name A_Current_Period */ public static final String COLUMNNAME_A_Current_Period = "A_Current_Period"; @@ -195,6 +208,15 @@ public interface I_I_FixedAsset /** Get Asset Salvage Value */ public BigDecimal getA_Salvage_Value(); + /** Column name AssetAmtEntered */ + public static final String COLUMNNAME_AssetAmtEntered = "AssetAmtEntered"; + + /** Set Entered Amount */ + public void setAssetAmtEntered (BigDecimal AssetAmtEntered); + + /** Get Entered Amount */ + public BigDecimal getAssetAmtEntered(); + /** Column name AssetDepreciationDate */ public static final String COLUMNNAME_AssetDepreciationDate = "AssetDepreciationDate"; @@ -234,6 +256,15 @@ public interface I_I_FixedAsset */ public Timestamp getAssetServiceDate(); + /** Column name AssetSourceAmt */ + public static final String COLUMNNAME_AssetSourceAmt = "AssetSourceAmt"; + + /** Set Source Amount */ + public void setAssetSourceAmt (BigDecimal AssetSourceAmt); + + /** Get Source Amount */ + public BigDecimal getAssetSourceAmt(); + /** Column name BPartner_Value */ public static final String COLUMNNAME_BPartner_Value = "BPartner_Value"; @@ -247,6 +278,21 @@ public interface I_I_FixedAsset */ public String getBPartner_Value(); + /** 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 C_BPartnerSR_ID */ public static final String COLUMNNAME_C_BPartnerSR_ID = "C_BPartnerSR_ID"; @@ -286,6 +332,21 @@ public interface I_I_FixedAsset /** Get City Value */ public String getC_City_Value(); + /** Column name C_Currency_ID */ + public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID"; + + /** Set Currency. + * The Currency for this record + */ + public void setC_Currency_ID (int C_Currency_ID); + + /** Get Currency. + * The Currency for this record + */ + public int getC_Currency_ID(); + + public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException; + /** Column name Created */ public static final String COLUMNNAME_Created = "Created"; @@ -422,6 +483,19 @@ public interface I_I_FixedAsset */ public boolean isActive(); + /** Column name ISO_Code */ + public static final String COLUMNNAME_ISO_Code = "ISO_Code"; + + /** Set ISO Currency Code. + * Three letter ISO 4217 Code of the Currency + */ + public void setISO_Code (String ISO_Code); + + /** Get ISO Currency Code. + * Three letter ISO 4217 Code of the Currency + */ + public String getISO_Code(); + /** Column name LocatorValue */ public static final String COLUMNNAME_LocatorValue = "LocatorValue"; diff --git a/org.adempiere.base/src/org/compiere/model/MAsset.java b/org.adempiere.base/src/org/compiere/model/MAsset.java index f27d6f230f..ed65eb442c 100644 --- a/org.adempiere.base/src/org/compiere/model/MAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MAsset.java @@ -161,6 +161,8 @@ public class MAsset extends X_A_Asset setDateAcct(ifa.getDateAcct()); setName(ifa.getName()); setDescription(ifa.getDescription()); + + setI_FixedAsset(ifa); } /** @@ -413,6 +415,9 @@ public class MAsset extends X_A_Asset { if (assetgrpacct.getAD_Org_ID() == 0 || assetgrpacct.getAD_Org_ID() == getAD_Org_ID()) { + if (getI_FixedAsset() != null && assetgrpacct.getC_AcctSchema_ID() != getI_FixedAsset().getC_AcctSchema_ID()) + continue; + // Asset Accounting MAssetAcct assetacct = new MAssetAcct(this, assetgrpacct); assetacct.setAD_Org_ID(getAD_Org_ID()); //added by @win @@ -576,6 +581,10 @@ public class MAsset extends X_A_Asset public void setA_Accumulated_Depr(BigDecimal A_Accumulated_Depr) { m_A_Accumulated_Depr = A_Accumulated_Depr; } public BigDecimal getA_Accumulated_Depr_F() { return m_A_Accumulated_Depr_F; } public void setA_Accumulated_Depr_F(BigDecimal A_Accumulated_Depr_F) { m_A_Accumulated_Depr_F = A_Accumulated_Depr_F; } + + private MIFixedAsset m_I_FixedAsset = null; + public MIFixedAsset getI_FixedAsset() { return m_I_FixedAsset; } + public void setI_FixedAsset(MIFixedAsset I_FixedAsset) { m_I_FixedAsset = I_FixedAsset; } public MAssetDelivery confirmDelivery(EMail email, int ad_User_ID) { // TODO Auto-generated method stub diff --git a/org.adempiere.base/src/org/compiere/model/MAssetAddition.java b/org.adempiere.base/src/org/compiere/model/MAssetAddition.java index fa79f538cb..c99fe20291 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetAddition.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetAddition.java @@ -293,6 +293,7 @@ public class MAssetAddition extends X_A_Asset_Addition setA_SourceType(A_SOURCETYPE_Imported); // setM_Product_ID(ifa.getM_Product_ID()); + setAssetValueAmt(ifa.getA_Asset_Cost()); setSourceAmt(ifa.getA_Asset_Cost()); setDateDoc(ifa.getAssetServiceDate()); setM_Locator_ID(ifa.getM_Locator_ID()); @@ -311,6 +312,13 @@ public class MAssetAddition extends X_A_Asset_Addition if (log.isLoggable(Level.FINE)) log.fine("DateAcct=" + dateAcct); setDateAcct(dateAcct); } + if (ifa.getA_Asset_ID() > 0) + setA_Asset_ID(ifa.getA_Asset_ID()); + if (ifa.getC_Currency_ID() > 0) + setC_Currency_ID(ifa.getC_Currency_ID()); + setAssetAmtEntered(ifa.getAssetAmtEntered()); + setAssetSourceAmt(ifa.getAssetSourceAmt()); + setI_FixedAsset(ifa); } @@ -445,6 +453,8 @@ public class MAssetAddition extends X_A_Asset_Addition */ private void setAssetValueAmt() { + if (A_SOURCETYPE_Imported.equals(getA_SourceType())) + return; getDateAcct(); MConversionRateUtil.convertBase(SetGetUtil.wrap(this), COLUMNNAME_DateAcct, @@ -554,7 +564,8 @@ public class MAssetAddition extends X_A_Asset_Addition // Only New assets can be activated if (isA_CreateAsset() && !MAsset.A_ASSET_STATUS_New.equals(asset.getA_Asset_Status())) { - throw new AssetException("Only new assets can be activated"); + if (!A_SOURCETYPE_Imported.equals(getA_SourceType())) + throw new AssetException("Only new assets can be activated"); } // // Validate Source - Project @@ -667,9 +678,10 @@ 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())) { + if (A_SOURCETYPE_Imported.equals(getA_SourceType()) && assetgrpacct.getC_AcctSchema_ID() != getI_FixedAsset().getC_AcctSchema_ID()) + continue; assetwk = new MDepreciationWorkfile(asset, getPostingType(), assetgrpacct); } } @@ -685,17 +697,23 @@ public class MAssetAddition extends X_A_Asset_Addition // for (MDepreciationWorkfile assetworkFile : MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName())) { + if (A_SOURCETYPE_Imported.equals(getA_SourceType()) && assetworkFile.getC_AcctSchema_ID() != getI_FixedAsset().getC_AcctSchema_ID()) + continue; + 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 + if (A_SOURCETYPE_Imported.equals(getA_SourceType())) { + assetworkFile.adjustCost(getI_FixedAsset().getA_Asset_Cost(), getA_QTY_Current(), isA_CreateAsset()); } else { - assetworkFile.adjustCost(getAssetSourceAmt(), getA_QTY_Current(), isA_CreateAsset()); // reset if isA_CreateAsset - + 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)) { @@ -703,15 +721,19 @@ public class MAssetAddition extends X_A_Asset_Addition 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{ + if (A_SOURCETYPE_Imported.equals(getA_SourceType())) { assetworkFile.setA_Salvage_Value(this.getA_Salvage_Value()); + } else { + 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()); @@ -721,8 +743,11 @@ public class MAssetAddition extends X_A_Asset_Addition //@win set initial depreciation period = 1 if (isA_CreateAsset()) { - assetworkFile.setA_Current_Period(1); - assetworkFile.saveEx(); + if (assetworkFile.getA_Current_Period() == 0) + { + assetworkFile.setA_Current_Period(1); + assetworkFile.saveEx(); + } } // // Rebuild depreciation: @@ -1169,6 +1194,10 @@ public class MAssetAddition extends X_A_Asset_Addition { setA_CreateAsset(false); } + else if (A_SOURCETYPE_Imported.equals(getA_SourceType())) + { + setA_CreateAsset(true); + } else { final String sql = "SELECT COUNT(*) FROM A_Asset_Addition WHERE A_Asset_ID=? AND A_CreateAsset='Y'" diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java index 0255dac62f..3affa37a37 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java @@ -647,7 +647,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile //logging if(CLogMgt.isLevelFine()) { - sb.append("currentPeriod=" + getA_Current_Period() + ", AssetServiceDate=" + getAssetDepreciationDate() + "\n"); + sb.append("currentPeriod=" + getA_Current_Period() + ", AssetServiceDate=" + getAssetServiceDate() + "\n"); sb.append("offset: C|F=" + offset_C + "|" + offset_F + "\n"); sb.append("life: C|F=" + lifePeriods_C + "|" + lifePeriods_F + " + offset =" + lifePeriods + "\n"); } @@ -675,6 +675,20 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile lifePeriods_F = lifePeriods; } + Timestamp startDateAcct = getDateAcct(); + if (getAssetDepreciationDate() != null) + { + if (getAssetDepreciationDate().compareTo(getDateAcct()) >= 0) + { + if (TimeUtil.getMonthLastDay(startDateAcct).compareTo(getAssetDepreciationDate()) == 0) + { + startDateAcct = TimeUtil.addMonths(getAssetDepreciationDate(), 1); + ++A_Current_Period; + } + else + startDateAcct = getAssetDepreciationDate(); + } + } for (int currentPeriod = A_Current_Period, cnt = 1; currentPeriod <= lifePeriods; currentPeriod++, cnt++) { @@ -721,7 +735,7 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile int months = 0; months = months + (currentPeriod - A_Current_Period); - Timestamp dateAcct = TimeUtil.getMonthLastDay(TimeUtil.addMonths(getDateAcct(), months)); + Timestamp dateAcct = TimeUtil.getMonthLastDay(TimeUtil.addMonths(startDateAcct, months)); MDepreciationExp.createDepreciation (this, currentPeriod, dateAcct, exp_C, exp_F, diff --git a/org.adempiere.base/src/org/compiere/model/X_I_FixedAsset.java b/org.adempiere.base/src/org/compiere/model/X_I_FixedAsset.java index 851610ef42..ad0284b2d0 100644 --- a/org.adempiere.base/src/org/compiere/model/X_I_FixedAsset.java +++ b/org.adempiere.base/src/org/compiere/model/X_I_FixedAsset.java @@ -32,7 +32,7 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent /** * */ - private static final long serialVersionUID = 20191121L; + private static final long serialVersionUID = 20200225L; /** Standard Constructor */ public X_I_FixedAsset (Properties ctx, int I_FixedAsset_ID, String trxName) @@ -43,8 +43,12 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent setA_Asset_Cost (Env.ZERO); // 0 setA_Remaining_Period (0); +// 0 + setAssetAmtEntered (Env.ZERO); // 0 setAssetPeriodDepreciationAmt (Env.ZERO); +// 0 + setAssetSourceAmt (Env.ZERO); // 0 setDocAction (null); // 'CO' @@ -280,6 +284,23 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return (String)get_Value(COLUMNNAME_A_Asset_Type_Value); } + /** Set Account Schema Name. + @param AcctSchemaName + Name of the Accounting Schema + */ + public void setAcctSchemaName (String AcctSchemaName) + { + set_Value (COLUMNNAME_AcctSchemaName, AcctSchemaName); + } + + /** Get Account Schema Name. + @return Name of the Accounting Schema + */ + public String getAcctSchemaName () + { + return (String)get_Value(COLUMNNAME_AcctSchemaName); + } + /** Set Current Period. @param A_Current_Period Current Period */ public void setA_Current_Period (int A_Current_Period) @@ -331,6 +352,23 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return bd; } + /** Set Entered Amount. + @param AssetAmtEntered Entered Amount */ + public void setAssetAmtEntered (BigDecimal AssetAmtEntered) + { + set_Value (COLUMNNAME_AssetAmtEntered, AssetAmtEntered); + } + + /** Get Entered Amount. + @return Entered Amount */ + public BigDecimal getAssetAmtEntered () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_AssetAmtEntered); + if (bd == null) + return Env.ZERO; + return bd; + } + /** Set Asset Depreciation Date. @param AssetDepreciationDate Date of last depreciation @@ -385,6 +423,23 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return (Timestamp)get_Value(COLUMNNAME_AssetServiceDate); } + /** Set Source Amount. + @param AssetSourceAmt Source Amount */ + public void setAssetSourceAmt (BigDecimal AssetSourceAmt) + { + set_Value (COLUMNNAME_AssetSourceAmt, AssetSourceAmt); + } + + /** Get Source Amount. + @return Source Amount */ + public BigDecimal getAssetSourceAmt () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_AssetSourceAmt); + if (bd == null) + return Env.ZERO; + return bd; + } + /** Set Business Partner Key. @param BPartner_Value The Key of the Business Partner @@ -402,6 +457,34 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return (String)get_Value(COLUMNNAME_BPartner_Value); } + 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_Value (COLUMNNAME_C_AcctSchema_ID, null); + else + set_Value (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 org.compiere.model.I_C_BPartner getC_BPartnerSR() throws RuntimeException { return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name) @@ -472,6 +555,34 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return (String)get_Value(COLUMNNAME_C_City_Value); } + public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException + { + return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_Name) + .getPO(getC_Currency_ID(), get_TrxName()); } + + /** Set Currency. + @param C_Currency_ID + The Currency for this record + */ + public void setC_Currency_ID (int C_Currency_ID) + { + if (C_Currency_ID < 1) + set_Value (COLUMNNAME_C_Currency_ID, null); + else + set_Value (COLUMNNAME_C_Currency_ID, Integer.valueOf(C_Currency_ID)); + } + + /** Get Currency. + @return The Currency for this record + */ + public int getC_Currency_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + public org.compiere.model.I_C_UOM getC_UOM() throws RuntimeException { return (org.compiere.model.I_C_UOM)MTable.get(getCtx(), org.compiere.model.I_C_UOM.Table_Name) @@ -671,6 +782,23 @@ public class X_I_FixedAsset extends PO implements I_I_FixedAsset, I_Persistent return (String)get_Value(COLUMNNAME_InventoryNo); } + /** Set ISO Currency Code. + @param ISO_Code + Three letter ISO 4217 Code of the Currency + */ + public void setISO_Code (String ISO_Code) + { + set_Value (COLUMNNAME_ISO_Code, ISO_Code); + } + + /** Get ISO Currency Code. + @return Three letter ISO 4217 Code of the Currency + */ + public String getISO_Code () + { + return (String)get_Value(COLUMNNAME_ISO_Code); + } + /** Set Locator Key. @param LocatorValue Key of the Warehouse Locator diff --git a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java index 374fdaf68c..8eb066edbc 100644 --- a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java +++ b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java @@ -4,7 +4,11 @@ import java.math.BigDecimal; import java.sql.Timestamp; import java.util.logging.Level; +import org.compiere.model.MAsset; +import org.compiere.model.MAssetAcct; import org.compiere.model.MAssetAddition; +import org.compiere.model.MAssetGroupAcct; +import org.compiere.model.MDepreciationWorkfile; import org.compiere.model.MIFixedAsset; import org.compiere.model.POResultSet; import org.compiere.model.Query; @@ -73,7 +77,7 @@ public class ImportFixedAsset extends SvrProcess */ protected String doIt() throws java.lang.Exception { - StringBuffer sql = null; + StringBuilder sql = null; int no = 0; if(p_AD_Client_ID==0) p_AD_Client_ID = Env.getAD_Client_ID(getCtx()); @@ -84,14 +88,14 @@ public class ImportFixedAsset extends SvrProcess // Delete Old Imported if (p_DeleteOldImported) { - sql = new StringBuffer ("DELETE "+X_I_FixedAsset.Table_Name + sql = new StringBuilder ("DELETE "+X_I_FixedAsset.Table_Name + " WHERE I_IsImported='Y'").append (sqlCheck); no = DB.executeUpdateEx(sql.toString(), get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Delete Old Imported =" + no); } // Set Client, Org, IsActive, Created/Updated - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+ " " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+ " " + "SET AD_Client_ID = COALESCE (AD_Client_ID,").append (p_AD_Client_ID).append (")," + " AD_Org_ID = COALESCE (AD_Org_ID,").append (p_AD_Org_ID).append (")," + " IsActive = COALESCE (IsActive, 'Y')," @@ -106,8 +110,8 @@ public class ImportFixedAsset extends SvrProcess if (log.isLoggable(Level.INFO)) log.info ("Reset=" + no); // Check if Org is Null or 0 - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " - + "SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '" + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '" + "WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0" + " OR EXISTS (SELECT * FROM AD_Org oo WHERE ifa.AD_Org_ID=oo.AD_Org_ID AND (oo.IsSummary='Y' OR oo.IsActive='N')))" + " AND I_IsImported<>'Y'").append (sqlCheck); @@ -116,15 +120,15 @@ public class ImportFixedAsset extends SvrProcess log.warning ("Invalid Org=" + no); // Check if Name is Null - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " - + "SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Name Is Mandatory, '" + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Name Is Mandatory, '" + "WHERE Name IS NULL AND I_IsImported<>'Y'").append (sqlCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.warning ("Invalid Name=" + no); // Asset Group From Value - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + "SET A_Asset_Group_ID=(SELECT MAX(A_Asset_Group_ID) FROM A_Asset_Group t" + " WHERE ifa.A_Asset_Group_Value=t.Name AND ifa.AD_Client_ID=t.AD_Client_ID) " + "WHERE A_Asset_Group_ID IS NULL AND A_Asset_Group_Value IS NOT NULL" @@ -133,8 +137,8 @@ public class ImportFixedAsset extends SvrProcess if (log.isLoggable(Level.FINE)) log.fine("Set Asset Group from Value=" + no); // Check if Asset Group Have Asset Group Acct Record - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " - + "SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Asset Group Doesnt Have Asset Group Acct Record, ' " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Asset Group Doesnt Have Asset Group Acct Record, ' " + "WHERE A_Asset_Group_ID IS NOT NULL AND A_Asset_Group_ID>0 " //@win change to AND from OR + "AND NOT EXISTS (SELECT 1 FROM A_Asset_Group_Acct aga WHERE ifa.A_Asset_Group_ID=aga.A_Asset_Group_ID) " //@win change to AND from OR + "AND I_IsImported<>'Y'").append (sqlCheck); @@ -154,7 +158,7 @@ public class ImportFixedAsset extends SvrProcess */ // BP From Value - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + "SET C_BPartnerSR_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner t" + " WHERE ifa.BPartner_Value=t.Value AND ifa.AD_Client_ID=t.AD_Client_ID) " + "WHERE C_BPartnerSR_ID IS NULL AND BPartner_Value IS NOT NULL" @@ -163,7 +167,7 @@ public class ImportFixedAsset extends SvrProcess if (log.isLoggable(Level.FINE)) log.fine("Set BP from Value=" + no); // City From Value - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + "SET C_City_ID=(SELECT MAX(C_City_ID) FROM C_City t" + " WHERE ifa.C_City_Value=t.Name AND ifa.AD_Client_ID=t.AD_Client_ID) " + "WHERE C_City_ID IS NULL AND C_City_Value IS NOT NULL" @@ -172,7 +176,7 @@ public class ImportFixedAsset extends SvrProcess if (log.isLoggable(Level.FINE)) log.fine("Set City from Value=" + no); // Product - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product t" + " WHERE ifa.ProductValue=t.Value AND ifa.AD_Client_ID=t.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL" @@ -180,8 +184,8 @@ public class ImportFixedAsset extends SvrProcess no = DB.executeUpdate(sql.toString(), get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Set Product from Value=" + no); - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " - + "SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' " + "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (sqlCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -189,8 +193,8 @@ public class ImportFixedAsset extends SvrProcess log.warning ("Invalid Product=" + no); // Check if Product using Product Category has A Asset Category Set - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " - + "SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Product Using Product Category Without Asset Group Defined, ' " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product Using Product Category Without Asset Group Defined, ' " + "WHERE EXISTS (SELECT 1 FROM M_Product p " + "JOIN M_Product_Category pc ON p.M_Product_Category_ID=pc.M_Product_Category_ID " + "WHERE ifa.M_Product_ID=p.M_Product_ID " @@ -201,13 +205,82 @@ public class ImportFixedAsset extends SvrProcess log.warning ("Invalid Product Category=" + no); // Locator From Value - sql = new StringBuffer ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa " + "SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Product t" + " WHERE ifa.LocatorValue=t.Value AND ifa.AD_Client_ID=t.AD_Client_ID) " + "WHERE M_Locator_ID IS NULL AND LocatorValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (sqlCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Set Locator from Value=" + no); + + // Currency From ISO Code + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET C_Currency_ID=(SELECT c.C_Currency_ID FROM C_Currency c") + .append(" WHERE c.ISO_Code=ifa.ISO_Code AND c.AD_Client_ID IN (0,ifa.AD_Client_ID)) ") + .append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NOT NULL") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("Set Currency from ISO=" + no); + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET C_Currency_ID=(SELECT a.C_Currency_ID FROM C_AcctSchema a") + .append(" WHERE a.C_AcctSchema_ID=ifa.C_AcctSchema_ID AND a.AD_Client_ID=ifa.AD_Client_ID)") + .append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("Set Default Currency=" + no); + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Currency, '") + .append("WHERE (C_Currency_ID IS NULL OR C_Currency_ID=0)") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (no != 0) + log.warning ("Invalid Currency=" + no); + + // AcctSchema From Name + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET C_AcctSchema_ID=(SELECT a.C_AcctSchema_ID FROM C_AcctSchema a") + .append(" WHERE ifa.AcctSchemaName=a.Name AND ifa.AD_Client_ID=a.AD_Client_ID) ") + .append("WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NOT NULL") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("Set AcctSchema from Name=" + no); + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET C_AcctSchema_ID=(SELECT c.C_AcctSchema1_ID FROM AD_ClientInfo c WHERE c.AD_Client_ID=ifa.AD_Client_ID) ") + .append("WHERE C_AcctSchema_ID IS NULL AND AcctSchemaName IS NULL") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("Set AcctSchema from Client=" + no); + // Error AcctSchema + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid AcctSchema, '") + .append("WHERE (C_AcctSchema_ID IS NULL OR C_AcctSchema_ID=0") + .append(" OR NOT EXISTS (SELECT * FROM C_AcctSchema a WHERE ifa.AD_Client_ID=a.AD_Client_ID))") + .append(" AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (no != 0) + log.warning ("Invalid AcctSchema=" + no); + + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=AssetServiceDate Is Mandatory, '") + .append("WHERE AssetServiceDate IS NULL AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (no != 0) + log.warning ("No AssetServiceDate=" + no); + + sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") + .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=AssetDepreciationDate Is Mandatory, '") + .append("WHERE AssetDepreciationDate IS NULL AND I_IsImported<>'Y'").append (sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + if (no != 0) + log.warning ("No AssetDepreciationDate=" + no); + +// // Set DateAcct (mandatory) +// sql = new StringBuilder ("UPDATE "+MIFixedAsset.Table_Name+" ifa ") +// .append("SET DateAcct=SysDate ") +// .append("WHERE DateAcct IS NULL") +// .append(" AND I_IsImported<>'Y'").append (sqlCheck); +// no = DB.executeUpdate(sql.toString(), get_TrxName()); +// if (log.isLoggable(Level.FINE)) log.fine("Set DateAcct=" + no); //-- New BPartner --------------------------------------------------- @@ -332,16 +405,16 @@ public class ImportFixedAsset extends SvrProcess commitEx(); */ //commented by @win - if(p_IsValidateOnly) + if (p_IsValidateOnly) return "Data Was Validated"; - int cnt_ok = 0; - int cnt_err = 0; + int noInsert = 0; + int noUpdate = 0; String whereClause = "NVL(I_IsImported,'N')='N'"+sqlCheck; - POResultSet - rs = new Query(getCtx(), X_I_FixedAsset.Table_Name, whereClause, get_TrxName()) - .scroll(); + POResultSet rs = new Query(getCtx(), X_I_FixedAsset.Table_Name, whereClause, get_TrxName()) + .setOrderBy(X_I_FixedAsset.COLUMNNAME_I_FixedAsset_ID) + .scroll(); try { while (rs.hasNext()) { @@ -349,41 +422,126 @@ public class ImportFixedAsset extends SvrProcess MIFixedAsset ifa = new MIFixedAsset(getCtx(), xfa.getI_FixedAsset_ID(), get_TrxName()); try { + boolean isUpdate = ifa.getA_Asset_ID() > 0; + if (ifa.getA_Asset_ID() == 0) + { + // check for existing active asset by name and inventory no + sql = new StringBuilder("SELECT A_Asset_ID FROM A_Asset WHERE IsActive='Y' AND Name=? AND InventoryNo=?"); + int A_Asset_ID = DB.getSQLValue(get_TrxName(), sql.toString(), ifa.getName(), ifa.getInventoryNo()); + if (A_Asset_ID > 0) + { + isUpdate = true; + ifa.setA_Asset_ID(A_Asset_ID); + ifa.saveEx(); + } + } + + if (ifa.getDateAcct() == null && p_DateAcct != null) + ifa.setDateAcct(p_DateAcct); + MAssetAddition assetAdd = MAssetAddition.createAsset(ifa); - if(assetAdd==null){ + if (assetAdd == null) + { ifa.setI_ErrorMsg("Failed Create Assets"); - cnt_err++; - assetAdd=null; + assetAdd = null; continue; } - //if(p_A_Asset_Group_ID>0) - // assetAdd.getA_Asset().setA_Asset_Group_ID(p_A_Asset_Group_ID); - if(p_DateAcct!=null) - assetAdd.setDateAcct(p_DateAcct); - assetAdd.saveEx(); - //Process Asset Addition Based on Document Action - if(!assetAdd.processIt(ifa.getDocAction())){ + ifa.setA_Asset_ID(assetAdd.getA_Asset_ID()); + + 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())) + { + if (assetgrpacct.getAD_Org_ID() == 0 || assetgrpacct.getAD_Org_ID() == asset.getAD_Org_ID()) + { + if (assetgrpacct.getC_AcctSchema_ID() != ifa.getC_AcctSchema_ID()) + continue; + + // Asset Accounting + MAssetAcct assetacct = new MAssetAcct(asset, assetgrpacct); + assetacct.setAD_Org_ID(asset.getAD_Org_ID()); //added by @win + assetacct.saveEx(); + + // Asset Depreciation Workfile + MDepreciationWorkfile assetworkFile = new MDepreciationWorkfile(asset, assetacct.getPostingType(), assetgrpacct); + assetworkFile.setAD_Org_ID(asset.getAD_Org_ID()); //added by @win + assetworkFile.setUseLifeYears(assetgrpacct.getUseLifeYears()); + assetworkFile.setUseLifeMonths(assetgrpacct.getUseLifeMonths()); + assetworkFile.setUseLifeYears_F(assetgrpacct.getUseLifeYears_F()); + assetworkFile.setUseLifeMonths_F(assetgrpacct.getUseLifeMonths_F()); + assetworkFile.saveEx(); + } + } + } + + for (MDepreciationWorkfile assetworkFile : MDepreciationWorkfile.forA_Asset_ID(getCtx(), ifa.getA_Asset_ID(), get_TrxName())) + { + if (assetworkFile.getC_AcctSchema_ID() != ifa.getC_AcctSchema_ID()) + continue; + + if (ifa.getAssetDepreciationDate() != null) + assetworkFile.setAssetDepreciationDate(ifa.getAssetDepreciationDate()); + + assetworkFile.setDateAcct(assetAdd.getDateAcct()); + + BigDecimal assetCost = ifa.getA_Asset_Cost(); + if (assetCost == null) + assetCost = Env.ZERO; + assetworkFile.setA_Asset_Cost(assetCost); + + BigDecimal accumulatedDepr = ifa.getA_Accumulated_Depr(); + if (accumulatedDepr == null) + accumulatedDepr = Env.ZERO; + assetworkFile.setA_Accumulated_Depr(accumulatedDepr); + + BigDecimal accumulatedDeprF = ifa.getA_Accumulated_Depr_F(); + if (accumulatedDeprF == null) + accumulatedDeprF = Env.ZERO; + assetworkFile.setA_Accumulated_Depr_F(accumulatedDeprF); + + BigDecimal salvageValue = ifa.getA_Salvage_Value(); + if (salvageValue == null) + salvageValue = Env.ZERO; + assetworkFile.setA_Salvage_Value(salvageValue); + + assetworkFile.setUseLifeMonths(ifa.getUseLifeMonths()); + assetworkFile.setUseLifeMonths_F(ifa.getUseLifeMonths_F()); + + int currentPeriod = ifa.getA_Current_Period(); + if (currentPeriod == 0) + { + int useLifeMonths = ifa.getUseLifeMonths(); + if (useLifeMonths > 0) + currentPeriod = (int) (accumulatedDepr.doubleValue() / (assetCost.doubleValue() / useLifeMonths)); + } + assetworkFile.setA_Current_Period(currentPeriod > 0 ? currentPeriod : 1); + + assetworkFile.saveEx(); + } + + // Process Asset Addition Based on Document Action + if (!assetAdd.processIt(ifa.getDocAction())) + { ifa.setI_ErrorMsg("Failed Process Asset Addition"); - cnt_err++; - assetAdd=null; + assetAdd = null; continue; } assetAdd.saveEx(); ifa.setI_IsImported(true); ifa.setI_ErrorMsg(null); - ifa.setA_Asset_ID(assetAdd.getA_Asset_ID()); ifa.setProcessed(true); ifa.saveEx(); - - - cnt_ok++; + if (isUpdate) + noUpdate++; + else + noInsert++; } catch (Exception e) { ifa.setI_ErrorMsg(e.getLocalizedMessage()); - cnt_err++; ifa.saveEx(); } } @@ -392,8 +550,13 @@ public class ImportFixedAsset extends SvrProcess { DB.close(rs); rs = null; // - addLog (0, null, new BigDecimal (cnt_ok), "Imported @Ok@: "); - addLog (0, null, new BigDecimal (cnt_err), "Imported @Error@: "); + sql = new StringBuilder ("UPDATE "+X_I_FixedAsset.Table_Name) + .append(" SET I_IsImported='N', Updated=SysDate ") + .append("WHERE I_IsImported<>'Y'").append(sqlCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + addLog (0, null, new BigDecimal (no), "@Errors@"); + addLog (0, null, new BigDecimal (noInsert), "@A_Asset_ID@: @Inserted@"); + addLog (0, null, new BigDecimal (noUpdate), "@A_Asset_ID@: @Updated@"); } return ""; From 6c56100724327590387827b3bfcda0f3d16406c1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 24 Mar 2020 21:23:09 +0100 Subject: [PATCH 5/8] IDEMPIERE-4221 PackOut type "Data Single" (FHCA-1198) --- .../oracle/202003241800_IDEMPIERE-4221.sql | 19 +++++++++++++++++++ .../202003241800_IDEMPIERE-4221.sql | 16 ++++++++++++++++ .../org/compiere/model/MPackageExpDetail.java | 2 ++ .../model/X_AD_Package_Exp_Detail.java | 4 +++- org.adempiere.pipo.handlers/plugin.xml | 4 ++++ .../handler/GenericPOElementHandler.java | 5 ++++- .../org/adempiere/pipo2/IHandlerRegistry.java | 1 + .../org/adempiere/pipo2/PackOutProcess.java | 4 +++- 8 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 migration/i7.1/oracle/202003241800_IDEMPIERE-4221.sql create mode 100644 migration/i7.1/postgresql/202003241800_IDEMPIERE-4221.sql diff --git a/migration/i7.1/oracle/202003241800_IDEMPIERE-4221.sql b/migration/i7.1/oracle/202003241800_IDEMPIERE-4221.sql new file mode 100644 index 0000000000..25890cf5f4 --- /dev/null +++ b/migration/i7.1/oracle/202003241800_IDEMPIERE-4221.sql @@ -0,0 +1,19 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-4221 PackOut type Data Single (FHCA-1198) +-- Mar 24, 2020, 6:00:23 PM CET +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200492,'Data Single',50004,'DS',0,0,'Y',TO_DATE('2020-03-24 18:00:23','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-03-24 18:00:23','YYYY-MM-DD HH24:MI:SS'),100,'D','bb6620c6-4cef-4796-90d6-007b83fe213f') +; + +-- Mar 24, 2020, 6:26:24 PM CET +UPDATE AD_Field SET DisplayLogic='@Type@=''T''|@Type@=''D''|@Type@=''DS''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-03-24 18:26:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50103 +; + +-- Mar 24, 2020, 6:28:56 PM CET +UPDATE AD_Field SET DisplayLogic='@Type@=''D''|@Type@=''DS''|Type@=''SQL''|Type@=''SQM''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-03-24 18:28:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50105 +; + +SELECT register_migration_script('202003241800_IDEMPIERE-4221.sql') FROM dual +; + diff --git a/migration/i7.1/postgresql/202003241800_IDEMPIERE-4221.sql b/migration/i7.1/postgresql/202003241800_IDEMPIERE-4221.sql new file mode 100644 index 0000000000..05d0696ddc --- /dev/null +++ b/migration/i7.1/postgresql/202003241800_IDEMPIERE-4221.sql @@ -0,0 +1,16 @@ +-- IDEMPIERE-4221 PackOut type Data Single (FHCA-1198) +-- Mar 24, 2020, 6:00:23 PM CET +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200492,'Data Single',50004,'DS',0,0,'Y',TO_TIMESTAMP('2020-03-24 18:00:23','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-03-24 18:00:23','YYYY-MM-DD HH24:MI:SS'),100,'D','bb6620c6-4cef-4796-90d6-007b83fe213f') +; + +-- Mar 24, 2020, 6:26:24 PM CET +UPDATE AD_Field SET DisplayLogic='@Type@=''T''|@Type@=''D''|@Type@=''DS''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-03-24 18:26:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50103 +; + +-- Mar 24, 2020, 6:28:56 PM CET +UPDATE AD_Field SET DisplayLogic='@Type@=''D''|@Type@=''DS''|Type@=''SQL''|Type@=''SQM''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-03-24 18:28:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50105 +; + +SELECT register_migration_script('202003241800_IDEMPIERE-4221.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MPackageExpDetail.java b/org.adempiere.base/src/org/compiere/model/MPackageExpDetail.java index 06bc61f6f9..26309a56dd 100644 --- a/org.adempiere.base/src/org/compiere/model/MPackageExpDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MPackageExpDetail.java @@ -91,6 +91,8 @@ public class MPackageExpDetail extends X_AD_Package_Exp_Detail return 0; } else if (TYPE_Data.equals(type)) { return 0; + } else if (TYPE_DataSingle.equals(type)) { + return 0; } else if (TYPE_DynamicValidationRule.equals(type)) { return getAD_Val_Rule_ID(); } else if (TYPE_Form.equals(type)) { diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_Package_Exp_Detail.java b/org.adempiere.base/src/org/compiere/model/X_AD_Package_Exp_Detail.java index 1665f54786..5df052f50b 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_Package_Exp_Detail.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_Package_Exp_Detail.java @@ -30,7 +30,7 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta /** * */ - private static final long serialVersionUID = 20191121L; + private static final long serialVersionUID = 20200324L; /** Standard Constructor */ public X_AD_Package_Exp_Detail (Properties ctx, int AD_Package_Exp_Detail_ID, String trxName) @@ -945,6 +945,8 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta public static final String TYPE_SQLMandatory = "SQM"; /** Info Window = IW */ public static final String TYPE_InfoWindow = "IW"; + /** Data Single = DS */ + public static final String TYPE_DataSingle = "DS"; /** Set Type. @param Type Type of Validation (SQL, Java Script, Java Language) diff --git a/org.adempiere.pipo.handlers/plugin.xml b/org.adempiere.pipo.handlers/plugin.xml index 898e6fb806..818b89e3dc 100644 --- a/org.adempiere.pipo.handlers/plugin.xml +++ b/org.adempiere.pipo.handlers/plugin.xml @@ -180,6 +180,10 @@ class="org.adempiere.pipo2.handler.GenericPOElementHandler" id="table.genericHandler"> + + diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java index c4b9e40f86..6e98ff64d6 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java @@ -32,6 +32,7 @@ import org.adempiere.pipo2.AbstractElementHandler; import org.adempiere.pipo2.DataElementParameters; import org.adempiere.pipo2.Element; import org.adempiere.pipo2.ElementHandler; +import org.adempiere.pipo2.IHandlerRegistry; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PackoutItem; @@ -172,7 +173,9 @@ public class GenericPOElementHandler extends AbstractElementHandler { } if (createElement) { - if (po.get_KeyColumns() != null && po.get_KeyColumns().length == 1 && po.get_ID() > 0) { + // + if (po.get_KeyColumns() != null && po.get_KeyColumns().length == 1 && po.get_ID() > 0 + && ! IHandlerRegistry.TABLE_GENERIC_SINGLE_HANDLER.equals(ctx.packOut.getCurrentPackoutItem().getType())) { ElementHandler handler = ctx.packOut.getHandler(po.get_TableName()); if (handler != null && !handler.getClass().equals(this.getClass()) ) { handler.packOut(ctx.packOut, document, ctx.logDocument, po.get_ID()); diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/IHandlerRegistry.java b/org.adempiere.pipo/src/org/adempiere/pipo2/IHandlerRegistry.java index fd519f395f..09cbae743d 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/IHandlerRegistry.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/IHandlerRegistry.java @@ -9,6 +9,7 @@ public interface IHandlerRegistry { public static final String TABLE_TRANSLATION_HANDLER = "table.translationHandler"; public static final String TABLE_GENERIC_HANDLER = "table.genericHandler"; + public static final String TABLE_GENERIC_SINGLE_HANDLER = "table.genericSingleHandler"; /** * @param element diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java index e7c267d197..362d4a346d 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java @@ -162,6 +162,8 @@ public class PackOutProcess extends SvrProcess return "Code_Snipit"; else if (X_AD_Package_Exp_Detail.TYPE_Data.equals(type)) return IHandlerRegistry.TABLE_GENERIC_HANDLER; + else if (X_AD_Package_Exp_Detail.TYPE_DataSingle.equals(type)) + return IHandlerRegistry.TABLE_GENERIC_SINGLE_HANDLER; else if (X_AD_Package_Exp_Detail.TYPE_DynamicValidationRule.equals(type)) return I_AD_Val_Rule.Table_Name; else if (X_AD_Package_Exp_Detail.TYPE_File_CodeOrOther.equals(type)) @@ -204,7 +206,7 @@ public class PackOutProcess extends SvrProcess private Map getExpProperties(MPackageExpDetail dtl) { Map properties = new HashMap(); String type = dtl.getType(); - if (MPackageExpDetail.TYPE_Data.equals(type)) { + if (MPackageExpDetail.TYPE_Data.equals(type) || MPackageExpDetail.TYPE_DataSingle.equals(type)) { properties.put(DataElementParameters.AD_TABLE_ID, dtl.getAD_Table_ID()); properties.put(DataElementParameters.SQL_STATEMENT, dtl.getSQLStatement()); } else if (MPackageExpDetail.TYPE_SQLStatement.equals(type) || MPackageExpDetail.TYPE_SQLMandatory.equals(type)) { From 132cc4036c3031671182a8b16aef811b71760264 Mon Sep 17 00:00:00 2001 From: hengsin Date: Wed, 25 Mar 2020 10:33:49 +0800 Subject: [PATCH 6/8] IDEMPIERE-4200 AR Payment Allocation: Incorrect Currency Balancing Postings --- .../org/compiere/acct/Doc_AllocationHdr.java | 1342 ++++++++++------- 1 file changed, 765 insertions(+), 577 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java index 077146c359..9b656af07c 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java @@ -37,7 +37,6 @@ import org.compiere.model.MInvoice; import org.compiere.model.MInvoiceLine; import org.compiere.model.MOrder; import org.compiere.model.MPayment; -import org.compiere.model.MPeriod; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -76,10 +75,9 @@ public class Doc_AllocationHdr extends Doc private static final BigDecimal TOLERANCE = BigDecimal.valueOf(0.02); /** Facts */ private ArrayList m_facts = null; - private Hashtable htGainLossAmtByInv = new Hashtable(); - private Hashtable htGainLossAmtByCM = new Hashtable(); - private ArrayList gainLossFactList; - + + private ArrayList invGainLossFactLines = null; + private ArrayList payGainLossFactLines = null; /** * Load Specific Document Details @@ -173,17 +171,14 @@ public class Doc_AllocationHdr extends Doc public ArrayList createFacts (MAcctSchema as) { m_facts = new ArrayList(); + invGainLossFactLines = new ArrayList(); + payGainLossFactLines = new ArrayList(); // create Fact Header Fact fact = new Fact(this, as, Fact.POST_Actual); Fact factForRGL = new Fact(this, as, Fact.POST_Actual); // dummy fact (not posted) to calculate Realized Gain & Loss boolean isInterOrg = isInterOrg(as); - BigDecimal paymentSelectAmt = Env.ZERO; - BigDecimal totalAllocationSource = Env.ZERO; - MPayment payment = null; - int lineID = 0; MAccount bpAcct = null; // Liability/Receivables - gainLossFactList = new ArrayList(); for (int i = 0; i < p_lines.length; i++) { @@ -210,11 +205,15 @@ public class Doc_AllocationHdr extends Doc FactLine fl = null; FactLine flForRGL = null; // + MPayment payment = null; if (line.getC_Payment_ID() != 0) payment = new MPayment (getCtx(), line.getC_Payment_ID(), getTrxName()); MInvoice invoice = null; if (line.getC_Invoice_ID() != 0) invoice = new MInvoice (getCtx(), line.getC_Invoice_ID(), getTrxName()); + + BigDecimal allocPayAccounted = Env.ZERO; + BigDecimal allocPaySource = Env.ZERO; // No Invoice if (invoice == null) @@ -233,6 +232,7 @@ public class Doc_AllocationHdr extends Doc getC_Currency_ID(), line.getAmtSource(), null); if (fl != null && payment != null) fl.setAD_Org_ID(payment.getAD_Org_ID()); + allocPayAccounted = allocPayAccounted.add(fl.getAcctBalance()); } else { @@ -275,9 +275,9 @@ public class Doc_AllocationHdr extends Doc if (fl != null && payment != null) fl.setAD_Org_ID(payment.getAD_Org_ID()); if (payment.getReversal_ID() > 0 ) - paymentSelectAmt= paymentSelectAmt.add(fl.getAcctBalance().negate()); + allocPayAccounted = allocPayAccounted.add(fl.getAcctBalance().negate()); else - paymentSelectAmt= paymentSelectAmt.add(fl.getAcctBalance()); + allocPayAccounted = allocPayAccounted.add(fl.getAcctBalance()); } else if (line.getC_CashLine_ID() != 0) { @@ -408,7 +408,7 @@ public class Doc_AllocationHdr extends Doc getC_Currency_ID(), null, line.getAmtSource().negate()); if (fl != null && payment != null) fl.setAD_Org_ID(payment.getAD_Org_ID()); - paymentSelectAmt= paymentSelectAmt.add(fl.getAcctBalance().negate()); + allocPayAccounted = allocPayAccounted.add(fl.getAcctBalance().negate()); } else if (isUsingClearing && line.getC_CashLine_ID() != 0) // Avoid usage of clearing accounts { @@ -446,29 +446,31 @@ public class Doc_AllocationHdr extends Doc && (getC_Currency_ID() != as.getC_Currency_ID() // payment allocation in foreign currency || getC_Currency_ID() != line.getInvoiceC_Currency_ID())) // allocation <> invoice currency { - p_Error = createRealizedGainLoss (line, as, fact, bpAcct, invoice, + p_Error = createInvoiceGainLoss (line, as, fact, bpAcct, invoice, allocationSource, allocationAccounted); if (p_Error != null) return null; - } - totalAllocationSource = totalAllocationSource.add(line.getAmtSource()); - lineID = line.get_ID(); + } + + allocPaySource = allocPaySource.add(line.getAmtSource()); + if (payment != null && getC_Currency_ID() != as.getC_Currency_ID()) + { + p_Error = createPaymentGainLoss (line, as, fact, getPaymentAcct(as, payment.get_ID()), payment, + allocPaySource, allocPayAccounted); + if (p_Error != null) + return null; + } } // for all lines - - // rounding correction - if (payment != null && getC_Currency_ID() != as.getC_Currency_ID() ) // payment allocation in foreign currency - { - p_Error = createPaymentGainLoss (as, fact, getPaymentAcct(as, payment.get_ID()), payment, - totalAllocationSource, paymentSelectAmt, lineID); - if (p_Error != null) - return null; - } + // rounding adjustment if (getC_Currency_ID() != as.getC_Currency_ID()) { - p_Error = createInvoiceRounding (as, fact, bpAcct); + p_Error = createInvoiceRoundingCorrection (as, fact, bpAcct); if (p_Error != null) return null; + p_Error = createPaymentRoundingCorrection (as, fact); + if (p_Error != null) + return null; } // FR [ 1840016 ] Avoid usage of clearing accounts - subject to C_AcctSchema.IsPostIfClearingEqual @@ -730,145 +732,12 @@ public class Doc_AllocationHdr extends Doc * @param allocationSource source amt * @param allocationAccounted acct amt * @return Error Message or null if OK + * */ private String createRealizedGainLoss (DocLine line, MAcctSchema as, Fact fact, MAccount acct, MInvoice invoice, BigDecimal allocationSource, BigDecimal allocationAccounted) { - BigDecimal invoiceSource = null; - BigDecimal invoiceAccounted = null; - // - StringBuilder sql = new StringBuilder() - .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") - .append(" FROM Fact_Acct ") - .append("WHERE AD_Table_ID=? AND Record_ID=?") - .append(" AND C_AcctSchema_ID=?") - .append(" AND Account_ID=?") - .append(" AND PostingType='A'"); - - // For Invoice - List valuesInv = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), - MInvoice.Table_ID, invoice.getC_Invoice_ID(), as.getC_AcctSchema_ID(), acct.getAccount_ID()); - if (valuesInv != null) { - if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID()) - { - if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { - invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr - invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr - } else { - invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr - invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr - } - } - else - { - if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { - invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr - invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr - } else { - invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr - invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr - } - } - } - - // Requires that Invoice is Posted - if (invoiceSource == null || invoiceAccounted == null) - return "Gain/Loss - Invoice not posted yet"; - // - StringBuilder description = new StringBuilder("Invoice=(").append(invoice.getC_Currency_ID()).append(")").append(invoiceSource).append("/").append(invoiceAccounted) - .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocationSource).append("/").append(allocationAccounted); - if (log.isLoggable(Level.FINE)) log.fine(description.toString()); - // Allocation not Invoice Currency - if (getC_Currency_ID() != invoice.getC_Currency_ID()) - { - BigDecimal allocationSourceNew = MConversionRate.convert(getCtx(), - allocationSource, getC_Currency_ID(), - invoice.getC_Currency_ID(), getDateAcct(), - invoice.getC_ConversionType_ID(), invoice.getAD_Client_ID(), invoice.getAD_Org_ID()); - if (allocationSourceNew == null) - return "Gain/Loss - No Conversion from Allocation->Invoice"; - StringBuilder d2 = new StringBuilder("Allocation=(").append(getC_Currency_ID()).append(")").append(allocationSource) - .append("->(").append(invoice.getC_Currency_ID()).append(")").append(allocationSourceNew); - if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); - description.append(" - ").append(d2); - allocationSource = allocationSourceNew; - } - - BigDecimal acctDifference = null; // gain is negative - //reversal entry - if (allocationSource.signum() > 0 ) - { - acctDifference = invoiceAccounted.subtract(allocationAccounted.abs()); - } - // Full Payment in currency - if (allocationSource.abs().compareTo(invoiceSource.abs()) == 0) - { - acctDifference = invoiceAccounted.subtract(allocationAccounted.abs()); // gain is negative - - StringBuilder d2 = new StringBuilder("(full) = ").append(acctDifference); - if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); - description.append(" - ").append(d2); - } - else // partial or MC - { - // percent of total payment - double multiplier = allocationSource.doubleValue() / invoiceSource.doubleValue(); - // Reduce Orig Invoice Accounted - invoiceAccounted = invoiceAccounted.multiply(BigDecimal.valueOf(multiplier)); - // Difference based on percentage of Orig Invoice - acctDifference = invoiceAccounted.subtract(allocationAccounted); // gain is negative - // ignore Tolerance - if (acctDifference.abs().compareTo(TOLERANCE) < 0) - acctDifference = Env.ZERO; - // Round - int precision = as.getStdPrecision(); - if (acctDifference.scale() > precision) - acctDifference = acctDifference.setScale(precision, RoundingMode.HALF_UP); - StringBuilder d2 = new StringBuilder("(partial) = ").append(acctDifference).append(" - Multiplier=").append(multiplier); - if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); - description.append(" - ").append(d2); - } - - if (acctDifference.signum() == 0) - { - log.fine("No Difference"); - return null; - } - - MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); - MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); - BigDecimal cmGainLossAmt = htGainLossAmtByCM.get(invoice.getC_Invoice_ID()); - if (cmGainLossAmt == null) - cmGainLossAmt = Env.ZERO; - BigDecimal gainLossAmt = htGainLossAmtByInv.get(invoice.getC_Invoice_ID()); - if (gainLossAmt == null) - gainLossAmt = Env.ZERO; - if (invoice.isCreditMemo() || invoice.getReversal_ID() > 0) - cmGainLossAmt = cmGainLossAmt.add(acctDifference); - else - gainLossAmt = gainLossAmt.add(acctDifference); - htGainLossAmtByCM.put(invoice.getC_Invoice_ID(), cmGainLossAmt); - htGainLossAmtByInv.put(invoice.getC_Invoice_ID(), gainLossAmt); - // - - if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) - { - FactLine fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference); - fl.setDescription(description.toString()); - fl = fact.createLine (line, acct, as.getC_Currency_ID(), acctDifference.negate()); - gainLossFactList.add(fl); - } - else - { - FactLine fl = fact.createLine (line, acct, - as.getC_Currency_ID(), acctDifference); - gainLossFactList.add(fl); - fl = fact.createLine (line, loss, gain, - as.getC_Currency_ID(), acctDifference.negate()); - fl.setDescription(description.toString()); - - } - return null; + return createInvoiceGainLoss(line, as, fact, acct, invoice, allocationSource, allocationAccounted); } // createRealizedGainLoss @@ -944,19 +813,139 @@ public class Doc_AllocationHdr extends Doc } // createTaxCorrection /************************************************************************** - * Create Rounding Correction. + * Create Realized Gain & Loss. + * Compares the Accounted Amount of the Invoice to the + * Accounted Amount of the Allocation + * @param line Allocation line + * @param as accounting schema + * @param fact fact + * @param acct account + * @param invoice invoice + * @param allocationSource source amt + * @param allocationAccounted acct amt + * @return Error Message or null if OK + */ + private String createInvoiceGainLoss (DocLine line, MAcctSchema as, Fact fact, MAccount acct, + MInvoice invoice, BigDecimal allocationSource, BigDecimal allocationAccounted) + { + BigDecimal invoiceSource = null; + BigDecimal invoiceAccounted = null; + // + StringBuilder sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") + .append(" AND C_AcctSchema_ID=?") + .append(" AND Account_ID=?") + .append(" AND PostingType='A'"); + + // For Invoice + List valuesInv = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MInvoice.Table_ID, invoice.getC_Invoice_ID(), as.getC_AcctSchema_ID(), acct.getAccount_ID()); + if (valuesInv != null) { + if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID()) + { + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { + invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr + invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr + } else { + invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr + invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr + } + } + else + { + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { + invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr + invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr + } else { + invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr + invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr + } + } + } + + // Requires that Invoice is Posted + if (invoiceSource == null || invoiceAccounted == null) + return "Gain/Loss - Invoice not posted yet"; + // + StringBuilder description = new StringBuilder("Invoice=(").append(invoice.getC_Currency_ID()).append(")").append(invoiceSource).append("/").append(invoiceAccounted) + .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocationSource).append("/").append(allocationAccounted); + if (log.isLoggable(Level.FINE)) log.fine(description.toString()); + + BigDecimal acctDifference = null; // gain is negative + // Full Payment in currency + if (allocationSource.abs().compareTo(invoiceSource.abs()) == 0) + { + acctDifference = invoiceAccounted.abs().subtract(allocationAccounted.abs()); // gain is negative + + StringBuilder d2 = new StringBuilder("(full) = ").append(acctDifference); + if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); + description.append(" - ").append(d2); + } + else // partial or MC + { + BigDecimal allocationAccounted0 = MConversionRate.convert(getCtx(), + allocationSource, getC_Currency_ID(), + as.getC_Currency_ID(), invoice.getDateAcct(), + invoice.getC_ConversionType_ID(), invoice.getAD_Client_ID(), invoice.getAD_Org_ID()); + acctDifference = allocationAccounted0.abs().subtract(allocationAccounted.abs()); + // ignore Tolerance + if (acctDifference.abs().compareTo(TOLERANCE) < 0) + acctDifference = Env.ZERO; + // Round + int precision = as.getStdPrecision(); + if (acctDifference.scale() > precision) + acctDifference = acctDifference.setScale(precision, RoundingMode.HALF_UP); + StringBuilder d2 = new StringBuilder("(partial) = ").append(acctDifference); + if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); + description.append(" - ").append(d2); + } + + if (acctDifference.signum() == 0) + { + log.fine("No Difference"); + return null; + } + + MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); + MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); + // + + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) + { + FactLine fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + invGainLossFactLines.add(fl); + fl = fact.createLine (line, acct, as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + } + else + { + FactLine fl = fact.createLine (line, acct, as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + invGainLossFactLines.add(fl); + } + return null; + } + + /************************************************************************** + * Create Realized Gain & Loss. * Compares the Accounted Amount of the Payment to the * Accounted Amount of the Allocation + * @param line Allocation line * @param as accounting schema * @param fact fact * @param acct account * @param payment payment - * @param paymentSource source amt - * @param paymentAccounted acct amt + * @param allocationSource source amt + * @param allocationAccounted acct amt * @return Error Message or null if OK */ - private String createPaymentGainLoss (MAcctSchema as, Fact fact, MAccount acct, - MPayment payment, BigDecimal allocationSource, BigDecimal totalAllocationAccounted, int lineID) + private String createPaymentGainLoss (DocLine line, MAcctSchema as, Fact fact, MAccount acct, + MPayment payment, BigDecimal allocationSource, BigDecimal allocationAccounted) { BigDecimal paymentSource = null; BigDecimal paymentAccounted = null; @@ -986,43 +975,25 @@ public class Doc_AllocationHdr extends Doc return null; //"Gain/Loss - Payment not posted yet"; // StringBuilder description = new StringBuilder("Payment=(").append(payment.getC_Currency_ID()).append(")").append(paymentSource).append("/").append(paymentAccounted) - .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocationSource).append("/").append(totalAllocationAccounted); + .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocationSource).append("/").append(allocationAccounted); if (log.isLoggable(Level.FINE)) log.fine(description.toString()); - boolean isSameSourceDiffPeriod = false; BigDecimal acctDifference = null; // gain is negative // Full Payment in currency if (allocationSource.abs().compareTo(paymentSource.abs()) == 0) { - acctDifference = totalAllocationAccounted.abs().subtract(paymentAccounted.abs()); // gain is negative + acctDifference = allocationAccounted.abs().subtract(paymentAccounted.abs()); // gain is negative StringBuilder d2 = new StringBuilder("(full) = ").append(acctDifference); if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); description.append(" - ").append(d2); - - // Different period - if (MPeriod.getC_Period_ID(getCtx(), payment.getDateAcct(), payment.getAD_Org_ID()) != - MPeriod.getC_Period_ID(getCtx(), getDateAcct(), getAD_Org_ID())) - { - BigDecimal allocationAccounted0 = MConversionRate.convert(getCtx(), - allocationSource, getC_Currency_ID(), - as.getC_Currency_ID(), payment.getDateAcct(), - payment.getC_ConversionType_ID(), payment.getAD_Client_ID(), payment.getAD_Org_ID()); - BigDecimal paymentAccounted0 = MConversionRate.convert(getCtx(), - paymentSource, getC_Currency_ID(), - as.getC_Currency_ID(), getDateAcct(), - getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); - isSameSourceDiffPeriod = allocationAccounted0.abs().compareTo(paymentAccounted.abs()) == 0 && - paymentAccounted0.abs().compareTo(totalAllocationAccounted.abs()) == 0; - } } else { - // percent of total payment - double multiplier = allocationSource.doubleValue() / paymentSource.doubleValue(); - // Reduce Orig Payment Accounted - paymentAccounted = paymentAccounted.multiply(BigDecimal.valueOf(multiplier)); - // Difference based on percentage of Orig Payment - acctDifference = totalAllocationAccounted.abs().subtract(paymentAccounted.abs()); // gain is negative + BigDecimal allocationAccounted0 = MConversionRate.convert(getCtx(), + allocationSource, getC_Currency_ID(), + as.getC_Currency_ID(), payment.getDateAcct(), + payment.getC_ConversionType_ID(), payment.getAD_Client_ID(), payment.getAD_Org_ID()); + acctDifference = allocationAccounted.abs().subtract(allocationAccounted0.abs()); // ignore Tolerance if (acctDifference.abs().compareTo(TOLERANCE) < 0) acctDifference = Env.ZERO; @@ -1030,30 +1001,9 @@ public class Doc_AllocationHdr extends Doc int precision = as.getStdPrecision(); if (acctDifference.scale() > precision) acctDifference = acctDifference.setScale(precision, RoundingMode.HALF_UP); - StringBuilder d2 = new StringBuilder("(partial) = ").append(acctDifference).append(" - Multiplier=").append(multiplier); + StringBuilder d2 = new StringBuilder("(partial) = ").append(acctDifference); if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); description.append(" - ").append(d2); - - // Different period - if (MPeriod.getC_Period_ID(getCtx(), payment.getDateAcct(), payment.getAD_Org_ID()) != - MPeriod.getC_Period_ID(getCtx(), getDateAcct(), getAD_Org_ID())) - { - if (paymentAccounted.scale() > precision) - paymentAccounted = paymentAccounted.setScale(precision, RoundingMode.HALF_UP); - paymentSource = paymentSource.multiply(BigDecimal.valueOf(multiplier)); - if (paymentSource.scale() > precision) - paymentSource = paymentSource.setScale(precision, RoundingMode.HALF_UP); - BigDecimal allocationAccounted0 = MConversionRate.convert(getCtx(), - allocationSource, getC_Currency_ID(), - as.getC_Currency_ID(), payment.getDateAcct(), - payment.getC_ConversionType_ID(), payment.getAD_Client_ID(), payment.getAD_Org_ID()); - BigDecimal paymentAccounted0 = MConversionRate.convert(getCtx(), - paymentSource, getC_Currency_ID(), - as.getC_Currency_ID(), getDateAcct(), - getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); - isSameSourceDiffPeriod = allocationAccounted0.abs().compareTo(paymentAccounted.abs()) == 0 && - paymentAccounted0.abs().compareTo(totalAllocationAccounted.abs()) == 0; - } } if (acctDifference == null || acctDifference.signum() == 0) @@ -1065,38 +1015,21 @@ public class Doc_AllocationHdr extends Doc MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); // - if (payment.isReceipt()) + if ((payment.isReceipt() && payment.getPayAmt().signum() >= 0) || (!payment.isReceipt() && payment.getPayAmt().signum() < 0)) { - FactLine fl = fact.createLine (null, acct,as.getC_Currency_ID(), acctDifference.negate()); + FactLine fl = fact.createLine (line, acct, as.getC_Currency_ID(), acctDifference.negate()); fl.setDescription(description.toString()); - fl.setLine_ID(lineID); - if (!fact.isAcctBalanced()) - { - if (!isSameSourceDiffPeriod && as.isCurrencyBalancing() && as.getC_Currency_ID() != payment.getC_Currency_ID() ) - { - fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference); - } else - { - fl = fact.createLine (null, loss, gain,as.getC_Currency_ID(), acctDifference); - - } - } + fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + payGainLossFactLines.add(fl); } else { - FactLine fl = fact.createLine (null, acct,as.getC_Currency_ID(), acctDifference); + FactLine fl = fact.createLine (line, acct, as.getC_Currency_ID(), acctDifference); fl.setDescription(description.toString()); - fl.setLine_ID(lineID); - if (!fact.isAcctBalanced()) - { - if (!isSameSourceDiffPeriod && as.isCurrencyBalancing() && as.getC_Currency_ID() != payment.getC_Currency_ID() ) - { - fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference.negate()); - } else { - fact.createLine (null, loss, gain, as.getC_Currency_ID(), acctDifference.negate()); - } - } - + fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + payGainLossFactLines.add(fl); } return null; } @@ -1107,22 +1040,16 @@ public class Doc_AllocationHdr extends Doc * Accounted Amount of the AR/AP Allocation * @param as accounting schema * @param fact fact - * @param bpAcct account - * @param payment payment + * @param acct account * @return Error Message or null if OK */ - private String createInvoiceRounding(MAcctSchema as, Fact fact, MAccount bpAcct) + private String createInvoiceRoundingCorrection (MAcctSchema as, Fact fact, MAccount acct) { - PreparedStatement pstmt = null; - ResultSet rs = null; - // Invoice AR/AP ArrayList invList = new ArrayList(); - ArrayList payList = new ArrayList(); Hashtable htInvAllocLine = new Hashtable(); for (int i = 0; i < p_lines.length; i++) { MInvoice invoice = null; - MPayment payment = null; DocLine_Allocation line = (DocLine_Allocation)p_lines[i]; if (line.getC_Invoice_ID() != 0) { @@ -1131,390 +1058,651 @@ public class Doc_AllocationHdr extends Doc invList.add(invoice); htInvAllocLine.put(invoice.getC_Invoice_ID(), line.get_ID()); } - if (line.getC_Payment_ID() != 0) - { - payment = new MPayment (getCtx(), line.getC_Payment_ID(), getTrxName()); - if (!payList.contains(payment)) - payList.add(payment); - } } Hashtable htInvSource = new Hashtable(); Hashtable htInvAccounted = new Hashtable(); for (MInvoice invoice : invList) { - boolean isDebit = false; - // to cater for invoice reverse-accrual. - if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID()) - { - if (invoice.isSOTrx() && !invoice.isCreditMemo()) - isDebit = true; - else if (!invoice.isSOTrx() && invoice.isCreditMemo()) - isDebit = true; - } - else - { - if (!invoice.isSOTrx() && !invoice.isCreditMemo()) - isDebit = true; - else if (invoice.isSOTrx() && invoice.isCreditMemo()) - isDebit = true; - } - // - StringBuilder sql = new StringBuilder("SELECT ") - .append((isDebit ) - ? "SUM(AmtSourceDr), SUM(AmtAcctDr)" // so - : "SUM(AmtSourceCr), SUM(AmtAcctCr)") // po + StringBuilder sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") .append(" FROM Fact_Acct ") - .append("WHERE AD_Table_ID=? AND Record_ID=?") // Invoice + .append("WHERE AD_Table_ID=? AND Record_ID=?") .append(" AND C_AcctSchema_ID=?") - .append(" AND PostingType='A'") - .append(" AND Account_ID= ? "); - pstmt = null; - rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), getTrxName()); - pstmt.setInt(1, MInvoice.Table_ID); - pstmt.setInt(2, invoice.getC_Invoice_ID()); - pstmt.setInt(3, as.getC_AcctSchema_ID()); - pstmt.setInt(4, bpAcct.getAccount_ID()); - rs = pstmt.executeQuery(); - if (rs.next()) + .append(" AND Account_ID=?") + .append(" AND PostingType='A'"); + + // For Invoice + List valuesInv = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MInvoice.Table_ID, invoice.getC_Invoice_ID(), as.getC_AcctSchema_ID(), acct.getAccount_ID()); + if (valuesInv != null) { + BigDecimal invoiceSource = null; + BigDecimal invoiceAccounted = null; + if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID()) { - BigDecimal invoiceSource = rs.getBigDecimal(1); - BigDecimal invoiceAccounted = rs.getBigDecimal(2); - htInvSource.put(invoice.getC_Invoice_ID(), invoiceSource); - htInvAccounted.put(invoice.getC_Invoice_ID(), invoiceAccounted); - } + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { + invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr + invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr + } else { + invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr + invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr + } + } + else + { + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { + invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr + invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr + } else { + invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr + invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr + } + } + htInvSource.put(invoice.getC_Invoice_ID(), invoiceSource); + htInvAccounted.put(invoice.getC_Invoice_ID(), invoiceAccounted); } - catch (Exception e) + } + + MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); + MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); + + Hashtable htTotalAmtSourceDr = new Hashtable(); + Hashtable htTotalAmtAcctDr = new Hashtable(); + Hashtable htTotalAmtSourceCr = new Hashtable(); + Hashtable htTotalAmtAcctCr = new Hashtable(); + FactLine[] factlines = fact.getLines(); + for (FactLine factLine : factlines) + { + if (factLine.getLine_ID() > 0) { - throw new RuntimeException(e.getLocalizedMessage(), e); + MAllocationLine allocationLine = new MAllocationLine(getCtx(), factLine.getLine_ID(), getTrxName()); + if (allocationLine.getC_Invoice_ID() > 0) + { + if (factLine.getAccount_ID() == acct.getAccount_ID()) + { + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtAcctDr = htTotalAmtAcctDr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + BigDecimal totalAmtAcctCr = htTotalAmtAcctCr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + totalAmtSourceDr = totalAmtSourceDr.add(factLine.getAmtSourceDr()); + totalAmtAcctDr = totalAmtAcctDr.add(factLine.getAmtAcctDr()); + totalAmtSourceCr = totalAmtSourceCr.add(factLine.getAmtSourceCr()); + totalAmtAcctCr = totalAmtAcctCr.add(factLine.getAmtAcctCr()); + + htTotalAmtSourceDr.put(allocationLine.getC_Invoice_ID(), totalAmtSourceDr); + htTotalAmtAcctDr.put(allocationLine.getC_Invoice_ID(), totalAmtAcctDr); + htTotalAmtSourceCr.put(allocationLine.getC_Invoice_ID(), totalAmtSourceCr); + htTotalAmtAcctCr.put(allocationLine.getC_Invoice_ID(), totalAmtAcctCr); + } + else if (factLine.getAccount_ID() == gain.getAccount_ID() || factLine.getAccount_ID() == loss.getAccount_ID()) + { + if (!invGainLossFactLines.contains(factLine)) + continue; + + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(allocationLine.getC_Invoice_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + + totalAmtSourceDr = totalAmtSourceDr.subtract(factLine.getAmtSourceCr()); + totalAmtSourceCr = totalAmtSourceCr.subtract(factLine.getAmtSourceDr()); + + htTotalAmtSourceDr.put(allocationLine.getC_Invoice_ID(), totalAmtSourceDr); + htTotalAmtSourceCr.put(allocationLine.getC_Invoice_ID(), totalAmtSourceCr); + } + } } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } } Hashtable htAllocInvSource = new Hashtable(); Hashtable htAllocInvAccounted = new Hashtable(); - Hashtable htIsExcludeCMGainLoss = new Hashtable(); - Hashtable htIsCMReversal = new Hashtable(); - FactLine[] factlines = fact.getLines(); - for (FactLine factLine : factlines) - { - if (bpAcct != null) - { - if (factLine.getAccount_ID() == bpAcct.getAccount_ID()) - { - MAllocationLine allocationLine = null; - if (factLine.getLine_ID() != 0) - allocationLine = new MAllocationLine(getCtx(), factLine.getLine_ID(), getTrxName()); - - MInvoice invoice = null; - MPayment payment = null; - if (allocationLine != null) - { - invoice = allocationLine.getInvoice(); - if (allocationLine.getC_Payment_ID() > 0) - payment = new MPayment (getCtx(), allocationLine.getC_Payment_ID(), getTrxName()); - } + for (MInvoice invoice : invList) + { + BigDecimal allocateSource = Env.ZERO; + BigDecimal allocateAccounted = Env.ZERO; - BigDecimal allocInvoiceSource = htAllocInvSource.get(allocationLine.getC_Invoice_ID()); - if (allocInvoiceSource == null) - allocInvoiceSource = Env.ZERO; - BigDecimal allocInvoiceAccounted = htAllocInvAccounted.get(allocationLine.getC_Invoice_ID()); - if (allocInvoiceAccounted == null) - allocInvoiceAccounted = Env.ZERO; - BigDecimal cmGainLossAmt = htGainLossAmtByCM.get(invoice.getC_Invoice_ID()); - if (cmGainLossAmt == null) - cmGainLossAmt = Env.ZERO; - BigDecimal gainLossAmt = htGainLossAmtByInv.get(invoice.getC_Invoice_ID()); - if (gainLossAmt == null) - gainLossAmt = Env.ZERO; - Boolean isExcludeCMGainLoss = htIsExcludeCMGainLoss.get(invoice.getC_Invoice_ID()); - if (isExcludeCMGainLoss == null) - isExcludeCMGainLoss = Boolean.FALSE; - Boolean isCMReversal = htIsCMReversal.get(invoice.getC_Invoice_ID()); - if (isCMReversal == null) - isCMReversal = Boolean.FALSE; - if (invoice.isSOTrx()) + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(invoice.getC_Invoice_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtAcctDr = htTotalAmtAcctDr.get(invoice.getC_Invoice_ID()); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(invoice.getC_Invoice_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + BigDecimal totalAmtAcctCr = htTotalAmtAcctCr.get(invoice.getC_Invoice_ID()); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + if (totalAmtSourceDr.signum() == 0 && totalAmtAcctDr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr); + } + else if (totalAmtSourceCr.signum() == 0 && totalAmtAcctCr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr); + } + else + { + if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr); + } + else + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr); + } + } + + MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(), invoice.get_ID(), getTrxName()); + for (MAllocationHdr alloc : allocations) + { + if (alloc.get_ID() == get_ID()) + continue; + + BigDecimal currencyAdjustment = Env.ZERO; + StringBuilder sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") // allocation + .append(" AND C_AcctSchema_ID=?") + .append(" AND PostingType='A'") + .append(" AND Account_ID=?") + .append(" AND Line_ID IN (SELECT C_AllocationLine_ID FROM C_AllocationLine WHERE C_AllocationHdr_ID=? AND C_Invoice_ID=?)"); + + // For Allocation + List valuesAlloc = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MAllocationHdr.Table_ID, alloc.get_ID(), as.getC_AcctSchema_ID(), acct.getAccount_ID(), alloc.get_ID(), invoice.getC_Invoice_ID()); + if (valuesAlloc != null) { + totalAmtSourceDr = (BigDecimal) valuesAlloc.get(0); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + totalAmtAcctDr = (BigDecimal) valuesAlloc.get(1); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + totalAmtSourceCr = (BigDecimal) valuesAlloc.get(2); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + totalAmtAcctCr = (BigDecimal) valuesAlloc.get(3); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + if (totalAmtSourceDr.signum() == 0 && totalAmtAcctDr.signum() == 0) { - if (factLine.getC_Currency_ID() != as.getC_Currency_ID()) - { - if (!invoice.isCreditMemo()) - allocInvoiceSource = allocInvoiceSource.add(factLine.getAmtSourceCr()); - else - allocInvoiceSource = allocInvoiceSource.add(factLine.getAmtSourceDr()); - } - if (!gainLossFactList.contains(factLine) && !invoice.isCreditMemo()) - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctCr()); - else if (!gainLossFactList.contains(factLine) && invoice.isCreditMemo()) - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctDr()); - - if (!gainLossFactList.contains(factLine) && invoice.isCreditMemo() && invoice.getReversal_ID() > 0) - { - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctDr()); - if (!invoice.getDateAcct().equals(getDateAcct())) - isCMReversal = true; - } - if (invoice!=null) - { - if (invoice.isCreditMemo() || invoice.getReversal_ID() > 0 ) - { - allocInvoiceAccounted = allocInvoiceAccounted.add(cmGainLossAmt.abs()); - cmGainLossAmt = Env.ZERO; - } - if (gainLossFactList.contains(factLine)) - { - isExcludeCMGainLoss = true; - } - } - - if (payment != null && payment.getReversal_ID() > 0 && !gainLossFactList.contains(factLine)) - { - allocInvoiceSource = allocInvoiceSource.add(factLine.getAmtSourceDr()); - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctDr()); - } + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr); + } + else if (totalAmtSourceCr.signum() == 0 && totalAmtAcctCr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr); } else { - if (as.getC_Currency_ID() != factLine.getC_Currency_ID()) - allocInvoiceSource = allocInvoiceSource.add(factLine.getAmtSourceDr()); - - if (!gainLossFactList.contains(factLine) && !invoice.isCreditMemo()) - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctDr()); - - if (!gainLossFactList.contains(factLine) && invoice.isCreditMemo() && invoice.getReversal_ID() > 0) + if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0) { - allocInvoiceAccounted = allocInvoiceAccounted.add(factLine.getAmtAcctCr()); - // this is to cater for reverse-accrual. - if (!invoice.getDateAcct().equals(getDateAcct())) - isCMReversal = true; + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr); + currencyAdjustment = currencyAdjustment.add(totalAmtAcctCr); } - - if (invoice != null) + else { - if (invoice.isCreditMemo() || invoice.getReversal_ID() > 0) - { - allocInvoiceAccounted = allocInvoiceAccounted.add(cmGainLossAmt.abs()); - cmGainLossAmt = Env.ZERO; - } - if (gainLossFactList.contains(factLine)) - { - isExcludeCMGainLoss = true; - } + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr); + currencyAdjustment = currencyAdjustment.add(totalAmtAcctDr); } - } - htAllocInvSource.put(invoice.getC_Invoice_ID(), allocInvoiceSource); - htAllocInvAccounted.put(invoice.getC_Invoice_ID(), allocInvoiceAccounted); - htGainLossAmtByCM.put(invoice.getC_Invoice_ID(), cmGainLossAmt); - htGainLossAmtByInv.put(invoice.getC_Invoice_ID(), gainLossAmt); - htIsExcludeCMGainLoss.put(invoice.getC_Invoice_ID(), isExcludeCMGainLoss); - htIsCMReversal.put(invoice.getC_Invoice_ID(), isCMReversal); + } + } + + sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") // allocation + .append(" AND C_AcctSchema_ID=?") + .append(" AND PostingType='A'") + .append(" AND (Account_ID=? OR Account_ID=? OR Account_ID=?)") + .append(" AND Line_ID IN (SELECT C_AllocationLine_ID FROM C_AllocationLine WHERE C_AllocationHdr_ID=? AND C_Invoice_ID=?)"); + + // For Allocation + valuesAlloc = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MAllocationHdr.Table_ID, alloc.get_ID(), as.getC_AcctSchema_ID(), + gain.getAccount_ID(), loss.getAccount_ID(), as.getCurrencyBalancing_Acct().getAccount_ID(), + alloc.get_ID(), invoice.getC_Invoice_ID()); + if (valuesAlloc != null) { + totalAmtSourceDr = (BigDecimal) valuesAlloc.get(0); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + totalAmtAcctDr = (BigDecimal) valuesAlloc.get(1); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + totalAmtSourceCr = (BigDecimal) valuesAlloc.get(2); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + totalAmtAcctCr = (BigDecimal) valuesAlloc.get(3); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + allocateSource = allocateSource.subtract(totalAmtSourceDr).subtract(totalAmtSourceCr).add(currencyAdjustment); } } + + htAllocInvSource.put(invoice.getC_Invoice_ID(), allocateSource); + htAllocInvAccounted.put(invoice.getC_Invoice_ID(), allocateAccounted); } for (MInvoice invoice : invList) { - BigDecimal invoiceSource = htInvSource.get(invoice.getC_Invoice_ID()); - if (invoiceSource == null) - invoiceSource = Env.ZERO; - BigDecimal invoiceAccounted = htInvAccounted.get(invoice.getC_Invoice_ID()); - if (invoiceAccounted == null) - invoiceAccounted = Env.ZERO; - BigDecimal allocInvoiceSource = htAllocInvSource.get(invoice.getC_Invoice_ID()); - if (allocInvoiceSource == null) - allocInvoiceSource = Env.ZERO; - BigDecimal allocInvoiceAccounted = htAllocInvAccounted.get(invoice.getC_Invoice_ID()); - if (allocInvoiceAccounted == null) - allocInvoiceAccounted = Env.ZERO; - BigDecimal cmGainLossAmt = htGainLossAmtByCM.get(invoice.getC_Invoice_ID()); - if (cmGainLossAmt == null) - cmGainLossAmt = Env.ZERO; - BigDecimal gainLossAmt = htGainLossAmtByInv.get(invoice.getC_Invoice_ID()); - if (gainLossAmt == null) - gainLossAmt = Env.ZERO; - Boolean isExcludeCMGainLoss = htIsExcludeCMGainLoss.get(invoice.getC_Invoice_ID()); - if (isExcludeCMGainLoss == null) - isExcludeCMGainLoss = Boolean.FALSE; - Boolean isCMReversal = htIsCMReversal.get(invoice.getC_Invoice_ID()); - if (isCMReversal == null) - isCMReversal = Boolean.FALSE; + BigDecimal invSource = htInvSource.get(invoice.getC_Invoice_ID()); + if (invSource == null) + invSource = Env.ZERO; + BigDecimal invAccounted = htInvAccounted.get(invoice.getC_Invoice_ID()); + if (invAccounted == null) + invAccounted = Env.ZERO; + BigDecimal allocInvSource = htAllocInvSource.get(invoice.getC_Invoice_ID()); + if (allocInvSource == null) + allocInvSource = Env.ZERO; + BigDecimal allocInvAccounted = htAllocInvAccounted.get(invoice.getC_Invoice_ID()); + if (allocInvAccounted == null) + allocInvAccounted = Env.ZERO; - BigDecimal acctDifference = null; // gain is negative - // - StringBuilder description = new StringBuilder("Invoice=(").append(getC_Currency_ID()).append(")").append(allocInvoiceSource).append("/").append(allocInvoiceAccounted); + StringBuilder description = new StringBuilder("Invoice=(").append(getC_Currency_ID()).append(")").append(invSource).append("/").append(invAccounted) + .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocInvSource).append("/").append(allocInvAccounted); if (log.isLoggable(Level.FINE)) log.fine(description.toString()); - boolean isBPartnerAdjust = true; - if (allocInvoiceSource.abs().compareTo(invoiceSource.abs()) == 0) + BigDecimal acctDifference = null; + if (allocInvSource.abs().compareTo(invSource.abs()) == 0) { - if (isExcludeCMGainLoss) - allocInvoiceAccounted = allocInvoiceAccounted.add(cmGainLossAmt); - - for (MPayment payment : payList) - { - if (payment != null && payment.getReversal_ID() > 0 ) - allocInvoiceAccounted = allocInvoiceAccounted.subtract(gainLossAmt); - else - allocInvoiceAccounted = allocInvoiceAccounted.add(gainLossAmt); - } - - if (isCMReversal) - acctDifference = invoiceAccounted.subtract(allocInvoiceAccounted.abs()); - else - acctDifference = allocInvoiceAccounted.subtract(invoiceAccounted.abs()); // gain is positive for receipt - + acctDifference = allocInvAccounted.abs().subtract(invAccounted.abs()); // gain is negative StringBuilder d2 = new StringBuilder("(full) = ").append(acctDifference); if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); description.append(" - ").append(d2); - } - else - { - MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(), invoice.get_ID(), getTrxName()); - for (MAllocationHdr alloc : allocations) - { - if (alloc.get_ID() == get_ID()) - continue; - - StringBuilder sql = new StringBuilder("SELECT ") - .append(invoice.isSOTrx() - ? "SUM(AmtSourceCr), SUM(AmtAcctCr), SUM(AmtAcctDr)" // so - : "SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtAcctCr)") // po - .append(" FROM Fact_Acct ") - .append("WHERE AD_Table_ID=? AND Record_ID=?") // allocation - .append(" AND C_AcctSchema_ID=?") - .append(" AND PostingType='A'") - .append(" AND Account_ID=?") - .append(" AND Line_ID IN (SELECT C_AllocationLine_ID FROM C_AllocationLine WHERE C_AllocationHdr_ID=? AND C_Invoice_ID=?)"); - pstmt = null; - rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), getTrxName()); - pstmt.setInt(1, MAllocationHdr.Table_ID); - pstmt.setInt(2, alloc.get_ID()); - pstmt.setInt(3, as.getC_AcctSchema_ID()); - pstmt.setInt(4, bpAcct.getAccount_ID()); - pstmt.setInt(5, alloc.get_ID()); - pstmt.setInt(6, invoice.getC_Invoice_ID()); - rs = pstmt.executeQuery(); - if (rs.next()) - { - BigDecimal allocateSource = rs.getBigDecimal(1); - BigDecimal allocateAccounted = rs.getBigDecimal(2); - BigDecimal allocateCredit = rs.getBigDecimal(3); - allocInvoiceSource = allocInvoiceSource.add(allocateSource != null ? allocateSource: BigDecimal.ZERO); - allocInvoiceAccounted = allocInvoiceAccounted.add(allocateAccounted != null ? allocateAccounted : BigDecimal.ZERO); - allocInvoiceAccounted = allocInvoiceAccounted.subtract(allocateCredit != null ? allocateCredit : BigDecimal.ZERO); - } - - } - catch (Exception e) - { - throw new RuntimeException(e.getLocalizedMessage(), e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - } - double multiplier = allocInvoiceSource.doubleValue() / invoiceSource.doubleValue(); - - // Reduce Orig Invoice Accounted - BigDecimal reduceOrigAccounted = invoiceAccounted.multiply(BigDecimal.valueOf(multiplier)); - if (reduceOrigAccounted.compareTo(invoiceAccounted) < 0 ) - invoiceAccounted = reduceOrigAccounted; - if (isExcludeCMGainLoss) - allocInvoiceAccounted = allocInvoiceAccounted.add(cmGainLossAmt); - - allocInvoiceAccounted = allocInvoiceAccounted.add(gainLossAmt); - - // Difference based on percentage of Orig Invoice - acctDifference = allocInvoiceAccounted.subtract(invoiceAccounted); - // ignore Tolerance - if (acctDifference.abs().compareTo(BigDecimal.valueOf(0.01)) < 0) - acctDifference = Env.ZERO; - - // Round - int precision = as.getStdPrecision(); - if (acctDifference.scale() > precision) - acctDifference = acctDifference.setScale(precision, RoundingMode.HALF_UP); - StringBuilder d2 = new StringBuilder("(partial) = ").append(acctDifference).append(" - Multiplier=").append(multiplier); - if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); - description.append(" - ").append(d2); } - - if (acctDifference.signum() == 0) + + if (acctDifference == null || acctDifference.signum() == 0) { log.fine("No Difference"); return null; } - - MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); - MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); + // - if (acctDifference.abs().compareTo(TOLERANCE) <= 0) + Integer C_AllocationLine_ID = htInvAllocLine.get(invoice.getC_Invoice_ID()); + if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) { - Integer C_AllocationLine_ID = htInvAllocLine.get(invoice.getC_Invoice_ID()); - if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) + FactLine fl = fact.createLine (null, acct, as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + if (!fact.isAcctBalanced()) { - FactLine fl = null; - if (!isBPartnerAdjust) - fl = fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference); - else - fl = fact.createLine (null, bpAcct,as.getC_Currency_ID(), acctDifference); + if (as.isCurrencyBalancing() && as.getC_Currency_ID() != invoice.getC_Currency_ID()) + fl = fact.createLine (null, as.getCurrencyBalancing_Acct(), as.getC_Currency_ID(), acctDifference.negate()); + else + fl = fact.createLine (null, loss, gain, as.getC_Currency_ID(), acctDifference.negate()); fl.setDescription(description.toString()); fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); - - if (!fact.isAcctBalanced()) - { - if (as.isCurrencyBalancing() && as.getC_Currency_ID() != invoice.getC_Currency_ID()) - { - fl = fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference.negate()); - } - else - { - fl = fact.createLine (null, loss, gain,as.getC_Currency_ID(), acctDifference.negate()); - } - } - fl.setDescription(description.toString()); - fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); - } - else + } + } + else + { + FactLine fl = fact.createLine (null, acct, as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + if (!fact.isAcctBalanced()) { - FactLine fl = null; - if (!isBPartnerAdjust) - fl = fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference.negate()); + if (as.isCurrencyBalancing() && as.getC_Currency_ID() != invoice.getC_Currency_ID()) + fl = fact.createLine (null, as.getCurrencyBalancing_Acct(), as.getC_Currency_ID(), acctDifference); else - fl = fact.createLine (null, bpAcct,as.getC_Currency_ID(), acctDifference.negate()); - fl.setDescription(description.toString()); - fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); - - if (!fact.isAcctBalanced()) - { - if (as.isCurrencyBalancing() && as.getC_Currency_ID() != invoice.getC_Currency_ID()) - { - fl = fact.createLine (null, as.getCurrencyBalancing_Acct(),as.getC_Currency_ID(), acctDifference); - } - else - { - fl = fact.createLine (null, loss, gain, as.getC_Currency_ID(), acctDifference); - } - } + fl = fact.createLine (null, loss, gain, as.getC_Currency_ID(), acctDifference); fl.setDescription(description.toString()); fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); } } } - return null; - + return null; } // createInvoiceRounding - + + /************************************************************************** + * Create Rounding Correction. + * Compares the Accounted Amount of the Payment to the + * Accounted Amount of the Allocation + * @param as accounting schema + * @param fact fact + * @return Error Message or null if OK + */ + private String createPaymentRoundingCorrection (MAcctSchema as, Fact fact) + { + ArrayList payList = new ArrayList(); + Hashtable htPayAllocLine = new Hashtable(); + for (int i = 0; i < p_lines.length; i++) + { + MPayment payment = null; + DocLine_Allocation line = (DocLine_Allocation) p_lines[i]; + if (line.getC_Payment_ID() != 0) + { + payment = new MPayment (getCtx(), line.getC_Payment_ID(), getTrxName()); + if (!payList.contains(payment)) + payList.add(payment); + htPayAllocLine.put(payment.getC_Payment_ID(), line.get_ID()); + } + } + + Hashtable htPayAcct = new Hashtable(); + Hashtable htPaySource = new Hashtable(); + Hashtable htPayAccounted = new Hashtable(); + for (MPayment payment : payList) + { + htPayAcct.put(payment.getC_Payment_ID(), getPaymentAcct(as, payment.getC_Payment_ID())); + + StringBuilder sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") + .append(" AND C_AcctSchema_ID=?") + .append(" AND Account_ID = ? ") + .append(" AND PostingType='A'"); + + // For Payment + List valuesPay = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MPayment.Table_ID, payment.getC_Payment_ID(), as.getC_AcctSchema_ID(), htPayAcct.get(payment.getC_Payment_ID()).getAccount_ID()); + if (valuesPay != null) { + BigDecimal paymentSource = (BigDecimal) valuesPay.get(0); // AmtSourceDr + BigDecimal paymentAccounted = (BigDecimal) valuesPay.get(1); // AmtAcctDr + if (paymentSource.signum() == 0 && paymentAccounted.signum() == 0) { + paymentSource = (BigDecimal) valuesPay.get(2); // AmtSourceCr + paymentAccounted = (BigDecimal) valuesPay.get(3); // AmtAcctCr + } + htPaySource.put(payment.getC_Payment_ID(), paymentSource); + htPayAccounted.put(payment.getC_Payment_ID(), paymentAccounted); + } + } + + MAccount gain = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedGain_Acct()); + MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct()); + + Hashtable htTotalAmtSourceDr = new Hashtable(); + Hashtable htTotalAmtAcctDr = new Hashtable(); + Hashtable htTotalAmtSourceCr = new Hashtable(); + Hashtable htTotalAmtAcctCr = new Hashtable(); + FactLine[] factlines = fact.getLines(); + for (FactLine factLine : factlines) + { + if (factLine.getLine_ID() > 0) + { + MAllocationLine allocationLine = new MAllocationLine(getCtx(), factLine.getLine_ID(), getTrxName()); + if (allocationLine.getC_Payment_ID() > 0) + { + if (factLine.getAccount_ID() == htPayAcct.get(allocationLine.getC_Payment_ID()).getAccount_ID()) + { + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(allocationLine.getC_Payment_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtAcctDr = htTotalAmtAcctDr.get(allocationLine.getC_Payment_ID()); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(allocationLine.getC_Payment_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + BigDecimal totalAmtAcctCr = htTotalAmtAcctCr.get(allocationLine.getC_Payment_ID()); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + totalAmtSourceDr = totalAmtSourceDr.add(factLine.getAmtSourceDr()); + totalAmtAcctDr = totalAmtAcctDr.add(factLine.getAmtAcctDr()); + totalAmtSourceCr = totalAmtSourceCr.add(factLine.getAmtSourceCr()); + totalAmtAcctCr = totalAmtAcctCr.add(factLine.getAmtAcctCr()); + + htTotalAmtSourceDr.put(allocationLine.getC_Payment_ID(), totalAmtSourceDr); + htTotalAmtAcctDr.put(allocationLine.getC_Payment_ID(), totalAmtAcctDr); + htTotalAmtSourceCr.put(allocationLine.getC_Payment_ID(), totalAmtSourceCr); + htTotalAmtAcctCr.put(allocationLine.getC_Payment_ID(), totalAmtAcctCr); + } + else if (factLine.getAccount_ID() == gain.getAccount_ID() || factLine.getAccount_ID() == loss.getAccount_ID()) + { + if (!payGainLossFactLines.contains(factLine)) + continue; + + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(allocationLine.getC_Payment_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(allocationLine.getC_Payment_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + + totalAmtSourceDr = totalAmtSourceDr.subtract(factLine.getAmtSourceCr()); + totalAmtSourceCr = totalAmtSourceCr.subtract(factLine.getAmtSourceDr()); + + htTotalAmtSourceDr.put(allocationLine.getC_Payment_ID(), totalAmtSourceDr); + htTotalAmtSourceCr.put(allocationLine.getC_Payment_ID(), totalAmtSourceCr); + } + } + } + } + + Hashtable htAllocPaySource = new Hashtable(); + Hashtable htAllocPayAccounted = new Hashtable(); + for (MPayment payment : payList) + { + BigDecimal allocateSource = Env.ZERO; + BigDecimal allocateAccounted = Env.ZERO; + + BigDecimal totalAmtSourceDr = htTotalAmtSourceDr.get(payment.getC_Payment_ID()); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + BigDecimal totalAmtAcctDr = htTotalAmtAcctDr.get(payment.getC_Payment_ID()); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + BigDecimal totalAmtSourceCr = htTotalAmtSourceCr.get(payment.getC_Payment_ID()); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + BigDecimal totalAmtAcctCr = htTotalAmtAcctCr.get(payment.getC_Payment_ID()); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + if (totalAmtSourceDr.signum() == 0 && totalAmtAcctDr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr); + } + else if (totalAmtSourceCr.signum() == 0 && totalAmtAcctCr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr); + } + else + { + if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr); + } + else + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr); + } + } + + MAllocationHdr[] allocations = MAllocationHdr.getOfPayment(getCtx(), payment.get_ID(), getTrxName()); + for (MAllocationHdr alloc : allocations) + { + if (alloc.get_ID() == get_ID()) + continue; + + BigDecimal currencyAdjustment = Env.ZERO; + StringBuilder sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") // allocation + .append(" AND C_AcctSchema_ID=?") + .append(" AND PostingType='A'") + .append(" AND Account_ID=?") + .append(" AND Line_ID IN (SELECT C_AllocationLine_ID FROM C_AllocationLine WHERE C_AllocationHdr_ID=? AND C_Payment_ID=?)"); + + // For Allocation + List valuesAlloc = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MAllocationHdr.Table_ID, alloc.get_ID(), as.getC_AcctSchema_ID(), htPayAcct.get(payment.getC_Payment_ID()).getAccount_ID(), alloc.get_ID(), payment.getC_Payment_ID()); + if (valuesAlloc != null) { + totalAmtSourceDr = (BigDecimal) valuesAlloc.get(0); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + totalAmtAcctDr = (BigDecimal) valuesAlloc.get(1); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + totalAmtSourceCr = (BigDecimal) valuesAlloc.get(2); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + totalAmtAcctCr = (BigDecimal) valuesAlloc.get(3); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + if (totalAmtSourceDr.signum() == 0 && totalAmtAcctDr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr); + } + else if (totalAmtSourceCr.signum() == 0 && totalAmtAcctCr.signum() == 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr); + } + else + { + if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0) + { + allocateSource = allocateSource.add(totalAmtSourceDr); + allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr); + currencyAdjustment = currencyAdjustment.add(totalAmtAcctCr); + } + else + { + allocateSource = allocateSource.add(totalAmtSourceCr); + allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr); + currencyAdjustment = currencyAdjustment.add(totalAmtAcctDr); + } + } + } + + sql = new StringBuilder() + .append("SELECT SUM(AmtSourceDr), SUM(AmtAcctDr), SUM(AmtSourceCr), SUM(AmtAcctCr)") + .append(" FROM Fact_Acct ") + .append("WHERE AD_Table_ID=? AND Record_ID=?") // allocation + .append(" AND C_AcctSchema_ID=?") + .append(" AND PostingType='A'") + .append(" AND (Account_ID=? OR Account_ID=? OR Account_ID=?)") + .append(" AND Line_ID IN (SELECT C_AllocationLine_ID FROM C_AllocationLine WHERE C_AllocationHdr_ID=? AND C_Payment_ID=?)"); + + // For Allocation + valuesAlloc = DB.getSQLValueObjectsEx(getTrxName(), sql.toString(), + MAllocationHdr.Table_ID, alloc.get_ID(), as.getC_AcctSchema_ID(), + gain.getAccount_ID(), loss.getAccount_ID(), as.getCurrencyBalancing_Acct().getAccount_ID(), + alloc.get_ID(), payment.getC_Payment_ID()); + if (valuesAlloc != null) { + totalAmtSourceDr = (BigDecimal) valuesAlloc.get(0); + if (totalAmtSourceDr == null) + totalAmtSourceDr = Env.ZERO; + totalAmtAcctDr = (BigDecimal) valuesAlloc.get(1); + if (totalAmtAcctDr == null) + totalAmtAcctDr = Env.ZERO; + totalAmtSourceCr = (BigDecimal) valuesAlloc.get(2); + if (totalAmtSourceCr == null) + totalAmtSourceCr = Env.ZERO; + totalAmtAcctCr = (BigDecimal) valuesAlloc.get(3); + if (totalAmtAcctCr == null) + totalAmtAcctCr = Env.ZERO; + + allocateSource = allocateSource.subtract(totalAmtSourceDr).subtract(totalAmtSourceCr).add(currencyAdjustment); + if (as.isCurrencyBalancing() && as.getC_Currency_ID() != payment.getC_Currency_ID()) + ; + else + allocateAccounted = allocateAccounted.add(currencyAdjustment); + } + } + + htAllocPaySource.put(payment.getC_Payment_ID(), allocateSource); + htAllocPayAccounted.put(payment.getC_Payment_ID(), allocateAccounted); + } + + for (MPayment payment : payList) + { + BigDecimal paySource = htPaySource.get(payment.getC_Payment_ID()); + if (paySource == null) + paySource = Env.ZERO; + BigDecimal payAccounted = htPayAccounted.get(payment.getC_Payment_ID()); + if (payAccounted == null) + payAccounted = Env.ZERO; + BigDecimal allocPaySource = htAllocPaySource.get(payment.getC_Payment_ID()); + if (allocPaySource == null) + allocPaySource = Env.ZERO; + BigDecimal allocPayAccounted = htAllocPayAccounted.get(payment.getC_Payment_ID()); + if (allocPayAccounted == null) + allocPayAccounted = Env.ZERO; + + StringBuilder description = new StringBuilder("Payment=(").append(getC_Currency_ID()).append(")").append(paySource).append("/").append(payAccounted) + .append(" - Allocation=(").append(getC_Currency_ID()).append(")").append(allocPaySource).append("/").append(allocPayAccounted); + if (log.isLoggable(Level.FINE)) log.fine(description.toString()); + BigDecimal acctDifference = null; + if (allocPaySource.abs().compareTo(paySource.abs()) == 0) + { + acctDifference = allocPayAccounted.abs().subtract(payAccounted.abs()); // gain is negative + StringBuilder d2 = new StringBuilder("(full) = ").append(acctDifference); + if (log.isLoggable(Level.FINE)) log.fine(d2.toString()); + description.append(" - ").append(d2); + } + + if (acctDifference == null || acctDifference.signum() == 0) + { + log.fine("No Difference"); + return null; + } + + // + Integer C_AllocationLine_ID = htPayAllocLine.get(payment.getC_Payment_ID()); + if ((payment.isReceipt() && payment.getPayAmt().signum() >= 0) || (!payment.isReceipt() && payment.getPayAmt().signum() < 0)) + { + FactLine fl = fact.createLine (null, htPayAcct.get(payment.getC_Payment_ID()), as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + if (!fact.isAcctBalanced()) + { + if (as.isCurrencyBalancing() && as.getC_Currency_ID() != payment.getC_Currency_ID()) + fl = fact.createLine (null, as.getCurrencyBalancing_Acct(), as.getC_Currency_ID(), acctDifference); + else + fl = fact.createLine (null, loss, gain,as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + } + } + else + { + FactLine fl = fact.createLine (null, htPayAcct.get(payment.getC_Payment_ID()), as.getC_Currency_ID(), acctDifference); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + if (!fact.isAcctBalanced()) + { + if (as.isCurrencyBalancing() && as.getC_Currency_ID() != payment.getC_Currency_ID()) + fl = fact.createLine (null, as.getCurrencyBalancing_Acct(), as.getC_Currency_ID(), acctDifference.negate()); + else + fl = fact.createLine (null, loss, gain, as.getC_Currency_ID(), acctDifference.negate()); + fl.setDescription(description.toString()); + fl.setLine_ID(C_AllocationLine_ID == null ? 0 : C_AllocationLine_ID); + } + } + } + return null; + } } // Doc_Allocation /** From 92cd7142217760098b21befb14a67da3617c0f40 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Wed, 25 Mar 2020 14:57:57 +0100 Subject: [PATCH 7/8] IDEMPIERE-4222 GL Distribution can't work with organization set on the Org_ID field --- org.adempiere.base/src/org/compiere/model/MDistribution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MDistribution.java b/org.adempiere.base/src/org/compiere/model/MDistribution.java index d3cb7d288e..0c9a9a81ac 100644 --- a/org.adempiere.base/src/org/compiere/model/MDistribution.java +++ b/org.adempiere.base/src/org/compiere/model/MDistribution.java @@ -110,7 +110,7 @@ public class MDistribution extends X_GL_Distribution continue; // Optional Elements - "non-Any" - if (!distribution.isAnyOrg() && distribution.getAD_Org_ID() != AD_Org_ID) + if (!distribution.isAnyOrg() && distribution.getOrg_ID() != AD_Org_ID) continue; if (!distribution.isAnyAcct() && distribution.getAccount_ID() != Account_ID) continue; From 41aa4102cd678877198038a286ed09a3fa80d645 Mon Sep 17 00:00:00 2001 From: hengsin Date: Fri, 27 Mar 2020 11:34:27 +0800 Subject: [PATCH 8/8] IDEMPIERE-4223 Model class generated with wrong datatype for Column with displaytype=button and columname ends with _ID --- .../compiere/process/BPartnerOrgUnLink.java | 4 +-- .../org/compiere/process/DistributionRun.java | 30 +++++++++---------- .../org/compiere/process/ProjectSetType.java | 2 +- .../util/ModelInterfaceGenerator.java | 4 +++ .../src/org/compiere/model/I_C_BPartner.java | 4 +-- .../src/org/compiere/model/I_C_Project.java | 4 +-- .../src/org/compiere/model/MBPartner.java | 28 ++--------------- .../src/org/compiere/model/MInOut.java | 2 +- .../src/org/compiere/model/MInvoice.java | 2 +- .../src/org/compiere/model/MOrder.java | 2 +- .../src/org/compiere/model/MPayment.java | 2 +- .../src/org/compiere/model/MProject.java | 27 ++--------------- .../src/org/compiere/model/MRMA.java | 2 +- .../src/org/compiere/model/POInfoColumn.java | 4 +++ .../src/org/compiere/model/X_C_BPartner.java | 20 ++++++++----- .../src/org/compiere/model/X_C_Project.java | 16 ++++++---- 16 files changed, 63 insertions(+), 90 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/BPartnerOrgUnLink.java b/org.adempiere.base.process/src/org/compiere/process/BPartnerOrgUnLink.java index 16170b9fc0..a422612e5e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/BPartnerOrgUnLink.java +++ b/org.adempiere.base.process/src/org/compiere/process/BPartnerOrgUnLink.java @@ -64,9 +64,9 @@ public class BPartnerOrgUnLink extends SvrProcess if (bp.get_ID() == 0) throw new IllegalArgumentException ("Business Partner not found - C_BPartner_ID=" + p_C_BPartner_ID); // - if (bp.getAD_OrgBP_ID_Int() == 0) + if (bp.getAD_OrgBP_ID() == 0) throw new IllegalArgumentException ("Business Partner not linked to an Organization"); - bp.setAD_OrgBP_ID(null); + bp.setAD_OrgBP_ID(0); if (!bp.save()) throw new IllegalArgumentException ("Business Partner not changed"); diff --git a/org.adempiere.base.process/src/org/compiere/process/DistributionRun.java b/org.adempiere.base.process/src/org/compiere/process/DistributionRun.java index 757863c662..3b9de27e47 100644 --- a/org.adempiere.base.process/src/org/compiere/process/DistributionRun.java +++ b/org.adempiere.base.process/src/org/compiere/process/DistributionRun.java @@ -516,12 +516,12 @@ public class DistributionRun extends SvrProcess order.setC_DocType_ID(m_docType.getC_DocType_ID()); order.setIsSOTrx(m_docType.isSOTrx()); // Counter Doc - if (counter && bp.getAD_OrgBP_ID_Int() > 0) + if (counter && bp.getAD_OrgBP_ID() > 0) { - if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int() + if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID() + "-" + bp + ", To_BP=" + runBPartner); - order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); - MOrgInfo oi = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int(), get_TrxName()); + order.setAD_Org_ID(bp.getAD_OrgBP_ID()); + MOrgInfo oi = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID(), get_TrxName()); if (oi.getM_Warehouse_ID() > 0) order.setM_Warehouse_ID(oi.getM_Warehouse_ID()); order.setBPartner(runBPartner); @@ -557,7 +557,7 @@ public class DistributionRun extends SvrProcess // Create Order Line MOrderLine line = new MOrderLine(order); - if (counter && bp.getAD_OrgBP_ID_Int() > 0) + if (counter && bp.getAD_OrgBP_ID() > 0) ; // don't overwrite counter doc else // normal - optionally overwrite { @@ -929,7 +929,7 @@ public class DistributionRun extends SvrProcess lastC_BPartner_Location_ID = detail.getC_BPartner_Location_ID(); bp = new MBPartner (getCtx(), detail.getC_BPartner_ID(), get_TrxName()); - MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int(), get_TrxName()); + MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID(), get_TrxName()); m_target = MWarehouse.get(getCtx(), oi_target.getM_Warehouse_ID()); if(m_target==null) throw new AdempiereException("Do not exist Default Warehouse Target"); @@ -944,7 +944,7 @@ public class DistributionRun extends SvrProcess if(p_ConsolidateDocument) { - StringBuilder whereClause = new StringBuilder("DocStatus IN ('DR','IN') AND AD_Org_ID=").append(bp.getAD_OrgBP_ID_Int()).append(" AND ") + StringBuilder whereClause = new StringBuilder("DocStatus IN ('DR','IN') AND AD_Org_ID=").append(bp.getAD_OrgBP_ID()).append(" AND ") .append(MDDOrder.COLUMNNAME_C_BPartner_ID).append("=? AND ") .append(MDDOrder.COLUMNNAME_M_Warehouse_ID).append("=? AND ") .append(MDDOrder.COLUMNNAME_DatePromised).append("<=? "); @@ -961,16 +961,16 @@ public class DistributionRun extends SvrProcess if (!p_IsTest) { order = new MDDOrder (getCtx(), 0, get_TrxName()); - order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + order.setAD_Org_ID(bp.getAD_OrgBP_ID()); order.setC_DocType_ID(m_docType.getC_DocType_ID()); order.setIsSOTrx(m_docType.isSOTrx()); // Counter Doc - if (counter && bp.getAD_OrgBP_ID_Int() > 0) + if (counter && bp.getAD_OrgBP_ID() > 0) { - if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int() + if (log.isLoggable(Level.FINE)) log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID() + "-" + bp + ", To_BP=" + runBPartner); - order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + order.setAD_Org_ID(bp.getAD_OrgBP_ID()); if (ws[0].getM_Warehouse_ID() > 0) order.setM_Warehouse_ID(ws[0].getM_Warehouse_ID()); order.setBPartner(runBPartner); @@ -979,7 +979,7 @@ public class DistributionRun extends SvrProcess { if (log.isLoggable(Level.FINE)) log.fine("From_Org=" + runAD_Org_ID + ", To_BP=" + bp); - order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + order.setAD_Org_ID(bp.getAD_OrgBP_ID()); order.setBPartner(bp); if (detail.getC_BPartner_Location_ID() != 0) order.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID()); @@ -1015,7 +1015,7 @@ public class DistributionRun extends SvrProcess if (DD_OrderLine_ID <= 0) { MDDOrderLine line = new MDDOrderLine(order); - line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + line.setAD_Org_ID(bp.getAD_OrgBP_ID()); line.setM_Locator_ID(m_locator.getM_Locator_ID()); line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID()); line.setIsInvoiced(false); @@ -1059,7 +1059,7 @@ public class DistributionRun extends SvrProcess { // Create Order Line MDDOrderLine line = new MDDOrderLine(order); - if (counter && bp.getAD_OrgBP_ID_Int() > 0) + if (counter && bp.getAD_OrgBP_ID() > 0) ; // don't overwrite counter doc /*else // normal - optionally overwrite { @@ -1068,7 +1068,7 @@ public class DistributionRun extends SvrProcess line.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID()); }*/ // - line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int()); + line.setAD_Org_ID(bp.getAD_OrgBP_ID()); line.setM_Locator_ID(m_locator.getM_Locator_ID()); line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID()); line.setIsInvoiced(false); diff --git a/org.adempiere.base.process/src/org/compiere/process/ProjectSetType.java b/org.adempiere.base.process/src/org/compiere/process/ProjectSetType.java index d9d1ac8726..2d0d1f7e64 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ProjectSetType.java +++ b/org.adempiere.base.process/src/org/compiere/process/ProjectSetType.java @@ -66,7 +66,7 @@ public class ProjectSetType extends SvrProcess MProject project = new MProject (getCtx(), m_C_Project_ID, get_TrxName()); if (project.getC_Project_ID() == 0 || project.getC_Project_ID() != m_C_Project_ID) throw new IllegalArgumentException("Project not found C_Project_ID=" + m_C_Project_ID); - if (project.getC_ProjectType_ID_Int() > 0) + if (project.getC_ProjectType_ID() > 0) throw new IllegalArgumentException("Project already has Type (Cannot overwrite) " + project.getC_ProjectType_ID()); // MProjectType type = new MProjectType (getCtx(), m_C_ProjectType_ID, get_TrxName()); diff --git a/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java b/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java index 2e6b4a12f4..ad06da5b93 100644 --- a/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java +++ b/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java @@ -533,6 +533,10 @@ public class ModelInterfaceGenerator // return getClass(columnName, displayType, AD_Reference_ID); // recursive call with new parameters } + else if (displayType == DisplayType.Button && columnName.endsWith("_ID")) + { + return Integer.class; + } else { return DisplayType.getClass(displayType, true); diff --git a/org.adempiere.base/src/org/compiere/model/I_C_BPartner.java b/org.adempiere.base/src/org/compiere/model/I_C_BPartner.java index 6f5053db00..0009b3b552 100644 --- a/org.adempiere.base/src/org/compiere/model/I_C_BPartner.java +++ b/org.adempiere.base/src/org/compiere/model/I_C_BPartner.java @@ -94,12 +94,12 @@ public interface I_C_BPartner /** Set Linked Organization. * The Business Partner is another Organization for explicit Inter-Org transactions */ - public void setAD_OrgBP_ID (String AD_OrgBP_ID); + public void setAD_OrgBP_ID (int AD_OrgBP_ID); /** Get Linked Organization. * The Business Partner is another Organization for explicit Inter-Org transactions */ - public String getAD_OrgBP_ID(); + public int getAD_OrgBP_ID(); /** Column name AD_Org_ID */ public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; diff --git a/org.adempiere.base/src/org/compiere/model/I_C_Project.java b/org.adempiere.base/src/org/compiere/model/I_C_Project.java index 4ed500144c..13b88f2c85 100644 --- a/org.adempiere.base/src/org/compiere/model/I_C_Project.java +++ b/org.adempiere.base/src/org/compiere/model/I_C_Project.java @@ -268,12 +268,12 @@ public interface I_C_Project /** Set Project Type. * Type of the project */ - public void setC_ProjectType_ID (String C_ProjectType_ID); + public void setC_ProjectType_ID (int C_ProjectType_ID); /** Get Project Type. * Type of the project */ - public String getC_ProjectType_ID(); + public int getC_ProjectType_ID(); /** Column name C_Project_UU */ public static final String COLUMNNAME_C_Project_UU = "C_Project_UU"; diff --git a/org.adempiere.base/src/org/compiere/model/MBPartner.java b/org.adempiere.base/src/org/compiere/model/MBPartner.java index f48e61ece5..4e00562582 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartner.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartner.java @@ -573,41 +573,17 @@ public class MBPartner extends X_C_BPartner super.setClientOrg(AD_Client_ID, AD_Org_ID); } // setClientOrg - /** - * Set Linked Organization. - * (is Button) - * @param AD_OrgBP_ID - */ - public void setAD_OrgBP_ID (int AD_OrgBP_ID) - { - if (AD_OrgBP_ID == 0) - super.setAD_OrgBP_ID (null); - else - super.set_Value("AD_OrgBP_ID", AD_OrgBP_ID); - } // setAD_OrgBP_ID - /** * Get Linked Organization. * (is Button) * The Business Partner is another Organization * for explicit Inter-Org transactions * @return AD_Org_ID if BP + * @deprecated */ public int getAD_OrgBP_ID_Int() { - String org = super.getAD_OrgBP_ID(); - if (org == null) - return 0; - int AD_OrgBP_ID = 0; - try - { - AD_OrgBP_ID = Integer.parseInt (org); - } - catch (Exception ex) - { - log.log(Level.SEVERE, org, ex); - } - return AD_OrgBP_ID; + return getAD_OrgBP_ID(); } // getAD_OrgBP_ID_Int /** diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 6b97cc497f..be0113f9db 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1973,7 +1973,7 @@ public class MInOut extends X_M_InOut implements DocAction return null; // Business Partner needs to be linked to Org MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); - int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); + int counterAD_Org_ID = bp.getAD_OrgBP_ID(); if (counterAD_Org_ID == 0) return null; diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 31bf99d26e..3c60e60fb9 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -2205,7 +2205,7 @@ public class MInvoice extends X_C_Invoice implements DocAction return null; // Business Partner needs to be linked to Org MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); - int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); + int counterAD_Org_ID = bp.getAD_OrgBP_ID(); if (counterAD_Org_ID == 0) return null; diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 11a6f29677..c417e3a87b 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -2326,7 +2326,7 @@ public class MOrder extends X_C_Order implements DocAction return null; // Business Partner needs to be linked to Org MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); - int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); + int counterAD_Org_ID = bp.getAD_OrgBP_ID(); if (counterAD_Org_ID == 0) return null; diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 4f1422a260..a1af3d15d6 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -2171,7 +2171,7 @@ public class MPayment extends X_C_Payment return null; // Business Partner needs to be linked to Org MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); - int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); + int counterAD_Org_ID = bp.getAD_OrgBP_ID(); if (counterAD_Org_ID == 0) return null; diff --git a/org.adempiere.base/src/org/compiere/model/MProject.java b/org.adempiere.base/src/org/compiere/model/MProject.java index cd9af41767..edff0d8438 100644 --- a/org.adempiere.base/src/org/compiere/model/MProject.java +++ b/org.adempiere.base/src/org/compiere/model/MProject.java @@ -127,36 +127,13 @@ public class MProject extends X_C_Project /** * Get Project Type as Int (is Button). * @return C_ProjectType_ID id + * @deprecated */ public int getC_ProjectType_ID_Int() { - String pj = super.getC_ProjectType_ID(); - if (pj == null) - return 0; - int C_ProjectType_ID = 0; - try - { - C_ProjectType_ID = Integer.parseInt (pj); - } - catch (Exception ex) - { - log.log(Level.SEVERE, pj, ex); - } - return C_ProjectType_ID; + return getC_ProjectType_ID(); } // getC_ProjectType_ID_Int - /** - * Set Project Type (overwrite r/o) - * @param C_ProjectType_ID id - */ - public void setC_ProjectType_ID (int C_ProjectType_ID) - { - if (C_ProjectType_ID == 0) - super.setC_ProjectType_ID (null); - else - super.set_Value("C_ProjectType_ID", C_ProjectType_ID); - } // setC_ProjectType_ID - /** * String Representation * @return info diff --git a/org.adempiere.base/src/org/compiere/model/MRMA.java b/org.adempiere.base/src/org/compiere/model/MRMA.java index 93ca4ec366..36cfabbaff 100644 --- a/org.adempiere.base/src/org/compiere/model/MRMA.java +++ b/org.adempiere.base/src/org/compiere/model/MRMA.java @@ -505,7 +505,7 @@ public class MRMA extends X_M_RMA implements DocAction return null; // Business Partner needs to be linked to Org MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); - int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); + int counterAD_Org_ID = bp.getAD_OrgBP_ID(); if (counterAD_Org_ID == 0) return null; diff --git a/org.adempiere.base/src/org/compiere/model/POInfoColumn.java b/org.adempiere.base/src/org/compiere/model/POInfoColumn.java index 7b111ebce7..7123c132a5 100644 --- a/org.adempiere.base/src/org/compiere/model/POInfoColumn.java +++ b/org.adempiere.base/src/org/compiere/model/POInfoColumn.java @@ -87,6 +87,10 @@ public class POInfoColumn implements Serializable DisplayType = org.compiere.util.DisplayType.ID; ColumnClass = Integer.class; } + else if (displayType == org.compiere.util.DisplayType.Button && columnName.endsWith("_ID")) + { + ColumnClass = Integer.class; + } else ColumnClass = org.compiere.util.DisplayType.getClass(displayType, true); IsMandatory = isMandatory; diff --git a/org.adempiere.base/src/org/compiere/model/X_C_BPartner.java b/org.adempiere.base/src/org/compiere/model/X_C_BPartner.java index 512d90cecf..533d12c3be 100644 --- a/org.adempiere.base/src/org/compiere/model/X_C_BPartner.java +++ b/org.adempiere.base/src/org/compiere/model/X_C_BPartner.java @@ -33,7 +33,7 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent /** * */ - private static final long serialVersionUID = 20191121L; + private static final long serialVersionUID = 20200327L; /** Standard Constructor */ public X_C_BPartner (Properties ctx, int C_BPartner_ID, String trxName) @@ -86,8 +86,8 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent public String toString() { - StringBuffer sb = new StringBuffer ("X_C_BPartner[") - .append(get_ID()).append("]"); + StringBuilder sb = new StringBuilder ("X_C_BPartner[") + .append(get_ID()).append(",Name=").append(getName()).append("]"); return sb.toString(); } @@ -155,17 +155,23 @@ public class X_C_BPartner extends PO implements I_C_BPartner, I_Persistent @param AD_OrgBP_ID The Business Partner is another Organization for explicit Inter-Org transactions */ - public void setAD_OrgBP_ID (String AD_OrgBP_ID) + public void setAD_OrgBP_ID (int AD_OrgBP_ID) { - set_Value (COLUMNNAME_AD_OrgBP_ID, AD_OrgBP_ID); + if (AD_OrgBP_ID < 1) + set_Value (COLUMNNAME_AD_OrgBP_ID, null); + else + set_Value (COLUMNNAME_AD_OrgBP_ID, Integer.valueOf(AD_OrgBP_ID)); } /** Get Linked Organization. @return The Business Partner is another Organization for explicit Inter-Org transactions */ - public String getAD_OrgBP_ID () + public int getAD_OrgBP_ID () { - return (String)get_Value(COLUMNNAME_AD_OrgBP_ID); + Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgBP_ID); + if (ii == null) + return 0; + return ii.intValue(); } /** Set Partner Parent. diff --git a/org.adempiere.base/src/org/compiere/model/X_C_Project.java b/org.adempiere.base/src/org/compiere/model/X_C_Project.java index 8909e8eaa1..df2f04983f 100644 --- a/org.adempiere.base/src/org/compiere/model/X_C_Project.java +++ b/org.adempiere.base/src/org/compiere/model/X_C_Project.java @@ -33,7 +33,7 @@ public class X_C_Project extends PO implements I_C_Project, I_Persistent /** * */ - private static final long serialVersionUID = 20191121L; + private static final long serialVersionUID = 20200327L; /** Standard Constructor */ public X_C_Project (Properties ctx, int C_Project_ID, String trxName) @@ -451,17 +451,23 @@ public class X_C_Project extends PO implements I_C_Project, I_Persistent @param C_ProjectType_ID Type of the project */ - public void setC_ProjectType_ID (String C_ProjectType_ID) + public void setC_ProjectType_ID (int C_ProjectType_ID) { - set_Value (COLUMNNAME_C_ProjectType_ID, C_ProjectType_ID); + if (C_ProjectType_ID < 1) + set_Value (COLUMNNAME_C_ProjectType_ID, null); + else + set_Value (COLUMNNAME_C_ProjectType_ID, Integer.valueOf(C_ProjectType_ID)); } /** Get Project Type. @return Type of the project */ - public String getC_ProjectType_ID () + public int getC_ProjectType_ID () { - return (String)get_Value(COLUMNNAME_C_ProjectType_ID); + Integer ii = (Integer)get_Value(COLUMNNAME_C_ProjectType_ID); + if (ii == null) + return 0; + return ii.intValue(); } /** Set C_Project_UU.