Kafka
Here are the events that need to be consumed in order to build up a database for external services.
Party Events
Party service contains all contacts. Each party belongs to an Agency.
Events
- topic: "party-PartyEvent"
- type: PartyCreated_v1 & PartyUpdated_v1
- description: A party is either a company or person.
# company
{
:type=>"PartyCreated_v1", # PartyUpdated_v1
:id=>SecureRandom.uuid,
:taggableParty=>{
:company=>{
:tags=>["Landlord"],
:companyName=>"Mitch Again",
:tradingAs=>"",
:vatRegistered=>false,
:vatNumber=>"",
:companyRegistration=>"256033703",
:emailAddress=>"mitchagain@example.com",
:telNumber=>"3988634226",
:contactPersonFirstName=>"test",
:contactPersonLastName=>"Fredric Liane Greenholt",
:bank=>"FNB",
:branchCode=>"7174",
:accountName=>"Testing",
:accountNumber=>"123123123",
:accountType=>"Cheque"
}
}
}
# Person
{
:type=>"PartyCreated_v1", # PartyUpdated_v1
:id=>SecureRandom.uuid,
:taggableParty=>{
"person": {
"id": "117a20e1-222d-45a3-b08c-86ce50db82c3",
"agency": "0ed4c91b-d822-4685-9957-3ffa3599f318",
"tags": [
"Tenant",
"BodyCorporate"
],
"firstName": "Michael",
"lastName": "van Aswegen",
"idNumber": "8207205263083",
"emailAddress": "jeff+michael@rentalconnect.co.za",
"cellNumber": "0718980227",
"telNumber": "",
"bank": "",
"accountName": "",
"accountNumber": "",
"accountType": ""
}
}
}
- topic: "party-PartyEvent"
- type: PartyAccountAdded
- description: Parties can contain many accounts, we invoice and collect funds against the account. The account also has a payment reference the party must use when making payments.
{
"type": "PartyAccountAdded",
"id": "UUID",
"agencyId": "UUID",
"account": {
"partyId": "UUID",
"accountId": "UUID",
"tag": "String" # Team, Supplier, Tenant, Landlord, Trust
"portfolioId": "UUID", # portfolio = lease
"propertyAddress": "String"
}
}
Wallet Events
The wallet service is responsible for allocating receipts to wallets, if however the reference does not match an existing wallet the following event will be emitted.
- topic: "wallet-WalletEvent"
- type: BadReferenceReceived
- description: Money has come in to the account but
{
"type": "BadReferenceReceived",
"id": "UUID",
"transactionId": "String",
"transactionDate": "String", # yyyy-mm-dd
"transactionAmount": "BigDecimal", # precision 2
"transactionType": "String", # EFT || Cash
"referenceUsed": "String"
}
With this event you should have enough data to now prompt an admin user to allocate the funds to a PartyAccount
.
Once your workflow is complete, docs uploaded and the allocation takes place you will need to publish an event to Kafka in order for the Wallet Service to allocate accordingly.
- topic: "admin-WalletEvent"
- type: BadReferenceAssigned
- description: Money is now allocated
{
"type": "BadReferenceAssigned",
"id": "UUID",
"transactionId": "String",
"accountId": "UUID",
"correctReference": "String",
"eventRecord": { # who did the allocation and when
"userId": "UUID",
"createdAt": "Long"
}
}
Notes
This pattern is used by all services, so if the admin dashboard needs access to invoices as an example, your service can hook into the Invoice Topic on Kafka and consume all those events. However, what we will do is co-ordinate specific access points as some cases it might make sense to expose API calls to certain services rather than consuming all events. But we will take this on a case by case basis.