Aggiunto mappatura e prototipo filtro

This commit is contained in:
2025-08-06 19:28:01 +02:00
parent a1742e4e61
commit 652f9a7e76
12 changed files with 215 additions and 29 deletions

View File

@@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
class ImportRule extends Model
{
use HasFactory;
// In MovimentiController o direttamente nel model Movimenti
}

View File

@@ -18,6 +18,18 @@ class Movimenti extends Model
protected $dates = ['mov_data'];
protected $casts = [ 'mov_data'=>'datetime'];
protected $fillable = [
'mov_data',
'mov_fk_categoria',
'mov_descrizione',
'mov_importo_dare',
'mov_importo_avere',
'mov_inserito_da',
'mov_fk_tags',
'conto_id_da',
'conto_id_a'
];
public static $query= 'SELECT
a.id,
a.mov_data,
@@ -57,7 +69,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
'SELECT
a.id,
a.mov_data,
a.mov_importo,
a.mov_importo_dare,
a.mov_importo_avere,
a.mov_descrizione,
c.cat_name,
t.tag_name,
@@ -66,7 +79,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
FROM movimentis as a
JOIN tags as t ON a.mov_fk_tags=t.id
JOIN categories as c ON a.mov_fk_categoria=c.id
JOIN contos as co ON a.conto_id=co.id'
JOIN contos as co ON a.conto_id_da=co.id'
);
$query = $expression->getValue(DB::connection()->getQueryGrammar());
@@ -335,10 +348,12 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
return [
"Data movimento"=>"mov_data",
"Descrizione"=>"mov_descrizione",
"Importo"=>"mov_importo",
"Importo Dare"=>"mov_importo_dare",
"Importo Avere"=>"mov_importo_avere",
"Categoria"=>"mov_fk_categoria",
"Tag"=>"mov_fk_tags",
"Conto"=>"conto_id",
"Conto prelievo"=>"conto_id_da",
"Conto versamento"=>"conto_id_a",
];
}
@@ -361,6 +376,12 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
}
public static function getSuggestedCategory($descrizione)
{
$rule = ImportRule::whereRaw('? LIKE CONCAT("%", pattern, "%")', [$descrizione])->first();
return $rule ? $rule->category_id : null;
}