Files
SmartReports/docs/superpowers/specs/2026-03-26-memoria-natixis-design.md

93 lines
4.9 KiB
Markdown

# Design Spec: Campo Memoria + Parametro Natixis
**Data:** 2026-03-26
**Scope:** `CertReports.Syncfusion` — tutti i report (quotazione + expired)
---
## Panoramica
Due feature indipendenti da aggiungere a tutti i report PDF generati dall'API:
1. **Campo Memoria** — nuovo KV nella sezione Analisi, subito dopo Leva, che mostra il valore del campo `Memory` della SP `rpt_Master_CFT_ISIN`.
2. **Parametro `?natixis`** — flag URL che modifica il campo Tipologia: se `true`, usa `info.Nome` dalla SP; se `false` (default), usa `info.Categoria` come adesso.
---
## Feature 1: Campo Memoria
### Origine dati
- Il campo `Memory` (string) esiste già in `CertificateInfo` (riga 22 di `CertificateModels.cs`) e viene già letto dalla SP `rpt_Master_CFT_ISIN`.
- Nessuna modifica al modello o al data service necessaria.
### Rendering
- Aggiunto come 9° item nella **colonna sinistra** di `DrawAnalisi` in entrambi i renderer:
- `AnagraficaSectionRenderer` (report in quotazione)
- `ExpiredAnagraficaSectionRenderer` (report expired: Scaduto/Rimborsato/Revocato)
- Posizione: subito dopo `("Leva", ...)`.
- Valore: `string.IsNullOrWhiteSpace(info.Memory) ? "—" : info.Memory`
- La colonna sinistra passa da 8 a **9 item**, simmetrica alla colonna destra che ne ha già 9.
---
## Feature 2: Parametro `?natixis`
### Comportamento
- `?natixis=false` (default): `Tipologia = info.Categoria` — comportamento invariato
- `?natixis=true`: `Tipologia = info.Nome` (campo Nome dalla SP `rpt_Master_CFT_ISIN`)
### Propagazione del flag
Il flag segue lo stesso pattern di `showBranding` e `showDividend`:
1. **`CertificateReportData`**: aggiungere `bool ShowNatixis { get; set; } = false;`
2. **`ReportController`**: aggiungere `[FromQuery(Name = "natixis")] bool showNatixis = false` a tutti e 3 gli endpoint (`GenerateReport`, `GenerateReportByIsin`, `DownloadReport`) e al metodo helper `GenerateAndReturnPdf`.
3. **`IReportOrchestrator` / `ReportOrchestrator.GenerateReportAsync`**: aggiungere parametro `bool showNatixis = false`, propagarlo in `CertificateReportData.ShowNatixis`.
4. **Renderer — `DrawTitle`**: i metodi privati `DrawTitle` in entrambi i renderer hanno firma `(PdfGraphics g, CertificateInfo info, float w, float y)` e non ricevono `CertificateReportData`. La strategia adottata è **Option A**: aggiungere `bool showNatixis` come parametro aggiuntivo e aggiornare il sito di chiamata in `Render` passando `data.ShowNatixis`.
```csharp
// firma aggiornata
private float DrawTitle(PdfGraphics g, CertificateInfo info, float w, float y, bool showNatixis)
// call site in Render
y = DrawTitle(g, info, PageW, y, data.ShowNatixis);
// uso interno
string tipologia = showNatixis ? info.Nome : info.Categoria;
```
Il guard di visibilità del box Tipologia va aggiornato di conseguenza:
```csharp
bool showTip = !string.IsNullOrEmpty(showNatixis ? info.Nome : info.Categoria);
```
Questo evita che il box venga soppresso quando `natixis=true` ma `Categoria` è vuota.
### Cache (Approccio A — flag concatenati)
La chiave cache segue il pattern esistente. Il suffisso `:natixis` si applica **sia al path base che al path expired** (`{isin}:expired`):
| Flags attivi | Chiave base | Chiave expired |
|---------------------------------|--------------------------------|---------------------------------------|
| nessuno | `{isin}` | `{isin}:expired` |
| branding | `{isin}:branded` | `{isin}:expired:branded` |
| natixis | `{isin}:natixis` | `{isin}:expired:natixis` |
| branding + natixis | `{isin}:branded:natixis` | `{isin}:expired:branded:natixis` |
| dividend | `{isin}:dividend` | n/a (dividend solo per expired path) |
La logica in `ReportOrchestrator` aggiunge `:natixis` a entrambe le chiavi (base ed expired) quando `showNatixis == true`.
---
## File modificati
| File | Modifica |
|------|----------|
| `Models/CertificateModels.cs` | Aggiungere `bool ShowNatixis` a `CertificateReportData` |
| `Controllers/ReportController.cs` | Aggiungere param `natixis` a tutti gli endpoint |
| `Services/Interfaces/IServices.cs` | Aggiornare firma `GenerateReportAsync` |
| `Services/Implementations/ReportOrchestrator.cs` | Aggiungere param, propagare flag, aggiornare cache key |
| `Services/Implementations/AnagraficaSectionRenderer.cs` | Aggiungere Memoria in DrawAnalisi; usare ShowNatixis in DrawTitle |
| `Services/Implementations/ExpiredAnagraficaSectionRenderer.cs` | Stesse modifiche |
---
## Non in scope
- Modifica al data service o alle stored procedure (i campi `Memory` e `Nome` sono già letti)
- Modifica a `EventiSectionRenderer`, `ScenarioSectionRenderer`, `ChartSectionRenderer`, `DividendSectionRenderer`
- Aggiornamento documentazione API pubblica