Skip to content

Commit

Permalink
refs #201 fix bill repetition bug producing way too many bills
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed May 14, 2023
1 parent ab67d3a commit 4c5959e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Service/ProjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ private function getBillFromRow(array $row): array {
'id' => $dbBillId,
'amount' => $dbAmount,
'what' => $dbWhat,
'comment' => $dbComment,
'comment' => $dbComment ?? '',
'timestamp' => $dbTimestamp,
'date' => $dbDate->format('Y-m-d'),
'payer_id' => $dbPayerId,
Expand Down Expand Up @@ -3523,8 +3523,9 @@ public function cronRepeatBills(?int $billId = null): array {
}

// Repeat if $nextDate is in the past (or today)
$diff = $now->diff($nextDate);
if ($nextDate->format('Y-m-d') === $now->format('Y-m-d') || $diff->invert) {
$nowTs = $now->getTimestamp();
$nextDateTs = $nextDate->getTimestamp();
if ($nowTs > $nextDateTs || $nextDate->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) {
Expand Down

0 comments on commit 4c5959e

Please sign in to comment.