Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9164

Problem creating payment draft SDK

$
0
0

Hi,

 

I am using the following code to create a paymentdraft but my problem is to link a invoice and receipt

 

oCompany = new SAPbobsCOM.Company();            Int32 lRetCode, temp, errCode;            String strDocEntry, errMsg;            String _mensaje = String.Empty;            try            {                #region MyRegion                Conectar();                SAPbobsCOM.Payments _borrador = oCompany.GetBusinessObject(BoObjectTypes.oPaymentsDrafts);                _borrador.DocObjectCode = BoPaymentsObjectType.bopot_IncomingPayments;                _borrador.DocType = BoRcptTypes.rCustomer;                _borrador.CardCode = cobranza.CodCliente;                 _borrador.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;                _borrador.DocDate = Convert.ToDateTime(cobranza.Fecha);                _borrador.DocCurrency = "BS";                #endregion                foreach (var item in cobranzaPago)                {                    if (item.FormaPago == "Deposito" || item.FormaPago == "Efectivo")                    {                        _borrador.CashAccount = _boConexion.CuentaEfectivo;// "1111001";                        _borrador.CashSum = Convert.ToDouble(Convert.ToDecimal(item.Monto)) + _borrador.CashSum;                                                                   }                    if (item.FormaPago == "Transferencia")                    {                        _borrador.TransferAccount = _boConexion.CuentaEfectivo; // "1111001";                        _borrador.TransferDate = DateTime.Now;                        _borrador.TransferSum = Convert.ToDouble(Convert.ToDecimal(item.Monto)) + _borrador.TransferSum;                         _borrador.TransferReference = item.CodDocumento + "-" + _borrador.TransferReference;                    }                    if (item.FormaPago == "Cheque")                    {                        _borrador.Checks.AccounttNum = _boConexion.CuentaEfectivo;                        _borrador.Checks.CheckAccount = _boConexion.CuentaEfectivo;                        _borrador.Checks.BankCode = item.CodBanco;                        _borrador.Checks.CheckSum = Convert.ToDouble(Convert.ToDecimal(item.Monto));                         _borrador.Checks.Details = "";                        _borrador.Checks.DueDate = DateTime.Now;                        _borrador.Checks.CheckNumber = System.Convert.ToInt32(item.CodDocumento);                        _borrador.Checks.Add();                    }                                   }                Int32 cuenta = 1;                foreach (var item in detallecobranza)                {                    #region MyRegion                    String _cadenax = String.Empty;                    String _numeroFactura = item.CodDocumento;                    if (item.TipoDocumento == "DI")                    {                        _borrador.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice;                        _cadenax = "Select DocEntry from OINV where docnum = '" + _numeroFactura + "'";                        String _docEntryFactura = DalClass.SeleccionarEscalar(_conexionXML, _cadenax);                        _borrador.Invoices.DocEntry = Convert.ToInt32(_docEntryFactura);                        _borrador.Invoices.SumApplied = System.Convert.ToDouble(item.MontoAbonado);                        _borrador.Invoices.DocLine = cuenta;                        _borrador.Invoices.Add();                    }                    if (item.TipoDocumento == "AD")                    {                        _borrador.Invoices.InvoiceType = BoRcptInvTypes.it_Receipt;                        _cadenax =  "select docentry from ORCT where docnum = '" + _numeroFactura + "'";                        String _docEntryPago = DalClass.SeleccionarEscalar(_conexionXML, _cadenax);                        _borrador.Invoices.DocEntry = Convert.ToInt32(_docEntryPago);                        _borrador.Invoices.SumApplied = System.Convert.ToDouble(item.MontoAbonado);                                               _borrador.Invoices.DocLine = cuenta;                        _borrador.Invoices.Add();                                            }                                        cuenta++;                                                                                                        #endregion                }                Program.log.Info("Registro cardcode " + _borrador.CardCode + " DocDate: " + _borrador.DocDate + " Total: "                    + _borrador.CashSum + " DocEntry: " + _borrador.Invoices.DocEntry);                                          lRetCode = _borrador.Add();                if (lRetCode != 0)                {                    oCompany.GetLastError(out errCode, out errMsg);                    _mensaje = "Error de SAP: " + errMsg;                }                else                {                    oCompany.GetNewObjectCode(out strDocEntry);                    temp = Convert.ToInt32(strDocEntry);                    _mensaje = "Documento con cardcode " +_borrador.CardCode + " fue creado con el número de documento preliminar "+ strDocEntry.ToString();                }                Program.log.Info(_mensaje);                listBoxProcesamiento.Items.Add(_mensaje);            }            catch (Exception ex)            {                _mensaje = ex.Message;                listBoxProcesamiento.Items.Add(_mensaje);                Program.log.Info(_mensaje);            }            return _mensaje;

I got this error

 

"Base document card and target document card do not match.  RCT2.DocLine]line: 1]"


Viewing all articles
Browse latest Browse all 9164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>