implementato modulo HR

This commit is contained in:
2025-12-04 02:12:34 +01:00
parent ed2472febc
commit 500a3197e2
41 changed files with 12556 additions and 674 deletions

View File

@@ -0,0 +1,94 @@
using Zentral.Domain.Entities.HR;
using Zentral.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Zentral.API.Modules.HR.Controllers;
[ApiController]
[Route("api/hr/[controller]")]
public class AssenzeController : ControllerBase
{
private readonly ZentralDbContext _context;
public AssenzeController(ZentralDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<Assenza>>> GetAssenze([FromQuery] int? dipendenteId, [FromQuery] DateTime? from, [FromQuery] DateTime? to)
{
var query = _context.Assenze.Include(a => a.Dipendente).AsQueryable();
if (dipendenteId.HasValue)
query = query.Where(a => a.DipendenteId == dipendenteId.Value);
if (from.HasValue)
query = query.Where(a => a.DataInizio >= from.Value);
if (to.HasValue)
query = query.Where(a => a.DataFine <= to.Value);
return await query.OrderByDescending(a => a.DataInizio).ToListAsync();
}
[HttpGet("{id}")]
public async Task<ActionResult<Assenza>> GetAssenza(int id)
{
var assenza = await _context.Assenze
.Include(a => a.Dipendente)
.FirstOrDefaultAsync(a => a.Id == id);
if (assenza == null)
return NotFound();
return assenza;
}
[HttpPost]
public async Task<ActionResult<Assenza>> CreateAssenza(Assenza assenza)
{
assenza.CreatedAt = DateTime.UtcNow;
_context.Assenze.Add(assenza);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetAssenza), new { id = assenza.Id }, assenza);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateAssenza(int id, Assenza assenza)
{
if (id != assenza.Id)
return BadRequest();
assenza.UpdatedAt = DateTime.UtcNow;
_context.Entry(assenza).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await _context.Assenze.AnyAsync(a => a.Id == id))
return NotFound();
throw;
}
return NoContent();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAssenza(int id)
{
var assenza = await _context.Assenze.FindAsync(id);
if (assenza == null)
return NotFound();
_context.Assenze.Remove(assenza);
await _context.SaveChangesAsync();
return NoContent();
}
}

View File

@@ -0,0 +1,88 @@
using Zentral.Domain.Entities.HR;
using Zentral.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Zentral.API.Modules.HR.Controllers;
[ApiController]
[Route("api/hr/[controller]")]
public class ContrattiController : ControllerBase
{
private readonly ZentralDbContext _context;
public ContrattiController(ZentralDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<Contratto>>> GetContratti([FromQuery] int? dipendenteId)
{
var query = _context.Contratti.Include(c => c.Dipendente).AsQueryable();
if (dipendenteId.HasValue)
query = query.Where(c => c.DipendenteId == dipendenteId.Value);
return await query.OrderByDescending(c => c.DataInizio).ToListAsync();
}
[HttpGet("{id}")]
public async Task<ActionResult<Contratto>> GetContratto(int id)
{
var contratto = await _context.Contratti
.Include(c => c.Dipendente)
.FirstOrDefaultAsync(c => c.Id == id);
if (contratto == null)
return NotFound();
return contratto;
}
[HttpPost]
public async Task<ActionResult<Contratto>> CreateContratto(Contratto contratto)
{
contratto.CreatedAt = DateTime.UtcNow;
_context.Contratti.Add(contratto);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetContratto), new { id = contratto.Id }, contratto);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateContratto(int id, Contratto contratto)
{
if (id != contratto.Id)
return BadRequest();
contratto.UpdatedAt = DateTime.UtcNow;
_context.Entry(contratto).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await _context.Contratti.AnyAsync(c => c.Id == id))
return NotFound();
throw;
}
return NoContent();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteContratto(int id)
{
var contratto = await _context.Contratti.FindAsync(id);
if (contratto == null)
return NotFound();
_context.Contratti.Remove(contratto);
await _context.SaveChangesAsync();
return NoContent();
}
}

View File

