Matt Carter
05/02/2022, 3:39 PMMatt Carter
05/02/2022, 4:15 PMjen
05/02/2022, 4:29 PMjen
05/02/2022, 4:29 PMjen
05/02/2022, 4:29 PMjen
05/02/2022, 4:30 PM<#if record.apply?has_content><apply>[<#list record.apply as apply>{"due":"${apply.due}","currency":"${apply.currency}","applydate":"${apply.applydate}","disc":"${apply.disc}","internalid":"${apply.internalid}","total":"${apply.total}","amount":"${apply.amount}","refnum":"${apply.refnum}"}<#if !apply?is_last>,</#if></#list>]</apply></#if>
<#if record.credit?has_content><credit>[<#list record.credit as credit>{"currency":"${credit.currency}","creditdate":"${credit.creditdate}","appliedto":"${credit.appliedto}","internalid":"${credit.internalid}","amount":"${credit.amount}","type":"${credit.type}","refnum":"${credit.refnum}"}<#if !credit?is_last>,</#if></#list>]</credit></#if>
jen
05/02/2022, 4:30 PMjen
05/02/2022, 4:30 PM// Start by gathering all the data we will display.
// Get the XML template results, which will give us the payment & credit data.
var templated_xml = render.transaction({
entityId: parseInt(payment_id),
formId: 270,
printMode: render.PrintMode.HTML
});
var xml = templated_xml.getContents();
var applied_to = [];
var credits = [];
// Is there anything in the <apply>?
var apply_xml_start = xml.indexOf('<apply>');
var apply_xml_end = xml.indexOf('</apply>');
if(apply_xml_start !== -1 && apply_xml_end !== -1) {
var apply_xml = xml.substring(apply_xml_start + 7, apply_xml_end);
applied_to = JSON.parse(apply_xml);
}
// Is there anything in the <credit>?
var credit_xml_start = xml.indexOf('<credit>');
var credit_xml_end = xml.indexOf('</credit>');
if(credit_xml_start !== -1 && credit_xml_end !== -1) {
var credit_xml = xml.substring(credit_xml_start + 8, credit_xml_end);
credits = JSON.parse(credit_xml);
}
Matt Carter
05/02/2022, 4:38 PMShawn Talbert
05/02/2022, 4:38 PMjen
05/02/2022, 4:40 PMmattdahse
05/02/2022, 7:05 PMjen
05/02/2022, 8:23 PMjen
05/02/2022, 8:24 PMShawn Talbert
05/02/2022, 11:33 PMbattk
05/03/2022, 1:24 AMbattk
05/03/2022, 1:24 AMbattk
05/03/2022, 1:27 AMbattk
05/03/2022, 1:28 AMbattk
05/03/2022, 1:32 AMbattk
05/03/2022, 1:33 AMjen
05/03/2022, 3:32 PMso to get from payment to related credits, you have to search/query the related credits from the bill, which could be inaccurate if you have multiple payments that applied credits to the same bill
jen
05/03/2022, 3:32 PMjen
05/03/2022, 3:33 PMjen
05/03/2022, 3:33 PM