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

Commit 563510f

Browse files
author
Sachin Maheshwari
committed
changes according to issue#7
1 parent 61a1461 commit 563510f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

config/default.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ module.exports = {
4242

4343
PAYMENT_STATUS_ID: process.env.PAYMENT_STATUS_ID || 70,
4444
MODIFICATION_RATIONALE_ID: process.env.MODIFICATION_RATIONALE_ID || 1,
45-
WINNER_PAYMENT_TYPE_ID: process.env.WINNER_PAYMENT_TYPE_ID || 65,
46-
COPILOT_PAYMENT_TYPE_ID: process.env.COPILOT_PAYMENT_TYPE_ID || 45,
45+
WINNER_PAYMENT_TYPE_ID: process.env.WINNER_PAYMENT_TYPE_ID || 72,
46+
COPILOT_PAYMENT_TYPE_ID: process.env.COPILOT_PAYMENT_TYPE_ID || 74,
4747

4848
PAYMENT_METHOD_ID: process.env.PAYMENT_METHOD_ID || 1,
4949
CHARITY_IND: process.env.CHARITY_IND || 0,

src/services/paymentService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const paymentDetailIdGen = new IDGenerator('PAYMENT_DETAIL_SEQ')
1212
const paymentIdGen = new IDGenerator('PAYMENT_SEQ')
1313

1414
// the insert statement of payment detail
15-
const INSERT_PAYMENT_DETAIL = 'INSERT INTO payment_detail (payment_detail_id, net_amount, gross_amount, payment_status_id, modification_rationale_id, payment_desc, payment_type_id, date_modified, date_due, payment_method_id, component_project_id, create_date, charity_ind, total_amount, installment_number, create_user) VALUES(?,?,?,?,?,?,?, CURRENT, CURRENT + INTERVAL (15) DAY(5) TO DAY,?,?, CURRENT,?,?,?,?)'
15+
const INSERT_PAYMENT_DETAIL = 'INSERT INTO payment_detail (payment_detail_id, net_amount, gross_amount, payment_status_id, modification_rationale_id, payment_desc, payment_type_id, date_modified, date_due, payment_method_id, component_project_id, create_date, charity_ind, total_amount, installment_number, create_user, jira_issue_id) VALUES(?,?,?,?,?,?,?, CURRENT, CURRENT + INTERVAL (15) DAY(5) TO DAY,?,?, CURRENT,?,?,?,?,?)'
1616
// the insert statement of payment
1717
const INSERT_PAYMENT = 'INSERT INTO payment (payment_id, user_id, most_recent_detail_id, create_date, modify_date, has_global_ad) VALUES(?,?,?, CURRENT, CURRENT, "f")'
1818
// the insert statement of payment detail xref
@@ -41,7 +41,7 @@ async function createPayment (payment) {
4141
try {
4242
await connection.beginTransactionAsync()
4343
const insertDetail = await prepare(connection, INSERT_PAYMENT_DETAIL)
44-
await insertDetail.executeAsync([paymentDetailId, payment.amount, payment.amount, payment.statusId, payment.modificationRationaleId, payment.desc, payment.typeId, payment.methodId, payment.projectId, payment.charityInd, payment.grossAmount, payment.installmentNumber, payment.createUser])
44+
await insertDetail.executeAsync([paymentDetailId, payment.amount, payment.amount, payment.statusId, payment.modificationRationaleId, payment.desc, payment.typeId, payment.methodId, payment.projectId, payment.charityInd, payment.grossAmount, payment.installmentNumber, payment.createUser, payment.v5ChallengeId])
4545
const insertPayment = await prepare(connection, INSERT_PAYMENT)
4646
await insertPayment.executeAsync([paymentId, payment.memberId, paymentDetailId])
4747
const insertDetailXref = await prepare(connection, INSERT_PAYMENT_DETAIL_XREF)

src/services/processorService.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ const config = require('config')
1717
async function processUpdate(message) {
1818
const createUserId = await helper.getUserId(message.payload.createdBy)
1919
const legacyId = _.get(message, 'payload.legacyId', null)
20+
const v5challengeId = _.get(message, 'payload.id', null)
2021

2122
if (!legacyId) {
22-
logger.warn(`payload of challenge ${message.payload.id} does not contain a legacy id`)
23+
logger.warn(`payload of challenge ${v5challengeId} does not contain a legacy id`)
2324
}
2425
const grossAmount = _.sumBy(_.flatMap(message.payload.prizeSets, 'prizes'), 'value')
2526

@@ -32,12 +33,14 @@ async function processUpdate(message) {
3233
charityInd: config.CHARITY_IND,
3334
installmentNumber: config.INSTALLMENT_NUMBER,
3435
createUser: createUserId,
35-
grossAmount
36+
grossAmount,
37+
v5ChallengeId
3638
}
3739

3840
// add winner payment
3941
try {
4042
const winnerPrizes = _.get(_.find(message.payload.prizeSets, ['type', 'placement']), 'prizes', [])
43+
const winnerPaymentDesc = _.get(_.find(message.payload.prizeSets, ['type', 'placement']), 'description', '')
4144
const winnerMembers = _.sortBy(_.get(message.payload, 'winners', []), ['placement'])
4245
if (_.isEmpty(winnerPrizes)) {
4346
logger.warn(`For challenge ${legacyId}, no winner payment avaiable`)
@@ -49,7 +52,7 @@ async function processUpdate(message) {
4952
await paymentService.createPayment(_.assign({
5053
memberId: winnerMembers[i - 1].userId,
5154
amount: winnerPrizes[i - 1].value,
52-
desc: `Task - ${message.payload.name} - ${i} Place`,
55+
desc: (winnerPaymentDesc ? winnerPaymentDesc : `Task - ${message.payload.name} - ${i} Place`),
5356
typeId: config.WINNER_PAYMENT_TYPE_ID
5457
}, basePayment))
5558
}
@@ -61,6 +64,8 @@ async function processUpdate(message) {
6164
// add copilot payment
6265
const copilotId = await helper.getCopilotId(message.payload.id)
6366
const copilotAmount = _.get(_.head(_.get(_.find(message.payload.prizeSets, ['type', 'copilot']), 'prizes', [])), 'value')
67+
const copilotPaymentDesc = _.get(_.find(message.payload.prizeSets, ['type', 'copilot']), 'description', '')
68+
6469
if (!copilotAmount) {
6570
logger.warn(`For challenge ${legacyId}, no copilot payment avaiable`)
6671
} else if (!copilotId) {
@@ -70,7 +75,7 @@ async function processUpdate(message) {
7075
const copilotPayment = _.assign({
7176
memberId: copilotId,
7277
amount: copilotAmount,
73-
desc: `Task - ${message.payload.name} - Copilot`,
78+
desc: (copilotPaymentDesc ? copilotPaymentDesc : `Task - ${message.payload.name} - Copilot`),
7479
typeId: config.COPILOT_PAYMENT_TYPE_ID
7580
}, basePayment)
7681
await paymentService.createPayment(copilotPayment)

0 commit comments

Comments
 (0)