Implement Tare; Implement OrderItemPallet;, improvements, fixes, etc...
This commit is contained in:
parent
a74b356e70
commit
0f1ed24631
|
|
@ -0,0 +1,83 @@
|
||||||
|
using FruitBank.Common.Interfaces;
|
||||||
|
using LinqToDB;
|
||||||
|
using LinqToDB.Mapping;
|
||||||
|
using Mango.Nop.Core.Entities;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Entities;
|
||||||
|
|
||||||
|
public abstract class MeasuringItemPalletBase : MgEntityBase, IMeasuringItemPalletBase
|
||||||
|
{
|
||||||
|
private double _palletWeight;
|
||||||
|
private double _grossWeight;
|
||||||
|
private double _tareWeight;
|
||||||
|
|
||||||
|
[NotColumn]
|
||||||
|
protected int ForeignItemId;
|
||||||
|
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
|
[Column(DataType = DataType.DecFloat)]
|
||||||
|
public double TareWeight
|
||||||
|
{
|
||||||
|
get => _tareWeight;
|
||||||
|
set => _tareWeight = double.Round(value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Column(DataType = DataType.DecFloat)]
|
||||||
|
public double PalletWeight
|
||||||
|
{
|
||||||
|
get => _palletWeight;
|
||||||
|
set => _palletWeight = double.Round(value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NotColumn] public double NetWeight => CalculateNetWeight();
|
||||||
|
|
||||||
|
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
|
||||||
|
public double GrossWeight
|
||||||
|
{
|
||||||
|
get => _grossWeight;
|
||||||
|
set => _grossWeight = double.Round(value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMeasured { get; set; }
|
||||||
|
|
||||||
|
[SkipValuesOnUpdate]
|
||||||
|
public int? CreatorId { get; set; }
|
||||||
|
public int? ModifierId { get; set; }
|
||||||
|
|
||||||
|
[SkipValuesOnUpdate]
|
||||||
|
public DateTime Created { get; set; }
|
||||||
|
public DateTime Modified { get; set; }
|
||||||
|
|
||||||
|
public virtual double CalculateNetWeight() => double.Round(GrossWeight - PalletWeight - (TareWeight * Quantity), 1);
|
||||||
|
|
||||||
|
/// <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 virtual bool IsValidSafeMeasuringValues()
|
||||||
|
{
|
||||||
|
return Quantity > 0 && TareWeight >= 0 && PalletWeight >= 0 && NetWeight >= 0 && GrossWeight >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Szigorúbb" mint az IsValidSafeMeasuringValues()
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isMeasurable"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool IsValidMeasuringValues(bool isMeasurable)
|
||||||
|
{
|
||||||
|
return Quantity > 0 && ((!isMeasurable && NetWeight == 0 && GrossWeight == 0 && PalletWeight == 0 && TareWeight == 0)
|
||||||
|
|| (isMeasurable && NetWeight > 0 && GrossWeight > 0 && PalletWeight >= 0 && TareWeight >= 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMeasuredAndValid(bool isMeasurable)
|
||||||
|
{
|
||||||
|
return Id > 0 && IsMeasured && IsValidMeasuringValues(isMeasurable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{base.ToString()} [ForeignItemId: {ForeignItemId}; IsMeasured: {IsMeasured}; PalletWeight: {PalletWeight}; TareWeight: {TareWeight}; Quantity: {Quantity}; NetWeight: {NetWeight}; GrossWeight: {GrossWeight}]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using FruitBank.Common.Interfaces;
|
||||||
|
using LinqToDB.Mapping;
|
||||||
|
using Nop.Core.Domain.Orders;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Entities;
|
||||||
|
|
||||||
|
[Table(Name = FruitBankConstClient.OrderItemPalletDbTableName)]
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.OrderItemPalletDbTableName)]
|
||||||
|
public class OrderItemPallet : MeasuringItemPalletBase, IOrderItemPallet
|
||||||
|
{
|
||||||
|
public int OrderItemId
|
||||||
|
{
|
||||||
|
get => ForeignItemId;
|
||||||
|
set => ForeignItemId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[LinqToDB.Mapping.Association(ThisKey = nameof(OrderItemId), OtherKey = nameof(OrderItem.Id), CanBeNull = true)]
|
||||||
|
public OrderItem? OrderItem { get; set; }
|
||||||
|
|
||||||
|
public override double CalculateNetWeight() => base.CalculateNetWeight();
|
||||||
|
|
||||||
|
public override bool IsValidSafeMeasuringValues()
|
||||||
|
{
|
||||||
|
return OrderItemId > 0 && base.IsValidSafeMeasuringValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Szigorúbb" mint az IsValidSafeMeasuringValues()
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isMeasurable"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool IsValidMeasuringValues(bool isMeasurable)
|
||||||
|
{
|
||||||
|
return OrderItemId > 0 && base.IsValidMeasuringValues(isMeasurable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,66 +1,28 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using FruitBank.Common.Interfaces;
|
using FruitBank.Common.Interfaces;
|
||||||
using LinqToDB.Mapping;
|
using LinqToDB.Mapping;
|
||||||
using Mango.Nop.Core.Entities;
|
|
||||||
using DataType = LinqToDB.DataType;
|
|
||||||
|
|
||||||
namespace FruitBank.Common.Entities;
|
namespace FruitBank.Common.Entities;
|
||||||
|
|
||||||
[Table(Name = FruitBankConstClient.ShippingItemPalletDbTableName)]
|
[Table(Name = FruitBankConstClient.ShippingItemPalletDbTableName)]
|
||||||
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemPalletDbTableName)]
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemPalletDbTableName)]
|
||||||
public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
|
public class ShippingItemPallet : MeasuringItemPalletBase, IShippingItemPallet
|
||||||
{
|
{
|
||||||
private double _palletWeight;
|
public int ShippingItemId
|
||||||
private double _grossWeight;
|
|
||||||
|
|
||||||
public int ShippingItemId { get; set; }
|
|
||||||
|
|
||||||
[Column(DataType = DataType.DecFloat)]
|
|
||||||
public double PalletWeight
|
|
||||||
{
|
{
|
||||||
get => _palletWeight;
|
get => ForeignItemId;
|
||||||
set => _palletWeight = double.Round(value, 1);
|
set => ForeignItemId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//[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; }
|
|
||||||
|
|
||||||
[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 => _grossWeight;
|
|
||||||
set => _grossWeight = double.Round(value, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsMeasured { get; set; }
|
|
||||||
|
|
||||||
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingItemId), OtherKey = nameof(ShippingItem.Id), CanBeNull = true)]
|
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingItemId), OtherKey = nameof(ShippingItem.Id), CanBeNull = true)]
|
||||||
public ShippingItem? ShippingItem { get; set; }
|
public ShippingItem? ShippingItem { get; set; }
|
||||||
|
|
||||||
[SkipValuesOnUpdate]
|
public override double CalculateNetWeight() => base.CalculateNetWeight();
|
||||||
public int? CreatorId { get; set; }
|
|
||||||
public int? ModifierId { get; set; }
|
|
||||||
|
|
||||||
[SkipValuesOnUpdate]
|
public override bool IsValidSafeMeasuringValues()
|
||||||
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;
|
return ShippingItemId > 0 && base.IsValidSafeMeasuringValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -68,19 +30,8 @@ public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isMeasurable"></param>
|
/// <param name="isMeasurable"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsValidMeasuringValues(bool isMeasurable)
|
public override bool IsValidMeasuringValues(bool isMeasurable)
|
||||||
{
|
{
|
||||||
return ShippingItemId > 0 && Quantity > 0 &&
|
return ShippingItemId > 0 && base.IsValidMeasuringValues(isMeasurable);
|
||||||
((!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}]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +18,9 @@ public static class FruitBankConstClient
|
||||||
public const string PalletDbTableName = "fbPallet";
|
public const string PalletDbTableName = "fbPallet";
|
||||||
public const string FilesDbTableName = "fbFiles";
|
public const string FilesDbTableName = "fbFiles";
|
||||||
public const string PartnerDbTableName = "fbPartner";
|
public const string PartnerDbTableName = "fbPartner";
|
||||||
|
|
||||||
|
public const string OrderItemPalletDbTableName = "fbOrderItemPallet";
|
||||||
|
|
||||||
public const string ShippingDbTableName = "fbShipping";
|
public const string ShippingDbTableName = "fbShipping";
|
||||||
public const string ShippingItemDbTableName = "fbShippingItem";
|
public const string ShippingItemDbTableName = "fbShippingItem";
|
||||||
public const string ShippingItemPalletDbTableName = "fbShippingItemPallet";
|
public const string ShippingItemPalletDbTableName = "fbShippingItemPallet";
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IMeasurable
|
||||||
|
{
|
||||||
|
bool IsMeasurable { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IMeasured
|
||||||
|
{
|
||||||
|
bool IsMeasured { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IMeasuringAttributeValues : IMeasuringWeights, IEntityInt
|
public interface IMeasuringAttributeValues : IEntityInt, IMeasuringWeights, IMeasurable
|
||||||
{
|
{
|
||||||
bool IsMeasurable { get; set; }
|
|
||||||
|
|
||||||
bool HasMeasuringValues(); //=> Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
bool HasMeasuringValues(); //=> Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using AyCode.Interfaces.Entities;
|
||||||
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
|
using FruitBank.Common.Entities;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IMeasuringItemPalletBase : IEntityInt, IMeasuringQuantity, IMeasuringGrossWeight, IMeasured, ITimeStampInfo
|
||||||
|
{
|
||||||
|
public double TareWeight { get; set; }
|
||||||
|
public double PalletWeight { get; set; }
|
||||||
|
|
||||||
|
public int? CreatorId { get; set; }
|
||||||
|
public int? ModifierId { get; set; }
|
||||||
|
|
||||||
|
public double CalculateNetWeight();
|
||||||
|
|
||||||
|
public bool IsValidSafeMeasuringValues();
|
||||||
|
public bool IsValidMeasuringValues(bool isMeasurable);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using FruitBank.Common.Entities;
|
||||||
|
using Nop.Core.Domain.Orders;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IOrderItemPallet : IMeasuringItemPalletBase
|
||||||
|
{
|
||||||
|
int OrderItemId { get; set; }
|
||||||
|
public OrderItem? OrderItem { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ using FruitBank.Common.Entities;
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IShipping : IEntityInt, ITimeStampInfo
|
public interface IShipping : IEntityInt, ITimeStampInfo//, IMeasured
|
||||||
{
|
{
|
||||||
DateTime ShippingDate { get; set; }
|
DateTime ShippingDate { get; set; }
|
||||||
string LicencePlate { get; set; }
|
string LicencePlate { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using FruitBank.Common.Entities;
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IShippingDocument: IEntityInt, ITimeStampInfo
|
public interface IShippingDocument: IEntityInt, ITimeStampInfo//, IMeasured
|
||||||
{
|
{
|
||||||
public int PartnerId { get; set; }
|
public int PartnerId { get; set; }
|
||||||
public int? ShippingId { get; set; }
|
public int? ShippingId { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using Nop.Core.Domain.Catalog;
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IShippingItem : IEntityInt, ITimeStampInfo
|
public interface IShippingItem : IEntityInt, ITimeStampInfo, IMeasurable, IMeasured
|
||||||
{
|
{
|
||||||
int ShippingDocumentId { get; set; }
|
int ShippingDocumentId { get; set; }
|
||||||
int? PalletId { get; set; }
|
int? PalletId { get; set; }
|
||||||
|
|
@ -24,9 +24,6 @@ public interface IShippingItem : IEntityInt, ITimeStampInfo
|
||||||
double MeasuredNetWeight { get; set; }
|
double MeasuredNetWeight { get; set; }
|
||||||
double MeasuredGrossWeight { get; set; }
|
double MeasuredGrossWeight { get; set; }
|
||||||
|
|
||||||
bool IsMeasurable { get; set; }
|
|
||||||
bool IsMeasured { get; set; }
|
|
||||||
|
|
||||||
public Product? Product { get; set; }
|
public Product? Product { get; set; }
|
||||||
public ShippingDocument? ShippingDocument { get; set; }
|
public ShippingDocument? ShippingDocument { get; set; }
|
||||||
public List<ShippingItemPallet>? ShippingItemPallets { get; set; }
|
public List<ShippingItemPallet>? ShippingItemPallets { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,9 @@
|
||||||
using AyCode.Interfaces.Entities;
|
using FruitBank.Common.Entities;
|
||||||
using AyCode.Interfaces.TimeStampInfo;
|
|
||||||
using FruitBank.Common.Entities;
|
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IShippingItemPallet : IEntityInt, IMeasuringGrossWeight, IMeasuringQuantity, ITimeStampInfo
|
public interface IShippingItemPallet : IMeasuringItemPalletBase
|
||||||
{
|
{
|
||||||
int ShippingItemId { get; set; }
|
int ShippingItemId { get; set; }
|
||||||
|
|
||||||
public double PalletWeight { get; set; }
|
|
||||||
public bool IsMeasured { get; set; }
|
|
||||||
|
|
||||||
public ShippingItem? ShippingItem { get; set; }
|
public ShippingItem? ShippingItem { get; set; }
|
||||||
|
|
||||||
public int? CreatorId { get; set; }
|
|
||||||
public int? ModifierId { get; set; }
|
|
||||||
|
|
||||||
public bool IsValidMeasuringValues(bool isMeasurable);
|
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,8 @@ public class SignalRTags : AcSignalRTags
|
||||||
|
|
||||||
public const int AddShippingItemPallet = 95;
|
public const int AddShippingItemPallet = 95;
|
||||||
public const int UpdateShippingItemPallet = 96;
|
public const int UpdateShippingItemPallet = 96;
|
||||||
public const int AddOrUpdateMeasuredShippingItemPallets = 97;
|
public const int AddOrUpdateMeasuredShippingItemPallet = 97;
|
||||||
|
public const int AddOrUpdateMeasuredShippingItemPallets = 98;
|
||||||
|
|
||||||
public const int AuthenticateUser = 160;
|
public const int AuthenticateUser = 160;
|
||||||
public const int RefreshToken = 200;
|
public const int RefreshToken = 200;
|
||||||
|
|
|
||||||
|
|
@ -207,17 +207,17 @@ namespace FruitBankHybrid.Shared.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow(1, -1, -2.137563300001, -333.75238200001)]
|
[DataRow(1, -1, -2.137563300001, -333.75238200001, 2.12545)]
|
||||||
[DataRow(1, 1, 2.137563300001, 3.75238200001)]
|
[DataRow(1, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(1, 1, 20.137563300001, 3.75238200001)]
|
[DataRow(1, 1, 20.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(2, -1, -20.137563300001, 3.75238200001)]
|
[DataRow(2, -1, -20.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(2, -1, 20.137563300001, 3.75238200001)]
|
[DataRow(2, -1, 20.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(3, 1, 2.137563300001, 1.75238200001)]
|
[DataRow(3, 1, 2.137563300001, 1.75238200001, 2.12545)]
|
||||||
[DataRow(3, 1, 2.137563300001, 3.75238200001)]
|
[DataRow(3, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(4, 13, 2.137563300001, 3.75238200001)]
|
[DataRow(4, 13, 2.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(5, 1, 2.137563300001, 3.75238200001)]
|
[DataRow(5, 1, 2.137563300001, 3.75238200001, 2.12545)]
|
||||||
[DataRow(5, -1, 2.137563300001, 3.75238200001)]
|
[DataRow(5, -1, 2.137563300001, 3.75238200001, 2.12545)]
|
||||||
public async Task UpdateShippingItemTest(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight)
|
public async Task UpdateShippingItemTest(int shippingItemId, int incQuantity, double incPalletWeight, double incGrossWeight, double incTare)
|
||||||
{
|
{
|
||||||
var originalShippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
var originalShippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
||||||
var originalMeasuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
var originalMeasuringProductDto = await GetMeasuringProductDtoByIdAsync(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
||||||
|
|
@ -226,46 +226,58 @@ namespace FruitBankHybrid.Shared.Tests
|
||||||
|
|
||||||
var shippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
var shippingItem = await GetShippingItemByIdAsync(shippingItemId);
|
||||||
|
|
||||||
var shippingItemPallet = shippingItem.ShippingItemPallets!.FirstOrDefault();
|
var originalShippingItemPallet = shippingItem.ShippingItemPallets!.FirstOrDefault();
|
||||||
|
|
||||||
if (shippingItemPallet == null)
|
if (originalShippingItemPallet == null)
|
||||||
{
|
{
|
||||||
shippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id, PalletWeight = shippingItem.Pallet?.Weight ?? 0 };
|
originalShippingItemPallet = new ShippingItemPallet { ShippingItemId = shippingItem.Id, PalletWeight = shippingItem.Pallet?.Weight ?? 0 };
|
||||||
shippingItem.ShippingItemPallets!.Add(shippingItemPallet);
|
shippingItem.ShippingItemPallets!.Add(originalShippingItemPallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.IsNotNull(shippingItemPallet);
|
Assert.IsNotNull(originalShippingItemPallet);
|
||||||
|
|
||||||
var nullResultIsValid = shippingItem.IsMeasured && !shippingItem.IsValidMeasuringValues();
|
var nullResultIsValid = shippingItem.IsMeasured && !shippingItem.IsValidMeasuringValues();
|
||||||
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(originalMeasuringProductDto.IsMeasurable));
|
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidMeasuringValues(originalMeasuringProductDto.IsMeasurable));
|
||||||
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
|
nullResultIsValid = nullResultIsValid || shippingItem.ShippingItemPallets!.Any(x => !x.IsValidSafeMeasuringValues());
|
||||||
|
|
||||||
shippingItemPallet.Quantity += incQuantity;
|
originalShippingItemPallet.Quantity += incQuantity;
|
||||||
shippingItemPallet.GrossWeight += incGrossWeight;
|
originalShippingItemPallet.GrossWeight += incGrossWeight;
|
||||||
shippingItemPallet.PalletWeight += incPalletWeight;
|
originalShippingItemPallet.PalletWeight += incPalletWeight;
|
||||||
|
originalShippingItemPallet.TareWeight += incTare;
|
||||||
|
|
||||||
shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
//shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
||||||
|
var shippingItemPallet = await _signalRClient.UpdateShippingItemPallet(originalShippingItemPallet);
|
||||||
|
|
||||||
//A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
|
//A szerver oldal 0-ra állítja a shippingItemPallet weight-eket, ha nem mérhető! - J.
|
||||||
if (!originalMeasuringProductDto.IsMeasurable)
|
if (!originalMeasuringProductDto.IsMeasurable)
|
||||||
{
|
{
|
||||||
shippingItemPallet.GrossWeight = 0;
|
originalShippingItemPallet.GrossWeight = 0;
|
||||||
shippingItemPallet.PalletWeight = 0;
|
originalShippingItemPallet.PalletWeight = 0;
|
||||||
|
originalShippingItemPallet.TareWeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullResultIsValid || !shippingItemPallet.IsValidSafeMeasuringValues())
|
if (nullResultIsValid || !originalShippingItemPallet.IsValidSafeMeasuringValues())
|
||||||
{
|
{
|
||||||
Assert.IsNull(shippingItem);
|
Assert.IsNull(shippingItemPallet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.IsNotNull(shippingItemPallet);
|
||||||
|
Assert.IsTrue(shippingItemPallet.TareWeight == originalShippingItemPallet.TareWeight);
|
||||||
|
Assert.IsTrue(shippingItemPallet.Quantity == originalShippingItemPallet.Quantity);
|
||||||
|
Assert.IsTrue(shippingItemPallet.GrossWeight == originalShippingItemPallet.GrossWeight);
|
||||||
|
Assert.IsTrue(shippingItemPallet.PalletWeight == originalShippingItemPallet.PalletWeight);
|
||||||
|
Assert.IsTrue(shippingItemPallet.ShippingItemId == originalShippingItemPallet.ShippingItemId);
|
||||||
|
|
||||||
|
shippingItem = await _signalRClient.GetShippingItemById(shippingItemPallet.ShippingItemId);
|
||||||
|
|
||||||
Assert.IsNotNull(shippingItem);
|
Assert.IsNotNull(shippingItem);
|
||||||
Assert.IsNotNull(shippingItem.Product);
|
Assert.IsNotNull(shippingItem.Product);
|
||||||
Assert.IsNotNull(shippingItem.ShippingItemPallets);
|
Assert.IsNotNull(shippingItem.ShippingItemPallets);
|
||||||
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
|
Assert.IsTrue(shippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
|
||||||
|
|
||||||
incGrossWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
|
incGrossWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight, 1) : 0;
|
||||||
var incNetWeight = originalMeasuringProductDto.IsMeasurable ? double.Round(incGrossWeight - incPalletWeight, 1) : 0;
|
var incNetWeight = originalMeasuringProductDto.IsMeasurable ? double.Round((incGrossWeight - incPalletWeight) - (incQuantity * incTare), 1) : 0;
|
||||||
|
|
||||||
var isMeasuredPalletsCount = shippingItem.ShippingItemPallets!.Count(x => x.IsMeasured);
|
var isMeasuredPalletsCount = shippingItem.ShippingItemPallets!.Count(x => x.IsMeasured);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,8 @@
|
||||||
@if (SelectedShippingItem != null)
|
@if (SelectedShippingItem != null)
|
||||||
{
|
{
|
||||||
<h3 style="margin-bottom: 30px;" class="@(SelectedShippingItem.IsMeasured && SelectedShippingItem.ShippingItemPallets!.All(x => x.IsMeasuredAndValid(SelectedShippingItem.IsMeasurable)) ? "text-success" : "")">
|
<h3 style="margin-bottom: 30px;" class="@(SelectedShippingItem.IsMeasured && SelectedShippingItem.ShippingItemPallets!.All(x => x.IsMeasuredAndValid(SelectedShippingItem.IsMeasurable)) ? "text-success" : "")">
|
||||||
@SelectedShippingItem.Name</h3>
|
@SelectedShippingItem.Name
|
||||||
|
</h3>
|
||||||
|
|
||||||
<EditForm Model="@SelectedShippingItem" Context="FrmContext"
|
<EditForm Model="@SelectedShippingItem" Context="FrmContext"
|
||||||
OnValidSubmit="@HandleValidSubmit"
|
OnValidSubmit="@HandleValidSubmit"
|
||||||
|
|
@ -140,55 +141,63 @@
|
||||||
</DxFormLayoutItem> *@
|
</DxFormLayoutItem> *@
|
||||||
|
|
||||||
<DxFormLayoutItem Context="dfsdf" ColSpanMd="12">
|
<DxFormLayoutItem Context="dfsdf" ColSpanMd="12">
|
||||||
@for (var index = 0; index < SelectedShippingItem.ShippingItemPallets!.Count; index++)
|
@for (var index = 0; index < SelectedShippingItem.ShippingItemPallets!.Count; index++)
|
||||||
{
|
{
|
||||||
var localI = index + 1;
|
var localI = index + 1;
|
||||||
var currentShippingItemPallet = SelectedShippingItem.ShippingItemPallets![index];
|
var currentShippingItemPallet = SelectedShippingItem.ShippingItemPallets![index];
|
||||||
|
|
||||||
<DxFormLayout Data="@currentShippingItemPallet" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating2(pair.Key, pair.Value, currentShippingItemPallet))">
|
<DxFormLayout Data="@currentShippingItemPallet" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100 measuring-form-layout"
|
||||||
<DxFormLayoutItem ColSpanMd="3" BeginRow="true">
|
ItemUpdating="@((pair) => OnItemUpdating2(pair.Key, pair.Value, currentShippingItemPallet))">
|
||||||
<text>@(localI). Raklap</text>
|
|
||||||
|
<DxFormLayoutItem ColSpanMd="1" BeginRow="true">
|
||||||
|
<text>@(localI).mérés</text>
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
|
|
||||||
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.PalletWeight), currentShippingItemPallet))"
|
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.PalletWeight), currentShippingItemPallet))"
|
||||||
Field="@nameof(ShippingItemPallet.PalletWeight)"
|
Field="@nameof(ShippingItemPallet.PalletWeight)"
|
||||||
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||||
Caption="Rakl.súly(kg)" ColSpanMd="2" />
|
Caption="Rakl.súly(kg)" ColSpanMd="2"/>
|
||||||
|
|
||||||
|
<DxFormLayoutItem ColSpanMd="1"/>
|
||||||
|
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.TareWeight), currentShippingItemPallet))"
|
||||||
|
Field="@nameof(ShippingItemPallet.TareWeight)"
|
||||||
|
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||||
|
Caption="Tára.súly(kg)" ColSpanMd="2"/>
|
||||||
|
|
||||||
<DxFormLayoutItem ColSpanMd="1" />
|
|
||||||
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.Quantity), currentShippingItemPallet))"
|
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.Quantity), currentShippingItemPallet))"
|
||||||
Field="@nameof(ShippingItemPallet.Quantity)"
|
Field="@nameof(ShippingItemPallet.Quantity)"
|
||||||
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||||
Caption="Rekesz/csomag" ColSpanMd="2" />
|
Caption="Rekesz/csomag" ColSpanMd="2"/>
|
||||||
|
|
||||||
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.GrossWeight), currentShippingItemPallet))"
|
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.GrossWeight), currentShippingItemPallet))"
|
||||||
Field="@nameof(ShippingItemPallet.GrossWeight)"
|
Field="@nameof(ShippingItemPallet.GrossWeight)"
|
||||||
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||||
Caption="Br.súly(kg)" ColSpanMd="2">
|
Caption="Br.súly(kg)" ColSpanMd="2">
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
<DxFormLayoutItem Caption="Net.súly(kg)" ColSpanMd="2" CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.NetWeight), currentShippingItemPallet))">
|
<DxFormLayoutItem Caption="Net.súly(kg)" ColSpanMd="1" CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.NetWeight), currentShippingItemPallet))">
|
||||||
<text>@(currentShippingItemPallet.NetWeight) kg.</text>
|
<text>@(currentShippingItemPallet.NetWeight) kg.</text>
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
@* <DxFormLayoutItem ColSpanMd="1">
|
<DxFormLayoutItem ColSpanMd="1">
|
||||||
<DxButton Text="@(currentShippingItemPallet.Id == 0 ? "Mentés" : "Módosítás")" Click="() => OnShippingItemPalletSaveClick(currentShippingItemPallet)" CssClass="w-100" />
|
<DxButton Text="@(currentShippingItemPallet.Id == 0 ? "Mentés" : "Módosítás")" Click="() => OnShippingItemPalletSaveClick(currentShippingItemPallet)" CssClass="w-100"/>
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
*@
|
|
||||||
</DxFormLayout>
|
</DxFormLayout>
|
||||||
}
|
}
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
<DxFormLayoutItem Context="vfdfgfd" ColSpanMd="12" BeginRow="true">
|
<DxFormLayoutItem Context="vfdfgfd" ColSpanMd="12" BeginRow="true">
|
||||||
<DxFormLayout CssClass="w-100">
|
<DxFormLayout CssClass="w-100">
|
||||||
<DxFormLayoutItem ColSpanMd="4" BeginRow="false"><strong>TOTAL:</strong></DxFormLayoutItem>
|
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>TOTAL:</strong></DxFormLayoutItem>
|
||||||
|
<DxFormLayoutItem ColSpanMd="2" BeginRow="false" />
|
||||||
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
|
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
|
||||||
|
<DxFormLayoutItem ColSpanMd="2" BeginRow="false" />
|
||||||
|
<DxFormLayoutItem ColSpanMd="2" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredQuantity) db</strong></DxFormLayoutItem>
|
||||||
|
<DxFormLayoutItem ColSpanMd="2" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredGrossWeight) kg</strong></DxFormLayoutItem>
|
||||||
|
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredNetWeight) kg</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>
|
</DxFormLayout>
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
|
|
@ -196,7 +205,7 @@
|
||||||
<ValidationSummary />
|
<ValidationSummary />
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
@if (SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)
|
@* @if (SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)
|
||||||
{
|
{
|
||||||
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
||||||
<DxButton Text="@(SelectedShippingItem.IsMeasured ? "Befejezett mérés módosítása" : "Mérés befejezése")"
|
<DxButton Text="@(SelectedShippingItem.IsMeasured ? "Befejezett mérés módosítása" : "Mérés befejezése")"
|
||||||
|
|
@ -208,7 +217,7 @@
|
||||||
{
|
{
|
||||||
_errorText = "Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...";
|
_errorText = "Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...";
|
||||||
}
|
}
|
||||||
|
*@
|
||||||
@if (!_errorText.IsNullOrWhiteSpace())
|
@if (!_errorText.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,10 @@ namespace FruitBankHybrid.Shared.Pages
|
||||||
|
|
||||||
switch (fieldName)
|
switch (fieldName)
|
||||||
{
|
{
|
||||||
|
case nameof(ShippingItemPallet.TareWeight):
|
||||||
|
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||||
|
(shippingItemPallet.TareWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||||
|
break;
|
||||||
case nameof(ShippingItemPallet.PalletWeight):
|
case nameof(ShippingItemPallet.PalletWeight):
|
||||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||||
(shippingItemPallet.PalletWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
(shippingItemPallet.PalletWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||||
|
|
@ -274,6 +278,10 @@ namespace FruitBankHybrid.Shared.Pages
|
||||||
shippingItemPallet.PalletWeight = (double)newValue;
|
shippingItemPallet.PalletWeight = (double)newValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case nameof(ShippingItemPallet.TareWeight):
|
||||||
|
shippingItemPallet.TareWeight = (double)newValue;
|
||||||
|
break;
|
||||||
|
|
||||||
case nameof(ShippingItemPallet.Quantity):
|
case nameof(ShippingItemPallet.Quantity):
|
||||||
shippingItemPallet.Quantity = (int)newValue;
|
shippingItemPallet.Quantity = (int)newValue;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
using FruitBank.Common.Models;
|
using AyCode.Core.Loggers;
|
||||||
|
using FruitBank.Common.Models;
|
||||||
|
using FruitBankHybrid.Shared.Services.SignalRs;
|
||||||
|
using Mango.Nop.Core.Loggers;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -10,6 +13,10 @@ namespace FruitBankHybrid.Shared.Pages
|
||||||
{
|
{
|
||||||
public partial class MeasuringOut : ComponentBase
|
public partial class MeasuringOut : ComponentBase
|
||||||
{
|
{
|
||||||
|
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
|
||||||
|
[Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; }
|
||||||
[Inject] public required LoggedInModel LoggedInModel { get; set; }
|
[Inject] public required LoggedInModel LoggedInModel { get; set; }
|
||||||
|
|
||||||
|
private ILogger _logger = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,4 +68,8 @@ h1:focus {
|
||||||
mask-repeat: no-repeat;
|
mask-repeat: no-repeat;
|
||||||
-webkit-mask-image: var(--icon-mask-image);
|
-webkit-mask-image: var(--icon-mask-image);
|
||||||
mask-image: var(--icon-mask-image);
|
mask-image: var(--icon-mask-image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.measuring-form-layout {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue