jelly-fin icon indicating copy to clipboard operation
jelly-fin copied to clipboard

Transaction CRUD

Open jonathan-irvin opened this issue 5 years ago • 17 comments

Ability to Create, Read, Update, and Delete Transactions.

jonathan-irvin avatar Aug 28 '18 19:08 jonathan-irvin

Example Transaction Object:

screen shot 2018-08-30 at 3 06 27 pm

jonathan-irvin avatar Aug 30 '18 20:08 jonathan-irvin

Does the transaction object need to hold information about the user who initially created it?

ajroberts0417 avatar Sep 07 '18 17:09 ajroberts0417

Yes and no. Yes, we need to associate transactions with users, but I don't think we need to specify that in the transaction object.

What we could do is in the transaction collection, have a top-level entry for users and then input transactions for each user there.

{
    user: "random_user_string_here",
    transactions: {
        {...},
    }
}

But, in the future, I'd also like to handle multiple accounts. For alpha, we can just focus on handling one account for now.

jonathan-irvin avatar Sep 07 '18 17:09 jonathan-irvin

What's your proposal?

jonathan-irvin avatar Sep 07 '18 17:09 jonathan-irvin

At first I thought of: What if we simply create a 'transactions' collection inside the user's document?

But your idea of handling multiple accounts came to my mind too, because that would be a great feature for families, so, in that case, creating a collection inside the user would be a mess because later when we want to handle multiple users we would have to add the same transaction inside the two users. So, what we could do is like create a transactions collection and there add the reference to the user(s) it belongs to.

Or, when we handle multiple users, we can create like "Teams" and there we save their transactions and those stuff.

I'm still not sure about how our approach to that should be so I'm just giving ideas.

emmanuelvr avatar Sep 07 '18 20:09 emmanuelvr

Just thought of something else. People usually share finances, so maybe we would have one account with multiple users?

jonathan-irvin avatar Sep 07 '18 20:09 jonathan-irvin

My proposal is that the model for Users & Transactions are many-to-one related.

EDIT: I disagree with myself. Users can have any number of transactions, and transactions have a user (the one who performed the transaction).

Is there any reason not to do this? The extra infrastructure doesn't seem very costly.

ajroberts0417 avatar Sep 07 '18 20:09 ajroberts0417

Have a collection of accounts, which has a list of transactions.

Then users have a list of accounts. 2 users can have the same account.

jonathan-irvin avatar Sep 07 '18 20:09 jonathan-irvin

Yes, this is a feasible way to implement sharing, I can use my login credentials to access any number of accounts that have been shared with me.

ajroberts0417 avatar Sep 07 '18 20:09 ajroberts0417

So we restructure everything:

Users Have:

  • User ID (unique)
  • Username, password, email
  • Other optional personal information if we choose to collect it (first name, last name, etc.)
  • Account IDs (MANY)

Accounts Have:

  • Account ID (unique)
  • Original User ID (this is the master user who initially created the account) (ONE)
  • Shared User IDs (MANY)
  • Transaction IDs (MANY)
  • ???

Transactions Have:

  • Transaction ID (unique)
  • Account associated (ONE??)
  • Transaction info (as written in the original issue)

ajroberts0417 avatar Sep 07 '18 20:09 ajroberts0417

One thing to add,

Payment method is a 2 character string Here are the definitions of each:

ad = auto draft po = pay online bp = bill-pay in = income xf = transfer

We can add more as time goes on, but that's the basis for that field.

jonathan-irvin avatar Sep 07 '18 20:09 jonathan-irvin

We might think of more, I just did.

aj = adjustment cx = cryptocurrency

jonathan-irvin avatar Sep 07 '18 21:09 jonathan-irvin

Amount will obviously be stored as a float. It's probably easier to do positive and negative numbers as that makes it easy to sum.

jonathan-irvin avatar Sep 07 '18 21:09 jonathan-irvin

Accounts Have:

Account ID (unique)

Great idea on 2 users. Shared users could be an array.

Original User ID (this is the master user who initially created the account) (ONE)
Shared User IDs (MANY)
Transaction IDs (MANY)
???

Transactions Have:

Transaction ID (unique)

Yes, I think one is sufficient. Keep in mind, if we do a transfer, we need to have 2 transactions.

Account associated (ONE??)
Transaction info (as written in the original issue)

jonathan-irvin avatar Sep 07 '18 21:09 jonathan-irvin

We'll need to store an initial balance somewhere. I was thinking it's easiest to create an "init" transaction for this.

jonathan-irvin avatar Sep 07 '18 21:09 jonathan-irvin

@ajroberts0417 have you been able to get the dev environment up?

jonathan-irvin avatar Sep 14 '18 19:09 jonathan-irvin

This issue was moved to jelly-fin/jelly-fin-web#12

jonathan-irvin avatar Sep 29 '18 17:09 jonathan-irvin