Skip to Content
0
Former Member
Oct 14, 2014 at 06:57 AM

Add A/P invoice

42 Views

Hi Team

I am adding A/P Invoice using B1WS PurchaseInvoicesService and getting an error

"Cannot add row without complete selection of batch/serial numbers"

Like I have one Bill which is having 2 items on that I have added bill value in PurchaseInvoicesService.Document

and loop for items using matrix and added in PurchaseInvoicesService.DocumentDocumentLine[]

my code is below.

PurchaseInvoicesService.Document documentBill = new PurchaseInvoicesService.Document();

documentBill.CardCode = vendorLinkedCompanyCode;

documentBill.CardName = vendorCompanyName;

documentBill.DocNum = docNum;

documentBill.CreationDate = DateTime.Now;

documentBill.CreationDateSpecified = true;

documentBill.Comments = memo;

documentBill.DocType = PurchaseInvoicesService.DocumentDocType.dDocument_Service;

documentBill.DocObjectCode = "18";

documentBill.NumAtCard = docNumber;

documentBill.Project = jobRef;

documentBill.DocTotal = Convert.ToDouble(total);

documentBill.DocTotalSpecified = true;

if (dueDate.HasValue)

{

documentBill.DocDueDate = DateTime.Now;

documentBill.DocDueDateSpecified = true;

}

documentBill.Rounding = PurchaseInvoicesService.DocumentRounding.tYES;

//Loop for Items like I have 4 items

var items = ap.GetBillItems(documentType, id, subInvRetainage);

PurchaseInvoicesService.DocumentDocumentLine[] documentLines = new PurchaseInvoicesService.DocumentDocumentLine[items.Count];

for (int count = 0; count < items.Count; count++)

{

documentLines[count] = new PurchaseInvoicesService.DocumentDocumentLine();

documentLines[count].ItemCode = itemCode;

documentLines[count].ItemDescription = description;

documentLines[count].FreeText = description;

documentLines[count].ProjectCode = jobRef;

documentLines[count].Price = Convert.ToDouble(unitPrice);

documentLines[count].PriceSpecified = true;

documentLines[count].UnitPrice = Convert.ToDouble(unitPrice);

documentLines[count].UnitPriceSpecified = true;

documentLines[count].Quantity = Convert.ToDouble(qty);

documentLines[count].LineTotal = Convert.ToDouble(qty * unitPrice);

documentLines[count].DeferredTax = PurchaseInvoicesService.DocumentDocumentLineDeferredTax.tYES;

documentLines[count].SerialNum = Convert.ToString(count + 1);

documentLines[count].LineNum = count;

PurchaseInvoicesService.DocumentDocumentLineBatchNumber[] dBatchNumber = new PurchaseInvoicesService.DocumentDocumentLineBatchNumber[1];

dBatchNumber[0] = new PurchaseInvoicesService.DocumentDocumentLineBatchNumber();

dBatchNumber[0].BaseLineNumber = 1;//count + 1;

dBatchNumber[0].BaseLineNumberSpecified = true;

dBatchNumber[0].BatchNumber = "01";// Convert.ToString(count + 1);

dBatchNumber[0].AddmisionDate = DateTime.Now;

dBatchNumber[0].AddmisionDateSpecified = true;

dBatchNumber[0].InternalSerialNumber = "01";

dBatchNumber[0].ManufacturerSerialNumber = "01";

dBatchNumber[0].Notes = "";

dBatchNumber[0].Quantity = Convert.ToDouble(qty);

dBatchNumber[0].QuantitySpecified = true;

documentLines[count].BatchNumbers = dBatchNumber;

PurchaseInvoicesService.DocumentDocumentLineSerialNumber[] dSerialNumber = new PurchaseInvoicesService.DocumentDocumentLineSerialNumber[1];

dSerialNumber[0] = new PurchaseInvoicesService.DocumentDocumentLineSerialNumber();

dSerialNumber[0].BaseLineNumber = 1;//count + 1;

dSerialNumber[0].BaseLineNumberSpecified = true;

dSerialNumber[0].BatchID = "01";// Convert.ToString(count + 1);

dSerialNumber[0].Quantity = Convert.ToDouble(qty);

dSerialNumber[0].QuantitySpecified = true;

dSerialNumber[0].InternalSerialNumber = "01";

dSerialNumber[0].Notes = "";

//dSerialNumber[0].SystemSerialNumber = 1;// count + 1;

//dSerialNumber[0].SystemSerialNumberSpecified = true;

documentLines[count].SerialNumbers = dSerialNumber;

documentBill.DocumentLines = documentLines;

}

PurchaseInvoicesService.PurchaseInvoicesService myPOService = new PurchaseInvoicesService.PurchaseInvoicesService();

// Create Header

PurchaseInvoicesService.MsgHeader msgHeader = new PurchaseInvoicesService.MsgHeader();

msgHeader.SessionID = sessionId;

msgHeader.ServiceName = PurchaseInvoicesService.MsgHeaderServiceName.PurchaseInvoicesService;

msgHeader.ServiceNameSpecified = true;

myPOService.MsgHeaderValue = msgHeader;

// Call command with output return

documentParamsBill = myPOService.Add(documentBill);

I am getting an error of Cannot add row without complete selection of batch/serial numbers I used all matrix to add Batch / Serial and include all possible value.

Can you suggest where is an issue?

Regards

Shyam