Bladeren bron

Adding account and removing row id from receipt poster

Kenric Nugteren 1 jaar geleden
bovenliggende
commit
7df82ab8e4
2 gewijzigde bestanden met toevoegingen van 23 en 6 verwijderingen
  1. 1 1
      prs.classes/Entities/Invoice/InvoiceLink.cs
  2. 22 5
      prs.shared/Posters/MYOB/ReceiptMYOBPoster.cs

+ 1 - 1
prs.classes/Entities/Invoice/InvoiceLink.cs

@@ -5,7 +5,7 @@ namespace Comal.Classes
 {
     public class InvoiceLink : EntityLink<Invoice>, IPostable
     {
-        [CodePopupEditor(typeof(Invoice))]
+        [PopupEditor(typeof(Invoice))]
         public override Guid ID { get; set; }
 
         [NullEditor]

+ 22 - 5
prs.shared/Posters/MYOB/ReceiptMYOBPoster.cs

@@ -1,5 +1,6 @@
 using Comal.Classes;
 using InABox.Core;
+using InABox.Core.Postable;
 using InABox.Poster.MYOB;
 using MYOB.AccountRight.SDK.Contracts.Version2.Sale;
 using MYOB.AccountRight.SDK.Services.Sale;
@@ -16,6 +17,9 @@ namespace PRS.Shared.Posters.MYOB;
 
 public class ReceiptMYOBPosterSettings : MYOBPosterSettings
 {
+    [EditorSequence(1)]
+    [TextBoxEditor(ToolTip = "The MYOB account code for receipts")]
+    public string Account { get; set; }
 }
 
 public class ReceiptMYOBPoster : IMYOBPoster<Receipt, ReceiptMYOBPosterSettings>
@@ -30,7 +34,7 @@ public class ReceiptMYOBPoster : IMYOBPoster<Receipt, ReceiptMYOBPosterSettings>
         {
             table.IsDefault = false;
         }
-        model.SetShouldLoad<Receipt>(true);
+        model.SetIsDefault<Receipt>(true);
         model.SetColumns<Receipt>(RequiredReceiptColumns());
 
         model.SetIsDefault<InvoiceReceipt>(true, alias: "Receipt_InvoiceReceipt");
@@ -95,12 +99,25 @@ public class ReceiptMYOBPoster : IMYOBPoster<Receipt, ReceiptMYOBPosterSettings>
 
             var myobReceipt = new MYOBReceipt();
 
-            myobReceipt.DepositTo = DepositTo.UndepositedFunds;
+            myobReceipt.DepositTo = DepositTo.Account;
 
             // Setting this to null right now.
             myobReceipt.Account ??= new();
-            myobReceipt.Account.UID = Guid.Empty;
-            // Account =
+
+            if (Settings.Account.IsNullOrWhiteSpace())
+            {
+                throw new MissingSettingException<ReceiptMYOBPosterSettings>(x => x.Account);
+            }
+            else if(AccountMYOBUtils.GetAccount(ConnectionData, Settings.Account).Get(out var accountID, out var error))
+            {
+                myobReceipt.Account.UID = accountID;
+            }
+            else
+            {
+                CoreUtils.LogException("", error);
+                results.AddFailed(receipt, error.Message);
+                continue;
+            }
 
             if(customers.TryGetValue(receipt.CustomerLink.ID, out var customer))
             {
@@ -131,7 +148,7 @@ public class ReceiptMYOBPoster : IMYOBPoster<Receipt, ReceiptMYOBPosterSettings>
                     var invoice = receiptInvoices[i];
 
                     var line = new CustomerPaymentLine();
-                    line.RowID = i + 1;
+                    // line.RowID = i + 1;
                     line.Number = invoice.InvoiceLink.Number.ToString().Truncate(8);
                     line.AmountApplied = (decimal)invoice.Amount;
                     line.Type = CustomerPaymentLineType.Invoice;