public override Int64 Set(string parametersArr) { try { //Set Values of Netsuite Customer ID // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Start"); //new GenericeDAO<Foodics.NetSuite.Shared.Model.Invoice.Integrate>().GetAndUpdateCustomerIDandCreditMemo(); //get recentrly added invoices after creating the return List <Foodics.NetSuite.Shared.Model.Invoice> invoiceLst = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>().GetWhere(" Netsuite_Id IS NULL or Netsuite_Id =0"); Setting objSetting = new GenericeDAO <Setting>().GetAll().FirstOrDefault(); // = new NetsuiteDAO().SelectInvoicesForIntegration(); // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Count: " + invoiceLst.Count.ToString()); bool result = true; if (invoiceLst.Count > 0) { #region variables Invoice[] InvoiceArr = new Invoice[invoiceLst.Count]; List <Foodics.NetSuite.Shared.Model.InvoiceItem> itemLst; List <Foodics.NetSuite.Shared.Model.GiftCertificate.Integrate> giftCertificateLst; //List<Foodics.NetSuite.Shared.Model.ItemLotSerial.Sales> lotSerialLst; Foodics.NetSuite.Shared.Model.Invoice invoice_info; Foodics.NetSuite.Shared.Model.InvoiceItem itemDetails; GiftCertRedemption[] giftRedeem; InvoiceItem[] invoiceItems; DateTime invoice_date; Invoice invoiceObject; InvoiceItem invoiceItemObject; InvoiceItemList items; InventoryAssignmentList InventoryAssignmentlst; InventoryAssignment[] assignList; InventoryAssignment assign; InventoryDetail invDetails; GiftCertRedemptionList redemptionLst; DateCustomFieldRef trans_time; ListOrRecordRef emirate_region, custSelectValue, custSelectCashier; SelectCustomFieldRef emirate_ref = null, terminal, cashier; RecordRef authCodeRef, taxCode, item, unit, price, itmSerial, discItem, subsid, currency, entity, location, classification, department; DoubleCustomFieldRef line_total, line_discount_amount, balance, paid, lineDiscount; StringCustomFieldRef trans_no, pos_id, orderDiscount; CustomFieldRef[] customFieldRefArr, customFieldRefArray; int item_custom_cols = 2; #endregion for (int i = 0; i < invoiceLst.Count; i++) { try { invoice_info = invoiceLst[i]; //Netsuite invoice type invoiceObject = new Invoice(); //get invoice items itemLst = new GenericeDAO <Foodics.NetSuite.Shared.Model.InvoiceItem>().GetWhere("Invoice_Id =" + invoice_info.Id);//new NetsuiteDAO().SelectInvoicItems(invoice_info.Id); //get invoice gift certificates #region gift certificate redemption //try //{ // giftCertificateLst = new NetsuiteDAO().SelectEntityGiftCertificates(invoice_info.Id, 1); // if (giftCertificateLst.Count > 0) // { // redemptionLst = new GiftCertRedemptionList(); // giftRedeem = new GiftCertRedemption[giftCertificateLst.Count]; // for (int r = 0; r < giftCertificateLst.Count; r++) // { // GiftCertRedemption gift = new GiftCertRedemption(); // authCodeRef = new RecordRef(); // authCodeRef.internalId = giftCertificateLst[r].Netsuite_Id.ToString(); // authCodeRef.type = RecordType.giftCertificate; // gift.authCode = authCodeRef; // gift.authCodeAppliedSpecified = true; // gift.authCodeApplied = Convert.ToDouble(giftCertificateLst[r].Amount); // giftRedeem[r] = gift; // } // redemptionLst.giftCertRedemption = giftRedeem; // invoiceObject.giftCertRedemptionList = redemptionLst; // } //} //catch (Exception ex) //{ // //LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding GiftCertificates: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString()); //} #endregion #region invoice items //Define Invoice Items List invoiceItems = new InvoiceItem[itemLst.Count]; try { item_custom_cols = 2; for (int k = 0; k < itemLst.Count; k++) { itemDetails = itemLst[k]; invoiceItemObject = new InvoiceItem(); // TAX //invoiceItemObject.taxRate1Specified = true; //invoiceItemObject.taxRate1 = itemDetails.Tax_Rate; //invoiceItemObject.taxAmount = itemDetails.Tax_Amt; // tax code taxCode = new RecordRef(); taxCode.internalId = objSetting.TaxCode_Netsuite_Id.ToString(); //"15";//itemDetails.Tax_Code.ToString(); taxCode.type = RecordType.taxAcct; invoiceItemObject.taxCode = taxCode; // item item = new RecordRef(); item.internalId = itemDetails.Item_Id.ToString(); item.type = (RecordType)Enum.Parse(typeof(RecordType), itemDetails.Item_Type, true); //item.type = (RecordType)Enum.Parse(typeof(RecordType), "InventoryItem", true); invoiceItemObject.item = item; if (Utility.ConvertToInt(itemDetails.Units) > 0) { unit = new RecordRef(); unit.internalId = itemDetails.Units.ToString(); unit.type = RecordType.unitsType; invoiceItemObject.units = unit; } // price level #region price level price = new RecordRef(); price.type = RecordType.priceLevel; if (itemDetails.Amount > 0) { //if (itemDetails.Customer_Price_Level > 0) //{ // // customer price level // price.internalId = itemDetails.Customer_Price_Level.ToString(); // invoiceItemObject.price = price; //} //else if (itemDetails.Price_Level_Id > 0) //{ // // default price level // price.internalId = itemDetails.Price_Level_Id.ToString(); // invoiceItemObject.price = price; //} //else //{ // amount invoiceItemObject.amountSpecified = true; invoiceItemObject.amount = itemDetails.Amount; //} } #endregion // invoiceItemObject.costEstimateType = (ItemCostEstimateType)itemDetails.Cost_Estimate_Type; //if (itemDetails.Item_Type == "GiftCertificateItem") //{ // #region sell gift certificate // try // { // invoiceItemObject.giftCertNumber = itemDetails.Gift_Code; // invoiceItemObject.giftCertFrom = itemDetails.Sender; // invoiceItemObject.giftCertMessage = itemDetails.Gift_Message; // invoiceItemObject.giftCertRecipientName = itemDetails.Recipient_Name; // invoiceItemObject.giftCertRecipientEmail = itemDetails.Recipient_Email; // } // catch { } // #endregion //} //else //{ // quantity invoiceItemObject.quantitySpecified = true; invoiceItemObject.quantity = itemDetails.Quantity; #region serials/Lot //if (Utility.ItemTypeSerialized.Contains(itemDetails.Item_Type)) //{ // lotSerialLst = new NetsuiteDAO().SelectInvoiceLotSerials(itemDetails.Id); // InventoryAssignmentlst = new InventoryAssignmentList(); // assignList = new InventoryAssignment[lotSerialLst.Count]; // for (int z = 0; z < lotSerialLst.Count; z++) // { // assign = new InventoryAssignment(); // itmSerial = new RecordRef(); // itmSerial.internalId = lotSerialLst[z].Netsuite_Id.ToString(); // itmSerial.type = RecordType.lotNumberedInventoryItem; // itmSerial.typeSpecified = true; // if (Utility.ItemTypeLot.Contains(itemDetails.Item_Type)) // { // assign.quantitySpecified = true; // assign.quantity = lotSerialLst[z].Quantity; // } // assign.issueInventoryNumber = itmSerial; // assignList[z] = assign; // } // InventoryAssignmentlst.inventoryAssignment = assignList; // invDetails = new InventoryDetail(); // invDetails.inventoryAssignmentList = InventoryAssignmentlst; // invoiceItemObject.inventoryDetail = invDetails; //} #endregion // } #region custom fields try { #region line-item discount //line_total = new DoubleCustomFieldRef(); //line_total.scriptId = "custcol_da_pos_line_item_total"; //line_total.value = Math.Round(itemDetails.Total_Line_Amount, 3); //line_discount_amount = new DoubleCustomFieldRef(); //line_discount_amount.scriptId = "custcol_da_pos_line_item_discount"; //line_discount_amount.value = Math.Round(itemDetails.Line_Discount_Amount, 3); // line-item amount invoiceItemObject.amount = (itemDetails.Quantity * itemDetails.Amount); #endregion #region Transaction Region (Emirate) //item_custom_cols = 2; //if (invoice_info.Transaction_Region > 0) //{ // item_custom_cols = 3; // emirate_region = new ListOrRecordRef(); // emirate_region.internalId = invoice_info.Transaction_Region.ToString(); // emirate_ref = new SelectCustomFieldRef(); // emirate_ref.scriptId = "custcol_emirate"; // emirate_ref.value = emirate_region; //} #endregion //customFieldRefArr = new CustomFieldRef[item_custom_cols]; //customFieldRefArr[0] = line_total; //customFieldRefArr[1] = line_discount_amount; //if (item_custom_cols == 3) // customFieldRefArr[2] = emirate_ref; //invoiceItemObject.customFieldList = customFieldRefArr; } catch (Exception ex) { // LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding customField: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString()); } #endregion invoiceItems[k] = invoiceItemObject; } } catch (Exception ex) { // LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding invoice: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString()); } //Assign invoive items items = new InvoiceItemList(); items.item = invoiceItems; invoiceObject.itemList = items; //GiftCertRedemption #endregion #region Invoice Values #region Standard Attributes invoice_date = TimeZoneInfo.ConvertTimeToUtc(invoice_info.Date, TimeZoneInfo.Local); invoiceObject.tranDateSpecified = true; invoiceObject.dueDateSpecified = true; invoiceObject.tranDate = invoice_date; invoiceObject.dueDate = invoice_date; invoiceObject.exchangeRate = invoice_info.Exchange_Rate; invoiceObject.memo = invoice_info.Notes; if (invoice_info.Subsidiary_Id > 0) { subsid = new RecordRef(); subsid.internalId = objSetting.Subsidiary_Netsuite_Id.ToString(); subsid.type = RecordType.subsidiary; invoiceObject.subsidiary = subsid; } //RecordRef customForm = new RecordRef(); //customForm.internalId = "92"; //invoiceObject.customForm = customForm; currency = new RecordRef(); currency.internalId = objSetting.Currency_Netsuite_Id.ToString(); currency.type = RecordType.currency; invoiceObject.currency = currency; entity = new RecordRef(); entity.internalId = invoice_info.Customer_Netsuite_Id > 0? invoice_info.Customer_Netsuite_Id.ToString(): objSetting.Customer_Netsuite_Id.ToString(); entity.type = RecordType.customer; invoiceObject.entity = entity; location = new RecordRef(); location.internalId = invoice_info.Location_Id.ToString(); //objSetting.Location_Netsuite_Id.ToString(); location.type = RecordType.location; invoiceObject.location = location; // department //if (invoice_info.Department_Id > 0) //{ // department = new RecordRef(); // department.internalId = invoice_info.Department_Id.ToString(); // department.type = RecordType.department; // invoiceObject.department = department; //} //// class //if (invoice_info.Class_Id > 0) //{ // classification = new RecordRef(); // classification.internalId = invoice_info.Class_Id.ToString(); // classification.type = RecordType.classification; // invoiceObject.@class = classification; //} // sales rep if (invoice_info.Sales_Rep_Id > 0) { RecordRef sales_rep = new RecordRef(); sales_rep.internalId = invoice_info.Sales_Rep_Id.ToString(); sales_rep.type = RecordType.employee; invoiceObject.salesRep = sales_rep; } #endregion #region Invoice Custom Attributes trans_no = new StringCustomFieldRef(); trans_no.scriptId = "custbody_da_pos_trans_no"; trans_no.value = invoice_info.BarCode.ToString(); pos_id = new StringCustomFieldRef(); pos_id.scriptId = "custbody_da_pos_id"; pos_id.value = invoice_info.Id.ToString(); custSelectValue = new ListOrRecordRef(); terminal = new SelectCustomFieldRef(); custSelectValue.internalId = invoice_info.Terminal_Id.ToString(); terminal.scriptId = "custbody_da_terminal"; terminal.value = custSelectValue; custSelectCashier = new ListOrRecordRef(); cashier = new SelectCustomFieldRef(); custSelectCashier.internalId = invoice_info.Cashier.ToString(); cashier.scriptId = "custbody_da_cashier"; cashier.value = custSelectCashier; balance = new DoubleCustomFieldRef(); balance.scriptId = "custbody_da_balance"; balance.value = Math.Round(invoice_info.Balance, 3); paid = new DoubleCustomFieldRef(); paid.scriptId = "custbody_da_paid"; paid.value = Math.Round(invoice_info.Paid, 3); trans_time = new DateCustomFieldRef(); trans_time.scriptId = "custbody_da_pos_trans_time"; trans_time.value = invoice_date; #region Discount invoiceObject.discountRate = (Math.Round(invoice_info.Total_Discount, 3) * -1).ToString(); lineDiscount = new DoubleCustomFieldRef(); lineDiscount.scriptId = "custbody_da_pos_line_item_discount"; lineDiscount.value = Math.Round(invoice_info.Line_Discount_Amount, 3) * -1; orderDiscount = new StringCustomFieldRef(); orderDiscount.scriptId = "custbody_da_pos_order_discount"; orderDiscount.value = (Math.Round(invoice_info.Invoice_Discount_Rate, 3) * -1).ToString(); if (invoice_info.Invoice_Discount_Type == 1) { orderDiscount.value = (Math.Round(invoice_info.Invoice_Discount_Rate, 3) * -1).ToString() + "%"; } if (invoice_info.Accounting_Discount_Item != 0) { discItem = new RecordRef(); discItem.internalId = invoice_info.Accounting_Discount_Item.ToString(); discItem.type = RecordType.discountItem; invoiceObject.discountItem = discItem; } #endregion int length = 7; if (invoice_info.Terminal_Id > 0) { length = 8; } customFieldRefArray = new CustomFieldRef[length]; customFieldRefArray[0] = cashier; customFieldRefArray[1] = balance; customFieldRefArray[2] = paid; customFieldRefArray[3] = trans_time; customFieldRefArray[4] = trans_no; customFieldRefArray[5] = lineDiscount; customFieldRefArray[6] = orderDiscount; if (invoice_info.Terminal_Id > 0) { customFieldRefArray[7] = terminal; } invoiceObject.customFieldList = customFieldRefArray; #endregion InvoiceArr[i] = invoiceObject; #endregion } catch (Exception ex) { invoiceLst.RemoveAt(i); // LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding invoice: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString()); } } // Send invoice list to netsuite WriteResponseList wr = Service(true).addList(InvoiceArr); result = wr.status.isSuccess; // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Status: " + result); if (result) { //Update database with returned Netsuite ids UpdatedInvoice(invoiceLst, wr); } } // post customerPayment to netsuite // bool postPayments = PostCustomerPayment(); } catch (Exception ex) { // LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask Error", "Error " + ex.Message); } // release the the object //new ScheduleTaskDAO().Processing(taskType, TaskRunType.POST, false); return(0); }
public override Int64 Set(string parametersArr) { try { bool result = true; new CustomDAO().InvoiceRelatedUpdate(); new CustomDAO().SetItemClass(); #region Check Correct Invoices /* * SELECT * * FROM Invoice * WHERE * --(Location_Id = 201) and * Order_Status=4 * and Net_Payable + Total_Discount != (select sum( Quantity * amount) - sum(Line_Discount_Amount) from InvoiceItem where InvoiceItem.Invoice_Id =Invoice.Id and ISNULL(Item_Id,0)>0 and ProductStatus=3 ) * * SELECT * * FROM Invoice * WHERE * * Order_Status=5 * and Net_Payable + Total_Discount != (select sum( Quantity * amount) - sum(Line_Discount_Amount) from InvoiceItem where InvoiceItem.Invoice_Id =Invoice.Id and ISNULL(Item_Id,0)>0 and ProductStatus=6 ) * select * from InvoiceItem where isnull([Item_Id], 0)=0 * * Declare @id nvarchar(50) * set @id='007f91e2-a8ad-4dab-a20a-70c90e8db6ce' * select * from Invoice * where Foodics_Id =@id * select Net_Payable,Net_Payable-((Net_Payable*15)/100) from Invoice * where Foodics_Id =@id * select * from InvoiceItem * where Foodics_Id =@id */ #endregion List <Foodics.NetSuite.Shared.Model.Invoice> lstitemsAll = new CustomDAO().SelectInvoice(4); int Exe_length = 200; int lstend = Exe_length; if (lstitemsAll.Count > 0) { for (int Index = 0; Index < lstitemsAll.Count; Index += Exe_length) { if (Index + Exe_length >= lstitemsAll.Count) { lstend = lstitemsAll.Count - Index; } List <Foodics.NetSuite.Shared.Model.Invoice> invoiceLst = lstitemsAll.GetRange(Index, lstend); if (invoiceLst.Count > 0) { #region variables Invoice[] InvoiceArr = new Invoice[invoiceLst.Count]; Foodics.NetSuite.Shared.Model.Invoice invoice_info; Foodics.NetSuite.Shared.Model.InvoiceItem itemDetails; DateTime invoice_date; Invoice invoiceObject; InvoiceItem invoiceItemObject; InvoiceItemList items; RecordRef subsid, currency, entity, location; StringCustomFieldRef FoodicsRef, FoodicsNumb, CreatedBy, Source, orderDiscount; CustomFieldRef[] customFieldRefArray; #endregion for (int i = 0; i < invoiceLst.Count; i++) { try { List <Foodics.NetSuite.Shared.Model.InvoiceItem> itemLst = new List <Foodics.NetSuite.Shared.Model.InvoiceItem>(); List <InvoiceItem> invoiceItems = new List <InvoiceItem>(); invoice_info = invoiceLst[i]; Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + invoice_info.Subsidiary_Id).FirstOrDefault(); invoiceObject = new Invoice(); #region invoice items itemLst = new GenericeDAO <Foodics.NetSuite.Shared.Model.InvoiceItem>().GetWhere(" ProductStatus =3 and Invoice_Id =" + invoice_info.Id + " and isnull(Item_Id,0) >0 "); try { for (int k = 0; k < itemLst.Count; k++) { itemDetails = itemLst[k]; invoiceItemObject = CreateInvoiceItem(objSetting, itemDetails); invoiceItems.Add(invoiceItemObject); if (itemDetails.Line_Discount_Amount > 0) { float Discount = itemDetails.Line_Discount_Amount; Foodics.NetSuite.Shared.Model.InvoiceItem OtherCharge = new Foodics.NetSuite.Shared.Model.InvoiceItem(); OtherCharge.Item_Id = objSetting.OtherChargeItem_Netsuite_Id; OtherCharge.Amount = Discount * -1; OtherCharge.Quantity = 1; OtherCharge.Item_Type = nameof(Item_Type.OtherChargeSaleItem); invoiceItemObject = CreateInvoiceItem(objSetting, OtherCharge); invoiceItems.Add(invoiceItemObject); } } //if (invoice_info.Total_Discount > 0) //{ // float Discount = invoice_info.Total_Discount; // Foodics.NetSuite.Shared.Model.InvoiceItem discountItem = new Foodics.NetSuite.Shared.Model.InvoiceItem(); // if (invoice_info.Discount_Id > 0) // discountItem.Item_Id = invoice_info.Discount_Id; // else // discountItem.Item_Id = objSetting.DiscountItem_Netsuite_Id; // discountItem.Amount = Discount * -1; // //discountItem.Quantity = 1; // discountItem.Item_Type = nameof(Item_Type.DiscountItem); // invoiceItemObject = CreateInvoiceItem(objSetting, discountItem); // invoiceItems.Add(invoiceItemObject); //} } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } //Assign invoive items items = new InvoiceItemList(); items.item = invoiceItems.ToArray(); invoiceObject.itemList = items; //GiftCertRedemption #endregion #region Standard Attributes invoice_date = TimeZoneInfo.ConvertTimeToUtc(invoice_info.Date, TimeZoneInfo.Local); //invoiceObject.externalId = invoice_info.BarCode; invoiceObject.tranDateSpecified = true; invoiceObject.dueDateSpecified = true; invoiceObject.tranDate = invoice_date; invoiceObject.dueDate = invoice_date; invoiceObject.exchangeRate = invoice_info.Exchange_Rate; //invoiceObject.memo = invoice_info.Notes; if (invoice_info.Subsidiary_Id > 0) { subsid = new RecordRef(); subsid.internalId = objSetting.Subsidiary_Netsuite_Id.ToString(); subsid.type = RecordType.subsidiary; invoiceObject.subsidiary = subsid; } currency = new RecordRef(); currency.internalId = objSetting.Currency_Netsuite_Id.ToString(); currency.type = RecordType.currency; invoiceObject.currency = currency; entity = new RecordRef(); entity.internalId = invoice_info.Customer_Netsuite_Id > 0 ? invoice_info.Customer_Netsuite_Id.ToString() : objSetting.Customer_Netsuite_Id.ToString(); entity.type = RecordType.customer; invoiceObject.entity = entity; location = new RecordRef(); location.internalId = invoice_info.Location_Id.ToString(); //objSetting.Location_Netsuite_Id.ToString(); location.type = RecordType.location; invoiceObject.location = location; if (invoice_info.Sales_Rep_Id > 0) { RecordRef sales_rep = new RecordRef(); sales_rep.internalId = invoice_info.Sales_Rep_Id.ToString(); sales_rep.type = RecordType.employee; invoiceObject.salesRep = sales_rep; } #endregion #region Discount if (invoice_info.Total_Discount > 0) { RecordRef discountitem = new RecordRef(); discountitem.type = RecordType.discountItem; invoiceObject.discountItem = discountitem; float taxRate = 1 + (objSetting.TaxRate / 100); if (objSetting.TaxAlwaysAppliedInItems) { invoiceObject.discountRate = (Math.Round((invoice_info.Total_Discount / taxRate), 3) * -1).ToString(); } else { //if (objSetting.ItemTaxInclusive) // invoiceObject.discountRate = (Math.Round((invoice_info.Total_Discount / taxRate), 3) * -1).ToString(); //else invoiceObject.discountRate = (Math.Round(invoice_info.Total_Discount, 3) * -1).ToString(); } if (invoice_info.Discount_Id > 0) { discountitem.internalId = invoice_info.Discount_Id.ToString(); } else { discountitem.internalId = objSetting.DiscountItem_Netsuite_Id.ToString(); } } else { invoiceObject.discountRate = "0"; } orderDiscount = new StringCustomFieldRef(); orderDiscount.scriptId = "custbody_da_invoice_discount"; orderDiscount.value = invoice_info.Total_Discount.ToString(); //if (invoice_info.Accounting_Discount_Item != 0) //{ // RecordRef discItem = new RecordRef(); // discItem.internalId = invoice_info.Accounting_Discount_Item.ToString(); // discItem.type = RecordType.discountItem; // invoiceObject.discountItem = discItem; //} #endregion //RecordRef Approval = new RecordRef(); //Approval.internalId = "2"; ////Approval.type = RecordType.; //invoiceObject.approvalStatus = Approval; #region Invoice Custom Attributes FoodicsRef = new StringCustomFieldRef(); FoodicsRef.scriptId = "custbody_da_foodics_reference"; FoodicsRef.value = invoice_info.BarCode.ToString(); FoodicsNumb = new StringCustomFieldRef(); FoodicsNumb.scriptId = "custbody_da_foodics_number"; FoodicsNumb.value = invoice_info.Number.ToString(); CreatedBy = new StringCustomFieldRef(); CreatedBy.scriptId = "custbody_da_foodics_createdby"; CreatedBy.value = invoice_info.CreatedBy != null?invoice_info.CreatedBy.ToString() : ""; Source = new StringCustomFieldRef(); Source.scriptId = "custbody_da_foodics_source"; Source.value = invoice_info.Source.ToString(); customFieldRefArray = new CustomFieldRef[5]; customFieldRefArray[0] = orderDiscount; customFieldRefArray[1] = FoodicsRef; customFieldRefArray[2] = FoodicsNumb; customFieldRefArray[3] = CreatedBy; customFieldRefArray[4] = Source; invoiceObject.customFieldList = customFieldRefArray; #endregion InvoiceArr[i] = invoiceObject; } catch (Exception ex) { //invoiceLst.RemoveAt(i); LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } } // Send invoice list to netsuite WriteResponseList wr = Service(true).addList(InvoiceArr); result = wr.status.isSuccess; if (result) { //Update database with returned Netsuite ids UpdatedInvoice(invoiceLst, wr); } } } } } catch (Exception ex) { LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message); } return(0); }