julien-nc / cospend-nc

💰 💲hared budget manager Nextcloud app
GNU Affero General Public License v3.0
238 stars 29 forks source link

Feature: Bill Type - Custom split by weight #20

Closed stildalf closed 2 years ago

stildalf commented 3 years ago

Great NC App!

Would be neat to have the ability to quickly split the bill amount by custom weights, defaulting to configured settings per member. The weights per member are already taken into account for "Classic, even split", I would just like to tweak the weights when capturing a bill.

julien-nc commented 3 years ago

Thanks for the compliment!

I agree it would be nice and useful. Paying an electricity bill with one member being absent half the time would become easy with this feature. His/her weight would be 0.5 for this particular bill.

What kind of use case do you have in mind?

There is a problem though... Should it replace the weight or just be complementary (and be called differently)? Using the previous example, if this member has a global weight of 2 (because it represents 2 real persons for example), shouldn't it still be considered, whatever the custom weight is? I think it's ok to still consider member's global weights in balance calculations. I guess it depends what you use weights for.

Making this a pure interface feature would be very easy: there would be a new bill creation mode pretty much looking like the "custom amounts" one: "custom weights". You would set a bill amount and then a custom weight for each ower, then the interface would take care of creating one or several bills accordingly.

A little example: member A pays 150 in electricity bill for A and B. But B only lives there half the time. B's custom weight for the bill would then be 0.5 leading to 2 bills. Total share number is 1.5. One share is 100.

What do you think?

stildalf commented 3 years ago

I think keeping it simple is sometimes more difficult than we might think... Hehehe.

My use case is for quickly splitting bills by entering the bill total and ad hoc weights, which are not affected by subsequent changes to global member weights. So the decision is made at the time of capturing that specific bill, who owes what for that bill.

Making this a pure interface feature would be very easy: there would be a new bill creation mode pretty much looking like the "custom amounts" one: "custom weights". You would set a bill amount and then a custom weight for each ower, then the interface would take care of creating one or several bills accordingly.

Your description here caters for my use case perfectly, but I think will also assist in some other scenarios of which I see there are some open issues/requests for. Let me add that I love the unit-less weight option because it can be used in so many ways:

So, for my scenario, I would not replace the global with custom weights, but rather use the globals as default values for the custom weight fields per member per bill. A future feature might be to have the ability to define category based weights per member in addition to the current project globals per member - although that will certainly add to both UI and DB complexity.

julien-nc commented 3 years ago

I just published a nightly build with a "first version" of this feature. It would be awesome if you could try it.

Here is the deal. There's a new bill creation mode called "custom share per member". If it is selected, you can then choose to "ignore members weights" or not with a checkbox. Then you set custom share numbers (the equivalent of weights but I think it's better to avoid the confusion with global weights). You get a real time overview of the owed amount while you are setting the custom shares. Then it creates one bill per member with corresponding amount.

If you ignore the global weights, only share numbers are considered, COEF = share number. If you don't, COEF = weight * share number is used. So, in both cases, the calculated amount for a member is AMOUNT * (COEF / Σ(COEF)).

but rather use the globals as default values for the custom weight fields per member per bill

Well it implies that this feature always overwrites the member's weight. What about when you want to still consider it? Like when a member is actually 2 real persons. I prefer keeping the possibility to let both values have an effect on the owed amount. As ignoring the weight is an option, it stills cover your use case.

I love the unit-less weight option because it can be used in so many ways

That's pretty neat indeed!

stildalf commented 3 years ago

Just tried v1.2.5-2-nightly locally, ran through a couple permutations, simply works as described - thank you.

Really an elegant solution, nice touch on the "Ignore member weights" option. 🥇

StCyr commented 3 years ago

This looks cool. Is there any plan to implement it at the project level?

mayonezo commented 3 years ago

I just tested the "Custom share per member" option and ran into a problem: The "How much?" field does not allow decimal point input in the "Custom share per member" option.

Feature request: It would be nice to be able to change bill types after creation. Right now I can only choose bill types for new bills. I can open a separate issue for this request, if needed.

mayonezo commented 3 years ago

I found a workaround for my problem: I can enter the places behind the decimal point when selecting other bill types and the change the bills type to "Custom share per member".

This will create 2 separate bills though. What I actually meant to do was change the weight from 1:4 to 1:1. Is there an option to change weights in bills individually?

julien-nc commented 3 years ago

@mayonezo

The "How much?" field does not allow decimal point input in the "Custom share per member" option.

It was a strange bug. I didn't really understand why it happened but I found a way to fix it. It was caused by the function which updates the per-member amounts (computed in live depending on the "how much" and the custom weights).

It would be nice if you (or anyone else) could try it. It's available in v1.3.11-5-nightly (which is only compatible with NC 22). You can easily get it with an occ command (adapt to your context):

sudo -u www-data php ./occ app:update --allow-unstable cospend

To get back to stable release, just get to the app settings, disable, delete and "download and install" the app.

Feature request: It would be nice to be able to change bill types after creation. Right now I can only choose bill types for new bills. I can open a separate issue for this request, if needed.

I'm afraid it's not possible and never will be. Having bill types is just an interface trick which can create multiple bills. In the end, a bill has just one amount and a list of owers. In the concept of bill (how it's stored behind the scene :wink:) there is no such thing as custom weights per ower or custom personal amount...

@StCyr

Is there any plan to implement it at the project level?

What do you mean?

Ezwen commented 2 years ago

It seems this feature is available in the current version? I'm asking because I was surprised to find this issue still "Open".

julien-nc commented 2 years ago

@Ezwen Right, thanks.