Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 9739112

Browse files
committed
Changed check performed when creating/updating payments from "having been in the Paid status ever" to "having the Paid status as the current status".
1 parent 7f89dcd commit 9739112

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,17 +3735,16 @@ private void checkPayment(Connection c, Payment p, boolean newPayment)
37353735
return;
37363736
}
37373737

3738-
// Can't update if payment has already been paid
3738+
// Can't update if payment's current status is Paid
37393739
StringBuffer checkPaid = new StringBuffer(300);
3740-
checkPaid.append("SELECT COUNT(*) FROM payment p, payment_detail pd, payment_detail_xref pdx ");
3741-
checkPaid.append("WHERE p.payment_id = pdx.payment_id ");
3742-
checkPaid.append("AND pdx.payment_detail_id = pd.payment_detail_id ");
3740+
checkPaid.append("SELECT COUNT(*) FROM payment p, payment_detail pd ");
3741+
checkPaid.append("WHERE p.most_recent_detail_id = pd.payment_detail_id ");
37433742
checkPaid.append("AND pd.payment_status_id = " + PaymentStatus.PAID_PAYMENT_STATUS.getId() + " ");
37443743
checkPaid.append("AND p.payment_id = " + p.getHeader().getId());
37453744
ResultSetContainer rsc = runSelectQuery(c, checkPaid.toString());
37463745
int paidRecords = Integer.parseInt(rsc.getItem(0, 0).toString());
37473746
if (paidRecords > 0) {
3748-
throw new PaymentPaidException("Payment " + p.getHeader().getId() + " has already been paid " +
3747+
throw new PaymentPaidException("Payment " + p.getHeader().getId() + " is in the Paid status " +
37493748
"and cannot be updated");
37503749
}
37513750
}

0 commit comments

Comments
 (0)