0

have using Netsuite Webservice Logic Code. I want to convert Invoice to Customer payment.In the below code is working fine but I am seeing unexpected error

InitializeRecord ir = new InitializeRecord(); ir.type = InitializeType.customerPayment;

        InitializeRef iref = new InitializeRef();
        iref.typeSpecified = true;
        iref.type = InitializeRefType.invoice;
        iref.internalId = invoiceno; //4845
        ir.reference = iref;

customerPayment = new CustomerPayment();

            string paymentmethodID = NSSearchRecord.SearchPaymentMethod(NSConstants.NSCashMethod);

            ((CustomerPayment)record).externalId = "4845"; //externalID;
            ((CustomerPayment)record).customer = new RecordRef() { internalId = "4845", typeSpecified = true };
            //((CustomerPayment)record).customer = new RecordRef() { internalId = "4845", typeSpecified = true };
            ((CustomerPayment)record).tranDate =Convert.ToDateTime("01/08/2023");// transDate;
            ((CustomerPayment)record).tranDateSpecified = true;
            ((CustomerPayment)record).tranId = "4845";// transnumber;
            ((CustomerPayment)record).currency =new  RecordRef() { internalId = "1", typeSpecified = true };// currencyId;
            ((CustomerPayment)record).exchangeRate = 1;// exchangerate;
            ((CustomerPayment)record).payment = 10;// totalAmount;
            ((CustomerPayment)record).paymentSpecified = true;
            ((CustomerPayment)record).paymentMethod = new RecordRef() { internalId = "1", typeSpecified = true }; //paymentmethodID
            //((CustomerPayment)record).account = new RecordRef() { internalId = "381", typeSpecified = true };
            ((CustomerPayment)record).arAcct = new RecordRef() { internalId = "381", typeSpecified = true };

            ((CustomerPayment)record).applyList.apply[0].amount = 10;
            ((CustomerPayment)record).applyList.apply[0].amountSpecified = true;

            WriteResponse response = Client.Service.add(customerPayment);
            if (null != response.status && response.status.isSuccess)
            {
                string strClientID = ((RecordRef)response.baseRef).internalId;
                Console.WriteLine("Payemnt Invoice created successfully: " + strClientID);
                
            }
       

Anybody one helps me to resolve it.

0 Answers0