@@ -0,0 +1,93 @@
using Zentral.Domain.Entities.HR;
using Zentral.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Zentral.API.Modules.HR.Controllers;
[ApiController]
[Route("api/hr/[controller]")]
public class DipendentiController : ControllerBase
{
private readonly ZentralDbContext _context;
public DipendentiController(ZentralDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<Dipendente>>> GetDipendenti([FromQuery] string? search)
{
var query = _context.Dipendenti.AsQueryable();
if (!string.IsNullOrEmpty(search))
query = query.Where(d => d.Nome.Contains(search) ||
d.Cognome.Contains(search) ||
(d.CodiceFiscale != null && d.CodiceFiscale.Contains(search)));
return await query.OrderBy(d => d.Cognome).ThenBy(d => d.Nome).ToListAsync();
}
[HttpGet("{id}")]
public async Task<ActionResult<Dipendente>> GetDipendente(int id)
{
var dipendente = await _context.Dipendenti
.Include(d => d.Contratti)
.Include(d => d.Assenze)
.Include(d => d.Pagamenti)
.Include(d => d.Rimborsi)
.FirstOrDefaultAsync(d => d.Id == id);
if (dipendente == null)
return NotFound();
return dipendente;
}
[HttpPost]
public async Task<ActionResult<Dipendente>> CreateDipendente(Dipendente dipendente)
{
dipendente.CreatedAt = DateTime.UtcNow;
_context.Dipendenti.Add(dipendente);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetDipendente), new { id = dipendente.Id }, dipendente);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateDipendente(int id, Dipendente dipendente)
{
if (id != dipendente.Id)
return BadRequest();
dipendente.UpdatedAt = DateTime.UtcNow;
_context.Entry(dipendente).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await _context.Dipendenti.AnyAsync(d => d.Id == id))
return NotFound();
throw;
}
return NoContent();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDipendente(int id)
{
var dipendente = await _context.Dipendenti.FindAsync(id);
if (dipendente == null)
return NotFound();
_context.Dipendenti.Remove(dipendente);
await _context.SaveChangesAsync();
return NoContent();
}
}

View File

@@ -0,0 +1,94 @@
using Zentral.Domain.Entities.HR;
using Zentral.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Zentral.API.Modules.HR.Controllers;
[ApiController]
[Route("api/hr/[controller]")]
public class PagamentiController : ControllerBase
{
private readonly ZentralDbContext _context;
public PagamentiController(ZentralDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<Pagamento>>> GetPagamenti([FromQuery] int? dipendenteId, [FromQuery] DateTime? from, [FromQuery] DateTime? to)
{
var query = _context.Pagamenti.Include(p => p.Dipendente).AsQueryable();
if (dipendenteId.HasValue)
query = query.Where(p => p.DipendenteId == dipendenteId.Value);
if (from.HasValue)
query = query.Where(p => p.DataPagamento >= from.Value);
if (to.HasValue)
query = query.Where(p => p.DataPagamento <= to.Value);
return await query.OrderByDescending(p => p.DataPagamento).ToListAsync();
}
[HttpGet("{id}")]
public async Task<ActionResult<Pagamento>> GetPagamento(int id)
{
var pagamento = await _context.Pagamenti
.Include(p => p.Dipendente)
.FirstOrDefaultAsync(p => p.Id == id);
if (pagamento == null)
return NotFound();
return pagamento;
}
[HttpPost]
public async Task<ActionResult<Pagamento>> CreatePagamento(Pagamento pagamento)
{
pagamento.CreatedAt = DateTime.UtcNow;
_context.Pagamenti.Add(pagamento);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetPagamento), new { id = pagamento.Id }, pagamento);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdatePagamento(int id, Pagamento pagamento)
{
if (id != pagamento.Id)
return BadRequest();
pagamento.UpdatedAt = DateTime.UtcNow;
_context.Entry(pagamento).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await _context.Pagamenti.AnyAsync(p => p.Id == id))
return NotFound();
throw;
}
return NoContent();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeletePagamento(int id)
{
var pagamento = await _context.Pagamenti.FindAsync(id);
if (pagamento == null)
return NotFound();
_context.Pagamenti.Remove(pagamento);
await _context.SaveChangesAsync();
return NoContent();
}
}

View File

