improvements, fixes, etc...

This commit is contained in:
Loretta 2025-10-09 07:29:33 +02:00
parent dc249b8ef4
commit a74b356e70
10 changed files with 247 additions and 88 deletions

View File

@ -10,25 +10,36 @@ namespace FruitBank.Common.Entities;
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemPalletDbTableName)]
public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
{
private double _palletWeight;
private double _grossWeight;
public int ShippingItemId { get; set; }
[Column(DataType = DataType.DecFloat)]
public double PalletWeight { get; set; }
public double PalletWeight
{
get => _palletWeight;
set => _palletWeight = double.Round(value, 1);
}
//[Nullable]
//[Column(CanBeNull = true)]
[Range(1, 100000, ErrorMessage = "The Quantity value should be a number between 1 and 100,000.")]
public int Quantity { get; set; }
//[Nullable]
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
[Range(1, 100000, ErrorMessage = "The NetWeight value should be a number between 1 and 100,000.")]
public double NetWeight { get; set; }
[NotColumn]
//[Column(DataType = DataType.DecFloat, CanBeNull = false)]
//[Range(1, 100000, ErrorMessage = "The NetWeight value should be a number between 1 and 100,000.")]
public double NetWeight => double.Round(GrossWeight - PalletWeight, 1);
//[Nullable]
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
[Range(1, 100000, ErrorMessage = "The GrossWeight value should be a number between 1 and 100,000.")]
public double GrossWeight { get; set; }
public double GrossWeight
{
get => _grossWeight;
set => _grossWeight = double.Round(value, 1);
}
public bool IsMeasured { get; set; }
@ -43,8 +54,33 @@ public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
/// <summary>
/// Nem lehet nullánál kisebb "Weight" érték és a ShippingId, Quantity nagyobb mint nulla! Megengedőbb mint az IsValidMeasuringValues(bool isMeasurable)...
/// </summary>
/// <returns></returns>
public bool IsValidSafeMeasuringValues()
{
return ShippingItemId > 0 && Quantity > 0 && PalletWeight >= 0 && NetWeight >= 0 && GrossWeight >= 0;
}
/// <summary>
/// "Szigorúbb" mint az IsValidSafeMeasuringValues()
/// </summary>
/// <param name="isMeasurable"></param>
/// <returns></returns>
public bool IsValidMeasuringValues(bool isMeasurable)
{
return ShippingItemId > 0 && PalletWeight >= 0 && Quantity > 0 && (!isMeasurable || (NetWeight > 0 && GrossWeight > 0));
return ShippingItemId > 0 && Quantity > 0 &&
((!isMeasurable && NetWeight == 0 && GrossWeight == 0 && PalletWeight == 0) || (isMeasurable && NetWeight > 0 && GrossWeight > 0 && PalletWeight >= 0));
}
public bool IsMeasuredAndValid(bool isMeasurable)
{
return Id > 0 && IsMeasured && IsValidMeasuringValues(isMeasurable);
}
public override string ToString()
{
return $"{base.ToString()} [ShippingItemId: {ShippingItemId}; IsMeasured: {IsMeasured}; PalletWeight: {PalletWeight}; Quantity: {Quantity}; NetWeight: {NetWeight}; GrossWeight: {GrossWeight}]";
}
}

View File

@ -34,6 +34,7 @@ public interface IFruitBankDataControllerCommon
#region ShippingItemPallet
public Task<ShippingItemPallet?> AddShippingItemPallet(ShippingItemPallet shippingItemPallet);
public Task<ShippingItemPallet?> UpdateShippingItemPallet(ShippingItemPallet shippingItemPallet);
public Task<ShippingItem?> AddOrUpdateMeasuredShippingItemPallets(List<ShippingItemPallet> shippingItemPallets);
#endregion ShippingItemPallet
#region ShippingDocument

View File

@ -1,6 +1,10 @@
namespace FruitBank.Common.Interfaces;
public interface IMeasuringValues : IMeasuringWeights
public interface IMeasuringValues : IMeasuringWeights, IMeasuringQuantity
{
}
public interface IMeasuringQuantity
{
int Quantity { get; set; }
}

View File

