|
@@ -1,6 +1,8 @@
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
using InABox.Core;
|
|
|
+using InABox.Wpf;
|
|
|
+using org.omg.PortableInterceptor;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
@@ -8,308 +10,292 @@ using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+public delegate void HoldingsReviewRefresh();
|
|
|
+/// <summary>
|
|
|
+/// Interaction logic for JobRequisitionHoldingsReview.xaml
|
|
|
+/// </summary>
|
|
|
+public partial class JobRequisitionHoldingsReview
|
|
|
{
|
|
|
- public delegate void HoldingsReviewRefresh();
|
|
|
- /// <summary>
|
|
|
- /// Interaction logic for JobRequisitionHoldingsReview.xaml
|
|
|
- /// </summary>
|
|
|
- public partial class JobRequisitionHoldingsReview
|
|
|
+ private ProductStyleLink companyDefaultStyle = new ProductStyleLink();
|
|
|
+ public ProductStyleLink CompanyDefaultStyle
|
|
|
{
|
|
|
- private ProductStyleLink companyDefaultStyle = new ProductStyleLink();
|
|
|
- public ProductStyleLink CompanyDefaultStyle
|
|
|
+ get => companyDefaultStyle;
|
|
|
+ set
|
|
|
{
|
|
|
- get => companyDefaultStyle;
|
|
|
- set
|
|
|
- {
|
|
|
- companyDefaultStyle = value;
|
|
|
- DefaultOrNoStyleText.Text = companyDefaultStyle.Description + @" /None";
|
|
|
- }
|
|
|
+ companyDefaultStyle = value;
|
|
|
+ DefaultOrNoStyleText.Text = companyDefaultStyle.Description + @" /None";
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- public event HoldingsReviewRefresh? OnHoldingsReviewRefresh;
|
|
|
- List<Job> jobs = new List<Job>();
|
|
|
+ public event HoldingsReviewRefresh? OnHoldingsReviewRefresh;
|
|
|
|
|
|
- private JobRequisitionItem? item;
|
|
|
- public JobRequisitionItem? Item
|
|
|
+ private JobRequisitionItem? item;
|
|
|
+ public JobRequisitionItem? Item
|
|
|
+ {
|
|
|
+ get
|
|
|
{
|
|
|
- get
|
|
|
- {
|
|
|
- return item;
|
|
|
- }
|
|
|
- set
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if(item?.ID != value?.ID)
|
|
|
{
|
|
|
- if(item?.ID != value?.ID)
|
|
|
- {
|
|
|
- item = value;
|
|
|
- CalculateHoldings();
|
|
|
- SetStyle();
|
|
|
- SetProductName();
|
|
|
- }
|
|
|
+ item = value;
|
|
|
+ CalculateHoldings();
|
|
|
+ SetStyle();
|
|
|
+ SetProductName();
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void SetProductName()
|
|
|
- {
|
|
|
- productLbl.Text = Item != null
|
|
|
- ? Item.Product.Name + " (" + Item.Product.Code + ")"
|
|
|
- : "No Product Selected";
|
|
|
- }
|
|
|
+ private void SetProductName()
|
|
|
+ {
|
|
|
+ productLbl.Text = Item != null
|
|
|
+ ? Item.Product.Name + " (" + Item.Product.Code + ")"
|
|
|
+ : "No Product Selected";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetStyle()
|
|
|
+ {
|
|
|
+ if ((Item != null) && (Item.Style.ID != Guid.Empty))
|
|
|
+ styleLbl.Text = Item.Style.Description + " (" + Item.Style.Code + ")";
|
|
|
+ else
|
|
|
+ styleLbl.Text = "No Style Selected";
|
|
|
+ }
|
|
|
+
|
|
|
+ public JobRequisitionHoldingsReview()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
|
|
|
- private void SetStyle()
|
|
|
+ greenList.CollectionChanged += (s, e) =>
|
|
|
{
|
|
|
- if ((Item != null) && (Item.Style.ID != Guid.Empty))
|
|
|
- styleLbl.Text = Item.Style.Description + " (" + Item.Style.Code + ")";
|
|
|
- else
|
|
|
- styleLbl.Text = "No Style Selected";
|
|
|
- }
|
|
|
+ availableTab.Visibility = greenList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ };
|
|
|
+ yellowList.CollectionChanged += (s, e) =>
|
|
|
+ {
|
|
|
+ reservedTab.Visibility = yellowList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ };
|
|
|
+ redList.CollectionChanged += (s, e) =>
|
|
|
+ {
|
|
|
+ requisitionedTab.Visibility = redList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ private readonly ObservableCollection<JobRequiHoldingsReviewModel> greenList = new();
|
|
|
+ private readonly ObservableCollection<JobRequiHoldingsReviewModel> yellowList = new();
|
|
|
+ private readonly ObservableCollection<JobRequiHoldingsReviewModel> redList = new();
|
|
|
|
|
|
- public JobRequisitionHoldingsReview()
|
|
|
+ private void DistributeMovements(Dictionary<Guid, List<StockMovement>>? movements, Guid selectedStyleID, JobRequiHoldingsReviewModel model)
|
|
|
+ {
|
|
|
+ if (movements is null) return;
|
|
|
+
|
|
|
+ foreach(var (id, mvts) in movements)
|
|
|
{
|
|
|
- InitializeComponent();
|
|
|
- CoreTable table = new Client<Job>().Query(null, new Columns<Job>(x => x.ID, x => x.JobNumber, x => x.Name));
|
|
|
- foreach (var row in table.Rows)
|
|
|
+ if(id == Guid.Empty || id == CompanyDefaultStyle.ID)
|
|
|
{
|
|
|
- jobs.Add(row.ToObject<Job>());
|
|
|
+ model.StockOfNoStyle.AddRange(mvts);
|
|
|
}
|
|
|
- greenList.CollectionChanged += (s, e) =>
|
|
|
- {
|
|
|
- availableTab.Visibility = greenList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- };
|
|
|
- yellowList.CollectionChanged += (s, e) =>
|
|
|
+ else if (id == selectedStyleID)
|
|
|
{
|
|
|
- reservedTab.Visibility = yellowList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- };
|
|
|
- redList.CollectionChanged += (s, e) =>
|
|
|
+ model.StockOfCurrentStyle.AddRange(mvts);
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- requisitionedTab.Visibility = redList.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- };
|
|
|
+ model.StockOfOtherStyles.AddRange(mvts);
|
|
|
+ }
|
|
|
}
|
|
|
+ model.UnitsOfCurrentStyle = Math.Max(model.StockOfCurrentStyle.Sum(x => x.Units), 0);
|
|
|
+ model.UnitsOfNoStyle = Math.Max(model.StockOfNoStyle.Sum(x => x.Units), 0);
|
|
|
+ model.UnitsOfOtherStyles = Math.Max(model.StockOfOtherStyles.Sum(x => x.Units), 0);
|
|
|
+ }
|
|
|
|
|
|
- private readonly ObservableCollection<JobRequiHoldingsReviewModel> greenList = new();
|
|
|
- private readonly ObservableCollection<JobRequiHoldingsReviewModel> yellowList = new();
|
|
|
- private readonly ObservableCollection<JobRequiHoldingsReviewModel> redList = new();
|
|
|
-
|
|
|
- private void CalculateHoldings()
|
|
|
+ private void CalculateHoldings()
|
|
|
+ {
|
|
|
+ if(item is not null)
|
|
|
{
|
|
|
- CoreTable table = new Client<StockMovement>().Query(
|
|
|
- new Filter<StockMovement>(x => x.Product.ID).IsEqualTo(item?.Product.ID ?? Guid.Empty).
|
|
|
- And(x => x.Dimensions.UnitSize).IsEqualTo(item?.Dimensions.UnitSize ?? "")
|
|
|
- .And(x => x.Location.ID).IsNotEqualTo(Guid.Empty),
|
|
|
+ var stockMovements = Client.Query(
|
|
|
+ new Filter<StockMovement>(x => x.Product.ID).IsEqualTo(item.Product.ID)
|
|
|
+ .And(x => x.Dimensions.UnitSize).IsEqualTo(item.Dimensions.UnitSize)
|
|
|
+ .And(x => x.Location.ID).IsNotEqualTo(Guid.Empty),
|
|
|
new Columns<StockMovement>(
|
|
|
x => x.ID,
|
|
|
x => x.Style.ID,
|
|
|
x => x.Style.Description,
|
|
|
x => x.Style.Code,
|
|
|
- x => x.Received,
|
|
|
- x => x.Issued,
|
|
|
+ x => x.Units,
|
|
|
x => x.Location.ID,
|
|
|
x => x.Location.Code,
|
|
|
x => x.Location.Description,
|
|
|
x => x.Location.Area.Description,
|
|
|
x => x.Job.ID,
|
|
|
- x => x.Job.JobNumber,
|
|
|
- x => x.JobRequisitionItem.ID,
|
|
|
- x => x.Dimensions.Unit.ID,
|
|
|
- x => x.Dimensions.Unit.Formula,
|
|
|
- x => x.Dimensions.Unit.Format,
|
|
|
- x => x.Dimensions.Unit.HasHeight,
|
|
|
- x => x.Dimensions.Unit.HasWeight,
|
|
|
- x => x.Dimensions.Unit.HasLength,
|
|
|
- x => x.Dimensions.Unit.HasWidth,
|
|
|
- x => x.Dimensions.Unit.HasQuantity,
|
|
|
- x => x.Dimensions.Quantity,
|
|
|
- x => x.Dimensions.Height,
|
|
|
- x => x.Dimensions.Weight,
|
|
|
- x => x.Dimensions.Width,
|
|
|
- x => x.Dimensions.Length,
|
|
|
- x => x.Dimensions.UnitSize,
|
|
|
- x => x.Dimensions.Value
|
|
|
- ));
|
|
|
-
|
|
|
- List<StockMovement> stockMovements = new List<StockMovement>();
|
|
|
-
|
|
|
- foreach (CoreRow row in table.Rows)
|
|
|
- stockMovements.Add(row.ToObject<StockMovement>());
|
|
|
-
|
|
|
- CalculateHoldingsForJob(stockMovements);
|
|
|
- CalculateHoldingsForFreeStock(stockMovements);
|
|
|
- listViewGreen.ItemsSource = greenList;
|
|
|
-
|
|
|
- CalculateNonRequiHoldingsForOtherJobs(stockMovements);
|
|
|
- listViewYellow.ItemsSource = yellowList;
|
|
|
-
|
|
|
- CalculateAlreadyRequiedHoldings(stockMovements);
|
|
|
- listViewRed.ItemsSource = redList;
|
|
|
- }
|
|
|
-
|
|
|
- private void CalculateHoldingsForJob(List<StockMovement> mvts)
|
|
|
- {
|
|
|
- greenList.Clear();
|
|
|
- if (item != null)
|
|
|
+ x => x.JobRequisitionItem.ID)
|
|
|
+ .AddDimensionsColumns(x => x.Dimensions, Dimensions.ColumnsType.Data))
|
|
|
+ .ToObjects<StockMovement>()
|
|
|
+ .GroupBy(x => new { JobID = x.Job.ID, Allocated = x.JobRequisitionItem.ID != Guid.Empty })
|
|
|
+ .ToDictionary(
|
|
|
+ x => x.Key,
|
|
|
+ x => x.GroupBy(x => x.Style.ID)
|
|
|
+ .Select(x =>
|
|
|
+ {
|
|
|
+ var mvts = x.ToList();
|
|
|
+ return new
|
|
|
+ {
|
|
|
+ Style = x.Key,
|
|
|
+ Movements = mvts
|
|
|
+ };
|
|
|
+ })
|
|
|
+ .ToDictionary(
|
|
|
+ x => x.Style,
|
|
|
+ x => x.Movements));
|
|
|
+
|
|
|
+ var jobs = Client.Query(
|
|
|
+ new Filter<Job>(x => x.ID).InList(stockMovements.Keys.Select(x => x.JobID).ToArray()),
|
|
|
+ new Columns<Job>(x => x.ID).Add(x => x.JobNumber).Add(x => x.Name))
|
|
|
+ .ToObjects<Job>()
|
|
|
+ .ToDictionary(x => x.ID, x => x);
|
|
|
+
|
|
|
+ if(!stockMovements.ContainsKey(new { JobID = item.Job.ID, Allocated = false }))
|
|
|
{
|
|
|
- var currentJobHoldings = new JobRequiHoldingsReviewModel(item.Job.ID,
|
|
|
- item.Job.JobNumber, item.Job.Name, mvts, CompanyDefaultStyle);
|
|
|
- currentJobHoldings.GetStock(item.Job.ID, item.Style.ID);
|
|
|
- greenList.Add(currentJobHoldings);
|
|
|
+ stockMovements.Add(new { JobID = item.Job.ID, Allocated = false }, new Dictionary<Guid, List<StockMovement>>());
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private void CalculateHoldingsForFreeStock(List<StockMovement> mvts)
|
|
|
- {
|
|
|
- if (item != null)
|
|
|
+ if (!stockMovements.ContainsKey(new { JobID = Guid.Empty, Allocated = false }))
|
|
|
{
|
|
|
- var freeStock = new JobRequiHoldingsReviewModel(Guid.Empty, "Free Stock", "Free Stock", mvts,
|
|
|
- CompanyDefaultStyle);
|
|
|
- freeStock.GetStock(Guid.Empty, item.Style.ID);
|
|
|
- greenList.Add(freeStock);
|
|
|
+ stockMovements.Add(new { JobID = Guid.Empty, Allocated = false }, new Dictionary<Guid, List<StockMovement>>());
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- private void CalculateNonRequiHoldingsForOtherJobs(List<StockMovement> mvts)
|
|
|
- {
|
|
|
+ greenList.Clear();
|
|
|
yellowList.Clear();
|
|
|
- if (item != null)
|
|
|
+ redList.Clear();
|
|
|
+ foreach (var (key, movements) in stockMovements)
|
|
|
{
|
|
|
- foreach (var job in jobs)
|
|
|
- {
|
|
|
- if (job.ID == item.Job.ID)
|
|
|
- continue;
|
|
|
-
|
|
|
- var holdings =
|
|
|
- new JobRequiHoldingsReviewModel(job.ID, job.JobNumber, job.Name, mvts, CompanyDefaultStyle);
|
|
|
- holdings.GetStock(job.ID, item.Style.ID);
|
|
|
+ var job = jobs.GetValueOrDefault(key.JobID);
|
|
|
|
|
|
- if (holdings.StockOfCurrentStyle == 0 && holdings.StockOfNoStyle == 0 &&
|
|
|
- holdings.StockOfOtherStyles == 0)
|
|
|
- continue;
|
|
|
- yellowList.Add(holdings);
|
|
|
+ JobRequiHoldingsReviewModel holding;
|
|
|
+ if (key.Allocated)
|
|
|
+ {
|
|
|
+ holding = new JobRequiHoldingsReviewModel(key.JobID, job?.JobNumber ?? "", job?.Name ?? "")
|
|
|
+ {
|
|
|
+ AlreadyAllocated = true
|
|
|
+ };
|
|
|
+ DistributeMovements(movements, item.Style.ID, holding);
|
|
|
+ if (!holding.Empty)
|
|
|
+ {
|
|
|
+ redList.Add(holding);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (key.JobID == Guid.Empty)
|
|
|
+ {
|
|
|
+ holding = new JobRequiHoldingsReviewModel(Guid.Empty, "Free Stock", "Free Stock");
|
|
|
+ DistributeMovements(movements, item.Style.ID, holding);
|
|
|
+ greenList.Add(holding);
|
|
|
+ }
|
|
|
+ else if(key.JobID == item.Job.ID)
|
|
|
+ {
|
|
|
+ holding = new JobRequiHoldingsReviewModel(item.Job.ID, item.Job.JobNumber, item.Job.Name);
|
|
|
+ DistributeMovements(movements, item.Style.ID, holding);
|
|
|
+ greenList.Add(holding);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ holding = new JobRequiHoldingsReviewModel(key.JobID, job?.JobNumber ?? "", job?.Name ?? "");
|
|
|
+ DistributeMovements(movements, item.Style.ID, holding);
|
|
|
+ if (!holding.Empty)
|
|
|
+ {
|
|
|
+ yellowList.Add(holding);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if (yellowList.Count == 1)
|
|
|
- yellowList.Add(new JobRequiHoldingsReviewModel());
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ if (greenList.Count == 1)
|
|
|
+ greenList.Add(new JobRequiHoldingsReviewModel());
|
|
|
|
|
|
- private void CalculateAlreadyRequiedHoldings(List<StockMovement> mvts)
|
|
|
+ if (redList.Count == 1)
|
|
|
+ redList.Add(new JobRequiHoldingsReviewModel());
|
|
|
+
|
|
|
+ if (yellowList.Count == 1)
|
|
|
+ yellowList.Add(new JobRequiHoldingsReviewModel());
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
+ greenList.Clear();
|
|
|
+ yellowList.Clear();
|
|
|
redList.Clear();
|
|
|
- if (item != null)
|
|
|
- {
|
|
|
- foreach (var job in jobs)
|
|
|
- {
|
|
|
- var holdings =
|
|
|
- new JobRequiHoldingsReviewModel(job.ID, job.JobNumber, job.Name, mvts, CompanyDefaultStyle);
|
|
|
- holdings.AlreadyAllocated = true;
|
|
|
- holdings.GetStock(job.ID, item.Style.ID);
|
|
|
-
|
|
|
- if (holdings.StockOfCurrentStyle == 0 && holdings.StockOfNoStyle == 0 &&
|
|
|
- holdings.StockOfOtherStyles == 0)
|
|
|
- continue;
|
|
|
+ }
|
|
|
|
|
|
- redList.Add(holdings);
|
|
|
+ listViewGreen.ItemsSource = greenList;
|
|
|
+ listViewYellow.ItemsSource = yellowList;
|
|
|
+ listViewRed.ItemsSource = redList;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ private void Take_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (sender is not FrameworkElement element
|
|
|
+ || element.DataContext is not JobRequiHoldingsReviewModel model
|
|
|
+ || element.Tag is not List<StockMovement> mvts) return;
|
|
|
+ LaunchStockSelectionPage(model, mvts);
|
|
|
+ }
|
|
|
|
|
|
- if (redList.Count == 1)
|
|
|
- redList.Add(new JobRequiHoldingsReviewModel());
|
|
|
- }
|
|
|
- }
|
|
|
+ private void LaunchStockSelectionPage(JobRequiHoldingsReviewModel model, List<StockMovement> mvts)
|
|
|
+ {
|
|
|
+ if (Item is null) return;
|
|
|
|
|
|
- private void Take_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- LaunchStockSelectionPage((sender as Button).Name, (sender as Button).DataContext as JobRequiHoldingsReviewModel);
|
|
|
- }
|
|
|
+ var locationIDs = new List<Guid>();
|
|
|
+ var holdings = new List<StockHolding>();
|
|
|
|
|
|
- private void LaunchStockSelectionPage(string buttonName, JobRequiHoldingsReviewModel model)
|
|
|
+ foreach (var mvt in mvts)
|
|
|
{
|
|
|
- if (Item is null) return;
|
|
|
-
|
|
|
- var mvts = model.Movements.Where(x => x.Job.ID == model.JobID);
|
|
|
-
|
|
|
- switch (buttonName)
|
|
|
+ if (!locationIDs.Contains(mvt.Location.ID))
|
|
|
{
|
|
|
- case "currentStyle":
|
|
|
- if (model.StockOfCurrentStyle == 0)
|
|
|
- return;
|
|
|
- mvts = mvts
|
|
|
- .Where(x => x.Style.ID == Item.Style.ID);
|
|
|
- break;
|
|
|
- case "noStyle":
|
|
|
- if (model.StockOfNoStyle == 0)
|
|
|
- return;
|
|
|
- mvts = mvts
|
|
|
- .Where(x => x.Style.ID == Guid.Empty || x.Style.ID == CompanyDefaultStyle.ID);
|
|
|
- break;
|
|
|
- case "otherStyle":
|
|
|
- if (model.StockOfOtherStyles == 0)
|
|
|
- return;
|
|
|
- mvts = mvts
|
|
|
- .Where(x => x.Style.ID != Guid.Empty && x.Style.ID != Item.Style.ID && x.Style.ID != CompanyDefaultStyle.ID);
|
|
|
- break;
|
|
|
+ var holding = new StockHolding();
|
|
|
+ holding.Location.ID = mvt.Location.ID;
|
|
|
+ holding.Location.Description = mvt.Location.Description;
|
|
|
+ holding.Location.Area.Description = mvt.Location.Area.Description;
|
|
|
+ holding.Style.ID = mvt.Style.ID;
|
|
|
+ holding.Style.Description = mvt.Style.Description;
|
|
|
+ holding.Style.Code = mvt.Style.Code;
|
|
|
+ holding.Dimensions.CopyFrom(mvt.Dimensions);
|
|
|
+ if (mvt.JobRequisitionItem.ID != Guid.Empty && model.AlreadyAllocated)
|
|
|
+ {
|
|
|
+ holding.Units = mvt.Units;
|
|
|
+ holdings.Add(holding);
|
|
|
+ locationIDs.Add(mvt.Location.ID);
|
|
|
+ }
|
|
|
+ else if (mvt.JobRequisitionItem.ID == Guid.Empty && !model.AlreadyAllocated)
|
|
|
+ {
|
|
|
+ holding.Units = mvt.Units;
|
|
|
+ holdings.Add(holding);
|
|
|
+ locationIDs.Add(mvt.Location.ID);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- List<Guid> locationIDs = new List<Guid>();
|
|
|
- List<StockHolding> holdings = new List<StockHolding>();
|
|
|
- List<StockMovement> movements = new List<StockMovement>();
|
|
|
- foreach (var mvt in mvts)
|
|
|
- movements.Add(mvt);
|
|
|
-
|
|
|
- foreach (var mvt in movements)
|
|
|
+ else
|
|
|
{
|
|
|
- if (!locationIDs.Contains(mvt.Location.ID))
|
|
|
+ if (mvt.JobRequisitionItem.ID != Guid.Empty && model.AlreadyAllocated)
|
|
|
{
|
|
|
- var holding = new StockHolding();
|
|
|
- holding.Location.ID = mvt.Location.ID;
|
|
|
- holding.Location.Description = mvt.Location.Description;
|
|
|
- holding.Location.Area.Description = mvt.Location.Area.Description;
|
|
|
- holding.Style.ID = mvt.Style.ID;
|
|
|
- holding.Style.Description = mvt.Style.Description;
|
|
|
- holding.Style.Code = mvt.Style.Code;
|
|
|
- holding.Dimensions.CopyFrom(mvt.Dimensions);
|
|
|
- if (mvt.JobRequisitionItem.ID != Guid.Empty && model.AlreadyAllocated)
|
|
|
- {
|
|
|
- holding.Units = mvt.Received - mvt.Issued;
|
|
|
- holdings.Add(holding);
|
|
|
- locationIDs.Add(mvt.Location.ID);
|
|
|
- }
|
|
|
- else if (mvt.JobRequisitionItem.ID == Guid.Empty && !model.AlreadyAllocated)
|
|
|
- {
|
|
|
- holding.Units = mvt.Received - mvt.Issued;
|
|
|
- holdings.Add(holding);
|
|
|
- locationIDs.Add(mvt.Location.ID);
|
|
|
- }
|
|
|
+ var holding = holdings.First(x => x.Location.ID == mvt.Location.ID);
|
|
|
+ holding.Units += mvt.Units;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (mvt.JobRequisitionItem.ID == Guid.Empty && !model.AlreadyAllocated)
|
|
|
{
|
|
|
- if (mvt.JobRequisitionItem.ID != Guid.Empty && model.AlreadyAllocated)
|
|
|
- {
|
|
|
- var holding = holdings.First(x => x.Location.ID == mvt.Location.ID);
|
|
|
- holding.Units = holding.Units + mvt.Received - mvt.Issued;
|
|
|
- }
|
|
|
- else if (mvt.JobRequisitionItem.ID == Guid.Empty && !model.AlreadyAllocated)
|
|
|
- {
|
|
|
- var holding = holdings.First(x => x.Location.ID == mvt.Location.ID);
|
|
|
- holding.Units = holding.Units + mvt.Received - mvt.Issued;
|
|
|
- }
|
|
|
-
|
|
|
+ var holding = holdings.First(x => x.Location.ID == mvt.Location.ID);
|
|
|
+ holding.Units += mvt.Units;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- var filteredHoldings = holdings.Where(x => x.Units > 0);
|
|
|
+ }
|
|
|
+ var filteredHoldings = holdings.Where(x => x.Units > 0);
|
|
|
|
|
|
- var page = new StockSelectionPage(
|
|
|
- filteredHoldings,
|
|
|
- Item,
|
|
|
- new Job { ID = model.JobID, Name = model.JobName, JobNumber = model.JobNumber },
|
|
|
- model.AlreadyAllocated);
|
|
|
+ var page = new StockSelectionPage(
|
|
|
+ filteredHoldings,
|
|
|
+ Item,
|
|
|
+ new Job { ID = model.JobID, Name = model.JobName, JobNumber = model.JobNumber },
|
|
|
+ model.AlreadyAllocated);
|
|
|
|
|
|
- if (page.ShowDialog() == true)
|
|
|
- {
|
|
|
- MessageBox.Show("Success - stock allocated to requisition line");
|
|
|
- OnHoldingsReviewRefresh?.Invoke();
|
|
|
- }
|
|
|
-
|
|
|
+ if (page.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ MessageWindow.ShowMessage("Success - stock allocated to requisition line", "Success");
|
|
|
+ OnHoldingsReviewRefresh?.Invoke();
|
|
|
}
|
|
|
}
|
|
|
}
|