Skip to content

Commit

Permalink
fix inserting bills with 0 amount, weird issue with db mapper
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Sep 29, 2024
1 parent 9501907 commit 135d27e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Service/LocalProjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,14 @@ public function createBill(
$newBill->setComment($comment);
}
$newBill->setTimestamp($dateTs);
$newBill->setAmount($amount);
// TODO figure out why it is problematic to insert a bill with an amount of 0
// this does not happen when inserting a currency with a 0 exchange rate
// it is apparently related with the fact that the methods accept null (even if the db column is set to NOTNULL)
if ($amount === 0.0) {
$newBill->setAmount(1);
} else {
$newBill->setAmount($amount);
}
$newBill->setPayerId($payer);
$newBill->setRepeat($repeat);
$newBill->setRepeatAllActive($repeatAllActive);
Expand All @@ -996,6 +1003,12 @@ public function createBill(

$insertedBillId = $createdBill->getId();

// TODO remove this after figuring it out
if ($amount === 0.0) {
$createdBill->setAmount(0);
$this->billMapper->update($createdBill);
}

// insert bill owers
foreach ($owerIds as $owerId) {
$billOwer = new BillOwer();
Expand Down

0 comments on commit 135d27e

Please sign in to comment.