Browse Source

Fixed up BillLine Editor sequences, and also improved the BillLine Editor, with a new edit button, improvements to DirectEditor, and performance improvemnets.
Also fixed BillLines synchronising with Bill.
Fixed BillLineStore performance problems

Kenric Nugteren 2 năm trước cách đây
mục cha
commit
63f7eca234

+ 8 - 3
prs.classes/Entities/Bill/BillLine.cs

@@ -17,17 +17,21 @@ namespace Comal.Classes
         public BillLink BillLink { get; set; }
 
         [EntityRelationship(DeleteAction.SetNull)]
+        [EditorSequence(1)]
         public PurchaseOrderItemLink OrderItem { get; set; }
 
         [MemoEditor]
+        [EditorSequence(2)]
         public string Description { get; set; }
 
-        [RequiredColumn]
-        public TaxCodeLink TaxCode { get; set; }
-
         [DoubleEditor(Summary = Summary.Sum)]
+        [EditorSequence(3)]
         public double ExTax { get; set; }
 
+        [RequiredColumn]
+        [EditorSequence(4)]
+        public TaxCodeLink TaxCode { get; set; }
+
         [DoubleEditor(Editable = Editable.Hidden)]
         public double TaxRate { get; set; }
 
@@ -35,6 +39,7 @@ namespace Comal.Classes
         public double Tax { get; set; }
 
         [DoubleEditor(Summary = Summary.Sum)]
+        [EditorSequence(5)]
         public double IncTax { get; set; }
 
         [NullEditor]

+ 1 - 1
prs.desktop/Panels/DataEntry/DataEntryPanel.xaml.cs

@@ -215,7 +215,7 @@ namespace PRSDesktop
 
                 var code = DatabaseSchema.Properties(selectedType)
                     .Where(x => x.Parent is null && (x.Editor is CodeEditor || x.Editor is UniqueCodeEditor)
-                        && x.Editor.Editable != Editable.Hidden)
+                        && x.Editor.Editable.EditorVisible())
                     .FirstOrDefault();
 
                 BaseEditor editor;

+ 52 - 2
prs.desktop/Panels/Suppliers/SupplierBillLineGrid.cs

@@ -1,16 +1,21 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Windows.Controls;
+using System.Windows.Media.Imaging;
 using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using InABox.DynamicGrid;
+using InABox.Wpf;
 using InABox.WPF;
 
 namespace PRSDesktop
 {
     public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
     {
+        private static readonly BitmapImage pencil = InABox.Wpf.Resources.pencil.AsBitmapImage();
+
         public SupplierBillLineGrid()
         {
             Options
@@ -34,12 +39,57 @@ namespace PRSDesktop
             HiddenColumns.Add(x => x.IncTax);
             HiddenColumns.Add(x => x.Description);
 
+            ActionColumns.Add(new DynamicImageColumn(pencil, BillLineEdit_Click));
+        }
+
+        public override void Load(object item, Func<Type, CoreTable>? PageDataHandler)
+        {
+            Refresh(true, false);
+            base.Load(item, type =>
+            {
+                var data = PageDataHandler?.Invoke(type);
+                if(data is null && type == typeof(BillLine))
+                {
+                    data = new Client<BillLine>().Query(
+                        new Filter<BillLine>(x => x.BillLink.ID).IsEqualTo(Item.ID),
+                        DynamicGridUtils.LoadEditorColumns(DataColumns()),
+                        LookupFactory.DefineSort<BillLine>());
+                }
+                return data;
+            });
+        }
+
+        private bool BillLineEdit_Click(CoreRow? row)
+        {
+            if(row is null)
+            {
+                return false;
+            }
+            var item = LoadItem(row);
+            if (EditItems(new BillLine[] { item }))
+            {
+                SaveItem(item);
+                return true;
+            }
+            return false;
+        }
+
+        public override void ConfigureColumns(DynamicGridColumns columns)
+        {
+            base.ConfigureColumns(columns);
+
+            var orderItemColumn = columns.Find(x => x.ColumnName == $"{nameof(BillLine.OrderItem)}.{nameof(BillLine.OrderItem.ID)}");
+            if (orderItemColumn != null)
+            {
+                orderItemColumn.Editor.Editable = Editable.DisabledOnDirectEdit;
+            }
         }
 
         private bool ImportPOLines(Button arg1, CoreRow[] arg2)
         {
             MultiSelectDialog<PurchaseOrderItem> dlg = new MultiSelectDialog<PurchaseOrderItem>(
-                new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID).And(x => x.PurchaseOrderLink.ClosedDate).IsEqualTo(DateTime.MinValue),
+                new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID)
+                    .And(x => x.PurchaseOrderLink.ClosedDate).IsEqualTo(DateTime.MinValue),
                 new Columns<PurchaseOrderItem>
                 (
                     x => x.ID,
@@ -72,7 +122,7 @@ namespace PRSDesktop
                 );
                 foreach (var row in items.Rows)
                 {
-                    var line = new BillLine();
+                    var line = CreateItem();
 
                     line.OrderItem.ID = row.Get<PurchaseOrderItem, Guid>(x => x.ID);
                     line.OrderItem.PurchaseOrderLink.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseOrderLink.ID);

+ 1 - 0
prs.desktop/Panels/Suppliers/SupplierBillPanel.xaml.cs

@@ -4,6 +4,7 @@ using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using Comal.Classes;
+using InABox.Clients;
 using InABox.Core;
 using InABox.DynamicGrid;
 using InABox.WPF;

+ 1 - 1
prs.server/Engines/WebEngine/WebListener.cs

@@ -880,7 +880,7 @@ Model.LoadModel(
             foreach (var property in DatabaseSchema.Properties(entityType))
             {
                 var editor = EditorUtils.GetPropertyEditor(entityType, property);
-                if (editor != null && !(editor is NullEditor) && editor.Editable != Editable.Hidden)
+                if (editor != null && !(editor is NullEditor) && editor.Editable.EditorVisible())
                 {
                     if (editor is LookupEditor)
                     {

+ 9 - 3
prs.stores/BillLineStore.cs

@@ -12,19 +12,25 @@ namespace Comal.Stores
             var pitems = Provider.Query(
                 new Filter<PurchaseOrderItem>(x => x.ID).IsEqualTo(entity.OrderItem.ID),
                 new Columns<PurchaseOrderItem>(
+                    x => x.ID,
+                    x => x.ExTax,
+                    x => x.TaxCode,
+                    x => x.TaxRate,
+                    x => x.IncTax,
+                    x => x.Balance,
+                    x => x.ReceivedDate
                 )
             ).Rows.Select(x => x.ToObject<PurchaseOrderItem>()).ToArray();
             foreach (var pitem in pitems)
             {
                 pitem.ExTax = entity.ExTax;
-                pitem.TaxCode = entity.TaxCode;
+                pitem.TaxCode.ID = entity.TaxCode.ID;
                 pitem.TaxRate = entity.TaxRate;
                 pitem.IncTax = entity.IncTax;
                 pitem.Balance = pitem.ReceivedDate.IsEmpty() ? pitem.IncTax : 0.00F;
             }
 
-            ;
-            FindSubStore<PurchaseOrderItem>().Save(pitems, "Updated by Bill Modification");
+            FindSubStore<PurchaseOrderItem>().Save(pitems.Where(x => x.IsChanged()), "Updated by Bill Modification");
         }
     }
 }