-
Notifications
You must be signed in to change notification settings - Fork 32
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
Bug? | Future bills already affect current balance #310
Comments
Had this annoyance for a long time, just didn't bother to file a ticket. I guess it could be a checkbox or flip switch to choose whether to exclude future bills from the balance. |
I think this is related to #261. Not sure which one is the cause though. But I have the impression, that the handling of repeated bills is weird. A repeat from a repeated bill is not created on the day of the next due date, but one day later. But to account this next repeated bill already in today‘s balance, the balance needs to also account the repeated bill. And because of the latter, it also accounts for any future bill in today‘s balance. |
Signed-off-by: Julien Veyssier <[email protected]>
@julien-nc thanks. I mentioned that its also not comprehensible for me, why repeated bills are not repeated on the day of the next repeat date. While applying your fix for this issue to my local 1.6.1 installation, I also poked around in the
But no bill for today was created. What could prevent this from working? |
Got it. Here is patch which is in line with my understanding of repeating bills. It uses the current bill‘s date for the check, not the next date. diff -urp cospend-nc-1.6.2-fix/lib/Service/ProjectService.php cospend-nc-1.6.2-fix2/lib/Service/ProjectService.php
--- cospend-nc-1.6.2-fix/lib/Service/ProjectService.php 2024-10-28 20:56:33.802921527 +0100
+++ cospend-nc-1.6.2-fix2/lib/Service/ProjectService.php 2024-10-28 23:47:07.433359910 +0100
@@ -2518,8 +2518,8 @@ class ProjectService {
// Repeat if $nextDate is in the past (or today)
$nowTs = $now->getTimestamp();
- $nextDateTs = $nextDate->getTimestamp();
- if ($nowTs > $nextDateTs || $nextDate->format('Y-m-d') === $now->format('Y-m-d')) {
+ $billDateTs = $billDate->getTimestamp();
+ if ($nowTs > $billDateTs || $billDate->format('Y-m-d') === $now->format('Y-m-d')) {
$newBillId = $this->repeatBill($bill['projectid'], $bill['id'], $nextDate);
// bill was not repeated (because of disabled owers or repeatuntil)
if ($newBillId === null) {
diff -urp cospend-nc-1.6.2-fix/lib/Command/RepeatBills.php cospend-nc-1.6.2-fix2/lib/Command/RepeatBills.php
--- cospend-nc-1.6.2-fix/lib/Command/RepeatBills.php 2024-10-15 22:16:01.792586243 +0200
+++ cospend-nc-1.6.2-fix2/lib/Command/RepeatBills.php 2024-10-29 00:22:03.562504986 +0100
@@ -33,7 +33,7 @@ class RepeatBills extends Base {
foreach ($repeated as $r) {
$output->writeln(
'[Project "'.$r['project_name'].'"] Bill "'.$r['what'].
- '" ('.$r['date_orig'].') repeated on ('.$r['date_repeat'].')'
+ '" ('.$r['date_orig'].') repeated, next repeat on ('.$r['date_repeat'].')'
);
}
return 0; For me, that makes it possible to use "approximation" for repeating bills and adjust the value to the actual value already for the current bill. To be more specific:
Without the above patch/understand, I would need to wait until the first of the next month to adjust the bill for this current month (then past month). Hope that makes my understanding clear. |
Btw, the balance in the project settlements with no date still accounts future bills |
Possible change: diff -urp cospend-nc-1.6.2-fix/lib/Service/ProjectService.php cospend-nc-1.6.2-fix2/lib/Service/ProjectService.php
--- cospend-nc-1.6.2-fix/lib/Service/ProjectService.php 2024-10-28 20:56:33.802921527 +0100
+++ cospend-nc-1.6.2-fix2/lib/Service/ProjectService.php 2024-10-29 07:39:16.993083990 +0100
@@ -1104,6 +1104,9 @@ class ProjectService {
* @return array
*/
public function getProjectSettlement(string $projectId, ?int $centeredOn = null, ?int $maxTimestamp = null): array {
+ if ($maxTimestamp === null) {
+ $maxTimestamp = time();
+ }
$balances = $this->getBalance($projectId, $maxTimestamp);
if ($centeredOn === null) {
$transactions = $this->settle($balances); |
Could it be that MoneyBuster also needs these changes? I see already a non-zero balance if I only have future repeating bills. This does not make sense to me, the server should be the only authoritative source for the current balance. |
@bertwesarg I'm not sure it's a good thing to change how the settlement is computed because there is an optional "settlement date" that can be set in the UI. This is enough IMO. If no date is set, the project is "completely" settled, considering all the bills. About the balance calculation, there is now an admin settings to choose if only past bills should be considered or all bills. This setting applies to all projects. It is disabled by default (use all bills). This will be included in the next release which is coming soon. About the bill repetition, can you create another issue? I think this is unrelated. Thanks for your patience and perseverance. |
Cospend 1.6.1
A future bill already affects the balance from today.
u1
andu2
u1
u1
and -500 foru2
This makes it rather complicated to jump start a new project where there are already known repeating bills over the year. With this behavior in place, I would need to wait creating these bills after the first due date, and it still is not clear, if not the next due date already affects the current balance.
The text was updated successfully, but these errors were encountered: