Open nonprofittechy opened 1 month ago
The approach I'm using for this was to loop through the gathered list after the first element and enable the attachment(s) into a bundle:
objects:
- employment[i].additional_employment: ALDocument.using(title="FA Additional Employment Business", filename="fa_additional_employment_business.pdf", has_addendum=False)
---
objects:
- additional_employment_bundle: ALDocumentBundle.using(elements=[], title= "FA Additional Employment Bundle", filename="fa_additional_employment_business.pdf", has_addendum=False)
---
reconsider: True
code: |
employment_to_bundle = []
additional_employment_bundle.enabled = False
for index, el in enumerate(employment):
# No need for additional employment or business income unless employment.number_gathered() >= 1
if index == 0:
el.additional_employment.enabled = False
else:
el.additional_employment.enabled = True
additional_employment_bundle.enabled = True
employment_to_bundle.append(el.additional_employment)
additional_employment_bundle.elements = employment_to_bundle
complete_additional_employment = True
---
attachment:
variable name: employment[i].additional_employment[j]
name: additional_employment
filename: additional_employment
skip undefined: True
editable: False
pdf template file: fa_additional_employment_business.pdf
fields:
- "county": ${ case_county }
- "case_number": ${ case_number }
...
- "employed_yes": ${ employment[i].type == 'employed' }
...
ALDocumentBundle envisions a static cap on the number of documents you produce, but something, this number is dynamic.
For example: in Illinois, if you have multiple jobs, each job needs to recorded on a separate PDF document with a fixed format. The number of documents you produce is contingent on the number of jobs and there is no cap.
reconsider
or perhapson update
block to handle refreshing the bundle's contents when the list changes.I'm not sure yet what affordance makes sense. People can handle this manually with Python code, but a simpler API for common use cases would be helpful.