Pagos recibidos por SDK de sap

Hola Expertos,

Quisiera saber como se realizan los pagos recibidos por SDK,
Estoy usando Visual Studio 2015
SAP Business one 9.1

Hola.
Pues se hace con el objeto “Payments” de la DIAPI. Hay muchos ejemplos en la ayuda del SDK y los foros oficiales, aqui esta uno:

SAPbobsCOM.Payments downPayment;
 
                downPayment = (SAPbobsCOM.Payments)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);
 
                downPayment.DocObjectCode = BoPaymentsObjectType.bopot_OutgoingPayments;
 
                downPayment.CardCode = socioNegocio;
                downPayment.DocDate = pago.Fecha;
                downPayment.DocType = BoRcptTypes.rSupplier;
                downPayment.DocCurrency = pago.CodigoMoneda;
 
                downPayment.JournalRemarks = "PAGO " + socioNegocio.CardName;
                downPayment.Remarks = socioNegocio.CardName;
 
                //La variable *total*, contiene la suma de los importes que se aplicará a las facturas en el pago menos el importe de las notas de credito que se creen
 
                if (pago.TipoPago == TipoPagoPago.Efectivo)
                {
                    downPayment.CashSum = (double)total;
                }
                else if (pago.TipoPago == TipoPagoPago.Cheque)
                {
                    downPayment.Checks.CheckSum = (double)total;
                    downPayment.Checks.AccounttNum = pago.CodigoCuenta;
                    downPayment.Checks.BankCode = pago.CodigoBanco;
                    downPayment.Checks.CheckNumber = (int)pago.NumeroCheque.Value;
                    downPayment.Checks.DueDate = pago.Fecha;
                }
                else if (pago.TipoPago == TipoPagoPago.Deposito || pago.TipoPago == TipoPagoPago.Transferencia)
                {
                    downPayment.TransferAccount = pago.BancoCuenta.GLAccount;
                    downPayment.TransferSum = (double)total;
                }
 
                var line = 0;
                foreach (var pagoFactura in pago.Detalles)
                {
 
                    var folio = pagoFactura.Folio;
                    var monto = pagoFactura.Abono;  //El monto a aplicar de cada factura
                    var importeNC = pagoFactura.ImporteNC; //El monto de la nota de credito que se creará
 
                    if (monto > 0)
                    {
                        if (line != 0)
                        {
                            downPayment.Invoices.Add();
                        }
 
                        Se anexa el folio de la factura y su monto
 
                        downPayment.Invoices.DocEntry = folio;
                        downPayment.Invoices.InvoiceType = BoRcptInvTypes.it_PurchaseInvoice;
                        downPayment.Invoices.SumApplied = (double)monto;
 
                        line++;
                    }
                    if (importeNC > 0)
                    {
                        if (line != 0)
                        {
                            downPayment.Invoices.Add();
                        }
 
                        var nota = company.GetBusinessObject(BoObjectTypes.oPurchaseCreditNotes) as Documents;
 
                        var fecha = pago.Fecha;
 
                        nota .CardCode = socio;
                        nota .DocDate = fecha;
                        nota .DocDueDate = fecha;
                        nota .TaxDate = fecha;
                        nota .DocCurrency = pago.CodigoMoneda;
                        nota .Comments = "Nota de Credito de la factura " + folio.Split('-')[1];
                        nota .DocType = BoDocumentTypes.dDocument_Service;
 
                        nota.Lines.AccountCode = cuentaContableNC;
                        nota.Lines.ItemDescription = "DESCUENTO A PROVEEDORES";
                        nota.Lines.Quantity = 1;
                        nota.Lines.TaxCode = "TAX0";
                        nota.Lines.Price = (double)importeNC;
 
                        var statusNC = nota.Add();
                        if (statusNC != 0)
                        {
                            log.ErrorFormat("Error registering Nota credito {0} - {1} - {2}", pagoFactura.Codigo, statusNC, company.GetLastErrorDescription());
                            break;
                        }
                        var codigo = company.GetNewObjectKey();
                        nota.GetByKey(int.Parse(codigo));                     
 
                        //Una vez creada la nota, se anexa al pago con el monto de la nota
 
                        downPayment.Invoices.DocEntry = int.Parse(codigo);
                        downPayment.Invoices.InvoiceType = BoRcptInvTypes.it_PurchaseCreditNote;
                        downPayment.Invoices.SumApplied = -(double)importeNC;
                       line++;
 
                    }
                }
 
                var status = downPayment.Add();

Saludos.

3 Me gusta

Si hermano, gracias por tu respuesta

Este lo verifique pero ese ejemplo seria para pagos afectuados, yo requiero para pagos recibidos.

El cual intente realizar con este mismo codigo cambiando las siguientes lineas :

downPayment = (SAPbobsCOM.Payments)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);

downPayment.DocObjectCode = BoPaymentsObjectType.bopot_IncomingPayments;

Y si culmina el proceso, no me da error. Pero al momento de revisar en SAP en el modulo de Gestion de bancos -> Pagos recibidos -> Pagos recibidos
No se encuentra el pago que realice

1 me gusta
  • ¿Verificaste si la conexion de la DIAPI se esta haciendo hacia la empresa correcta?
  • ¿Consultaste la DB para ver si se esta registrando la informacion (SELECT * FROM ORCT T0 JOIN RCT2 T1 ON T0.DocNum = T1.DocNum)?

Si todavia no te funciona, intenta agregando un pago simple tipo:

Dim vPay As SAPbobsCOM.Payments = oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments)
        vPay.CardCode = "ACC" ' ENTER HERE A VALID CARDCODE
        vPay.CashAccount = "38110100" ' ENTER HERE A VALID CASH G/L ACCOUNT
        vPay.CashSum = 84 ' ENTER HERE A VALID AMOUNT (eg DocTotal)
        vPay.DocDate = Date.Today()
        vPay.VatDate = Date.Today()
        vPay.DueDate = Date.Today()
        vPay.TaxDate = Date.Today()
        vPay.LocalCurrency = BoYesNoEnum.tYES
 
        vPay.Invoices.DocEntry = 13 ' ENTER HERE THE INVOICE DOCENTRY
        vPay.Invoices.DocLine = 0
        vPay.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice
        vPay.Invoices.SumApplied = 84  ' ENTER HERE A VALID AMOUNT (eg DocTotal)
     
       If (vPay.Add() <> 0) Then
            MsgBox(oCompany.GetLastErrorDescription)
        End If

Saludos.

2 Me gusta

@GabrielGS muchas gracias por tu respuesta si me funciono pero todavia necesito ayuda,

Me estan indicando que al momento de realizar el pago no tiene que estar tildada la casilla de pago a cuenta.

Estoy buscando la manera y no encuentro, sabras como?(adjunto imagen)

2 Me gusta

Este tema se cerró automáticamente 7 días después del último post. No se permiten nuevas respuestas.