Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Base/AjaxForms/SalesHeaderHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ private static function renderField(Translator $i18n, SalesDocument $model, stri
return self::codtrans($i18n, $model);

case 'direccion':
return self::addressField($i18n, $model, 'direccion', 'address', 6, 100);
return self::addressField($i18n, $model, 'direccion', 'address', 6, 200);

case 'fecha':
return self::fecha($i18n, $model);
Expand Down
2 changes: 1 addition & 1 deletion Core/Lib/AjaxForms/SalesHeaderHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ private static function renderField(SalesDocument $model, string $field): ?strin
return self::codtrans($model);

case 'direccion':
return self::addressField($model, 'direccion', 'address', 6, 100);
return self::addressField($model, 'direccion', 'address', 6, 200);

case 'fecha':
return self::fecha($model);
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/albaranescli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>dtopor1</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/almacenes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>idempresa</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/contactos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>email</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/empresas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>excepcioniva</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/facturascli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>dtopor1</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/pedidoscli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>dtopor1</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/Table/presupuestoscli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</column>
<column>
<name>direccion</name>
<type>character varying(100)</type>
<type>character varying(200)</type>
</column>
<column>
<name>dtopor1</name>
Expand Down
2 changes: 1 addition & 1 deletion Core/View/Wizard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<div class="col-sm-6">
<div class="mb-3">
{{ forms.simpleInput('direccion', 'direccion', fsc.empresa.direccion, 'text', trans('address'),
'fa-solid fa-map-marked', {'maxlength': '100'}) }}
'fa-solid fa-map-marked', {'maxlength': '200'}) }}
</div>
</div>
<div class="col-sm-3">
Expand Down
2 changes: 1 addition & 1 deletion Core/XMLView/EditAlmacen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<widget type="text" fieldname="nombre" maxlength="100" required="true"/>
</column>
<column name="address" numcolumns="6" order="120">
<widget type="text" fieldname="direccion" maxlength="100" icon="fa-solid fa-map-marked"/>
<widget type="text" fieldname="direccion" maxlength="200" icon="fa-solid fa-map-marked"/>
</column>
<column name="phone" numcolumns="2" order="130">
<widget type="text" fieldname="telefono" maxlength="30" icon="fa-solid fa-phone"/>
Expand Down
2 changes: 1 addition & 1 deletion Core/XMLView/EditContacto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</group>
<group name="address" title="address" numcolumns="12">
<column name="address" numcolumns="8" order="100">
<widget type="text" fieldname="direccion" maxlength="100" icon="fa-solid fa-map-marked"/>
<widget type="text" fieldname="direccion" maxlength="200" icon="fa-solid fa-map-marked"/>
</column>
<column name="post-office-box" numcolumns="2" order="110">
<widget type="text" fieldname="apartado" maxlength="10"/>
Expand Down
2 changes: 1 addition & 1 deletion Core/XMLView/EditDireccionContacto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<widget type="text" fieldname="descripcion"/>
</column>
<column name="address" numcolumns="9" order="130">
<widget type="text" fieldname="direccion" maxlength="100" icon="fa-solid fa-map-marked"/>
<widget type="text" fieldname="direccion" maxlength="200" icon="fa-solid fa-map-marked"/>
</column>
<column name="post-office-box" order="140">
<widget type="text" fieldname="apartado" maxlength="10"/>
Expand Down
2 changes: 1 addition & 1 deletion Core/XMLView/EditEmpresa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</group>
<group name="address" numcolumns="12">
<column name="address" numcolumns="10" order="100">
<widget type="text" fieldname="direccion" maxlength="100" icon="fa-solid fa-map-marked" required="true"/>
<widget type="text" fieldname="direccion" maxlength="200" icon="fa-solid fa-map-marked" required="true"/>
</column>
<column name="post-office-box" numcolumns="2" order="110">
<widget type="text" fieldname="apartado" maxlength="10"/>
Expand Down
42 changes: 42 additions & 0 deletions Test/Core/Model/AlbaranClienteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use FacturaScripts\Core\Model\Almacen;
use FacturaScripts\Core\Model\Empresa;
use FacturaScripts\Core\Model\Stock;
use FacturaScripts\Core\Tools;
use FacturaScripts\Test\Traits\DefaultSettingsTrait;
use FacturaScripts\Test\Traits\LogErrorsTrait;
use FacturaScripts\Test\Traits\RandomDataTrait;
Expand Down Expand Up @@ -274,6 +275,47 @@ public function testCreateProductLine(): void
$this->assertTrue($product->delete(), 'can-not-delete-product-3');
}

