TL;DR

Resuming an old module to do some accounting.

I have a system with my wife where we split most expenses that we do together. It was born to split things fairly - i.e. to avoid that any of us could have the feeling of not contributing enough. I know, I know.

Anyway, I modeled the whole thing as a ledger where the total sum of things isâ€¦ zero. There are a few accounts that can contain, give or receive resources (well, money!) and all operations are about moving a quantity X from account A to account B, possibly with a reason.

I keep four accounts:

• one for my wife (Foo) and one for me (Bar);
• one modeling us as a single entity (Common);
• one modeling the external world (External).

Something happening in the real world has its counterpart in this accounting system. A few examples:

• getting 100 â‚¬ in our shared account in the bank, e.g. a gift from someone, means transferring 100 â‚¬ from External to Common. Hence, External becomes poorer by 100 â‚¬, and itâ€™s right: this money is now in our Common assets;
• splitting those 100 â‚¬ in half means two operations:
• moving 50 â‚¬ from Common to Foo
• moving 50 â‚¬ from Common to Bar

Net result is that Common is back to 0 â‚¬, External is poorer by 100 â‚¬ and both of us are richer by 50 â‚¬.

• paying a bill of 200 â‚¬ is a transfer from Common to External, creating a void of 200 â‚¬ in Common (i.e. it is now at -200 â‚¬);
• splitting the bill among us means doing two transfers, which depend on how we split. E.g. if I pay 60% of that bill, it means the following two transactions:
• moving 80 â‚¬ from Foo to Common
• moving 120 â‚¬ from Bar to Common.

Again, the Common part goes back to 0 â‚¬, which means that each euro has been attributed to either of us.

The interesting thing with this is that our common bank account (but it might just as well be a pocket containing shared money) is always represented by the External account with the changed sign: a negative value for External means that there is actual money in the pocket, while a positive value means that we owe the external world money.

I started implementing a Perl module to capture this, and later forgot about it. As I resumed the idea, I see that the implementation was (is?) quite complete, also including a lot of tests.

So I hope Iâ€™ll resume this project in a proper way, and release to CPAN as soon as possible.

Stay safe folks!