Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/domain/participant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,53 @@ const getLimitsForAllParticipants = async ({ currency = null, type = null }) =>
* @returns {integer} - Returns number of database rows affected if successful, or throws an error if failed
*/

// {
Comment thread
vgenev marked this conversation as resolved.
Outdated
// "currency": "USD",
// "limit": {
// "type": "NET_DEBIT_CAP",
// "value": 1500,
// "thresholdAlarmPercentage": 10
// }
// }

const adjustLimits = async (name, payload) => {
try {
const participant = await ParticipantFacade.getByNameAndCurrency(name, payload.currency, Enum.LedgerAccountType.POSITION)
let { limit, currency } = payload
payload.name = name
Comment thread
vgenev marked this conversation as resolved.
Outdated
const participant = await ParticipantFacade.getByNameAndCurrency(name, currency, Enum.LedgerAccountType.POSITION)
participantExists(participant)
return ParticipantFacade.adjustLimits(participant.participantCurrencyId, payload.limit)
let result = await ParticipantFacade.adjustLimits(participant.participantCurrencyId, limit)
await Utility.produceGeneralMessage(TransferEventType.NOTIFICATION, TransferEventAction.EVENT, createLimitAdjustmentMessageProtocol(payload), Utility.ENUMS.STATE.SUCCESS)
return result
} catch (err) {
throw err
}
}

const createLimitAdjustmentMessageProtocol = (payload, action = 'limitAdjustment', state = '', pp = '') => {
return {
id: Uuid(),
from: payload.name,
to: 'SYSTEM',
type: 'application/json',
content: {
header: {},
payload
},
metadata: {
event: {
id: Uuid(),
responseTo: '',
type: 'notification',
action,
createdAt: new Date(),
state
}
},
pp
}
}

/**
* @function GetPositions
*
Expand Down