@ -1,7 +1,15 @@
namespace FruitBank.Common.Interfaces;
public interface IMeasuringWeights
public interface IMeasuringWeights : IMeasuringGrossWeight, IMeasuringNetWeight
{
}
public interface IMeasuringNetWeight
{
double NetWeight { get; set; }
}
public interface IMeasuringGrossWeight
{
double GrossWeight { get; set; }
}

View File

@ -4,7 +4,7 @@ using FruitBank.Common.Entities;
namespace FruitBank.Common.Interfaces;
public interface IShippingItemPallet : IEntityInt, IMeasuringValues, ITimeStampInfo
public interface IShippingItemPallet : IEntityInt, IMeasuringGrossWeight, IMeasuringQuantity, ITimeStampInfo
{
int ShippingItemId { get; set; }

View File

@ -42,6 +42,7 @@ public class SignalRTags : AcSignalRTags
public const int AddShippingItemPallet = 95;
public const int UpdateShippingItemPallet = 96;
public const int AddOrUpdateMeasuredShippingItemPallets = 97;
public const int AuthenticateUser = 160;
public const int RefreshToken = 200;

View File

@ -9,6 +9,8 @@ using FruitBank.Common.Loggers;
using FruitBankHybrid.Shared.Services.SignalRs;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices.JavaScript;
using System.Security.Cryptography.X509Certificates;
// ReSharper disable CompareOfFloatsByEqualityOperator
namespace FruitBankHybrid.Shared.Tests
@ -148,7 +150,25 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsNotNull(shippingItems);
Assert.IsTrue(shippingItems.Count != 0);
Assert.IsTrue(shippingItems.All(si=>si.Product?.Id == si.ProductId), "shippingItem.Product == null");
Assert.IsTrue(shippingItems.All(si => si.Product?.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.NetWeight) == x.MeasuredNetWeight));
foreach (var shippingItem in shippingItems.ToList())
{
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(shippingItem.ProductId!.Value);
Assert.IsTrue(measuringProductDto!.Quantity == shippingItem.Product!.StockQuantity);
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}");
var shippingItemSumWeight = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredNetWeight);
Assert.IsTrue(shippingItemSumWeight == measuringProductDto!.NetWeight, $"{shippingItem}; shippingItemSum NetWeight: {shippingItemSumWeight} == {measuringProductDto.NetWeight}");
shippingItemSumWeight = shippingItems.Where(x => x.IsMeasured && x.Id == shippingItem.Id).Sum(x => x.MeasuredGrossWeight);
Assert.IsTrue(shippingItemSumWeight == measuringProductDto.GrossWeight, $"{shippingItem}; shippingItemSum GrossWeight: {shippingItemSumWeight} == {measuringProductDto.GrossWeight}");
}
}
[TestMethod]
@ -174,7 +194,8 @@ namespace FruitBankHybrid.Shared.Tests
var shippingItem = await _signalRClient.GetShippingItemById(shippingItemId);
Assert.IsNotNull(shippingItem, $"shippingItemId: {shippingItemId}");
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.IsTrue(shippingItem.Id == shippingItemId);
@ -186,14 +207,17 @@ namespace FruitBankHybrid.Shared.Tests
}
[DataTestMethod]
[DataRow(1, -1, -2.137563300001, -3.75238200001)]
[DataRow(1, -1, -2.137563300001, -333.75238200001)]
[DataRow(1, 1, 2.137563300001, 3.75238200001)]
[DataRow(2, -1, -2.137563300001, 3.75238200001)]
[DataRow(3, 1, 2.137563300001, -3.75238200001)]
[DataRow(1, 1, 20.137563300001, 3.75238200001)]
[DataRow(2, -1, -20.137563300001, 3.75238200001)]
[DataRow(2, -1, 20.137563300001, 3.75238200001)]
[DataRow(3, 1, 2.137563300001, 1.75238200001)]
[DataRow(3, 1, 2.137563300001, 3.75238200001)]
[DataRow(4, -1, 2.137563300001, 3.75238200001)]
[DataRow(4, 13, 2.137563300001, 3.75238200001)]
[DataRow(5, 1, 2.137563300001, 3.75238200001)]
public async Task UpdateShippingItemTest(int shippingItemId, int incQuantity, double incNetWeight, double incGrossWeight)
[DataRow(5, -1, 2.137563300001, 3.75238200001)]
public async Task UpdateShippingItemTest(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight)
{
var originalShippingItem = await GetShippingItemByIdAsync(shippingItemId);
var originalMeasuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
@ -212,13 +236,24 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsNotNull(shippingItemPallet);
var nullResultIsValid = shippingItem.IsMeasured && !shippingItem.IsValidMeasuringValues();
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(originalMeasuringProductDto.IsMeasurable));
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
shippingItemPallet.Quantity += incQuantity;
shippingItemPallet.NetWeight += incNetWeight;
shippingItemPallet.GrossWeight += incGrossWeight;
shippingItemPallet.PalletWeight += incPalletWeight;
shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
if (!shippingItemPallet.IsValidMeasuringValues(originalMeasuringProductDto.IsMeasurable))
//A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
if (!originalMeasuringProductDto.IsMeasurable)
{
shippingItemPallet.GrossWeight = 0;
shippingItemPallet.PalletWeight = 0;
}
if (nullResultIsValid || !shippingItemPallet.IsValidSafeMeasuringValues())
{
Assert.IsNull(shippingItem);
return;
@ -226,26 +261,44 @@ namespace FruitBankHybrid.Shared.Tests
Assert.IsNotNull(shippingItem);
Assert.IsNotNull(shippingItem.Product);
Assert.IsNotNull(shippingItem.ShippingItemPallets);
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
//incNetWeight = double.Round(incNetWeight, 1);
//incGrossWeight = double.Round(incGrossWeight, 1);
incGrossWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
var incNetWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight - incPalletWeight, 1) : 0;
Assert.IsTrue(shippingItem.IsMeasured);
var isMeasuredPalletsCount = shippingItem.ShippingItemPallets!.Count(x => x.IsMeasured);
Assert.IsTrue(shippingItem.IsMeasured == (shippingItem.ShippingItemPallets!.All(x => x.IsMeasured) && shippingItem.MeasuringCount == isMeasuredPalletsCount));
if (shippingItem.IsMeasured)
{
Assert.IsTrue(shippingItem.IsValidMeasuringValues());
Assert.IsTrue(shippingItem.MeasuringCount == isMeasuredPalletsCount);
}
else
{
incQuantity = 0;
incNetWeight = 0;
incGrossWeight = 0;
Assert.IsTrue(shippingItem.MeasuringCount > isMeasuredPalletsCount);
}
Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity);
Assert.IsTrue(shippingItem.Product.StockQuantity == originalShippingItem.Product!.StockQuantity + incQuantity);
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
Assert.IsTrue(shippingItem.MeasuredQuantity == originalShippingItem.MeasuredQuantity + incQuantity);
var measuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, shippingItem.IsMeasurable);
Assert.IsTrue(measuringProductDto.StockQuantity == originalMeasuringProductDto.StockQuantity + incQuantity);
Assert.IsTrue(shippingItem.MeasuredNetWeight == double.Round(originalShippingItem.MeasuredNetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
Assert.IsTrue(shippingItem.MeasuredGrossWeight == double.Round(originalShippingItem.MeasuredGrossWeight + (shippingItem.IsMeasurable ? incGrossWeight : 0), 1));
Assert.IsTrue(measuringProductDto.NetWeight == double.Round(originalMeasuringProductDto.NetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
Assert.IsTrue(measuringProductDto.GrossWeight == double.Round(originalMeasuringProductDto.GrossWeight + (shippingItem.IsMeasurable ? incGrossWeight : 0), 1));
Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidSafeMeasuringValues()));
Assert.IsTrue(shippingItem.ShippingItemPallets!.All(x => x.IsValidMeasuringValues(shippingItem.IsMeasurable)));
Assert.IsTrue(shippingItem.MeasuredNetWeight == double.Round(originalShippingItem.MeasuredNetWeight + (shippingItem.IsMeasurable ? incNetWeight : 0), 1));
Assert.IsTrue(shippingItem.MeasuredGrossWeight == double.Round(originalShippingItem.MeasuredGrossWeight + (shippingItem.IsMeasurable ? incGrossWeight : 0), 1));
}
#endregion ShippingItem
@ -301,7 +354,7 @@ namespace FruitBankHybrid.Shared.Tests
shippingDocument = await GetShippingDocumentByIdAsync(shippingDocumentId);
Assert.IsTrue(shippingDocument.Country == newCountry);
Assert.IsTrue(shippingDocument!.ShippingDocumentToFiles?.FirstOrDefault()?.ShippingDocumentFile?.Id == 1);
Assert.IsTrue(shippingDocument.ShippingDocumentToFiles?.FirstOrDefault()?.ShippingDocumentFile?.Id == 1);
shippingDocument.Country = GetOriginalName(shippingDocument.Country);
await _signalRClient.UpdateShippingDocument(shippingDocument);
@ -363,6 +416,8 @@ namespace FruitBankHybrid.Shared.Tests
[DataRow(5, true)]
[DataRow(6, false)]
[DataRow(33, true)]
[DataRow(64, false)]
[DataRow(7, false)]
public async Task GetMeasuringProductDtoByIdTest(int productId, bool isMeasurableExcepted)
{
await GetMeasuringProductDtoByIdAsync(productId, isMeasurableExcepted);
@ -378,7 +433,7 @@ namespace FruitBankHybrid.Shared.Tests
else
{
Assert.IsTrue(measuringProductDto.Id > 0);
Assert.IsTrue(measuringProductDto.StockQuantity > 0);
Assert.IsTrue(measuringProductDto.StockQuantity >= 0);
Assert.IsTrue(measuringProductDto.NetWeight == 0);
Assert.IsTrue(measuringProductDto.GrossWeight == 0);

View File

@ -21,10 +21,10 @@
InputId="deDisabledDates">
<DayCellTemplate>
@{
var cssClass = GetCssClassNames(ctxShippingDate);
var cssClass = GetShippingDateCssClassNames(ctxShippingDate);
if (!cssClass.IsNullOrWhiteSpace())
{
<a class="@GetCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
<a class="@GetShippingDateCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
}
else
{
@ -94,15 +94,18 @@
</DxFormLayout>
</div>
<div style="margin-top: 100px;">
<div style="margin-top: 50px;">
@if (SelectedShippingItem != null)
{
<h3 style="margin-bottom: 30px;" class="@(SelectedShippingItem.IsMeasured && SelectedShippingItem.ShippingItemPallets!.All(x => x.IsMeasuredAndValid(SelectedShippingItem.IsMeasurable)) ? "text-success" : "")">
@SelectedShippingItem.Name</h3>
<EditForm Model="@SelectedShippingItem" Context="FrmContext"
OnValidSubmit="@HandleValidSubmit"
OnInvalidSubmit="@HandleInvalidSubmit">
@* <DataAnnotationsValidator /> *@
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))">
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="8" />
@* <DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="8" />
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.GrossWeightOnDocument)" Caption="GrossWeightOnDocument:" Enabled="false" ColSpanMd="3" />
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.NetWeightOnDocument)" Caption="NetWeightOnDocument:" Enabled="false" ColSpanMd="3" />
@ -134,49 +137,60 @@
Field="@nameof(ShippingItem.MeasuredGrossWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="MeasuredGrossWeight:" ColSpanMd="3">
</DxFormLayoutItem> *@
<DxFormLayoutItem Context="dfsdf" ColSpanMd="12">
@for (var index = 0; index < SelectedShippingItem.ShippingItemPallets!.Count; index++)
{
var localI = index + 1;
var currentShippingItemPallet = SelectedShippingItem.ShippingItemPallets![index];
<DxFormLayout Data="@currentShippingItemPallet" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating2(pair.Key, pair.Value, currentShippingItemPallet))">
<DxFormLayoutItem ColSpanMd="3" BeginRow="true">
<text>@(localI). Raklap</text>
</DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.PalletWeight), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.PalletWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rakl.súly(kg)" ColSpanMd="2" />
<DxFormLayoutItem ColSpanMd="1" />
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.Quantity), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.Quantity)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rekesz/csomag" ColSpanMd="2" />
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.GrossWeight), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.GrossWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Br.súly(kg)" ColSpanMd="2">
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Net.súly(kg)" ColSpanMd="2" CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.NetWeight), currentShippingItemPallet))">
<text>@(currentShippingItemPallet.NetWeight) kg.</text>
</DxFormLayoutItem>
@* <DxFormLayoutItem ColSpanMd="1">
<DxButton Text="@(currentShippingItemPallet.Id == 0 ? "Mentés" : "Módosítás")" Click="() => OnShippingItemPalletSaveClick(currentShippingItemPallet)" CssClass="w-100" />
</DxFormLayoutItem>
*@
</DxFormLayout>
}
</DxFormLayoutItem>
<br /><br />
@* <DxFormLayout CssClass="w-100">
<DxFormLayoutItem ColSpanMd="4" BeginRow="true">
<text>Raklap</text>
</DxFormLayoutItem>
</DxFormLayout
*@
@for (var index = 0; index < SelectedShippingItem!.ShippingItemPallets!.Count; index++)
{
var localI = index + 1;
var currentShippingItemPallet = SelectedShippingItem!.ShippingItemPallets![index];
<DxFormLayout Data="@currentShippingItemPallet" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating2(pair.Key, pair.Value, currentShippingItemPallet))">
<DxFormLayoutItem ColSpanMd="4" BeginRow="true">
<text>@(localI). Raklap</text>
</DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(ShippingitemPalletMeasuredAndValid(currentShippingItemPallet) ? "text-success" : (currentShippingItemPallet.NetWeight < 0 ? "text-danger" : ""))"
Field="@nameof(ShippingItemPallet.PalletWeight)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rakl.súly(kg):" ColSpanMd="1" />
<DxFormLayoutItem ColSpanMd="1"/>
<DxFormLayoutItem CaptionCssClass="@(ShippingitemPalletMeasuredAndValid(currentShippingItemPallet) ? "text-success" : (currentShippingItemPallet.Quantity < 0 ? "text-danger" : ""))"
Field="@nameof(ShippingItemPallet.Quantity)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rekesz/csomag:" ColSpanMd="1" />
<DxFormLayoutItem CaptionCssClass="@(ShippingitemPalletMeasuredAndValid(currentShippingItemPallet) ? "text-success" : (currentShippingItemPallet.NetWeight < 0 ? "text-danger" : ""))"
Field="@nameof(ShippingItemPallet.GrossWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Br.súly(kg):" ColSpanMd="1">
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="4">
@* <DxButton Text="@(currentShippingItemPallet.Id == 0 ? "Mentés" : "Módosítás")" Click="() => OnShippingItemPalletSaveClick(currentShippingItemPallet)" CssClass="w-100" /> *@
</DxFormLayoutItem>
<DxFormLayoutItem Context="vfdfgfd" ColSpanMd="12" BeginRow="true">
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem ColSpanMd="4" BeginRow="false"><strong>TOTAL:</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredQuantity) db.</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredGrossWeight) kg.</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredNetWeight) kg.</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="3" BeginRow="false" />
</DxFormLayout>
}
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<ValidationSummary />
@ -186,7 +200,7 @@
{
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<DxButton Text="@(SelectedShippingItem.IsMeasured ? "Befejezett mérés módosítása" : "Mérés befejezése")"
Enabled="BtnSaveEnabled || (BtnSaveEnabled && (SelectedShippingItem.ShippingItemPallets.All(x => ShippingitemPalletMeasuredAndValid(x, SelectedShippingItem.IsMeasurable))))"
Enabled="@BtnSaveEnabled"
SubmitFormOnClick="true" CssClass="w-100" />
</DxFormLayoutItem>
}
@ -202,7 +216,6 @@
</DxFormLayoutItem>
//_errorText = string.Empty;
}
</DxFormLayout>
</EditForm>
}

