improvements, fixes, etc...

This commit is contained in:
Loretta 2025-10-16 11:43:46 +02:00
parent d93cb107b6
commit f145dfcd70
12 changed files with 50 additions and 53 deletions

View File

@ -34,10 +34,32 @@ public class ProductDto : MgProductDto, IProductDto
get => CommonHelper.To<bool>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))?.Value ?? "false"); get => CommonHelper.To<bool>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))?.Value ?? "false");
set set
{ {
throw new Exception($"ProductDto.IsMeasurable not set");
//Direkt legyen exception! - J. //Direkt legyen exception! - J.
var ga = GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))!; var ga = GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))!;
ga.Value = value.ToString(); ga.Value = value.ToString();
} }
}
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public double Tare
{
get => CommonHelper.To<double>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(ITare.Tare))?.Value ?? "0");
set => throw new Exception($"ProductDto.Tare not set");
}
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public double NetWeight
{
get => CommonHelper.To<double>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
set => throw new Exception($"ProductDto.NetWeight not set");
}
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public int IncomingQuantity
{
get => CommonHelper.To<int>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IIncomingQuantity.IncomingQuantity))?.Value ?? "0");
set => throw new Exception($"ProductDto.IncomingQuantity not set");
} }
} }

View File

@ -8,6 +8,7 @@ using Nop.Core.Domain.Orders;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Catalog;
using DataType = LinqToDB.DataType; using DataType = LinqToDB.DataType;
using FruitBank.Common.Dtos;
namespace FruitBank.Common.Entities; namespace FruitBank.Common.Entities;
@ -56,8 +57,8 @@ public class ShippingItem : MgEntityBase, IShippingItem
[LinqToDB.Mapping.Association(ThisKey = nameof(PalletId), OtherKey = nameof(Pallet.Id), CanBeNull = true)] [LinqToDB.Mapping.Association(ThisKey = nameof(PalletId), OtherKey = nameof(Pallet.Id), CanBeNull = true)]
public Pallet? Pallet { get; set; } public Pallet? Pallet { get; set; }
[LinqToDB.Mapping.Association(ThisKey = nameof(ProductId), OtherKey = nameof(Product.Id), CanBeNull = true)] [LinqToDB.Mapping.Association(ThisKey = nameof(ProductId), OtherKey = nameof(ProductDto.Id), CanBeNull = true)]
public Product? Product { get; set; } public ProductDto? ProductDto { get; set; }
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingDocument.Id), CanBeNull = true)] [LinqToDB.Mapping.Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingDocument.Id), CanBeNull = true)]
public ShippingDocument? ShippingDocument { get; set; } public ShippingDocument? ShippingDocument { get; set; }

View File

@ -0,0 +1,6 @@
namespace FruitBank.Common.Interfaces;
public interface IIncomingQuantity
{
int IncomingQuantity { get; set; }
}

View File

@ -2,7 +2,6 @@
namespace FruitBank.Common.Interfaces; namespace FruitBank.Common.Interfaces;
public interface IProductDto : IMgProductDto, IMeasurable public interface IProductDto : IMgProductDto, IMeasurable, ITare, IIncomingQuantity, IMeasuringNetWeight
{ {
} }

View File

@ -1,5 +1,6 @@
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using FruitBank.Common.Dtos;
using FruitBank.Common.Entities; using FruitBank.Common.Entities;
using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Catalog;
@ -24,7 +25,7 @@ public interface IShippingItem : IEntityInt, ITimeStampInfo, IMeasurable, IMeasu
double MeasuredNetWeight { get; set; } double MeasuredNetWeight { get; set; }
double MeasuredGrossWeight { get; set; } double MeasuredGrossWeight { get; set; }
public Product? Product { get; set; } public ProductDto? ProductDto { get; set; }
public ShippingDocument? ShippingDocument { get; set; } public ShippingDocument? ShippingDocument { get; set; }
public List<ShippingItemPallet>? ShippingItemPallets { get; set; } public List<ShippingItemPallet>? ShippingItemPallets { get; set; }

View File

