Kaynağa Gözat

Fixed Job Summary and Stock Summary Grids
Fixed Issues with Quote Screens

Frank van den Bos 2 yıl önce
ebeveyn
işleme
738504ecd5

+ 26 - 1
prs.classes/Entities/Product/Kit/KitFormula.cs

@@ -1,19 +1,44 @@
-using InABox.Core;
+using System.Collections.Generic;
+using System.Linq;
+using InABox.Core;
 
 namespace Comal.Classes
 {
     [UserTracking(typeof(Quote))]
     public class KitFormula : Entity, IRemotable, IPersistent, ILicense<QuotesManagementLicense>
     {
+        [EditorSequence(1)]
         [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
         public string Code { get; set; }
 
+        [EditorSequence(2)]
         [TextBoxEditor]
         public string Description { get; set; }
+        
+        [EditorSequence(3)]
+        [ExpressionEditor(null, typeof(KitFormulaExpressionGenerator))]
+        public virtual string Formula { get; set; }  
+        
+        private class KitFormulaExpressionGenerator : IExpressionModelGenerator
+        {
+            public List<string> GetVariables(object?[] items)
+            {
+                var dimensionUnits = items.Select(x => x as QuoteCostSheetItem).Where(x => x != null).Cast<QuoteCostSheetItem>();
+                var variables = new List<string>();
+                var props = CoreUtils.PropertyList(typeof(QuoteCostSheetItem), x => true, true);
+                foreach (var prop in props.Keys)
+                    variables.Add(prop);
+                return variables;
+            }
+        }
 
         public override string ToString()
         {
             return string.Format("{0}: {1}", Code, Description);
         }
+        
+
     }
+    
+
 }

+ 6 - 7
prs.desktop/DockPanels/ProductLookupDock.xaml.cs

@@ -121,11 +121,9 @@ namespace PRSDesktop
         private void Items_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             Image.Source = null;
-            var productid = Guid.Empty;
             if (e.AddedItems.Count > 0)
             {
                 var item = e.AddedItems[0] as PDI;
-                productid = item.ID;
                 if (!item.ImageID.Equals(Guid.Empty))
                     new Client<Document>().Query(
                         new Filter<Document>(x => x.ID).IsEqualTo(item.ImageID),
@@ -155,17 +153,18 @@ namespace PRSDesktop
                     );
                 else
                     Image.Source = null;
+                if (Security.CanView<StockLocation>())
+                {
+                    _holdings.ParentID = item.ID;
+                    _holdings.Refresh(false, true);
+                }
             }
             else
             {
                 Image.Source = null;
             }
 
-            if (Security.CanView<StockLocation>())
-            {
-                _holdings.ParentID = productid;
-                _holdings.Refresh(false, true);
-            }
+
         }
 
         private void Items_KeyUp(object sender, KeyEventArgs e)

+ 113 - 88
prs.desktop/Panels/Jobs/JobSummaryGrid.cs

@@ -5,10 +5,12 @@ using System.Linq.Expressions;
 using System.Reflection;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media;
 using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using InABox.DynamicGrid;
+using InABox.WPF;
 
 
 namespace PRSDesktop
