我正在使用 Netsuite 中的高级 PDF/HTML 模板来创建自定义输出模板。在此模板中,我想评估一个项目以查看它是否应纳税。
NetSuite 的架构定义了 Sales Order
带有子列表 Item
有一个字段 .istaxable
(source)
- 字段:应税
- 类型:复选框
- 标签:税
- 必填:假
当我尝试计算表达式时,例如:
<#if item.istaxable == true>
通过打印模板,我收到以下错误。
Left hand operand is a com.netledger.templates.model.StringModel
Right hand operand is a freemarker.template.TemplateBooleanModel$2
当我尝试将 .istaxable 评估为字符串时:
<#if item.istaxable == "true">
或
<#if item.istaxable == 'T'>
*编辑:更新以响应建议的答案
我无法在编辑器中保存模板,因为它会引发错误:
The only legal comparisons are between two numbers, two strings, or two dates. Left hand operand is a com.netledger.templates.model.BooleanModel Right hand operand is a freemarker.template.SimpleScalar
item.istaxable
也是如此StringModel 还是 BooleanModel?
最佳答案
众所周知,Netsuite 与它处理 bool 值的方式不一致,事实上,我遇到过根据事务的不同对相同字段进行不同处理的情况(在我的例子中,它是 isclose
字段)。我最终使用了以下语法:
<#if (item.isclosed?is_boolean && item.isclosed) || (item.isclosed?is_string && item.isclosed == 'T')
关于freemarker - 您如何评估和比较 Netsuite 中 item.istaxable 的值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41947387/