This repository contains the Python program BillSplitterForTwo
which, once run, prompts to the user to:
- create a new file;
- add a transaction (to an existing file);
- show account balances;
- quit.
The program creates or updates an .xlsx
file in the same folder containing the program itself.
pip install pandas xlsxwriter
python BillSplitterforTwo.py
This program is tailored to accounting for two people. Not three or higher. The .xlsx
file created contains two sheets, one for each person.
On each person's sheet the following fields are created:
- description;
- total amount;
- taxes;
- additional costs;
- person's amount;
- amount paid by person;
- what they are owed/owed;
- external debts.
Upon creating a file, the above fields are initialised. When adding a transaction, the user is prompted to fill in each field.
The program itself passes no values and relies on user inputs.
As mentioned, this system is tailored to record-keeping for two people, say person
By construction
There are three scenarios to now consider: where the totals paid equals the total, is overpaid or underpaid. That is:
-
$x_A + x_B = t$ ; -
$x_A + x_B > t$ ; -
$x_A + x_B < t$ .
Recall, it is always the case that owed/owes
. In
Note. In this case
In this case
Upon redistribution, each person's effective pay is:
This scenario is more difficult to account for since, in this case, external debts
column.
Now if both persons underpay, external debts
column on the respective spreadsheets.
In the case where one of the persons pay what they owe while the other fails, e.g.,
Finally, we have the subtle case where one overpays and the other underpays to the point of total underpayment. So e.g.,
The debt owed by
Note. Recording the debt owed by
Suppose Alice and Balkrishna split a taxi fare. The taxi costs
- Alice pays
$350$ ; Balkrishna pays$150$ .
Then owed/owes
column. It will likewise record owed/owes
column.
Balkrishna owes Alice
Alice and Balkrishna took that taxi to a restaurant for dinner. Alice had the sirloin pork cutlet and Balkrishna a full spit roast. Suppose the dinner for both cost 1500. Of this:
- Alice paid
$600$ while Balkrishna pids$1200$ .
Then
Suppose now that the cost of Alice's dish is owed/owes
column; and in Balkrishna's owed/owes
column
Combined with the taxi fare, Alice's owed/owes
column is owed/owes
column is
Alice and Balkrishna are running out of cash. On the taxi ride back from the restaurant to wherever they came from, suppose the fare is
- Alice pays
$x_A = 350$ ; Balkrishna pays$x_B = 100$ .
The total amount paid is
Alice owed owed/owes
column records
Now in combination with the other two transactions, see that Alice's owed/owes
column is external debts
column.
Remark. Record the above three transactions as an exercise in using the program BillSplitterForTwo
.