创建订单时在 SuiteScript 中处理无效税码时出错

问题描述 投票:0回答:1

我在使用 SuiteScript 创建订单时遇到与税码相关的错误。该错误消息表明存在无效税码问题,特别是“TW5”。这是详细的错误消息:

{
   type: "error.SuiteScriptError",
   name: "INVALID_TAX_CODES",
   message: "Invalid Tax Code(s): TW5 -- valid ",
   stack: [
      "Error at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)",
      "at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)",
      "at createOrder (/SuiteScripts/SO/shopline_excel/MR_shopline_order_create.js:119:43)",
      "at Object.map (/SuiteScripts/SO/shopline_excel/MR_shopline_order_create.js:305:13)"
   ],
   cause: {
      type: "internal error",
      code: "INVALID_TAX_CODES",
      details: "Invalid Tax Code(s): TW5 -- valid ",
      stackTrace: [
         "Error at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)",
         "at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)",
         "at createOrder (/SuiteScripts/SO/shopline_excel/MR_shopline_order_create.js:119:43)",
         "at Object.map (/SuiteScripts/SO/shopline_excel/MR_shopline_order_create.js:305:13)"
      ],
      notifyOff: false
   },
   notifyOff: false,
   userFacing: true
}

下面是设置税码的代码部分:

javascript

function createOrder(jsonData, mappingData) {
    try {
        var salesOrder = record.create({
            type: record.Type.SALES_ORDER,
            isDynamic: true
        });

        // Set various other fields...

        if (jsonData['商品信息']) {
            jsonData['商品信息'].forEach((item, index) => {
                var itemId = getItemId(item['商品貨號']);
                if (itemId) {
                    salesOrder.selectNewLine({ sublistId: 'item' });
                    // Set item details including quantity and adjusted price...
                    salesOrder.setCurrentSublistValue({
                        sublistId: 'item',
                        fieldId: 'taxcode',
                        value: 1902  // Is this where the error is occurring?
                    });

                    salesOrder.commitLine({ sublistId: 'item' });
                } else {
                    log.error('商品编码未找到', item['商品貨號']);
                }
            });
        }

        // Process mapping and save record...
        var recordId = salesOrder.save({
            enableSourcing: true,
            ignoreMandatoryFields: false
        });
        log.debug('销售订单已创建', 'ID: ' + recordId);
    } catch (e) {
        log.error({
            title: '创建订单时出错',
            details: e
        });
    }
}

我不确定此处使用的税码“1902”是否正确。是否该税码在系统中未被识别或无效,或者我应该以不同的方式处理此问题?

javascript netsuite suitescript
1个回答
0
投票

税码列表可以在设置 > 会计 > 税码下找到。检查 1902 该税码对您的客户是否有效。首先尝试在 UI 中创建销售订单,然后检查该客户的可用税码。

© www.soinside.com 2019 - 2024. All rights reserved.