Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/535 Settlement Transfer Abort #51

Merged
merged 1 commit into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions APIDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ N/A
| in | name | type | required | description |
|-|-|-|-|-|
| query | participantId | integer | false | A valid participant Id to filter on. |
| query | state | string: OPEN, CLOSED, PENDING_SETTLEMENT, SETTLED, NOT_SETTLED | false | A settlement window state to filter on. |
| query | state | string: OPEN, CLOSED, PENDING_SETTLEMENT, SETTLED, ABORTED | false | A settlement window state to filter on. |
| query | fromDateTime | string, date-time | false | The start date for query (relates to central-ledger.settlementWindow.createdDate). Can be used together with `toDateTime'. eg 2017-07-20T17:32:28Z |
| query | toDateTime | string, date-time | false | The end date for query (relates to central-ledger.settlementWindow.createdDate). Can be used together with `fromDateTime'. eg 2017-07-21T17:32:28Z |

Expand Down Expand Up @@ -221,7 +221,7 @@ N/A
| query | participantId | integer | false | A valid participant Id to filter on |
| query | settlementWindowId | number | false | A valid Settlement Window Id to filter on.|
| query | accountId | number | false | A valid Account Id to filter on. |
| query | state | string: PENDING_SETTLEMENT, SETTLED, NOT_SETTLED | false | A settlement state to filter on. |
| query | state | string: PENDING_SETTLEMENT, SETTLED, ABORTED | false | A settlement state to filter on. |
| query | fromDateTime | string, date-time | false | The start date for query (relates to central-ledger.settlement.createdDate). Can be used together with `toDateTime'. eg 2017-07-20T17:32:28Z |
| query | toDateTime | string, date-time | false | The end date for query (relates to central-ledger.settlement.createdDate). Can be used together with `fromDateTime'. eg 2017-07-21T17:32:28Z |
| query | fromSettlementWindowDateTime | string, date-time | false | The start date for query (relates to central-ledger.settlementWindow.createdDate). Can be used together with `toDateTime'. eg 2017-07-20T17:32:28Z |
Expand Down
2 changes: 1 addition & 1 deletion src/domain/settlement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module.exports = {
for (let settlementWindow of settlementWindows) {
let { state } = settlementWindow
if (state !== enums.settlementWindowStates.CLOSED &&
state !== enums.settlementWindowStates.NOT_SETTLED) {
state !== enums.settlementWindowStates.ABORTED) {
let err = new Error('2001')
throw err
}
Expand Down
4 changes: 2 additions & 2 deletions src/interface/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"CLOSED",
"PENDING_SETTLEMENT",
"SETTLED",
"NOT_SETTLED"
"ABORTED"
],
"description": "A settlement window state to filter on.\n",
"required": false
Expand Down Expand Up @@ -274,7 +274,7 @@
"enum": [
"PENDING_SETTLEMENT",
"SETTLED",
"NOT_SETTLED"
"ABORTED"
],
"description": "A settlement state to filter on. \n",
"required": false
Expand Down
14 changes: 7 additions & 7 deletions src/models/settlement/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ const Facade = {
psTransfersReservedCount: 0,
psTransfersCommittedCount: 0,
settledCount: 0,
notSettledCount: 0,
abortedCount: 0,
unknownCount: 0
}
let allAccounts = new Map()
Expand Down Expand Up @@ -594,8 +594,8 @@ const Facade = {
settlementAccounts.settledCount++
break
}
case enums.settlementStates.NOT_SETTLED: {
settlementAccounts.notSettledCount++
case enums.settlementStates.ABORTED: {
settlementAccounts.abortedCount++
break
}
default: {
Expand Down Expand Up @@ -632,7 +632,7 @@ const Facade = {
psTransfersReservedCount: 0,
psTransfersCommittedCount: 0,
settledCount: 0,
notSettledCount: 0
abortedCount: 0
}
switch (state) {
case enums.settlementStates.PENDING_SETTLEMENT: {
Expand All @@ -655,8 +655,8 @@ const Facade = {
windowsAccounts[wid].settledCount++
break
}
case enums.settlementStates.NOT_SETTLED: {
windowsAccounts[wid].notSettledCount++
case enums.settlementStates.ABORTED: {
windowsAccounts[wid].abortedCount++
break
}
default: {
Expand Down Expand Up @@ -867,7 +867,7 @@ const Facade = {
settlementWindows.push(allWindows[affectedWindows[aw]])

if (windowAccounts.psTransfersCommittedCount === 0 &&
windowAccounts.notSettledCount === 0 &&
windowAccounts.abortedCount === 0 &&
windowAccounts.settledCount > 0) {
allWindows[affectedWindows[aw]].settlementWindowStateId = enums.settlementWindowStates.SETTLED
allWindows[affectedWindows[aw]].reason = 'All window settlement accounts are settled'
Expand Down
4 changes: 2 additions & 2 deletions test/unit/models/lib/enums.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Test('Enums', async (enumsTest) => {
{ settlementWindowStateId: 'CLOSED', enumeration: 'CLOSED' },
{ settlementWindowStateId: 'PENDING_SETTLEMENT', enumeration: 'PENDING_SETTLEMENT' },
{ settlementWindowStateId: 'SETTLED', enumeration: 'SETTLED' },
{ settlementWindowStateId: 'NOT_SETTLED', enumeration: 'NOT_SETTLED' }
{ settlementWindowStateId: 'ABORTED', enumeration: 'ABORTED' }
]
Db.settlementWindowState = { find: sandbox.stub().returns(states) }
let settlementWindowStatesEnum = await Enums.settlementWindowStates()
Expand Down Expand Up @@ -95,7 +95,7 @@ Test('Enums', async (enumsTest) => {
const states = [
{ settlementStateId: 'PENDING_SETTLEMENT', enumeration: 'PENDING_SETTLEMENT' },
{ settlementStateId: 'SETTLED', enumeration: 'SETTLED' },
{ settlementStateId: 'NOT_SETTLED', enumeration: 'NOT_SETTLED' }
{ settlementStateId: 'ABORTED', enumeration: 'ABORTED' }
]
Db.settlementState = { find: sandbox.stub().returns(states) }
let settlementStatesEnum = await Enums.settlementStates()
Expand Down
10 changes: 5 additions & 5 deletions test/unit/models/settlement/facade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ Test('Settlement facade', async (settlementFacadeTest) => {
PS_TRANSFERS_COMMITTED: 'PS_TRANSFERS_COMMITTED',
SETTLING: 'SETTLING',
SETTLED: 'SETTLED',
NOT_SETTLED: 'NOT_SETTLED'
ABORTED: 'ABORTED'
},
settlementWindowStates: {
PENDING_SETTLEMENT: 'PENDING_SETTLEMENT',
SETTLED: 'SETTLED',
NOT_SETTLED: 'NOT_SETTLED'
ABORTED: 'ABORTED'
},
participantLimitTypes: {
NET_DEBIT_CAP: 'NET_DEBIT_CAP'
Expand Down Expand Up @@ -341,7 +341,7 @@ Test('Settlement facade', async (settlementFacadeTest) => {
{
participantId: 1,
participantCurrencyId: 4,
settlementStateId: 'NOT_SETTLED',
settlementStateId: 'ABORTED',
reason: 'text',
netAmount: 100,
currencyId: 'USD',
Expand Down Expand Up @@ -417,7 +417,7 @@ Test('Settlement facade', async (settlementFacadeTest) => {
},
{
settlementWindowId: 3,
settlementWindowStateId: 'NOT_SETTLED',
settlementWindowStateId: 'ABORTED',
reason: 'text',
createdDate: now
},
Expand Down Expand Up @@ -1994,7 +1994,7 @@ Test('Settlement facade', async (settlementFacadeTest) => {
test.equal(result.state, 'PENDING_SETTLEMENT', 'Settlement should remain in PENDING_SETTLEMENT state')
test.equal(result.settlementWindows.length, 2, 'Exactly two settlement windows are expected to be affected')
test.equal(result.settlementWindows[0].settlementWindowStateId, 'PENDING_SETTLEMENT', 'First window is PENDING_SETTLEMENT')
test.equal(result.settlementWindows[1].settlementWindowStateId, 'NOT_SETTLED', 'Second window is NOT_SETTLED')
test.equal(result.settlementWindows[1].settlementWindowStateId, 'ABORTED', 'Second window is ABORTED')
test.equal(result.participants.length, 2, 'Two participants are affected')
test.equal(result.participants[0].accounts.length, 6, 'Six accounts for first participant are affected')
test.equal(result.participants[1].accounts.length, 1, 'One account for second participant is affected')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/models/settlementWindow/facade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Test('Settlement Window facade', async (settlementWindowFacadeTest) => {
state: 'SETTLED'
}, {
settlementWindowId: 2,
state: 'NOT_SETTLED'
state: 'ABORTED'
}]
let e

Expand Down