Skip to main content

Tax Information Details

{% include 'Custom Integration - Header' %}
{% if DocumentsProvisioned %}

{% fetchxml recordContact %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="tt_taxreturn">
<attribute name="tt_name" />
<attribute name="tt_contactid" />
<attribute name="tt_taxreturnid" />
<order attribute="tt_name" descending="false" />
<filter type="and">
<condition attribute="tt_taxreturnid" operator="eq" uitype="tt_taxreturn" value="{{ TaxReturnID }}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}

{% if recordContact.results.entities.size >= 1 %}
{% assign contact = recordContact.results.entities[0].tt_contactid.id %}
{% endif %}

{% fetchxml contactDocuments %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="tt_contactdocuments">
<attribute name='tt_contactdocumentsid' />
<attribute name='tt_name' />
<attribute name='createdon' />
<attribute name='tt_serviceline' />
<order attribute="tt_name" descending="false" />
<filter type="and">
<condition attribute="tt_uktaxreturn" operator="eq" uitype="tt_taxreturn" value="{{ TaxReturnID }}" />
</filter>
<link-entity name="sharepointdocumentlocation" from="regardingobjectid" to="tt_contactdocumentsid" link-type="inner" alias="aa" />
</entity>
</fetch>
{% endfetchxml %}

{% assign documentSections = "" %}

{% if contactDocuments.results.entities.size >= 1 %}
{% assign records = contactDocuments.results.entities.size | minus: 1 %}
{% for i in (0...records) %}
{% assign contactDocumentName = contactDocuments.results.entities[i].tt_name %}

{% unless documentSections contains contactDocumentName %}
{% assign documentSections = documentSections | append:',' | append: contactDocumentName %}

{% assign contactDocumentRecord = contactDocuments.results.entities[i].tt_contactdocumentsid %}
{% assign contactDocumentServiceLine = contactDocuments.results.entities[i].tt_serviceline.label %}

{% assign RecordToGetSharePointDetails = contactDocumentRecord %}
{% assign EntityLogicalName = "tt_contactdocuments" %}
{% assign EnableUpload = true %}
{% assign EnableDeletion = true %}
{% assign EnableCollaboration = false %}
{% assign sectionName = contactDocumentName %}

{% assign serviceLine = "UK Tax" %}

{% include 'Utility/GetSharePointDetails' %}
{% include 'Custom Integration - Main' %}

<script>
var sectionName = "{{ sectionName }}";
// Get the div with the id matching sectionName
var documentSectionDiv = $(`.contactDocumentLocation[id="${sectionName}"]`);
// Select the h2 element with the specified section name
var sectionHeader = $('.tab-title').filter(function() {
var text = $(this).text().trim().replace(/[&/.?%]/g, '-');
return text === sectionName;
});

// Get the next sibling element (the div)
var sectionDiv = sectionHeader.next();
// Find the table within sectionDiv
var sectionTables = sectionDiv.find('table');
var sectionRows = sectionTables.find('tr');

// Find the first table with a data-name like "section*Empty"
var targetTable = sectionTables.filter(function () {
var dataName = $(this).attr('data-name');
return dataName && /^section.*Empty$/.test(dataName);
}).first();

// Check if there are at least two tables
if (targetTable.length > 0) {
// Get the penultimate table
var emptyRow = targetTable.find('tr').last();
// Insert the documentSectionDiv after the empty row
documentSectionDiv.insertAfter(emptyRow);
} else {
// If there are fewer than two tables, just append documentSectionDiv at the end of sectionDiv
sectionDiv.append(documentSectionDiv);
}
$(`.contactDocumentLocation[id="${sectionName}"]`).attr("style", "padding:10px");
$(`.contactDocumentLocation[id="${sectionName}"]`).find('h1').text(`Documents`);
$(`.contactDocumentLocation[id="${sectionName}"]`).find('h1').append(`<h5>{{ snippets['PracticeGateway/UKTR/Documents/Label'] }}</h5>`);
//$(`.contactDocumentLocation[id="${sectionName}"]`).hide();
</script>
{% endunless %}
{% endfor %}
{% endif %}

{% if isDocumentsOnly == true %}
<script>
$('div.contactDocumentLocation[id="UK Interest"]').hide()
$('div.contactDocumentLocation[id="Pension Contributions"]').hide()
$('div.contactDocumentLocation[id="UK Dividends"]').hide()
$('div.contactDocumentLocation[id="Employments"]').hide()
$('div.contactDocumentLocation[id="Gift Aid"]').hide()
$('div.contactDocumentLocation[id="Pension Income"]').hide()
$('div.contactDocumentLocation[id="Child Benefit"]').hide()
$('div.contactDocumentLocation[id="State Pensions and Benefits"]').hide()
$('div.contactDocumentLocation[id="UK Property Income"]').hide()
$('div.contactDocumentLocation[id="Capital Gains"]').hide()
$('div.contactDocumentLocation[id="Self Employment"]').hide()
$('div.contactDocumentLocation[id="Foreign Income"]').hide()
$('div.contactDocumentLocation[id="Tax Reliefs"]').hide()
$('div.contactDocumentLocation[id="Other Income"]').hide()
$('div.contactDocumentLocation[id="Repayment and Other Details"]').hide()
$('div.contactDocumentLocation[id="Other Details"]').hide()
$('div.contactDocumentLocation[id="Travel Calendar"]').hide()
$('div.contactDocumentLocation[id="UK Departures"]').hide()
$('div.contactDocumentLocation[id="UK Arrivals"]').hide()
$('div.contactDocumentLocation[id="Domicile and Remittances - UK Arrivals"]').hide()
$('div.contactDocumentLocation[id="Seafarer"]').hide()
</script>
{% endif %}
{% endif %}
{% assign CRMPortalContact = false %}

{% fetchxml CRMPortalContacts %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact">
<attribute name="fullname" />
<attribute name="emailaddress1" />
<attribute name="tt_clientcode" />
<attribute name="tt_managername" />
<attribute name="ownerid" />
<attribute name="contactid" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="contactid" operator="eq" uitype="contact" value="{{ contact }}" />
</filter>
<link-entity name="sharepointdocumentlocation" from="regardingobjectid" to="contactid" link-type="inner" alias="ag">
<link-entity name="sharepointdocumentlocation" from="sharepointdocumentlocationid" to="parentsiteorlocation" link-type="inner" alias="ah">
<link-entity name="sharepointsite" from="sharepointsiteid" to="parentsiteorlocation" link-type="inner" alias="ai">
<filter type="and">
<condition attribute="isdefault" operator="eq" value="1" />
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}

{% if CRMPortalContacts.results.entities.size >= 1 %}
{% assign CRMPortalContact = true %}
{% endif %}
{% if CRMPortalContact == true %}
<script>
$('div.contactDocumentLocation').hide()

var sectionName = "Other Documents";
// Get the div with the id matching sectionName
var documentSectionDiv = $(`div#maintenance-image`);
// Select the h2 element with the specified section name
var sectionHeader = $('.tab-title').filter(function() {
var text = $(this).text().trim().replace(/[&/.?%]/g, '-');
return text === sectionName;
});

// Get the next sibling element (the div)
var sectionDiv = sectionHeader.next();
// Find the table within sectionDiv
sectionDiv.append(documentSectionDiv);
$('div#maintenance-image').show()

</script>
{% endif %}
<script>
var CRMPortalContact = '{{ CRMPortalContact }}';
console.log(`CRMPortalContact : ${CRMPortalContact}`)
if(CRMPortalContact == "true") {
$('#subgridDocuments').closest('tr').show();
}
else {
$('#subgridDocuments').closest('tr').hide();
}
</script>