Although the concept of a ledger is closely associated with financial transactions, Midaz can be used to store a wide variety of applications that require transactions to function. A classic example of this is using Midaz for inventory management in a pharmacy.
Let's suppose a large pharmaceutical company called Doe's Pharma operates in the United States, Canada, Brazil, Spain, and Angola. For this, in North America, it has another parent organization with two ledgers, and for the other countries, it has directly linked ledgers, as shown in Figure 1.
Implementation
Imagine that the pharmaceutical company has various medications, including Novalgina, Dipirona, and Aspirin. Each of these medications would be an instrument created using the Create an Instrument endpoint, as shown below.
POST /v1/organizations/{{id}}/ledgers/{{id}}/instruments
And for each pharmacy, two accounts would be created: one to represent the quantity of medications in the stock and the other for the quantity of medications on the shelves for sale, using the Create an Account endpoint.
POST /v1/organizations/{{id}}/ledgers/{{id}}/portfolios/{{id}}/accounts
With this setup, whenever a medication is sold, it would move from the soho_main account to the @external/NOV-12345-S-BL account (the account representing assets leaving the ledger because they were sold). Whenever inventory is moved from the stock to the shelves, it would move from the soho_warehouse account to the soho_main account, and whenever it is restocked, the reverse path would be followed. Thus, during report generation, the total inventory of the pharmacy, as well as the purchases and sales of medications, could be generated using Midaz's infrastructure.
Going even further, if users were to pay using a digital account from Doe's Pharma, the financial flow could also be handled using Midaz.