Posting a Receipt from the API

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
kwesterlage
Posts: 73
Joined: Thu May 21, 2015 2:28 pm

Posting a Receipt from the API

Post by kwesterlage »

We are currently working to automate the posting of certain receipts in SoftPro. It would really help us if we could see some code demonstrating:

1.) how to set the Payor/Payee of a transaction
2.) how to split a transaction amount between unapplied, earnest money, and a specific line
3.) how to programmatically retrieve the available/valid lines for a particular split
mikedrew
Posts: 4
Joined: Tue Feb 14, 2017 12:08 pm

Re: Posting a Receipt from the API

Post by mikedrew »

Please see the sample code below and let me know if you have any questions.

Code: Select all

//Get the transaction you're interested in
ITransactionsManager tm = sp.GetService<ITransactionsManager>();
ITransactionInfo tInfo = tm.Transactions.Where(t => t.ReferenceNumber == 9876 && t.IsCurrent).Single();
ITransaction tx = tm.GetTransaction(tInfo);


//Set the Payor/Payee
tx.Name = "Mike";


//Adjust the splits
var applied = tx.Splits.Single(s => s.Kind == TransactionSplitKind.Applied);
var unapplied = tx.Splits.Single(s => s.Kind == TransactionSplitKind.Unapplied);
var emd = tx.Splits.Single(s => s.Kind == TransactionSplitKind.EMD);
var line = tx.Splits.Single(s => s.Kind == TransactionSplitKind.SendToLine);

//Receipt amount is $123.00, make sure the splits still add up to $123.00
applied.Amount = 120;

//Send $1 to unapplied
unapplied.Amount = 1;

//Send $1 to earnest money, L.01
emd.Amount = 1;
emd.Description = "Deposit";
emd.Tags.Clear();
emd.Tags.Add(new Tag("CDFSection", "4"));
emd.Tags.Add(new Tag("CDFLine", "1"));

//Find available lines
ILedgersManager lm = sp.GetService<ILedgersManager>();

ILedgerInfo ledgerInfo = lm.Ledgers.Where(l => l.Name == "2017100003").Single();
IOrderLedger ledger = (IOrderLedger)lm.GetLedger(ledgerInfo);
IOrderInformation orderInformation = ledger.GetOrderInformation();

IList<IOrderCDFLine> availableDueToBuyerLines = orderInformation.ApplyTowards.CDF.DueToBuyerSection
                                                                                  .Where(
                                                                                          b => string.IsNullOrEmpty(b.Description) && 
                                                                                          b.Amount <= 0 && 
                                                                                          !b.IsCreditDebit
                                                                                        ).ToList();

//Send $1 to the next available line
line.Amount = 1;
line.Description = "Sending To Line";
line.Tags.Clear();
line.Tags.Add(new Tag("CDFSection", "4"));
line.Tags.Add(new Tag("CDFLine", availableDueToBuyerLines[0].Number.ToString()));



//Save the changes
tm.ApplyChanges("Updated Transaction", tx);
Mike Drew, Software Developer, SoftPro
Post Reply