Add source to invoice criteria. Modify invoice rules to get service fees from... #1701

Merged
arcticzero merged 217 commits from 746-resq-2-0-final into master 2023-11-22 08:54:48 +00:00
2 changed files with 16 additions and 2 deletions
Showing only changes of commit 33e6994aaa - Show all commits

View file

@ -230,7 +230,10 @@ class RiderController extends ApiController
$this->em->persist($rating);
$this->em->flush();
// TODO: set average rating in rider entity
// TODO: preliminary rating computation on the entity for now
$rider->updateRatingAverage();
$this->em->persist($rider);
$this->em->flush();
// response
return new ApiResponse();

View file

@ -81,7 +81,7 @@ class Rider
// current rating of rider
/**
* @ORM\Column(type="integer")
* @ORM\Column(type="float")
*/
protected $curr_rating;
@ -241,6 +241,17 @@ class Rider
return $this->image_file;
}
public function updateRatingAverage()
{
$total = 0;
foreach ($this->ratings as $rating) {
$total += $rating->getRating();
}
$this->setCurrentRating(round($total / $this->ratings->count(), 2));
}
public function setCurrentRating($rating)
{
$this->curr_rating = $rating;