Disburse Transferred Funds

Discussions related to custom development with Select.
Post Reply
tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Disburse Transferred Funds

Post by tmeisinger » Wed Jun 24, 2015 3:58 pm

We would like to use the API to Disburse all of the Receipts (Transfers from the Order Ledgers) out of a Revenue Ledger. Has anyone done this or could someone give me a little head start?

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

Re: Disburse Transferred Funds

Post by sindrapal » Thu Jun 25, 2015 10:52 am

Please refer to the code sample below that shows how you can accomplish this using the API. Hope this helps!

// Load the revenue ledger
ILedgersManager lm = _sps.GetService<ILedgersManager>();
ILedgerInfo ledgerInfo = lm.Ledgers
.Where(l => l.Name == "RevenueLedger")
.Single();

// Disbursed transferred funds functionality only supports Specialized ledgers (Fee, Revenue & Transfer)
ISpecializedLedger ledger = (ISpecializedLedger)lm.GetLedger(ledgerInfo);

// Load the corresponding trust account
IAccountsManager am = _sps.GetService<IAccountsManager>();
ITrustAccount ta = am.GetTrustAccount(ledger.TrustAccount.ID);

// Load the receipts that need to be disbursed - ledger transfer-in (FTI) transactions
ITransactionsManager tm = _sps.GetService<ITransactionsManager>();
List<ITransactionInfo> transfers = tm.Transactions
.Where(ti => (ti.IsCurrent)
&& (ti.Ledger.ID == ledger.ID)
&& (!ti.IsDeleted && ti.Status == TransactionStatus.Posted)
&& (ti.Kind == TransactionKind.LedgerTransferIn))
.ToList()
.Where(ti => (!ti.DisbursedAsTransactionID.HasValue))
.ToList();

// Create the Funds transferred disbursement. Can be of type - MDE, CHK or WOU.
IBankDebitTransaction disbursement = tm.NewTransaction<IMiscellaneousDebitTransaction>(ledgerInfo);
if (ledger is IRevenueLedger)
{
disbursement.Name = ta.RevenueDefaults.PayeeName;
disbursement.Memo = ta.RevenueDefaults.Memo;
}
else
{
disbursement.Name = ledger.Payee;
}

// Add transfers to the disbursement
disbursement.Status = TransactionStatus.Posted;
transfers.ForEach(t => disbursement.RelatedTransfers.Add(t));
disbursement.Amount = transfers.Sum(t => t.Amount);
disbursement.Splits.FirstOrDefault(s => s.Kind == TransactionSplitKind.Unapplied).Amount = disbursement.Amount;

// Save
tm.ApplyChanges("Original", disbursement);

tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Disburse Transferred Funds

Post by tmeisinger » Fri Jun 26, 2015 7:51 am

Thank you very much, I'm a VB guy (don't hold that against me) so it took a little tweaking but I got it working. I hate to think how long it would have taken me without your help.

tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Disburse Transferred Funds

Post by tmeisinger » Thu Jul 09, 2015 9:08 am

I can Disburse by creating a Posted Misc Debit, but when I try to Disburse by creating a Pending Check (the API works and the transaction is created) and go into SoftPro Select, I can't Print/Post. When I go to Post, I'm not able to enter the Check number or change any of the fields. If I try to Post anyway, I get 'Unable to save changes, Operation is not valid due to the current state of the object.'. Any ideas? Missing a required field on the Check? Here is my VB Code...

Code: Select all

If ledger.DisburseAs = BankDisbursementKind.Check Then
    Dim chk As ICheckTransaction = tm.NewTransaction(Of ICheckTransaction)(ledgerInfo)
    chk.Name = ledger.Payee
    chk.Medium = mediumLU.Values.First(Function(MLU) MLU.Code = "CHK")
    chk.MemoExtended = "Memo"
    chk.Status = TransactionStatus.Pending
    transfers.ForEach(Sub(t) chk.RelatedTransfers.Add(t))
    chk.Amount = transfers.Sum(Function(t) t.Amount)
    chk.Splits.FirstOrDefault(Function(s) s.Kind = TransactionSplitKind.Unapplied).Amount = chk.Amount
    tm.ApplyChanges("Original", chk)
ElseIf ledger.DisburseAs = BankDisbursementKind.MiscellaneousDebit Then
    Dim debit As IMiscellaneousDebitTransaction = tm.NewTransaction(Of IMiscellaneousDebitTransaction)(ledgerInfo)
    debit.Name = ledger.Payee
    debit.Medium = mediumLU.Values.First(Function(MLU) MLU.Code = "DDP")
    debit.MemoExtended = "Memo"
    debit.Status = TransactionStatus.Posted
    transfers.ForEach(Sub(t) debit.RelatedTransfers.Add(t))
    debit.Amount = transfers.Sum(Function(t) t.Amount)
    debit.Splits.FirstOrDefault(Function(s) s.Kind = TransactionSplitKind.Unapplied).Amount = debit.Amount
    tm.ApplyChanges("Original", debit)

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

Re: Disburse Transferred Funds

Post by sindrapal » Thu Jul 09, 2015 9:58 am

chk.Status = TransactionStatus.Pending

You need to set the status of the Check to Posted. Also set the Reference Number if a check printing manager is not hooked up to your trust account.

tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Disburse Transferred Funds

Post by tmeisinger » Thu Jul 09, 2015 10:21 am

So there is no way to set the Check to Pending and have Accounting actually go in and Print and Post the Check?

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

Re: Disburse Transferred Funds

Post by sindrapal » Thu Jul 09, 2015 10:36 am

Not in this scenario. Because you are disbursing ledger transfers, the disbursement's status must be Posted. You can create pending checks via the API but cannot use them to disburse transfers.

Post Reply