create invoice component

This commit is contained in:
zzdrojewskipaw
2025-11-27 23:52:32 +01:00
parent 2b7ed3e451
commit 437d6d8f42
14 changed files with 624 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ namespace BimAI.Infrastructure.Data;
public class BimAIDbContext(DbContextOptions<BimAIDbContext> options) : DbContext(options)
{
public DbSet<Product> Products { get; set; }
public DbSet<Invoice> Invoices { get; set; }
public DbSet<SyncState> SyncStates { get; set; }
public DbSet<User> Users { get; set; }
@@ -20,6 +21,21 @@ public class BimAIDbContext(DbContextOptions<BimAIDbContext> options) : DbContex
modelBuilder.Entity<Product>().Property(x => x.Ean).IsRequired().HasMaxLength(50);
modelBuilder.Entity<Product>().Property(x => x.StockAddresses).IsRequired().HasMaxLength(512);
// Invoice properties
modelBuilder.Entity<Invoice>().HasKey(x => x.Id);
modelBuilder.Entity<Invoice>().Property(x => x.DocumentNo).IsRequired().HasMaxLength(100);
modelBuilder.Entity<Invoice>().Property(x => x.Type).IsRequired().HasMaxLength(50);
modelBuilder.Entity<Invoice>().Property(x => x.ClientName).IsRequired().HasMaxLength(255);
modelBuilder.Entity<Invoice>().Property(x => x.ClientId).HasMaxLength(100);
modelBuilder.Entity<Invoice>().Property(x => x.ClientNip).HasMaxLength(50);
modelBuilder.Entity<Invoice>().Property(x => x.ClientAddress).HasMaxLength(500);
modelBuilder.Entity<Invoice>().Property(x => x.Currency).IsRequired().HasMaxLength(10);
modelBuilder.Entity<Invoice>().Property(x => x.Source).IsRequired().HasMaxLength(50);
modelBuilder.Entity<Invoice>().Property(x => x.TotalNetto).HasPrecision(18, 2);
modelBuilder.Entity<Invoice>().Property(x => x.TotalBrutto).HasPrecision(18, 2);
modelBuilder.Entity<Invoice>().Property(x => x.TotalVat).HasPrecision(18, 2);
modelBuilder.Entity<Invoice>().HasIndex(x => new { x.DocumentNo, x.Source }).IsUnique().HasDatabaseName("IX_Invoices_DocumentNo_Source");
// SyncState properties
modelBuilder.Entity<SyncState>().HasKey((x => x.Entity));