|
@@ -62,8 +62,17 @@ namespace PRSDesktop
|
|
|
{
|
|
|
var models = ViewModels.Where(x => x.ChosenUnits > 0);
|
|
|
|
|
|
+ double total = 0;
|
|
|
foreach (var model in models)
|
|
|
+ {
|
|
|
CreateStockMovements(model);
|
|
|
+ total = total + model.ChosenUnits;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Item.Qty > total)
|
|
|
+ {
|
|
|
+ SplitLine(Item, total, Item.Qty - total);
|
|
|
+ }
|
|
|
|
|
|
DialogResult = true;
|
|
|
}
|
|
@@ -151,6 +160,37 @@ namespace PRSDesktop
|
|
|
if (model.ChosenUnits < holdingUnits)
|
|
|
model.ChosenUnits++;
|
|
|
}
|
|
|
+
|
|
|
+ private void SplitLine(JobRequisitionItem item, double oldItemQty, double newItemQty)
|
|
|
+ {
|
|
|
+ List<JobRequisitionItem> items = new List<JobRequisitionItem>();
|
|
|
+ JobRequisitionItem newItem = new JobRequisitionItem();
|
|
|
+ newItem.Requisition.ID = item.Requisition.ID;
|
|
|
+ newItem.Status = JobRequisitionItemStatus.NotChecked;
|
|
|
+ newItem.Requisition.Job.ID = item.Requisition.Job.ID;
|
|
|
+ newItem.Requisition.Job.JobNumber = item.Requisition.Job.JobNumber;
|
|
|
+ newItem.Requisition.Job.Name = item.Requisition.Job.Name;
|
|
|
+ newItem.Job.ID = item.Job.ID;
|
|
|
+ newItem.Product.ID = item.Product.ID;
|
|
|
+ newItem.Product.Name = item.Product.Name;
|
|
|
+ newItem.Product.Code = item.Product.Code;
|
|
|
+ newItem.Product.Group.ID = item.Product.Group.ID;
|
|
|
+ newItem.Product.Group.Description = item.Product.Group.Description;
|
|
|
+ newItem.Dimensions.CopyFrom(item.Dimensions);
|
|
|
+ newItem.Style.ID = item.Style.ID;
|
|
|
+ newItem.Style.Description = item.Style.Description;
|
|
|
+ newItem.Style.Code = item.Style.Code;
|
|
|
+ newItem.Notes = item.Notes + Environment.NewLine + "Line split from original line when reserving";
|
|
|
+ item.Notes = newItem.Notes;
|
|
|
+
|
|
|
+ item.Qty = oldItemQty;
|
|
|
+ newItem.Qty = newItemQty;
|
|
|
+
|
|
|
+ items.Add(newItem);
|
|
|
+ items.Add(item);
|
|
|
+ new Client<JobRequisitionItem>().Save(items, "Split lines from Job Requi Item Review Dashboard");
|
|
|
+ MessageBox.Show("Requisition Line split due to " + oldItemQty + " stock selected of " + (oldItemQty + newItemQty) + " required.");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public class JobRequistionStockSelectionViewModel : INotifyPropertyChanged
|