Hey! I'm trying to set the value of taxamountoverr...
# general
x
Hey! I'm trying to set the value of taxamountoverride (invoice) and I get a 'rounding error' for any value that is not zero. Any idea how to overcome this issue? Code: It's a user event script, aftersubmit.
Copy code
rec.setValue({
  fieldId: 'taxamountoverride', //      Error on values that are not 0 / 0.00 etc.
  value: salesTaxAmountFixedFormat
})
Error:
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "ROUNDING_ERROR",
  "message": "Rounding Error: 1",
  "stack":
    [
      "Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at insertTax (/SuiteScripts/tax_tst.js:245:13)\n at Object.afterSubmit (/SuiteScripts/tax_tst.js:21:9)",
    ],
  "cause":
    {
      "type": "internal error",
      "code": "ROUNDING_ERROR",
      "details": "Rounding Error: 1",
      "userEvent": null,
      "stackTrace":
        [
          "Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at insertTax (/SuiteScripts/tax_tst.js:245:13)\n at Object.afterSubmit (/SuiteScripts/tax_tst.js:21:9)",
        ],
      "notifyOff": false,
    },
  "id": "",
  "notifyOff": false,
  "userFacing": true,
  
}
Things I tried: • Change the format of the salesTaxAmount to a currency format (with 'N/format/i18n' module) • Passing 1 / 1.0 / 1.00 as the value • Using parseFloat(number).toPrecision() (passed 1 / 2 / 3) Thanks in advance < 3
b
change the tax code
x
Hey @battk - can you unpack that a bit 😅 I'm super new at this.
b
to something that isnt not taxable
this is a terrible idea for a new developer, taxamountoverride is a solution that needs to cover multiple transactions depending on the use case
there is an entire bundle dedicated to managing that field
x
What would be the best way to set the total tax amount in you opinion?
b
setup the taxes correctly in netsuite
there arent usually multiple correct values for taxes
x
We have an API that returns the total amount of tax that need to be collected on a document level (invoice in this case) My goal is to insert this amount into the invoice. We don't need multiple values or anything like that.
b
setup the taxes in netsuite
if it disagrees with your api, someone is wrong
x
yup, NetSuite can't do the calculations that the API does - that's why we need to override the amount...
b
my warning to you is that you need to understand when netsuite recalculates taxes
and have scripts in place to do the calculation instead, netsuite wont do it when you override the amount
x
understood 💪 it's good we want to ignore NetSuite's calc. I changed 'taxable' to be FALSE on the invoice as you advised and it looks like the 'taxamountoverride' is now set behind the scenes - but it's not affecting the summary box.
b
i said the opposite, change the tex code to something that isnt not taxable
with
not taxable
being the name of the default tax code for no taxes
x
Thanks for correcting me - to make sure I get you:
b
dont use the not taxable tax code to charge taxes
x
So should I create a new tax code, set the rate to zero and attach it onto the invoice? this is what you meant by changing to a tax code that is not taxable?
b
either way you are going to want to create your own tax code
but literally choose any tax other than the one in your screen shot
the
Not Taxable
tax code is not meant to be used to charge taxes
x
oh, so this is what I had before:
same behaviour
b
choose one with a non zero rate
x
Tried it as well - I changed this custom_rate tax code and I get and unexpected error
b
does it happen without the script doing anything?
152 Views