Page 1 of 1

Disburse Transferred Funds

Posted: Wed Jun 24, 2015 3:58 pm
by tmeisinger
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?

Re: Disburse Transferred Funds

Posted: Thu Jun 25, 2015 10:52 am
by sindrapal
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);

Re: Disburse Transferred Funds

Posted: Fri Jun 26, 2015 7:51 am
by tmeisinger
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.

Re: Disburse Transferred Funds

Posted: Thu Jul 09, 2015 9:08 am
by tmeisinger
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)

Re: Disburse Transferred Funds

Posted: Thu Jul 09, 2015 9:58 am
by sindrapal
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.

Re: Disburse Transferred Funds

Posted: Thu Jul 09, 2015 10:21 am
by tmeisinger
So there is no way to set the Check to Pending and have Accounting actually go in and Print and Post the Check?

Re: Disburse Transferred Funds

Posted: Thu Jul 09, 2015 10:36 am
by sindrapal
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.