Skip to Content
0

AR Invoice + Payment through DI API

Mar 13, 2017 at 09:01 PM

285

avatar image

Hello everyone.

I have been working with invoice xml for a long time without any problems, but now I want to make invoice + payment directly through an xml. I really have no idea how to do it. I send the code where I currently upload only invoices. If someone wants to help me I would appreciate it very much.

Alvaro

using System;

using System.Data.SqlClient;

using ConectoresBO.Conectores;

namespace SAPBOConector.Documentos

{

public class oInvoice

{

public oInvoice(SAPbobsCOM.Documents oInvoice, SAPbobsCOM.Company sapCompany, Company company, int key, int index)

{

SQLAdapter sqlAdapter = company.Conector.SQLAdapter;

SAPbobsCOM.Documents invoice = (SAPbobsCOM.Documents)sapCompany .GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

int COUNT = 0;

SqlDataReader reader = sqlAdapter.ejecutarConsulta ("SELECT COUNT('A') FROM " + sapCompany.CompanyDB + ".dbo.OINV WHERE U_BKV_UID='" + oInvoice.UserFields.Fields.Item("U_BKV_UID").Value + "'");

if (reader.Read())

{

COUNT = reader.GetInt32(0);

}

if (COUNT == 0)

{

invoice.CardCode = oInvoice.CardCode;

invoice.TaxDate = oInvoice.TaxDate;

invoice.DocDate = oInvoice.DocDate;

invoice.DocDueDate = oInvoice.DocDueDate;

invoice.ShipToCode = oInvoice.ShipToCode;

invoice.UserFields.Fields.Item("U_BKV_UID").Value = oInvoice.UserFields.Fields.Item("U_BKV_UID").Value; invoice.UserFields.Fields.Item("U_BKV_Nombre").Value = oInvoice.UserFields.Fields.Item("U_BKV_Nombre").Value; invoice.UserFields.Fields.Item("U_BKV_Cedula").Value = oInvoice.UserFields.Fields.Item("U_BKV_Cedula").Value; invoice.UserFields.Fields.Item("U_BKV_Direccion").Value = oInvoice.UserFields.Fields.Item("U_BKV_Direccion").Value; invoice.UserFields.Fields.Item("U_BKV_Telefono").Value = oInvoice.UserFields.Fields.Item("U_BKV_Telefono").Value; invoice.UserFields.Fields.Item("U_BKV_Email").Value = oInvoice.UserFields.Fields.Item("U_BKV_Email").Value;

for (int i = 0; i < oInvoice.Lines.Count; i++)

{

oInvoice.Lines.SetCurrentLine(i);

invoice.Lines.SetCurrentLine(i);

char[] delimiterChars = { '.' };

string[] cantidad = oInvoice.Lines.Quantity.ToString().Split(delimiterChars); invoice.Lines.ItemCode = oInvoice.Lines.ItemCode;

invoice.Lines.Quantity = Convert.ToDouble(cantidad[0]);

invoice.Lines.WarehouseCode = oInvoice.Lines.WarehouseCode; invoice.Lines.ProjectCode = oInvoice.Lines.ProjectCode;

invoice.Lines.UseBaseUnits = SAPbobsCOM.BoYesNoEnum.tNO;

invoice.Lines.Add();

}

invoice.Add();

String Status = "";

if (sapCompany.GetLastErrorCode() != 0)

{

Status = "Error :" + sapCompany.GetLastErrorDescription().ToString();

}

else

{

Status = "Done";

Regards

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Edy Simon Mar 15, 2017 at 04:09 AM
0

Hi,

DI API does not provide method to create AR Inv + Payment.
You need to create the AR Invoice first, after successful then add the Payment Document for the newly created AR Invoice.

Regards
Edy

Share
10 |10000 characters needed characters left characters exceeded