Просмотр исходного кода

Fixed errors with payment and receipt posters

Kenric Nugteren 2 недель назад
Родитель
Сommit
04537f5568

+ 11 - 3
prs.shared/Posters/Xero/PaymentXeroPoster.cs

@@ -161,10 +161,17 @@ public class PaymentXeroPoster : IXeroPoster<Payment, PaymentXeroPosterSettings>
             {
                 throw new MissingSettingException<PaymentXeroPosterSettings>(x => x.Account);
             }
-            else
+            else if(AccountXeroUtils.GetAccount(ConnectionData, Settings.Account).Get(out var account, out var error))
             {
                 xeroPayment.Account ??= new();
-                xeroPayment.Account.Code = Settings.Account;
+                xeroPayment.Account.AccountID = account.AccountID;
+                xeroPayment.Account.Code = account.Code;
+            }
+            else
+            {
+                CoreUtils.LogException("", error);
+                results.AddFailed(payment, error.Message);
+                continue;
             }
 
             xeroPayment.Date = payment.Date;
@@ -182,10 +189,11 @@ public class PaymentXeroPoster : IXeroPoster<Payment, PaymentXeroPosterSettings>
                     // BankAccountNumber
 
                     line.Amount = bill.Amount;
-                    line.Details = payment.Notes;
+                    line.Details = payment.Notes.Truncate(18);
 
                     if(Guid.TryParse(bill.Bill.PostedReference, out var xeroBillID))
                     {
+                        line.Invoice ??= new();
                         line.Invoice.InvoiceID = xeroBillID;
                     }
                     else

+ 13 - 4
prs.shared/Posters/Xero/ReceiptXeroPoster.cs

@@ -161,14 +161,22 @@ public class ReceiptXeroPoster : IXeroPoster<Receipt, ReceiptXeroPosterSettings>
             {
                 throw new MissingSettingException<ReceiptXeroPosterSettings>(x => x.Account);
             }
-            else
+            else if(AccountXeroUtils.GetAccount(ConnectionData, Settings.Account).Get(out var account, out var error))
             {
                 xeroReceipt.Account ??= new();
-                xeroReceipt.Account.Code = Settings.Account;
+                xeroReceipt.Account.AccountID = account.AccountID;
+                xeroReceipt.Account.Code = account.Code;
+            }
+            else
+            {
+                CoreUtils.LogException("", error);
+                results.AddFailed(receipt, error.Message);
+                continue;
             }
 
             xeroReceipt.Date = receipt.Date;
-            xeroReceipt.Details = receipt.Notes.Truncate(18);
+            // xeroReceipt.Details = receipt.Notes.Truncate(18);
+            xeroReceipt.Reference = receipt.Notes.Truncate(12);
 
             if(billReceipts.TryGetValue(receipt.ID, out var receiptInvoices))
             {
@@ -182,10 +190,11 @@ public class ReceiptXeroPoster : IXeroPoster<Receipt, ReceiptXeroPosterSettings>
                     // BankAccountNumber
 
                     line.Amount = bill.Amount;
-                    line.Details = receipt.Notes;
+                    // line.Details = receipt.Notes;
 
                     if(Guid.TryParse(bill.Invoice.PostedReference, out var xeroInvoiceID))
                     {
+                        line.Invoice ??= new();
                         line.Invoice.InvoiceID = xeroInvoiceID;
                     }
                     else