public function testPropertiesLength(): void
{
// creamos un cliente
$subject = $this->getRandomCustomer();
$this->assertTrue($subject->save(), 'can-not-save-customer-1');


// Definir los campos a validar: campo => [longitud_máxima, longitud_invalida]
$campos = [
'apartado' => [10, 11],
'cifnif' => [30, 31],
'ciudad' => [100, 101],
'codpais' => [20, 21],
'codpostal' => [10, 11],
'direccion' => [200, 201],
'nombrecliente' => [100, 101],
'provincia' => [100, 101],
];

foreach ($campos as $campo => [$valido, $invalido]) {
// Creamos un nuevo albarán
$doc = new AlbaranCliente();
$doc->setSubject($subject);

// Asignamos el valor inválido en el campo a probar
$doc->{$campo} = Tools::randomString($invalido);
$this->assertFalse($doc->save(), "can-save-albaranCliente-bad-{$campo}");

// Corregimos el campo y comprobamos que ahora sí se puede guardar
$doc->{$campo} = Tools::randomString($valido);
$this->assertTrue($doc->save(), "cannot-save-albaranCliente-fixed-{$campo}");

// Limpiar
$this->assertTrue($doc->delete(), "cannot-delete-albaranCliente-{$campo}");
}

// Eliminamos el cliente
$this->assertTrue($subject->getDefaultAddress()->delete(), 'can-not-delete-contact');
$this->assertTrue($subject->delete(), 'can-not-delete-customer');
}

public function testSecondCompany(): void
{
// creamos la empresa 2
Expand Down
39 changes: 39 additions & 0 deletions Test/Core/Model/AlbaranProveedorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use FacturaScripts\Core\Model\AlbaranProveedor;
use FacturaScripts\Core\Model\Almacen;
use FacturaScripts\Core\Model\Empresa;
use FacturaScripts\Core\Tools;
use FacturaScripts\Test\Traits\DefaultSettingsTrait;
use FacturaScripts\Test\Traits\LogErrorsTrait;
use FacturaScripts\Test\Traits\RandomDataTrait;
Expand Down Expand Up @@ -231,6 +232,44 @@ public function testCreateProductLine()
$this->assertTrue($product->delete(), 'can-not-delete-product-3');
}

public function testPropertiesLength(): void
{
// creamos un proveedor
$subject = $this->getRandomSupplier();
$this->assertTrue($subject->save(), 'can-not-save-customer-1');


// Definir los campos a validar: campo => [longitud_máxima, longitud_invalida]
$campos = [
'cifnif' => [30, 31],
'codigo' => [20, 21],
'nombre' => [100, 101],
'numproveedor' => [50, 51],
'operacion' => [20, 21],
];

foreach ($campos as $campo => [$valido, $invalido]) {
// Creamos un nuevo albarán
$doc = new AlbaranProveedor();
$doc->setSubject($subject);

// Asignamos el valor inválido en el campo a probar
$doc->{$campo} = Tools::randomString($invalido);
$this->assertFalse($doc->save(), "can-save-albaranProveedor-bad-{$campo}");

// Corregimos el campo y comprobamos que ahora sí se puede guardar
$doc->{$campo} = Tools::randomString($valido);
$this->assertTrue($doc->save(), "cannot-save-albaranProveedor-fixed-{$campo}");

// Limpiar
$this->assertTrue($doc->delete(), "cannot-delete-albaranProveedor-{$campo}");
}

// Eliminamos el cliente
$this->assertTrue($subject->getDefaultAddress()->delete(), 'can-not-delete-contact');
$this->assertTrue($subject->delete(), 'can-not-delete-customer');
}