@ -150,7 +150,7 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsNotNull(shippingItems); Assert.IsNotNull(shippingItems);
Assert.IsTrue(shippingItems.Count != 0); Assert.IsTrue(shippingItems.Count != 0);
Assert.IsTrue(shippingItems.All(si => si.Product?.Id == si.ProductId), "shippingItem.Product == null"); Assert.IsTrue(shippingItems.All(si => si.ProductDto?.Id == si.ProductId), "shippingItem.Product == null");
Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.GrossWeight) == x.MeasuredGrossWeight)); Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.GrossWeight) == x.MeasuredGrossWeight));
Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.NetWeight) == x.MeasuredNetWeight)); Assert.IsTrue(shippingItems.All(x => x.ShippingItemPallets!.Where(sp => sp.IsMeasured).Sum(sp => sp.NetWeight) == x.MeasuredNetWeight));
@ -159,7 +159,7 @@ namespace FruitBankHybrid.Shared.Tests
{ {
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(shippingItem.ProductId!.Value); var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(shippingItem.ProductId!.Value);
Assert.IsTrue(measuringProductDto!.Quantity == shippingItem.Product!.StockQuantity); Assert.IsTrue(measuringProductDto!.Quantity == shippingItem.ProductDto!.StockQuantity);
var shippingItemSumQnty = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredQuantity); var shippingItemSumQnty = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredQuantity);
Assert.IsTrue(shippingItemSumQnty == measuringProductDto.Quantity, $"{shippingItem}; shippingItemSum Quantity: {shippingItemSumQnty} == {measuringProductDto.Quantity}"); Assert.IsTrue(shippingItemSumQnty == measuringProductDto.Quantity, $"{shippingItem}; shippingItemSum Quantity: {shippingItemSumQnty} == {measuringProductDto.Quantity}");
@ -196,7 +196,7 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsNotNull(shippingItem, $"shippingItemId: {shippingItemId}"); Assert.IsNotNull(shippingItem, $"shippingItemId: {shippingItemId}");
if (shippingItem.IsMeasurable) Assert.IsNotNull(shippingItem.Pallet, $"shippingItem.Pallet == null; shippingItem.PalletId: {shippingItem.PalletId}"); if (shippingItem.IsMeasurable) Assert.IsNotNull(shippingItem.Pallet, $"shippingItem.Pallet == null; shippingItem.PalletId: {shippingItem.PalletId}");
Assert.IsNotNull(shippingItem.Product, $"shippingItem.Product == null; shippingItem.ProductId: {shippingItem.ProductId}"); Assert.IsNotNull(shippingItem.ProductDto, $"shippingItem.Product == null; shippingItem.ProductId: {shippingItem.ProductId}");
Assert.IsTrue(shippingItem.Id == shippingItemId); Assert.IsTrue(shippingItem.Id == shippingItemId);
Assert.IsTrue(shippingItem.QuantityOnDocument > 0, "QuantityOnDocument == 0"); Assert.IsTrue(shippingItem.QuantityOnDocument > 0, "QuantityOnDocument == 0");
@ -272,7 +272,7 @@ namespace FruitBankHybrid.Shared.Tests
shippingItem = await _signalRClient.GetShippingItemById(shippingItemPallet.ShippingItemId); shippingItem = await _signalRClient.GetShippingItemById(shippingItemPallet.ShippingItemId);
Assert.IsNotNull(shippingItem); Assert.IsNotNull(shippingItem);
Assert.IsNotNull(shippingItem.Product); Assert.IsNotNull(shippingItem.ProductDto);
Assert.IsNotNull(shippingItem.ShippingItemPallets); Assert.IsNotNull(shippingItem.ShippingItemPallets);
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable); Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
@ -298,7 +298,7 @@ namespace FruitBankHybrid.Shared.Tests
} }
Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity); Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity);
Assert.IsTrue(shippingItem.Product.StockQuantity == originalShippingItem.Product!.StockQuantity + incQuantity); Assert.IsTrue(shippingItem.ProductDto.StockQuantity == originalShippingItem.ProductDto!.StockQuantity + incQuantity);
var measuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable); var measuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable);
Assert.IsTrue(measuringProductDto.StockQuantity == originalMeasuringProductDto.StockQuantity + incQuantity); Assert.IsTrue(measuringProductDto.StockQuantity == originalMeasuringProductDto.StockQuantity + incQuantity);

View File

