diff --git a/FruitBank.Common/Entities/Pallet.cs b/FruitBank.Common/Entities/Pallet.cs
new file mode 100644
index 0000000..8d2afc5
--- /dev/null
+++ b/FruitBank.Common/Entities/Pallet.cs
@@ -0,0 +1,21 @@
+using FruitBank.Common.Interfaces;
+using LinqToDB;
+using LinqToDB.Mapping;
+using Mango.Nop.Core.Entities;
+
+namespace FruitBank.Common.Entities;
+
+[Table(Name = FruitBankConstClient.PalletDbTableName)]
+[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.PalletDbTableName)]
+public class Pallet : MgEntityBase, IPallet
+{
+ public string Name { get; set; }
+ public string Size { get; set; }
+
+ [Column(DataType = DataType.DecFloat, CanBeNull = true)]
+ public double? Weight { get; set; }
+
+ [SkipValuesOnUpdate]
+ public DateTime Created { get; set; }
+ public DateTime Modified { get; set; }
+}
\ No newline at end of file
diff --git a/FruitBank.Common/Entities/ShippingItem.cs b/FruitBank.Common/Entities/ShippingItem.cs
index 047399e..504b559 100644
--- a/FruitBank.Common/Entities/ShippingItem.cs
+++ b/FruitBank.Common/Entities/ShippingItem.cs
@@ -53,6 +53,9 @@ public class ShippingItem : MgEntityBase, IShippingItem
public bool IsMeasurable { get; set; }
public bool IsMeasured { get; set; }
+ [LinqToDB.Mapping.Association(ThisKey = nameof(PalletId), OtherKey = nameof(Pallet.Id), CanBeNull = true)]
+ public Pallet? Pallet { get; set; }
+
[LinqToDB.Mapping.Association(ThisKey = nameof(ProductId), OtherKey = nameof(Product.Id), CanBeNull = true)]
public Product? Product { get; set; }
diff --git a/FruitBank.Common/Entities/ShippingItemPallet.cs b/FruitBank.Common/Entities/ShippingItemPallet.cs
index 310c29c..03510e8 100644
--- a/FruitBank.Common/Entities/ShippingItemPallet.cs
+++ b/FruitBank.Common/Entities/ShippingItemPallet.cs
@@ -12,6 +12,7 @@ public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
{
public int ShippingItemId { get; set; }
+ [Column(DataType = DataType.DecFloat)]
public double PalletWeight { get; set; }
//[Nullable]
diff --git a/FruitBank.Common/FruitBankConstClient.cs b/FruitBank.Common/FruitBankConstClient.cs
index 2cb95e3..3095ec2 100644
--- a/FruitBank.Common/FruitBankConstClient.cs
+++ b/FruitBank.Common/FruitBankConstClient.cs
@@ -15,6 +15,7 @@ public static class FruitBankConstClient
public static string DefaultHubName = "fbHub";
public static string LoggerHubName = "loggerHub";
+ public const string PalletDbTableName = "fbPallet";
public const string FilesDbTableName = "fbFiles";
public const string PartnerDbTableName = "fbPartner";
public const string ShippingDbTableName = "fbShipping";
diff --git a/FruitBank.Common/Helpers/MeasuringValuesHelper.cs b/FruitBank.Common/Helpers/MeasuringValuesHelper.cs
new file mode 100644
index 0000000..26798cd
--- /dev/null
+++ b/FruitBank.Common/Helpers/MeasuringValuesHelper.cs
@@ -0,0 +1,35 @@
+using FruitBank.Common.Entities;
+
+namespace FruitBank.Common.Helpers;
+
+public static class MeasuringValuesHelper
+{
+ public static void SetShippingItemTotalMeasuringValues(ShippingItem? shippingItem)
+ {
+ if (shippingItem == null) return;
+
+ var totalMeasuringValues = GetTotalNetAndGrossWeightFromPallets(shippingItem);
+
+ shippingItem.MeasuredQuantity = totalMeasuringValues.TotalQuantity;
+ shippingItem.MeasuredNetWeight = totalMeasuringValues.TotalNetWeight;
+ shippingItem.MeasuredGrossWeight = totalMeasuringValues.TotalGrossWeight;
+ }
+
+ public static (int TotalQuantity, double TotalNetWeight, double TotalGrossWeight) GetTotalNetAndGrossWeightFromPallets(ShippingItem? shippingItem)
+ {
+ if (shippingItem?.ShippingItemPallets == null) return (0, 0d, 0d);
+
+ var totalQuantity = 0;
+ var totalNetWeight = 0d;
+ var totalGrossWeight = 0d;
+
+ foreach (var shippingItemPallet in shippingItem.ShippingItemPallets)
+ {
+ totalQuantity += shippingItemPallet.Quantity;
+ totalNetWeight += shippingItemPallet.NetWeight;
+ totalGrossWeight += shippingItemPallet.GrossWeight;
+ }
+
+ return (totalQuantity, double.Round(totalNetWeight, 1), Math.Round(totalGrossWeight, 1));
+ }
+}
\ No newline at end of file
diff --git a/FruitBank.Common/Interfaces/IPallet.cs b/FruitBank.Common/Interfaces/IPallet.cs
new file mode 100644
index 0000000..260651a
--- /dev/null
+++ b/FruitBank.Common/Interfaces/IPallet.cs
@@ -0,0 +1,11 @@
+using AyCode.Interfaces.Entities;
+using AyCode.Interfaces.TimeStampInfo;
+
+namespace FruitBank.Common.Interfaces;
+
+public interface IPallet : IEntityInt, ITimeStampInfo
+{
+ string Name { get; set; }
+ string Size { get; set; }
+ double? Weight { get; set; }
+}
\ No newline at end of file
diff --git a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs
index 137a98b..bded39f 100644
--- a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs
+++ b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs
@@ -173,8 +173,9 @@ namespace FruitBankHybrid.Shared.Tests
{
var shippingItem = await _signalRClient.GetShippingItemById(shippingItemId);
- Assert.IsNotNull(shippingItem);
- Assert.IsNotNull(shippingItem.Product, $"shippingItem.Product == null; shippingItem.Id: {shippingItem.ProductId}");
+ Assert.IsNotNull(shippingItem, $"shippingItemId: {shippingItemId}");
+ 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);
Assert.IsTrue(shippingItem.QuantityOnDocument > 0, "QuantityOnDocument == 0");
@@ -205,7 +206,7 @@ namespace FruitBankHybrid.Shared.Tests
if (shippingItemPallet == null)
{
- shippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id/*, PalletSize = shippingItem.PalletSize*/ };
+ shippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id, PalletWeight = shippingItem.Pallet?.Weight ?? 0 };
shippingItem.ShippingItemPallets!.Add(shippingItemPallet);
}
diff --git a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor
index 7691d22..3c1493f 100644
--- a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor
+++ b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor
@@ -137,6 +137,12 @@
+@*
+
+ Raklap
+
+ @(localI). Raklap
-
+
+
+
+ Caption="Rekesz/csomag:" ColSpanMd="1" />
-
-
-
-
-
+ Caption="Br.súly(kg):" ColSpanMd="1">
-
-
+
+ @* *@
@@ -180,7 +186,7 @@
{
}
diff --git a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
index 11d4776..c792509 100644
--- a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
+++ b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
@@ -2,6 +2,7 @@
using AyCode.Core.Loggers;
using DevExpress.Blazor;
using FruitBank.Common.Entities;
+using FruitBank.Common.Helpers;
using FruitBank.Common.Interfaces;
using FruitBank.Common.Models;
using FruitBankHybrid.Shared.Services.Loggers;
@@ -97,35 +98,6 @@ namespace FruitBankHybrid.Shared.Pages
SelectedShippingItem = eventArgs.DataItem?.ShippingItems?.FirstOrDefault();
}
- private void UpdateShippingItemTotalMeasuringValues(ShippingItem? shippingItem)
- {
- if (shippingItem == null) return;
-
- var totalMeasuringValues = GetTotalNetAndGrossWeightFromPallets(shippingItem);
-
- shippingItem.MeasuredQuantity = totalMeasuringValues.TotalQuantity;
- shippingItem.MeasuredNetWeight = totalMeasuringValues.TotalNetWeight;
- shippingItem.MeasuredGrossWeight = totalMeasuringValues.TotalGrossWeight;
- }
-
- private (int TotalQuantity, double TotalNetWeight, double TotalGrossWeight) GetTotalNetAndGrossWeightFromPallets(ShippingItem? shippingItem)
- {
- if (shippingItem?.ShippingItemPallets == null) return (0, 0d, 0d);
-
- var totalQuantity = 0;
- var totalNetWeight = 0d;
- var totalGrossWeight = 0d;
-
- foreach (var shippingItemPallet in shippingItem.ShippingItemPallets)
- {
- totalQuantity += shippingItemPallet.Quantity;
- totalNetWeight += shippingItemPallet.NetWeight;
- totalGrossWeight += shippingItemPallet.GrossWeight;
- }
-
- return (totalQuantity, double.Round(totalNetWeight, 1), Math.Round(totalGrossWeight, 1));
- }
-
private void OnSelectedShippingItemChanged(SelectedDataItemChangedEventArgs eventArgs)
{
BtnSaveEnabled = false;
@@ -143,7 +115,7 @@ namespace FruitBankHybrid.Shared.Pages
var shippingDate = _shippingDates.FirstOrDefault(shipping => shipping.ShippingId == SelectedShipping.Id);
if (shippingDate != null) shippingDate.IsMeasured = SelectedShipping.IsAllMeasured;
- UpdateShippingItemTotalMeasuringValues(shippingItem);
+ MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(shippingItem);
shippingItem.ShippingItemPallets ??= new List(shippingItem.PalletsOnDocument);
if (shippingItem.ShippingItemPallets.Count >= shippingItem.PalletsOnDocument) return;
@@ -152,7 +124,7 @@ namespace FruitBankHybrid.Shared.Pages
shippingItem.ShippingItemPallets.Add(new ShippingItemPallet
{
ShippingItemId = shippingItem.Id,
- //PalletSize = shippingItem.PalletSize,
+ PalletWeight = shippingItem.Pallet?.Weight ?? 0,
});
//if (shippingItem.Id == SelectedShippingItem?.Id) return;
@@ -209,7 +181,7 @@ namespace FruitBankHybrid.Shared.Pages
shippingItemPallet.Id = responseShippingItemPallet.Id; //Az UpdateCollection miatt kell, hogy megtalálja mit kell kicserélni! - J.
SelectedShippingItem!.ShippingItemPallets!.UpdateCollection(responseShippingItemPallet, false);
- UpdateShippingItemTotalMeasuringValues(SelectedShippingItem);
+ MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(SelectedShippingItem);
}
else LogErrorAndDisplayText($"Sikertelen volt a raklap adatainak mentése! {shippingItemPallet}");
@@ -236,20 +208,13 @@ namespace FruitBankHybrid.Shared.Pages
protected void OnItemUpdating(string fieldName, object newValue)
{
+ return;
+
BtnSaveEnabled = false;
if (SelectedShippingItem == null) return;
switch (fieldName)
{
- //case nameof(ShippingItem.Name):
- // SelectedShippingItem.Name = newValue.ToString() ?? string.Empty;
- // break;
- //case nameof(ShippingItem.GrossWeight):
- // SelectedShippingItem.GrossWeight = (double)newValue;
- // break;
- //case nameof(ShippingItem.NetWeight):
- // SelectedShippingItem.NetWeight = (double)newValue;
- // break;
case nameof(ShippingItem.MeasuredQuantity):
SelectedShippingItem.MeasuredQuantity = (int)newValue <= 0 ? 0 : (int)newValue;
break;
@@ -271,21 +236,24 @@ namespace FruitBankHybrid.Shared.Pages
switch (fieldName)
{
+ case nameof(ShippingItemPallet.PalletWeight):
+ shippingItemPallet.PalletWeight = (double)newValue;
+ break;
+
case nameof(ShippingItemPallet.Quantity):
shippingItemPallet.Quantity = (int)newValue;
- SelectedShippingItem.MeasuredQuantity = GetTotalNetAndGrossWeightFromPallets(SelectedShippingItem).TotalQuantity;
- break;
- case nameof(ShippingItemPallet.NetWeight):
- shippingItemPallet.NetWeight = (double)newValue;
- SelectedShippingItem.MeasuredNetWeight = GetTotalNetAndGrossWeightFromPallets(SelectedShippingItem).TotalNetWeight;
break;
+
case nameof(ShippingItemPallet.GrossWeight):
shippingItemPallet.GrossWeight = (double)newValue;
- SelectedShippingItem.MeasuredGrossWeight = GetTotalNetAndGrossWeightFromPallets(SelectedShippingItem).TotalGrossWeight;
break;
}
- BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues();
+ shippingItemPallet.NetWeight = shippingItemPallet.GrossWeight - shippingItemPallet.PalletWeight;
+
+ MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(SelectedShippingItem);
+
+ BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues() && shippingItemPallet.IsValidMeasuringValues(SelectedShippingItem.IsMeasurable);
}
private void LogErrorAndDisplayText(string errorText, Exception? ex = null)
{
@@ -293,10 +261,5 @@ namespace FruitBankHybrid.Shared.Pages
_logger.Error($"{errorText}", ex);
//Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...
}
-
- protected void OnAnyMeasuringValueKeyDown(KeyboardEventArgs e)
- {
- BtnSaveEnabled = SelectedShippingItem?.IsValidMeasuringValues() ?? false;
- }
}
}