-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathShipmentViewModelService.cs
More file actions
591 lines (537 loc) · 26.6 KB
/
ShipmentViewModelService.cs
File metadata and controls
591 lines (537 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Shipping;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Catalog;
using Grand.Domain.Directory;
using Grand.Domain.Orders;
using Grand.Domain.Shipping;
using Grand.Infrastructure;
using Grand.Web.Admin.Interfaces;
using Grand.Web.Admin.Models.Orders;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services;
public class ShipmentViewModelService : IShipmentViewModelService
{
private readonly ICountryService _countryService;
private readonly IDateTimeService _dateTimeService;
private readonly IDownloadService _downloadService;
private readonly IMeasureService _measureService;
private readonly MeasureSettings _measureSettings;
private readonly IOrderService _orderService;
private readonly IProductService _productService;
private readonly IShipmentService _shipmentService;
private readonly ShippingProviderSettings _shippingProviderSettings;
private readonly IShippingService _shippingService;
private readonly ShippingSettings _shippingSettings;
private readonly IStockQuantityService _stockQuantityService;
private readonly ITranslationService _translationService;
private readonly IWarehouseService _warehouseService;
private readonly IContextAccessor _contextAccessor;
public ShipmentViewModelService(
IOrderService orderService,
IContextAccessor contextAccessor,
IProductService productService,
IShipmentService shipmentService,
IWarehouseService warehouseService,
IMeasureService measureService,
IDateTimeService dateTimeService,
ICountryService countryService,
ITranslationService translationService,
IDownloadService downloadService,
IShippingService shippingService,
IStockQuantityService stockQuantityService,
MeasureSettings measureSettings,
ShippingSettings shippingSettings,
ShippingProviderSettings shippingProviderSettings)
{
_orderService = orderService;
_contextAccessor = contextAccessor;
_productService = productService;
_shipmentService = shipmentService;
_warehouseService = warehouseService;
_measureService = measureService;
_dateTimeService = dateTimeService;
_countryService = countryService;
_translationService = translationService;
_downloadService = downloadService;
_shippingService = shippingService;
_stockQuantityService = stockQuantityService;
_measureSettings = measureSettings;
_shippingSettings = shippingSettings;
_shippingProviderSettings = shippingProviderSettings;
}
public virtual async Task<ShipmentModel> PrepareShipmentModel(Shipment shipment, bool prepareProducts,
bool prepareShipmentEvent = false)
{
//measures
var baseWeight = await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId);
var baseWeightIn = baseWeight != null ? baseWeight.Name : "";
var baseDimension = await _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId);
var baseDimensionIn = baseDimension != null ? baseDimension.Name : "";
var order = await _orderService.GetOrderById(shipment.OrderId);
var model = new ShipmentModel {
Id = shipment.Id,
ShipmentNumber = shipment.ShipmentNumber,
OrderId = shipment.OrderId,
OrderNumber = order?.OrderNumber ?? 0,
OrderCode = order != null ? order.Code : "",
TrackingNumber = shipment.TrackingNumber,
TotalWeight = shipment.TotalWeight.HasValue ? $"{shipment.TotalWeight:F2} [{baseWeightIn}]" : "",
ShippedDate = shipment.ShippedDateUtc.HasValue
? _dateTimeService.ConvertToUserTime(shipment.ShippedDateUtc.Value, DateTimeKind.Utc)
: new DateTime?(),
ShippedDateUtc = shipment.ShippedDateUtc,
CanShip = !shipment.ShippedDateUtc.HasValue,
DeliveryDate = shipment.DeliveryDateUtc.HasValue
? _dateTimeService.ConvertToUserTime(shipment.DeliveryDateUtc.Value, DateTimeKind.Utc)
: new DateTime?(),
DeliveryDateUtc = shipment.DeliveryDateUtc,
CanDeliver = shipment.ShippedDateUtc.HasValue && !shipment.DeliveryDateUtc.HasValue,
AdminComment = shipment.AdminComment,
UserFields = shipment.UserFields
};
if (prepareProducts)
foreach (var shipmentItem in shipment.ShipmentItems)
{
var orderItem = order?.OrderItems.FirstOrDefault(x => x.Id == shipmentItem.OrderItemId);
if (orderItem == null)
continue;
//quantities
var qtyInThisShipment = shipmentItem.Quantity;
var maxQtyToAdd = orderItem.OpenQty;
var qtyOrdered = shipmentItem.Quantity;
var qtyInAllShipments = orderItem.ShipQty;
var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
if (product != null)
{
var warehouse = await _warehouseService.GetWarehouseById(shipmentItem.WarehouseId);
var shipmentItemModel = new ShipmentModel.ShipmentItemModel {
Id = shipmentItem.Id,
OrderItemId = orderItem.Id,
ProductId = orderItem.ProductId,
ProductName = product.Name,
Sku = product.FormatSku(orderItem.Attributes),
AttributeInfo = orderItem.AttributeDescription,
ShippedFromWarehouse = warehouse?.Name,
ShipSeparately = product.ShipSeparately,
ItemWeight = orderItem.ItemWeight.HasValue
? $"{orderItem.ItemWeight:F2} [{baseWeightIn}]"
: "",
ItemDimensions =
$"{product.Length:F2} x {product.Width:F2} x {product.Height:F2} [{baseDimensionIn}]",
QuantityOrdered = qtyOrdered,
QuantityInThisShipment = qtyInThisShipment,
QuantityInAllShipments = qtyInAllShipments,
QuantityToAdd = maxQtyToAdd
};
model.Items.Add(shipmentItemModel);
}
}
if (prepareShipmentEvent && !string.IsNullOrEmpty(shipment.TrackingNumber))
{
var srcm = _shippingService.LoadShippingRateCalculationProviderBySystemName(order?.ShippingRateProviderSystemName);
if (srcm != null &&
srcm.IsShippingRateMethodActive(_shippingProviderSettings))
{
var shipmentTracker = srcm.ShipmentTracker;
if (shipmentTracker != null)
{
model.TrackingNumberUrl = await shipmentTracker.GetUrl(shipment.TrackingNumber);
if (_shippingSettings.DisplayShipmentEventsToStoreOwner)
{
var shipmentEvents = await shipmentTracker.GetShipmentEvents(shipment.TrackingNumber);
if (shipmentEvents != null)
foreach (var shipmentEvent in shipmentEvents)
{
var shipmentStatusEventModel = new ShipmentModel.ShipmentStatusEventModel();
var shipmentEventCountry =
await _countryService.GetCountryByTwoLetterIsoCode(shipmentEvent.CountryCode);
shipmentStatusEventModel.Country = shipmentEventCountry != null
? shipmentEventCountry.GetTranslation(x => x.Name,
_contextAccessor.WorkContext.WorkingLanguage.Id)
: shipmentEvent.CountryCode;
shipmentStatusEventModel.Date = shipmentEvent.Date;
shipmentStatusEventModel.EventName = shipmentEvent.EventName;
shipmentStatusEventModel.Location = shipmentEvent.Location;
model.ShipmentStatusEvents.Add(shipmentStatusEventModel);
}
}
}
}
}
return model;
}
public virtual async Task<int> GetStockQty(Product product, string warehouseId)
{
var _qty = new List<int>();
foreach (var item in product.BundleProducts)
{
var p1 = await _productService.GetProductById(item.ProductId);
if (p1.UseMultipleWarehouses)
{
var stock = p1.ProductWarehouseInventory.FirstOrDefault(x => x.WarehouseId == warehouseId);
if (stock != null) _qty.Add(stock.StockQuantity / item.Quantity);
}
else
{
_qty.Add(p1.StockQuantity / item.Quantity);
}
}
return _qty.Count > 0 ? _qty.Min() : 0;
}
public virtual async Task<int> GetReservedQty(Product product, string warehouseId)
{
var _qty = new List<int>();
foreach (var item in product.BundleProducts)
{
var p1 = await _productService.GetProductById(item.ProductId);
if (p1.UseMultipleWarehouses)
{
var stock = p1.ProductWarehouseInventory.FirstOrDefault(x => x.WarehouseId == warehouseId);
if (stock != null) _qty.Add(stock.ReservedQuantity / item.Quantity);
}
}
return _qty.Count > 0 ? _qty.Min() : 0;
}
public virtual async Task<IList<ShipmentModel.ShipmentNote>> PrepareShipmentNotes(Shipment shipment)
{
//shipment notes
var shipmentNoteModels = new List<ShipmentModel.ShipmentNote>();
foreach (var shipmentNote in (await _shipmentService.GetShipmentNotes(shipment.Id))
.OrderByDescending(on => on.CreatedOnUtc))
{
var download = await _downloadService.GetDownloadById(shipmentNote.DownloadId);
shipmentNoteModels.Add(new ShipmentModel.ShipmentNote {
Id = shipmentNote.Id,
ShipmentId = shipment.Id,
DownloadId = string.IsNullOrEmpty(shipmentNote.DownloadId) ? "" : shipmentNote.DownloadId,
DownloadGuid = download?.DownloadGuid ?? Guid.Empty,
DisplayToCustomer = shipmentNote.DisplayToCustomer,
Note = shipmentNote.Note,
CreatedOn = _dateTimeService.ConvertToUserTime(shipmentNote.CreatedOnUtc, DateTimeKind.Utc),
CreatedByCustomer = shipmentNote.CreatedByCustomer
});
}
return shipmentNoteModels;
}
public virtual async Task InsertShipmentNote(Shipment shipment, string downloadId, bool displayToCustomer,
string message)
{
var shipmentNote = new ShipmentNote {
DisplayToCustomer = displayToCustomer,
Note = message,
DownloadId = downloadId,
ShipmentId = shipment.Id
};
await _shipmentService.InsertShipmentNote(shipmentNote);
//new shipment note notification
// TODO
}
public virtual async Task DeleteShipmentNote(Shipment shipment, string id)
{
var shipmentNote = (await _shipmentService.GetShipmentNotes(shipment.Id)).FirstOrDefault(on => on.Id == id);
if (shipmentNote == null)
throw new ArgumentException("No shipment note found with the specified id");
shipmentNote.ShipmentId = shipment.Id;
await _shipmentService.DeleteShipmentNote(shipmentNote);
//delete an old "attachment" file
if (!string.IsNullOrEmpty(shipmentNote.DownloadId))
{
var attachment = await _downloadService.GetDownloadById(shipmentNote.DownloadId);
if (attachment != null)
await _downloadService.DeleteDownload(attachment);
}
}
public virtual async Task<(IEnumerable<Shipment> shipments, int totalCount)> PrepareShipments(
ShipmentListModel model, int pageIndex, int pageSize)
{
DateTime? startDateValue = model.StartDate == null
? null
: _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);
DateTime? endDateValue = model.EndDate == null
? null
: _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);
//load shipments
var shipments = await _shipmentService.GetAllShipments(
model.StoreId,
model.VendorId,
model.WarehouseId,
model.CountryId,
model.StateProvinceId,
model.City,
model.TrackingNumber,
model.LoadNotShipped,
startDateValue,
endDateValue,
pageIndex - 1,
pageSize);
return (shipments.ToList(), shipments.TotalCount);
}
public virtual async Task<ShipmentListModel> PrepareShipmentListModel()
{
var model = new ShipmentListModel();
//countries
model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = "" });
foreach (var c in await _countryService.GetAllCountries(showHidden: true))
model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });
//states
model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });
//warehouses
model.AvailableWarehouses.Add(new SelectListItem
{ Text = _translationService.GetResource("Admin.Common.All"), Value = "" });
foreach (var w in await _warehouseService.GetAllWarehouses())
model.AvailableWarehouses.Add(new SelectListItem { Text = w.Name, Value = w.Id });
return model;
}
public virtual async Task<ShipmentModel> PrepareShipmentModel(Order order)
{
var model = new ShipmentModel {
OrderId = order.Id,
OrderNumber = order.OrderNumber
};
//measures
var baseWeight = await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId);
var baseWeightIn = baseWeight != null ? baseWeight.Name : "";
var baseDimension = await _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId);
var baseDimensionIn = baseDimension != null ? baseDimension.Name : "";
foreach (var orderItem in order.OrderItems)
{
var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
//we can ship only shippable products
if (!product.IsShipEnabled)
continue;
//quantities
var qtyInThisShipment = 0;
var maxQtyToAdd = orderItem.OpenQty;
var qtyOrdered = orderItem.Quantity;
var qtyInAllShipments = orderItem.ShipQty;
//ensure that this product can be added to a shipment
if (maxQtyToAdd <= 0)
continue;
var shipmentItemModel = new ShipmentModel.ShipmentItemModel {
OrderItemId = orderItem.Id,
ProductId = orderItem.ProductId,
ProductName = product.Name,
WarehouseId = orderItem.WarehouseId,
Sku = product.FormatSku(orderItem.Attributes),
AttributeInfo = orderItem.AttributeDescription,
ShipSeparately = product.ShipSeparately,
ItemWeight = orderItem.ItemWeight.HasValue ? $"{orderItem.ItemWeight:F2} [{baseWeightIn}]" : "",
ItemDimensions =
$"{product.Length:F2} x {product.Width:F2} x {product.Height:F2} [{baseDimensionIn}]",
QuantityOrdered = qtyOrdered,
QuantityInThisShipment = qtyInThisShipment,
QuantityInAllShipments = qtyInAllShipments,
QuantityToAdd = maxQtyToAdd
};
switch (product.ManageInventoryMethodId)
{
case ManageInventoryMethod.ManageStock when product.UseMultipleWarehouses:
{
//multiple warehouses supported
shipmentItemModel.AllowToChooseWarehouse = true;
foreach (var pwi in product.ProductWarehouseInventory
.OrderBy(w => w.WarehouseId).ToList())
{
var warehouse = await _warehouseService.GetWarehouseById(pwi.WarehouseId);
if (warehouse != null)
shipmentItemModel.AvailableWarehouses.Add(
new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
WarehouseCode = warehouse.Code,
StockQuantity = pwi.StockQuantity,
ReservedQuantity = pwi.ReservedQuantity
});
}
break;
}
case ManageInventoryMethod.ManageStock:
{
//multiple warehouses are not supported
var warehouse = await _warehouseService.GetWarehouseById(product.WarehouseId);
if (warehouse != null)
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
WarehouseCode = warehouse.Code,
StockQuantity = product.StockQuantity
});
break;
}
case ManageInventoryMethod.ManageStockByAttributes when product.UseMultipleWarehouses:
{
//multiple warehouses supported
shipmentItemModel.AllowToChooseWarehouse = true;
var comb = product.FindProductAttributeCombination(orderItem.Attributes);
if (comb != null)
foreach (var pwi in comb.WarehouseInventory
.OrderBy(w => w.WarehouseId).ToList())
{
var warehouse = await _warehouseService.GetWarehouseById(pwi.WarehouseId);
if (warehouse != null)
shipmentItemModel.AvailableWarehouses.Add(
new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
StockQuantity = pwi.StockQuantity,
WarehouseCode = warehouse.Code,
ReservedQuantity = pwi.ReservedQuantity
});
}
break;
}
case ManageInventoryMethod.ManageStockByAttributes:
{
//multiple warehouses are not supported
var warehouse = await _warehouseService.GetWarehouseById(product.WarehouseId);
if (warehouse != null)
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
WarehouseCode = warehouse.Code,
StockQuantity = product.StockQuantity
});
break;
}
}
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByBundleProducts)
{
if (!string.IsNullOrEmpty(orderItem.WarehouseId))
{
var warehouse = await _warehouseService.GetWarehouseById(product.WarehouseId);
if (warehouse != null)
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
WarehouseCode = warehouse.Code,
StockQuantity = await GetStockQty(product, orderItem.WarehouseId),
ReservedQuantity = await GetReservedQty(product, orderItem.WarehouseId)
});
}
else
{
shipmentItemModel.AllowToChooseWarehouse = false;
if (shipmentItemModel.AllowToChooseWarehouse)
{
var warehouses = await _warehouseService.GetAllWarehouses();
foreach (var warehouse in warehouses)
shipmentItemModel.AvailableWarehouses.Add(
new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
WarehouseCode = warehouse.Code,
StockQuantity = await GetStockQty(product, warehouse.Id),
ReservedQuantity = await GetReservedQty(product, warehouse.Id)
});
}
}
}
model.Items.Add(shipmentItemModel);
}
return model;
}
public virtual async Task<(bool valid, string message)> ValidStockShipment(Shipment shipment)
{
foreach (var item in shipment.ShipmentItems)
{
var product = await _productService.GetProductById(item.ProductId);
switch (product.ManageInventoryMethodId)
{
case ManageInventoryMethod.ManageStock:
{
var stock = _stockQuantityService.GetTotalStockQuantity(product, false,
item.WarehouseId);
if (stock - item.Quantity < 0)
return (false, $"Out of stock for product {product.Name}");
break;
}
case ManageInventoryMethod.ManageStockByAttributes:
{
var combination = product.FindProductAttributeCombination(item.Attributes);
if (combination == null)
return (false, $"Can't find combination for product {product.Name}");
var stock = _stockQuantityService.GetTotalStockQuantityForCombination(product, combination,
false, item.WarehouseId);
if (stock - item.Quantity < 0)
return (false, $"Out of stock for product {product.Name}");
break;
}
}
}
return (true, string.Empty);
}
public virtual async Task<(Shipment shipment, double? totalWeight)> PrepareShipment(Order order,
IEnumerable<OrderItem> orderItems, AddShipmentModel model)
{
Shipment shipment = null;
double? totalWeight = null;
foreach (var orderItem in orderItems)
{
//is shippable
if (!orderItem.IsShipEnabled)
continue;
//ensure that this product can be shipped (have at least one item to ship)
if (orderItem.OpenQty <= 0)
continue;
var shipmentItemModel = model.Items.FirstOrDefault(x => x.OrderItemId == orderItem.Id);
if (shipmentItemModel == null)
continue;
var product = await _productService.GetProductById(orderItem.ProductId);
var warehouseId = "";
if (product != null && (((product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock ||
product.ManageInventoryMethodId ==
ManageInventoryMethod.ManageStockByAttributes) &&
product.UseMultipleWarehouses) || product.ManageInventoryMethodId ==
ManageInventoryMethod.ManageStockByBundleProducts))
//multiple warehouses supported
//warehouse is chosen by a store owner
warehouseId = shipmentItemModel.WarehouseId;
else
//multiple warehouses are not supported
warehouseId = orderItem.WarehouseId;
//validate quantity
if (shipmentItemModel.QuantityToAdd <= 0)
continue;
if (shipmentItemModel.QuantityToAdd > orderItem.OpenQty)
shipmentItemModel.QuantityToAdd = orderItem.OpenQty;
//ok. we have at least one item. create a shipment (if it does not exist)
var orderItemTotalWeight = orderItem.ItemWeight * shipmentItemModel.QuantityToAdd;
if (orderItemTotalWeight.HasValue)
{
totalWeight ??= 0;
totalWeight += orderItemTotalWeight.Value;
}
if (shipment == null)
{
var trackingNumber = model.TrackingNumber;
var adminComment = model.AdminComment;
shipment = new Shipment {
OrderId = order.Id,
SeId = order.SeId,
TrackingNumber = trackingNumber,
TotalWeight = null,
ShippedDateUtc = null,
DeliveryDateUtc = null,
AdminComment = adminComment,
StoreId = order.StoreId
};
}
//create a shipment item
var shipmentItem = new ShipmentItem {
ProductId = orderItem.ProductId,
OrderItemId = orderItem.Id,
Quantity = shipmentItemModel.QuantityToAdd,
WarehouseId = warehouseId,
Attributes = orderItem.Attributes
};
shipment.ShipmentItems.Add(shipmentItem);
}
return (shipment, totalWeight);
}
}