@ -62,7 +62,7 @@ public sealed class OrderClientTests
[TestMethod] [TestMethod]
[DataRow(new[] {1,2,4,7})] [DataRow(new[] {1,2,4,7})]
public async Task GetOrderDtoById(int[] orderIds) public async Task GetOrderDtoByIds(int[] orderIds)
{ {
var orderDtoList = await _signalRClient.GetAllOrderDtoByIds(orderIds); var orderDtoList = await _signalRClient.GetAllOrderDtoByIds(orderIds);

View File

@ -107,11 +107,11 @@
</h3> </h3>
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100"> <DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
<DxFormLayoutItem Context="dfsdf" ColSpanMd="12"> <DxFormLayoutItem Context="ctxShippingItemFromLayoutItem" ColSpanMd="12">
@for (var index = 0; index < SelectedShippingItem.ShippingItemPallets!.Count; index++) @for (var index = 0; index < (SelectedShippingItem?.ShippingItemPallets?.Count ?? 0); index++)
{ {
var localI = index + 1; var localI = index + 1;
var currentShippingItemPallet = SelectedShippingItem.ShippingItemPallets![index]; var currentShippingItemPallet = SelectedShippingItem!.ShippingItemPallets![index];
<PalletItemComponent IsMeasurable="@SelectedShippingItem.IsMeasurable" <PalletItemComponent IsMeasurable="@SelectedShippingItem.IsMeasurable"
MeasuringIndex="@localI" MeasuringIndex="@localI"

View File

@ -94,14 +94,16 @@ namespace FruitBankHybrid.Shared.Pages
MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(shippingItem); MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(shippingItem);
//_logger.Info($"{shippingItem.ProductDto?.Tare}");
shippingItem.ShippingItemPallets ??= new List<ShippingItemPallet>(shippingItem.PalletsOnDocument); shippingItem.ShippingItemPallets ??= new List<ShippingItemPallet>(shippingItem.PalletsOnDocument);
if (shippingItem.ShippingItemPallets.Count >= shippingItem.PalletsOnDocument) return; //if (shippingItem.ShippingItemPallets.Count >= shippingItem.PalletsOnDocument) return;
for (var i = shippingItem.ShippingItemPallets.Count; i < shippingItem.PalletsOnDocument; i++) for (var i = shippingItem.ShippingItemPallets.Count; i < shippingItem.PalletsOnDocument; i++)
shippingItem.ShippingItemPallets.Add(new ShippingItemPallet shippingItem.ShippingItemPallets.Add(new ShippingItemPallet
{ {
ShippingItemId = shippingItem.Id, ShippingItemId = shippingItem.Id,
PalletWeight = shippingItem.Pallet?.Weight ?? 0, PalletWeight = shippingItem.Pallet?.Weight ?? 0,
TareWeight = shippingItem.ProductDto?.Tare?? 0,
CreatorId = LoggedInModel.CustomerDto?.Id, CreatorId = LoggedInModel.CustomerDto?.Id,
ModifierId = LoggedInModel.CustomerDto?.Id ModifierId = LoggedInModel.CustomerDto?.Id

View File

@ -104,12 +104,12 @@
//text = ((OrderItemPallet)(context.DataItem)).OrderItemId.ToString() + " dfgdfsg"; //text = ((OrderItemPallet)(context.DataItem)).OrderItemId.ToString() + " dfgdfsg";
//var selectedOrderItemDto = SelectedOrder!.OrderItemDtos.First(x => x.Id == orderItemPallet.OrderItemId); //var selectedOrderItemDto = SelectedOrder!.OrderItemDtos.First(x => x.Id == orderItemPallet.OrderItemId);
var selectedOrderItemDto = (OrderItemDto)(context.DataItem); var selectedOrderItemDto = (OrderItemDto)(context.DataItem);
<DxFormLayout Context="ctxFormLayout" Data="@selectedOrderItemDto" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))"> <DxFormLayout Context="ctxFormLayout" Data="@selectedOrderItemDto" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
<DxFormLayoutItem Context="ctxFormLayoutItem" ColSpanMd="12"> <DxFormLayoutItem Context="ctxFormLayoutItem" ColSpanMd="12">
@for (var index = 0; index < selectedOrderItemDto.OrderItemPallets!.Count; index++) @for (var index = 0; index < (selectedOrderItemDto?.OrderItemPallets?.Count ?? 0); index++)
{ {
var localI = index + 1; var localI = index + 1;
var currentOrderItemPallet = selectedOrderItemDto.OrderItemPallets![index]; var currentOrderItemPallet = selectedOrderItemDto!.OrderItemPallets![index];
<PalletItemComponent IsMeasurable="@selectedOrderItemDto.IsMeasurable" <PalletItemComponent IsMeasurable="@selectedOrderItemDto.IsMeasurable"
MeasuringIndex="@localI" MeasuringIndex="@localI"

View File

@ -80,41 +80,6 @@ namespace FruitBankHybrid.Shared.Pages
//SelectedOrderItem = eventArgs.DataItem?.OrderItemDtos?.FirstOrDefault(); //SelectedOrderItem = eventArgs.DataItem?.OrderItemDtos?.FirstOrDefault();
} }
protected bool BtnSaveEnabled { get; set; }
protected void OnItemUpdating(string fieldName, object newValue)
{
return;
}
protected void OnItemUpdating2(string fieldName, object newValue, OrderItemPallet orderItemPallet)
{
BtnSaveEnabled = false;
if (SelectedOrderItem == null) return;
switch (fieldName)
{
case nameof(OrderItemPallet.PalletWeight):
orderItemPallet.PalletWeight = (double)newValue;
break;
case nameof(OrderItemPallet.TareWeight):
orderItemPallet.TareWeight = (double)newValue;
break;
case nameof(OrderItemPallet.TrayQuantity):
orderItemPallet.TrayQuantity = (int)newValue;
break;
case nameof(OrderItemPallet.GrossWeight):
orderItemPallet.GrossWeight = (double)newValue;
break;
}
//MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(SelectedShippingItem);
//BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues() && shippingItemPallet.IsValidMeasuringValues(SelectedShippingItem.IsMeasurable);
}
private Task OnOrderItemPalletValueChanged(OrderItemPallet orderItemPallet, OrderItemDto selectedOrderItemDto) private Task OnOrderItemPalletValueChanged(OrderItemPallet orderItemPallet, OrderItemDto selectedOrderItemDto)
{ {
StateHasChanged(); StateHasChanged();

View File

@ -66,6 +66,7 @@ public class MeasuringService
{ {
OrderItemId = orderItemDto.Id, OrderItemId = orderItemDto.Id,
OrderItemDto = orderItemDto, OrderItemDto = orderItemDto,
TareWeight = orderItemDto.ProductDto?.Tare ?? 0,
CreatorId = customerDto?.Id, CreatorId = customerDto?.Id,
ModifierId = customerDto?.Id ModifierId = customerDto?.Id