Fixes #22 post bank statement on statement date

(transplanted and modified for idempiere from http://adempiere.hg.sourceforge.net/hgweb/adempiere/contribution_adaxa/rev/069a8413c27d)
This commit is contained in:
Paul Bowden 2011-07-26 15:32:37 +10:00
parent 4c16922d20
commit e377f62aec
6 changed files with 312 additions and 6 deletions

View File

@ -0,0 +1,137 @@
-- 22/07/2011 5:13:40 PM
-- --
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,61939,263,0,15,392,'DateAcct',TO_DATE('2011-07-22 17:13:37','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Date','D',7,'The Accounting Date indicates the date to be used on the General Ledger account entries generated from this document. It is also used for any currency conversion.','Y','Y','N','N','N','N','N','Y','N','N','N','N','Y','Account Date',0,TO_DATE('2011-07-22 17:13:37','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- 22/07/2011 5:13:40 PM
-- --
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=61939 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- 22/07/2011 5:13:47 PM
-- --
ALTER TABLE C_BankStatement ADD DateAcct DATE
;
update c_bankstatement set dateacct=statementdate;
-- 22/07/2011 5:32:05 PM
-- --
ALTER TABLE C_BankStatement MODIFY DateAcct DATE
;
-- 22/07/2011 5:32:05 PM
-- --
ALTER TABLE C_BankStatement MODIFY DateAcct NOT NULL
;
-- 22/07/2011 5:14:50 PM
-- --
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,61939,61967,0,328,TO_DATE('2011-07-22 17:14:49','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Date',7,'D','The Accounting Date indicates the date to be used on the General Ledger account entries generated from this document. It is also used for any currency conversion.','Y','Y','Y','N','N','N','N','N','Account Date',TO_DATE('2011-07-22 17:14:49','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 22/07/2011 5:14:50 PM
-- --
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=61967 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- 22/07/2011 5:14:52 PM
-- --
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,59035,61968,0,328,TO_DATE('2011-07-22 17:14:50','YYYY-MM-DD HH24:MI:SS'),100,'The date+time (expressed in decimal format) when the document has been processed',20,'D','The ProcessedOn Date+Time save the exact moment (nanoseconds precision if allowed by the DB) when a document has been processed.','Y','Y','Y','N','N','N','N','N','Processed On',TO_DATE('2011-07-22 17:14:50','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 22/07/2011 5:14:52 PM
-- --
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=61968 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=61968
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=61967
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=3996
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=3998
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=4119
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=3993
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=4365
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=4003
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=8933
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=3997
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=8686
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=8687
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=10585
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=10586
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10587
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=3999
;
-- 22/07/2011 5:15:20 PM
-- --
UPDATE AD_Field SET IsSameLine='Y',Updated=TO_DATE('2011-07-22 17:15:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=61967
;
-- 26/07/2011 3:12:34 PM
-- --
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.dateAcct',Updated=TO_DATE('2011-07-26 15:12:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4918
;

View File

@ -0,0 +1,139 @@
-- 22/07/2011 5:13:40 PM
-- --
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,61939,263,0,15,392,'DateAcct',TO_TIMESTAMP('2011-07-22 17:13:37','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Date','D',7,'The Accounting Date indicates the date to be used on the General Ledger account entries generated from this document. It is also used for any currency conversion.','Y','Y','N','N','N','N','N','Y','N','N','N','N','Y','Account Date',0,TO_TIMESTAMP('2011-07-22 17:13:37','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- 22/07/2011 5:13:40 PM
-- --
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=61939 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- 22/07/2011 5:13:47 PM
-- --
ALTER TABLE C_BankStatement ADD COLUMN DateAcct TIMESTAMP
;
update c_bankstatement set dateacct=statementdate;
-- 22/07/2011 5:32:05 PM
-- --
INSERT INTO t_alter_column values('c_bankstatement','DateAcct','TIMESTAMP',null,null)
;
-- 22/07/2011 5:32:05 PM
-- --
INSERT INTO t_alter_column values('c_bankstatement','DateAcct',null,'NOT NULL',null)
;
-- 22/07/2011 5:14:50 PM
-- --
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,61939,61967,0,328,TO_TIMESTAMP('2011-07-22 17:14:49','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Date',7,'D','The Accounting Date indicates the date to be used on the General Ledger account entries generated from this document. It is also used for any currency conversion.','Y','Y','Y','N','N','N','N','N','Account Date',TO_TIMESTAMP('2011-07-22 17:14:49','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 22/07/2011 5:14:50 PM
-- --
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=61967 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- 22/07/2011 5:14:52 PM
-- --
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,59035,61968,0,328,TO_TIMESTAMP('2011-07-22 17:14:50','YYYY-MM-DD HH24:MI:SS'),100,'The date+time (expressed in decimal format) when the document has been processed',20,'D','The ProcessedOn Date+Time save the exact moment (nanoseconds precision if allowed by the DB) when a document has been processed.','Y','Y','Y','N','N','N','N','N','Processed On',TO_TIMESTAMP('2011-07-22 17:14:50','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 22/07/2011 5:14:52 PM
-- --
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=61968 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=61968
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=61967
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=3996
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=3998
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=4119
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=3993
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=4365
;
-- 22/07/2011 5:15:05 PM
-- --
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=4003
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=8933
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=3997
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=8686
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=8687
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=10585
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=10586
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10587
;
-- 22/07/2011 5:15:06 PM
-- --
UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=3999
;
-- 22/07/2011 5:15:20 PM
-- --
UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2011-07-22 17:15:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=61967
;
-- 26/07/2011 3:12:34 PM
-- --
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.dateAcct',Updated=TO_TIMESTAMP('2011-07-26 15:12:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4918
;

View File

@ -344,6 +344,29 @@ public class DocLine
return m_DateAcct;
} // getDateAcct
/**
* Get FX Conversion Date
*
* The foreign exchange rate conversion date may be different from the accounting posting date in some cases (e.g. bank statement)
*
* @return FX conversion date
*/
public Timestamp getDateConv ()
{
Timestamp dateConv = null;
int index = p_po.get_ColumnIndex("DateAcct");
if (index != -1)
{
dateConv = (Timestamp)p_po.get_Value(index);
}
if (dateConv == null)
dateConv = getDateAcct();
return dateConv;
} // getDateAcct
/**
* Set Document Date
* @param dateDoc doc date

View File

@ -46,6 +46,7 @@ public class DocLine_Bank extends DocLine
m_TrxAmt = line.getTrxAmt();
//
setDateDoc(line.getValutaDate());
setDateAcct(doc.getDateAcct()); // adaxa-pb use statement date
setC_BPartner_ID(line.getC_BPartner_ID());
} // DocLine_Bank

View File

@ -68,7 +68,7 @@ public class Doc_BankStatement extends Doc
{
MBankStatement bs = (MBankStatement)getPO();
setDateDoc(bs.getStatementDate());
setDateAcct(bs.getStatementDate()); // Overwritten on Line Level
setDateAcct(bs.getDateAcct());
m_C_BankAccount_ID = bs.getC_BankAccount_ID();
// Amounts
@ -102,9 +102,7 @@ public class Doc_BankStatement extends Doc
{
MBankStatementLine line = lines[i];
DocLine_Bank docLine = new DocLine_Bank(line, this);
// Set Date Acct
if (i == 0)
setDateAcct(line.getDateAcct());
MPeriod period = MPeriod.get(getCtx(), line.getDateAcct(), line.getAD_Org_ID());
if (period != null && period.isOpen(DOCTYPE_BankStatement, line.getDateAcct()))
docLine.setC_Period_ID(period.getC_Period_ID());

View File

@ -20,6 +20,7 @@ import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
@ -705,14 +706,21 @@ public final class FactLine extends X_Fact_Acct
if (AD_Org_ID == 0)
AD_Org_ID = m_doc.getAD_Org_ID();
}
Timestamp convDate = getDateAcct();
if ( m_doc instanceof Doc_BankStatement )
convDate = m_docLine.getDateConv();
setAmtAcctDr (MConversionRate.convert (getCtx(),
getAmtSourceDr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
getDateAcct(), C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
if (getAmtAcctDr() == null)
return false;
setAmtAcctCr (MConversionRate.convert (getCtx(),
getAmtSourceCr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
getDateAcct(), C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
return true;
} // convert