首页 > 解决方案 > 使用 Netsuite 高级 PDF/HTML 模板进行条件打印(零值)

问题描述

我继承了一个自定义的 NetSuite 高级 PDF/HTML 模板,这是我们大多数发票的主要默认设置。

我们希望在价值为 0.00 美元时不打印费用行。在线搜索和 Stack Overflow 都没有提供明确的方向。看来#if/#else 可能是解决方案,但我不清楚如何集成到现有代码中。我有一些 HTML/CSS 经验,但对 Freemarker 很陌生。

当前代码看起来包装了打印行项目的指令,这些指令未作为可计费费用指令的费用输入?

<#if record.item?has_content>
        <#assign totalBillableExpense = 0>
        <table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items -->
            <#list record.item as item>
                <#if item_index==0>
                    <thead>
                        <tr>
                            <th colspan="20" align="left">${item.description@label}</th>
                            <!--th align="center" colspan="3">${item.quantity@label}</th-->
                            <!--th align="right" colspan="4">${item.rate@label}</th-->
                            <th align="right" colspan="4">${item.amount@label}</th>
                        </tr>
                    </thead>
                </#if>
                <tr>
                    <#if item.custcol_ns_print_pdf?string == "Yes">                      
                        <td colspan="20">          
                            <!--#if item.itemtype?contains("Description") || item.itemtype?contains("Subtotal")-->
                            <!--/#if-->

                          ${item.description}</td>
                            <!--td align="center" colspan="3" line-height="150%">${item.quantity}</td-->
                            <!--td align="right" colspan="4">${item.rate}</td-->
                            <td align="right" colspan="4">${item.amount}</td>
                    </#if>
                    <#if item.description?contains("Total Billable Expenses")>
                        <#assign totalBillableExpense = totalBillableExpense + item.amount>
                    </#if>
                </tr>
            </#list><!-- end items -->
            <tr>
                <td colspan="20">Billable Expenses </td>
                <td align="right" colspan="4">${totalBillableExpense?string.currency}</td>
            </tr>

标签: templatesnetsuitefreemarker

解决方案


这可能是您要问的:

<#if totalBillableExpense gt 0>
        <tr>
            <td colspan="20">Billable Expenses </td>
            <td align="right" colspan="4">${totalBillableExpense?string.currency}</td>
        </tr>
</#if>

此外,为了避免空标签的潜在问题,<tr/>您应该重新制定:

<tr>
    <#if item.custcol_ns_print_pdf?string == "Yes">    
    ....
   </#if>
   <#if item.description?contains("Total Billable Expenses")>
       <#assign totalBillableExpense = totalBillableExpense + item.amount>
   </#if>
</tr>

类似于:

<#if item.description?contains("Total Billable Expenses")>
       <#assign totalBillableExpense = totalBillableExpense + item.amount>
</#if>
<#if item.custcol_ns_print_pdf?string == "Yes">
    <tr>
    
    ....
   </tr>
</#if>

推荐阅读