Improve facturae invoice for individuals

This commit is contained in:
David Bomba 2023-08-06 11:30:35 +10:00
parent 45e2465a24
commit 2748df1bce
3 changed files with 45 additions and 4 deletions

View File

@ -17,9 +17,11 @@ namespace App\Models\Presenters;
class UserPresenter extends EntityPresenter
{
/**
* Returns the first and last names concatenated.
*
* @return string
*/
public function name()
public function name(): string
{
if (! $this->entity) {
return 'No User Object Available';
@ -30,8 +32,13 @@ class UserPresenter extends EntityPresenter
return $first_name.' '.$last_name;
}
public function getDisplayName()
/**
* Returns a full name (with fallback) of the user
*
* @return string
*/
public function getDisplayName(): string
{
if ($this->getFullName()) {
return $this->getFullName();
@ -43,6 +50,7 @@ class UserPresenter extends EntityPresenter
}
/**
* Returns the full name of the user
* @return string
*/
public function getFullName()
@ -53,4 +61,35 @@ class UserPresenter extends EntityPresenter
return '';
}
}
/**
* Returns the first name of the user
*
* @return string
*/
public function firstName(): string
{
if (! $this->entity) {
return 'No First Name Available';
}
return $this->entity->first_name ?? 'First Name';
}
/**
* Returns the last name of the user
*
* @return string
*/
public function lastName(): string
{
if (! $this->entity) {
return 'No Last Name Available';
}
return $this->entity->last_name ?? 'Last Name';
}
}

View File

@ -482,6 +482,8 @@ class FacturaEInvoice extends AbstractService
"fax" => "",
"website" => substr($company->settings->website, 0, 50),
"contactPeople" => substr($company->owner()->present()->name(), 0, 40),
"firstName" => $company->owner()->present()->firstName(),
"lastName" => $company->owner()->present()->lastName();
// 'centres' => $this->setFace(),
// "cnoCnae" => "04647", // Clasif. Nacional de Act. Económicas
// "ineTownCode" => "280796" // Cód. de municipio del INE

View File

@ -163,7 +163,7 @@ trait UserNotifies
* Underrated method right here, last ones
* are always the best
*
* @param CompanyUser $company_user
* @param \App\Models\CompanyUser $company_user
* @param Invoice | Quote | Credit | PurchaseOrder | Product $entity
* @param array $required_notification
*