|
@@ -15,6 +15,7 @@ using Customer = Comal.Classes.Customer;
|
|
|
using MYOBCustomer = MYOB.AccountRight.SDK.Contracts.Version2.Contact.Customer;
|
|
|
using MYOBAddress = MYOB.AccountRight.SDK.Contracts.Version2.Contact.Address;
|
|
|
using MYOB.AccountRight.SDK.Contracts.Version2.Sale;
|
|
|
+using InABox.Clients;
|
|
|
|
|
|
namespace PRS.Shared.Posters.MYOB;
|
|
|
|
|
@@ -61,14 +62,44 @@ public class CustomerMYOBPoster : IMYOBPoster<Customer, CustomerMYOBPosterSettin
|
|
|
table.IsDefault = false;
|
|
|
}
|
|
|
model.SetIsDefault<Customer>(true);
|
|
|
+ model.SetColumns<Customer>(RequiredColumns());
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public static Columns<Customer> RequiredColumns()
|
|
|
+ {
|
|
|
+ return Columns.None<Customer>()
|
|
|
+ .Add(x => x.ID)
|
|
|
+ .Add(x => x.PostedReference)
|
|
|
+ .Add(x => x.DefaultContact.Name)
|
|
|
+ .Add(x => x.Name)
|
|
|
+ .Add(x => x.Code)
|
|
|
+ .Add(x => x.CustomerStatus.ID)
|
|
|
+ .Add(x => x.CustomerStatus.Active)
|
|
|
+ .Add(x => x.Delivery.Street)
|
|
|
+ .Add(x => x.Delivery.City)
|
|
|
+ .Add(x => x.Delivery.State)
|
|
|
+ .Add(x => x.Delivery.PostCode)
|
|
|
+ .Add(x => x.Postal.Street)
|
|
|
+ .Add(x => x.Postal.City)
|
|
|
+ .Add(x => x.Postal.State)
|
|
|
+ .Add(x => x.Postal.PostCode)
|
|
|
+ .Add(x => x.DefaultContact.Mobile)
|
|
|
+ .Add(x => x.DefaultContact.Telephone)
|
|
|
+ .Add(x => x.DefaultContact.Email)
|
|
|
+ .Add(x => x.DefaultContact.Name)
|
|
|
+ .Add(x => x.DefaultContact.Mobile)
|
|
|
+ .Add(x => x.ABN);
|
|
|
+ }
|
|
|
+
|
|
|
public static Result<Exception> UpdateCustomer(MYOBConnectionData data, CustomerMYOBPosterSettings settings, Customer customer, MYOBCustomer myobCustomer, bool isNew)
|
|
|
{
|
|
|
// Documentation: https://developer.myob.com/api/myob-business-api/v2/contact/customer/
|
|
|
|
|
|
+ // Since this might be called from some other poster, we need to ensure we have the right columns.
|
|
|
+ Client.EnsureColumns(customer, RequiredColumns());
|
|
|
+
|
|
|
SplitName(customer.DefaultContact.Name, out var firstName, out var lastName);
|
|
|
|
|
|
myobCustomer.CompanyName = customer.Name.Truncate(50);
|