@@ -0,0 +1,91 @@
using Zentral.Domain.Entities.HR;
using Zentral.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Zentral.API.Modules.HR.Controllers;
[ApiController]
[Route("api/hr/[controller]")]
public class RimborsiController : ControllerBase
{
private readonly ZentralDbContext _context;
public RimborsiController(ZentralDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<Rimborso>>> GetRimborsi([FromQuery] int? dipendenteId, [FromQuery] string? stato)
{
var query = _context.Rimborsi.Include(r => r.Dipendente).AsQueryable();
if (dipendenteId.HasValue)
query = query.Where(r => r.DipendenteId == dipendenteId.Value);
if (!string.IsNullOrEmpty(stato))
query = query.Where(r => r.Stato == stato);
return await query.OrderByDescending(r => r.DataSpesa).ToListAsync();
}
[HttpGet("{id}")]
public async Task<ActionResult<Rimborso>> GetRimborso(int id)
{
var rimborso = await _context.Rimborsi
.Include(r => r.Dipendente)
.FirstOrDefaultAsync(r => r.Id == id);
if (rimborso == null)
return NotFound();
return rimborso;
}
[HttpPost]
public async Task<ActionResult<Rimborso>> CreateRimborso(Rimborso rimborso)
{
rimborso.CreatedAt = DateTime.UtcNow;
_context.Rimborsi.Add(rimborso);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetRimborso), new { id = rimborso.Id }, rimborso);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateRimborso(int id, Rimborso rimborso)
{
if (id != rimborso.Id)
return BadRequest();
rimborso.UpdatedAt = DateTime.UtcNow;
_context.Entry(rimborso).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await _context.Rimborsi.AnyAsync(r => r.Id == id))
return NotFound();
throw;
}
return NoContent();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteRimborso(int id)
{
var rimborso = await _context.Rimborsi.FindAsync(id);
if (rimborso == null)
return NotFound();
_context.Rimborsi.Remove(rimborso);
await _context.SaveChangesAsync();
return NoContent();
}
}

View File