@@ -22,6 +24,9 @@ namespace PRSDesktop
         
         public JobSummaryGrid() : base()
         {
+
+            ColumnsTag = nameof(JobSummaryGrid);
+            
             Options.AddRange(
                 DynamicGridOption.RecordCount,
                 DynamicGridOption.SelectColumns,
@@ -72,8 +77,9 @@ namespace PRSDesktop
             columns.Add<JobMaterial, double>(x => x.Issued, 80, "Issued", "", Alignment.MiddleCenter);
             columns.Add<JobMaterial, double>(x => x.ReservedStock, 80, "Reserved", "", Alignment.MiddleCenter);
             columns.Add<JobMaterial, double>(x => x.OnOrder, 80, "Ordered", "", Alignment.MiddleCenter);
-            columns.Add<JobMaterial, double>(x => x.JobShortage, 80, "Shortage", "", Alignment.MiddleCenter);
+            columns.Add<JobMaterial, double>(x => x.JobShortage, 80, "Job Short", "", Alignment.MiddleCenter);
             columns.Add<JobMaterial, double>(x => x.FreeStockTotal, 80, "Free Stock", "", Alignment.MiddleCenter);
+            columns.Add<JobMaterial, double>(x => x.FreeStockShortage, 80, "Stk Short", "", Alignment.MiddleCenter);
         }
         
         private void ShowDetailGrid<TEntity>(
@@ -295,7 +301,7 @@ namespace PRSDesktop
             return result;
         }
 
-        private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid? jobid, Guid productid, Guid? styleid, String unitsize) where TSource : IJobMaterial
+        private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid? jobid, Guid productid, Guid? styleid, String unitsize, Func<CoreRow,bool>? extrafilter = null) where TSource : IJobMaterial
         {
             int jobcol = columns.IndexOf(x => x.Job.ID);
             int productcol = columns.IndexOf(x => x.Product.ID);
@@ -308,6 +314,7 @@ namespace PRSDesktop
                     && Guid.Equals(r.Values[productcol], productid)
                     && (!styleid.HasValue || Guid.Equals(r.Values[stylecol], styleid))
                     && String.Equals(r.Values[unitcol], unitsize)
+                    && ((extrafilter == null) || extrafilter(r) )
                 );
             
             return subset.ToArray();
@@ -334,104 +341,108 @@ namespace PRSDesktop
                 ? new Filter<JobMaterial>().None()
                 : new Filter<JobMaterial>(x => x.Job.ID).IsEqualTo(ParentID)
                     .And(x => x.Product.ID).IsNotEqualTo(Guid.Empty);
-            
-            var orderby = sort != null ? Serialization.Deserialize<SortOrder<JobMaterial>>(Serialization.Serialize(sort)) : null;
 
