Skip to content

Commit 49e1783

Browse files
DocGen example updates to use Dynamic Tables (#158)
* update doc gen example
1 parent 326b325 commit 49e1783

File tree

7 files changed

+59
-13
lines changed

7 files changed

+59
-13
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070

7171
gem 'docusign_admin', '~> 1.3.0'
7272
gem 'docusign_click', '~> 1.4.0'
73-
gem 'docusign_esign', '~> 3.25.0'
73+
gem 'docusign_esign', '~> 3.27.0.rc1'
7474
gem 'docusign_maestro', '~> 1.0.0.rc1'
7575
gem 'docusign_monitor', '~> 1.2.0'
7676
gem 'docusign_rooms', '~> 1.3.0'

Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ GEM
110110
json (~> 2.1, >= 2.1.0)
111111
jwt (~> 2.2, >= 2.2.1)
112112
typhoeus (~> 1.0, >= 1.0.1)
113-
docusign_esign (3.25.0)
113+
docusign_esign (3.27.0.rc1)
114114
addressable (~> 2.7, >= 2.7.0)
115115
json (~> 2.1, >= 2.1.0)
116116
jwt (~> 2.2, >= 2.2.1)
@@ -349,7 +349,7 @@ DEPENDENCIES
349349
coffee-rails (~> 5.0.0)
350350
docusign_admin (~> 1.3.0)
351351
docusign_click (~> 1.4.0)
352-
docusign_esign (~> 3.25.0)
352+
docusign_esign (~> 3.27.0.rc1)
353353
docusign_maestro (~> 1.0.0.rc1)
354354
docusign_monitor (~> 1.2.0)
355355
docusign_rooms (~> 1.3.0)

app/controllers/e_sign/eeg042_document_generation_controller.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ def create
1313
manager_name: param_gsub(params['manager_name']),
1414
job_title: param_gsub(params['job_title']),
1515
salary: param_gsub(params['salary']),
16+
rsus: param_gsub(params['rsus']),
1617
start_date: param_gsub(params['start_date']),
17-
doc_file: File.join('data', Rails.application.config.doc_offer_letter)
18+
doc_file: File.join('data', Rails.application.config.offer_letter_dynamic_table)
1819
}
1920
args = {
2021
account_id: session['ds_account_id'],

app/services/e_sign/eg042_document_generation_service.rb

+46-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def recipient_tabs
113113
anchorYOffset: '-22'
114114
)
115115
date_signed = DocuSign_eSign::DateSigned.new(
116-
anchorString: 'Date',
116+
anchorString: 'Date Signed',
117117
anchorUnits: 'pixels',
118118
anchorYOffset: '-22'
119119
)
@@ -144,6 +144,8 @@ def make_envelope(template_id, args)
144144