@@ -405,9 +405,6 @@ public class ModuleService
/// </summary>
public async Task SeedDefaultModulesAsync()
{
if (await _context.AppModules.AnyAsync())
return;
var defaultModules = new List<AppModule>
{
new AppModule
@@ -482,12 +479,46 @@ public class ModuleService
RoutePath = "/quality",
IsAvailable = true,
CreatedAt = DateTime.UtcNow
},
new AppModule
{
Code = "events",
Name = "Gestione Eventi",
Description = "Gestione eventi, pianificazione e controllo avanzamento",
Icon = "Event",
BasePrice = 2000m,
MonthlyMultiplier = 1.2m,
SortOrder = 60,
IsCore = false,
RoutePath = "/events",
IsAvailable = true,
CreatedAt = DateTime.UtcNow
},
new AppModule
{
Code = "hr",
Name = "Gestione Personale",
Description = "Gestione personale, contratti, pagamenti, assenze, rimborsi e analisi personale",
Icon = "People",
BasePrice = 1600m,
MonthlyMultiplier = 1.2m,
SortOrder = 70,
IsCore = false,
RoutePath = "/hr",
IsAvailable = true,
CreatedAt = DateTime.UtcNow
}
};
_context.AppModules.AddRange(defaultModules);
await _context.SaveChangesAsync();
var existingCodes = await _context.AppModules.Select(m => m.Code).ToListAsync();
var newModules = defaultModules.Where(m => !existingCodes.Contains(m.Code)).ToList();
_logger.LogInformation("Seed {Count} moduli di default completato", defaultModules.Count);
if (newModules.Any())
{
_context.AppModules.AddRange(newModules);
await _context.SaveChangesAsync();
_logger.LogInformation("Added {Count} new default modules: {Modules}",
newModules.Count, string.Join(", ", newModules.Select(m => m.Code)));
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Zentral.Domain.Entities.HR;
public class Assenza : BaseEntity
{
public int DipendenteId { get; set; }
public Dipendente Dipendente { get; set; } = null!;
public DateTime DataInizio { get; set; }
public DateTime DataFine { get; set; }
public string TipoAssenza { get; set; } = string.Empty;
public string Stato { get; set; } = "Richiesta";
public string? Note { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System;
namespace Zentral.Domain.Entities.HR;
public class Contratto : BaseEntity
{
public int DipendenteId { get; set; }
public Dipendente Dipendente { get; set; } = null!;
public DateTime DataInizio { get; set; }
public DateTime? DataFine { get; set; }
public string TipoContratto { get; set; } = string.Empty;
public string? Livello { get; set; }
public decimal RetribuzioneLorda { get; set; }
public string? Note { get; set; }
public bool Attivo { get; set; } = true;
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace Zentral.Domain.Entities.HR;
public class Dipendente : BaseEntity
{
public string Nome { get; set; } = string.Empty;
public string Cognome { get; set; } = string.Empty;
public string? CodiceFiscale { get; set; }
public string? Email { get; set; }
public string? Telefono { get; set; }
public string? Indirizzo { get; set; }
public DateTime? DataNascita { get; set; }
public string? Ruolo { get; set; }
public List<Contratto> Contratti { get; set; } = new();
public List<Assenza> Assenze { get; set; } = new();
public List<Pagamento> Pagamenti { get; set; } = new();
public List<Rimborso> Rimborsi { get; set; } = new();
}

View File

@@ -0,0 +1,14 @@
using System;
namespace Zentral.Domain.Entities.HR;
public class Pagamento : BaseEntity
{
public int DipendenteId { get; set; }
public Dipendente Dipendente { get; set; } = null!;
public DateTime DataPagamento { get; set; }
public decimal ImportoNetto { get; set; }
public string Descrizione { get; set; } = string.Empty;
public bool Pagato { get; set; } = false;
}

View File

@@ -0,0 +1,14 @@
using System;
namespace Zentral.Domain.Entities.HR;
public class Rimborso : BaseEntity
{
public int DipendenteId { get; set; }
public Dipendente Dipendente { get; set; } = null!;
public DateTime DataSpesa { get; set; }
public decimal Importo { get; set; }
public string Descrizione { get; set; } = string.Empty;
public string Stato { get; set; } = "Richiesto";
}

View File

@@ -3,6 +3,7 @@ using Zentral.Domain.Entities.Warehouse;
using Zentral.Domain.Entities.Purchases;
using Zentral.Domain.Entities.Sales;
using Zentral.Domain.Entities.Production;
using Zentral.Domain.Entities.HR;
using Microsoft.EntityFrameworkCore;
namespace Zentral.Infrastructure.Data;
@@ -86,10 +87,70 @@ public class ZentralDbContext : DbContext
public DbSet<ProductionOrderPhase> ProductionOrderPhases => Set<ProductionOrderPhase>();
public DbSet<MrpSuggestion> MrpSuggestions => Set<MrpSuggestion>();
// Personale module entities
public DbSet<Dipendente> Dipendenti => Set<Dipendente>();
public DbSet<Contratto> Contratti => Set<Contratto>();
public DbSet<Assenza> Assenze => Set<Assenza>();
public DbSet<Pagamento> Pagamenti => Set<Pagamento>();
public DbSet<Rimborso> Rimborsi => Set<Rimborso>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// ===============================================
// PERSONALE MODULE ENTITIES
// ===============================================
modelBuilder.Entity<Dipendente>(entity =>
{
entity.ToTable("Dipendenti");
entity.HasIndex(e => e.CodiceFiscale).IsUnique();
});
modelBuilder.Entity<Contratto>(entity =>
{
entity.ToTable("Contratti");
entity.Property(e => e.RetribuzioneLorda).HasPrecision(18, 2);
entity.HasOne(e => e.Dipendente)
.WithMany(d => d.Contratti)
.HasForeignKey(e => e.DipendenteId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<Assenza>(entity =>
{
entity.ToTable("Assenze");
entity.HasOne(e => e.Dipendente)
.WithMany(d => d.Assenze)
.HasForeignKey(e => e.DipendenteId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<Pagamento>(entity =>
{
entity.ToTable("Pagamenti");
entity.Property(e => e.ImportoNetto).HasPrecision(18, 2);
entity.HasOne(e => e.Dipendente)
.WithMany(d => d.Pagamenti)
.HasForeignKey(e => e.DipendenteId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<Rimborso>(entity =>
{
entity.ToTable("Rimborsi");
entity.Property(e => e.Importo).HasPrecision(18, 2);
entity.HasOne(e => e.Dipendente)
.WithMany(d => d.Rimborsi)
.HasForeignKey(e => e.DipendenteId)
.OnDelete(DeleteBehavior.Cascade);
});
// Cliente
modelBuilder.Entity<Cliente>(entity =>
{

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,201 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Zentral.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPersonaleModule : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Dipendenti",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nome = table.Column<string>(type: "TEXT", nullable: false),
Cognome = table.Column<string>(type: "TEXT", nullable: false),
CodiceFiscale = table.Column<string>(type: "TEXT", nullable: true),
Email = table.Column<string>(type: "TEXT", nullable: true),
Telefono = table.Column<string>(type: "TEXT", nullable: true),
Indirizzo = table.Column<string>(type: "TEXT", nullable: true),
DataNascita = table.Column<DateTime>(type: "TEXT", nullable: true),
Ruolo = table.Column<string>(type: "TEXT", nullable: true),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Dipendenti", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Assenze",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DipendenteId = table.Column<int>(type: "INTEGER", nullable: false),
DataInizio = table.Column<DateTime>(type: "TEXT", nullable: false),
DataFine = table.Column<DateTime>(type: "TEXT", nullable: false),
TipoAssenza = table.Column<string>(type: "TEXT", nullable: false),
Stato = table.Column<string>(type: "TEXT", nullable: false),
Note = table.Column<string>(type: "TEXT", nullable: true),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Assenze", x => x.Id);
table.ForeignKey(
name: "FK_Assenze_Dipendenti_DipendenteId",
column: x => x.DipendenteId,
principalTable: "Dipendenti",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Contratti",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DipendenteId = table.Column<int>(type: "INTEGER", nullable: false),
DataInizio = table.Column<DateTime>(type: "TEXT", nullable: false),
DataFine = table.Column<DateTime>(type: "TEXT", nullable: true),
TipoContratto = table.Column<string>(type: "TEXT", nullable: false),
Livello = table.Column<string>(type: "TEXT", nullable: true),
RetribuzioneLorda = table.Column<decimal>(type: "TEXT", precision: 18, scale: 2, nullable: false),
Note = table.Column<string>(type: "TEXT", nullable: true),
Attivo = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Contratti", x => x.Id);
table.ForeignKey(
name: "FK_Contratti_Dipendenti_DipendenteId",
column: x => x.DipendenteId,
principalTable: "Dipendenti",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Pagamenti",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DipendenteId = table.Column<int>(type: "INTEGER", nullable: false),
DataPagamento = table.Column<DateTime>(type: "TEXT", nullable: false),
ImportoNetto = table.Column<decimal>(type: "TEXT", precision: 18, scale: 2, nullable: false),
Descrizione = table.Column<string>(type: "TEXT", nullable: false),
Pagato = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Pagamenti", x => x.Id);
table.ForeignKey(
name: "FK_Pagamenti_Dipendenti_DipendenteId",
column: x => x.DipendenteId,
principalTable: "Dipendenti",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Rimborsi",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DipendenteId = table.Column<int>(type: "INTEGER", nullable: false),
DataSpesa = table.Column<DateTime>(type: "TEXT", nullable: false),
Importo = table.Column<decimal>(type: "TEXT", precision: 18, scale: 2, nullable: false),
Descrizione = table.Column<string>(type: "TEXT", nullable: false),
Stato = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Rimborsi", x => x.Id);
table.ForeignKey(
name: "FK_Rimborsi_Dipendenti_DipendenteId",
column: x => x.DipendenteId,
principalTable: "Dipendenti",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Assenze_DipendenteId",
table: "Assenze",
column: "DipendenteId");
migrationBuilder.CreateIndex(
name: "IX_Contratti_DipendenteId",
table: "Contratti",
column: "DipendenteId");
migrationBuilder.CreateIndex(
name: "IX_Dipendenti_CodiceFiscale",
table: "Dipendenti",
column: "CodiceFiscale",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pagamenti_DipendenteId",
table: "Pagamenti",
column: "DipendenteId");
migrationBuilder.CreateIndex(
name: "IX_Rimborsi_DipendenteId",
table: "Rimborsi",
column: "DipendenteId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Assenze");
migrationBuilder.DropTable(
name: "Contratti");
migrationBuilder.DropTable(
name: "Pagamenti");
migrationBuilder.DropTable(
name: "Rimborsi");
migrationBuilder.DropTable(
name: "Dipendenti");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Zentral.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class RenamePersonaleToHR : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -940,6 +940,254 @@ namespace Zentral.Infrastructure.Migrations
b.ToTable("EventiDettaglioRisorse");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Assenza", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<string>("CustomFieldsJson")
.HasColumnType("TEXT");
b.Property<DateTime>("DataFine")
.HasColumnType("TEXT");
b.Property<DateTime>("DataInizio")
.HasColumnType("TEXT");
b.Property<int>("DipendenteId")
.HasColumnType("INTEGER");
b.Property<string>("Note")
.HasColumnType("TEXT");
b.Property<string>("Stato")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("TipoAssenza")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UpdatedBy")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("DipendenteId");
b.ToTable("Assenze", (string)null);
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Contratto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<bool>("Attivo")
.HasColumnType("INTEGER");
b.Property<DateTime?>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<string>("CustomFieldsJson")
.HasColumnType("TEXT");
b.Property<DateTime?>("DataFine")
.HasColumnType("TEXT");
b.Property<DateTime>("DataInizio")
.HasColumnType("TEXT");
b.Property<int>("DipendenteId")
.HasColumnType("INTEGER");
b.Property<string>("Livello")
.HasColumnType("TEXT");
b.Property<string>("Note")
.HasColumnType("TEXT");
b.Property<decimal>("RetribuzioneLorda")
.HasPrecision(18, 2)
.HasColumnType("TEXT");
b.Property<string>("TipoContratto")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UpdatedBy")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("DipendenteId");
b.ToTable("Contratti", (string)null);
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Dipendente", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CodiceFiscale")
.HasColumnType("TEXT");
b.Property<string>("Cognome")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime?>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<string>("CustomFieldsJson")
.HasColumnType("TEXT");
b.Property<DateTime?>("DataNascita")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<string>("Indirizzo")
.HasColumnType("TEXT");
b.Property<string>("Nome")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Ruolo")
.HasColumnType("TEXT");
b.Property<string>("Telefono")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UpdatedBy")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CodiceFiscale")
.IsUnique();
b.ToTable("Dipendenti", (string)null);
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Pagamento", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<string>("CustomFieldsJson")
.HasColumnType("TEXT");
b.Property<DateTime>("DataPagamento")
.HasColumnType("TEXT");
b.Property<string>("Descrizione")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("DipendenteId")
.HasColumnType("INTEGER");
b.Property<decimal>("ImportoNetto")
.HasPrecision(18, 2)
.HasColumnType("TEXT");
b.Property<bool>("Pagato")
.HasColumnType("INTEGER");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UpdatedBy")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("DipendenteId");
b.ToTable("Pagamenti", (string)null);
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Rimborso", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("CreatedBy")
.HasColumnType("TEXT");
b.Property<string>("CustomFieldsJson")
.HasColumnType("TEXT");
b.Property<DateTime>("DataSpesa")
.HasColumnType("TEXT");
b.Property<string>("Descrizione")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("DipendenteId")
.HasColumnType("INTEGER");
b.Property<decimal>("Importo")
.HasPrecision(18, 2)
.HasColumnType("TEXT");
b.Property<string>("Stato")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UpdatedBy")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("DipendenteId");
b.ToTable("Rimborsi", (string)null);
});
modelBuilder.Entity("Zentral.Domain.Entities.Location", b =>
{
b.Property<int>("Id")
@@ -3697,6 +3945,50 @@ namespace Zentral.Infrastructure.Migrations
b.Navigation("Risorsa");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Assenza", b =>
{
b.HasOne("Zentral.Domain.Entities.HR.Dipendente", "Dipendente")
.WithMany("Assenze")
.HasForeignKey("DipendenteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dipendente");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Contratto", b =>
{
b.HasOne("Zentral.Domain.Entities.HR.Dipendente", "Dipendente")
.WithMany("Contratti")
.HasForeignKey("DipendenteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dipendente");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Pagamento", b =>
{
b.HasOne("Zentral.Domain.Entities.HR.Dipendente", "Dipendente")
.WithMany("Pagamenti")
.HasForeignKey("DipendenteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dipendente");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Rimborso", b =>
{
b.HasOne("Zentral.Domain.Entities.HR.Dipendente", "Dipendente")
.WithMany("Rimborsi")
.HasForeignKey("DipendenteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dipendente");
});
modelBuilder.Entity("Zentral.Domain.Entities.ModuleSubscription", b =>
{
b.HasOne("Zentral.Domain.Entities.AppModule", "Module")
@@ -4219,6 +4511,17 @@ namespace Zentral.Infrastructure.Migrations
b.Navigation("DettagliRisorse");
});
modelBuilder.Entity("Zentral.Domain.Entities.HR.Dipendente", b =>
{
b.Navigation("Assenze");
b.Navigation("Contratti");
b.Navigation("Pagamenti");
b.Navigation("Rimborsi");
});
modelBuilder.Entity("Zentral.Domain.Entities.Location", b =>
{
b.Navigation("Eventi");