-            new Client<JobMaterial>().Query(filter,columns,orderby, (o,e) =>
-            {
-                
-                var pids = o.ExtractValues<JobMaterial, Guid>(x => x.Product.ID).ToArray();
-                
-                MultiQuery query = new MultiQuery();
-                
-                query.Add<StockHolding>(
-                    new Filter<StockHolding>(x => x.Product.ID).InList(pids)
-                        .And(x=>x.Units).IsNotEqualTo(0.0F)
-                        .And(
-                            IncludeReserves
-                                ? new Filter<StockHolding>(x => x.Job.ID).IsNotEqualTo(ParentID)
-                                : new Filter<StockHolding>(x => x.Job.JobStatus.Active).IsEqualTo(false)
-                        ),
-                    new Columns<StockHolding>(x => x.Product.ID)
-                        .Add(x => x.Style.ID)
-                        .Add(x => x.Dimensions.UnitSize)
-                        .Add(x => x.Units)
-                        .Add(x=>x.Job.ID)
-                );
-                
-                query.Add<PurchaseOrderItem>(
-                    new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
-                        .And(x => x.Product.ID).InList(pids)
-                        .And(
-                            IncludeReserves
-                                ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsNotEqualTo(ParentID)
-                                : new Filter<PurchaseOrderItem>(x => x.Job.JobStatus.Active).IsEqualTo(false)
-                        ),
-                    new Columns<PurchaseOrderItem>(x => x.Product.ID)
-                        .Add(x => x.Style.ID)
-                        .Add(x => x.Dimensions.UnitSize)
-                        .Add(x => x.Qty)
-                );
-                
-                query.Query();
-                
-                var freestock = query.Get<StockHolding>();
-                Columns<StockHolding> freestockcolumns = new Columns<StockHolding>(freestock.Columns.Select(x => x.ColumnName));
-                
-                var freeorders = query.Get<PurchaseOrderItem>();
-                Columns<PurchaseOrderItem> freeordercolumns = new Columns<PurchaseOrderItem>(freeorders.Columns.Select(x => x.ColumnName));
-                
-                CoreTable table = new CoreTable();
-                table.LoadColumns(columns);
-                
-                if (o != null)
+            var orderby = sort;
+            
+            Progress.ShowModal("Loading Data", 
+                (progress) =>
                 {
+                    CoreTable table = new CoreTable();
+                    table.LoadColumns(columns);
                     
+                    var data = new Client<JobMaterial>().Query(filter, columns, orderby);
+                    var pids = data.ExtractValues<JobMaterial, Guid>(x => x.Product.ID).ToArray();
                     
-                    var keys = GetKeys(o.Rows, columns, _stylecolumnVisible);
-                    
-                    foreach (var key in keys)
+                    if (pids.Any())
                     {
+
+                        MultiQuery query = new MultiQuery();
+
+                        query.Add<StockHolding>(
+                            new Filter<StockHolding>(x => x.Product.ID).InList(pids)
+                                .And(x => x.Units).IsNotEqualTo(0.0F)
+                                .And(new Filter<StockHolding>(x => x.Job.ID).IsEqualTo(Guid.Empty).Or(x=>x.Job.ID).IsNotEqualTo(ParentID)),
+                            new Columns<StockHolding>(x => x.Product.ID)
+                                .Add(x => x.Style.ID)
+                                .Add(x => x.Dimensions.UnitSize)
+                                .Add(x => x.Units)
+                                .Add(x => x.Job.ID)
+                                .Add(x => x.Job.JobStatus.Active)
+                        );
+
+                        query.Add<PurchaseOrderItem>(
+                            new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
+                                .And(x => x.Product.ID).InList(pids)
+                                .And(new Filter<PurchaseOrderItem>(x => x.Job.ID).IsEqualTo(Guid.Empty).Or(x=>x.Job.ID).IsNotEqualTo(ParentID)),
+                            new Columns<PurchaseOrderItem>(x => x.Product.ID)
+                                .Add(x => x.Style.ID)
+                                .Add(x => x.Dimensions.UnitSize)
+                                .Add(x => x.Qty)
+                                .Add(x => x.Job.ID)
+                                .Add(x => x.Job.JobStatus.Active)
+                        );
+
+                        query.Query();
+
+                        var freestock = query.Get<StockHolding>();
+                        Columns<StockHolding> freestockcolumns = new Columns<StockHolding>(freestock.Columns.Select(x => x.ColumnName));
+
+                        var freeorders = query.Get<PurchaseOrderItem>();
+                        Columns<PurchaseOrderItem> freeordercolumns = new Columns<PurchaseOrderItem>(freeorders.Columns.Select(x => x.ColumnName));
                         
-                        var rows = GetRows(o.Rows, columns, key.Item1, key.Item2, key.Item3, key.Item4);
-                        if (rows.Any())
+                        var keys = GetKeys(data.Rows, columns, _stylecolumnVisible);
+
+                        foreach (var key in keys)
                         {
-                            
-                            CoreRow newrow = table.NewRow();
-                            newrow.LoadValues(rows.First().Values);
-                            
-                            var bom = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.BillOfMaterials, newrow, x => x.BillOfMaterials);
-                            var requi = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.Requisitions, newrow, x => x.Requisitions);
-                            var picklist = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.PickingLists, newrow, x => x.PickingLists);
-                            var issued = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.Issued, newrow, x => x.Issued);
-                            
-                            var reserved = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.ReservedStock, newrow, x => x.ReservedStock);
-                            var ordered = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.OnOrder, newrow, x => x.OnOrder);
-
-                            var shortage = Math.Max(0, Math.Max(0,(requi - issued)) - (reserved + ordered));
-                            newrow.Set<JobMaterial, double>(x => x.JobShortage, shortage);
-                            
-                            var freestockrows = GetRows(freestock.Rows, freestockcolumns, null, key.Item2, key.Item3, key.Item4);
-                            var freeonhand = Aggregate(freestockrows, freestockcolumns, _stylecolumnVisible, false, x => x.Units, newrow, x => x.FreeOnHand);
-                            newrow.Set<JobMaterial, double>(x => x.FreeOnHand, freeonhand);
-                            
-                            var freeorderrows = GetRows(freeorders.Rows, freeordercolumns, null, key.Item2, key.Item3, key.Item4);
-                            var freeonorder = Aggregate(freeorderrows, freeordercolumns, _stylecolumnVisible, false, x => x.Qty, newrow, x => x.FreeOnOrder);
-                            newrow.Set<JobMaterial, double>(x => x.FreeOnOrder, freeonorder);
-                            
-                            newrow.Set<JobMaterial, double>(x => x.FreeStockTotal, freeonhand+freeonorder);
-                            newrow.Set<JobMaterial, double>(x => x.FreeStockShortage, Math.Max(0,shortage-(freeonhand+freeonorder)));
-                            table.Rows.Add(newrow);
-                        }
-                        
 
