Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/763 payments algorithms #1056

Merged
merged 64 commits into from
Nov 29, 2021
Merged

Task/763 payments algorithms #1056

merged 64 commits into from
Nov 29, 2021

Conversation

CrazedCoding
Copy link
Contributor

@CrazedCoding CrazedCoding commented Mar 16, 2021

I am preliminarily creating this PR so people can start commenting as changes are being made, in real-time.

Here is the start of the mocha tests that I am going to create for the event-based distribution approaches:

// Please note: "income"s are the user pledges if positive, OR the needed income amount ABOVE mincome if NEGATIVE.
const distributionEvents = []

// User1 creates a group at the beginning of the month of January, 2021, and then sets an income of 100 at 10% of the way throgh the monthly cycle.
distributionEvents.push(
  {
    "type": "incomeDeclaredEvent",
    "data": {
      "name": "u1",
      "income": 100,
      "cycle": 0.1
    }
  })

// User2 joins and sets income of -50 at 20% of the way through the monthly cycle.
distributionEvents.push(
  {
    "type": "incomeDeclaredEvent",
    "data": {
      "name": "u2",
      "income": -50,
      "cycle": 0.2
    }
  })

// User3 joins and sets income of -50 at 30% of the way through the monthly cycle.
distributionEvents.push(
  {
    "type": "incomeDeclaredEvent",
    "data": {
      "name": "u3",
      "income": -50,
      "cycle": 0.3
    }
  })

// User1 pays User2 10 (out of <???>) at 40% of the way through the monthly cycle.
distributionEvents.push(
  {
    "type": "paymentEvent",
    "data": {
      "from": "u1",
      "to": "u2",
      "amount": 10,
      "cycle": 0.4
    }
  })

// User4 joins and sets income of -100 at 50% of the way through the monthly cycle.
distributionEvents.push(
  {
    "type": "incomeDeclaredEvent",
    "data": {
      "name": "u4",
      "income": -100,
      "cycle": 0.5
    }
  })

// User3 removes themselves from the group at 60% of the way through the monthly cycle. TODO: This causes UI glitches/errors for other members...
distributionEvents.push(
  {
    "type": "leaveGroup",
    "data": {
      "name": "u3"
      "cycle": 0.6
    }
  })

// User1 pays User4 5 (out of <???>) at 70% of the way through the monthly cycle.
distributionEvents.push({
    "type": "paymentEvent",
    "data": {
      "from": "u1",
      "to": "u4",
      "amount": 5,
      "cycle": 0.7
    }
  })

// User3 RE-joins the group at 75% of the way through the monthly cycle, and sets their income to -100 at 80% of the way through the monthly cycle.
distributionEvents.push({
    "type": "incomeDeclaredEvent",
    "data": {
      "name": "u3",
      "income": -100,
      "cycle": 0.8
    }
  })

These scenarios are mathematically/algorithmically designed to throw a monkey-wrench into any so-called turing-complete-solution anyone comes up with. If these can't break your solution, nothing can, BUT:

PLEASE don't just answer these scenarios with: "SOME should go to u2, and MORE/LESS should go to u3"

Terms like SOME, MORE, and LESS do not help us approach an algorithmic/arithmatic/mathematical solution.

Until we all agree on the distribution outcome (for any point in time) of these scenarios for the group-consolidated-approach, I will continue to try to create a "base-line" pro-rating/time-weighted solution (so we at least have some sort of reference point).

Copy link
Contributor Author

@CrazedCoding CrazedCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done ^^

frontend/model/contracts/group.js Show resolved Hide resolved
frontend/model/contracts/group.js Show resolved Hide resolved
frontend/utils/distribution/group-income-distribution.js Outdated Show resolved Hide resolved
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work @CrazedCoding!

Think this is very close to ready to merge. The charts and graphs seem to not be broken, which is great, and during my testing I only found an extraneous console.error (see recent comment & screenshot - I recommend testing yourself in Firefox container tabs manually to catch these things).

Can you also merge master into your PR? It will just make it easier for others to test it without having to change the dependencies multiple times.

frontend/model/contracts/group.js Outdated Show resolved Hide resolved
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved!! 🎉🎉🎉🎉

@taoeffect taoeffect merged commit c76b8ae into master Nov 29, 2021
@taoeffect taoeffect deleted the task/763-payments-algorithms branch November 29, 2021 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants