Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

c# - Associate invoice to a Sales Order

I am not able to set "Created From" on Invoice to reference a Sales Order record through the SOAP web service. I have tried setting this field directly and also through Initialize API (initializing a invoice record using the sales order and then copying the CreatedFrom field from the initialized invoice to the invoice being created).

I don't get any errors yet the Created From field doesn't get set on the created invoice record.

The code I am trying looks something like this:

// initialize invoice from sales order
var initializeRecord = new InitializeRecord()
            {
                type = InitializeType.invoice,
                reference = new InitializeRef() { internalId = "sales-order-internal-id", type = InitializeRefType.salesOrder, typeSpecified = true }
            };            
            var result = Utility.Do(async () => await connector.NetSuiteClient.initializeAsync(initializeRecord));
SuiteTalk.Invoice initializedInvoice = result.record;

// create a invoice and copy over the "createdFrom" field
var invoice = new SuiteTalk.Invoice();
invoice.createdFrom = initializedInvoice.createdFrom;

/* set other fields on the invoice and add some line items
....
...
..
*/

// finally create the invoice
var result = Utility.Do(async () => await connector.NetSuiteClient.addAsync(invoice));

How I can associate this invoice to a sales order while creating it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What you will have to do -- as painful as it is -- is to use the transformed record provided to you by netsuite from the initializeRecord call, and then modify it. It is a pain because there are several fields that you will have to unset as you fill in the record.

The issue is that there are createdFrom associations on both the header level, and the line level, that need to be filled in for the sales order to invoice association to take.

here are the list of line fields that I had to unset in the invoice:

line-level:

  • quantityRemaining
  • quantityAvailable
  • quantityFulfilled
  • quantityOrdered
  • quantityOnHand
  • costEstimate
  • taxRate1

here are the header-level fields:

  • subTotal
  • total
  • totalCostEstimate
  • estGrossProfit
  • estGrossProfitPercent
  • discountTotal
  • giftCertApplied
  • shippingTax1Rate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...