add estimation date

This commit is contained in:
Martijn Scheepers
2023-02-22 12:18:01 +01:00
parent 387b001fdf
commit 1023bcc32f
7 changed files with 52 additions and 6 deletions

View File

@@ -338,6 +338,7 @@ namespace Manut_Test_Blazor.Data
{
EstimationCode = item.Prodid.TrimEnd().ReplaceLineEndings(),
Description = item.Desc.TrimEnd(),
Date = DateOnly.FromDateTime(item.Regdate),
};
_partsdbContext.Estimations.Add(estimation);
}

View File

@@ -77,7 +77,7 @@ namespace Manut_Test_Blazor.Data
CustomerCode = item.Customercode?.TrimEnd(),
Name = item.Name?.TrimEnd(),
Street = CleanUpRecord(item.Street)?.Replace(" ", ""),
Zipcode = CleanUpRecord(item.Zipcode),
Zipcode = CleanUpRecord(item.Zipcode)?.Replace(" ", ""),
City = CleanUpRecord(item.City),
Country = CleanUpRecord(item.Country),
};

View File

@@ -15,6 +15,9 @@ namespace PartsDB.models.DB
[MaxLength(100)]
public string Description { get; set; } = string.Empty;
[Required]
public DateOnly Date { get; set; }
public ICollection<Part>? PartsList { get; set; }
}

View File

@@ -12,13 +12,35 @@ namespace PartsDB.models.DB
[ForeignKey("MainProductId")]
public virtual Product? MainProduct { get; set; }
public Product? MainProduct { get; set; }
[ForeignKey("PartProductId")]
public virtual Product? PartProduct { get; set; }
public Product? PartProduct { get; set; }
[ForeignKey("EstimationId")]
public virtual Estimation? Estimation { get; set; }
public Estimation? Estimation { get; set; }
public decimal? TotalPriceEx()
{
return PartProduct?.MainVendor?.Price * Quantity;
}
public decimal? PriceInc()
{
if (PartProduct?.ProfitMargin != 0)
{
return ((PartProduct?.MainVendor?.Price * PartProduct?.ProfitMargin) / 100) + PartProduct?.MainVendor?.Price;
}
else
{
return PartProduct?.MainVendor?.Price;
}
}
public decimal? TotalPriceInc()
{
return PriceInc() * Quantity;
}
}
}

View File

@@ -66,9 +66,13 @@ namespace PartsDB.models.DB
.OnDelete(DeleteBehavior.Cascade);
entity.Navigation(b => b.PartsList);
entity.HasMany(d => d.PartOfList).WithOne();
entity.HasMany(d => d.PartOfList)
.WithOne();
entity.Navigation(b => b.PartOfList);
//entity.HasMany(e => e.Estimations)
// .WithOne(e => e.Estimation.);
entity.HasOne(d => d.Brand)
.WithMany(b => b.Products)
.HasForeignKey("BrandId");
@@ -113,6 +117,8 @@ namespace PartsDB.models.DB
.HasMaxLength(100)
.HasColumnName("Description");
entity.Property(e => e.Date).HasColumnName("Date");
entity.HasMany(p => p.PartsList)
.WithOne(p => p.Estimation)
.OnDelete(DeleteBehavior.Cascade);
@@ -138,6 +144,7 @@ namespace PartsDB.models.DB
entity.HasOne(d => d.Estimation)
.WithMany(b => b.PartsList)
.HasForeignKey("EstimationId");
});

View File

@@ -25,6 +25,13 @@ namespace PartsDB.models.DB
public bool Obsolete { get; set; }
public int? ProductGroupLevel0Id { get; set; }
public int? ProductGroupLevel1Id { get; set; }
public int? ProductGroupLevel2Id { get; set; }
[ForeignKey("PackUnitId")]
public PackUnit? PackUnit { get; set; }
@@ -49,10 +56,13 @@ namespace PartsDB.models.DB
public ICollection<Part>? PartOfList { get; set; }
//public ICollection<Part>? Estimations { get; set; }
public ICollection<Serial>? Serials { get; set; }
[NotMapped]
public ProductVendor? MainVendor => ProductVendors?.Where(m => m.IsMainVendor == true).SingleOrDefault();
}
}

View File

@@ -19,10 +19,13 @@ namespace PartsDB.models.DB
public ICollection<ProductGroup>? Childeren { get; }
public ProductGroup? SelectedChild => Childeren?.Where(c => c.Id == c.Parent?.Id).SingleOrDefault();
public ICollection<Product>? Products { get; }
public ICollection<Product>? ProductsLevel0 { get; }
public ICollection<Product>? ProductsLevel1 { get; }
public ICollection<Product>? ProductsLevel2 { get; }