Monitoring for last transaction to be disbursed

Discussions related to custom development with Select.
Post Reply
kwesterlage
Posts: 73
Joined: Thu May 21, 2015 2:28 pm

Monitoring for last transaction to be disbursed

Post by kwesterlage »

When the last transaction for an order is disbursed we need to prompt the user and ask if they want to generate and attach a report.
We tried to implement this using the transaction-changed events. The behavior of the checks when being disbursed together is preventing us from reliably identifying the final disbursement.

Each time a LTO is posted, the ledger balance is adjusted and a "changed" event is fired.
But when posting the checks, the "changed" events are all fired together, after all of the transactions have been posted.
This behavior means that for each check-posted event, e.Transaction.Ledger.Balance will be the same (on a balanced order, 0.00).

Two Questions:
1.) What is a good alternative method to know when the last transaction has been disbursed and the ledger is balanced (excluding held/voided/deleted transactions)?
2.) Are the "changed" events supposed to behave differently for different types of transactions?
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Monitoring for last transaction to be disbursed

Post by BobRichards »

Sorry that we are taking a while to answer your question. However, I want you to know that a developer has been assigned to look into this and you have not been forgotten.
Bob Richards, Senior Software Developer, SoftPro
neetab
Posts: 22
Joined: Wed Apr 17, 2013 3:20 pm

Re: Monitoring for last transaction to be disbursed

Post by neetab »

1.) What is a good alternative method to know when the last transaction has been disbursed and the ledger is balanced (excluding held/voided/deleted transactions)?

When posting checks the transaction changed event is fired one after the other, so you should still be able to use this event to check the ledger balance.

2.) Are the "changed" events supposed to behave differently for different types of transactions?

No, The changed events are not transaction type specific.
kwesterlage
Posts: 73
Joined: Thu May 21, 2015 2:28 pm

Re: Monitoring for last transaction to be disbursed

Post by kwesterlage »

The changed events are fired one after another, but there is no way to determine the last one without looking at the ledger balance.
The problem is, the actual ledger balance is adjusted for ALL checks before ANY of the check changed events are fired.

I used the code below to batch-disburse four $25 checks using the "Print/Post Pending Disbursements" option, before the disbursement my ledger balance was $100.

Code: Select all

public void OnChange(object sender, TransactionInfoEventArgs e)
        {
            ILedgersManager lm = _select.GetService<ILedgersManager>();
            ITransactionsManager tm = _select.GetService<ITransactionsManager>();

            ILedger ledger = lm.GetLedger(e.Transaction.Ledger);

            var actualLedgerBalance = ledger.ToInfo().Balance;
            var transactionLedgerBalance = e.Transaction.Ledger.Balance;
        }
An event is fired for each of the four checks and for each event the values are the same:
actualLedgerBalance = 0.00
transactionLedgerBalance = 100.00
neetab
Posts: 22
Joined: Wed Apr 17, 2013 3:20 pm

Re: Monitoring for last transaction to be disbursed

Post by neetab »

You will not be able to determine the last one just by looking at the ledger balance.
You will still need to hook into the Changed events, but you need to load all the transaction infos for the given ledger to determine if all transactions have been posted/voided/deleted and if the ledger balance is zero.
Post Reply