Q:

Modelling an account manager in OOP

I have this task of modelling a system where given a group of users each can keep track of their expenses.  The basic requirements are as followed:

To be able to give credit to an user. 
Find all the transactions of a given user. 
Filter out the transaction where either user is borrower or spender. 
Create a group and put users in that group and then when a group is mentioned then distribute money equally among them.[TODO]

I have tried few things but I am not convinced at all. 
const trxn = new Array();

class Transaction {
    constructor(amount, from, to) {
      this.timestamp = new Date();
      this.amount = amount;
      this.from = from;
      this.to   = to;
      trxn.push(this);
    }

    toString() {
      let dd = this.timestamp.getDate();
      let mm = this.timestamp.getMonth();
      let yy = this.timestamp.getFullYear();
      return `[Transaction: ${dd}/${mm}/${yy}] ${this.from} Gives ${this.amount} to ${this.to}`;
    }
}

class Person {
    constructor(name) {
      this.name = name;
      this._transactions = [];
    }

    transfer(amount, to) {
      let t = new Transaction(amount, this, to);
      this._transactions.push(t);
    }

    transactions() {
      return this._transactions;
    }

    toString() {
      return `${this.name.charAt(0).toUpperCase() + this.name.slice(1)}`;
    }
}

function history(transactions, user) {
  return transactions.filter((t) => {
    return t.to.name === user.name || t.from.name === user.name;
  });
}

let amy = new Person('amy');
let foo = new Person('foo');
amy.transfer(500, foo);
amy.transfer(500, foo);
foo.transfer(200, amy);

for (let t of amy.transactions()) {
  console.log('Transaction by AMY');
  console.log(t);
}

for (let f of foo.transactions()) {
  console.log('Transaction by FOO');
  console.log(f);
}

console.log('Transaction history');
console.log(history(trxn, amy));

Output of the above logic:
Transaction by AMY
[Transaction: 22/10/2016] Amy Gives 500 to Foo
Transaction by AMY
[Transaction: 22/10/2016] Amy Gives 500 to Foo
Transaction by FOO
[Transaction: 22/10/2016] Foo Gives 200 to Amy
Transaction history
[Transaction: 22/10/2016] Amy Gives 500 to Foo,
[Transaction: 22/10/2016] Amy Gives 500 to Foo,
[Transaction: 22/10/2016] Foo Gives 200 to Amy

How to approach problems like these?  I have read that just think about the business logic and not about the implementation details hence in my code there is no mention of delivery mechanism and all. 
How can I make my code more flexible and robust following the OOP practices? 

A:

This sounds like the standard bank account double book accounting problem.  Don't be fooled by all the talk of Users, the objects you are modelling are accounts and they have transactions. 
whenever you do a debit or credit you create two transactions.  ie Amy gives Beth 100 dollars
Id,AccountId,Value
1,Amy,-100
2,Beth, +100

If you like you can add an extra linking Id to provide the 'where does the money come from' info
Id,AccountId,Value,LinkId
1,Amy,-100,1
2,Beth, +100,1

