This commit is contained in:
Loretta 2025-10-21 08:13:28 +02:00
parent 434a058efc
commit a261318005
1 changed files with 8 additions and 3 deletions

View File

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