如何使用suitetalk在netsuite中创建发票?

时间:2018-10-07 06:39:53

标签: api netsuite restlet suitescript suitetalk

感谢您阅读本主题,如果netsuite的某人可以与我分享以下问题的解决方案,我将不胜感激。

我正在netsuite Web门户中与没有信用额度的客户一起创建发票,我添加了库存项目,然后添加了该项目的付款项目,它运作良好,我感到非常高兴。但是当我要使用Suitetalk Web服务创建相同的东西时,会向我显示以下错误。

  

[Code = USER_ERROR]客户余额超过了信用额度

     

[Code = WARNING]客户余额23.52超出了信用额度0.01。

     

[Code = WARNING]客户余额23.52超出了信用额度0.01。

请看一下源代码:

        Invoice invoice = new Invoice();

        invoice.entity = new RecordRef() { internalId = "5967", type = RecordType.customer, typeSpecified = true };
        invoice.tranDate = DateTime.UtcNow;
        invoice.memo = "TEST0001";
        invoice.department = new RecordRef() { internalId = "2", type = RecordType.department, typeSpecified = true };
        invoice.location = new RecordRef() { internalId = "1", type = RecordType.location, typeSpecified = true };

        InvoiceItemList invoiceItemList = new InvoiceItemList();
        List<InvoiceItem> invoiceItems = new List<InvoiceItem>();

        // payment item
        invoiceItems.Add(new InvoiceItem()
        {
            item = new RecordRef() { internalId = "62374" },
            rate = (25 * -1).ToString(),
            price = new RecordRef() { internalId = "-1", type = RecordType.priceLevel, typeSpecified = true },
            taxCode = new RecordRef() { internalId = "16", type = RecordType.taxGroup, typeSpecified = true }
        });

        // inventory or other items
        InvoiceItem invoiceItem = new InvoiceItem();
        invoiceItem.item = new RecordRef() { internalId = "59852" };
        invoiceItem.rate = "25";
        invoiceItem.quantity = 1;
        invoiceItem.quantitySpecified = true;
        invoiceItem.taxCode = new RecordRef() { internalId = "16", type = RecordType.taxGroup, typeSpecified = true };
        invoiceItem.price = new RecordRef() { internalId = "-1", type = RecordType.priceLevel, typeSpecified = true };            

        invoiceItems.Add(invoiceItem);

        invoiceItemList.item = invoiceItems.ToArray();
        invoice.itemList = invoiceItemList;

        WriteResponse writeRes = Client.Service.add(invoice);
        if (writeRes.status != null && writeRes.status.isSuccess)
        {
            string baseRef = ((RecordRef)writeRes.baseRef).internalId;
        }
        else
        {
            string response = Client.GetStatusDetails(writeRes.status);
            MessageBox.Show(response);
        }

0 个答案:

没有答案