/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $transaction = new Transaction();
     $transaction->item_name = $request->get('item_name');
     $transaction->quantity = $request->get('quantity');
     $transaction->price = $request->get('price');
     $transaction->save();
     return redirect('/transaction')->withSuccess("Transaction added {$transaction->item_name}");
 }
Пример #2
0
 public function receiveToken(Request $request)
 {
     $token = (string) $request->input('token');
     $transaction = new Transaction();
     $transaction->associated_name = $request->has('associated_name') ? $request->input('associated_name') : '';
     $transaction->contains_please = $request->has('contains_please') ? $request->input('contains_please') : 0;
     $transaction->charge(100, ['source' => $token]);
     $transaction->save();
     return response()->json(['status' => 'success']);
 }
Пример #3
0
 /**
  * Handle the event.
  *
  * @param  SubscriptionSucceeded  $event
  * @return void
  */
 public function handle(SubscriptionSucceeded $event)
 {
     // Get subscription id
     $query = Subscription::where('paymill_subscription_id', $event->subscription['id'])->first();
     $transaction = new Transaction();
     $transaction->paymill_transaction_id = $event->transaction['id'];
     $transaction->user_id = $event->userId;
     $transaction->subscription_id = $query->id;
     $transaction->amount = $event->transaction['amount'];
     $transaction->status = $event->transaction['status'];
     $transaction->response_code = $event->transaction['response_code'];
     $transaction->save();
 }
