diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index 4592275a490f..a11c6cc03226 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -468,11 +468,13 @@ class FacturaEInvoice extends AbstractService { $company = $this->invoice->company; + if($company->getSetting('classification')) + return $this->setIndividualSeller(); + $seller = new FacturaeParty([ - // "isLegalEntity" => $company->custom_value1, // Se asume true si se omite - "isLegalEntity" => $this->invoice->client->classification === 'individual' ? false : true, + "isLegalEntity" => true, "taxNumber" => $company->settings->vat_number, - "name" => $company->getSetting('classification') === 'individual' ? substr($company->owner()->present()->name(), 0, 40) : substr($company->present()->name(), 0, 40), + "name" => substr($company->present()->name(), 0, 40), "address" => substr($company->settings->address1, 0, 80), "postCode" => substr($this->invoice->client->postal_code, 0, 5), "town" => substr($company->settings->city, 0, 50), @@ -501,6 +503,44 @@ class FacturaEInvoice extends AbstractService return $this; } + + private function setIndividualSeller(): self + { + + $company = $this->invoice->company; + + $seller = new FacturaeParty([ + "isLegalEntity" => false, + "taxNumber" => $company->settings->vat_number, + "name" => $company->getSetting('classification') === 'individual' ? substr($company->owner()->present()->name(), 0, 40) : substr($company->present()->name(), 0, 40), + "address" => substr($company->settings->address1, 0, 80), + "postCode" => substr($this->invoice->client->postal_code, 0, 5), + "town" => substr($company->settings->city, 0, 50), + "province" => substr($company->settings->state, 0, 20), + "countryCode" => $company->country()->iso_3166_3, // Se asume España si se omite + // "book" => "0", // Libro + // "merchantRegister" => "RG", // Registro Mercantil + // "sheet" => "1", // Hoja + // "folio" => "2", // Folio + // "section" => "3", // Sección + // "volume" => "4", // Tomo + "email" => substr($company->settings->email, 0, 60), + "phone" => substr($company->settings->phone, 0, 15), + "fax" => "", + "website" => substr($company->settings->website, 0, 50), + // "contactPeople" => substr($company->owner()->present()->name(), 0, 40), + "firstSurname" => $company->owner()->present()->firstName(), + "lastSurname" => $company->owner()->present()->lastName(), + ]); + + $this->fac->setSeller($seller); + + return $this; + + + } + + private function buildBuyer(): self {