Skip to content

Commit

Permalink
Merge pull request #1984 from SusanneCalderon/feature/Issue1555_Renam…
Browse files Browse the repository at this point in the history
…e_AndDeleteFlag

#1555 BankTransfer: Voiding PaymentsBankTransfer
fixes
  • Loading branch information
e-Evolution committed Oct 7, 2018
2 parents f5705d2 + b261eca commit cc344ab
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 60 deletions.
19 changes: 4 additions & 15 deletions base/src/org/compiere/model/I_C_Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,14 @@ public interface I_C_Payment

public org.compiere.model.I_C_PaymentBatch getC_PaymentBatch() throws RuntimeException;

/** Column name PaymentRelated_ID */
public static final String COLUMNNAME_PaymentRelated_ID = "PaymentRelated_ID";
/** Column name RelatedPayment_ID */
public static final String COLUMNNAME_RelatedPayment_ID = "RelatedPayment_ID";

/** Set Payment Related */
public void setPaymentRelated_ID (int PaymentRelated_ID);
public void setRelatedPayment_ID (int RelatedPayment_ID);

/** Get Payment Related */
public int getPaymentRelated_ID();

public org.compiere.model.I_C_Payment getC_PaymentRelated() throws RuntimeException;
public int getRelatedPayment_ID();

/** Column name C_POS_ID */
public static final String COLUMNNAME_C_POS_ID = "C_POS_ID";
Expand Down Expand Up @@ -795,15 +793,6 @@ public interface I_C_Payment
*/
public boolean isSelfService();

/** Column name IsVoidRelatedDocument */
public static final String COLUMNNAME_IsVoidRelatedDocument = "IsVoidRelatedDocument";

/** Set IsVoidRelatedDocument */
public void setIsVoidRelatedDocument (boolean IsVoidRelatedDocument);

/** Get IsVoidRelatedDocument */
public boolean isVoidRelatedDocument();

/** Column name Micr */
public static final String COLUMNNAME_Micr = "Micr";

