Exemplo n.º 1
0
 public function latestPayments()
 {
     $this->_fetchLastInvoice();
     $q = APTransaction::where('type', 'cr')->where('user_id', $this->account->id)->where('created_at', '<', $this->generated_on)->select(DB::raw('sum(amount) as amount'));
     if ($this->lastInvoice != NULL) {
         $q->where('created_at', '>', $this->lastInvoice->generated_on);
     }
     $payment = $q->first();
     $amount = $payment->amount ?: 0;
     return number_format((double) $amount, 2, '.', '');
 }
 public function postAddTransaction()
 {
     $txn = new APTransaction();
     $txn->fill(Input::all());
     if ($txn->save()) {
         $this->notifySuccess('Transaction Successful.');
     } else {
         $this->notifyError('Transaction Failed.');
     }
     return Redirect::back();
 }