diff --git a/migration/360lts-release/oracle/818_IDEMPIERE-148.sql b/migration/360lts-release/oracle/818_IDEMPIERE-148.sql new file mode 100644 index 0000000000..73836b4cbc --- /dev/null +++ b/migration/360lts-release/oracle/818_IDEMPIERE-148.sql @@ -0,0 +1,10 @@ +-- Feb 13, 2012 12:36:56 PM COT +-- IDEMPIERE-148 Allow reversal invoice to use DocNo^ instead of consuming an invoice # +INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Name,Value,Description,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive) VALUES (200009,'D','C','Invoice_ReverseUseNewNumber','Y','Allows you to choose to use a new number for the reversed invoice.',0,0,TO_DATE('2012-02-13 12:36:55','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-02-13 12:36:55','YYYY-MM-DD HH24:MI:SS'),100,100,'Y') +; + +UPDATE AD_System + SET LastMigrationScriptApplied='818_IDEMPIERE-148.sql' +WHERE LastMigrationScriptApplied<'818_IDEMPIERE-148.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/migration/360lts-release/postgresql/818_IDEMPIERE-148.sql b/migration/360lts-release/postgresql/818_IDEMPIERE-148.sql new file mode 100644 index 0000000000..8601ea14f4 --- /dev/null +++ b/migration/360lts-release/postgresql/818_IDEMPIERE-148.sql @@ -0,0 +1,10 @@ +-- Feb 13, 2012 12:36:56 PM COT +-- IDEMPIERE-148 Allow reversal invoice to use DocNo^ instead of consuming an invoice # +INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Name,Value,Description,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive) VALUES (200009,'D','C','Invoice_ReverseUseNewNumber','Y','Allows you to choose to use a new number for the reversed invoice.',0,0,TO_TIMESTAMP('2012-02-13 12:36:55','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-02-13 12:36:55','YYYY-MM-DD HH24:MI:SS'),100,100,'Y') +; + +UPDATE AD_System + SET LastMigrationScriptApplied='818_IDEMPIERE-148.sql' +WHERE LastMigrationScriptApplied<'818_IDEMPIERE-148.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 1ac1bb9023..3c21dcf4fc 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -55,13 +55,14 @@ import org.eevolution.model.MPPProductBOMLine; *
  • FR [ 2520591 ] Support multiples calendar for Org * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962 * Modifications: Added RMA functionality (Ashley Ramdass) + * Modifications: Generate DocNo^ instead of using a new number whan an invoice is reversed (Diego Ruiz-globalqss) */ public class MInvoice extends X_C_Invoice implements DocAction { /** * */ - private static final long serialVersionUID = 816227083897031327L; + private static final long serialVersionUID = 6821562060687417857L; /** * Get Payments Of BPartner @@ -93,11 +94,33 @@ public class MInvoice extends X_C_Invoice implements DocAction public static MInvoice copyFrom (MInvoice from, Timestamp dateDoc, Timestamp dateAcct, int C_DocTypeTarget_ID, boolean isSOTrx, boolean counter, String trxName, boolean setOrder) + { + return copyFrom (from, dateDoc, dateAcct, + C_DocTypeTarget_ID, isSOTrx, counter, + trxName, setOrder,null); + } + + /** + * Create new Invoice by copying + * @param from invoice + * @param dateDoc date of the document date + * @param acctDate original account date + * @param C_DocTypeTarget_ID target doc type + * @param isSOTrx sales order + * @param counter create counter links + * @param trxName trx + * @param setOrder set Order links + * @param Document Number for reversed invoices + * @return Invoice + */ + public static MInvoice copyFrom (MInvoice from, Timestamp dateDoc, Timestamp dateAcct, + int C_DocTypeTarget_ID, boolean isSOTrx, boolean counter, + String trxName, boolean setOrder, String documentNo) { MInvoice to = new MInvoice (from.getCtx(), 0, trxName); PO.copyValues (from, to, from.getAD_Client_ID(), from.getAD_Org_ID()); to.set_ValueNoCheck ("C_Invoice_ID", I_ZERO); - to.set_ValueNoCheck ("DocumentNo", null); + to.set_ValueNoCheck ("DocumentNo", documentNo); // to.setDocStatus (DOCSTATUS_Drafted); // Draft to.setDocAction(DOCACTION_Complete); @@ -2148,8 +2171,11 @@ public class MInvoice extends X_C_Invoice implements DocAction load(get_TrxName()); // reload allocation reversal info // Deep Copy - MInvoice reversal = copyFrom (this, getDateInvoiced(), getDateAcct(), - getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true); + MInvoice reversal = null; + if (MSysConfig.getBooleanValue("Invoice_ReverseUseNewNumber", true, getAD_Client_ID())) + reversal = copyFrom (this, getDateInvoiced(), getDateAcct(), getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true); + else + reversal = copyFrom (this, getDateInvoiced(), getDateAcct(), getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true, getDocumentNo()+"^"); if (reversal == null) { m_processMsg = "Could not create Invoice Reversal";