Skip to content

Commit b595fae

Browse files
add dynamic table to document generation (#147)
1 parent e0ba4ca commit b595fae

File tree

5 files changed

+56
-10
lines changed

5 files changed

+56
-10
lines changed

app/ds_config_sample.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"doc_terms_pdf": "Term_Of_Service.pdf",
3030
"doc_txt": "Welcome.txt",
3131
"doc_offer_letter": "Offer_Letter_Demo.docx",
32+
"doc_dynamic_table": "Offer_Letter_Dynamic_Table.docx",
3233
# Payment gateway information is optional
3334
"gateway_account_id": "{DS_PAYMENT_GATEWAY_ID}",
3435
"gateway_name": "stripe",

app/eSignature/examples/eg042_document_generation.py

+47-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from os import path
44
from docusign_esign import EnvelopesApi, TemplatesApi, EnvelopeDefinition, Document, Signer, SignHere, \
55
DateSigned, Tabs, Recipients, DocGenFormField, EnvelopeTemplate, TemplateRole, DocGenFormFields, \
6-
DocGenFormFieldRequest, Envelope
6+
DocGenFormFieldRequest, Envelope, DocGenFormFieldRowValue
77

88
from ...consts import demo_docs_path, pattern
99
from ...ds_config import DS_CONFIG
@@ -20,8 +20,9 @@ def get_args():
2020
"manager_name": pattern.sub("", request.form.get("manager_name")),
2121
"job_title": pattern.sub("", request.form.get("job_title")),
2222
"salary": pattern.sub("", request.form.get("salary")),
23+
"rsus": pattern.sub("", request.form.get("rsus")),
2324
"start_date": pattern.sub("", request.form.get("start_date")),
24-
"doc_file": path.join(demo_docs_path, DS_CONFIG["doc_offer_letter"])
25+
"doc_file": path.join(demo_docs_path, DS_CONFIG["doc_dynamic_table"])
2526
}
2627
args = {
2728
"account_id": session["ds_account_id"],
@@ -164,7 +165,7 @@ def recipient_tabs(cls):
164165
anchor_y_offset="-22"
165166
)
166167
date_signed = DateSigned(
167-
anchor_string="Date",
168+
anchor_string="Date Signed",
168169
anchor_units="pixels",
169170
anchor_y_offset="-22"
170171
)
@@ -197,6 +198,7 @@ def make_envelope(cls, template_id, args):
197198
#ds-snippet-start:eSign42Step7
198199
@classmethod
199200
def form_fields(cls, args, document_id_guid):
201+
bonus_value = "20%"
200202
doc_gen_form_field_request = DocGenFormFieldRequest(
201203
doc_gen_form_fields=[
202204
DocGenFormFields(
@@ -214,13 +216,51 @@ def form_fields(cls, args, document_id_guid):
214216
name="Job_Title",
215217
value=args["job_title"]
216218
),
217-
DocGenFormField(
218-
name="Salary",
219-
value=args["salary"]
220-
),
221219
DocGenFormField(
222220
name="Start_Date",
223221
value=args["start_date"]
222+
),
223+
DocGenFormField(
224+
name="Compensation_Package",
225+
type="TableRow",
226+
row_values=[
227+
DocGenFormFieldRowValue(
228+
doc_gen_form_field_list=[
229+
DocGenFormField(
230+
name="Compensation_Component",
231+
value="Salary"
232+
),
233+
DocGenFormField(
234+
name="Details",
235+
value=f"${args['salary']}"
236+
)
237+
]
238+
),
239+
DocGenFormFieldRowValue(
240+
doc_gen_form_field_list=[
241+
DocGenFormField(
242+
name="Compensation_Component",
243+
value="Bonus"
244+
),
245+
DocGenFormField(
246+
name="Details",
247+
value=bonus_value
248+
)
249+
]
250+
),
251+
DocGenFormFieldRowValue(
252+
doc_gen_form_field_list=[
253+
DocGenFormField(
254+
name="Compensation_Component",
255+
value="RSUs"
256+
),
257+
DocGenFormField(
258+
name="Details",
259+
value=args["rsus"]
260+
)
261+
]
262+
)
263+
]
224264
)
225265
]
226266
)
Binary file not shown.

app/templates/eSignature/eg042_document_generation.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{% set job_title_index = 3 %}
1010
{% set salary_index = 4 %}
1111
{% set start_date_index = 5 %}
12+
{% set rsus_index = 6 %}
1213

1314
<form class="eg" action="" method="post" data-busy="form">
1415
{% if 'FormName' in example['Forms'][form_index] %}
@@ -36,15 +37,19 @@
3637
<label for="job_title">{{ example['Forms'][form_index]['Inputs'][job_title_index]['InputName'] }}</label>
3738
<select class="form-control" id="job_title" name="job_title">
3839
<option value="Software Engineer">Software Engineer</option>
39-
<option value="Product Manager">Product Manager</option>
40-
<option value="Sales Representative">Sales Representative</option>
40+
<option value="Account Executive">Account Executive</option>
4141
</select>
4242
</div>
4343
<div class="form-group">
4444
<label for="salary">{{ example['Forms'][form_index]['Inputs'][salary_index]['InputName'] }}</label>
4545
<input type="text" class="form-control" id="salary" placeholder="{{ example['Forms'][form_index]['Inputs'][salary_index]['InputPlaceholder'] }}" name="salary"
4646
required />
4747
</div>
48+
<div class="form-group">
49+
<label for="rsus">{{ example['Forms'][form_index]['Inputs'][rsus_index]['InputName'] }}</label>
50+
<input type="number" class="form-control" id="rsus" placeholder="{{ example['Forms'][form_index]['Inputs'][rsus_index]['InputPlaceholder'] }}" name="rsus"
51+
min="0" required />
52+
</div>
4853
<div class="form-group">
4954
<label for="start_date">{{ example['Forms'][form_index]['Inputs'][start_date_index]['InputName'] }}</label>
5055
<input type="date" class="form-control" id="start_date" placeholder="{{ example['Forms'][form_index]['Inputs'][start_date_index]['InputPlaceholder'] }}" name="start_date"

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cffi==1.15.1
44
chardet==5.1.0
55
Click
66
cryptography==39.0.0
7-
docusign-esign==3.24.0
7+
docusign-esign==3.26.0rc1
88
docusign-rooms==1.3.0
99
docusign-monitor==1.2.0
1010
docusign-click==1.4.0

0 commit comments

Comments
 (0)