akaunting 3.0 (the last dance)
This commit is contained in:
@ -36,7 +36,7 @@ class Accounts extends Controller
|
||||
public function show(Account $account)
|
||||
{
|
||||
// Handle transactions
|
||||
$transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->collect('paid_at');
|
||||
$transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->isNotRecurring()->collect('paid_at');
|
||||
|
||||
$transfers = Transfer::with('expense_transaction', 'income_transaction')->get()->filter(function ($transfer) use($account) {
|
||||
if ($transfer->expense_account->id == $account->id || $transfer->income_account->id == $account->id) {
|
||||
@ -53,6 +53,7 @@ class Accounts extends Controller
|
||||
|
||||
return view('banking.accounts.show', compact('account', 'transactions', 'transfers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
@ -60,11 +61,9 @@ class Accounts extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
$currency = Currency::where('code', '=', setting('default.currency'))->first();
|
||||
|
||||
return view('banking.accounts.create', compact('currencies', 'currency'));
|
||||
return view('banking.accounts.create', compact('currency'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,13 +121,11 @@ class Accounts extends Controller
|
||||
*/
|
||||
public function edit(Account $account)
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
$account->default_account = ($account->id == setting('default.account')) ? 1 : 0;
|
||||
|
||||
$currency = Currency::where('code', '=', $account->currency_code)->first();
|
||||
|
||||
return view('banking.accounts.edit', compact('account', 'currencies', 'currency'));
|
||||
return view('banking.accounts.edit', compact('account', 'currency'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,18 +219,18 @@ class Accounts extends Controller
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
public function createRevenue(Account $account)
|
||||
public function createIncome(Account $account)
|
||||
{
|
||||
$data['account_id'] = $account->id;
|
||||
|
||||
return redirect()->route('revenues.create')->withInput($data);
|
||||
return redirect()->route('transactions.create', ['type' => 'income'])->withInput($data);
|
||||
}
|
||||
|
||||
public function createPayment(Account $account)
|
||||
public function createExpense(Account $account)
|
||||
{
|
||||
$data['account_id'] = $account->id;
|
||||
|
||||
return redirect()->route('payments.create')->withInput($data);
|
||||
return redirect()->route('transactions.create', ['type' => 'expense'])->withInput($data);
|
||||
}
|
||||
|
||||
public function createTransfer(Account $account)
|
||||
|
@ -11,7 +11,7 @@ use App\Jobs\Banking\UpdateReconciliation;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Reconciliation;
|
||||
use App\Models\Banking\Transaction;
|
||||
use Date;
|
||||
use App\Utilities\Date;
|
||||
|
||||
class Reconciliations extends Controller
|
||||
{
|
||||
@ -24,9 +24,7 @@ class Reconciliations extends Controller
|
||||
{
|
||||
$reconciliations = Reconciliation::with('account')->collect();
|
||||
|
||||
$accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id'));
|
||||
|
||||
return $this->response('banking.reconciliations.index', compact('reconciliations', 'accounts'));
|
||||
return $this->response('banking.reconciliations.index', compact('reconciliations'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,8 +44,6 @@ class Reconciliations extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$accounts = Account::enabled()->pluck('name', 'id');
|
||||
|
||||
$account_id = request('account_id', setting('default.account'));
|
||||
$started_at = request('started_at', Date::now()->firstOfMonth()->toDateString());
|
||||
$ended_at = request('ended_at', Date::now()->endOfMonth()->toDateString());
|
||||
@ -60,7 +56,7 @@ class Reconciliations extends Controller
|
||||
|
||||
$opening_balance = $this->getOpeningBalance($account, $started_at);
|
||||
|
||||
return view('banking.reconciliations.create', compact('accounts', 'account', 'currency', 'opening_balance', 'transactions'));
|
||||
return view('banking.reconciliations.create', compact('account', 'currency', 'opening_balance', 'transactions'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
222
app/Http/Controllers/Banking/RecurringTransactions.php
Normal file
222
app/Http/Controllers/Banking/RecurringTransactions.php
Normal file
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Banking;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Common\Recurring;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions as TransactionsTrait;
|
||||
|
||||
class RecurringTransactions extends Controller
|
||||
{
|
||||
use Currencies, DateTime, TransactionsTrait;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-banking-transactions')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-banking-transactions')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-banking-transactions')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-banking-transactions')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$transactions = Transaction::with('category', 'recurring')->isRecurring()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
return $this->response('banking.recurring_transactions.index', compact('transactions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Transaction $recurring_transaction)
|
||||
{
|
||||
$recurring_transaction->load(['category', 'recurring', 'children']);
|
||||
|
||||
$title = ($recurring_transaction->type == 'income-recurring') ? trans_choice('general.recurring_incomes', 1) : trans_choice('general.recurring_expenses', 1);
|
||||
|
||||
return view('banking.recurring_transactions.show', compact('recurring_transaction', 'title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$type = request()->get('type', 'income-recurring');
|
||||
$real_type = request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type');
|
||||
|
||||
$number = $this->getNextTransactionNumber('-recurring');
|
||||
|
||||
$account_currency_code = Account::where('id', setting('default.account'))->pluck('currency_code')->first();
|
||||
|
||||
$currency = Currency::where('code', $account_currency_code)->first();
|
||||
|
||||
return view('banking.recurring_transactions.create', compact(
|
||||
'type',
|
||||
'real_type',
|
||||
'number',
|
||||
'contact_type',
|
||||
'account_currency_code',
|
||||
'currency'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new CreateTransaction($request->merge(['paid_at' => $request->get('recurring_started_at')])));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('recurring-transactions.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$response['redirect'] = route('recurring-transactions.create');
|
||||
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param Transaction $recurring_transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function duplicate(Transaction $recurring_transaction)
|
||||
{
|
||||
$clone = $recurring_transaction->duplicate();
|
||||
|
||||
$message = trans('messages.success.duplicated', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect()->route('recurring-transactions.edit', $clone->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Transaction $recurring_transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Transaction $recurring_transaction)
|
||||
{
|
||||
$type = $recurring_transaction->type;
|
||||
$real_type = request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type');
|
||||
|
||||
$number = $this->getNextTransactionNumber('-recurring');
|
||||
|
||||
$currency = Currency::where('code', $recurring_transaction->currency_code)->first();
|
||||
|
||||
$date_format = $this->getCompanyDateFormat();
|
||||
|
||||
return view('banking.recurring_transactions.edit', compact(
|
||||
'type',
|
||||
'real_type',
|
||||
'number',
|
||||
'contact_type',
|
||||
'recurring_transaction',
|
||||
'currency',
|
||||
'date_format'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Transaction $recurring_transaction
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Transaction $recurring_transaction, Request $request)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateTransaction($recurring_transaction, $request->merge(['paid_at' => $request->get('recurring_started_at')])));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('recurring-transactions.show', $recurring_transaction->id);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$response['redirect'] = route('recurring-transactions.edit', $recurring_transaction->id);
|
||||
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* End recurring template.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function end(Transaction $recurring_transaction)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateTransaction($recurring_transaction, [
|
||||
'recurring_frequency' => $recurring_transaction->recurring->frequency,
|
||||
'recurring_interval' => $recurring_transaction->recurring->interval,
|
||||
'recurring_started_at' => $recurring_transaction->recurring->started_at,
|
||||
'recurring_limit' => $recurring_transaction->recurring->limit,
|
||||
'recurring_limit_count' => $recurring_transaction->recurring->limit_count,
|
||||
'recurring_limit_date' => $recurring_transaction->recurring->limit_date,
|
||||
'created_from' => $recurring_transaction->created_from,
|
||||
'created_by' => $recurring_transaction->created_by,
|
||||
'recurring_status' => Recurring::END_STATUS,
|
||||
]));
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.ended', ['type' => trans_choice('general.recurring_transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return redirect()->route('recurring-transactions.index');
|
||||
}
|
||||
}
|
@ -3,16 +3,31 @@
|
||||
namespace App\Http\Controllers\Banking;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Events\Banking\TransactionPrinting;
|
||||
use App\Events\Banking\TransactionSent;
|
||||
use App\Exports\Banking\Transactions as Export;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use App\Http\Requests\Banking\TransactionConnect;
|
||||
use App\Http\Requests\Common\Import as ImportRequest;
|
||||
use App\Imports\Banking\Transactions as Import;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Banking\DeleteTransaction;
|
||||
use App\Jobs\Banking\MatchBankingDocumentTransaction;
|
||||
use App\Jobs\Banking\SplitTransaction;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Notifications\Banking\Transaction as Notification;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions as TransactionsTrait;
|
||||
|
||||
class Transactions extends Controller
|
||||
{
|
||||
use Currencies, DateTime, TransactionsTrait;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -20,17 +35,115 @@ class Transactions extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->isNotRecurring()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$types = collect(['expense' => trans_choice('general.expenses', 1), 'income' => trans_choice('general.incomes', 1)])
|
||||
->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), '');
|
||||
$totals = [
|
||||
'income' => 0,
|
||||
'expense' => 0,
|
||||
'profit' => 0,
|
||||
];
|
||||
|
||||
$request_type = !request()->has('type') ? ['income', 'expense'] : request('type');
|
||||
$categories = Category::enabled()->type($request_type)->orderBy('name')->pluck('name', 'id');
|
||||
$transactions->each(function ($transaction) use (&$totals) {
|
||||
if ($transaction->isNotIncome() && $transaction->isNotExpense()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
||||
$totals[$transaction->type] += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
return $this->response('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories'));
|
||||
$totals['profit'] = $totals['income'] - $totals['expense'];
|
||||
|
||||
$translations = $this->getTranslationsForConnect('income');
|
||||
|
||||
return $this->response('banking.transactions.index', compact(
|
||||
'transactions',
|
||||
'translations',
|
||||
'totals'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Transaction $transaction)
|
||||
{
|
||||
$title = ($transaction->type == 'income') ? trans_choice('general.receipts', 1) : trans('transactions.payment_made');
|
||||
|
||||
return view('banking.transactions.show', compact('transaction', 'title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$type = request()->get('type', 'income');
|
||||
|
||||
$number = $this->getNextTransactionNumber();
|
||||
|
||||
$contact_type = config('type.transaction.' . $type . '.contact_type');
|
||||
|
||||
$account_currency_code = Account::where('id', setting('default.account'))->pluck('currency_code')->first();
|
||||
|
||||
$currency = Currency::where('code', $account_currency_code)->first();
|
||||
|
||||
return view('banking.transactions.create', compact(
|
||||
'type',
|
||||
'number',
|
||||
'contact_type',
|
||||
'account_currency_code',
|
||||
'currency'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new CreateTransaction($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('transactions.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$response['redirect'] = route('transactions.create');
|
||||
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function duplicate(Transaction $transaction)
|
||||
{
|
||||
$clone = $transaction->duplicate();
|
||||
|
||||
$message = trans('messages.success.duplicated', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect()->route('transactions.edit', $clone->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,6 +170,60 @@ class Transactions extends Controller
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Transaction $transaction)
|
||||
{
|
||||
$type = $transaction->type;
|
||||
$contact_type = config('type.transaction.' . $type . '.contact_type');
|
||||
|
||||
$currency = Currency::where('code', $transaction->currency_code)->first();
|
||||
|
||||
$date_format = $this->getCompanyDateFormat();
|
||||
|
||||
return view('banking.transactions.edit', compact(
|
||||
'type',
|
||||
'contact_type',
|
||||
'transaction',
|
||||
'currency',
|
||||
'date_format'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Transaction $transaction, Request $request)
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateTransaction($transaction, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('transactions.show', $transaction->id);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$response['redirect'] = route('transactions.edit', $transaction->id);
|
||||
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
@ -92,4 +259,100 @@ class Transactions extends Controller
|
||||
{
|
||||
return $this->exportExcel(new Export, trans_choice('general.transactions', 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of transaction.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function emailTransaction(Transaction $transaction)
|
||||
{
|
||||
if (empty($transaction->contact->email)) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Notify the customer/vendor
|
||||
$transaction->contact->notify(new Notification($transaction, config('type.transaction.' . $transaction->type . '.email_template'), true));
|
||||
|
||||
event(new TransactionSent($transaction));
|
||||
|
||||
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.transactions', 1)]))->success();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the transaction.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printTransaction(Transaction $transaction)
|
||||
{
|
||||
event(new TransactionPrinting($transaction));
|
||||
|
||||
$view = view('banking.transactions.print_default', compact('transaction'));
|
||||
|
||||
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of transaction.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfTransaction(Transaction $transaction)
|
||||
{
|
||||
event(new TransactionPrinting($transaction));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$view = view('banking.transactions.print_default', compact('transaction', 'currency_style'))->render();
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$file_name = $this->getTransactionFileName($transaction);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
||||
public function connect(Transaction $transaction, TransactionConnect $request)
|
||||
{
|
||||
$total_items = count($request->data['items']);
|
||||
|
||||
if ($total_items == 1) {
|
||||
$document = Document::find($request->data['items'][0]['document_id']);
|
||||
|
||||
if (!is_null($document)) {
|
||||
$response = $this->ajaxDispatch(new MatchBankingDocumentTransaction($document, $transaction));
|
||||
}
|
||||
}
|
||||
|
||||
if ($total_items > 1) {
|
||||
$response = $this->ajaxDispatch(new SplitTransaction($transaction, $request->data));
|
||||
}
|
||||
|
||||
$response['redirect'] = route('transactions.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.connected', ['type' => trans_choice('general.transactions', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ use App\Jobs\Banking\DeleteTransfer;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transfer;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Utilities\Modules;
|
||||
use Date;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Transfers extends Controller
|
||||
@ -52,13 +50,9 @@ class Transfers extends Controller
|
||||
{
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
|
||||
$file_types = $this->prepeareFileTypes();
|
||||
|
||||
return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currency', 'file_types'));
|
||||
return view('banking.transfers.create', compact('accounts', 'currency'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,15 +136,11 @@ class Transfers extends Controller
|
||||
{
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
$currency_code = ($transfer->expense_transaction->account) ? $transfer->expense_transaction->account->currency_code : setting('default.currency');
|
||||
|
||||
$account = $transfer->expense_transaction->account;
|
||||
$currency = Currency::where('code', $currency_code)->first();
|
||||
|
||||
$currency = Currency::where('code', $account->currency_code)->first();
|
||||
|
||||
$file_types = $this->prepeareFileTypes();
|
||||
|
||||
return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currency', 'file_types'));
|
||||
return view('banking.transfers.edit', compact('transfer', 'accounts', 'currency'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -259,19 +249,4 @@ class Transfers extends Controller
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
||||
protected function prepeareFileTypes()
|
||||
{
|
||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
||||
|
||||
$file_types = [];
|
||||
|
||||
foreach ($file_type_mimes as $mime) {
|
||||
$file_types[] = '.' . $mime;
|
||||
}
|
||||
|
||||
$file_types = implode(',', $file_types);
|
||||
|
||||
return $file_types;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user