+                            var rows = GetRows(data.Rows, columns, key.Item1, key.Item2, key.Item3, key.Item4);
+                            if (rows.Any())
+                            {
+
+                                CoreRow newrow = table.NewRow();
+                                newrow.LoadValues(rows.First().Values);
 
+                                var bom = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.BillOfMaterials, newrow,
+                                    x => x.BillOfMaterials);
+                                var requi = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.Requisitions, newrow, x => x.Requisitions);
+                                var picklist = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.PickingLists, newrow,
+                                    x => x.PickingLists);
+                                var issued = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.Issued, newrow, x => x.Issued);
+
+                                var reserved = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.ReservedStock, newrow,
+                                    x => x.ReservedStock);
+                                var ordered = Aggregate(rows, columns, _stylecolumnVisible, true, x => x.OnOrder, newrow, x => x.OnOrder);
+
+                                var shortage = Math.Max(0, Math.Max(0, (requi - issued)) - (reserved + ordered));
+                                newrow.Set<JobMaterial, double>(x => x.JobShortage, shortage);
+
+                                var freestockrows = GetRows(freestock.Rows, freestockcolumns, null, key.Item2, key.Item3, key.Item4, 
+                                    IncludeReserves ? null : (r) => !r.Get<StockHolding,bool>(x=>x.Job.JobStatus.Active));
+                                var freeonhand = Aggregate(freestockrows, freestockcolumns, _stylecolumnVisible, false, x => x.Units, newrow,
+                                    x => x.FreeOnHand);
+                                newrow.Set<JobMaterial, double>(x => x.FreeOnHand, freeonhand);
+
+                                var freeorderrows = GetRows(freeorders.Rows, freeordercolumns, null, key.Item2, key.Item3, key.Item4,
+                                    IncludeReserves ? null : (r) => !r.Get<PurchaseOrderItem,bool>(x=>x.Job.JobStatus.Active));
+                                var freeonorder = Aggregate(freeorderrows, freeordercolumns, _stylecolumnVisible, false, x => x.Qty, newrow,
+                                    x => x.FreeOnOrder);
+                                newrow.Set<JobMaterial, double>(x => x.FreeOnOrder, freeonorder);
+
+                                newrow.Set<JobMaterial, double>(x => x.FreeStockTotal, freeonhand + freeonorder);
+                                newrow.Set<JobMaterial, double>(x => x.FreeStockShortage, Math.Max(0, shortage - (freeonhand + freeonorder)));
+                                table.Rows.Add(newrow);
+                            }
+
+
+                        }
                     }
+
+                    action?.Invoke(table, null);
+                    
                 }
-                action?.Invoke(table, e);
-            });
+            );
         }
-
+        
         protected override bool FilterRecord(CoreRow row)
         {
             var result = base.FilterRecord(row)
@@ -445,5 +456,19 @@ namespace PRSDesktop
                 );
             return result;
         }
+        
+        private String _jobshortage = CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.JobShortage, ".");
+        private String _stockshortage = CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.FreeStockShortage, ".");
+
+        protected override Brush? GetCellBackground(CoreRow row, string columnname)
+        {
+
+            
+            if (String.Equals(columnname, _jobshortage))
+                return row.Get<JobMaterial, double>(x => x.JobShortage) > 0.0F ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 } : null;
+            if (String.Equals(columnname, _stockshortage))
+                return row.Get<JobMaterial, double>(x => x.FreeStockShortage) > 0.0F ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 } : null;
+            return null;
+        }
     }
 }

+ 54 - 16
prs.desktop/Panels/Quotes/QuoteCostSheetItemGrid.cs

