Posting Checks to an Invoice

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
Posts: 108
Joined: Thu Aug 04, 2011 3:11 pm

Posting Checks to an Invoice

Post by joe.mag » Wed Jan 06, 2021 9:34 am

I am on version 4.2.41028.10 (preparing to upgrade in a few months). I have been tasked with posting check payments to the invoice of an order via the API. I can fetch the invoice by simply calling order.Invoices[0] where order is a dynamic reference to the open order (we apparently never use more than one invoice and always have an invoice). I cannot, however, appear to find any documentation or reference to the InvoicePayment type that I see mentioned via reflection-based querying of the invoice object. I also cannot appear to declare a variable of type InvoicePayment in order to add it to the invoice object's payments collection. Any guidance would be appreciated.

Posts: 1006
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC

Re: Posting Checks to an Invoice

Post by BobRichards » Wed Jan 06, 2021 12:46 pm

Like all parent nodes in the order model, they are IOrderItem objects and that is the only type available to Visual Studio. You cannot use the derived types from the order model (such as Property, LoanPolicy, InvoicePayment, etc.) because Visual Studio does not have the source code where the types are defined.

The code below assumes the first invoice has been sent and adds a payment to the Payments collection. The key is to get a new InvoicePayment object from the order like is done for any other order model type.

Code: Select all

// Get payments collection for first invoice.
IOrderItem invoice = (IOrderItem)((IList)order.GetProperty("Invoices"))[0];
IList payments = (IList)invoice.GetProperty("Payments");

// Create a payment and add it to the payments collection.
IOrderItem payment = order.CreateNew("InvoicePayment");

// Modify properties AFTER it is added to collection.
//  ("DatePaid" property defaults to today - I'll leave it alone)
payment.SetProperty("Description", "The description");
payment.SetProperty("ReferenceNumber", "A ref num.");
payment.SetProperty("Amount", 666.00m);

// Save order with changes.
IOrderStore os = ss.GetService<IOrderStore>();
Bob Richards, Software Developer, SoftPro

Posts: 108
Joined: Thu Aug 04, 2011 3:11 pm

Re: Posting Checks to an Invoice

Post by joe.mag » Wed Jan 06, 2021 2:41 pm


As always, you've provided excellent customer service. A code example, even! Thanks!

That worked like a charm.


Post Reply