| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | 
							- using System.Collections.Generic;
 
- using InABox.Core;
 
- namespace Comal.Classes
 
- {
 
-     public static class DeliveryItemExtensions
 
-     {
 
-         public static DeliveryItem CreateDeliveryItem(this PurchaseOrderItem item)
 
-         {
 
-             var result = new DeliveryItem();
 
-             result.OrderItem.ID = item.ID;
 
-             result.JobLink.ID = item.Job.ID;
 
-             result.JobLink.Synchronise(item.Job);
 
-             result.DueDate = item.ReceivedDate;
 
-             result.Description = string.Format("{0} x {1}", item.Qty, item.Description);
 
-             result.Title = result.Description;
 
-             result.Piece = result.Description;
 
-             result.Cost = item.Cost;
 
-             return result;
 
-         }
 
-         public static DeliveryItem CreateDeliveryItem(this RequisitionItem item, Requisition requisition)
 
-         {
 
-             var result = new DeliveryItem();
 
-             result.RequisitionLink.ID = requisition.ID;
 
-             result.JobLink.ID = requisition.JobLink.ID;
 
-             result.JobLink.Synchronise(requisition.JobLink);
 
-             result.Delivery.ID = requisition.Delivery.ID;
 
-             result.Delivery.Synchronise(requisition.Delivery);
 
-             result.DueDate = requisition.Due;
 
-             result.Description = string.Format("{0} ({1} off)", item.Description, item.Quantity);
 
-             result.Title = item.Code;
 
-             result.Piece = item.Code;
 
-             return result;
 
-         }
 
-         public static IEnumerable<DeliveryItem> CreateDeliveryItems(this ManufacturingPacket entity, int From)
 
-         {
 
-             var result = new List<DeliveryItem>();
 
-             // If the (new system) barcode qty is set, always use that - otherwise use the old system (Grouped/individual/none)
 
-             var iCount = entity.BarcodeQty > 0 ? entity.BarcodeQty :
 
-                 entity.BarcodeType == BarcodeType.None ? 0 :
 
-                 entity.BarcodeType == BarcodeType.Grouped ? 1 : entity.Quantity;
 
-             for (var iSeq = 1; iSeq <= iCount; iSeq++)
 
-             {
 
-                 var item = new DeliveryItem();
 
-                 item.ManufacturingPacketLink.ID = entity.ID;
 
-                 //item.CustomAttributes = entity.CustomAttributes;
 
-                 //if (item.CustomAttributes != null)
 
-                 //{
 
-                 //    StringBuilder sb = new StringBuilder();
 
-                 //    if (item.CustomAttributes != null)
 
-                 //    {
 
-                 //        foreach (var attribute in item.CustomAttributes)
 
-                 //            sb.AppendLine(String.Format("{0}={1}", attribute.Name, attribute.Value));
 
-                 //    }
 
-                 //    item.Attributes = sb.ToString();
 
-                 //}
 
-                 item.SetoutLink.ID = entity.SetoutLink.ID;
 
-                 item.SetoutLink.Synchronise(entity.SetoutLink);
 
-                 item.JobLink.ID = entity.SetoutLink.JobLink.ID;
 
-                 item.JobLink.Synchronise(entity.SetoutLink.JobLink);
 
-                 item.DueDate = entity.DueDate;
 
-                 if (iCount > 1)
 
-                 {
 
-                     item.Piece = string.Format("{0}{1:D2}", entity.ManufacturingTemplateLink.Code, iSeq);
 
-                     item.Title = string.Format("{0} ({1}/{2})", CoreUtils.StripHTML(entity.SetoutLink.Description), iSeq, iCount);
 
-                     item.Description = string.Format("{0} ({1}/{2})", entity.Title, iSeq, iCount);
 
-                 }
 
-                 else
 
-                 {
 
-                     item.Piece = entity.ManufacturingTemplateLink.Code;
 
-                     item.Title = string.Format("{0} ({1} unit{2})", entity.SetoutLink.Description, entity.Quantity, entity.Quantity > 1 ? "s" : "");
 
-                     item.Description = string.Format("{0} ({1} unit{2})", entity.Title, entity.Quantity, entity.Quantity > 1 ? "s" : "");
 
-                 }
 
-                 item.Sequence = From + iSeq;
 
-                 item.Height = entity.Height;
 
-                 item.Width = entity.Width;
 
-                 item.Length = entity.Length;
 
-                 var props = entity.UserProperties.AsDictionary;
 
-                 foreach (var key in props.Keys)
 
-                     if (item.UserProperties.ContainsKey(key))
 
-                         item.UserProperties[key] = props[key];
 
-                 result.Add(item);
 
-             }
 
-             return result;
 
-         }
 
-     }
 
- }
 
 
  |