|
@ -1,3 +1,4 @@ |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
@ -20,13 +21,28 @@ public class UnplannedReceiptNoteEventHandler |
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<UnplannedReceiptNote> eventData) |
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<UnplannedReceiptNote> eventData) |
|
|
{ |
|
|
{ |
|
|
var entity = eventData.Entity; |
|
|
var entity = eventData.Entity; |
|
|
await AddExchangeDataAsync(entity).ConfigureAwait(false); |
|
|
var copy = CopyEntity(entity); |
|
|
|
|
|
if (entity.Details != null && entity.Details.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
await AddExchangeDataAsync(copy).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
[UnitOfWork] |
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<UnplannedReceiptNote>> eventData) |
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<UnplannedReceiptNote>> eventData) |
|
|
{ |
|
|
{ |
|
|
var entities = eventData.Entity; |
|
|
var entities = eventData.Entity; |
|
|
|
|
|
List<UnplannedReceiptNote> notelist = new List<UnplannedReceiptNote>(); |
|
|
|
|
|
foreach (var entity in entities) |
|
|
|
|
|
{ |
|
|
|
|
|
if (entity.Details != null && entity.Details.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var copy = CopyEntity(entity); |
|
|
|
|
|
notelist.Add(copy); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
await AddExchangeDataAsync(entities).ConfigureAwait(false); |
|
|
await AddExchangeDataAsync(entities).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -40,5 +56,19 @@ public class UnplannedReceiptNoteEventHandler |
|
|
var exchangeData = await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, dtos).ConfigureAwait(false); |
|
|
var exchangeData = await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, dtos).ConfigureAwait(false); |
|
|
await AddManyAsync(exchangeData).ConfigureAwait(false); |
|
|
await AddManyAsync(exchangeData).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
private UnplannedReceiptNote CopyEntity(UnplannedReceiptNote p_note) |
|
|
|
|
|
{ |
|
|
|
|
|
var json = System.Text.Json.JsonSerializer.Serialize(p_note); |
|
|
|
|
|
|
|
|
|
|
|
var copy = System.Text.Json.JsonSerializer.Deserialize<UnplannedReceiptNote>(json); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var detail in copy.Details) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Qty = detail.Qty != 0 ? -Math.Abs(detail.Qty) : 0; |
|
|
|
|
|
detail.HandledQty = detail.HandledQty != 0 ? -Math.Abs(detail.HandledQty) : 0; |
|
|
|
|
|
detail.RecommendQty = detail.RecommendQty != 0 ? -Math.Abs(detail.RecommendQty) : 0; |
|
|
|
|
|
} |
|
|
|
|
|
return copy; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|