Sample code for Anticipated (Incoming) Wires

Discussions related to custom development with Select.
Post Reply
PeterKelly
Posts: 92
Joined: Tue Feb 04, 2014 3:34 pm

Sample code for Anticipated (Incoming) Wires

Post by PeterKelly »

Hi,

Can somebody please provide me some sample code to add an Anticipated Incoming Wire to a dynamic order?

I'm not sure what object to create and where it goes since the Field Code Browser doesn't work for popups. Or is there a workaround for that?

Thanks,
Peter
sindrapal
Posts: 42
Joined: Tue Oct 14, 2008 9:21 am

Re: Sample code for Anticipated (Incoming) Wires

Post by sindrapal »

Here you go. Please let me know if you have any questions.

// Add an anticipated wire to an order related ledger
ILedgersManager lm = _sps.GetService<ILedgersManager>();

// find the ledger
ILedgerInfo info = lm.Ledgers
.Where(l => l.Name == "TestLedger" && l.TrustAccount.Code == "Code1")
.SingleOrDefault();

if (info != null)
{
// load the full ledger object
IOrderLedger ledger = (IOrderLedger)lm.GetLedger(info);
IOrderInformation oi = ledger.GetOrderInformation();

// get a contact for the anticipated wire
IOrderContact contact = oi.Contacts.First();

// create a new instance of the IAnticipatedWire type
IAnticipatedWire wire = ledger.NewAnticipatedWire(contact, 1000);
ledger.AnticipatedWires.Add(wire);

// save changes
lm.ApplyChanges(ledger);
}
Post Reply