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

Commit 3fdd0ff

Browse files
authored
Merge pull request #10 from topcoder-platform/add_payment_provider_for_wipro
add payment method for wipro
2 parents 37aa9f3 + 9632da6 commit 3fdd0ff

File tree

9 files changed

+200
-61
lines changed

9 files changed

+200
-61
lines changed

resources/taglib/tc-webtags.tld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@
185185
<required>false</required>
186186
<rtexprvalue>true</rtexprvalue>
187187
</attribute>
188+
<attribute>
189+
<name>disabled</name>
190+
<required>false</required>
191+
<rtexprvalue>true</rtexprvalue>
192+
</attribute>
188193
</tag>
189194

190195
<tag>

src/main/com/topcoder/web/common/model/PaymentMethod.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
/**
55
* A class to hold Payment Method data.
66
*
7-
* @author VolodymyrK
7+
* <p>
8+
* Version 1.1 (Topcoder - Add New Payment Provider) Change notes:
9+
* <ol>
10+
* <li>Added eligible attribute to determinate whether the payment method is allowed or not.</li>
11+
* </ol>
12+
* </p>
13+
*
14+
* @author VolodymyrK, TCSCODER
15+
* @version 1.1
816
*/
917
public class PaymentMethod extends Base {
1018

1119
private Long id;
1220
private String name;
21+
private boolean eligible = true;
1322

1423
public PaymentMethod() {
1524
}
@@ -30,4 +39,12 @@ public void setName(String name) {
3039
this.name = name;
3140
}
3241

42+
public boolean isEligible() {
43+
return eligible;
44+
}
45+
46+
public void setEligible(boolean eligible) {
47+
this.eligible = eligible;
48+
}
49+
3350
}