Пример #4
0
 public function getPartydue($invoiceId)
 {
     $totalPrice = 0;
     $totalAmount = 0;
     $sale = Sale::where('invoice_id', '=', $invoiceId)->first();
     $saleDetails = SAleDetail::where('invoice_id', '=', $invoiceId)->get();
     $transactions = Transaction::where('invoice_id', '=', $invoiceId)->where('payment_method', '=', 'Check')->where('type', '=', 'Receive')->where('cheque_status', '=', 1)->get();
     foreach ($saleDetails as $saleDetail) {
         $totalPrice = $totalPrice + $saleDetail->price * $saleDetail->quantity;
     }
     $totalPrice -= $sale->discount_percentage;
     foreach ($transactions as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $transactions2 = Transaction::where('invoice_id', '=', $invoiceId)->where('type', '=', 'Receive')->where('payment_method', '!=', 'Check')->get();
     foreach ($transactions2 as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $due = $totalPrice - $totalAmount;
     if ($due > 0) {
         return "Due is {$due}";
     } else {
         return 'No due';
     }
 }
Пример #5
0
 public function testRemoveInUseTag()
 {
     $tags = $this->createTags();
     $t = Transaction::create(['date' => '01/01/2016', 'name' => 'Rent', 'value' => 625]);
     $tags[0]->transactions()->save($t);
     $this->visitTagsPage()->press('Delete')->seePageIsTags()->seeInElement('ul.tags li', $tags[0]->name)->seeInElement('.alert-danger', 'Tag cannot be removed while in use');
 }
 /**
  * agreed to buy
  * @param  Request
  * @return [type]
  */
 public function postBuy(Request $request)
 {
     //MENU
     $mainMenu = Category::getParentMenu();
     $allMenu = Category::getAllMenu($mainMenu);
     //HOT PRODUCTS.
     $hotProduct = Product::hotProduct();
     //DISCOUNT PRODUCTS.
     $discountProduct = Product::discountProduct();
     if (\Session::has('giohang')) {
         $data = \Session::get('giohang');
         if ($request->get('account_number') != null) {
             $account_number = $request->get('account_number');
         } else {
             $account_number = null;
         }
         $transaction = ['customer_id' => \Auth::id(), 'ship_id' => \Session::get('ship'), 'pay_id' => \Session::get('pay'), 'amount' => \Session::get('total'), 'message' => $request->get('message'), 'security' => time(), 'account_number' => $request->get('account_number')];
         //dd($transaction);
         $transactions = Transaction::create($transaction);
         //dd($transactions->toArray());
         foreach ($data as $key => $value) {
             $order = ['transaction_id' => $transactions->id, 'product_id' => $value['id'], 'qty' => $value['qty'], 'price_order' => $value['price'], 'discount_order' => $value['discount']];
             $orders = Order::create($order);
         }
         $this->getCancel();
         return view('fornindex.shopping_succeed', compact('allMenu', 'hotProduct', 'discountProduct'));
     }
 }
Пример #7
0
 /**
  * Handle the event.
  *
  * @param  SubscriptionFailed  $event
  * @return void
  */
 public function handle(SubscriptionFailed $event)
 {
     // Stop event propagation if subscription does not exists
     if (!$event->userId) {
         return false;
     }
     // Get subscription id
     $subscriptionQuery = Subscription::where('paymill_subscription_id', $event->subscription['id'])->first();
     $transaction = new Transaction();
     $transaction->paymill_transaction_id = $event->transaction['id'];
     $transaction->subscription_id = $subscriptionQuery->id;
     $transaction->user_id = $event->userId;
     $transaction->amount = $event->transaction['amount'];
     $transaction->status = $event->transaction['status'];
     $transaction->response_code = $event->transaction['response_code'];
     $transaction->save();
 }
Пример #8
0
 /**
  * показываем список транзакций за указанную дату для текущего пользователя
  *
  * @return \Illuminate\Http\Response
  */
 public function getList($date = '')
 {
     $date = $date ?: date("Y-m-d");
     $start = \Carbon::createFromFormat("Y-m-d", $date)->startOfDay()->toDateTimeString();
     $end = \Carbon::createFromFormat("Y-m-d", $date)->endOfDay()->toDateTimeString();
     //
     return ['content' => Transaction::with('card')->where('user_id', $this->user->id)->where('created_at', '>=', $start)->where('created_at', '<=', $end)->orderBy('created_at', 'DESC')->get()];
 }
 public function markResolved($id)
 {
     $transaction = Transaction::findOrFail($id);
     $transaction->markResolved();
     $this->emailUser($transaction, "Resolved", "good");
     $this->grantMembershipIfApplicable($transaction);
     return Redirect::back()->with("good", "Successfully marked payment as resolved.");
 }
 public function update($id, $status)
 {
     if ($transaction = Transaction::find($id)) {
         $transaction->status = $status;
         $transaction->save();
     }
     // Redirect back to the checkout
     return redirect($transaction->redirect_url);
 }
Пример #11
0
 public function transaction($id)
 {
     $transaction = \App\Transaction::where('transaction_number', '=', $id)->get();
     foreach ($transaction as $trns) {
         $t_num = $trns->transaction_number;
     }
     // dd($t_num);
     return view('dashboard.admin.transaction')->with(['transaction' => $transaction, 'user' => \Auth::User(), 't_num' => $t_num]);
 }
 /**
  * @return bool
  */
 public function process()
 {
     while ($line = fgetcsv($this->csv, 1000, ';')) {
         $transaction = Transaction::firstOrNew(['statement' => $line[2], 'amount' => $this->doConvertion($line[3]), 'balance' => $this->doConvertion($line[4]), 'executed' => Carbon::createFromFormat('d-m-Y', $line[0]), 'rate' => Carbon::createFromFormat('d-m-Y', $line[1])]);
         if (!$this->account->addTransaction($transaction)) {
             return false;
         }
     }
     return true;
 }
Пример #13
0
 public function getDelete($id)
 {
     $transactions = \App\Transaction::find($id);
     if (is_null($transactions)) {
         \Session::flash('flash_message', 'Transaction not found.');
         return redirect('/transactions/' . $transactions->account_id);
     }
     $transactions->delete();
     \Session::flash('flash_message', 'Your "' . $transactions->trans_name . '" transaction was deleted.');
     return redirect('/transactions/' . $transactions->account_id);
 }
Пример #14
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function checkin($id)
 {
     $lastTransaction = Transaction::findLatest($id);
     if (!$lastTransaction->get()->isEmpty() && $lastTransaction->in_or_out == 'OUT') {
         $transaction = new Transaction();
         $transaction->in_or_out = 'IN';
         $transaction->transaction_id = $this->generateTransactionId($transaction->in_or_out);
         $transaction->due_date = NULL;
         $transaction->equipment_id = $id;
         $transaction->username = Auth::id();
         // temporary
         $transaction->person_id = $lastTransaction->person_id;
         // temporary
         $transaction->save();
         $this->generateReceiptEmail($transaction);
         return redirect()->route('inventory.index');
     } else {
         return redirect()->route('inventory.index');
     }
 }
Пример #15
0
 public function destroy($id)
 {
     $userid = Auth::id();
     $currentTransaction = Transaction::where('user_id', '=', $userid)->findOrFail($id);
     $purchasedItem = Item::where('user', $userid)->where('sku', $currentTransaction->sku)->first();
     $inventoryQuantity = $currentTransaction->quantity;
     $newQuantity = $inventoryQuantity + $purchasedItem->quantity;
     $purchasedItem->update(array('quantity' => $newQuantity));
     $currentTransaction->delete();
     return redirect('home');
 }
Пример #16
0
 public function get_money(Request $request)
 {
     if ($request->register_id == null || $request->money == null || $request->code == null) {
         return $this->responseBadRequest('Not enough parameters!');
     }
     $register_id = $request->register_id;
     $money = str_replace(array('.', ','), '', $request->money);
     $code = $request->code;
     $register = Register::find($register_id);
     if ($register->status == 1) {
         return $this->responseBadRequest('Học viên này đã đóng tiền rồi');
     }
     $register->money = $money;
     $register->paid_time = format_time_to_mysql(time());
     $register->note = $request->note;
     $register->staff_id = $this->user->id;
     $regis_by_code = Register::where('code', $code)->first();
     if ($regis_by_code != null) {
         return $this->responseBadRequest('code is already existed');
     } else {
         $register->code = $code;
         $register->status = 1;
         $register->save();
         $transaction = new Transaction();
         $transaction->money = $money;
         $transaction->sender_id = $this->user->id;
         $transaction->receiver_id = $register->id;
         $transaction->sender_money = $this->user->money;
         $transaction->note = "Học viên " . $register->user->name . " - Lớp " . $register->studyClass->name;
         $transaction->status = 1;
         $transaction->type = 1;
         $transaction->save();
         DB::insert(DB::raw("\n                insert into attendances(`register_id`,`checker_id`,class_lesson_id)\n                (select registers.id,-1,class_lesson.id\n                from class_lesson\n                join registers on registers.class_id = class_lesson.class_id\n                where registers.id = {$register->id}\n                )\n                "));
         $current_money = $this->user->money;
         $this->user->money = $current_money + $money;
         $this->user->save();
         send_mail_confirm_receive_studeny_money($register, ["*****@*****.**", "*****@*****.**"]);
     }
     $return_data = array('data' => ['money' => $register->money, 'code' => $register->code, 'paid_time' => format_date_full_option($register->paid_time)], 'message' => "success");
     return $this->respond($return_data);
 }
 public function getConfirm($tnx)
 {
     // return $tnx;
     $tnx_id = Crypt::decrypt($tnx);
     $rTw = substr($tnx_id, 0, 3);
     if ($rTw == 'r2w') {
         $confirmVar = Transaction::where('tnx_id', $tnx_id)->get();
         return view('accounts.transferConfirmation', compact('confirmVar'));
     } else {
         $confirmVar = Transaction::where('tnx_id', $tnx_id)->get();
         $forReceiver = Transaction::where('tnx_id', $tnx_id)->first()->related_id;
         $receiver = User::where('id', $forReceiver)->first()->username;
         return view('accounts.transferConfirmation', compact('confirmVar', 'receiver'));
     }
 }
 public function getComplete3($id)
 {
     $register2 = Transaction::find($id);
     $register2->cheque_status = 1;
     if ($register2->payment_method == "Check") {
         if ($register2->cheque_date == '') {
             $register2->cheque_date = date("m/d/Y", time());
         }
         $accountPayment = NameOfAccount::find($register2->account_name_id);
         $accountPayment->opening_balance = $accountPayment->opening_balance - $register2->amount;
         $accountPayment->save();
     }
     $register2->save();
     return Redirect::to('dashboard');
 }
Пример #19
0
 public function getPurchasedue($invoiceId)
 {
     $totalPrice = $this->getTotalAmount($invoiceId);
     $totalAmount = 0;
     $transactions = Transaction::where('invoice_id', '=', $invoiceId)->where('payment_method', '=', 'Check')->where('type', '=', 'Payment')->where('cheque_status', '=', 1)->get();
     foreach ($transactions as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $transactions2 = Transaction::where('invoice_id', '=', $invoiceId)->where('type', '=', 'Payment')->where('payment_method', '!=', 'Check')->get();
     foreach ($transactions2 as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $due = $totalPrice[0]->total - $totalAmount;
     return $due;
 }
Пример #20
0
 public function placeOrder($request)
 {
     $shoppingCart = $request->session()->get('cart');
     $shoppingCartItems = $request->session()->get('items');
     $user = Auth::user();
     $code = $request->input('coupon');
     $coupon = Coupon::ofCode($code);
     $transaction = Transaction::create(array('id' => md5(uniqid()), 'coupon' => is_object($coupon) ? $coupon->id : '', 'user_id' => $user->id, 'order_data' => json_encode($shoppingCartItems), 'real_charges' => $request->input('realCharges'), 'amount_off' => $request->input('amountOff')));
     ShoppingCartItem::where('shopping_cart_id', $shoppingCart->id)->delete();
     if (is_object($coupon)) {
         Coupon::where('id', $coupon->id)->update(['times_redeemed' => $coupon->times_redeemed + 1]);
     }
     $request->session()->forget('items');
     $request->session()->put('itemsCtr', 0);
 }
 protected function computeBalance($id)
 {
     $balance = 0;
     $transactions = Transaction::where('investor_id', $id)->orderBy('transactionDate', 'asc')->get();
     foreach ($transactions as $key => $value) {
         if ($value->transactionType->account_type === 'DR') {
             $balance -= $value->amount;
         } else {
             $balance += $value->amount;
         }
         $value->runningBalance = $balance;
         $value->save();
     }
     return $balance;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // get user's categories
     $categories = Category::with('transactions')->where('user_id', Auth::user()->id)->orderBy('name', 'ASC')->get();
     // get all transactions of the user
     $transactions = Transaction::where('user_id', Auth::user()->id)->get();
     // calculate total income and total expense
     $incomeTotal = $transactions->where('type', 'DEPOSIT')->sum('amount');
     $expenseTotal = $transactions->where('type', 'WITHDRAWAL')->sum('amount');
     // get uncategorized transactions
     $transactions = Transaction::where('user_id', Auth::user()->id)->whereNull('category_id')->get();
     // stuff to pass into view
     $title = "Categories";
     $heading = "Categories";
     return view('categories.index', compact('categories', 'transactions', 'incomeTotal', 'expenseTotal', 'title', 'heading'));
 }
 public function verify()
 {
     $data = \Input::all();
     $transaction = \App\Transaction::where('transaction_number', '=', $data['t_num'])->get();
     $status = \App\Status::find(1);
     foreach ($transaction as $trns) {
         $trns->verify();
         $slots = $trns->slots;
         foreach ($slots as $slot) {
             $slot->verifySlot($slot);
             $slot->rank($slot);
         }
     }
     $trns->verify();
     return redirect('valence');
 }
Пример #24
0
 /**
  * заполнение таблицы пранзакций
  */
 private function transactionsTable()
 {
     Transaction::truncate();
     $u = User::count();
     $c = Card::count();
     $i = 0;
     while ($i < 10) {
         ++$i;
         Transaction::create(['user_id' => rand(1, $u), 'card_id' => rand(1, $c), 'money' => rand(0, 1000)]);
     }
     $crd = Card::all();
     foreach ($crd as $v) {
         $v->balance = Transaction::where('card_id', $v->id)->sum('money');
         $v->save();
     }
 }
 /**
  * Responds to requests to
  */
 public function getPage($id = null)
 {
     // get the transaction
     $transaction = \App\Transaction::where('public_item_id', '=', $id)->first();
     //dump($transaction);
     $transactionArray = $transaction->public_item->toArray();
     //dump($transactionArray);
     $transactionArray["transaction_type"] = $transaction->transaction_type;
     $transactionArray["transaction_date"] = $transaction->created_at;
     $transactionArray["tax"] = $transaction->tax;
     $transactionArray["total"] = $transaction->total;
     //dump($transactionArray);
     $transactionObject = (object) $transactionArray;
     //$addedItemsArray = $addedItems->toArray();
     return view('pongo.transaction_details')->with('transaction', $transactionObject);
 }
 public function save($id, TransactionItemSaveRequest $request, ProductRepository $productRepository)
 {
     $transactionItem = $this->transactionItemRepository->getById($id);
     if ($transactionItem && Gate::denies('save', $transactionItem)) {
         return $this->json->error('You cannot alter other\'s Transactions ...');
     }
     if (!$transactionItem) {
         $transactionItem = new TransactionItem();
     }
     $product = $productRepository->getById($request->get('amazon_product_id'));
     if (!$product) {
         return $this->json->error('No Product Associated');
     }
     $transactionItem->fill($request->except(['transaction_id']));
     Transaction::find($request->get('transaction_id'))->items()->save($transactionItem);
     return $this->json->success();
 }
Пример #27
0
 public function getDashboard()
 {
     $reports = new Report();
     $totalProducts = $reports->getTotalProducts();
     $totalImports = $reports->getTotalImports();
     $totalSales = $reports->getTotalSalesToday();
     $totalPurchase = $reports->getTotalPurchaseToday();
     $accountsBalance = $reports->getAccountBalances();
     $accountBalanceTransfers = $reports->getBalanceTransferFullReport();
     $stocksBranch = $reports->getStocksBranch();
     $stockRequisitions = StockRequisition::orderBy('id', 'desc')->take(3)->get();
     $latestTransactions = Transaction::orderBy('id', 'desc')->take(5)->get();
     $register = Transaction::where('payment_method', '=', 'check')->where('type', '=', 'Receive')->where('cheque_status', '=', 0)->orderBy('id', 'desc')->get();
     $purchaseregister = Transaction::where('payment_method', '=', 'check')->where('type', '=', 'Payment')->where('cheque_status', '=', 0)->orwhere('type', '=', 'Expense')->where('cheque_status', '=', 0)->orderBy('id', 'desc')->get();
     //var_dump($stockRequisitions);
     return view('Users.dashboard')->with('latestTransactions', $latestTransactions)->with('totalProducts', $totalProducts)->with('totalSales', $totalSales)->with('stockRequisitions', $stockRequisitions)->with('stocksBranch', $stocksBranch)->with('accountsBalance', $accountsBalance)->with('accountBalanceTransfers', $accountBalanceTransfers)->with('totalPurchase', $totalPurchase)->with('totalImports', $totalImports)->with('register', $register)->with('purchaseregister', $purchaseregister);
 }
Пример #28
0
 public function process()
 {
     $transactionID = Input::get('transactionID');
     $transaction = Transaction::where('transaction_id', '=', $transactionID)->first();
     $logs = Log::where('transaction_id', '=', $transactionID)->get();
     $recentLog = Log::where('transaction_id', '=', $transactionID)->orderBy('created_at', 'desc')->first();
     if (Input::has('create')) {
         // Redirect to different route / URI
         return Redirect::route('superadmin/create_transaction')->with('transactionID', $transactionID);
         // Alternatively, you could process action 1 here
     } elseif (Input::has('update')) {
         // Process action 2
         return Redirect::route('superadmin/update_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('recentLog', $recentLog);
     } elseif (Input::has('out')) {
         // Process action 3
         return Redirect::route('superadmin/out_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('users', '')->with('recentLog', $recentLog);
     }
 }
Пример #29
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function showTransaction()
 {
     //  $transaction = Transaction::find($id);
     $id = Input::get('transaction_id');
     $pw = Input::get('password');
     //  $transaction = Transaction::find($id);
     $transaction = Transaction::where('transaction_id', '=', $id)->first();
     if ($transaction == null) {
         return Redirect::route('customer')->with('transaction', $transaction)->with('message', 'Invalid Transaction ID or Password');
     } else {
         $transpas = $transaction->password;
         if ($transpas == $pw) {
             return Redirect::route('customer')->with('transaction', $transaction)->with('message', 'Transaction found');
         } else {
             return Redirect::route('customer')->with('transaction', $transaction)->with('message', 'Invalid Transaction ID or Password');
         }
     }
 }
Пример #30
0
 public function complete(Request $request, $id)
 {
     $userid = Auth::id();
     $transaction_id = Transaction::where('user_id', $userid)->where('status', 'open')->first()->transaction_id;
     $totalValue = Transaction::where('user_id', $userid)->where('status', 'open')->sum('price');
     $tax = 0.08;
     $total = $totalValue * $tax + $totalValue;
     $change = $id;
     $notes = $request->input('notes');
     $cash_received = $change + $total;
     //store receipt
     Receipt::create(array('transaction_id' => $transaction_id, 'user_id' => $userid, 'total' => $total, 'cash_received' => $cash_received, 'change' => $change, 'notes' => $notes));
     //close transaction
     $transactionItems = Transaction::where('user_id', $userid)->where('status', 'open')->get();
     foreach ($transactionItems as $item) {
         $item->update(array('status' => 'closed'));
     }
     return redirect('home');
 }