* Added ItemCustPriceAll entity

This commit is contained in:
2025-08-22 07:13:47 +02:00
parent 8c646d4bc7
commit 764ba68f56
8 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class ItemCustPriceAllController(IItemCustPriceAllService service, IMapper mapper) : Controller
{
[HttpGet("by-parameters")]
public async Task<ActionResult<ItemCustPriceAllDto>> GetItemCustPriceAll(string itemCode, string customerDoInvoice)
{
var result = await service.GetItemCustPriceAllAsync(itemCode, customerDoInvoice);
if (result == null)
{
return NotFound();
}
return Ok(mapper.Map<ItemCustPriceAllDto>(result));
}
}

View File

@@ -107,6 +107,7 @@ builder.Services.AddScoped<ICustomerService, CustomerService>();
builder.Services.AddScoped<ICustomerTpService, CustomerTpService>();
builder.Services.AddScoped<IItemService, ItemService>();
builder.Services.AddScoped<IVatCodeAssociationService, VatCodeAssociationService>();
builder.Services.AddScoped<IItemCustPriceAllService, ItemCustPriceAllService>();
builder.Services.AddHostedService<TimedHostedService>();

View File

@@ -0,0 +1,39 @@
namespace SytelineSaAppEfDataModel.Dtos;
public class ItemCustPriceAllDto
{
public string SiteRef { get; set; }
public string Item { get; set; }
public string CustNum { get; set; }
public int CustItemSeq { get; set; }
public DateTime EffectDate { get; set; }
public decimal? ContPrice { get; set; }
public decimal? BrkQty1 { get; set; }
public decimal? BrkQty2 { get; set; }
public decimal? BrkQty3 { get; set; }
public decimal? BrkQty4 { get; set; }
public decimal? BrkQty5 { get; set; }
public decimal? BrkPrice1 { get; set; }
public decimal? BrkPrice2 { get; set; }
public decimal? BrkPrice3 { get; set; }
public decimal? BrkPrice4 { get; set; }
public decimal? BrkPrice5 { get; set; }
public string BaseCode1 { get; set; }
public string BaseCode2 { get; set; }
public string BaseCode3 { get; set; }
public string BaseCode4 { get; set; }
public string BaseCode5 { get; set; }
public string DolPercent1 { get; set; }
public string DolPercent2 { get; set; }
public string DolPercent3 { get; set; }
public string DolPercent4 { get; set; }
public string DolPercent5 { get; set; }
public bool NoteExistsFlag { get; set; }
public DateTime RecordDate { get; set; }
public Guid RowPointer { get; set; }
public string CreatedBy { get; set; }
public string UpdatedBy { get; set; }
public DateTime CreateDate { get; set; }
public bool InWorkflow { get; set; }
public bool IncludeTaxInPrice { get; set; }
}

View File

@@ -0,0 +1,39 @@
namespace SytelineSaAppEfDataModel.Entities;
public class ItemCustPriceAll
{
public string SiteRef { get; set; }
public string Item { get; set; }
public string CustNum { get; set; }
public int CustItemSeq { get; set; }
public DateTime EffectDate { get; set; }
public decimal? ContPrice { get; set; }
public decimal? BrkQty1 { get; set; }
public decimal? BrkQty2 { get; set; }
public decimal? BrkQty3 { get; set; }
public decimal? BrkQty4 { get; set; }
public decimal? BrkQty5 { get; set; }
public decimal? BrkPrice1 { get; set; }
public decimal? BrkPrice2 { get; set; }
public decimal? BrkPrice3 { get; set; }
public decimal? BrkPrice4 { get; set; }
public decimal? BrkPrice5 { get; set; }
public string BaseCode1 { get; set; }
public string BaseCode2 { get; set; }
public string BaseCode3 { get; set; }
public string BaseCode4 { get; set; }
public string BaseCode5 { get; set; }
public string DolPercent1 { get; set; }
public string DolPercent2 { get; set; }
public string DolPercent3 { get; set; }
public string DolPercent4 { get; set; }
public string DolPercent5 { get; set; }
public bool NoteExistsFlag { get; set; }
public DateTime RecordDate { get; set; }
public Guid RowPointer { get; set; }
public string CreatedBy { get; set; }
public string UpdatedBy { get; set; }
public DateTime CreateDate { get; set; }
public bool InWorkflow { get; set; }
public bool IncludeTaxInPrice { get; set; }
}

View File

@@ -30,6 +30,7 @@ namespace SytelineSaAppEfDataModel
CreateMap<CustomerTp, CustomerTpDto>().ReverseMap();
CreateMap<Item, ItemDto>().ReverseMap();
CreateMap<VatCodeAssociation, VatCodeAssociationDto>().ReverseMap();
CreateMap<ItemCustPriceAll, ItemCustPriceAllDto>().ReverseMap();
}
}
}

View File

@@ -0,0 +1,8 @@
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public interface IItemCustPriceAllService
{
Task<ItemCustPriceAllDto?> GetItemCustPriceAllAsync(string item, string customerNumber);
}

View File

@@ -0,0 +1,13 @@
using AutoMapper;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public class ItemCustPriceAllService(SytelineSaAppDbContext context, IMapper mapper) : IItemCustPriceAllService
{
public async Task<ItemCustPriceAllDto?> GetItemCustPriceAllAsync(string item, string customerNumber)
{
return await Task.FromResult(mapper.Map<ItemCustPriceAllDto?>(context.ItemCustPriceAlls
.OrderByDescending(x => x.EffectDate).FirstOrDefault(x => x.Item == item && x.CustNum == customerNumber)));
}
}

