public function index()
 {
     $expenses = Expense::where('office', '=', '2')->orderBy('paid_on', 'desc')->get();
     $payments = Payment::orderBy('paid_on', 'desc')->get();
     // \Auth::user()->name; //get name of Auth user
     return view('expenses.index', compact('expenses', 'payments'));
 }
Example #2
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $expensesss = Expense::where('project_id', '=', 0)->first();
     $expensess = Expense::where('project_id', '=', 0)->orderBy('paid_on', 'desc')->get();
     $clients = Client::orderBy('created_at', 'desc')->get();
     $projects = Project::orderBy('created_at', 'desc')->get();
     $expenses = Expense::where('project_id', '>', 0)->orderBy('paid_on', 'desc')->get();
     $payments = Payment::orderBy('created_at', 'desc')->get();
     $hours = Hour::where('amount_paid', '<', 0)->orderBy('day_worked', 'desc')->get();
     return view('home', compact('projects', 'expenses', 'payments', 'hours', 'clients', 'expensess', 'expensesss'));
 }
Example #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Define first day of current month.
     $date = date('Y-m') . '-01';
     // Get all the branches.
     $branches = Branch::all();
     foreach ($branches as $branch) {
         // Try to get expense.
         $expense = Expense::where('BranchId', '=', $branch->Id)->where('Date', '=', $date)->first();
         if (!$expense) {
             $default = json_decode($branch->DefaultExpenses);
             if ($default->regimen == 'cuotafija') {
                 Expense::create(array('Date' => $date, 'BranchId' => $branch->Id, 'Electricity' => $default->electricity, 'Water' => $default->water, 'Telecommunications' => $default->phone, 'Rent' => $default->rent, 'Depreciation' => $default->depreciation, 'Security' => $default->security, 'Government' => $default->government, 'Taxes' => $default->taxes, 'Regimen' => $default->regimen, 'TaxesSettled' => 1));
             } else {
                 Expense::create(array('Date' => $date, 'BranchId' => $branch->Id, 'Electricity' => $default->electricity, 'Water' => $default->water, 'Telecommunications' => $default->phone, 'Rent' => $default->rent, 'Depreciation' => $default->depreciation, 'Security' => $default->security, 'Government' => $default->government, 'Taxes' => $default->taxes, 'Regimen' => $default->regimen, 'TaxesSettled' => 0));
             }
         }
     }
 }
 public function monthlyExpenses(Request $request, $month = null)
 {
     $months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
     $otherMonth = isset($month) && ($month > 0 && $month < 13);
     $currentMonthTrackedExpenses = TrackedExpenses::query();
     if ($otherMonth) {
         //Get a Specific Months Data
         $monthStart = Carbon::create(date('Y'), $month, 1, 0, 0, 0);
         $monthEnd = Carbon::create(date('Y'), $month, 1, 0, 0, 0)->endOfMonth();
         $currentMonthTrackedExpenses = $currentMonthTrackedExpenses->where('created_at', '>=', $monthStart)->where('created_at', '<=', $monthEnd);
         if ($month == 1) {
             $monthStart = clone $monthStart;
             $monthStart->previous()->startOfMonth();
             $monthEnd = clone $monthEnd;
             $monthEnd = $monthEnd->firstOfMonth()->previous()->endOfMonth();
         } else {
             $monthStart = $monthStart->previous()->startOfMonth();
             $monthEnd = $monthEnd->previous()->lastOfMonth();
         }
         $lastMonthData = TrackedExpenses::where('created_at', '>=', $monthStart)->where('created_at', '<=', $monthEnd)->orderBy('id', 'asc')->get()->toArray();
     } else {
         //Get current Months Data
         $currentMonthTrackedExpenses = $currentMonthTrackedExpenses->where('created_at', '>=', Carbon::now()->startOfMonth())->where('created_at', '<=', Carbon::now()->endOfMonth());
         $lastMonthData = TrackedExpenses::where('created_at', '>=', Carbon::now()->startOfMonth()->previous()->firstOfMonth())->where('created_at', '<=', Carbon::now()->startOfMonth()->previous()->lastOfMonth())->get()->toArray();
     }
     //$lastMonthData = $lastMonthData->orderBy('id','desc')->get()->toArray();
     $currentMonthTrackedExpenses = $currentMonthTrackedExpenses->orderBy('id', 'desc')->get();
     $expenses = Expense::where('active', 1)->get();
     $current = 0;
     foreach ($expenses as $expense) {
         $e[$current]['expense'] = $expense;
         $e[$current]['monthlypayed'] = $this->findExpense($expense->id, $currentMonthTrackedExpenses);
         $e[$current]['lastMonthCost'] = $this->findExpenseLastMonth($expense->id, $lastMonthData);
         $current++;
     }
     return ['month' => $otherMonth ? $months[$month - 1] : Date('F'), 'payments' => $e, 'year' => date('Y')];
 }
 private function setPurchasePayment()
 {
     $accountPayment = NameOfAccount::find(Input::get('account_name_id'));
     if ($accountPayment->opening_balance >= Input::get('amount')) {
         $expense[0] = Expense::where('invoice_id', '=', Input::get('invoice_id'))->get();
         $expenseTransaction = new Transaction();
         $expenseTransaction->branch_id = Input::get('branch_id');
         $expenseTransaction->account_category_id = Input::get('account_category_id');
         $expenseTransaction->account_name_id = Input::get('account_name_id');
         $expenseTransaction->amount = Input::get('amount');
         $expenseTransaction->remarks = Input::get('remarks');
         $expenseTransaction->type = "Expense";
         $expenseTransaction->user_id = Session::get('user_id');
         $expenseTransaction->payment_method = Input::get('payment_method');
         $expenseTransaction->invoice_id = Input::get('invoice_id');
         $expenseTransaction->cheque_no = Input::get('cheque_no');
         $expenseTransaction->save();
         $totalAmount = 0;
         $transactions = Transaction::where('invoice_id', '=', $expenseTransaction->invoice_id)->get();
         foreach ($transactions as $transaction) {
             $totalAmount = $totalAmount + $transaction->amount;
         }
         $expense = Expense::find($expense[0][0]['id']);
         if ($totalAmount == $expense->amount) {
             $expense->status = "Completed";
         } else {
             $expense->status = "Partial";
         }
         $expense->save();
         $accountPayment->opening_balance = $accountPayment->opening_balance - Input::get('amount');
         $accountPayment->save();
         Session::flash('message', 'Expense has been Successfully Cleared.');
     } else {
         Session::flash('message', 'You dont have Enough Balance');
     }
 }
