templates - 使用 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>
解决方案
这可能是您要问的:
<#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>
推荐阅读
- gitlab - gitlab 中 raw.githubusercontent 的对应物是什么?
- architecture - 带有分支预测的 CPI 计算练习
- javascript - 如何从反应父组件获取更新状态
- pandas - 在 python pandas 中:使用 '\t' 导入数据时不会改变列数
- c# - 非静态字段、方法或属性“Program.InsertLogData()”需要对象引用
- r - R - grepl 警告:参数“模式”的长度 > 1,仅使用第一个元素
- scrapy - 为什么我不能只抓取这个特定的 P 标签?
- django - Crispy FormHelper 对象没有属性“attrs”
- visual-studio-code - 使用一次后,Vscode 不显示自动建议(仅显示一次)
- machine-learning - 如何在 Xamarin 中指定与 TensorFlowLite 输出相关的 Java 对象?