145145
#ds-snippet-start:eSign42Step7
146146
def form_fields(args, document_id_guid)
147+
bonus_value = '20%'
148+
147149
candidate_name_field = DocuSign_eSign::DocGenFormField.new(
148150
name: 'Candidate_Name',
149151
value: args[:candidate_name]
@@ -156,16 +158,54 @@ def form_fields(args, document_id_guid)
156158
name: 'Job_Title',
157159
value: args[:job_title]
158160
)
159-
salary_field = DocuSign_eSign::DocGenFormField.new(
160-
name: 'Salary',
161-
value: args[:salary]
162-
)
163161
start_date_field = DocuSign_eSign::DocGenFormField.new(
164162
name: 'Start_Date',
165163
value: args[:start_date]
166164
)
165+
166+
salary_row = DocuSign_eSign::DocGenFormFieldRowValue.new(
167+
docGenFormFieldList: [
168+
DocuSign_eSign::DocGenFormField.new(
169+
name: 'Compensation_Component',
170+
value: 'Salary'
171+
),
172+
DocuSign_eSign::DocGenFormField.new(
173+
name: 'Details',
174+
value: "$#{args[:salary]}"
175+
)
176+
]
177+
)
178+
bonus_row = DocuSign_eSign::DocGenFormFieldRowValue.new(
179+
docGenFormFieldList: [
180+
DocuSign_eSign::DocGenFormField.new(
181+
name: 'Compensation_Component',
182+
value: 'Bonus'
183+
),
184+
DocuSign_eSign::DocGenFormField.new(
185+
name: 'Details',
186+
value: bonus_value
187+
)
188+
]
189+
)
190+
rsus_row = DocuSign_eSign::DocGenFormFieldRowValue.new(
191+
docGenFormFieldList: [
192+
DocuSign_eSign::DocGenFormField.new(
193+
name: 'Compensation_Component',
194+
value: 'RSUs'
195+
),
196+
DocuSign_eSign::DocGenFormField.new(
197+
name: 'Details',
198+
value: args[:rsus]
199+
)
200+
]
201+
)
202+
compensation_package = DocuSign_eSign::DocGenFormField.new(
203+
name: 'Compensation_Package',
204+
type: 'TableRow',
205+
rowValues: [salary_row, bonus_row, rsus_row]
206+
)
167207
doc_gen_form_fields_list = [
168-
candidate_name_field, manager_name_field, salary_field, job_title_field, start_date_field
208+
candidate_name_field, manager_name_field, job_title_field, start_date_field, compensation_package
169209
]
170210

171211
doc_gen_form_fields = DocuSign_eSign::DocGenFormFields.new(

app/views/e_sign/eeg042_document_generation/get.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<% job_title_index = 3 %>
88
<% salary_index = 4 %>
99
<% start_date_index = 5 %>
10+
<% rsus_index = 6 %>
1011

1112
<form class="eg" action="" method="post" data-busy="form">
1213
<% if @example["Forms"][form_index]["FormName"] %>
@@ -34,15 +35,19 @@
3435
<label for="job_title"><%= @example['Forms'][form_index]['Inputs'][job_title_index]['InputName'] %></label>
3536
<select class="form-control" id="job_title" name="job_title">
3637
<option value="Software Engineer">Software Engineer</option>
37-
<option value="Product Manager">Product Manager</option>
38-
<option value="Sales Representative">Sales Representative</option>
38+
<option value="Account Executive">Account Executive</option>
3939
</select>
4040
</div>
4141
<div class="form-group">
4242
<label for="salary"><%= @example['Forms'][form_index]['Inputs'][salary_index]['InputName'] %></label>
4343
<input type="text" class="form-control" id="salary" placeholder="<%= @example['Forms'][form_index]['Inputs'][salary_index]['InputPlaceholder'] %>" name="salary"
4444
required />
4545
</div>
46+
<div class="form-group">
47+
<label for="rsus"><%= @example['Forms'][form_index]['Inputs'][rsus_index]['InputName'] %></label>
48+
<input type="number" class="form-control" id="rsus" placeholder="<%= @example['Forms'][form_index]['Inputs'][rsus_index]['InputPlaceholder'] %>" name="rsus"
49+
min="0" required />
50+
</div>
4651
<div class="form-group">
4752
<label for="start_date"><%= @example['Forms'][form_index]['Inputs'][start_date_index]['InputName'] %></label>
4853
<input type="date" class="form-control" id="start_date" placeholder="<%= @example['Forms'][form_index]['Inputs'][start_date_index]['InputPlaceholder'] %>" name="start_date"

config/appsettings.example.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ default: &default
3535
doc_docx: World_Wide_Corp_Battle_Plan_Trafalgar.docx
3636
doc_pdf: World_Wide_Corp_lorem.pdf
3737
doc_terms_pdf: Term_Of_Service.pdf
38-
doc_offer_letter: Offer_Letter_Demo.docx
38+
offer_letter_dynamic_table: Offer_Letter_Dynamic_Table.docx
3939
web_form_template_file: World_Wide_Corp_Form.pdf
4040
web_form_config_file: web-form-config.json
4141
gateway_name: "stripe"

data/Offer_Letter_Dynamic_Table.docx

35.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)