/**
  * A subscription charge has been marked as processing
  *
  * @param integer $chargeId
  * @param integer $userId
  * @param Carbon  $paymentDate
  * @param double  $amount
  */
 public function onProcessing($chargeId, $userId, Carbon $paymentDate, $amount)
 {
     $user = $this->userRepository->getById($userId);
     /** @var $user \BB\Entities\User */
     $user->extendMembership(null, $paymentDate->addMonth());
 }
Example #2
0
 public function addInterval(Carbon $date)
 {
     switch ($this->interval) {
         case 'yearly':
             $date->addYear();
             break;
         case 'quarterly':
             $date->addMonths(3);
             break;
         case 'weekly':
             $date->addWeek();
             break;
         case 'monthly':
         default:
             $date->addMonth();
     }
     return $date;
 }
 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     $income = '0';
     $expense = '0';
     $count = 0;
     while ($start < $end) {
         $date = $start->format('Y-m');
         $currentIncome = isset($earned[$date]) ? $earned[$date] : 0;
         $currentExpense = isset($spent[$date]) ? $spent[$date] : 0;
         $income = bcadd($income, $currentIncome);
         $expense = bcadd($expense, $currentExpense);
         $count++;
         $start->addMonth();
     }
     $data = $this->generator->yearInOutSummarized($income, $expense, $count);
     return $data;
 }
 /**
  * @param Carbon $current
  * @param Carbon $end
  *
  * @return array
  */
 private function createYearHeaders(Carbon $current, Carbon $end) : array
 {
     $headers = [];
     while ($current < $end) {
         $short = $current->format('m-Y');
         $headers[$short] = $current->formatLocalized((string) trans('config.month'));
         $current->addMonth();
     }
     return $headers;
 }
 public function show($id)
 {
     $success = true;
     $message = "La actualizacion se realizo correctamente";
     $clients = $this->clienteHostRepo->findByField2('id_host', $id);
     $transacciones = $this->transaccionRepo->getAll();
     $transaccionHost = [];
     $cajeroTransaccion = [];
     foreach ($transacciones as $key => $value) {
         $transaccionHost[$key] = $value->id;
     }
     foreach ($clients as $key => $value) {
         $cajeroTransaccion[$key] = $value->id_transaccion;
     }
     $prueba = 0;
     for ($i = 0; $i < count($transaccionHost); $i++) {
         $contador = 0;
         if (count($cajeroTransaccion) != 0) {
             for ($x = 0; $x < count($cajeroTransaccion); $x++) {
                 if ($transaccionHost[$i] == $cajeroTransaccion[$x]) {
                     $contador++;
                 }
             }
         }
         if ($contador == 0) {
             $transaccionData = $this->transaccionRepo->findOrFail($transaccionHost[$i]);
             $creditoData = $this->creditoRepo->findOrFail($transaccionData->idCredito);
             if ($transaccionData->tipoTransaccion == 'credito') {
                 $datos['id_host'] = $id;
                 $datos['id_cliente'] = $creditoData->idCliente;
                 $datos['saldo'] = $transaccionData->monto;
                 $datos['interes'] = $creditoData->interes;
                 $datos['id_credito'] = $transaccionData->idCredito;
                 $datos['id_transaccion'] = $transaccionData->id;
                 $datos['tipo_transaccion'] = $transaccionData->tipoTransaccion;
                 $registro = $this->clienteHostRepo->create($datos);
                 $cuota = $this->cuotaRepo->findByField('idCredito', $creditoData->id);
                 $fecha = new Carbon($cuota->fechaPago);
                 for ($i = 1; $i <= $creditoData->no_cuotas; $i++) {
                     $dataCuota['id_clienteHost'] = $registro->id;
                     $dataCuota['montoCuota'] = $cuota->montoCuota;
                     $dataCuota['fechaPago'] = $fecha->addMonth();
                     $dataCuota['estado'] = 'activa';
                     $dataCuota['balance'] = $cuota->montoCuota;
                     $this->cuotasHostRepo->create($dataCuota);
                 }
             } else {
                 $bitacoraBranch = $this->bitacoraRepo->findByField('idTransaccionMaster', $transaccionData->id);
                 $prueba = $bitacoraBranch['id_cuota_branch'];
                 $idCreditoBranch = $bitacoraBranch['id_credito_branch'];
                 $idCuotaBranch = $bitacoraBranch['id_cuota_branch'];
                 $creditoBranch = $this->clienteHostRepo->findOrFail($idCreditoBranch);
                 $creditoBranch['saldo'] = $creditoBranch['saldo'] - $transaccionData['monto'];
                 $creditoBranch->save();
                 $cuotaBranch = $this->cuotasHostRepo->findOrFail($idCuotaBranch);
                 $cuotaBranch = $this->cuotasHostRepo->findOrFail($idCuotaBranch);
                 $cuotaBranch['estado'] = 'Cancelada';
                 $cuotaBranch['balance'] = 0.0;
                 $cuotaBranch->save();
             }
         }
     }
     return compact('success', 'message');
 }
Example #6
-1
 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function singleYearInOut(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     // per month? simply use each month.
     $entries = new Collection();
     while ($start < $end) {
         // total income and total expenses:
         $date = $start->format('Y-m');
         $incomeSum = isset($earned[$date]) ? $earned[$date] : 0;
         $expenseSum = isset($spent[$date]) ? $spent[$date] * -1 : 0;
         $entries->push([clone $start, $incomeSum, $expenseSum]);
         $start->addMonth();
     }
     $data = $this->generator->yearInOut($entries);
     return $data;
 }