فهرست منبع

Removed requirement for User name on MYOB company file

Kenric Nugteren 11 ماه پیش
والد
کامیت
b357b4c0a3

+ 15 - 0
InABox.Poster.MYOB/MYOBGlobalPosterSettings.cs

@@ -21,6 +21,21 @@ public class MYOBGlobalPosterSettings : GlobalPosterSettings
     [PasswordEditor(ViewButtonVisible = true)]
     [PasswordEditor(ViewButtonVisible = true)]
     public string CompanyFilePassword { get; set; }
     public string CompanyFilePassword { get; set; }
 
 
+    [EditorSequence(4)]
+    [CheckBoxEditor]
+    public bool NoCredentials { get; set; }
+
     [TextBoxEditor(ToolTip = "The MYOB tax code which should be used for global supplier tax codes, customer tax codes, freight tax codes, etc.")]
     [TextBoxEditor(ToolTip = "The MYOB tax code which should be used for global supplier tax codes, customer tax codes, freight tax codes, etc.")]
     public string DefaultTaxCode { get; set; }
     public string DefaultTaxCode { get; set; }
+
+    protected override void DoPropertyChanged(string name, object? before, object? after)
+    {
+        base.DoPropertyChanged(name, before, after);
+
+        if(name == nameof(NoCredentials) && NoCredentials)
+        {
+            CompanyFileUserID = "";
+            CompanyFilePassword = "";
+        }
+    }
 }
 }

+ 7 - 2
InABox.Poster.MYOB/MYOBPosterEngine.cs

@@ -183,24 +183,29 @@ public abstract class MYOBPosterEngine<TPostable, TSettings> :
                 }
                 }
             }
             }
 
 
-            if(globalSettings.CompanyFileUserID.IsNullOrWhiteSpace())
+            if(!globalSettings.NoCredentials && globalSettings.CompanyFileUserID.IsNullOrWhiteSpace())
             {
             {
                 var credentials = new MYOBCompanyFileCredentials
                 var credentials = new MYOBCompanyFileCredentials
                 {
                 {
                     UserID = globalSettings.CompanyFileUserID,
                     UserID = globalSettings.CompanyFileUserID,
                     Password = globalSettings.CompanyFilePassword,
                     Password = globalSettings.CompanyFilePassword,
+                    NoCredentials = globalSettings.NoCredentials
                 };
                 };
                 if (DynamicGridUtils.EditObject(credentials, customiseGrid: grid =>
                 if (DynamicGridUtils.EditObject(credentials, customiseGrid: grid =>
                 {
                 {
                     grid.OnValidate += (grid, items, errors) =>
                     grid.OnValidate += (grid, items, errors) =>
                     {
                     {
-                        if(items.Any(x => x.UserID.IsNullOrWhiteSpace()))
+                        var item = items.FirstOrDefault();
+                        if (item is null) return;
+
+                        if(!item.NoCredentials && item.UserID.IsNullOrWhiteSpace())
                         {
                         {
                             errors.Add("[UserID] cannot be blank");
                             errors.Add("[UserID] cannot be blank");
                         }
                         }
                     };
                     };
                 }))
                 }))
                 {
                 {
+                    globalSettings.NoCredentials = credentials.NoCredentials;
                     globalSettings.CompanyFileUserID = credentials.UserID;
                     globalSettings.CompanyFileUserID = credentials.UserID;
                     globalSettings.CompanyFilePassword = credentials.Password;
                     globalSettings.CompanyFilePassword = credentials.Password;
 
 

+ 17 - 2
InABox.Poster.MYOB/UI/MYOBCompanyFileCredentials.cs

@@ -11,9 +11,24 @@ public class MYOBCompanyFileCredentials : BaseObject
 {
 {
     [EditorSequence(1)]
     [EditorSequence(1)]
     [TextBoxEditor]
     [TextBoxEditor]
-    public string UserID { get; set; }
+    public string UserID { get; set; } = "";
 
 
     [EditorSequence(2)]
     [EditorSequence(2)]
     [PasswordEditor(ViewButtonVisible = true)]
     [PasswordEditor(ViewButtonVisible = true)]
-    public string Password { get; set; }
+    public string Password { get; set; } = "";
+
+    [EditorSequence(3)]
+    [CheckBoxEditor]
+    public bool NoCredentials { get; set; } = false;
+
+    protected override void DoPropertyChanged(string name, object? before, object? after)
+    {
+        base.DoPropertyChanged(name, before, after);
+
+        if(name == nameof(NoCredentials) && NoCredentials)
+        {
+            UserID = "";
+            Password = "";
+        }
+    }
 }
 }