|
@@ -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;
|