Merge branch 'master' of https://github.com/brkcvn/akaunting into code-clean
This commit is contained in:
@ -40,11 +40,32 @@ abstract class Report
|
||||
{
|
||||
$now = Date::now();
|
||||
|
||||
$financial_start = setting('localisation.financial_start');
|
||||
$setting = explode('-', $financial_start);
|
||||
$financial_start_day = ! empty($setting[0]) ? $setting[0] : '01';
|
||||
|
||||
$format = ($financial_start == '01-01')
|
||||
? $this->getYearlyDateFormat()
|
||||
: (($financial_start_day != '01') ? $this->getDailyDateFormat() : $this->getMonthlyDateFormat());
|
||||
|
||||
$years = [];
|
||||
|
||||
$y = $now->addYears(2);
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$years[$y->year] = $y->year;
|
||||
$financial_year = $this->getFinancialYear($y->year);
|
||||
|
||||
if ($financial_start == '01-01') {
|
||||
$title = $financial_year->getStartDate()->copy()->format($format);
|
||||
} else {
|
||||
$start = $financial_year->getStartDate()->copy()->format($format);
|
||||
$end = $financial_year->getEndDate()->copy()->format($format);
|
||||
|
||||
$title = $start . ' - ' . $end;
|
||||
}
|
||||
|
||||
$years[$y->year] = $title;
|
||||
|
||||
$y->subYear();
|
||||
}
|
||||
|
||||
|
@ -281,9 +281,10 @@ abstract class Index extends Component
|
||||
|
||||
foreach ($totals as $key => $total) {
|
||||
$items[] = [
|
||||
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
|
||||
'href' => route($route, ['search' => 'status:' . $key]),
|
||||
'amount' => money($total, setting('default.currency'), true),
|
||||
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
|
||||
'href' => route($route, ['search' => 'status:' . $key]),
|
||||
'amount' => money($total, setting('default.currency'), true)->formatForHumans(),
|
||||
'tooltip' => money($total, setting('default.currency'), true)->format(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -392,12 +392,14 @@ abstract class Index extends Component
|
||||
foreach ($totals as $key => $total) {
|
||||
$title = ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key);
|
||||
$href = route($route, ['search' => 'status:' . $key]);
|
||||
$amount = money($total, setting('default.currency'), true);
|
||||
$amount = money($total, setting('default.currency'), true)->formatForHumans();
|
||||
$tooltip = money($total, setting('default.currency'), true)->format();
|
||||
|
||||
$items[] = [
|
||||
'title' => $title,
|
||||
'href' => $href,
|
||||
'amount' => $amount,
|
||||
'title' => $title,
|
||||
'href' => $href,
|
||||
'amount' => $amount,
|
||||
'tooltip' => $tooltip,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,17 @@ class Reconciliations extends Controller
|
||||
{
|
||||
$reconciliations = Reconciliation::with('account')->collect();
|
||||
|
||||
return $this->response('banking.reconciliations.index', compact('reconciliations'));
|
||||
$reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance'), setting('default.currency'), true);
|
||||
$in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'), setting('default.currency'), true);
|
||||
|
||||
$summary_amounts = [
|
||||
'amount_exact' => $reconciled_amount->format(),
|
||||
'amount_for_humans' => $reconciled_amount->formatForHumans(),
|
||||
'in_progress_exact' => $in_progress_amount->format(),
|
||||
'in_progress_for_humans' => $in_progress_amount->formatForHumans(),
|
||||
];
|
||||
|
||||
return $this->response('banking.reconciliations.index', compact('reconciliations', 'summary_amounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,12 +56,25 @@ class Transactions extends Controller
|
||||
|
||||
$totals['profit'] = $totals['income'] - $totals['expense'];
|
||||
|
||||
$incoming_amount = money($totals['income'], setting('default.currency'), true);
|
||||
$expense_amount = money($totals['expense'], setting('default.currency'), true);
|
||||
$profit_amount = money($totals['profit'], setting('default.currency'), true);
|
||||
|
||||
$summary_amounts = [
|
||||
'incoming_exact' => $incoming_amount->format(),
|
||||
'incoming_for_humans' => $incoming_amount->formatForHumans(),
|
||||
'expense_exact' => $expense_amount->format(),
|
||||
'expense_for_humans' => $expense_amount->formatForHumans(),
|
||||
'profit_exact' => $profit_amount->format(),
|
||||
'profit_for_humans' => $profit_amount->formatForHumans(),
|
||||
];
|
||||
|
||||
$translations = $this->getTranslationsForConnect('income');
|
||||
|
||||
return $this->response('banking.transactions.index', compact(
|
||||
'transactions',
|
||||
'translations',
|
||||
'totals'
|
||||
'summary_amounts'
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -45,5 +45,9 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
||||
|
||||
throw new \Exception($message);
|
||||
}
|
||||
|
||||
if ($this->model->isTransferTransaction()) {
|
||||
throw new \Exception('Unauthorized');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,13 @@ trait DateTime
|
||||
return $date_picker_shortcuts;
|
||||
}
|
||||
|
||||
public function getDailyDateFormat($year = null)
|
||||
{
|
||||
$format = 'd M Y';
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
public function getMonthlyDateFormat($year = null)
|
||||
{
|
||||
$format = 'M Y';
|
||||
|
@ -12,7 +12,7 @@ class Content extends Component
|
||||
{
|
||||
public $counts;
|
||||
|
||||
public $totals;
|
||||
public $summary_amounts;
|
||||
|
||||
public $transactions;
|
||||
|
||||
@ -72,7 +72,20 @@ class Content extends Component
|
||||
$totals['paid'] += $item->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
$this->totals = $totals;
|
||||
$open_amount = money($totals['open'], setting('default.currency'), true);
|
||||
$overdue_amount = money($totals['overdue'], setting('default.currency'), true);
|
||||
$paid_amount = money($totals['paid'], setting('default.currency'), true);
|
||||
|
||||
$summary_amounts = [
|
||||
'open_exact' => $open_amount->format(),
|
||||
'open_for_humans' => $open_amount->formatForHumans(),
|
||||
'overdue_exact' => $overdue_amount->format(),
|
||||
'overdue_for_humans' => $overdue_amount->formatForHumans(),
|
||||
'paid_exact' => $paid_amount->format(),
|
||||
'paid_for_humans' => $paid_amount->formatForHumans(),
|
||||
];
|
||||
|
||||
$this->summary_amounts = $summary_amounts;
|
||||
|
||||
$this->transactions = $this->paginate($this->transactions->sortByDesc('paid_at'));
|
||||
$this->documents = $this->paginate($this->documents->sortByDesc('issued_at'));
|
||||
|
@ -28,6 +28,18 @@ class Account extends Form
|
||||
|
||||
$this->accounts = $this->getAccounts();
|
||||
|
||||
$account_id = old('account.id', old('account_id', null));
|
||||
|
||||
if (! empty($account_id)) {
|
||||
$this->selected = $account_id;
|
||||
|
||||
if (! $this->accounts->has($account_id)) {
|
||||
$account = Model::find($account_id);
|
||||
|
||||
$this->accounts->put($account->id, $account->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->selected) && empty($this->getParentData('model'))) {
|
||||
$this->selected = setting('default.account');
|
||||
}
|
||||
|
@ -33,6 +33,18 @@ class Category extends Form
|
||||
|
||||
$model = $this->getParentData('model');
|
||||
|
||||
$category_id = old('category.id', old('category_id', null));
|
||||
|
||||
if (! empty($category_id)) {
|
||||
$this->selected = $category_id;
|
||||
|
||||
if (! $this->categories->has($category_id)) {
|
||||
$category = Model::find($category_id);
|
||||
|
||||
$this->categories->put($category->id, $category->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($model) && ! empty($model->category_id)) {
|
||||
$this->selected = $model->category_id;
|
||||
|
||||
|
@ -39,6 +39,18 @@ class Contact extends Form
|
||||
|
||||
$model = $this->getParentData('model');
|
||||
|
||||
$contact_id = old('contact.id', old('contact_id', null));
|
||||
|
||||
if (! empty($contact_id)) {
|
||||
$this->selected = $contact_id;
|
||||
|
||||
if (! $this->contacts->has($contact_id)) {
|
||||
$contact = Model::find($contact_id);
|
||||
|
||||
$this->contacts->put($contact->id, $contact->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($model) && ! empty($model->contact_id)) {
|
||||
$this->selected = $model->contact_id;
|
||||
|
||||
|
@ -35,6 +35,18 @@ class Currency extends Form
|
||||
|
||||
$this->currencies = Model::enabled()->orderBy('name')->pluck('name', 'code');
|
||||
|
||||
$currency_id = old('currency.id', old('currency_id', null));
|
||||
|
||||
if (! empty($currency_id)) {
|
||||
$this->selected = $currency_id;
|
||||
|
||||
if (! $this->currencies->has($currency_id)) {
|
||||
$currency = Model::find($currency_id);
|
||||
|
||||
$this->currencies->put($currency->id, $currency->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->selected) && empty($this->getParentData('model'))) {
|
||||
$this->selected = setting('default.currency');
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Setting\Currency as Model;
|
||||
use App\Models\Setting\Tax as Model;
|
||||
|
||||
class Tax extends Form
|
||||
{
|
||||
@ -13,7 +13,7 @@ class Tax extends Form
|
||||
|
||||
public $field;
|
||||
|
||||
public $currencies;
|
||||
public $taxes;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -23,20 +23,32 @@ class Tax extends Form
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'currency_code';
|
||||
$this->name = 'tax_id';
|
||||
}
|
||||
|
||||
$this->path = route('modals.currencies.create');
|
||||
$this->path = route('modals.taxes.create');
|
||||
|
||||
$this->field = [
|
||||
'key' => 'code',
|
||||
'key' => 'id',
|
||||
'value' => 'name'
|
||||
];
|
||||
|
||||
$this->currencies = Model::enabled()->orderBy('name')->pluck('name', 'code');
|
||||
$this->taxes = Model::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$tax_id = old('tax.id', old('tax_id', null));
|
||||
|
||||
if (! empty($tax_id)) {
|
||||
$this->selected = $tax_id;
|
||||
|
||||
if (! $this->taxes->has($tax_id)) {
|
||||
$tax = Model::find($tax_id);
|
||||
|
||||
$this->taxes->put($tax->id, $tax->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->selected)) {
|
||||
$this->selected = setting('default.currency');
|
||||
$this->selected = setting('default.tax');
|
||||
}
|
||||
|
||||
return view('components.form.group.tax');
|
||||
|
Reference in New Issue
Block a user