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

Commit 7ee6b4f

Browse files
that should fix it
1 parent a7886f6 commit 7ee6b4f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/services/copilotPaymentService.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ const QUERY_UPDATE_COPILOT_RESOURCE_PAYMENT = `UPDATE resource_info SET value =
3434
// const QUERY_DELETE_COPILOT_RESOURCE_PAYMENT = `DELETE FROM resource_info WHERE resource_id = ? AND resource_info_type_id = ${COPILOT_PAYMENT_RESOURCE_INFO_ID}`
3535

3636
const QUERY_SELECT_PAYMENT_TYPE = `SELECT value FROM resource_info WHERE resource_info_type_id = ${COPILOT_PAYMENT_TYPE_ID} AND resource_id = %d`
37-
const QUERY_INSERT_PAYMENT_TYPE = `INSERT INTO resource_info (resource_id, resource_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (40052372, ${COPILOT_PAYMENT_TYPE_ID}, "true", "TCConnCopilot", CURRENT, "TCConnCopilot", CURRENT)`
38-
const QUERY_UPDATE_PAYMENT_TYPE = `UPDATE resource_info SET value = "true", modify_user = ?, modify_date = CURRENT WHERE resource_id = ? AND resource_info_type_id = ${COPILOT_PAYMENT_TYPE_ID}`
37+
const QUERY_INSERT_PAYMENT_TYPE = `INSERT INTO resource_info (resource_id, resource_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (?, ${COPILOT_PAYMENT_TYPE_ID}, ?, ?, CURRENT, ?, CURRENT)`
38+
const QUERY_UPDATE_PAYMENT_TYPE = `UPDATE resource_info SET value = ?, modify_user = ?, modify_date = CURRENT WHERE resource_id = ? AND resource_info_type_id = ${COPILOT_PAYMENT_TYPE_ID}`
39+
3940
/**
4041
* Prepare Informix statement
4142
* @param {Object} connection the Informix connection
@@ -81,6 +82,7 @@ async function setCopilotPayment (challengeLegacyId, amount, createdBy, updatedB
8182
logger.debug(`No copilot assigned, removing any payments for legacy ID: ${challengeLegacyId}`)
8283
return deleteCopilotPayment(connection, challengeLegacyId)
8384
}
85+
await connection.commitTransactionAsync()
8486
} catch (e) {
8587
logger.error(`Error in 'setCopilotPayment' ${e}`)
8688
await connection.rollbackTransactionAsync()
@@ -111,8 +113,7 @@ async function getCopilotPaymentType (connection, resourceId) {
111113
async function createCopilotPaymentType (connection, resourceId, value, createdBy) {
112114
const query = await prepare(connection, QUERY_INSERT_PAYMENT_TYPE)
113115
logger.debug(`Create Copilot Payment Type Values: ${[resourceId, value, createdBy, createdBy]}`)
114-
const res = await query.executeAsync()
115-
logger.debug(JSON.stringify(res))
116+
await query.executeAsync([resourceId, value, createdBy, createdBy])
116117
}
117118

118119
/**
@@ -125,7 +126,7 @@ async function createCopilotPaymentType (connection, resourceId, value, createdB
125126
async function updateCopilotPaymentType (connection, resourceId, value, createdBy) {
126127
const query = await prepare(connection, QUERY_UPDATE_PAYMENT_TYPE)
127128
logger.debug(`Update Copilot Payment Type Values: ${[value, createdBy, resourceId]}`)
128-
await query.executeAsync([createdBy, resourceId])
129+
await query.executeAsync([value, createdBy, resourceId])
129130
}
130131

131132
/**

0 commit comments

Comments
 (0)