show amendment page in PDF contract
This commit is contained in:
19
app/views/contracts/_amendment_page.html.erb
Normal file
19
app/views/contracts/_amendment_page.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<% if preview %>
|
||||
<h1>PREVIEW ONLY</h1>
|
||||
<% end %>
|
||||
|
||||
<p class="heading"><strong><u><%= t '.heading' %></u></strong></p>
|
||||
|
||||
<dl>
|
||||
<%= description_list_pair "#{t('.description_labels.amendment_clause')}:", releasable.contract_template.amendment_clause %>
|
||||
<%= description_list_pair "#{t('.description_labels.amendment_signer_name')}:", releasable.amendment_signer_name %>
|
||||
|
||||
<dt><%= t('.description_labels.amendment_signature') %>:</dt>
|
||||
<dd>
|
||||
<% if preview %>
|
||||
<%= image_tag dummy_signature %>
|
||||
<% elsif releasable.amendment_signature.attached? %>
|
||||
<%= image_tag releasable.amendment_signature.variant(auto_orient: true, resize: "200x200") %>
|
||||
<% end %>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -26,6 +26,12 @@
|
||||
<%= render "contracts/signature_page", releasable: releasable, contract_template: contract_template, preview: preview %>
|
||||
</div>
|
||||
|
||||
<% if releasable.respond_to?(:amendment_signed?) && releasable.amendment_signed? %>
|
||||
<div class="page">
|
||||
<%= render "contracts/amendment_page", releasable: releasable, preview: preview %>
|
||||
</div>
|
||||
<%end %>
|
||||
|
||||
<% if releasable.respond_to?(:approved?) && releasable.approved? %>
|
||||
<div class="page">
|
||||
<%= render "contracts/for_office_use_only", releasable: releasable, preview: preview %>
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
<i class="fa fa-check-square-o text-dark"
|
||||
data-toggle="tooltip"
|
||||
title="<%= t '.messages.amendment_signed_tooltip' %>"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-square-o"></i>
|
||||
<% elsif location_release.amendment_signable? %>
|
||||
<i class="fa fa-square-o"
|
||||
data-toggle="tooltip"
|
||||
title="<%= t '.messages.amendment_not_signed_tooltip' %>"></i>
|
||||
<% end %>
|
||||
</td>
|
||||
|
||||
|
||||
@@ -323,6 +323,12 @@ en:
|
||||
update:
|
||||
notice: The release template has been updated
|
||||
contracts:
|
||||
amendment_page:
|
||||
description_labels:
|
||||
amendment_clause: Amendment Clause
|
||||
amendment_signature: Amendment Signature
|
||||
amendment_signer_name: Amendment Signer Name
|
||||
heading: Amendment
|
||||
for_office_use_only:
|
||||
description_labels:
|
||||
date_issued: Date Issued
|
||||
@@ -783,6 +789,7 @@ en:
|
||||
review: Review
|
||||
sign_amendment: Sign Amendment
|
||||
messages:
|
||||
amendment_not_signed_tooltip: Amendment not yet signed
|
||||
amendment_signed_tooltip: Amendment Signed
|
||||
approved_tooltip: Approved by %{user} on %{timestamp}
|
||||
no_photos: Needs Photo
|
||||
|
||||
@@ -148,6 +148,12 @@ es:
|
||||
update:
|
||||
notice: The release template has been updated (ES)
|
||||
contracts:
|
||||
amendment_page:
|
||||
description_labels:
|
||||
amendment_clause: Amendment Clause (ES)
|
||||
amendment_signature: Amendment Signature (ES)
|
||||
amendment_signer_name: Amendment Signer Name (ES)
|
||||
heading: Amendment (ES)
|
||||
for_office_use_only:
|
||||
description_labels:
|
||||
date_issued: Date Issued (ES)
|
||||
@@ -343,6 +349,7 @@ es:
|
||||
actions:
|
||||
sign_amendment: Sign Amendment (ES)
|
||||
messages:
|
||||
amendment_not_signed_tooltip: Amendment not yet signed (ES)
|
||||
amendment_signed_tooltip: Amendment Signed (ES)
|
||||
material_releases:
|
||||
form:
|
||||
|
||||
@@ -301,7 +301,7 @@ feature "User managing location releases" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF" do
|
||||
scenario "viewing the contract PDF when amendment is not yet signed" do
|
||||
location_release = create(:location_release_with_contract_template_and_photo,
|
||||
:native,
|
||||
project: project,
|
||||
@@ -313,16 +313,13 @@ feature "User managing location releases" do
|
||||
content: "Note 1",
|
||||
user: build(:user, email: "jane.doe@test.com"),
|
||||
email: "jane.doe@test.com",
|
||||
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),
|
||||
),
|
||||
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),),
|
||||
build(:note,
|
||||
content: "Note 2",
|
||||
user: build(:user, email: "john.doe@test.com"),
|
||||
email: "john.doe@test.com",
|
||||
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),
|
||||
),
|
||||
]
|
||||
)
|
||||
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),),
|
||||
])
|
||||
|
||||
sign_in(current_user)
|
||||
visit project_location_releases_path(project)
|
||||
@@ -331,6 +328,8 @@ feature "User managing location releases" do
|
||||
expect(content_type).to eq("application/pdf")
|
||||
expect(content_disposition).to include("inline")
|
||||
expect(pdf_filename).to include("benny-s-burritos")
|
||||
|
||||
expect(pdf_body).not_to have_content amendment_page_heading
|
||||
expect(pdf_body).to have_content("Benny's Burritos")
|
||||
expect(pdf_body).to have_content("NOTES")
|
||||
expect(pdf_body).to have_content("Note 1")
|
||||
@@ -347,6 +346,34 @@ feature "User managing location releases" do
|
||||
expect(pdf_body).to have_content("06:00 - 20:00")
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF when amendment is signed" do
|
||||
contract_template = create(:location_release_contract_template, :with_amendment_clause, project: project)
|
||||
location_release = create(:location_release,
|
||||
:amendment_signed,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
name: "Test Loc")
|
||||
|
||||
sign_in(current_user)
|
||||
visit project_location_releases_path(project)
|
||||
click_link *view_release_pdf_link_for(location_release)
|
||||
|
||||
expect(content_type).to eq("application/pdf")
|
||||
expect(content_disposition).to include("inline")
|
||||
expect(pdf_filename).to include("test-loc")
|
||||
|
||||
expect(pdf_body).to have_content("Test Loc")
|
||||
|
||||
expect(pdf_body).to have_content amendment_page_heading
|
||||
expect(pdf_body).to have_content amendment_clause_label
|
||||
expect(pdf_body).to have_content amendment_signer_name_label
|
||||
expect(pdf_body).to have_content amendment_signature_label
|
||||
|
||||
expect(pdf_body).to have_content contract_template.amendment_clause.to_plain_text
|
||||
expect(pdf_body).to have_content location_release.amendment_signer_name
|
||||
end
|
||||
|
||||
context "when the user is account manager" do
|
||||
let(:current_user) { create(:user, :account_manager) }
|
||||
|
||||
@@ -686,4 +713,20 @@ feature "User managing location releases" do
|
||||
def copy_url_button
|
||||
t 'public.amendments.new.copy_url'
|
||||
end
|
||||
|
||||
def amendment_page_heading
|
||||
t 'contracts.amendment_page.heading'
|
||||
end
|
||||
|
||||
def amendment_signer_name_label
|
||||
t 'contracts.amendment_page.description_labels.amendment_signer_name'
|
||||
end
|
||||
|
||||
def amendment_clause_label
|
||||
t 'contracts.amendment_page.description_labels.amendment_clause'
|
||||
end
|
||||
|
||||
def amendment_signature_label
|
||||
t 'contracts.amendment_page.description_labels.amendment_signature'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user