Fixes for Facturae 3.2.2

This commit is contained in:
David Bomba 2023-09-26 12:58:06 +10:00
parent aa5f00cd33
commit 31b8709a89

View File

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