This commit is contained in:
Adam 2025-10-21 09:02:06 +02:00
commit 9cb032db3d
1 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using FruitBank.Common.Entities;
using FruitBank.Common.Interfaces;
using LinqToDB;
using Mango.Nop.Core.Repositories;
using Nop.Core.Caching;
@ -18,13 +19,15 @@ public class ShippingItemDbTable : MgDbTableBase<ShippingItem>
protected override void OnUpdate(ShippingItem entity)
{
RoundMeasuredValue(entity);
PrepareValues(entity);
base.OnUpdate(entity);
}
protected override void OnInsert(ShippingItem entity)
{
RoundMeasuredValue(entity);
entity.MeasuringCount = entity.PalletsOnDocument;
PrepareValues(entity);
base.OnInsert(entity);
}
@ -56,8 +59,10 @@ public class ShippingItemDbTable : MgDbTableBase<ShippingItem>
public IQueryable<ShippingItem> GetAllByShippingDocumentIdAsync(int shippingDocumentId, bool loadRelations)
=> GetAll(loadRelations).Where(si => si.ShippingDocumentId == shippingDocumentId);
private static void RoundMeasuredValue(ShippingItem shippingItem)
private static void PrepareValues(ShippingItem shippingItem)
{
if (shippingItem.MeasuringCount < 1) shippingItem.MeasuringCount = 1;
shippingItem.MeasuredNetWeight = double.Round(shippingItem.MeasuredNetWeight, 1);
shippingItem.MeasuredGrossWeight = double.Round(shippingItem.MeasuredGrossWeight, 1);
}