A CLI program in Go for managing group expenses in spreadsheets
When you are in group of friends, coworkers etc. and constantly lending and borrowing money by paying the group expenses, figuring out who-owes-how-much-to-whom can be cumbersome. GEM solves this problem by providing an organized spreadsheet to put everything at one place and make you free of any calculation.
In the very first moment, you give the names and card numbers of the group members to GEM, and it gives you back a spreadsheet, consisting of six sheets called members, expenses, transactions, debt matrix, settlements and base state (to know more about them look here).
In the spreadsheet provided by GEM you only need to enter the group expenses and transactions and the rest is handled; The debt between each two members is shown in a matrix and the minimum transactions needed for settlement are calculated.
The initial state of your group doesn't need to be even. You can enter the current base state of the group; which is the current debt between each two members. This information will be used in later calculations.
Pro-tip: upload the spreadsheet to a file sharing system like google sheets for everyone to have access!
Download the suitable binary for your system from here. Create a spreadsheet by the create command:
gem create -o my-sheet-name.xlsx
Then you need to enter each member's name and card number. You can also pass the members' information in a .csv
file like this:
gem create -o my-sheet-name.xlsx -f m.csv
And that's it. The spreadsheet is ready for entering the expenses and transactions.
To add a new record, copy and paste the dummy row in expenses/transactions sheet to a new row. This will preserve the styling and Excel formulas!
After adding a few expenses or transactions, to calculate the debts, run the update command:
gem update my-sheet-name.xlsx --overwrite
This command will update the debt matrix and settlement transactions and overwrite the result on the same file. It calculates the debts based on all the expenses and transactions (and the base state).
This cycle is basically how you use GEM; Create the spreadsheet once, add some expenses and transactions, update the debts, add more expenses and transactions, update the debts again and so on.
Use gem [command] --help
for more information about a command, like its flags.
GEM creates a spreadsheet consisting of six sheets. Each sheet holds a specific type of information and is structured differently.
Members sheet contains the initial information you passed to program. Its main use is looking up someone's card number.
Expenses sheet contains the list of all expenses. You add a new row every time somebody pays for something.
Each expense has a payer; The person who paid for the expense and lent money to the group. Each member has a share weight associated with that expense, showing how much of it is their share.
share weight should be a non-negative integer or a boolean value (true is equivalent to 1, false to 0). A zero share weight means that member is not included in the expense.
Share Amount is calculated via an Excel formula based on total amount, sum of share weights and the member's share weight.
Transactions sheet contains the list of all transactions. To state that you have paid some of your debts to the group, add a new row.
Each transaction has a receiver and a payer. The amount of transaction will be reduced from payer's overall debt and the debt state between payer and receiver will be updated.
Debt Matrix sheet contains the debt state between each two members. This matrix is calculated based on expenses transactions and base state only when you run the update command.
For each cell, the person in the row should pay the person in the column. Only the positive values are shown in the matrix.
Settlements sheet the minimum transactions needed for settling up. This list is calculated based on debt matrix and only when you run the update command.
Base State sheet contains the debt state between each two members, before creating the spreadsheet and using GEM. You can easily migrate to GEM by filling this matrix if you have been using a different system. The format of this matrix is similar to debt matrix.
GEM uses excelize to create and edit the spreadsheets.