From b6d614c696fbcd0a4929c1a6a29af09c8a4d6f32 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 27 Nov 2009 17:40:40 +0000 Subject: [PATCH] Implement [2902882] - Dunning Stabilization https://sourceforge.net/tracker/index.php?func=detail&aid=2902882&group_id=176962&atid=879335 --- base/src/org/compiere/acct/Doc_Cash.java | 8 +- .../org/compiere/model/I_C_DunningLevel.java | 26 ++ base/src/org/compiere/model/MDunning.java | 16 +- base/src/org/compiere/model/MDunningRun.java | 25 +- .../org/compiere/model/MDunningRunEntry.java | 256 +++++++++++------- .../org/compiere/model/MDunningRunLine.java | 22 +- .../org/compiere/model/X_C_DunningLevel.java | 56 +++- .../org/compiere/process/DunningPrint.java | 2 +- .../compiere/process/DunningRunCreate.java | 142 +++++++--- .../611_FR2902882_DunningStabilization.sql | 206 ++++++++++++++ .../611_FR2902882_DunningStabilization.sql | 207 ++++++++++++++ 11 files changed, 805 insertions(+), 161 deletions(-) create mode 100644 migration/354a-trunk/oracle/611_FR2902882_DunningStabilization.sql create mode 100644 migration/354a-trunk/postgresql/611_FR2902882_DunningStabilization.sql diff --git a/base/src/org/compiere/acct/Doc_Cash.java b/base/src/org/compiere/acct/Doc_Cash.java index b224c56559..b1d095b9da 100644 --- a/base/src/org/compiere/acct/Doc_Cash.java +++ b/base/src/org/compiere/acct/Doc_Cash.java @@ -244,9 +244,11 @@ public class Doc_Cash extends Doc } } // lines - // Cash Asset - fact.createLine(null, getAccount(Doc.ACCTTYPE_CashAsset, as), - getC_Currency_ID(), assetAmt); + if (assetAmt.compareTo(Env.ZERO) != 0) { // Carlos Ruiz - globalqss [BF 2904269] + // Cash Asset + fact.createLine(null, getAccount(Doc.ACCTTYPE_CashAsset, as), + getC_Currency_ID(), assetAmt); + } // ArrayList facts = new ArrayList(); diff --git a/base/src/org/compiere/model/I_C_DunningLevel.java b/base/src/org/compiere/model/I_C_DunningLevel.java index 08c10c369b..89073335a4 100644 --- a/base/src/org/compiere/model/I_C_DunningLevel.java +++ b/base/src/org/compiere/model/I_C_DunningLevel.java @@ -223,6 +223,19 @@ public interface I_C_DunningLevel */ public BigDecimal getInterestPercent(); + /** Column name InvoiceCollectionType */ + public static final String COLUMNNAME_InvoiceCollectionType = "InvoiceCollectionType"; + + /** Set Collection Status. + * Invoice Collection Status + */ + public void setInvoiceCollectionType (String InvoiceCollectionType); + + /** Get Collection Status. + * Invoice Collection Status + */ + public String getInvoiceCollectionType(); + /** Column name IsActive */ public static final String COLUMNNAME_IsActive = "IsActive"; @@ -288,6 +301,19 @@ public interface I_C_DunningLevel */ public boolean isShowNotDue(); + /** Column name IsStatement */ + public static final String COLUMNNAME_IsStatement = "IsStatement"; + + /** Set Is Statement. + * Dunning Level is a definition of a statement + */ + public void setIsStatement (boolean IsStatement); + + /** Get Is Statement. + * Dunning Level is a definition of a statement + */ + public boolean isStatement(); + /** Column name Name */ public static final String COLUMNNAME_Name = "Name"; diff --git a/base/src/org/compiere/model/MDunning.java b/base/src/org/compiere/model/MDunning.java index 6e0788d15b..41c580fcb0 100644 --- a/base/src/org/compiere/model/MDunning.java +++ b/base/src/org/compiere/model/MDunning.java @@ -31,7 +31,7 @@ public class MDunning extends X_C_Dunning /** * */ - private static final long serialVersionUID = 796291742140033745L; + private static final long serialVersionUID = -3844081441218291895L; /** * Standard Constructor @@ -55,4 +55,18 @@ public class MDunning extends X_C_Dunning super(ctx, rs, trxName); } // MDunning + + /** + * String Representation + * @return info + */ + @Override + public String toString() + { + StringBuffer sb = new StringBuffer("MDunning[").append(get_ID()) + .append("-").append(getName()); + sb.append("]"); + return sb.toString(); + } // toString + } // MDunning diff --git a/base/src/org/compiere/model/MDunningRun.java b/base/src/org/compiere/model/MDunningRun.java index 9323d40197..9b1b4c1dca 100644 --- a/base/src/org/compiere/model/MDunningRun.java +++ b/base/src/org/compiere/model/MDunningRun.java @@ -39,7 +39,7 @@ public class MDunningRun extends X_C_DunningRun /** * */ - private static final long serialVersionUID = 8450276205229694644L; + private static final long serialVersionUID = 6858939271415643483L; /** * Standard Constructor @@ -88,6 +88,7 @@ public class MDunningRun extends X_C_DunningRun MDunningLevel.Table_Name, "C_Dunning_ID=? AND C_DunningLevel_ID=?", get_TrxName()) + .setOnlyActiveRecords(true) .setParameters(new Object[]{getC_Dunning_ID(), getC_DunningLevel_ID()}) .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .list(); @@ -98,6 +99,7 @@ public class MDunningRun extends X_C_DunningRun MDunningLevel.Table_Name, "C_Dunning_ID=?", get_TrxName()) + .setOnlyActiveRecords(true) .setParameters(new Object[]{getC_Dunning_ID()}) .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .list(); @@ -113,6 +115,17 @@ public class MDunningRun extends X_C_DunningRun * @return entries */ public MDunningRunEntry[] getEntries (boolean requery) + { + return getEntries(requery, false); + } + + /** + * Get Entries + * @param requery requery requery + * @param onlyInvoices only invoices + * @return entries + */ + public MDunningRunEntry[] getEntries (boolean requery, boolean onlyInvoices) { if (m_entries != null && !requery) return m_entries; @@ -126,14 +139,18 @@ public class MDunningRun extends X_C_DunningRun pstmt.setInt (1, getC_DunningRun_ID()); ResultSet rs = pstmt.executeQuery (); while (rs.next ()) + { + MDunningRunEntry thisEntry = new MDunningRunEntry(getCtx(), rs, get_TrxName()); + if (!(onlyInvoices && thisEntry.hasInvoices())) list.add (new MDunningRunEntry(getCtx(), rs, get_TrxName())); + } rs.close (); pstmt.close (); pstmt = null; } catch (Exception e) { - log.log(Level.SEVERE, "getEntries", e); + log.log(Level.SEVERE, sql, e); } try { @@ -158,9 +175,7 @@ public class MDunningRun extends X_C_DunningRun public boolean deleteEntries(boolean force) { getEntries(true); - for (int i = 0; i < m_entries.length; i++) - { - MDunningRunEntry entry = m_entries[i]; + for (MDunningRunEntry entry : m_entries) { entry.delete(force); } boolean ok = getEntries(true).length == 0; diff --git a/base/src/org/compiere/model/MDunningRunEntry.java b/base/src/org/compiere/model/MDunningRunEntry.java index f6916499f6..8346b873e9 100644 --- a/base/src/org/compiere/model/MDunningRunEntry.java +++ b/base/src/org/compiere/model/MDunningRunEntry.java @@ -3,18 +3,18 @@ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.model; + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package org.compiere.model; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -28,9 +28,9 @@ import org.compiere.util.DB; import org.compiere.util.Env; /** - * Dunning Run Entry Model - * - * @author Jorg Janke + * Dunning Run Entry Model + * + * @author Jorg Janke * @version $Id: MDunningRunEntry.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $ * * @author Teo Sarca - BF [ 1739022 ], BF [ 1739096 ] @@ -42,7 +42,7 @@ public class MDunningRunEntry extends X_C_DunningRunEntry /** * */ - private static final long serialVersionUID = 2028055451030209868L; + private static final long serialVersionUID = -3838792682143065656L; /** Logger */ private static CLogger s_log = CLogger.getCLogger (MPayment.class); @@ -50,66 +50,66 @@ public class MDunningRunEntry extends X_C_DunningRunEntry /** * Standard Constructor * @param ctx context - * @param C_DunningRunEntry_ID id - * @param trxName transaction - */ - public MDunningRunEntry (Properties ctx, int C_DunningRunEntry_ID, String trxName) - { - super (ctx, C_DunningRunEntry_ID, trxName); - if (C_DunningRunEntry_ID == 0) - { - // setC_BPartner_ID (0); - // setC_BPartner_Location_ID (0); - // setAD_User_ID (0); - - // setSalesRep_ID (0); - // setC_Currency_ID (0); - setAmt (Env.ZERO); - setQty (Env.ZERO); - setProcessed (false); - } - } // MDunningRunEntry - - /** - * Load Constructor - * @param ctx context - * @param rs result set - * @param trxName transaction - */ - public MDunningRunEntry (Properties ctx, ResultSet rs, String trxName) - { - super(ctx, rs, trxName); - } // MDunningRunEntry - - /** - * Parent Constructor - * @param parent parent - */ - public MDunningRunEntry (MDunningRun parent) - { - this (parent.getCtx(), 0, parent.get_TrxName()); - setClientOrg(parent); - setC_DunningRun_ID(parent.getC_DunningRun_ID()); - m_parent = parent; - } // MDunningRunEntry - - /** Parent */ - private MDunningRun m_parent = null; - - /** - * Set BPartner - * @param bp partner - * @param isSOTrx SO - */ - public void setBPartner (MBPartner bp, boolean isSOTrx) - { - setC_BPartner_ID(bp.getC_BPartner_ID()); - MBPartnerLocation[] locations = bp.getLocations(false); - // Location - if (locations.length == 1) - setC_BPartner_Location_ID (locations[0].getC_BPartner_Location_ID()); - else - { + * @param C_DunningRunEntry_ID id + * @param trxName transaction + */ + public MDunningRunEntry (Properties ctx, int C_DunningRunEntry_ID, String trxName) + { + super (ctx, C_DunningRunEntry_ID, trxName); + if (C_DunningRunEntry_ID == 0) + { + // setC_BPartner_ID (0); + // setC_BPartner_Location_ID (0); + // setAD_User_ID (0); + + // setSalesRep_ID (0); + // setC_Currency_ID (0); + setAmt (Env.ZERO); + setQty (Env.ZERO); + setProcessed (false); + } + } // MDunningRunEntry + + /** + * Load Constructor + * @param ctx context + * @param rs result set + * @param trxName transaction + */ + public MDunningRunEntry (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MDunningRunEntry + + /** + * Parent Constructor + * @param parent parent + */ + public MDunningRunEntry (MDunningRun parent) + { + this (parent.getCtx(), 0, parent.get_TrxName()); + setClientOrg(parent); + setC_DunningRun_ID(parent.getC_DunningRun_ID()); + m_parent = parent; + } // MDunningRunEntry + + /** Parent */ + private MDunningRun m_parent = null; + + /** + * Set BPartner + * @param bp partner + * @param isSOTrx SO + */ + public void setBPartner (MBPartner bp, boolean isSOTrx) + { + setC_BPartner_ID(bp.getC_BPartner_ID()); + MBPartnerLocation[] locations = bp.getLocations(false); + // Location + if (locations.length == 1) + setC_BPartner_Location_ID (locations[0].getC_BPartner_Location_ID()); + else + { MBPartnerLocation firstActive = null; MBPartnerLocation firstBillTo = null; for (int i = 0; i < locations.length; i++) @@ -154,31 +154,31 @@ public class MDunningRunEntry extends X_C_DunningRunEntry log.info(msg); setC_BPartner_Location_ID (firstActive.getC_BPartner_Location_ID()); } - } - } - if (getC_BPartner_Location_ID() == 0) - { - throw new BPartnerNoAddressException(bp); - } - // User with location - MUser[] users = MUser.getOfBPartner(getCtx(), bp.getC_BPartner_ID(), get_TrxName()); - if (users.length == 1) - setAD_User_ID (users[0].getAD_User_ID()); - else - { - for (int i = 0; i < users.length; i++) - { - MUser user = users[i]; - if (user.getC_BPartner_Location_ID() == getC_BPartner_Location_ID()) - { - setAD_User_ID (users[i].getAD_User_ID()); - break; - } - } - } - // - int SalesRep_ID = bp.getSalesRep_ID(); - if (SalesRep_ID != 0) + } + } + if (getC_BPartner_Location_ID() == 0) + { + throw new BPartnerNoAddressException(bp); + } + // User with location + MUser[] users = MUser.getOfBPartner(getCtx(), bp.getC_BPartner_ID(), get_TrxName()); + if (users.length == 1) + setAD_User_ID (users[0].getAD_User_ID()); + else + { + for (int i = 0; i < users.length; i++) + { + MUser user = users[i]; + if (user.getC_BPartner_Location_ID() == getC_BPartner_Location_ID()) + { + setAD_User_ID (users[i].getAD_User_ID()); + break; + } + } + } + // + int SalesRep_ID = bp.getSalesRep_ID(); + if (SalesRep_ID != 0) setSalesRep_ID (SalesRep_ID); } // setBPartner @@ -187,9 +187,21 @@ public class MDunningRunEntry extends X_C_DunningRunEntry * @return Array of all lines for this Run */ public MDunningRunLine[] getLines() + { + return getLines(false); + } // getLines + + /** + * Get Lines + * @param onlyInvoices only with invoices + * @return Array of all lines for this Run + */ + public MDunningRunLine[] getLines (boolean onlyInvoices) { ArrayList list = new ArrayList(); String sql = "SELECT * FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=?"; + if (onlyInvoices) + sql += " AND C_Invoice_ID IS NOT NULL"; PreparedStatement pstmt = null; try { @@ -221,7 +233,47 @@ public class MDunningRunEntry extends X_C_DunningRunEntry MDunningRunLine[] retValue = new MDunningRunLine[list.size()]; list.toArray(retValue); return retValue; + } // getLines + + /** + * Check whether has Invoices + * @return true if it has Invoices + */ + public boolean hasInvoices() + { + boolean retValue = false; + String sql = "SELECT COUNT(*) FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=? AND C_Invoice_ID IS NOT NULL"; + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement(sql, get_TrxName()); + pstmt.setInt(1, get_ID ()); + ResultSet rs = pstmt.executeQuery(); + if (rs.next()) + { + if (rs.getInt(1) > 0) + retValue = true; + } + rs.close(); + pstmt.close(); + pstmt = null; + } + catch (Exception e) + { + s_log.log(Level.SEVERE, sql, e); + } + try + { + if (pstmt != null) + pstmt.close(); + pstmt = null; + } + catch (Exception e) + { + pstmt = null; } + return retValue; + } // hasInvoices /** * Get Parent @@ -245,7 +297,7 @@ public class MDunningRunEntry extends X_C_DunningRunEntry for (int i=0;i0) { String sqlAppend = ""; - for (int i=0; i'N')"; + "C_DunningRun_ID IN (SELECT C_DunningRun_ID FROM C_DunningRunEntry WHERE " + + "C_DunningLevel_ID=" + element.get_ID () + ")) AND Processed<>'N')"; } sql += sqlAppend; } } - sql2 = "SELECT COUNT(*), COALESCE(TRUNC(?-MAX(dr.DunningDate)),0) " - + "FROM C_DunningRun dr" + // ensure that we do only dunn what's not yet dunned, so we lookup the max of last Dunn Date which was processed + sql2 = "SELECT COUNT(*), COALESCE(DAYSBETWEEN(MAX(dr2.DunningDate), MAX(dr.DunningDate)),0)" + + "FROM C_DunningRun dr2, C_DunningRun dr" + " INNER JOIN C_DunningRunEntry dre ON (dr.C_DunningRun_ID=dre.C_DunningRun_ID)" + " INNER JOIN C_DunningRunLine drl ON (dre.C_DunningRunEntry_ID=drl.C_DunningRunEntry_ID) " - + "WHERE drl.Processed='Y' AND drl.C_Invoice_ID=? AND COALESCE(drl.C_InvoicePaySchedule_ID, 0)=?"; - + + "WHERE dr2.C_DunningRun_ID=? AND drl.C_Invoice_ID=?"; // ##1 ##2 BigDecimal DaysAfterDue = level.getDaysAfterDue(); int DaysBetweenDunning = level.getDaysBetweenDunning(); @@ -228,19 +229,21 @@ public class DunningRunCreate extends SvrProcess log.fine("C_Invoice_ID - DaysDue - GrandTotal: " + C_Invoice_ID + " - " + DaysDue + " - " + GrandTotal); log.fine("C_InvoicePaySchedule_ID: " + C_InvoicePaySchedule_ID); // + // Check for Dispute if (!p_IncludeInDispute && IsInDispute) continue; - if (DaysDue < DaysAfterDue.intValue() && !level.isShowAllDue()) + // Check the day again based on rulesets + if (DaysDue > 0 && DaysDue < DaysAfterDue.intValue() && !level.isShowAllDue ()) continue; + // Check for an open amount if (Env.ZERO.compareTo(Open) == 0) continue; // int TimesDunned = 0; int DaysAfterLast = 0; // SubQuery - pstmt2.setTimestamp(1, m_run.getDunningDate()); + pstmt2.setInt (1, m_run.get_ID ()); pstmt2.setInt (2, C_Invoice_ID); - pstmt2.setInt (3, C_InvoicePaySchedule_ID); ResultSet rs2 = pstmt2.executeQuery (); if (rs2.next()) { @@ -248,18 +251,24 @@ public class DunningRunCreate extends SvrProcess DaysAfterLast = rs2.getInt(2); } rs2.close(); - if (previousLevels != null) { - log.fine(TimesDunned + " - " + previousLevels.length); - } // SubQuery - if (level.getParent().isCreateLevelsSequentially() && previousLevels!=null && TimesDunned>previousLevels.length - && !level.isShowAllDue() && !level.isShowNotDue()) - { + + // Ensure that Daysbetween Dunning is enforced + // Ensure Not ShowAllDue and Not ShowNotDue is selected + // PROBLEM: If you have ShowAll activated then DaysBetweenDunning is not working, because we don't know whether + // there is something which we really must Dunn. + if (DaysBetweenDunning != 0 && TimesDunned > 0 && DaysAfterLast < DaysBetweenDunning && !level.isShowAllDue () && !level.isShowNotDue ()) continue; - } - log.fine(DaysBetweenDunning + " - " + DaysAfterLast); - if (DaysBetweenDunning != 0 && DaysAfterLast < DaysBetweenDunning && !level.isShowAllDue() && !level.isShowNotDue()) + + // We don't want to show non due documents + if (DaysDue<0 && !level.isShowNotDue ()) continue; + + // We will minus the timesDunned if this is the DaysBetweenDunning is not fullfilled. + // Remember in checkup later we must reset them! + // See also checkDunningEntry() + if (DaysAfterLast < DaysBetweenDunning) + TimesDunned = TimesDunned*-1; // if (createInvoiceLine(C_Invoice_ID, C_InvoicePaySchedule_ID, C_Currency_ID, GrandTotal, Open, DaysDue, IsInDispute, C_BPartner_ID, @@ -328,10 +337,6 @@ public class DunningRunCreate extends SvrProcess line.setC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID); if (!line.save()) throw new IllegalStateException("Cannot save MDunningRunLine"); - MInvoice invoice = new MInvoice(getCtx(),C_Invoice_ID, get_TrxName()); - invoice.setC_DunningLevel_ID(c_DunningLevel_ID); - if (!invoice.save()) - throw new IllegalStateException("Cannot update dunning level information in invoice"); return true; } // createInvoiceLine @@ -351,15 +356,24 @@ public class DunningRunCreate extends SvrProcess + " AND IsAllocated='N' AND C_BPartner_ID IS NOT NULL" + " AND C_Charge_ID IS NULL" + " AND DocStatus IN ('CO','CL')" - // Only BP with Dunning defined - + " AND EXISTS (SELECT * FROM C_BPartner bp " - + "WHERE p.C_BPartner_ID=bp.C_BPartner_ID" - + " AND bp.C_Dunning_ID=(SELECT C_Dunning_ID FROM C_DunningLevel WHERE C_DunningLevel_ID=?))"; // ##2 + // Only BP(Group) with Dunning defined + + " AND EXISTS (SELECT * FROM C_DunningLevel dl " + + "WHERE dl.C_DunningLevel_ID=?" // // ##2 + + " AND dl.C_Dunning_ID IN " + + "(SELECT COALESCE(bp.C_Dunning_ID, bpg.C_Dunning_ID) " + + "FROM C_BPartner bp" + + " INNER JOIN C_BP_Group bpg ON (bp.C_BP_Group_ID=bpg.C_BP_Group_ID) " + + "WHERE p.C_BPartner_ID=bp.C_BPartner_ID))"; if (p_C_BPartner_ID != 0) sql += " AND C_BPartner_ID=?"; // ##3 else if (p_C_BP_Group_ID != 0) sql += " AND EXISTS (SELECT * FROM C_BPartner bp " + "WHERE p.C_BPartner_ID=bp.C_BPartner_ID AND bp.C_BP_Group_ID=?)"; // ##3 + // If it is not a statement we will add lines only if InvoiceLines exists, + // because we do not want to dunn for money we owe the customer! + if (!level.isStatement()) + sql += " AND C_BPartner_ID IN (SELECT C_BPartner_ID FROM C_DunningRunEntry WHERE C_DunningRun_ID=" + m_run.get_ID () + ")"; + // show only receipts / if only Sales if (p_OnlySOTrx) sql += " AND IsReceipt='Y'"; if ( p_AD_Org_ID != 0 ) @@ -444,18 +458,64 @@ public class DunningRunCreate extends SvrProcess return true; } // createPaymentLine + /** + * Add Fees for every line + */ private void addFees(MDunningLevel level) { - MDunningRunEntry [] entries = m_run.getEntries (true); - if (entries!=null && entries.length>0) { - for (int i=0;i 0) + { + for (MDunningRunEntry element : entries) { + if (level.isShowAllDue() && level.isShowNotDue() && element.getAmt().compareTo(Env.ZERO) < 0) + // showing all the invoices and the amount of the entry is negative - don't generate a fee + continue; + MDunningRunLine line = new MDunningRunLine (element); line.setFee (p_C_Currency_ID, level.getFeeAmt()); if (!line.save()) throw new IllegalStateException("Cannot save MDunningRunLine"); - entries[i].setQty (entries[i].getQty ().subtract (new BigDecimal(1))); - } + element.setQty (element.getQty ().subtract (new BigDecimal(1))); } } + } // addFees + + /** + * Check the dunning run + * 1) Check for following Rule: ShowAll should produce only a record if at least one new line is found + */ + private void checkDunningEntry(MDunningLevel level) + { + // Check rule 1) + if (level.isShowAllDue ()) { + MDunningRunEntry [] entries = m_run.getEntries (true); + if (entries != null && entries.length > 0) + { + for (MDunningRunEntry element : entries) { + // We start with saying we delete this entry as long as we don't find something new + boolean entryDelete = true; + MDunningRunLine [] lines = element.getLines (true); + for (int j = 0; j < lines.length; j++) + { + if (lines[j].getTimesDunned() < 0) + { + // We clean up the *-1 from line 255 + lines[j].setTimesDunned (lines[j].getTimesDunned()*-1); + if (!lines[j].save()) + throw new IllegalStateException("Cannot save MDunningRunLine"); + } + else + { + // We found something new, so we would not save anything... + entryDelete = false; + } + } + if(entryDelete) + element.delete (false); + } + } + } + } // checkDunningEntry } // DunningRunCreate diff --git a/migration/354a-trunk/oracle/611_FR2902882_DunningStabilization.sql b/migration/354a-trunk/oracle/611_FR2902882_DunningStabilization.sql new file mode 100644 index 0000000000..304e6c0373 --- /dev/null +++ b/migration/354a-trunk/oracle/611_FR2902882_DunningStabilization.sql @@ -0,0 +1,206 @@ +-- Nov 23, 2009 9:06:59 PM COT +-- FR2902882-Dunning Stabilization +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Reference_Value_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,58591,3092,0,17,394,331,'InvoiceCollectionType',TO_DATE('2009-11-23 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,'Invoice Collection Status','D',1,'Status of the invoice collection process','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Collection Status',0,TO_DATE('2009-11-23 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- Nov 23, 2009 9:06:59 PM COT +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=58591 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) +; + +-- Nov 23, 2009 9:07:09 PM COT +ALTER TABLE C_DunningLevel ADD InvoiceCollectionType CHAR(1) DEFAULT NULL +; + +-- Nov 23, 2009 9:08:03 PM COT +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,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,58591,58079,0,268,TO_DATE('2009-11-23 21:08:00','YYYY-MM-DD HH24:MI:SS'),100,'Invoice Collection Status',0,'D','Status of the invoice collection process','Y','Y','Y','N','N','N','N','N','Collection Status',210,0,TO_DATE('2009-11-23 21:08:00','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:08:03 PM COT +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=58079 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) +; + +-- Nov 23, 2009 9:09:31 PM COT +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54076,0,'IsStatement',TO_DATE('2009-11-23 21:09:31','YYYY-MM-DD HH24:MI:SS'),100,'Dunning Level is a definition of a statement','D','Y','Is Statement','Is Statement',TO_DATE('2009-11-23 21:09:31','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:09:32 PM COT +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54076 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Nov 23, 2009 9:11:56 PM COT +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,DefaultValue,Description,EntityType,FieldLength,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,58593,54076,0,20,331,'IsStatement',TO_DATE('2009-11-23 21:11:53','YYYY-MM-DD HH24:MI:SS'),100,'N','Dunning Level is a definition of a statement','D',1,'Y','Y','N','N','N','N','N','Y','N','N','N','N','Y','Is Statement',0,TO_DATE('2009-11-23 21:11:53','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- Nov 23, 2009 9:11:56 PM COT +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=58593 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) +; + +-- Nov 23, 2009 9:11:58 PM COT +ALTER TABLE C_DunningLevel ADD IsStatement CHAR(1) DEFAULT 'N' CHECK (IsStatement IN ('Y','N')) NOT NULL +; + +-- Nov 23, 2009 9:12:23 PM COT +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,58593,58080,0,268,TO_DATE('2009-11-23 21:12:22','YYYY-MM-DD HH24:MI:SS'),100,'Dunning Level is a definition of a statement',1,'D','Y','Y','Y','N','N','N','N','N','Is Statement',220,0,TO_DATE('2009-11-23 21:12:22','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:12:23 PM COT +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=58080 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) +; + +-- Nov 23, 2009 9:12:29 PM COT +UPDATE AD_Field SET DisplayLength=1,Updated=TO_DATE('2009-11-23 21:12:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=58079 +; + +-- Nov 23, 2009 9:13:19 PM COT +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_DATE('2009-11-23 21:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=58080 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Element SET Name='Dunning Grace Date', PrintName='Dunning Grace Date',Updated=TO_DATE('2009-11-23 21:14:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Column SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Process_Para SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL, AD_Element_ID=53223 WHERE UPPER(ColumnName)='DUNNINGGRACE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Process_Para SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Element_ID=53223 AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Field SET Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53223) AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:14:18 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Dunning Grace Date', Name='Dunning Grace Date' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=53223) +; + +-- Nov 23, 2009 9:14:40 PM COT +UPDATE AD_Field SET DisplayLogic='@Processed@=Y',Updated=TO_DATE('2009-11-23 21:14:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53257 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2241 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2251 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=10,IsDisplayed='Y' WHERE AD_Field_ID=2239 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=20,IsDisplayed='Y' WHERE AD_Field_ID=2240 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=30,IsDisplayed='Y' WHERE AD_Field_ID=2250 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=40,IsDisplayed='Y' WHERE AD_Field_ID=2245 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=50,IsDisplayed='Y' WHERE AD_Field_ID=2249 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=3221 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=13702 +; + +-- Nov 23, 2009 9:15:34 PM COT +UPDATE AD_Field SET IsSameLine='N',Updated=TO_DATE('2009-11-23 21:15:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13702 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2914 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2918 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=2921 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=2920 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=5738 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=13703 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=13705 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=13704 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=58079 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=58080 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Element SET Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.',Updated=TO_DATE('2009-11-23 21:19:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Column SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Process_Para SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.', AD_Element_ID=1092 WHERE UPPER(ColumnName)='DAYSAFTERDUE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Process_Para SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Element_ID=1092 AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Field SET Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=1092) AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 +-- FR2902882-Dunning Stabilization +UPDATE C_DunningLevel SET IsStatement='Y' WHERE daysafterdue=-9999 +; + +-- Nov 23, 2009 10:20:48 PM COT +UPDATE C_DunningLevel SET IsShowAllDue='Y', IsShowNotDue='Y',Updated=TO_DATE('2009-11-23 22:20:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_DunningLevel_ID=100 +; + +-- Nov 23, 2009 10:20:52 PM COT +UPDATE C_DunningLevel SET IsShowAllDue='Y',Updated=TO_DATE('2009-11-23 22:20:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_DunningLevel_ID=101 +; + diff --git a/migration/354a-trunk/postgresql/611_FR2902882_DunningStabilization.sql b/migration/354a-trunk/postgresql/611_FR2902882_DunningStabilization.sql new file mode 100644 index 0000000000..9a7a802249 --- /dev/null +++ b/migration/354a-trunk/postgresql/611_FR2902882_DunningStabilization.sql @@ -0,0 +1,207 @@ +-- Nov 23, 2009 9:06:59 PM COT +-- FR2902882-Dunning Stabilization +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Reference_Value_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,58591,3092,0,17,394,331,'InvoiceCollectionType',TO_TIMESTAMP('2009-11-23 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,'Invoice Collection Status','D',1,'Status of the invoice collection process','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Collection Status',0,TO_TIMESTAMP('2009-11-23 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- Nov 23, 2009 9:06:59 PM COT +-- FR2902882-Dunning Stabilization +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=58591 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) +; + +-- Nov 23, 2009 9:07:09 PM COT +ALTER TABLE C_DunningLevel ADD COLUMN InvoiceCollectionType CHAR(1) DEFAULT NULL +; + +-- Nov 23, 2009 9:08:03 PM COT +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,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,58591,58079,0,268,TO_TIMESTAMP('2009-11-23 21:08:00','YYYY-MM-DD HH24:MI:SS'),100,'Invoice Collection Status',0,'D','Status of the invoice collection process','Y','Y','Y','N','N','N','N','N','Collection Status',210,0,TO_TIMESTAMP('2009-11-23 21:08:00','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:08:03 PM COT +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=58079 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) +; + +-- Nov 23, 2009 9:09:31 PM COT +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54076,0,'IsStatement',TO_TIMESTAMP('2009-11-23 21:09:31','YYYY-MM-DD HH24:MI:SS'),100,'Dunning Level is a definition of a statement','D','Y','Is Statement','Is Statement',TO_TIMESTAMP('2009-11-23 21:09:31','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:09:32 PM COT +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54076 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Nov 23, 2009 9:11:56 PM COT +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,DefaultValue,Description,EntityType,FieldLength,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,58593,54076,0,20,331,'IsStatement',TO_TIMESTAMP('2009-11-23 21:11:53','YYYY-MM-DD HH24:MI:SS'),100,'N','Dunning Level is a definition of a statement','D',1,'Y','Y','N','N','N','N','N','Y','N','N','N','N','Y','Is Statement',0,TO_TIMESTAMP('2009-11-23 21:11:53','YYYY-MM-DD HH24:MI:SS'),100,0) +; + +-- Nov 23, 2009 9:11:56 PM COT +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=58593 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) +; + +-- Nov 23, 2009 9:11:58 PM COT +ALTER TABLE C_DunningLevel ADD COLUMN IsStatement CHAR(1) DEFAULT 'N' CHECK (IsStatement IN ('Y','N')) NOT NULL +; + +-- Nov 23, 2009 9:12:23 PM COT +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,58593,58080,0,268,TO_TIMESTAMP('2009-11-23 21:12:22','YYYY-MM-DD HH24:MI:SS'),100,'Dunning Level is a definition of a statement',1,'D','Y','Y','Y','N','N','N','N','N','Is Statement',220,0,TO_TIMESTAMP('2009-11-23 21:12:22','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Nov 23, 2009 9:12:23 PM COT +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=58080 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) +; + +-- Nov 23, 2009 9:12:29 PM COT +UPDATE AD_Field SET DisplayLength=1,Updated=TO_TIMESTAMP('2009-11-23 21:12:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=58079 +; + +-- Nov 23, 2009 9:13:19 PM COT +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2009-11-23 21:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=58080 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Element SET Name='Dunning Grace Date', PrintName='Dunning Grace Date',Updated=TO_TIMESTAMP('2009-11-23 21:14:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Column SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Element_ID=53223 +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Process_Para SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL, AD_Element_ID=53223 WHERE UPPER(ColumnName)='DUNNINGGRACE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Process_Para SET ColumnName='DunningGrace', Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Element_ID=53223 AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:14:17 PM COT +UPDATE AD_Field SET Name='Dunning Grace Date', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53223) AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:14:18 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Dunning Grace Date', Name='Dunning Grace Date' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=53223) +; + +-- Nov 23, 2009 9:14:40 PM COT +UPDATE AD_Field SET DisplayLogic='@Processed@=Y',Updated=TO_TIMESTAMP('2009-11-23 21:14:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53257 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2241 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2251 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=10,IsDisplayed='Y' WHERE AD_Field_ID=2239 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=20,IsDisplayed='Y' WHERE AD_Field_ID=2240 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=30,IsDisplayed='Y' WHERE AD_Field_ID=2250 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=40,IsDisplayed='Y' WHERE AD_Field_ID=2245 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=50,IsDisplayed='Y' WHERE AD_Field_ID=2249 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=3221 +; + +-- Nov 23, 2009 9:15:24 PM COT +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=13702 +; + +-- Nov 23, 2009 9:15:34 PM COT +UPDATE AD_Field SET IsSameLine='N',Updated=TO_TIMESTAMP('2009-11-23 21:15:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13702 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2914 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=2918 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=2921 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=2920 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=5738 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=13703 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=13705 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=13704 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=58079 +; + +-- Nov 23, 2009 9:15:56 PM COT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=58080 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Element SET Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.',Updated=TO_TIMESTAMP('2009-11-23 21:19:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Column SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Element_ID=1092 +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Process_Para SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.', AD_Element_ID=1092 WHERE UPPER(ColumnName)='DAYSAFTERDUE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Process_Para SET ColumnName='DaysAfterDue', Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Element_ID=1092 AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 9:19:59 PM COT +UPDATE AD_Field SET Name='Days after due date', Description='Days after due date to dun (if negative days until due)', Help='The Days After Due Date indicates the number of days after the payment due date to initiate dunning. If the number is negative, it includes the not due invoices.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=1092) AND IsCentrallyMaintained='Y' +; + +-- Nov 23, 2009 +-- FR2902882-Dunning Stabilization +UPDATE C_DunningLevel SET IsStatement='Y' WHERE daysafterdue=-9999 +; + +-- Nov 23, 2009 10:20:48 PM COT +UPDATE C_DunningLevel SET IsShowAllDue='Y', IsShowNotDue='Y',Updated=TO_TIMESTAMP('2009-11-23 22:20:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_DunningLevel_ID=100 +; + +-- Nov 23, 2009 10:20:52 PM COT +UPDATE C_DunningLevel SET IsShowAllDue='Y',Updated=TO_TIMESTAMP('2009-11-23 22:20:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_DunningLevel_ID=101 +; +