fixed transaction set contact on request witData ( #39nxc76 )

This commit is contained in:
Cüneyt Şentürk 2022-08-05 11:01:41 +03:00
parent deaca4c9fa
commit 7a07a7512a
5 changed files with 49 additions and 1 deletions

View File

@ -28,6 +28,18 @@ class Account extends Form
$this->accounts = $this->getAccounts(); $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'))) { if (empty($this->selected) && empty($this->getParentData('model'))) {
$this->selected = setting('default.account'); $this->selected = setting('default.account');
} }

View File

@ -33,6 +33,18 @@ class Category extends Form
$model = $this->getParentData('model'); $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)) { if (! empty($model) && ! empty($model->category_id)) {
$this->selected = $model->category_id; $this->selected = $model->category_id;

View File

@ -39,6 +39,18 @@ class Contact extends Form
$model = $this->getParentData('model'); $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)) { if (! empty($model) && ! empty($model->contact_id)) {
$this->selected = $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'); $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'))) { if (empty($this->selected) && empty($this->getParentData('model'))) {
$this->selected = setting('default.currency'); $this->selected = setting('default.currency');
} }

View File

@ -40,7 +40,7 @@ class Tax extends Form
if (! empty($tax_id)) { if (! empty($tax_id)) {
$this->selected = $tax_id; $this->selected = $tax_id;
if ($this->taxes->has($tax_id)) { if (! $this->taxes->has($tax_id)) {
$tax = Model::find($tax_id); $tax = Model::find($tax_id);
$this->taxes->put($tax->id, $tax->name); $this->taxes->put($tax->id, $tax->name);