Skip to content

Commit 7d9c90e

Browse files
author
Carlos Garcia
committed
Solucionados problemas de tests con República Dominicana.
1 parent e6c2ce7 commit 7d9c90e

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

Core/Model/Subcuenta.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static function tableName(): string
206206

207207
public function test(): bool
208208
{
209-
$this->saldo = round($this->debe - $this->haber, FS_NF0);
209+
$this->saldo = Tools::round($this->debe - $this->haber);
210210

211211
// escape html
212212
foreach (['codcuenta', 'codsubcuenta', 'descripcion', 'codcuentaesp'] as $field) {
@@ -216,17 +216,22 @@ public function test(): bool
216216
$this->codsubcuenta = empty($this->idsubcuenta) ? $this->transformCodsubcuenta($this->codsubcuenta) : $this->codsubcuenta;
217217
$this->descripcion = Tools::noHtml($this->descripcion);
218218
if (strlen($this->descripcion) < 1 || strlen($this->descripcion) > 255) {
219-
Tools::log()->warning(
220-
'invalid-column-lenght',
221-
['%column%' => 'descripcion', '%min%' => '1', '%max%' => '255']
222-
);
219+
Tools::log()->warning('invalid-column-lenght', [
220+
'%column%' => 'descripcion',
221+
'%min%' => '1',
222+
'%max%' => '255'
223+
]);
223224
return false;
224225
}
225226

226227
// check exercise
227228
$exercise = $this->getExercise();
228229
if (false === $this->disable_additional_test && strlen($this->codsubcuenta) !== $exercise->longsubcuenta) {
229-
Tools::log()->warning('account-length-error', ['%code%' => $this->codsubcuenta]);
230+
Tools::log()->warning('account-length-error', [
231+
'%code%' => $this->codsubcuenta,
232+
'%length%' => $exercise->longsubcuenta,
233+
'%exercise%' => $exercise->id()
234+
]);
230235
return false;
231236
}
232237

Test/Core/Model/EjercicioCierreTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use FacturaScripts\Core\Base\DataBase;
2323
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
24+
use FacturaScripts\Core\DataSrc\Paises;
2425
use FacturaScripts\Core\Lib\Accounting\AccountingPlanImport;
2526
use FacturaScripts\Core\Lib\Accounting\ClosingToAcounting;
2627
use FacturaScripts\Core\Model\Almacen;
@@ -59,7 +60,7 @@ public function testCloseExercise(): void
5960
// obtenemos el almacén por defecto
6061
$almacen = new Almacen();
6162
$where = [new DataBaseWhere('idempresa', $empresa->idempresa)];
62-
$this->assertTrue($almacen->loadFromCode('', $where));
63+
$this->assertTrue($almacen->loadWhere($where));
6364

6465
// creamos el ejercicio para 2020
6566
$ejercicio = new Ejercicio();
@@ -71,7 +72,7 @@ public function testCloseExercise(): void
7172
$this->assertTrue($ejercicio->save());
7273

7374
// copiamos el plan contable
74-
$filePath = FS_FOLDER . '/Core/Data/Codpais/ESP/defaultPlan.csv';
75+
$filePath = FS_FOLDER . '/Core/Data/Codpais/' . Paises::default()->codpais . '/defaultPlan.csv';
7576
$planImport = new AccountingPlanImport();
7677
$planImport->importCSV($filePath, $ejercicio->codejercicio);
7778

@@ -90,10 +91,11 @@ public function testCloseExercise(): void
9091
'copySubAccounts' => true
9192
];
9293
$closing = new ClosingToAcounting();
94+
$this->assertTrue($ejercicio->reload());
9395
$this->assertTrue($closing->exec($ejercicio, $data));
9496

9597
// comprobamos que el ejercicio está cerrado
96-
$this->assertTrue($ejercicio->loadFromCode($ejercicio->codejercicio));
98+
$this->assertTrue($ejercicio->reload());
9799
$this->assertFalse($ejercicio->isOpened());
98100

99101
// comprobamos que todas las subcuentas del ejercicio anterior tienen saldo 0
@@ -133,7 +135,7 @@ public function testCloseExerciseWithMissingEntries(): void
133135
// obtenemos el almacén por defecto
134136
$almacen = new Almacen();
135137
$where = [new DataBaseWhere('idempresa', $empresa->idempresa)];
136-
$this->assertTrue($almacen->loadFromCode('', $where));
138+
$this->assertTrue($almacen->loadWhere($where));
137139

138140
// creamos el ejercicio para 2026
139141
$ejercicio = new Ejercicio();
@@ -145,7 +147,7 @@ public function testCloseExerciseWithMissingEntries(): void
145147
$this->assertTrue($ejercicio->save());
146148

147149
// copiamos el plan contable
148-
$filePath = FS_FOLDER . '/Core/Data/Codpais/ESP/defaultPlan.csv';
150+
$filePath = FS_FOLDER . '/Core/Data/Codpais/' . Paises::default()->codpais . '/defaultPlan.csv';
149151
$planImport = new AccountingPlanImport();
150152
$planImport->importCSV($filePath, $ejercicio->codejercicio);
151153

Test/Traits/DefaultSettingsTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
2323
use FacturaScripts\Core\DataSrc\Ejercicios;
24+
use FacturaScripts\Core\DataSrc\Paises;
2425
use FacturaScripts\Core\Lib\Accounting\AccountingPlanImport;
2526
use FacturaScripts\Core\Model\Almacen;
2627
use FacturaScripts\Core\Model\Cuenta;
@@ -33,8 +34,7 @@ trait DefaultSettingsTrait
3334
protected static function installAccountingPlan(): void
3435
{
3536
// ¿Existe el archivo del plan contable?
36-
$codpais = Tools::settings('default', 'codpais', 'ESP');
37-
$filePath = FS_FOLDER . '/Core/Data/Codpais/' . $codpais . '/defaultPlan.csv';
37+
$filePath = FS_FOLDER . '/Core/Data/Codpais/' . Paises::default()->codpais . '/defaultPlan.csv';
3838
if (false === file_exists($filePath)) {
3939
return;
4040
}
@@ -70,8 +70,7 @@ protected static function removeTaxRegularization(): void
7070

7171
protected static function setDefaultSettings(): void
7272
{
73-
$codpais = Tools::settings('default', 'codpais', 'ESP');
74-
$fileContent = file_get_contents(FS_FOLDER . '/Core/Data/Codpais/' . $codpais . '/default.json');
73+
$fileContent = file_get_contents(FS_FOLDER . '/Core/Data/Codpais/' . Paises::default()->codpais . '/default.json');
7574
$defaultValues = json_decode($fileContent, true) ?? [];
7675
foreach ($defaultValues as $group => $values) {
7776
foreach ($values as $key => $value) {

0 commit comments

Comments
 (0)