Skip to content

Commit

Permalink
piccolo fix in gestione prodotti nelle prenotazioni
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Oct 13, 2024
1 parent 7496803 commit 1084232
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions code/app/Booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public function getValue($type, $with_friends, $force_recalculate = false)
}

foreach ($products as $booked) {
$booked->setRelation('booking', $obj);
$value += $booked->getValue($type);
}
}
Expand Down Expand Up @@ -384,13 +383,16 @@ public function getProductsWithFriendsAttribute()
*/
$products = new Collection();
foreach($this->products as $p) {
$p->setRelation('booking', $obj);
$products->push($p);
}

$friends = $this->friends_bookings;

foreach($friends as $sub) {
foreach($sub->products as $sub_p) {
$sub_p->setRelation('booking', $sub);

$master_p = $products->firstWhere('product_id', $sub_p->product_id);

if (is_null($master_p)) {
Expand Down Expand Up @@ -420,10 +422,6 @@ public function getProductsWithFriendsAttribute()
return $a->product->name <=> $b->product->name;
});

$products = $products->map(function($a) use ($obj) {
return $a->setRelation('booking', $obj);
});

return $products;
});
}
Expand Down
1 change: 1 addition & 0 deletions code/tests/Services/ModifiersServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ public function testWithFriend()
$mods = $booking->applyModifiers(null, true);
$this->assertEquals($mods->count(), 1);
$second_initial_amount = $booking->getValue('booked', true);
$this->assertTrue($second_initial_amount > 0);
$this->assertEquals($second_initial_amount, $initial_amount + $amount_of_friend);
$second_initial_amount = $booking->getValue('effective', true);
$this->assertEquals(round($second_initial_amount, 2), round(($initial_amount + $amount_of_friend) * 1.10, 2));
Expand Down

0 comments on commit 1084232

Please sign in to comment.