@@ -119,7 +119,15 @@ namespace PRSDesktop
                         line.TaxCode.Rate = product.Get<KitProduct, double>(x => x.Product.TaxCode.Rate);
                         //line.TaxRate = line.TaxCode.Rate;
                         line.Qty = product.Get<KitProduct, double>(x => x.Multiplier);
-                        line.Cost = product.Get<KitProduct, double>(x => x.Product.NettCost);
+
+                        if (product.Get<KitProduct, bool>(x => x.Product.Charge.Chargeable))
+                        {
+                            if (product.Get<KitProduct, ProductPriceType>(x => x.Product.Charge.PriceType) == ProductPriceType.CostPlus)
+                                line.Cost = product.Get<KitProduct, double>(x => x.Product.NettCost) * (100.0F + product.Get<KitProduct, double>(x => x.Product.Charge.Price) / 100.0F);
+                            else
+                                line.Cost = product.Get<KitProduct, double>(x => x.Product.Charge.Price);
+                        }
+
                         updates.Add(line);
                     }
                 }
@@ -155,28 +163,58 @@ namespace PRSDesktop
                 if (ids.Any())
                 {
                     Progress.SetMessage("Loading Products");
-                    var products = new Client<Product>().Load(new Filter<Product>(x => x.ID).InList(ids));
+                    var products = new Client<Product>().Query(
+                        new Filter<Product>(x => x.ID).InList(ids),
+                        new Columns<Product>(x=>x.ID)
+                            .Add(x=>x.NettCost)
+                            .Add(x=>x.Supplier.ID)
+                            .Add(x=>x.Charge.Chargeable)
+                            .Add(x=>x.Charge.PriceType)
+                            .Add(x=>x.Charge.Price)
+                    );
+
                     var supprods = pricing.PricingType != PricingType.Nominal
-                        ? new Client<SupplierProduct>().Load(new Filter<SupplierProduct>(x => x.Product.ID).InList(ids))
-                        : new SupplierProduct[] { };
-                    Progress.SetMessage("Calculating Prices");
+                        ? new Client<SupplierProduct>().Query(
+                            new Filter<SupplierProduct>(x => x.Product.ID).InList(ids),
+                            new Columns<SupplierProduct>(x=>x.SupplierLink.ID)
+                                .Add(x=>x.Product.ID)
+                                .Add(x=>x.CostPrice)
+                        )
+                        : null;
+
                     foreach (var item in items)
                     {
-                        var product = products.FirstOrDefault(x => x.ID.Equals(item.Product.ID));
-                        if (product != null)
+                        var product = products.Rows.FirstOrDefault(r => r.Get<Product, Guid>(c => c.ID).Equals(item.Product.ID));
+
+                        if (product.Get<Product, bool>(x => x.Charge.Chargeable))
                         {
-                            SupplierProduct supprod = null;
-                            if (pricing.PricingType != PricingType.Nominal)
+                            if (product.Get<Product, ProductPriceType>(x => x.Charge.PriceType) == ProductPriceType.FixedPrice)
+                                item.Cost = product.Get<Product, double>(x => x.Charge.Price);
+                            else
                             {
-                                if (pricing.PricingType == PricingType.Lowest)
-                                    supprod = supprods.Where(x => x.Product.ID.Equals(item.Product.ID)).OrderBy(x => x.CostPrice)
-                                        .FirstOrDefault();
-                                else if (pricing.PricingType == PricingType.Preferred || supprod == null)
-                                    supprod = supprods.FirstOrDefault(x =>
-                                        x.Product.ID.Equals(item.Product.ID) && x.ID.Equals(product.Supplier.ID));
+                                var supprows = supprods?.Rows?.Where(r => r.Get<SupplierProduct, Guid>(c => c.Product.ID) == item.Product.ID)
+                                    ?.ToArray();
+
+                                double nettCost = 0.0F;
+                                if (pricing.PricingType == PricingType.Nominal)
+                                    nettCost = product.Get<Product, double>(x => x.NettCost);
+                                else if (pricing.PricingType == PricingType.Preferred)
+                                {
+                                    var preferred = supprows?.FirstOrDefault(r =>
+                                        r.Get<SupplierProduct, Guid>(x => x.SupplierLink.ID) ==
+                                        product.Get<Product, Guid>(x => x.Supplier.SupplierLink.ID));
+                                    nettCost = preferred?.Get<SupplierProduct, double>(c => c.CostPrice)
+                                               ?? product.Get<Product, double>(x => x.NettCost);
+                                }
+                                else
+                                {
+                                    nettCost = supprows?.Select(r => r.Get<SupplierProduct, double>(c => c.CostPrice)).Min()
+                                               ?? product.Get<Product, double>(x => x.NettCost);
+                                }
+
+                                item.Cost = nettCost * (100.0F + product.Get<Product, double>(x => x.Charge.Price) / 100.0F);
                             }
 
-                            item.Cost = supprod != null ? supprod.CostPrice : product.NettCost;
                         }
                     }
 

+ 4 - 4
prs.desktop/Panels/Quotes/QuoteCostSheets.xaml.cs

@@ -40,8 +40,8 @@ namespace PRSDesktop
 
         public void Refresh()
         {
-            CostSheets.Refresh(true, false);
-            Items.Refresh(true, false);
+            CostSheets.Refresh(false, true);
+            Items.Refresh(false, true);
         }
 
         public Dictionary<string, object[]> Selected()
@@ -54,8 +54,8 @@ namespace PRSDesktop
             CostSheets.OnBeforeSave += CostSheets_OnBeforeSave;
             CostSheets.OnAfterSave += CostSheets_OnAfterSave;
             CostSheets.OnSelectItem += CostSheets_OnSelectItem;
-            CostSheets.Refresh(false, true);
-            Items.Refresh(false, true);
+            CostSheets.Refresh(true, false);
+            Items.Refresh(true, false);
             Items.OnChanged += Items_OnChanged;
         }
 