Expand Down
3 changes: 2 additions & 1 deletion base/src/org/compiere/model/MPaySelectionCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,12 @@ public static int confirmPrint (List<MPaySelectionCheck> paySelectionChecks, MPa
receiptAccount.setC_BankAccount_ID(line.getC_BankAccountTo_ID());
receiptAccount.setIsReceipt(!payment.isReceipt());
receiptAccount.setC_DocType_ID(!payment.isReceipt());
receiptAccount.setPaymentRelated_ID(payment.getC_Payment_ID());
receiptAccount.setRelatedPayment_ID(payment.getC_Payment_ID());
receiptAccount.setTenderType(MPayment.TENDERTYPE_DirectDeposit);
receiptAccount.saveEx();
receiptAccount.processIt(DocAction.ACTION_Complete);
receiptAccount.saveEx();
payment.setRelatedPayment_ID(receiptAccount.getC_Payment_ID());
}
}
} else {
Expand Down
14 changes: 9 additions & 5 deletions base/src/org/compiere/model/MPayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,7 @@ public MPayment reverseIt(boolean isAccrual)
public boolean reverseCorrectIt()
{
log.info(toString());
String DocAction = getDocAction();
// Before reverseCorrect
processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT);
if (processMsg != null)
Expand All @@ -2503,7 +2504,7 @@ public boolean reverseCorrectIt()
return false;
// Reverse all deposit from cash
reverseGeneratedPayments();
reverseRelatedPayments();
reverseRelatedPayments(DocAction);
//
StringBuilder info = new StringBuilder(processMsg);
// After reverseCorrect
Expand Down Expand Up @@ -2544,13 +2545,14 @@ private void reverseGeneratedPayments() {
/**
* Reverse all payments generated by banktransfer
*/
private void reverseRelatedPayments() {
if (isVoidRelatedDocument() && getPaymentRelated_ID() !=0){
MPayment relatedPayment = (MPayment)getC_PaymentRelated();
private void reverseRelatedPayments(String DocAction) {
if (getRelatedPayment_ID() !=0){
MPayment relatedPayment = (MPayment)getRelatedPayment();
if (relatedPayment.isProcessing()) // to avoid endless loop
return;
if (relatedPayment.getDocStatus().equals(MPayment.DOCSTATUS_Completed)){
relatedPayment.processIt(MPayment.DOCACTION_Void);
relatedPayment.processIt(DocAction);
relatedPayment.saveEx();
}
else{
processMsg= Msg.getMsg(Env.getAD_Language(getCtx()), "The related document is not completed");
Expand All @@ -2568,6 +2570,7 @@ public boolean reverseAccrualIt()
log.info(toString());

// Before reverseAccrual
String DocAction = MPayment.DOCACTION_Reverse_Accrual;
processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL);
if (processMsg != null)
return false;
Expand All @@ -2576,6 +2579,7 @@ public boolean reverseAccrualIt()
return false;

// After reverseAccrual
reverseRelatedPayments(DocAction);
processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL);
if (processMsg != null)
return false;
Expand Down
38 changes: 9 additions & 29 deletions base/src/org/compiere/model/X_C_Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -688,26 +688,26 @@ public int getC_PaymentBatch_ID ()
return ii.intValue();
}

public org.compiere.model.I_C_Payment getC_PaymentRelated() throws RuntimeException
public org.compiere.model.I_C_Payment getRelatedPayment() throws RuntimeException
{
return (org.compiere.model.I_C_Payment)MTable.get(getCtx(), org.compiere.model.I_C_Payment.Table_Name)
.getPO(getPaymentRelated_ID(), get_TrxName()); }
.getPO(getRelatedPayment_ID(), get_TrxName()); }

/** Set Payment Related.
@param PaymentRelated_ID Payment Related */
public void setPaymentRelated_ID (int PaymentRelated_ID)
@param RelatedPayment_ID Payment Related */
public void setRelatedPayment_ID (int RelatedPayment_ID)
{
if (PaymentRelated_ID < 1)
set_Value (COLUMNNAME_PaymentRelated_ID, null);
if (RelatedPayment_ID < 1)
set_Value (COLUMNNAME_RelatedPayment_ID, null);
else
set_Value (COLUMNNAME_PaymentRelated_ID, Integer.valueOf(PaymentRelated_ID));
set_Value (COLUMNNAME_RelatedPayment_ID, Integer.valueOf(RelatedPayment_ID));
}

/** Get Payment Related.
@return Payment Related */
public int getPaymentRelated_ID ()
public int getRelatedPayment_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_PaymentRelated_ID);
Integer ii = (Integer)get_Value(COLUMNNAME_RelatedPayment_ID);
if (ii == null)
return 0;
return ii.intValue();
Expand Down Expand Up @@ -1342,26 +1342,6 @@ public boolean isSelfService ()
return false;
}

/** Set IsVoidRelatedDocument.
@param IsVoidRelatedDocument IsVoidRelatedDocument */
public void setIsVoidRelatedDocument (boolean IsVoidRelatedDocument)
{
set_Value (COLUMNNAME_IsVoidRelatedDocument, Boolean.valueOf(IsVoidRelatedDocument));
}

/** Get IsVoidRelatedDocument.
@return IsVoidRelatedDocument */
public boolean isVoidRelatedDocument ()
{
Object oo = get_Value(COLUMNNAME_IsVoidRelatedDocument);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}

/** Set Micr.
@param Micr
Expand Down
6 changes: 3 additions & 3 deletions base/src/org/eevolution/process/BankTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void generateBankTransfer() {
}

MBankAccount mBankFrom = new MBankAccount(getCtx(), getCBankAccountId(), get_TrxName());
MBankAccount mBankTo = new MBankAccount(getCtx(), getBankAccountToId(), get_TrxName());
MBankAccount mBankTo = new MBankAccount(getCtx(), getToCBankAccountId(), get_TrxName());

MPayment paymentBankFrom = new MPayment(getCtx(), 0 , get_TrxName());
paymentBankFrom.setC_BankAccount_ID(mBankFrom.getC_BankAccount_ID());
Expand Down Expand Up @@ -112,7 +112,7 @@ private void generateBankTransfer() {
paymentBankTo.setC_Charge_ID(getChargeId());
paymentBankTo.saveEx();

paymentBankFrom.setPaymentRelated_ID(paymentBankTo.getC_Payment_ID());
paymentBankFrom.setRelatedPayment_ID(paymentBankTo.getC_Payment_ID());
paymentBankFrom.saveEx();
paymentBankFrom.processIt(MPayment.DOCACTION_Complete);
paymentBankFrom.saveEx();
Expand All @@ -125,7 +125,7 @@ private void generateBankTransfer() {
+ " @C_BankStatement_ID@ " + bsl.getC_BankStatement().getName() + "]");
}
}
paymentBankTo.setPaymentRelated_ID(paymentBankFrom.getC_Payment_ID());
paymentBankTo.setRelatedPayment_ID(paymentBankFrom.getC_Payment_ID());
paymentBankTo.saveEx();
paymentBankTo.processIt(MPayment.DOCACTION_Complete);
paymentBankTo.saveEx();
Expand Down
14 changes: 7 additions & 7 deletions base/src/org/eevolution/process/BankTransferAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class BankTransferAbstract extends SvrProcess {
/** Parameter Name for Bank Account From */
public static final String FROM_C_BANKACCOUNT_ID = "From_C_BankAccount_ID";
/** Parameter Name for Bank Account To */
public static final String C_BANKACCOUNTTO_ID = "C_BankAccountTo_ID";
public static final String TO_C_BANKACCOUNT_ID = "To_C_BankAccount_ID";
/** Parameter Name for Business Partner */
public static final String C_BPARTNER_ID = "C_BPartner_ID";
/** Parameter Name for Currency */
Expand All @@ -61,7 +61,7 @@ public abstract class BankTransferAbstract extends SvrProcess {
/** Parameter Value for Bank Account From */
private int cBankAccountId;
/** Parameter Value for Bank Account To */
private int bankAccountToId;
private int toCBankAccountId;
/** Parameter Value for Business Partner */
private int bPartnerId;
/** Parameter Value for Currency */
Expand All @@ -88,7 +88,7 @@ public abstract class BankTransferAbstract extends SvrProcess {
@Override
protected void prepare() {
cBankAccountId = getParameterAsInt(FROM_C_BANKACCOUNT_ID);
bankAccountToId = getParameterAsInt(C_BANKACCOUNTTO_ID);
toCBankAccountId = getParameterAsInt(TO_C_BANKACCOUNT_ID);
bPartnerId = getParameterAsInt(C_BPARTNER_ID);
currencyId = getParameterAsInt(C_CURRENCY_ID);
conversionTypeId = getParameterAsInt(C_CONVERSIONTYPE_ID);
Expand All @@ -113,13 +113,13 @@ protected void setCBankAccountId(int cBankAccountId) {
}

/** Getter Parameter Value for Bank Account To */
protected int getBankAccountToId() {
return bankAccountToId;
protected int getToCBankAccountId() {
return toCBankAccountId;
}

/** Setter Parameter Value for Bank Account To */
protected void setBankAccountToId(int bankAccountToId) {
this.bankAccountToId = bankAccountToId;
protected void setToCBankAccountId(int toCBankAccountId) {
this.toCBankAccountId = toCBankAccountId;
}

/** Getter Parameter Value for Business Partner */
Expand Down

0 comments on commit cc344ab

Please sign in to comment.