Example #1
0
 /**
  * @param Client $client
  * @param Money  $amount
  *
  * @return \CSBill\ClientBundle\Entity\Credit
  */
 public function deductCredit(Client $client, Money $amount)
 {
     $credit = $client->getCredit();
     $credit->setValue($credit->getValue()->subtract($amount));
     return $this->save($credit);
 }
Example #2
0
 /**
  * @param Client $client
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function getCreditAction(Client $client)
 {
     $credit = $client->getCredit();
     return $this->json(['credit' => $this->get('csbill.money.formatter')->toFloat($credit->getValue()), 'id' => $credit->getId()]);
 }