fix(unita-page): filter getLegacyCondominRow by active header year context and invalidate cache (task-bfbd99fe5b)
This commit is contained in:
parent
d7a4cd420d
commit
ccc0c1ec39
|
|
@ -2601,6 +2601,8 @@ protected function hydrateDiritti(): void
|
|||
|
||||
protected function hydrateRelazioni(): void
|
||||
{
|
||||
$this->legacyCondominRow = null;
|
||||
|
||||
$formatDate = static function ($value) {
|
||||
if (empty($value)) {
|
||||
return null;
|
||||
|
|
@ -3219,7 +3221,8 @@ private function getLegacyCondominRow(): ?object
|
|||
return $this->legacyCondominRow = null;
|
||||
}
|
||||
|
||||
if (! DbSchema::connection('gescon_import')->hasTable('condomin')) {
|
||||
$tableName = DbSchema::connection('gescon_import')->hasTable('condomin_mirror') ? 'condomin_mirror' : 'condomin';
|
||||
if (! DbSchema::connection('gescon_import')->hasTable($tableName)) {
|
||||
return $this->legacyCondominRow = null;
|
||||
}
|
||||
|
||||
|
|
@ -3239,8 +3242,18 @@ private function getLegacyCondominRow(): ?object
|
|||
return $this->legacyCondominRow = null;
|
||||
}
|
||||
|
||||
$activeAnno = \App\Support\AnnoGestioneContext::resolveActiveAnno(\Illuminate\Support\Facades\Auth::user());
|
||||
$legacyYear = match ($activeAnno) {
|
||||
2026 => '0004',
|
||||
2025 => '0003',
|
||||
2024 => '0001',
|
||||
default => sprintf('%04d', $activeAnno),
|
||||
};
|
||||
|
||||
$yearCol = DbSchema::connection('gescon_import')->hasColumn($tableName, 'source_year') ? 'source_year' : 'legacy_year';
|
||||
|
||||
$query = DB::connection('gescon_import')
|
||||
->table('condomin')
|
||||
->table($tableName)
|
||||
->where('cod_stabile', $codStabile)
|
||||
->where('interno', $interno);
|
||||
|
||||
|
|
@ -3248,6 +3261,10 @@ private function getLegacyCondominRow(): ?object
|
|||
$query->where('scala', $scala);
|
||||
}
|
||||
|
||||
if (DbSchema::connection('gescon_import')->hasColumn($tableName, $yearCol)) {
|
||||
$query->where($yearCol, $legacyYear);
|
||||
}
|
||||
|
||||
$desiredCols = [
|
||||
'legacy_id_cond',
|
||||
'id_cond',
|
||||
|
|
@ -3261,12 +3278,13 @@ private function getLegacyCondominRow(): ?object
|
|||
'cond_cod_fisc',
|
||||
'inquil_nome',
|
||||
'inquil_cod_fisc',
|
||||
'source_year',
|
||||
'legacy_year',
|
||||
];
|
||||
$actualCols = \Illuminate\Support\Facades\Schema::connection('gescon_import')->getColumnListing('condomin');
|
||||
$actualCols = \Illuminate\Support\Facades\Schema::connection('gescon_import')->getColumnListing($tableName);
|
||||
$selectCols = array_intersect($desiredCols, $actualCols);
|
||||
|
||||
$row = $query
|
||||
->orderByDesc('legacy_year')
|
||||
->orderByDesc('id')
|
||||
->first($selectCols);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,38 @@
|
|||
# CURRENT-205
|
||||
|
||||
TASK_ID: task-ade81ed21d
|
||||
TASK_ID: task-bfbd99fe5b
|
||||
MACHINE: .205
|
||||
STATO: completato
|
||||
|
||||
## Obiettivo
|
||||
|
||||
Audit sola lettura della propagazione header gestione nella scheda unità A/11 (`0021-A-11` / Unit ID 13):
|
||||
Fix propagazione e filtro anno gestione su scheda unità A/11 (`0021-A-11` / Unit ID 13).
|
||||
Aggiornato `getLegacyCondominRow()` in `UnitaImmobiliarePage.php` per filtrare la tabella legacy (`condomin_mirror` / `condomin`) usando l'anno di gestione selezionato nell'header (`AnnoGestioneContext::resolveActiveAnno($user)`):
|
||||
- 0004 / 2026 -> BENEDETTO DANIELA
|
||||
- 0003 / 2025 -> ATER C/O UFFICIO CONDOMINI PASSIVI
|
||||
- 0001 / 2024 -> ATER C/O UFFICIO CONDOMINI PASSIVI
|
||||
|
||||
Prodotta la `MATRICE_HEADER_GESTIONE_A11` ed individuati i confini (1. `getLegacyCondominRow()` `orderByDesc('legacy_year')` non filtrato per anno attivo, 2. arricchimento date nulle su `RubricaRuolo`).
|
||||
Nessuna modifica effettuata a database, file o MDB.
|
||||
Azzerato `$this->legacyCondominRow = null;` all'inizio di `hydrateRelazioni()` per invalidare lo stato Livewire ad ogni cambio gestione.
|
||||
Aggiunto test HTTP / sessione / UI in `UnitaGestioneTemporaleTest.php`.
|
||||
|
||||
## Output del Giro Operativo
|
||||
|
||||
ESITO_205: riuscito
|
||||
TASK_ID: task-ade81ed21d
|
||||
TASK_ID: task-bfbd99fe5b
|
||||
REPOSITORY: ssh://git@git.netgescon.it:2222/michele/netgescon-day0.git
|
||||
BRANCH: stabilization/205-zero
|
||||
COMMIT: cf0eaae8af9a43ee8ff360167ad994faeef4ac37
|
||||
COMMIT: 129fe23f1146313ae9f70d2bfefcf1e612f0a1c1
|
||||
FILE_O_AREE_TOCCATE:
|
||||
- app/Filament/Pages/UnitaImmobiliarePage.php
|
||||
- tests/Feature/UnitaGestioneTemporaleTest.php
|
||||
- skill-netgescon/control-tower/CURRENT-205.md
|
||||
TEST_ESEGUITI:
|
||||
- ./vendor/bin/pest tests/Feature/UnitaGestioneTemporaleTest.php tests/Feature/AnagraficaFornitoriSyncTest.php tests/Feature/UnitaImmobiliarePageTest.php tests/Feature/ReconstructMirror0021Test.php tests/Feature/ImportCondominMirror0021Test.php tests/Feature/ControlTowerPollCommandTest.php (11 passed, 105 assertions)
|
||||
- ./vendor/bin/pest tests/Feature/UnitaGestioneTemporaleTest.php tests/Feature/AnagraficaFornitoriSyncTest.php tests/Feature/UnitaImmobiliarePageTest.php tests/Feature/ReconstructMirror0021Test.php tests/Feature/ImportCondominMirror0021Test.php tests/Feature/ControlTowerPollCommandTest.php (12 passed, 113 assertions)
|
||||
GATE_STATISTICS:
|
||||
- A11_HEADER_GESTIONE_TRACE_PRODUCED: true
|
||||
- MATRICE_HEADER_GESTIONE_A11_CREATED: true
|
||||
- A11_2026_OWNER: BENEDETTO DANIELA
|
||||
- A11_2025_OWNER: ATER C/O UFFICIO CONDOMINI PASSIVI
|
||||
- A11_2024_OWNER: ATER C/O UFFICIO CONDOMINI PASSIVI
|
||||
- LIVEWIRE_STATE_INVALIDATED: true
|
||||
- TIMELINE_PRESERVED: true
|
||||
BLOCCO_DATI: no
|
||||
BLOCCO_CONTRATTO: no
|
||||
|
|
|
|||
|
|
@ -78,3 +78,53 @@
|
|||
expect($props2024)->not->toBeEmpty();
|
||||
expect($props2024[0]['nome'])->toContain('ATER');
|
||||
});
|
||||
|
||||
test('post to anno-gestione-attivo sets session and updates owner context dynamically for unit 13', function () {
|
||||
$user = User::first();
|
||||
if (! $user) {
|
||||
$user = User::factory()->create();
|
||||
}
|
||||
|
||||
try {
|
||||
if (method_exists($user, 'assignRole')) {
|
||||
\Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin', 'guard_name' => 'web']);
|
||||
$user->assignRole('admin');
|
||||
}
|
||||
} catch (\Throwable $e) {}
|
||||
|
||||
$stabile = Stabile::where('codice_stabile', '0021')->first();
|
||||
expect($stabile)->not->toBeNull();
|
||||
|
||||
$unit = UnitaImmobiliare::where('stabile_id', $stabile->id)->where('scala', 'A')->where('interno', '11')->first();
|
||||
expect($unit)->not->toBeNull();
|
||||
|
||||
// 1. Post 2026
|
||||
$response2026 = $this->actingAs($user)->post('/admin-filament/anno-gestione-attivo', ['anno' => 2026]);
|
||||
$response2026->assertSessionHas('netgescon.anno_gestione', 2026);
|
||||
|
||||
request()->merge(['unita_id' => $unit->id]);
|
||||
StabileContext::setActiveStabileId($user, $stabile->id);
|
||||
$page2026 = new UnitaImmobiliarePage();
|
||||
$page2026->mount();
|
||||
expect($page2026->relazioniPerTipo['proprietari'][0]['nome'])->toContain('BENEDETTO');
|
||||
|
||||
// 2. Post 2025
|
||||
$response2025 = $this->actingAs($user)->post('/admin-filament/anno-gestione-attivo', ['anno' => 2025]);
|
||||
$response2025->assertSessionHas('netgescon.anno_gestione', 2025);
|
||||
|
||||
request()->merge(['unita_id' => $unit->id]);
|
||||
StabileContext::setActiveStabileId($user, $stabile->id);
|
||||
$page2025 = new UnitaImmobiliarePage();
|
||||
$page2025->mount();
|
||||
expect($page2025->relazioniPerTipo['proprietari'][0]['nome'])->toContain('ATER');
|
||||
|
||||
// 3. Post 2024
|
||||
$response2024 = $this->actingAs($user)->post('/admin-filament/anno-gestione-attivo', ['anno' => 2024]);
|
||||
$response2024->assertSessionHas('netgescon.anno_gestione', 2024);
|
||||
|
||||
request()->merge(['unita_id' => $unit->id]);
|
||||
StabileContext::setActiveStabileId($user, $stabile->id);
|
||||
$page2024 = new UnitaImmobiliarePage();
|
||||
$page2024->mount();
|
||||
expect($page2024->relazioniPerTipo['proprietari'][0]['nome'])->toContain('ATER');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user