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

feat: migrate central settlement service docs #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
96 changes: 96 additions & 0 deletions website/versioned_docs/v1.0.1/sidebar.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,102 @@
],
"sidebarDepth": 2
},
{
"title": "Central Settlements Services",
"collapsable": true,
"children": [
{
"title": "Settlement Process",
"collapsable": false,
"children": [
{
"title": "Overview",
"path": "central-settlements/settlement-process/"
},
{
"title": "Settlement Windows By Params",
"path": "central-settlements/settlement-process/get-settlement-windows-by-params"
},
{
"title": "Request Settlement By Window",
"path": "central-settlements/settlement-process/get-settlement-window-by-id"
},
{
"title": "Close Settlement Window",
"path": "central-settlements/settlement-process/post-close-settlement-window"
},
{
"title": "Create Settlement",
"path": "central-settlements/settlement-process/post-create-settlement"
},
{
"title": "Request Settlement",
"path": "central-settlements/settlement-process/get-settlement-by-id"
},
{
"title": "Settlement Transfer Acknowledgment",
"path": "central-settlements/settlement-process/put-settlement-transfer-ack"
},
{
"title": "Settlement Abort",
"path": "central-settlements/settlement-process/put-settlement-abort"
},
{
"title": "Request Settlement By SPA",
"path": "central-settlements/settlement-process/get-settlement-by-spa"
},
{
"title": "Request Settlement By Params",
"path": "central-settlements/settlement-process/get-settlements-by-params"
},
{
"title": "Gross Settlement Handler",
"path": "central-settlements/settlement-process/gross-settlement-handler-consumer"
},
{
"title": "Rules Handler",
"path": "central-settlements/settlement-process/rules-handler-consumer"
}
]
},
{
"title": "Funds In/Out",
"collapsable": false,
"path": "central-settlements/funds-in-out",
"children": [
{
"title": "Reconciliation Transfer Prepare",
"path": "central-settlements/funds-in-out/reconciliation-transfer-prepare"
},
{
"title": "Transfer State and Position Change",
"path": "central-settlements/funds-in-out/transfer-state-and-position-change"
},
{
"title": "Funds In",
"path": "central-settlements/funds-in-out/funds-in-prepare-reserve-commit"
},
{
"title": "Funds Out - Prepare & Reserve",
"path": "central-settlements/funds-in-out/funds-out-prepare-reserve"
},
{
"title": "Funds Out - Commit",
"path": "central-settlements/funds-in-out/funds-out-commit"
},
{
"title": "Funds Out - Abort",
"path": "central-settlements/funds-in-out/funds-out-abort"
}
]
},
{
"title": "OSS Settlement FSD",
"collapsable": false,
"path": "central-settlements/oss-settlement-fsd"
}
]
},
{
"title": "Central Event Processor Service",
"collapsable": true,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Central-Settlements Service

The Central Settlements service is part of the Mojaloop project and deployment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Central Settlements service is part of the Mojaloop project and deployment.
The Central Settlements service is part of the Mojaloop core.


* The central settlements service exposes Settlement API to manage the settlements between FSPs and the Central Hub.
* The service manages Settlement Windows and Settlements Event Triggers and provides information about FSPs accounts and settlements.

## 1. Settlement Process Design

### 1.1. Architecture overview

![The Settlements Architecture](./assets/diagrams/architecture/Arch-Mojaloop-Settlements-PI4.svg)

## 2. Funds In/Out

Record Funds In and Record Funds Out operations are used respectively to deposit and withdraw funds into participant SETTLEMENT ledgers. The balance of the SETTLEMENT account relates to the NET_DEBIT_CAP set by the switch for every participant of the scheme. NET_DEBIT_CAP value is always lower or equal to the SETTLEMENT value. On the other side, the balance of the participant's POSITION account is limited to the value of the NET_DEBIT_CAP.

## 3. API Specification

Refer to **Central Settlements API** in the [API Specifications](../../api/README.md#central-settlements-api) section.

## 4. Rules Engine

The rules engine is separate handler within the Central-Settlement handler, that can be deployed if needed. Rules format and way of operation can be found on [Rules Handler . Interchange fees example. File format.](./settlement-process/rules-handler-consume.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Funds In / Out

## 1. Sequence diagrams

### 1.1. Reconciliation Transfer Prepare

- [Sequence Diagram for Reconciliation Transfer Prepare sub-process](reconciliation-transfer-prepare.md)

### 1.2. Transfer State and Position Change

- [Sequence Diagram for Transfer State and Position Change Prepare sub-process](transfer-state-and-position-change.md)

### 1.3. Funds In - Prepare, Reserve, Commit

- [Sequence Diagram for Funds In](funds-in-prepare-reserve-commit.md)

### 1.4. Funds Out - Prepare & Reserve

- [Sequence Diagram for Funds Out Prepare & Reserve](funds-out-prepare-reserve.md)

### 1.5. Funds Out - Commit

- [Sequence Diagram for Funds Out Commit](funds-out-commit.md)

### 1.6. Funds Out - Abort

- [Sequence Diagram for Funds Out Abort](funds-out-abort.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/'*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
- Name Surname <[email protected]>

* Georgi Georgiev <[email protected]>
--------------
******'/

@startuml
' declate title
title 5.1.0.a. Reconciliation transfer prepare (reconciliationTransferPrepare)

autonumber

' Actor Keys:
' boundary - APIs/Interfaces, etc
' collections - Kafka Topics
' control - Kafka Consumers
' entity - Database Access Objects
' database - Database Persistance Store

' declare actors
entity "Transfer DAO" as TRANSFER_DAO
database "Central Store" as DB

box "Central Service" #LightYellow
participant TRANSFER_DAO
participant DB
end box

' start flow
group reconciliationTransferPrepare (payload, trx)
TRANSFER_DAO -> DB: Insert transferDuplicateCheck
activate DB
deactivate DB
hnote over DB #lightyellow
INSERT INTO **transferDuplicateCheck** (transferId, hash, createdDate)
VALUES ({payload.transferId}, hashCode({payload.transferId}), {transactionTimestamp})
end hnote

TRANSFER_DAO -> DB: Insert transfer
activate DB
deactivate DB
hnote over DB #lightyellow
INSERT INTO **transfer** (transferId, amount, currencyId,
ilpCondition, expirationDate, createdDate)
VALUES ({payload.transferId}, {payload.amount.amount},
{payload.amount.curency}, 0,
{new Date()+Config.INTERNAL_TRANSFER_VALIDITY_SECONDS},
{transactionTimestamp})
end hnote

TRANSFER_DAO -> DB: Retrieve hub reconciliation account
activate DB
hnote over DB #lightyellow
SELECT participantCurrencyId AS reconciliationAccountId
FROM **participantCurrency**
WHERE participantId = 1
AND currencyId = {payload.amount.currency}
LIMIT 1
end hnote
deactivate DB
TRANSFER_DAO <-- DB: Return **reconciliationAccountId**

alt payload.action == 'RECORD_FUNDS_IN'
note right of TRANSFER_DAO #lightgray
**ledgerEntryTypeId** = 'RECORD_FUNDS_IN'
**amount** = <color #blue>payload.amount.amount</color>
end note
else payload.action == 'RECORD_FUNDS_OUT_PREPARE'
note right of TRANSFER_DAO #lightgray
**ledgerEntryTypeId** = 'RECORD_FUNDS_OUT'
**amount** = <color #red>-payload.amount.amount</color>
end note
end

TRANSFER_DAO -> DB: Insert transferParticipant records
activate DB
deactivate DB
hnote over DB #lightyellow
INSERT INTO **transferParticipant**
(transferId, participantCurrencyId, transferParticipantRoleTypeId,
ledgerEntryTypeId, amount, createdDate)
VALUES (payload.transferId, reconciliationAccountId, 'HUB',
{ledgerEntryTypeId}, {amount}, {transactionTimestamp})

INSERT INTO **transferParticipant**
(transferId, participantCurrencyId, transferParticipantRoleTypeId,
ledgerEntryTypeId, amount, createdDate)
VALUES ({payload.transferId}, {payload.participantCurrencyId}, 'DFSP_SETTLEMENT',
{ledgerEntryTypeId}, {-amount}, {transactionTimestamp})
end hnote

TRANSFER_DAO -> DB: Insert transferStateChange record
activate DB
deactivate DB
hnote over DB #lightyellow
INSERT INTO **transferStateChange**
(transferId, transferStateId, reason, createdDate)
VALUES ({payload.transferId}, 'RECEIVED_PREPARE',
{payload.reason}, {transactionTimestamp})
end hnote

TRANSFER_DAO -> DB: Save externalReference and extensions
activate DB
deactivate DB
hnote over DB #lightyellow
transferExtension
end hnote
end
@enduml
Loading