Browse Source

Fixed Obsolete PurchaseOrderStatus handling on mobile
Improved Photo taking on iOS devices
Fixed Query Column Flags

Frank van den Bos 1 year ago
parent
commit
f6e10e71b8

+ 8 - 10
prs.mobile.new/PRS.Mobile/CustomControls/ImageViewer/ImageViewerPage.xaml.cs

@@ -1,11 +1,9 @@
 using System;
-using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using InABox.Clients;
 using InABox.Core;
 using InABox.Mobile;
-using JetBrains.Annotations;
 using Xamarin.Forms;
 
 namespace PRS.Mobile
@@ -28,13 +26,13 @@ namespace PRS.Mobile
     
     public partial class ImageViewerPage
     {
-        [CanBeNull] private Action _deleteaction = null;
+        private readonly Action? _deleteaction;
 
-        private Document _doc;
+        private Document? _doc;
 
-        public event ImageViewerPageImageChangedEvent ImageChanged;
+        public event ImageViewerPageImageChangedEvent? ImageChanged;
         
-        public ImageViewerPage(ImageSource image, Action ondelete)
+        public ImageViewerPage(ImageSource image, Action? ondelete)
         {
             InitializeComponent();
             BindingContext = image;
@@ -42,7 +40,7 @@ namespace PRS.Mobile
             _delete.IsVisible = ondelete != null;
         }
         
-        public ImageViewerPage(byte[] data, Action ondelete)
+        public ImageViewerPage(byte[] data, Action? ondelete)
         {
             InitializeComponent();
             BindingContext = ImageSource.FromStream(() => new MemoryStream(data));
@@ -53,9 +51,9 @@ namespace PRS.Mobile
         public ImageViewerPage(Guid id)
         {
             InitializeComponent();
-            new Client<Document>().Query(
+            Client.Query(
                 new Filter<Document>(x => x.ID).IsEqualTo(id), 
-                null, 
+                Columns.All<Document>(), 
                 null, 
                 (o, e) =>
                 {
@@ -82,7 +80,7 @@ namespace PRS.Mobile
         {
             if (_doc == null)
                 return;
-            _doc.Data = MobileUtils.ImageTools.RotateImage(_doc.Data,90F,100);
+            _doc.Data = MobileUtils.ImageTools.RotateImage(_doc.Data,90F);
             _doc.CRC = CoreUtils.CalculateCRC(_doc.Data);
             var msg = "Image Rotated on Mobile Device";
             new Client<Document>().Save(_doc, msg);

+ 10 - 1
prs.mobile.new/PRS.Mobile/Data Models/Lists/PurchaseOrder/PurchaseOrderShell.cs

@@ -16,7 +16,11 @@ namespace PRS.Mobile
                 .Map(nameof(SupplierName), x => x.SupplierLink.Name)
                 .Map(nameof(Notes), x => x.Notes)
                 .Map(nameof(DueDate), x => x.DueDate)
-                .Map(nameof(Status), x => x.Status)
+                .Map(nameof(IssuedDate), x=>x.IssuedDate)
+                .Map(nameof(ClosedDate), x => x.ClosedDate)
+                .Map(nameof(CancelledDate), x=>x.CancelledDate)
+                .Map(nameof(Unreceived), x=>x.Unreceived)
+                .Map(nameof(Received), x=>x.Received)
                 ;
         }
         
@@ -25,6 +29,11 @@ namespace PRS.Mobile
         public string SupplierName => Get<String>();
         public String Notes => Get<String>();
         public DateTime DueDate => Get<DateTime>();
+        public DateTime IssuedDate => Get<DateTime>();
+        public double Received => Get<double>();
+        public double Unreceived => Get<double>();
+        public DateTime ClosedDate => Get<DateTime>();
+        public DateTime CancelledDate => Get<DateTime>();
         public PurchaseOrderStatus Status => Get<PurchaseOrderStatus>();
         
     }

+ 2 - 2
prs.mobile.new/PRS.Mobile/Modules/Deliveries/FrameScanner/Views/FrameDocumentPage.xaml.cs

@@ -29,9 +29,9 @@ namespace PRS.Mobile
 
             _documentid = documentid;
 
-            new Client<Document>().Query(
+            Client.Query(
                 new Filter<Document>(x => x.ID).IsEqualTo(_documentid),
-                null,
+                Columns.All<Document>(),
                 null,
                 (docs, error) =>
                 {

+ 4 - 1
prs.mobile.new/PRS.Mobile/Modules/Purchases/PurchaseOrderListView.xaml

@@ -6,6 +6,9 @@
              xmlns:local="clr-namespace:PRS.Mobile;assembly=PRS.Mobile"
              x:Class="PRS.Mobile.PurchaseOrderListView">
     
+    <ContentView.Resources>
+        <local:PurchaseOrderStatusConverter x:Key="PurchaseOrderStatusConverter"/>
+    </ContentView.Resources>
     <ContentView.Content>
 
         <Grid
@@ -97,7 +100,7 @@
                                     Grid.ColumnSpan="2"
                                     HorizontalOptions="Start"
                                     VerticalOptions="Center"
-                                    Text="{Binding Status}"
+                                    Text="{Binding ., Converter={StaticResource PurchaseOrderStatusConverter}}"
                                     FontSize="Micro"/>
 
                                 <Label 

+ 20 - 1
prs.mobile.new/PRS.Mobile/Modules/Purchases/PurchaseOrderListView.xaml.cs

@@ -41,8 +41,27 @@ namespace PRS.Mobile
     }
     
     public delegate void PurchaseOrderSelectedEvent(object sender, PurchaseOrderSelectedEventArgs args);
-    
 
+    public class PurchaseOrderStatusConverter : AbstractConverter<PurchaseOrderShell, String>
+    {
+        protected override string? Convert(PurchaseOrderShell? value, object? parameter = null)
+        {
+            return value == null
+                ? string.Empty
+                : !value.CancelledDate.IsEmpty()
+                    ? "Cancelled"
+                    : !value.ClosedDate.IsEmpty()
+                        ? "Closed"
+                        : !value.IssuedDate.IsEmpty()
+                            ? !value.Unreceived.IsEffectivelyEqual(0.0)
+                                ? !value.Received.IsEffectivelyEqual(0.0)
+                                    ? "Backorder"
+                                    : "Issued"
+                                : "Received"
+                            : "Draft";
+        }
+    }
+    
     
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class PurchaseOrderListView

+ 2 - 2
prs.mobile.new/PRS.Mobile/Modules/StoreRequis/StoreRequiConfirmationPage.xaml.cs

@@ -153,9 +153,9 @@ namespace PRS.Mobile
                         List<object> list = row.Values;
                         if (list[0] == null) { list[0] = Guid.Empty; }
                         Guid requisitionDocLinkID = Guid.Parse(list[0].ToString());
-                        new Client<Document>().Query(
+                        Client.Query(
                             new Filter<Document>(x => x.ID).IsEqualTo(requisitionDocLinkID),
-                            null,
+                            Columns.All<Document>(),
                             null,
                             (t, e) =>
                             {

+ 3 - 3
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Products/HoldingViewer.xaml.cs

@@ -58,7 +58,7 @@ namespace PRS.Mobile
                     Document doc = newPhotoDocuments.FirstOrDefault<Document>();
                     new Client<Document>().Save(doc, "Updated from mobile device");
 
-                    new Client<Product>().Query(
+                    Client.Query(
                             new Filter<Product>(x => x.ID).IsEqualTo(productID),
                             new Columns<Product>(ColumnTypeFlags.None).Add(x => x.ID, x => x.Image.ID),
                             null,
@@ -205,9 +205,9 @@ namespace PRS.Mobile
                 photoLbl.Text = "Loading Image";
                 await Task.Run(() =>
                 {
-                    new Client<Document>().Query(
+                    Client.Query(
                             new Filter<Document>(x => x.ID).IsEqualTo(imageID),
-                            null,
+                            Columns.All<Document>(),
                             null,
                             (t, e) =>
                             {

+ 1 - 1
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Stocktake/Edit/StockTakeEdit.xaml.cs

@@ -214,7 +214,7 @@ namespace PRS.Mobile
             where T : MobileImageSource<T, TOptions>
             where TOptions : MobileImageOptions<T>, new()
         {
-
+            App.Data.Products.Refresh(false);
             var product = App.Data.Products.FirstOrDefault(x => x.ID == ViewModel.Transaction.ProductID);
             if (product != null)
             {

+ 17 - 17
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Stocktake/StocktakeModule.xaml.cs

@@ -164,23 +164,23 @@ namespace PRS.Mobile
                     
                     if (shell.Parent.Transactions != null && !shell.Parent.Transactions.Contains(transaction))
                         shell.Parent.Transactions?.Add(transaction);
-                    if (shell.ID == Guid.Empty)
-                    {
-                        shell.ProductID = transaction.ProductID;
-                        shell.ProductCode = transaction.ProductCode;
-                        shell.ProductName = transaction.ProductName;
-                        var imageid = transaction.ImageID;
-                        if (imageid != Guid.Empty)
-                            shell.Parent.Images[imageid] = transaction.Image;
-                        shell.ImageID = imageid;
-                        shell.DimensionsUnitID = transaction.DimensionsUnitID;
-                        shell.DimensionsHeight = transaction.DimensionsHeight;
-                        shell.DimensionsWidth = transaction.DimensionsWidth;
-                        shell.DimensionsLength = transaction.DimensionsLength;
-                        shell.DimensionsQuantity = transaction.DimensionsQuantity;
-                        shell.DimensionsValue = transaction.DimensionsValue;
-                        shell.DimensionsUnitSize = transaction.DimensionsUnitSize;
-                    }
+
+                    shell.ProductID = transaction.ProductID;
+                    shell.ProductCode = transaction.ProductCode;
+                    shell.ProductName = transaction.ProductName;
+                    
+                    var imageid = transaction.ImageID;
+                    if (imageid != Guid.Empty)
+                        shell.Parent.Images[imageid] = transaction.Image;
+                    shell.ImageID = imageid;
+                    shell.DimensionsUnitID = transaction.DimensionsUnitID;
+                    shell.DimensionsHeight = transaction.DimensionsHeight;
+                    shell.DimensionsWidth = transaction.DimensionsWidth;
+                    shell.DimensionsLength = transaction.DimensionsLength;
+                    shell.DimensionsQuantity = transaction.DimensionsQuantity;
+                    shell.DimensionsValue = transaction.DimensionsValue;
+                    shell.DimensionsUnitSize = transaction.DimensionsUnitSize;
+
                     _holdings.ItemsSource = null;
                     _holdings.ItemsSource = ViewModel.Holdings.Items;
                 };