Example #6
0
                                    <th>Received by</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php 
$slNo = 1;
?>
                                @foreach($purchaseregister as $reg)
                                    <?php 
if ($reg->type == 'Payment') {
    $sale = \App\PurchaseInvoice::where('invoice_id', '=', $reg->invoice_id)->first();
    $partyname = \App\Party::find($sale->party_id);
} else {
    $sale = \App\Expense::where('invoice_id', '=', $reg->invoice_id)->first();
}
$time = strtotime($reg->cheque_date);
$newformat = date('d', $time);
$today = date('d', time());
?>
                                    <tr>
                                        <td <?php 
if ($newformat >= $today - 2 && $newformat <= $today + 2) {
    echo "class='blink'";
}
?>
>{{$slNo}}</td>
                                        <td <?php 
if ($newformat >= $today - 2 && $newformat <= $today + 2) {
    echo "class='blink'";
Example #7
0
 public function expenseSave()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('electricity' => 'required', 'water' => 'required', 'phone' => 'required', 'rent' => 'required', 'government' => 'required', 'depreciation' => 'required', 'taxes' => 'required', 'security' => 'required'));
     if ($validator->fails()) {
         return response()->json(['error' => 'Es necesario escribir algo para buscar!']);
     }
     // Get Expenses of selected month.
     $expenses = Expense::where('Date', '=', Input::get('year') . '-' . Input::get('month') . '-01')->first();
     if (!$expenses) {
         $response['state'] = 'Error';
         $response['error'] = 'No se encontraron gastos registrados para este mes!';
         return response()->json($response);
     }
     // Check we are not modifying taxes from a cuotafija.
     if ($expenses->Regimen == 'cuotageneral' && Input::get('taxes') != $expenses->Taxes) {
         $response['state'] = 'Error';
         $response['error'] = 'No se permite modificar los impuestos de un mes con regimen de cuota general!';
         return response()->json($response);
     }
     $expenses->Electricity = Input::get('electricity');
     $expenses->Water = Input::get('water');
     $expenses->Telecommunications = Input::get('phone');
     $expenses->Rent = Input::get('rent');
     $expenses->Government = Input::get('government');
     $expenses->Depreciation = Input::get('depreciation');
     $expenses->Taxes = Input::get('taxes');
     $expenses->Security = Input::get('security');
     $expenses->save();
     $response['state'] = 'Success';
     $response['message'] = 'Gastos guardados exitosamente!';
     return response()->json($response);
 }
 public function getDeleteTransaction($id)
 {
     $transaction = Transaction::find($id);
     $account_id = Input::get('data');
     $accounts = NameOfAccount::find($account_id);
     $accounts->opening_balance = $accounts->opening_balance + $transaction->amount;
     $expense = Expense::where('invoice_id', '=', $transaction->invoice_id)->first();
     $accounts->save();
     $transaction->delete();
     $checkTransaction = Transaction::where('invoice_id', '=', $transaction->invoice_id)->first();
     if ($checkTransaction) {
         $expense->status = "Partial";
     } else {
         $expense->status = "Activate";
     }
     $expense->save();
     $message = array('Transaction Successfully Deleted');
     return new JsonResponse($message);
 }
Example #9
0
 public function testDeleteExpense()
 {
     $this->seedDatabase();
     $expense = Expense::where('title', 'ropa')->first();
     $this->delete('/expenses/' . $expense->id)->notSeeInDatabase('expenses', ['title' => 'ropa', 'amount' => 20], $connection = null);
 }
 public function generate($id)
 {
     ini_set("max_execution_time", 0);
     $project = Project::find($id);
     $accomplishments = Accomplishment::where('project_id', $id)->get();
     $actions = Action::where('project_id', $id)->get();
     $expenses = Expense::where('project_id', $id)->get();
     $issues = Issue::where('project_id', $id)->get();
     $milestones = Milestone::where('project_id', $id)->get();
     $risks = Risk::where('project_id', $id)->get();
     $lastUser = $project->users->last();
     return view('projects.generate', compact('project', 'actions', 'accomplishments', 'expenses', 'issues', 'milestones', 'risks', 'lastUser'));
 }