Merge branch 'master' of https://github.com/brkcvn/akaunting into code-clean

This commit is contained in:
Burak Civan
2022-08-05 14:48:35 +03:00
56 changed files with 1184 additions and 210 deletions

View File

@ -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');
}

View File

@ -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;

View File

@ -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;

View File

@ -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');
}

View File

@ -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');