Suitable database model to use with django annotations

Hello All,

I am developing a database application where I will receive two types of letters every month and clear them and display any pending letters for the month. Before using this application, the client may have any pending letters. So, I have created two tables:

Table

LETTER_OPEN_BAL

with fields and values

LETTER_TYPE | OPEN_BAL
A           | 100
B           | 50

and another table to record the monthly letters received and cleared.

LETTER_INVENTORY

as

MONTH | YEAR | LETTER_TYPE | RECEIVED | CLEARED
Jan   | 2022 | A           | 20       | 60
Jan   | 2022 | B           | 5        | 15

and what to display user each month information like this in template:

OUTPUT

Description          | A |  B |
-------------------------------
Before Jan 2022      |100| 50 |
Received in Jan 2022 |20 | 5  |
Cleared in Jan 2022  |60 | 15 | 
Balance              |60 | 40 |

All subsequent months will fetch data from LETTER_INVENTORY table only, because I know the balance at the end of Jan 2022.

I am able to get this output in template, but not in a single query and I am using variables. Two database requests are made, one for the LETTER_OPEN_BAL table and another for LETTER_INVENTORY. Then i am building individual rows using basic HTML table in the template.

Please suggest, what is the correct approach to achieve this. If I am to use pivot, how to merge the table for the first month and all subsequent months, the OPEN_BAL of next month is the end balance of the previous month?

Thanks