rename: QuantityOnDocument, NetWeightOnDocument, GrossWeightOnDocument; improvements, fixes, etc...
This commit is contained in:
parent
d7e58e28f5
commit
158713a869
|
|
@ -6,9 +6,18 @@ namespace FruitBank.Common.Dtos;
|
||||||
|
|
||||||
public class MeasuringProductDto : ProductDto, IMeasuringProductDto
|
public class MeasuringProductDto : ProductDto, IMeasuringProductDto
|
||||||
{
|
{
|
||||||
public double? NetWeight { get; set; }
|
/// <summary>
|
||||||
public double? GrossWeight { get; set; }
|
/// Reference to StockQuantity, always equals!
|
||||||
public bool? IsMeasurable { get; set; }
|
/// </summary>
|
||||||
|
public int Quantity
|
||||||
|
{
|
||||||
|
get => StockQuantity;
|
||||||
|
set => StockQuantity = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double NetWeight { get; set; }
|
||||||
|
public double GrossWeight { get; set; }
|
||||||
|
public bool IsMeasurable { get; set; }
|
||||||
|
|
||||||
public MeasuringProductDto() :base()
|
public MeasuringProductDto() :base()
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -36,10 +45,12 @@ public class MeasuringProductDto : ProductDto, IMeasuringProductDto
|
||||||
|
|
||||||
base.CopyEntityValuesToDto(entity);
|
base.CopyEntityValuesToDto(entity);
|
||||||
|
|
||||||
NetWeight = measuringAttributeValues?.NetWeight;
|
if (measuringAttributeValues == null) return;
|
||||||
GrossWeight = measuringAttributeValues?.GrossWeight;
|
|
||||||
IsMeasurable = measuringAttributeValues?.IsMeasurable;
|
NetWeight = measuringAttributeValues.NetWeight;
|
||||||
|
GrossWeight = measuringAttributeValues.GrossWeight;
|
||||||
|
IsMeasurable = measuringAttributeValues.IsMeasurable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasValues() => Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
public bool HasMeasuringValues() => Id > 0 && NetWeight > 0 && GrossWeight > 0 && IsMeasurable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,26 +22,27 @@ public class ShippingItem : MgEntityBase, IShippingItem
|
||||||
public int ShippingDocumentId { get; set; }
|
public int ShippingDocumentId { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int QuantityOnDocument { get; set; }
|
||||||
|
|
||||||
[Column(DataType = DataType.DecFloat)] public double NetWeight { get; set; }
|
[Column(DataType = DataType.DecFloat)] public double NetWeightOnDocument { get; set; }
|
||||||
[Column(DataType = DataType.DecFloat)] public double GrossWeight { get; set; }
|
[Column(DataType = DataType.DecFloat)] public double GrossWeightOnDocument { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Nullable]
|
//[Nullable]
|
||||||
[Column(CanBeNull = true)]
|
//[Column(CanBeNull = true)]
|
||||||
[Range(1, 100000, ErrorMessage = "The MeasuredQuantity value should be a number between 1 and 100,000.")]
|
[Range(1, 100000, ErrorMessage = "The MeasuredQuantity value should be a number between 1 and 100,000.")]
|
||||||
public int? MeasuredQuantity { get; set; }
|
public int MeasuredQuantity { get; set; }
|
||||||
|
|
||||||
[Nullable]
|
//[Nullable]
|
||||||
[Column(DataType = DataType.DecFloat, CanBeNull = true)]
|
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
|
||||||
[Range(1, 100000, ErrorMessage = "The MeasuredNetWeight value should be a number between 1 and 100,000.")]
|
[Range(1, 100000, ErrorMessage = "The MeasuredNetWeight value should be a number between 1 and 100,000.")]
|
||||||
public double? MeasuredNetWeight { get; set; }
|
public double MeasuredNetWeight { get; set; }
|
||||||
|
|
||||||
[Nullable]
|
//[Nullable]
|
||||||
[Column(DataType = DataType.DecFloat, CanBeNull = true)]
|
//Precision = 1
|
||||||
|
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
|
||||||
[Range(1, 100000, ErrorMessage = "The MeasuredGrossWeight value should be a number between 1 and 100,000.")]
|
[Range(1, 100000, ErrorMessage = "The MeasuredGrossWeight value should be a number between 1 and 100,000.")]
|
||||||
public double? MeasuredGrossWeight { get; set; }
|
public double MeasuredGrossWeight { get; set; }
|
||||||
|
|
||||||
public bool IsMeasurable { get; set; }
|
public bool IsMeasurable { get; set; }
|
||||||
public bool IsMeasured { get; set; }
|
public bool IsMeasured { get; set; }
|
||||||
|
|
@ -52,6 +53,9 @@ public class ShippingItem : MgEntityBase, IShippingItem
|
||||||
[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; }
|
||||||
|
|
||||||
|
[LinqToDB.Mapping.Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingItemPallet.ShippingItemId), CanBeNull = true)]
|
||||||
|
public List<ShippingItemPallet>? ShippingItemPallets { get; set; }
|
||||||
|
|
||||||
[SkipValuesOnUpdate] public DateTime Created { get; set; }
|
[SkipValuesOnUpdate] public DateTime Created { get; set; }
|
||||||
public DateTime Modified { get; set; }
|
public DateTime Modified { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using FruitBank.Common.Interfaces;
|
||||||
|
using LinqToDB.Mapping;
|
||||||
|
using Mango.Nop.Core.Entities;
|
||||||
|
using DataType = LinqToDB.DataType;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Entities;
|
||||||
|
|
||||||
|
[Table(Name = FruitBankConstClient.ShippingItemPalletDbTableName)]
|
||||||
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemPalletDbTableName)]
|
||||||
|
public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
|
||||||
|
{
|
||||||
|
public int ShippingItemId { get; set; }
|
||||||
|
|
||||||
|
//[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; }
|
||||||
|
|
||||||
|
//[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; }
|
||||||
|
|
||||||
|
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingItemId), OtherKey = nameof(ShippingItem.Id), CanBeNull = true)]
|
||||||
|
public ShippingItem? ShippingItem { 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 bool IsValidMeasuringValues()
|
||||||
|
{
|
||||||
|
return ShippingItemId > 0 && Quantity > 0 && NetWeight > 0 && GrossWeight > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,7 @@ public static class FruitBankConstClient
|
||||||
public const string PartnerDbTableName = "fbPartner";
|
public const string PartnerDbTableName = "fbPartner";
|
||||||
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 ShippingDocumentDbTableName = "fbShippingDocument";
|
public const string ShippingDocumentDbTableName = "fbShippingDocument";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,9 @@
|
||||||
|
|
||||||
namespace FruitBank.Common.Interfaces;
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
public interface IMeasuringAttributeValues : IEntityInt
|
public interface IMeasuringAttributeValues : IMeasuringWeights, IEntityInt
|
||||||
{
|
{
|
||||||
double? NetWeight { get; set; }
|
bool IsMeasurable { get; set; }
|
||||||
double? GrossWeight { get; set; }
|
|
||||||
|
|
||||||
bool? IsMeasurable { get; set; }
|
bool HasMeasuringValues(); //=> Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
||||||
|
|
||||||
bool HasValues(); //=> Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IMeasuringValues : IMeasuringWeights
|
||||||
|
{
|
||||||
|
int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IMeasuringWeights
|
||||||
|
{
|
||||||
|
double NetWeight { get; set; }
|
||||||
|
double GrossWeight { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -11,19 +11,20 @@ public interface IShippingItem : IEntityInt, ITimeStampInfo
|
||||||
int? ProductId { get; set; }
|
int? ProductId { get; set; }
|
||||||
|
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
int Quantity { get; set; }
|
int QuantityOnDocument { get; set; }
|
||||||
double NetWeight { get; set; }
|
double NetWeightOnDocument { get; set; }
|
||||||
double GrossWeight { get; set; }
|
double GrossWeightOnDocument { get; set; }
|
||||||
|
|
||||||
int? MeasuredQuantity { get; set; }
|
int MeasuredQuantity { get; set; }
|
||||||
double? MeasuredNetWeight { get; set; }
|
double MeasuredNetWeight { get; set; }
|
||||||
double? MeasuredGrossWeight { get; set; }
|
double MeasuredGrossWeight { get; set; }
|
||||||
|
|
||||||
bool IsMeasurable { get; set; }
|
bool IsMeasurable { get; set; }
|
||||||
bool IsMeasured { 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 bool IsValidMeasuringValues();
|
public bool IsValidMeasuringValues();
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using AyCode.Interfaces.Entities;
|
||||||
|
using AyCode.Interfaces.TimeStampInfo;
|
||||||
|
using FruitBank.Common.Entities;
|
||||||
|
|
||||||
|
namespace FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IShippingItemPallet : IEntityInt, IMeasuringValues, ITimeStampInfo
|
||||||
|
{
|
||||||
|
int ShippingItemId { get; set; }
|
||||||
|
public ShippingItem? ShippingItem { get; set; }
|
||||||
|
|
||||||
|
public int? CreatorId { get; set; }
|
||||||
|
public int? ModifierId { get; set; }
|
||||||
|
|
||||||
|
public bool IsValidMeasuringValues();
|
||||||
|
}
|
||||||
|
|
@ -7,20 +7,20 @@ public class MeasuringAttributeValues : IMeasuringAttributeValues
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public double? NetWeight { get; set; }
|
public double NetWeight { get; set; }
|
||||||
public double? GrossWeight { get; set; }
|
public double GrossWeight { get; set; }
|
||||||
public bool? IsMeasurable { get; set; }
|
public bool IsMeasurable { get; set; }
|
||||||
|
|
||||||
public MeasuringAttributeValues()
|
public MeasuringAttributeValues()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public MeasuringAttributeValues(int entityId, double? netWeight, double? grossWeight, bool? isMeasurable)
|
public MeasuringAttributeValues(int entityId, double netWeight, double grossWeight, bool isMeasurable)
|
||||||
{
|
{
|
||||||
Initialize(entityId, netWeight, grossWeight, isMeasurable);
|
Initialize(entityId, netWeight, grossWeight, isMeasurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(int entityId, double? netWeight, double? grossWeight, bool? isMeasurable)
|
public void Initialize(int entityId, double netWeight, double grossWeight, bool isMeasurable)
|
||||||
{
|
{
|
||||||
Id = entityId;
|
Id = entityId;
|
||||||
NetWeight = netWeight;
|
NetWeight = netWeight;
|
||||||
|
|
@ -28,7 +28,7 @@ public class MeasuringAttributeValues : IMeasuringAttributeValues
|
||||||
IsMeasurable = isMeasurable;
|
IsMeasurable = isMeasurable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasValues() => Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
public bool HasMeasuringValues() => Id > 0 && NetWeight > 0 && GrossWeight > 0 && IsMeasurable;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
using AyCode.Core.Enums;
|
using AyCode.Core.Enums;
|
||||||
using AyCode.Core.Loggers;
|
using AyCode.Core.Loggers;
|
||||||
using AyCode.Utils.Extensions;
|
using AyCode.Utils.Extensions;
|
||||||
|
using FruitBank.Common;
|
||||||
|
using FruitBank.Common.Dtos;
|
||||||
using FruitBank.Common.Entities;
|
using FruitBank.Common.Entities;
|
||||||
using FruitBank.Common.Interfaces;
|
using FruitBank.Common.Interfaces;
|
||||||
using FruitBank.Common.Loggers;
|
using FruitBank.Common.Loggers;
|
||||||
using FruitBankHybrid.Shared.Services.SignalRs;
|
using FruitBankHybrid.Shared.Services.SignalRs;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.InteropServices.JavaScript;
|
using System.Runtime.InteropServices.JavaScript;
|
||||||
using FruitBank.Common;
|
// ReSharper disable CompareOfFloatsByEqualityOperator
|
||||||
|
|
||||||
namespace FruitBankHybrid.Shared.Tests
|
namespace FruitBankHybrid.Shared.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -154,9 +156,9 @@ namespace FruitBankHybrid.Shared.Tests
|
||||||
Assert.IsNotNull(shippingItem.Product, $"shippingItem.Product == null; shippingItem.Id: {shippingItem.ProductId}");
|
Assert.IsNotNull(shippingItem.Product, $"shippingItem.Product == null; shippingItem.Id: {shippingItem.ProductId}");
|
||||||
Assert.IsTrue(shippingItem.Id == shippingItemId);
|
Assert.IsTrue(shippingItem.Id == shippingItemId);
|
||||||
|
|
||||||
Assert.IsTrue(shippingItem.Quantity > 0, "Quantity == 0");
|
Assert.IsTrue(shippingItem.QuantityOnDocument > 0, "QuantityOnDocument == 0");
|
||||||
Assert.IsTrue(shippingItem.NetWeight > 0, "NetWeight == 0");
|
Assert.IsTrue(shippingItem.NetWeightOnDocument > 0, "NetWeightOnDocument == 0");
|
||||||
Assert.IsTrue(shippingItem.GrossWeight > 0, "GrossWeight == 0");
|
Assert.IsTrue(shippingItem.GrossWeightOnDocument > 0, "GrossWeightOnDocument == 0");
|
||||||
|
|
||||||
return shippingItem;
|
return shippingItem;
|
||||||
}
|
}
|
||||||
|
|
@ -164,39 +166,50 @@ namespace FruitBankHybrid.Shared.Tests
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow(1)]
|
[DataRow(1)]
|
||||||
[DataRow(2)]
|
[DataRow(2)]
|
||||||
//[DataRow(3)]
|
[DataRow(3)]
|
||||||
//[DataRow(4)]
|
[DataRow(4)]
|
||||||
|
[DataRow(5)]
|
||||||
public async Task UpdateShippingItemTest(int shippingItemId)
|
public async Task UpdateShippingItemTest(int shippingItemId)
|
||||||
{
|
{
|
||||||
|
const int incQuantity = 1;
|
||||||
|
var incNetWeight = 2.137563300001;
|
||||||
|
var incGrossWeight = 3.75238200001;
|
||||||
|
|
||||||
var originalShippingItem = await GetShippingItemByIdTest(shippingItemId);
|
var originalShippingItem = await GetShippingItemByIdTest(shippingItemId);
|
||||||
var newName = GetFixtureName(originalShippingItem.Name);
|
var originalMeasuringProductDto = await GetMeasuringProductDtoByIdTest(originalShippingItem.ProductId!.Value, originalShippingItem.IsMeasurable);
|
||||||
|
|
||||||
|
Assert.IsTrue(originalShippingItem.IsMeasurable == originalMeasuringProductDto.IsMeasurable);
|
||||||
|
|
||||||
var shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
var shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
||||||
shippingItem.Name = newName;
|
|
||||||
//shippingItem.MeasuredGrossWeight = 5;
|
|
||||||
shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
|
||||||
|
|
||||||
Assert.IsNotNull(shippingItem);
|
shippingItem.MeasuredQuantity += incQuantity;
|
||||||
Assert.IsNotNull(shippingItem.Product);
|
shippingItem.MeasuredNetWeight += incNetWeight;
|
||||||
Assert.IsTrue(shippingItem.Name == newName);
|
shippingItem.MeasuredGrossWeight += incGrossWeight;
|
||||||
Assert.IsTrue(shippingItem.Product.StockQuantity == originalShippingItem.Product!.StockQuantity);
|
|
||||||
|
|
||||||
shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
|
||||||
|
|
||||||
Assert.IsTrue(shippingItem.Name == newName);
|
|
||||||
Assert.IsTrue(shippingItem.Product!.StockQuantity == originalShippingItem.Product.StockQuantity);
|
|
||||||
//Assert.IsTrue(shippingItem.MeasuredGrossWeight is 5);
|
|
||||||
|
|
||||||
shippingItem.Name = GetOriginalName(shippingItem.Name);
|
|
||||||
shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
shippingItem = await _signalRClient.UpdateShippingItem(shippingItem);
|
||||||
|
|
||||||
Assert.IsNotNull(shippingItem);
|
Assert.IsNotNull(shippingItem);
|
||||||
Assert.IsNotNull(shippingItem.Product);
|
Assert.IsNotNull(shippingItem.Product);
|
||||||
|
|
||||||
shippingItem = await GetShippingItemByIdTest(shippingItemId);
|
//incNetWeight = double.Round(incNetWeight, 1);
|
||||||
|
//incGrossWeight = double.Round(incGrossWeight, 1);
|
||||||
|
|
||||||
Assert.IsTrue(shippingItem.Name == originalShippingItem.Name);
|
Assert.IsTrue(shippingItem.IsMeasured);
|
||||||
Assert.IsTrue(shippingItem.Product!.StockQuantity == originalShippingItem.Product.StockQuantity);
|
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 GetMeasuringProductDtoByIdTest(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));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion ShippingItem
|
#endregion ShippingItem
|
||||||
|
|
@ -289,22 +302,31 @@ namespace FruitBankHybrid.Shared.Tests
|
||||||
Assert.IsTrue(measuringProductDtos.Count != 0);
|
Assert.IsTrue(measuringProductDtos.Count != 0);
|
||||||
|
|
||||||
Assert.IsTrue(measuringProductDtos.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
Assert.IsTrue(measuringProductDtos.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
||||||
Assert.IsTrue(measuringProductDtos.All(x => !x.IsMeasurable.GetValueOrDefault(false) || x.HasValues()));
|
Assert.IsTrue(measuringProductDtos.All(x => !x.IsMeasurable || x.HasMeasuringValues()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
//[TestMethod]
|
||||||
[DataRow(1)]
|
//[DataRow(1)]
|
||||||
[DataRow(5)]
|
//[DataRow(5)]
|
||||||
[DataRow(33)]
|
//[DataRow(33)]
|
||||||
//[DataRow(3)]
|
public async Task<MeasuringProductDto> GetMeasuringProductDtoByIdTest(int productId, bool isMeasurableExcepted)
|
||||||
public async Task GetMeasuringProductDtoByIdTest(int productId)
|
|
||||||
{
|
{
|
||||||
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(productId);
|
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(productId);
|
||||||
|
|
||||||
Assert.IsNotNull(measuringProductDto);
|
Assert.IsNotNull(measuringProductDto);
|
||||||
Assert.IsTrue(measuringProductDto.HasValues());
|
|
||||||
//Assert.IsTrue(measuringProductDto.HasValues());
|
if (isMeasurableExcepted) Assert.IsTrue(measuringProductDto.HasMeasuringValues(), $"{measuringProductDto.IsMeasurable}, {measuringProductDto.NetWeight}, {measuringProductDto.GrossWeight}");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.IsTrue(measuringProductDto.Id > 0);
|
||||||
|
Assert.IsTrue(measuringProductDto.StockQuantity > 0);
|
||||||
|
Assert.IsTrue(measuringProductDto.NetWeight == 0);
|
||||||
|
Assert.IsTrue(measuringProductDto.GrossWeight == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return measuringProductDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Product
|
#endregion Product
|
||||||
|
|
||||||
#region Login
|
#region Login
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,8 @@
|
||||||
@* <DataAnnotationsValidator /> *@
|
@* <DataAnnotationsValidator /> *@
|
||||||
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))">
|
<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="6" />
|
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="6" />
|
||||||
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.GrossWeight)" Caption="GrossWeight:" Enabled="false" ColSpanMd="3" />
|
<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.NetWeight)" Caption="NetWeight:" Enabled="false" ColSpanMd="3" />
|
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.NetWeightOnDocument)" Caption="NetWeightOnDocument:" Enabled="false" ColSpanMd="3" />
|
||||||
|
|
||||||
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
||||||
Field="@nameof(ShippingItem.MeasuredQuantity)"
|
Field="@nameof(ShippingItem.MeasuredQuantity)"
|
||||||
|
|
|
||||||
|
|
@ -189,13 +189,13 @@ namespace FruitBankHybrid.Shared.Pages
|
||||||
// SelectedShippingItem.NetWeight = (double)newValue;
|
// SelectedShippingItem.NetWeight = (double)newValue;
|
||||||
// break;
|
// break;
|
||||||
case nameof(ShippingItem.MeasuredQuantity):
|
case nameof(ShippingItem.MeasuredQuantity):
|
||||||
SelectedShippingItem.MeasuredQuantity = (int)newValue <= 0 ? null : (int)newValue;
|
SelectedShippingItem.MeasuredQuantity = (int)newValue <= 0 ? 0 : (int)newValue;
|
||||||
break;
|
break;
|
||||||
case nameof(ShippingItem.MeasuredNetWeight):
|
case nameof(ShippingItem.MeasuredNetWeight):
|
||||||
SelectedShippingItem.MeasuredNetWeight = !SelectedShippingItem.IsMeasurable || (double)newValue <= 0 ? null : (double)newValue;
|
SelectedShippingItem.MeasuredNetWeight = !SelectedShippingItem.IsMeasurable || (double)newValue <= 0 ? 0 : (double)newValue;
|
||||||
break;
|
break;
|
||||||
case nameof(ShippingItem.MeasuredGrossWeight):
|
case nameof(ShippingItem.MeasuredGrossWeight):
|
||||||
SelectedShippingItem.MeasuredGrossWeight = !SelectedShippingItem.IsMeasurable || (double)newValue <= 0 ? null : (double)newValue;
|
SelectedShippingItem.MeasuredGrossWeight = !SelectedShippingItem.IsMeasurable || (double)newValue <= 0 ? 0 : (double)newValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue