feat: Implement price list management and import functionality

- Added ListinoRelationManager for managing price lists associated with models.
- Introduced ImportaListiniAction for importing price lists from Excel files.
- Created ListinoPrezzo model to represent price entries in the database.
- Developed ListinoExcelParser for parsing Excel files containing price lists.
- Implemented ListinoImporter to handle the import logic and associations.
- Added migration for creating listino_prezzi table and converting measures to mm.
- Updated frontend logic to handle new price list features and validations.
- Enhanced tests for price list import and conversion functionalities.
This commit is contained in:
2026-10-19 16:51:24 +02:00
parent a8aa6d9927
commit 1e352eb2ef
46 changed files with 1575 additions and 327 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ListinoPrezzo extends Model
{
protected $table = 'listino_prezzi';
protected $fillable = [
'modello_id', 'larghezza', 'altezza', 'prezzo',
];
protected $casts = [
'larghezza' => 'integer',
'altezza' => 'integer',
'prezzo' => 'float',
];
public function modello(): BelongsTo
{
return $this->belongsTo(Modello::class);
}
protected static function booted(): void
{
// Le modifiche manuali dal pannello aggiornano la data del listino del modello.
$tocca = fn (ListinoPrezzo $prezzo) => $prezzo->modello?->update(['listino_aggiornato_at' => now()]);
static::saved($tocca);
static::deleted($tocca);
}
}
+8
View File
@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;
class Modello extends Model
@@ -36,12 +37,14 @@ class Modello extends Model
protected $fillable = [
'sistema_id', 'codice', 'nome', 'descrizione', 'icona', 'ordine', 'attivo',
'cartella', 'file_modello', 'categoria', 'cartella_texture', 'moduli',
'listino_aggiornato_at',
];
protected $casts = [
'ordine' => 'integer',
'attivo' => 'boolean',
'moduli' => 'array',
'listino_aggiornato_at' => 'datetime',
];
public function sistema(): BelongsTo
@@ -49,6 +52,11 @@ class Modello extends Model
return $this->belongsTo(Sistema::class);
}
public function listino(): HasMany
{
return $this->hasMany(ListinoPrezzo::class);
}
public function scopeAttivi(Builder $query): Builder
{
return $query->where('attivo', true)->orderBy('ordine')->orderBy('id');