Is there a way to automatically round off the tota...
# general
l
Is there a way to automatically round off the total invoice amount for certain customers? I can't find a standard functionality for this. I also tried workflow but the Gross Amount (Line) or the Tax Amount (Line) field isn't exposed for Set Field Value. Am I stuck with scripting?
m
Could you use a saved search to calculate up the total amount. Then use that saved search to source a custom body field on your Invoice Then use that amount in that custom body field to calculate the amount needed to add/subtract to get your rounded amount then add that as a Discount line using the Create Line action?
So then essentially you would be giving them a couple pennies discount to get to a nice round number?
l
Thanks, @MGBC. It sounds like it's gonna work because the Amount (Line) field is available in workflows. I'm just concerned about the impact on our printed customer invoice. But it's more of a business decision whether to show the discount or not on pdf, whether to make the discount posting or non-posting, which segmentations to use for the discount line especially if the items are assigned to different segmentations, etc. Going back to my original post which is to override the Tax Amount Line (I can override Net Amount), it looks like scripting is my only way to go, right? Although right now, I like the idea of just adding a new discount/mark-up line because it won't mess up the quantity x rate = net amount calculation.
m
It's annoying that only net amount is available in a workflow. I recently had a case we needed to change other amount related fields on the line, and ended up writing a simple Workflow Action Script
Copy code
/**
 * @copyright 2023 <http://Carsales.com.au|Carsales.com.au>
 * @author Michoel Chaikin <michoel.chaikin@carsales.com.au>
 * @NApiVersion 2.1
 * @NScriptType WorkflowActionScript
 *
 * Workflow Action Script to set the value of any line level field on a workflow. The native Set Line Value workflow
 * action only supports specific sublists and fields.
 */

define(["N/runtime"], (runtime) => /**
 * @param {import("N/runtime") } runtime
 * @returns {object}
 */ {
  var exports = {};

  /**
   * @param {import("N/types").EntryPoints.WorkflowAction.onActionContext } context
   */
  exports.onAction = function (context) {
    log.debug({ title: "=== WA Script Starting ===" });

    const script = runtime.getCurrentScript();

    const sublistId = script.getParameter({ name: "custscript_cs_setsublistvalue_sublist_id" });
    const fieldId = script.getParameter({ name: "custscript_cs_setsublistvalue_field_id" });
    const line = script.getParameter({ name: "custscript_cs_setsublistvalue_line" });
    const value = script.getParameter({ name: "custscript_cs_setsublistvalue_value" });

    log.debug({ title: "script parameters", details: JSON.stringify({ sublistId, fieldId, line, value }) });

    context.newRecord.selectLine({ sublistId, line });
    context.newRecord.setCurrentSublistValue({ sublistId, fieldId, value });
    context.newRecord.commitLine({ sublistId });

    log.debug({ title: "=== WA Script Complete ===" });
  };

  return exports;
});
m
Have you tried with sublist field item on your workflow ?
l
Thanks, @michoel. Appreciate it.
@Marc, yes, but the tax amount field isn't exposed. Only the net amount is.