src/main/com/topcoder/web/common/tag/RadioButtonTag.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
* User: dok
55
* Date: Jan 3, 2005
66
* Time: 5:53:26 PM
7+
*
8+
* Version 1.1 (Topcoder - Add New Payment Provider) 08/08/2017
9+
* - Add "disabled" attribute
10+
*
11+
* @author dok, TCSCODER
12+
* @version 1.1
713
*/
814
public class RadioButtonTag extends BaseTag {
915
private String value = null;
1016
private String selected = null;
1117
private String onClick = null;
18+
private String disabled = null;
1219

1320
public int doStartTag() {
1421
StringBuffer ret = new StringBuffer();
@@ -25,6 +32,9 @@ public int doStartTag() {
2532
}
2633
if (onClick != null)
2734
ret.append("onClick=\"").append(onClick).append("\" ");
35+
if (disabled != null) {
36+
ret.append("disabled ");
37+
}
2838
ret.append("/>");
2939
pageContext.getOut().print(ret.toString());
3040
} catch (java.io.IOException ioe) {
@@ -48,6 +58,10 @@ public void setOnClick(String onClick) {
4858
this.onClick = onClick;
4959
}
5060

61+
public void setDisabled(String disabled) {
62+
this.disabled = disabled;
63+
}
64+
5165
protected void init() {
5266
this.value = null;
5367
this.selected = null;

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2004 - 2012 TopCoder Inc., All Rights Reserved.
2+
* Copyright (C) 2004 - 2017 TopCoder Inc., All Rights Reserved.
33
*/
44
package com.topcoder.web.ejb.pacts;
55

@@ -75,7 +75,7 @@
7575
* <ol>
7676
* <li>Added common payment types for all tracks. No more separate payments for architecture, assembly, components etc.</li>
7777
* </ol>
78-
* </p>
78+
* </p>
7979
*
8080
* <p>
8181
* Version 1.10 (Member Payments Automation Assembly 1.0) Change notes:
@@ -84,8 +84,15 @@
8484
* </ol>
8585
* </p>
8686
*
87-
* @author pulky, VolodymyrK, isv
88-
* @version 1.10
87+
* <p>
88+
* Version 1.11 (Topcoder - Add New Payment Provider) Change notes:
89+
* <ol>
90+
* <li>Added {@link WIPRO_PAYROLL_PAYMENT_METHOD_ID} constant.</li>
91+
* </ol>
92+
* </p>
93+
*
94+
* @author pulky, VolodymyrK, isv, TCSCODER
95+
* @version 1.11
8996
*/
9097
public interface Constants {
9198

@@ -271,10 +278,11 @@ public interface Constants {
271278
public static final long NOT_SET_PAYMENT_METHOD_ID = 1;
272279
public static final long PAYPAL_PAYMENT_METHOD_ID = 2;
273280
public static final long PAYONEER_PAYMENT_METHOD_ID = 5;
281+
public static final long WIPRO_PAYROLL_PAYMENT_METHOD_ID = 7;
274282

275283
/**
276284
* <p>A <code>long</code> providing the ID of <code>Western Union</code> payment method.</p>
277-
*
285+
*
278286
* @since 1.10
279287
*/
280288
public static final long WESTERN_UNION_PAYMENT_METHOD_ID = 6;

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

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2004 - 2012 TopCoder Inc., All Rights Reserved.
2+
* Copyright (C) 2004 - 2017 TopCoder Inc., All Rights Reserved.
33
*/
44
package com.topcoder.web.ejb.pacts;
55

@@ -126,11 +126,17 @@
126126
* method.</li>
127127
* </ol>
128128
* </p>
129+
* <p>
130+
* Version 1.8 (Topcoder - Add New Payment Provider) Change notes:
131+
* <ol>
132+
* <li>Added {@link #hasWiproSSOAccount(long)} method.</li>
133+
* </ol>
134+
* </p>
129135
*
130136
* <p>VERY IMPORTANT: remember to update serialVersionUID if needed.</p>
131137
*
132-
* @author Dave Pecora, pulky, isv, Vitta, Blues, FireIce
133-
* @version 1.7
138+
* @author Dave Pecora, pulky, isv, Vitta, Blues, FireIce, TCSCODER
139+
* @version 1.8
134140
* @see PactsConstants
135141
*/
136142
public class PactsServicesBean extends BaseEJB implements PactsConstants {
@@ -1539,7 +1545,7 @@ public void saveUserPaymentMethod(long userId, long paymentMethodId) {
15391545
if (userId == 0) {
15401546
throw new IllegalArgumentException("Invalid user ID");
15411547
}
1542-
1548+
15431549
if (paymentMethodId <= 0) {
15441550
throw new IllegalArgumentException("Invalid payment method ID.");
15451551
}
@@ -1608,7 +1614,7 @@ public void saveUserPayPalAccount(long userId, String payPalAccount) {
16081614
if (payPalAccount == null) {
16091615
throw new IllegalArgumentException("Invalid email address of the PayPal account");
16101616
}
1611-
1617+
16121618
PreparedStatement insertPs = null, updatePs = null;
16131619
Connection conn = null;
16141620
try {
@@ -3203,7 +3209,7 @@ public Map findPayments(Map searchCriteria) throws SQLException {
32033209

32043210
StringBuffer whereClauses = new StringBuffer(300);
32053211
whereClauses.append(" WHERE 1=1 ");
3206-
3212+
32073213
ArrayList objects = new ArrayList();
32083214
Iterator i = searchCriteria.keySet().iterator();
32093215
try {
@@ -3759,7 +3765,7 @@ public double computePaymentNetAmount(int paymentTypeId, double grossAmount, lon
37593765

37603766
log.debug("In computePaymentNetAmount");
37613767
Connection c = null;
3762-
3768+
37633769
try {
37643770
c = DBMS.getConnection(trxDataSource);
37653771

@@ -3813,7 +3819,7 @@ public double computePaymentNetAmount(int paymentTypeId, double grossAmount, lon
38133819
} else {
38143820
return grossAmount;
38153821
}
3816-
3822+
38173823
// Round to lower pennie
38183824
BigDecimal bd = new BigDecimal(netAmount).setScale(2, RoundingMode.HALF_DOWN);
38193825
double roundedNetAmount = bd.doubleValue();
@@ -5334,7 +5340,7 @@ public int generateRoundPayments(long roundId, boolean makeChanges, int paymentT
53345340
}
53355341

53365342
/**
5337-
5343+
53385344
* Generates all the payments for the people who won money for the given project (winners and
53395345
* and review board members).
53405346
* It doesn't insert the payments in the DB, just generates and returns them.
@@ -5376,7 +5382,7 @@ public List generateComponentPayments(long projectId, long status, String client
53765382
getWinners.append(" ELSE ROUND(ri7.value) ");
53775383
getWinners.append(" END::float AS payment ");
53785384

5379-
getWinners.append(" FROM tcs_catalog:project p ");
5385+
getWinners.append(" FROM tcs_catalog:project p ");
53805386
getWinners.append(" INNER JOIN tcs_catalog:project_category_lu pcl ON pcl.project_category_id = p.project_category_id ");
53815387
getWinners.append(" INNER JOIN tcs_catalog:resource r ON r.project_id = p.project_id AND r.resource_role_id = 1 ");
53825388
getWinners.append(" INNER JOIN tcs_catalog:resource_info ri1 ON r.resource_id = ri1.resource_id AND ri1.resource_info_type_id = 1 ");
@@ -5398,10 +5404,10 @@ public List generateComponentPayments(long projectId, long status, String client
53985404
long resourceId = rsc.getLongItem(i, "resource_id");
53995405
long projectCategoryId = rsc.getLongItem(i, "project_category_id");
54005406
String submissionType = rsc.getStringItem(i, "submission_type");
5401-
5407+
54025408
double penalty = penalties.get(coderId) == null ? 0.0 : penalties.get(coderId);
54035409
double amount = rsc.getDoubleItem(i, "payment")*(1.0-penalty);
5404-
5410+
54055411
log.info("Generating payment. Coder: " + coderId + " placed: " + placed + " amount: " + amount + " penalty: " + penalty + " resourceId: " + resourceId);
54065412
if (amount < 0.01) {
54075413
log.info("Ignoring the payment because of zero or negative amount.");
@@ -5413,7 +5419,7 @@ public List generateComponentPayments(long projectId, long status, String client
54135419
if (projectCategoryId == 37) { // If Marathon Match
54145420
if (rsc.getItem(i, "mm_round_id").getResultData() == null) {
54155421
log.info("MM round ID is not set. Ignoring the payment.");
5416-
continue;
5422+
continue;
54175423
}
54185424

54195425
long mmRoundId = rsc.getLongItem(i, "mm_round_id");
@@ -5433,7 +5439,7 @@ public List generateComponentPayments(long projectId, long status, String client
54335439

54345440
// Calculate the due date for the 2nd installment.
54355441
// It should be max(general due date assigned by the system, SECOND_INSTALLMENT_HOLD_PERIOD days from now).
5436-
Calendar cal = Calendar.getInstance();
5442+
Calendar cal = Calendar.getInstance();
54375443
cal.add(Calendar.DATE, SECOND_INSTALLMENT_HOLD_PERIOD);
54385444

54395445
payment2 = fillPaymentData(payment2);
@@ -5448,8 +5454,8 @@ public List generateComponentPayments(long projectId, long status, String client
54485454
} else if (submissionType.startsWith("Checkpoint Submission")) {
54495455
payments.add(new ContestCheckpointPayment(coderId, amount, client, projectId, placed));
54505456
}
5451-
5452-
resourceIds.add(new Long(resourceId));
5457+
5458+
resourceIds.add(new Long(resourceId));
54535459
} else {
54545460
log.info("Payments for the coder " + coderId + " are skipped because he/she still has pending late deliverables.");
54555461
}
@@ -5494,7 +5500,7 @@ public List generateComponentPayments(long projectId, long status, String client
54945500
log.info("Payments for the coder " + coderId + " are skipped because he/she still has pending late deliverables.");
54955501
continue;
54965502
}
5497-
5503+
54985504
String paymentType = rsc.getStringItem(i, "payment_type");
54995505
double penalty = penalties.get(coderId) == null ? 0.0 : penalties.get(coderId);
55005506
double amount = rsc.getDoubleItem(i, "paid");
@@ -5505,7 +5511,7 @@ public List generateComponentPayments(long projectId, long status, String client
55055511

55065512
ComponentProjectReferencePayment p = null;
55075513
int projectType = getProjectType(projectId);
5508-
5514+
55095515
if (paymentType.startsWith("Copilot Payment")) {
55105516
// The penalties are not applied to the copilot payments
55115517
p = new CopilotPayment(coderId, amount, client, projectId);
@@ -5537,8 +5543,8 @@ public List generateComponentPayments(long projectId, long status, String client
55375543
return payments;
55385544
}
55395545

5540-
/**
5541-
* Returns the maximum of two dates. A null date is considered to be less than any non-null date.
5546+
/**
5547+
* Returns the maximum of two dates. A null date is considered to be less than any non-null date.
55425548
*/
55435549
private static Date max(Date d1, Date d2) {
55445550
if (d1 == null && d2 == null) {
@@ -5559,7 +5565,7 @@ private static Date max(Date d1, Date d2) {
55595565
* is still in the 24 hours window since the moment of creation (which means the late member can still explain it).
55605566
*
55615567
* @param projectId The ID of the project
5562-
* @return List of user IDs who have pending late deliverables for this project.
5568+
* @return List of user IDs who have pending late deliverables for this project.
55635569
* @throws SQLException If there was some error retrieving the data.
55645570
*/
55655571
private List<Long> getPendingUserIds(long projectId) throws SQLException {
@@ -5569,9 +5575,9 @@ private List<Long> getPendingUserIds(long projectId) throws SQLException {
55695575
query.append(" ld.resource_id = r.resource_id and r.project_id = " + projectId + " and ");
55705576
query.append(" r.resource_id = ri.resource_id and ri.resource_info_type_id = 1 and ");
55715577
query.append(" ld.forgive_ind=0 and ");
5572-
query.append(" ((ld.explanation is not null and ld.response is null) "); // if the explained record is waiting for the response
5578+
query.append(" ((ld.explanation is not null and ld.response is null) "); // if the explained record is waiting for the response
55735579
query.append(" or (ld.explanation is null and ld.create_date>current-24 units hour)) "); // or if the late member still has time to explain (24 hours)
5574-
5580+
55755581
List<Long> userIds = new ArrayList<Long>();
55765582
ResultSetContainer rsc = runSelectQuery(query.toString());
55775583
for (int i = 0; i < rsc.size(); i++) {
@@ -5598,19 +5604,19 @@ private Map<Long,Double> getPaymentPenalties(long projectId) throws SQLException
55985604
query.append(" r.project_id=" + projectId + " and r.resource_id=ld.resource_id and r.resource_id=ri.resource_id and ");
55995605
query.append(" ri.resource_info_type_id=1 and ld.forgive_ind=0 ");
56005606
query.append(" group by 1 ");
5601-
5607+
56025608
Map<Long,Double> penalties = new HashMap<Long,Double>();
56035609
ResultSetContainer rsc = runSelectQuery(query.toString());
56045610
for (int i = 0; i < rsc.size(); i++) {
56055611
long userId = rsc.getLongItem(i, "user_id");
56065612
long delay = rsc.getLongItem(i, "total_delay");
56075613
long rejectedFinalFixes = rsc.getLongItem(i, "rejected_final_fixes");
5608-
5614+
56095615
long paymentPenaltyPercentage = (delay>0 ? 5 : 0) + (delay/3600) + rejectedFinalFixes * 5;
56105616
if (paymentPenaltyPercentage > 50) {
56115617
paymentPenaltyPercentage = 50;
56125618
}
5613-
5619+
56145620
penalties.put(userId, (double)paymentPenaltyPercentage/100.0);
56155621
}
56165622
return penalties;
@@ -6513,7 +6519,7 @@ private int getProjectType(long projectId) throws SQLException {
65136519
}
65146520

65156521
private boolean isStudioProject(long projectId) throws SQLException {
6516-
ResultSetContainer rsc = runSelectQuery("SELECT pcl.project_type_id FROM tcs_catalog:project_category_lu pcl, " +
6522+
ResultSetContainer rsc = runSelectQuery("SELECT pcl.project_type_id FROM tcs_catalog:project_category_lu pcl, " +
65176523
" tcs_catalog:project p WHERE p.project_category_id=pcl.project_category_id and p.project_id=" + projectId);
65186524

65196525
if (rsc.size() == 0) {
@@ -6748,12 +6754,12 @@ public List findCoderPayments(long coderId, int paymentTypeId, long referenceId)
67486754
searchCriteria.put(PAYMENT_REFERENCE_ID, String.valueOf(referenceId));
67496755
return findCoderPayments(searchCriteria);
67506756
}
6751-
6757+
67526758
/**
67536759
* Find a Jira payment by its issue key.
67546760
* @param jiraIssueKey the issue key.
67556761
* @return the Jira payments for the given issue, or empty if not found
6756-
* @throws RemoteException if there is an error
6762+
* @throws RemoteException if there is an error
67576763
* @throws Exception if there is an error
67586764
* @throws InvalidStatusException if there is an error
67596765
*/
@@ -7075,6 +7081,32 @@ public ResultSetContainer getContestsInfo(long eid) throws SQLException {
70757081

70767082
}
70777083

7084+
/**
7085+
* Returns true if the specified user is a Wipro SSO user.
7086+
*
7087+
* @param userId The user ID to check.
7088+
* @return Whether the user is a Wipro SSO user.
7089+
* @throws SQLException If there is some problem querying the database
7090+
*/
7091+
public boolean hasWiproSSOAccount(long userId) throws SQLException {
7092+
StringBuffer query = new StringBuffer(300);
7093+
query.append("SELECT COUNT(*) FROM user u ");
7094+
query.append(" JOIN user_sso_login su ON su.user_id = u.user_id ");
7095+
query.append(" JOIN sso_login_provider sp ON sp.sso_login_provider_id = su.provider_id AND sp.name = 'wipro-adfs' ");
7096+
query.append("WHERE u.user_id = " + userId);
7097+
7098+
Connection c = null;
7099+
boolean ret = false;
7100+
try {
7101+
c = DBMS.getConnection(DBMS.COMMON_OLTP_DATASOURCE_NAME);
7102+
ResultSetContainer rsc = runSelectQuery(c, query.toString());
7103+
ret = Integer.parseInt(rsc.getItem(0, 0).toString()) > 0;
7104+
} finally {
7105+
close(c);
7106+
}
7107+
return ret;
7108+
}
7109+
70787110
class AlgorithmContestPaymentDataRetriever extends AlgorithmContestPayment {
70797111
private final String roundName;
70807112
private final Date dueDate;

0 commit comments

Comments
 (0)