Skip to content

Commit

Permalink
adempiere adempiere#1555 BankTransfer: Voiding Payments
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanneCalderon committed Oct 3, 2018
1 parent a4185fe commit b261eca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 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,13 @@ private void reverseGeneratedPayments() {
/**
* Reverse all payments generated by banktransfer
*/
private void reverseRelatedPayments() {
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{
Expand All @@ -2569,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 @@ -2577,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
2 changes: 1 addition & 1 deletion 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
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 b261eca

Please sign in to comment.