View File

@ -71,7 +71,7 @@ namespace FruitBankHybrid.Shared.Pages
private void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args)
=> args.IsDisabled = !_shippingDates.Exists(shippingDateModel => DaysEqual(shippingDateModel.DateTime, args.Date));
private string GetCssClassNames(DateTime date)
private string GetShippingDateCssClassNames(DateTime date)
{
if (_shippingDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
return "fw-bold text-danger";
@ -88,6 +88,42 @@ namespace FruitBankHybrid.Shared.Pages
private static bool DaysEqual(DateTime date1, DateTime date2)
=> (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
private string GetShippingPalletsCssClassNames(string fieldName, ShippingItemPallet shippingItemPallet)
{
//if (shippingItemPallet.NetWeight < 0) return "text-danger";
switch (fieldName)
{
case nameof(ShippingItemPallet.PalletWeight):
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
(shippingItemPallet.PalletWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
break;
case nameof(ShippingItemPallet.Quantity):
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
(shippingItemPallet.Quantity < 0 ? "text-danger" : "");
break;
case nameof(ShippingItemPallet.GrossWeight):
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
(shippingItemPallet.GrossWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
break;
case nameof(ShippingItemPallet.NetWeight):
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
(shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
break;
}
//if (_shippingDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
// return "fw-bold text-danger";
//if (_shippingDates.Exists(shipping => shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
// return "fw-bold text-success";
//if (_shippingDates.Exists(shipping => !shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
// return "fw-bold";
return string.Empty;
}
private void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs<Shipping> eventArgs)
{
SelectedShippingDocument = eventArgs.DataItem?.ShippingDocuments?.FirstOrDefault();
@ -157,8 +193,10 @@ namespace FruitBankHybrid.Shared.Pages
if (shippingItem != null && shippingItem.IsValidMeasuringValues())
{
BtnSaveEnabled = false;
shippingItem.ShippingItemPallets = shippingItem.ShippingItemPallets!.Where(x => x.IsValidMeasuringValues(shippingItem.IsMeasurable)).ToList();
var updatedShippingItem = await FruitBankSignalRClient.UpdateMeasuredShippingItem(shippingItem);
//var updatedShippingItem = await FruitBankSignalRClient.AddOrUpdateMeasuredShippingItemPallets(shippingItem.ShippingItemPallets!.Where(x => x.IsValidMeasuringValues(shippingItem.IsMeasurable)).ToList());
if (updatedShippingItem == null)
{
LogErrorAndDisplayText($"Sikertelen volt a shippingItem mentése! {shippingItem}");
@ -189,12 +227,8 @@ namespace FruitBankHybrid.Shared.Pages
}
private bool ShippingitemPalletMeasuredAndValid(ShippingItemPallet shippingItemPallet)
=> ShippingitemPalletMeasuredAndValid(shippingItemPallet, SelectedShippingItem!.IsMeasurable);
private static bool ShippingitemPalletMeasuredAndValid(ShippingItemPallet shippingItemPallet, bool isMeasurable)
{
return shippingItemPallet.Id != 0 && shippingItemPallet.IsMeasured && shippingItemPallet.IsValidMeasuringValues(isMeasurable);
}
private bool IsShippingitemPalletMeasuredAndValid(ShippingItemPallet shippingItemPallet)
=> shippingItemPallet.IsMeasuredAndValid(SelectedShippingItem!.IsMeasurable);
private async Task HandleValidSubmit()
{
@ -249,11 +283,14 @@ namespace FruitBankHybrid.Shared.Pages
break;
}
shippingItemPallet.NetWeight = shippingItemPallet.GrossWeight - shippingItemPallet.PalletWeight;
MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(SelectedShippingItem);
BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues() && shippingItemPallet.IsValidMeasuringValues(SelectedShippingItem.IsMeasurable);
//BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues() &&
// shippingItemPallet.IsValidSafeMeasuringValues() &&
// SelectedShippingItem.ShippingItemPallets!.Any(sip => sip.IsValidMeasuringValues(SelectedShippingItem.IsMeasurable));
}
private void LogErrorAndDisplayText(string errorText, Exception? ex = null)
{

View File

@ -76,6 +76,10 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
public Task<ShippingItemPallet?> UpdateShippingItemPallet(ShippingItemPallet shippingItemPallet)
=> PostDataAsync(SignalRTags.UpdateShippingItemPallet, shippingItemPallet);
public Task<ShippingItem?> AddOrUpdateMeasuredShippingItemPallets(List<ShippingItemPallet> shippingItemPallets)
=> PostDataAsync<List<ShippingItemPallet>, ShippingItem>(SignalRTags.UpdateShippingItemPallet, shippingItemPallets);
#endregion ShippingItemPallet
#region ShippingDocument