public function testSecondCompany()
{
// creamos la empresa 2
Expand Down
36 changes: 36 additions & 0 deletions Test/Core/Model/AlmacenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace FacturaScripts\Test\Core\Model;

use FacturaScripts\Core\Model\Almacen;
use FacturaScripts\Core\Tools;
use FacturaScripts\Test\Traits\LogErrorsTrait;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -67,6 +68,41 @@ public function testDeleteDefault(): void
}
}

public function testPropertiesLength(): void
{
// Definir los campos a validar: campo => [longitud_máxima, longitud_invalida]
$campos = [
'apartado' => [10, 11],
'ciudad' => [100, 101],
'codpais' => [20, 21],
'codalmacen' => [4, 5],
'codpostal' => [10, 11],
'direccion' => [200, 201],
'nombre' => [100, 101],
'provincia' => [100, 101],
'telefono' => [30, 31],
];

foreach ($campos as $campo => [$valido, $invalido]) {
// Creamos un nuevo almacén
$warehouse = new Almacen();

// campo obligatorio (not null)
$warehouse->nombre = 'Test Warehouse with new code';

// Asignamos el valor inválido en el campo a probar
$warehouse->{$campo} = Tools::randomString($invalido);
$this->assertFalse($warehouse->save(), "can-save-almacen-bad-{$campo}");

// Corregimos el campo y comprobamos que ahora sí se puede guardar
$warehouse->{$campo} = Tools::randomString($valido);
$this->assertTrue($warehouse->save(), "cannot-save-almacen-fixed-{$campo}");

// Limpiar
$this->assertTrue($warehouse->delete(), "cannot-delete-almacen-{$campo}");
}
}

protected function tearDown(): void
{
$this->logErrors();
Expand Down
46 changes: 46 additions & 0 deletions Test/Core/Model/ContactoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Lib\Vies;
use FacturaScripts\Core\Model\Contacto;
use FacturaScripts\Core\Tools;
use FacturaScripts\Test\Traits\LogErrorsTrait;
use FacturaScripts\Test\Traits\RandomDataTrait;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -195,6 +196,51 @@ public function testNotNullFields(): void
$this->assertTrue($contact->delete(), 'contact-cant-delete');
}

public function testPropertiesLength(): void
{
// Definir los campos a validar: campo => [longitud_máxima, longitud_invalida]
$campos = [
'apellidos' => [150, 151],
'apartado' => [10, 11],
'cargo' => [100, 101],
'cifnif' => [30, 31],
'ciudad' => [100, 101],
'codpais' => [20, 21],
'codpostal' => [10, 11],
'descripcion' => [100, 101],
'direccion' => [200, 201],
//'email' => [100, 101],
'empresa' => [100, 101],
'langcode' => [10, 11],
'nombre' => [100, 101],
'provincia' => [100, 101],
'telefono1' => [30, 31],
'telefono2' => [30, 31],
'tipoidfiscal' => [25, 26],
//'web' => [100, 101],
];

foreach ($campos as $campo => [$valido, $invalido]) {
// Creamos un nuevo almacén
$contact = new Contacto();

// campo obligatorio (not null)
$contact->nombre = 'Test';
$contact->descripcion = 'Test'; // evitar autorellenado

// Asignamos el valor inválido en el campo a probar
$contact->{$campo} = Tools::randomString($invalido);
$this->assertFalse($contact->save(), "can-save-contacto-bad-{$campo}");

// Corregimos el campo y comprobamos que ahora sí se puede guardar
$contact->{$campo} = Tools::randomString($valido);
$this->assertTrue($contact->save(), "cannot-save-contacto-fixed-{$campo}");

// Limpiar
$this->assertTrue($contact->delete(), "cannot-delete-contacto-{$campo}");
}
}

public function testVies(): void
{
// creamos un contacto sin cif/nif
Expand Down
Loading
Loading