【问题标题】:Freemarker / Netsuite - Assign a variable to a specific item amountFreemarker / Netsuite - 将变量分配给特定的项目数量
【发布时间】:2021-02-09 22:50:34
【问题描述】:

我需要为 Freemarker(Netsuite 版本)中的特定项目金额分配一个变量,以便在发票模板的不同部分使用。

我正在努力弄清楚如何使用 来做到这一点。该项目将只使用一次,并将位于发票上的小计字段下方。

关于如何做到这一点的任何建议?

【问题讨论】:

    标签: netsuite freemarker


    【解决方案1】:

    查看Freemarker docs

    捕获数据:

    <#assign ord_number_is>Your order number is ${record.tranid}</#assign>
    ${ord_number_is}
    

    设置数据:

    <#assign fs_6="font-size: 6pt;" />
    ${fs_6}
    

    【讨论】:

      【解决方案2】:

      大多数(全部?)在 NetSuite 交易高级 pdf 表单中,交易项目内容的“内容”以如下行开头:

      <table class="itemtable"><!-- start items --><#list record.item as item><#if item_index==0>
      

      然后它在一个 html 表格中提供内容(通常是项目)并用结束标记结束循环:

      </#list><!-- end items -->
      

      当我需要首先从项目列表中收集信息但不实际将其打印到 pdf 中时,我喜欢遵循相同的结构减去 html 元素。对于您的情况,我认为您想识别子列表中的特定项目,然后如果它存在,请记录金额以供将来在表格中的其他地方使用。使用上面的结构,会是这样的:

      <!-- assign variable to hold initial value -->
      <#assign item_x_amount = 0>
      
      <!-- populate the amount if the item is present in any row -->
      <#list record.item as tmpLine>
          <#if (tmpLine.item == "Consulting Services")><#assign item_x_amount = item_x_amount + tmpLine.amount></#if>
      </#list>
      

      然后,稍后在创建小计表的代码中,添加变量标签和值。导致的事务如下所示:

      注意事项:

      • 我冒昧地将您的请求扩展到“特定项目的金额总和”。这也涵盖了您的假设,即交易中只会有一个匹配的项目,但人们很少总是遵守规则。如果您绝对不想要这种行为,您可以将&lt;#assign item_x_amount = item_x_amount + tmpLine.amount&gt; 更改为&lt;#assign item_x_amount = tmpLine.amount&gt;
      • 如果项目名称更改,则会中断。你没有提到你是如何识别有问题的项目的。使用有关项目的其他一些识别信息(可能是内部 ID)更安全,或者更好的是使用事务行字段将其标记为要在此流程中使用的行。
      • 我使用${item_x_amount?string.currency}将显示的结果格式化为货币

      希望这会有所帮助!我在 NetSuite 开发中经常使用这种技术。

      【讨论】:

        猜你喜欢
        • 2013-12-24
        • 2013-08-22
        • 2011-04-21
        • 2018-03-14
        • 2019-05-10
        • 1970-01-01
        • 2016-02-16
        • 1970-01-01
        • 2020-10-08
        相关资源
        最近更新 更多