Merge branch 'master' of github.com:akaunting/akaunting
This commit is contained in:
commit
5511ab9a48
@ -56,6 +56,9 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
// Store the current uri in the session
|
||||
session(['url.intended' => $request->url()]);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['error' => 'Unauthenticated.'], 401);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class Login extends Controller
|
||||
return redirect('wizard');
|
||||
}
|
||||
|
||||
return redirect('/');
|
||||
return redirect()->intended('/');
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
|
@ -112,6 +112,8 @@ class ExpenseSummary extends Controller
|
||||
$view_template = 'reports.expense_summary.index';
|
||||
}
|
||||
|
||||
$print_url = $this->getPrintUrl($year);
|
||||
|
||||
// Expenses chart
|
||||
$chart = Charts::multi('line', 'chartjs')
|
||||
->dimensions(0, 300)
|
||||
@ -121,7 +123,17 @@ class ExpenseSummary extends Controller
|
||||
->credits(false)
|
||||
->view($chart_template);
|
||||
|
||||
return view($view_template, compact('chart', 'dates', 'categories', 'statuses', 'accounts', 'vendors', 'expenses', 'totals'));
|
||||
return view($view_template, compact(
|
||||
'chart',
|
||||
'dates',
|
||||
'categories',
|
||||
'statuses',
|
||||
'accounts',
|
||||
'vendors',
|
||||
'expenses',
|
||||
'totals',
|
||||
'print_url'
|
||||
));
|
||||
}
|
||||
|
||||
private function setAmount(&$graph, &$totals, &$expenses, $items, $type, $date_field)
|
||||
@ -175,4 +187,25 @@ class ExpenseSummary extends Controller
|
||||
$totals[$month]['amount'] += $amount;
|
||||
}
|
||||
}
|
||||
|
||||
private function getPrintUrl($year)
|
||||
{
|
||||
$print_url = 'reports/expense-summary?print=1'
|
||||
. '&status=' . request('status')
|
||||
. '&year='. request('year', $year);
|
||||
|
||||
collect(request('accounts'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&accounts[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('vendors'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&vendors[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('categories'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&categories[]=' . $item;
|
||||
});
|
||||
|
||||
return $print_url;
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +153,8 @@ class IncomeExpenseSummary extends Controller
|
||||
$view_template = 'reports.income_expense_summary.index';
|
||||
}
|
||||
|
||||
$print_url = $this->getPrintUrl($year);
|
||||
|
||||
// Profit chart
|
||||
$chart = Charts::multi('line', 'chartjs')
|
||||
->dimensions(0, 300)
|
||||
@ -162,7 +164,20 @@ class IncomeExpenseSummary extends Controller
|
||||
->credits(false)
|
||||
->view($chart_template);
|
||||
|
||||
return view($view_template, compact('chart', 'dates', 'income_categories', 'expense_categories', 'categories', 'statuses', 'accounts', 'customers', 'vendors', 'compares', 'totals'));
|
||||
return view($view_template, compact(
|
||||
'chart',
|
||||
'dates',
|
||||
'income_categories',
|
||||
'expense_categories',
|
||||
'categories',
|
||||
'statuses',
|
||||
'accounts',
|
||||
'customers',
|
||||
'vendors',
|
||||
'compares',
|
||||
'totals',
|
||||
'print_url'
|
||||
));
|
||||
}
|
||||
|
||||
private function setAmount(&$graph, &$totals, &$compares, $items, $type, $date_field)
|
||||
@ -242,4 +257,29 @@ class IncomeExpenseSummary extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPrintUrl($year)
|
||||
{
|
||||
$print_url = 'reports/income-expense-summary?print=1'
|
||||
. '&status=' . request('status')
|
||||
. '&year='. request('year', $year);
|
||||
|
||||
collect(request('accounts'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&accounts[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('customers'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&customers[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('vendors'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&vendors[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('categories'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&categories[]=' . $item;
|
||||
});
|
||||
|
||||
return $print_url;
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ class IncomeSummary extends Controller
|
||||
$view_template = 'reports.income_summary.index';
|
||||
}
|
||||
|
||||
$print_url = $this->getPrintUrl($year);
|
||||
|
||||
// Incomes chart
|
||||
$chart = Charts::multi('line', 'chartjs')
|
||||
->dimensions(0, 300)
|
||||
@ -121,7 +123,17 @@ class IncomeSummary extends Controller
|
||||
->credits(false)
|
||||
->view($chart_template);
|
||||
|
||||
return view($view_template, compact('chart', 'dates', 'categories', 'statuses', 'accounts', 'customers', 'incomes', 'totals'));
|
||||
return view($view_template, compact(
|
||||
'chart',
|
||||
'dates',
|
||||
'categories',
|
||||
'statuses',
|
||||
'accounts',
|
||||
'customers',
|
||||
'incomes',
|
||||
'totals',
|
||||
'print_url'
|
||||
));
|
||||
}
|
||||
|
||||
private function setAmount(&$graph, &$totals, &$incomes, $items, $type, $date_field)
|
||||
@ -175,4 +187,25 @@ class IncomeSummary extends Controller
|
||||
$totals[$month]['amount'] += $amount;
|
||||
}
|
||||
}
|
||||
|
||||
private function getPrintUrl($year)
|
||||
{
|
||||
$print_url = 'reports/income-summary?print=1'
|
||||
. '&status=' . request('status')
|
||||
. '&year='. request('year', $year);
|
||||
|
||||
collect(request('accounts'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&accounts[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('customers'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&customers[]=' . $item;
|
||||
});
|
||||
|
||||
collect(request('categories'))->each(function($item) use(&$print_url) {
|
||||
$print_url .= '&categories[]=' . $item;
|
||||
});
|
||||
|
||||
return $print_url;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class All
|
||||
public function compose(View $view)
|
||||
{
|
||||
// Make sure it's installed
|
||||
if (!env('APP_INSTALLED')) {
|
||||
if (!env('APP_INSTALLED') && (env('APP_ENV') !== 'testing')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
@section('title', trans('reports.summary.expense'))
|
||||
|
||||
@section('new_button')
|
||||
<span class="new-button"><a href="{{ url('reports/expense-summary') }}?print=1&status={{ request('status') }}&year={{ request('year', $this_year) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
<span class="new-button"><a href="{{ url($print_url) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
@ -3,7 +3,7 @@
|
||||
@section('title', trans('reports.summary.income_expense'))
|
||||
|
||||
@section('new_button')
|
||||
<span class="new-button"><a href="{{ url('reports/income-expense-summary') }}?print=1&status={{ request('status') }}&year={{ request('year', $this_year) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
<span class="new-button"><a href="{{ url($print_url) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
@ -3,7 +3,7 @@
|
||||
@section('title', trans('reports.summary.income'))
|
||||
|
||||
@section('new_button')
|
||||
<span class="new-button"><a href="{{ url('reports/income-summary') }}?print=1&status={{ request('status') }}&year={{ request('year', $this_year) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
<span class="new-button"><a href="{{ url($print_url) }}" target="_blank" class="btn btn-success btn-sm"><span class="fa fa-print"></span> {{ trans('general.print') }}</a></span>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Banking;
|
||||
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Expense\Payment;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\Revenue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
public static function getUserTransactions($user_id, $type)
|
||||
{
|
||||
$transactions = array();
|
||||
|
||||
switch ($type) {
|
||||
case 'payments':
|
||||
$bills = Bill::where('vendor_id', $user_id)->get();
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
$bill_payments = $bill->payments;
|
||||
|
||||
if ($bill_payments) {
|
||||
foreach ($bill_payments as $bill_payment) {
|
||||
$transactions[] = (object) [
|
||||
'date' => $bill_payment->paid_at,
|
||||
'account' => $bill_payment->account->name,
|
||||
'type' => trans('invoices.status.partial'),
|
||||
'category' => trans_choice('general.invoices', 1),
|
||||
'description' => $bill_payment->description,
|
||||
'amount' => $bill_payment->amount,
|
||||
'currency_code' => $bill_payment->currency_code,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$payments = Payment::where('vendor_id', $user_id)->get();
|
||||
|
||||
foreach ($payments as $payment) {
|
||||
$transactions[] = (object) [
|
||||
'date' => $payment->paid_at,
|
||||
'account' => $payment->account->name,
|
||||
'type' => 'Expense',
|
||||
'category' => $payment->category->name,
|
||||
'description' => $payment->description,
|
||||
'amount' => $payment->amount,
|
||||
'currency_code' => $payment->currency_code,
|
||||
];
|
||||
}
|
||||
break;
|
||||
case 'revenues':
|
||||
$invoices = Invoice::where('customer_id', $user_id)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$invoice_payments = $invoice->payments;
|
||||
|
||||
if ($invoice_payments) {
|
||||
foreach ($invoice_payments as $invoice_payment) {
|
||||
$transactions[] = (object) [
|
||||
'date' => $invoice_payment->paid_at,
|
||||
'account' => $invoice_payment->account->name,
|
||||
'type' => trans('invoices.status.partial'),
|
||||
'category' => trans_choice('general.invoices', 1),
|
||||
'description' => $invoice_payment->description,
|
||||
'amount' => $invoice_payment->amount,
|
||||
'currency_code' => $invoice_payment->currency_code,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$revenues = Revenue::where('customer_id', $user_id)->get();
|
||||
|
||||
foreach ($revenues as $revenue) {
|
||||
$transactions[] = (object) [
|
||||
'date' => $revenue->paid_at,
|
||||
'account' => $revenue->account->name,
|
||||
'type' => trans_choice('general.payments', 1),
|
||||
'category' => $revenue->category->name,
|
||||
'description' => $revenue->description,
|
||||
'amount' => $revenue->amount,
|
||||
'currency_code' => $revenue->currency_code,
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user