Skip to content

Commit

Permalink
add dynamic table to document generation (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanBachaloSigmaSoftware authored Apr 12, 2024
1 parent e0ba4ca commit b595fae
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/ds_config_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"doc_terms_pdf": "Term_Of_Service.pdf",
"doc_txt": "Welcome.txt",
"doc_offer_letter": "Offer_Letter_Demo.docx",
"doc_dynamic_table": "Offer_Letter_Dynamic_Table.docx",
# Payment gateway information is optional
"gateway_account_id": "{DS_PAYMENT_GATEWAY_ID}",
"gateway_name": "stripe",
Expand Down
54 changes: 47 additions & 7 deletions app/eSignature/examples/eg042_document_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from os import path
from docusign_esign import EnvelopesApi, TemplatesApi, EnvelopeDefinition, Document, Signer, SignHere, \
DateSigned, Tabs, Recipients, DocGenFormField, EnvelopeTemplate, TemplateRole, DocGenFormFields, \
DocGenFormFieldRequest, Envelope
DocGenFormFieldRequest, Envelope, DocGenFormFieldRowValue

from ...consts import demo_docs_path, pattern
from ...ds_config import DS_CONFIG
Expand All @@ -20,8 +20,9 @@ def get_args():
"manager_name": pattern.sub("", request.form.get("manager_name")),
"job_title": pattern.sub("", request.form.get("job_title")),
"salary": pattern.sub("", request.form.get("salary")),
"rsus": pattern.sub("", request.form.get("rsus")),
"start_date": pattern.sub("", request.form.get("start_date")),
"doc_file": path.join(demo_docs_path, DS_CONFIG["doc_offer_letter"])
"doc_file": path.join(demo_docs_path, DS_CONFIG["doc_dynamic_table"])
}
args = {
"account_id": session["ds_account_id"],
Expand Down Expand Up @@ -164,7 +165,7 @@ def recipient_tabs(cls):
anchor_y_offset="-22"
)
date_signed = DateSigned(
anchor_string="Date",
anchor_string="Date Signed",
anchor_units="pixels",
anchor_y_offset="-22"
)
Expand Down Expand Up @@ -197,6 +198,7 @@ def make_envelope(cls, template_id, args):
#ds-snippet-start:eSign42Step7
@classmethod
def form_fields(cls, args, document_id_guid):
bonus_value = "20%"
doc_gen_form_field_request = DocGenFormFieldRequest(
doc_gen_form_fields=[
DocGenFormFields(
Expand All @@ -214,13 +216,51 @@ def form_fields(cls, args, document_id_guid):
name="Job_Title",
value=args["job_title"]
),
DocGenFormField(
name="Salary",
value=args["salary"]
),
DocGenFormField(
name="Start_Date",
value=args["start_date"]
),
DocGenFormField(
name="Compensation_Package",
type="TableRow",
row_values=[
DocGenFormFieldRowValue(
doc_gen_form_field_list=[
DocGenFormField(
name="Compensation_Component",
value="Salary"
),
DocGenFormField(
name="Details",
value=f"${args['salary']}"
)
]
),
DocGenFormFieldRowValue(
doc_gen_form_field_list=[
DocGenFormField(
name="Compensation_Component",
value="Bonus"
),
DocGenFormField(
name="Details",
value=bonus_value
)
]
),
DocGenFormFieldRowValue(
doc_gen_form_field_list=[
DocGenFormField(
name="Compensation_Component",
value="RSUs"
),
DocGenFormField(
name="Details",
value=args["rsus"]
)
]
)
]
)
]
)
Expand Down
Binary file not shown.
9 changes: 7 additions & 2 deletions app/templates/eSignature/eg042_document_generation.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{% set job_title_index = 3 %}
{% set salary_index = 4 %}
{% set start_date_index = 5 %}
{% set rsus_index = 6 %}

<form class="eg" action="" method="post" data-busy="form">
{% if 'FormName' in example['Forms'][form_index] %}
Expand Down Expand Up @@ -36,15 +37,19 @@
<label for="job_title">{{ example['Forms'][form_index]['Inputs'][job_title_index]['InputName'] }}</label>
<select class="form-control" id="job_title" name="job_title">
<option value="Software Engineer">Software Engineer</option>
<option value="Product Manager">Product Manager</option>
<option value="Sales Representative">Sales Representative</option>
<option value="Account Executive">Account Executive</option>
</select>
</div>
<div class="form-group">
<label for="salary">{{ example['Forms'][form_index]['Inputs'][salary_index]['InputName'] }}</label>
<input type="text" class="form-control" id="salary" placeholder="{{ example['Forms'][form_index]['Inputs'][salary_index]['InputPlaceholder'] }}" name="salary"
required />
</div>
<div class="form-group">
<label for="rsus">{{ example['Forms'][form_index]['Inputs'][rsus_index]['InputName'] }}</label>
<input type="number" class="form-control" id="rsus" placeholder="{{ example['Forms'][form_index]['Inputs'][rsus_index]['InputPlaceholder'] }}" name="rsus"
min="0" required />
</div>
<div class="form-group">
<label for="start_date">{{ example['Forms'][form_index]['Inputs'][start_date_index]['InputName'] }}</label>
<input type="date" class="form-control" id="start_date" placeholder="{{ example['Forms'][form_index]['Inputs'][start_date_index]['InputPlaceholder'] }}" name="start_date"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cffi==1.15.1
chardet==5.1.0
Click
cryptography==39.0.0
docusign-esign==3.24.0
docusign-esign==3.26.0rc1
docusign-rooms==1.3.0
docusign-monitor==1.2.0
docusign-click==1.4.0
Expand Down

0 comments on commit b595fae

Please sign in to comment.