您如何评价和比较item.istaxable在Netsuite中的价值?
How do you evaluate and compare the value of item.istaxable in Netsuite?
我正在使用 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
当我尝试将 .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?
你试过item.istaxable = 'T'了吗?这就是我在 SuiteScript 1.0
中使用的
Netsuite 与它处理布尔值的方式不一致是出了名的,事实上我遇到过 same 字段根据事务处理不同的情况(在我的例子中它是 isclosed
字段)。我最终使用了以下语法:
<#if (item.isclosed?is_boolean && item.isclosed) || (item.isclosed?is_string && item.isclosed == 'T')
<#if item.istaxable>.....
应作为 true/false 评估。
如果 Netsuite 已正确设置 boolean_format
,则以下操作应该有效:
<#if "${item.istaxable}" == "T">
如果 istaxable 是一个字符串,那么它的计算会产生 Netsuite 'T'。如果 istaxable 是布尔值,则使用 boolean_format
设置将其转换为字符串;如果 true 映射到 'T' 而 false 映射到 'F',那么它会产生与字符串版本相同的结果。
YMMV - 如果我记得,我会尝试更新此答案。
我正在使用 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
当我尝试将 .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?
你试过item.istaxable = 'T'了吗?这就是我在 SuiteScript 1.0
中使用的Netsuite 与它处理布尔值的方式不一致是出了名的,事实上我遇到过 same 字段根据事务处理不同的情况(在我的例子中它是 isclosed
字段)。我最终使用了以下语法:
<#if (item.isclosed?is_boolean && item.isclosed) || (item.isclosed?is_string && item.isclosed == 'T')
<#if item.istaxable>.....
应作为 true/false 评估。
如果 Netsuite 已正确设置 boolean_format
,则以下操作应该有效:
<#if "${item.istaxable}" == "T">
如果 istaxable 是一个字符串,那么它的计算会产生 Netsuite 'T'。如果 istaxable 是布尔值,则使用 boolean_format
设置将其转换为字符串;如果 true 映射到 'T' 而 false 映射到 'F',那么它会产生与字符串版本相同的结果。
YMMV - 如果我记得,我会尝试更新此答案。