Auto Close Online Bundles

This script is intended to run daily and will close the Online bundle from the specified number of days ago. It will total the contributions in the bundle and enter that total in the Total Check field. Then, if all entries have been assigned to a donor, will close the bundle.

Important

This script will close only the first found Online bundle for any given day. If you have multiple Online bundles created on the same day (e.g., because some have been created manually), you will need to close the others manually.

Configure the Script

To set this up, complete the following steps:

Step 1
Copy the python script below to a special content Python file. We recommend you name it AutoCloseOnlineBundles.
Step 2

Add the following line to your MorningBatch file:

model.CallScript("AutoCloseOnlineBundles")
Step 3
Make sure that the setting Run Morning Batch is enabled. This setting is on the System tab of Settings, in the Administration section.

Code for the AutoCloseOnlineBundles Script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import datetime

offset = -2  # will close the bundle from this many days ago

dt = datetime.date.today() + datetime.timedelta(days=offset)

bh = model.FindBundleHeader(dt, 'Online')
if bh is not None:
    if bh.BundleStatusId != 0:
        model.FinishBundle(bh)
        model.CloseBundle(bh)

Customize the Script

By default, the script is configured to close the Online bundle created two days ago. The bundles for today and yesterday will remain open. This is defined in line 3 as the variable offset. You can adjust this as desired, but the offset should never be set to 0 (zero)