close #2260 Fixed: Categories in New Payment window initially shown by id instead of name.

This commit is contained in:
Cüneyt Şentürk
2021-10-06 15:24:12 +03:00
parent 3738c64430
commit 11346d899f
3 changed files with 11 additions and 3 deletions

View File

@ -285,7 +285,7 @@ abstract class DocumentForm extends Base
/** Content Component End */
/** Metadata Component Start */
$this->contacts = $this->getContacts($type, $contacts);
$this->contacts = $this->getContacts($type, $document, $contacts);
$this->contact = $this->getContact($contact, $document);
$this->contactType = $this->getContactType($type, $contactType);
@ -442,7 +442,7 @@ abstract class DocumentForm extends Base
return 'general.recurring_and_more';
}
protected function getContacts($type, $contacts)
protected function getContacts($type, $document, $contacts)
{
if (!empty($contacts)) {
return $contacts;
@ -456,6 +456,10 @@ abstract class DocumentForm extends Base
$contacts = Contact::enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
}
if (!empty($document) && ($document->contact && !$contacts->has($document->contact_id))) {
$contacts->put($document->contact->id, $document->contact->name);
}
return $contacts;
}