View File

@@ -29,6 +29,7 @@ namespace SytelineSaAppEfDataModel
public DbSet<CustomerTp> CustomerTps { get; set; }
public DbSet<Item> Items { get; set; }
public DbSet<VatCodeAssociation> VatCodeAssociations { get; set; }
public DbSet<ItemCustPriceAll> ItemCustPriceAlls { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -2299,6 +2300,174 @@ namespace SytelineSaAppEfDataModel
.HasMaxLength(200)
.IsRequired(false);
});
modelBuilder.Entity<ItemCustPriceAll>(entity =>
{
entity.ToTable("itemcustprice_all");
entity.HasKey(e => new { e.SiteRef, e.Item, e.CustNum, e.CustItemSeq, e.EffectDate });
entity.Property(e => e.SiteRef)
.HasColumnName("site_ref")
.HasMaxLength(16)
.IsRequired();
entity.Property(e => e.Item)
.HasColumnName("item")
.HasMaxLength(60)
.IsRequired();
entity.Property(e => e.CustNum)
.HasColumnName("cust_num")
.HasMaxLength(14)
.IsRequired();
entity.Property(e => e.CustItemSeq)
.HasColumnName("cust_item_seq")
.HasColumnType("int")
.IsRequired();
entity.Property(e => e.EffectDate)
.HasColumnName("effect_date")
.IsRequired();
entity.Property(e => e.ContPrice)
.HasColumnName("cont_price")
.IsRequired(false);
entity.Property(e => e.BrkQty1)
.HasColumnName("brk_qty##1")
.IsRequired(false);
entity.Property(e => e.BrkQty2)
.HasColumnName("brk_qty##2")
.IsRequired(false);
entity.Property(e => e.BrkQty3)
.HasColumnName("brk_qty##3")
.IsRequired(false);
entity.Property(e => e.BrkQty4)
.HasColumnName("brk_qty##4")
.IsRequired(false);
entity.Property(e => e.BrkQty5)
.HasColumnName("brk_qty##5")
.IsRequired(false);
entity.Property(e => e.BrkPrice1)
.HasColumnName("brk_price##1")
.IsRequired(false);
entity.Property(e => e.BrkPrice2)
.HasColumnName("brk_price##2")
.IsRequired(false);
entity.Property(e => e.BrkPrice3)
.HasColumnName("brk_price##3")
.IsRequired(false);
entity.Property(e => e.BrkPrice4)
.HasColumnName("brk_price##4")
.IsRequired(false);
entity.Property(e => e.BrkPrice5)
.HasColumnName("brk_price##5")
.IsRequired(false);
entity.Property(e => e.BaseCode1)
.HasColumnName("base_code##1")
.HasMaxLength(2)
.IsRequired(false);
entity.Property(e => e.BaseCode2)
.HasColumnName("base_code##2")
.HasMaxLength(2)
.IsRequired(false);
entity.Property(e => e.BaseCode3)
.HasColumnName("base_code##3")
.HasMaxLength(2)
.IsRequired(false);
entity.Property(e => e.BaseCode4)
.HasColumnName("base_code##4")
.HasMaxLength(2)
.IsRequired(false);
entity.Property(e => e.BaseCode5)
.HasColumnName("base_code##5")
.HasMaxLength(2)
.IsRequired(false);
entity.Property(e => e.DolPercent1)
.HasColumnName("dol_percent##1")
.HasMaxLength(1)
.IsRequired(false);
entity.Property(e => e.DolPercent2)
.HasColumnName("dol_percent##2")
.HasMaxLength(1)
.IsRequired(false);
entity.Property(e => e.DolPercent3)
.HasColumnName("dol_percent##3")
.HasMaxLength(1)
.IsRequired(false);
entity.Property(e => e.DolPercent4)
.HasColumnName("dol_percent##4")
.HasMaxLength(1)
.IsRequired(false);
entity.Property(e => e.DolPercent5)
.HasColumnName("dol_percent##5")
.HasMaxLength(1)
.IsRequired(false);
entity.Property(e => e.NoteExistsFlag)
.HasColumnName("NoteExistsFlag")
.HasColumnType("tinyint")
.IsRequired();
entity.Property(e => e.RecordDate)
.HasColumnName("RecordDate")
.IsRequired();
entity.Property(e => e.RowPointer)
.HasColumnName("RowPointer")
.HasColumnType("uniqueidentifier")
.IsRequired();
entity.Property(e => e.CreatedBy)
.HasColumnName("CreatedBy")
.HasMaxLength(60)
.IsRequired();
entity.Property(e => e.UpdatedBy)
.HasColumnName("UpdatedBy")
.HasMaxLength(60)
.IsRequired();
entity.Property(e => e.CreateDate)
.HasColumnName("CreateDate")
.IsRequired();
entity.Property(e => e.InWorkflow)
.HasColumnName("InWorkflow")
.HasColumnType("tinyint")
.IsRequired();
entity.Property(e => e.IncludeTaxInPrice)
.HasColumnName("include_tax_in_price")
.HasColumnType("tinyint")
.IsRequired();
// Index
entity.HasIndex(e => new { e.RowPointer, e.SiteRef })
.HasDatabaseName("IX_itemcustprice_all_RowPointer")
.IsUnique();
});
}
}
}