+ 5 - 9
prs.desktop/Panels/Quotes/QuoteCostSheetsGrid.cs

@@ -8,8 +8,7 @@ namespace PRSDesktop
 {
     public class QuoteCostSheetGrid : DynamicDataGrid<QuoteCostSheet>
     {
-        private Guid _quoteid = Guid.Empty;
-
+        
         public QuoteCostSheetGrid()
         {
             Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns);
@@ -18,16 +17,13 @@ namespace PRSDesktop
             HiddenColumns.Add(x => x.CostSheet.Deleted);
         }
 
-        public Guid QuoteID
+        protected override void GenerateColumns(DynamicGridColumns columns)
         {
-            get => _quoteid;
-            set
-            {
-                _quoteid = value;
-                Refresh(false, true);
-            }
+            columns.Add<QuoteCostSheet, String>(x => x.Description, 0, "Description", "", Alignment.MiddleCenter);
         }
 
+        public Guid QuoteID { get; set; }
+
         private void CustomiseEditor(IDynamicEditorForm sender, QuoteCostSheet[]? items, DynamicGridColumn column, BaseEditor editor)
         {
             if (column.ColumnName.Equals("CostSheet.ID"))

+ 4 - 9
prs.desktop/Panels/StockSummary/StockSummaryGrid.cs

@@ -429,17 +429,12 @@ namespace PRSDesktop
 
         protected override Brush? GetCellBackground(CoreRow row, string columnname)
         {
-
-            // if (String.Equals(columnname, _minstock) || String.Equals(columnname, _bom) || String.Equals(columnname, _issued) || String.Equals(columnname, _nettrequired))
-            //     return Brushes.Khaki;
-            // if (String.Equals(columnname, _stock) || String.Equals(columnname, _ordered))
-            //     return Brushes.Lavender;
+            
             if (String.Equals(columnname, _balance))
             {
-                var balance = row.Get<StockSummary, double>(x => x.BalanceAvailable);
-                return balance < 0.0F
-                    ? Brushes.LightSalmon
-                    : Brushes.LightGreen;
+                return row.Get<StockSummary, double>(x => x.BalanceAvailable) < 0.0F
+                    ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 }
+                    : null;
             }
             return null;
         }