on 12-01-2016 1:20 AM
Im trying to post to sap from my add on application payments with multiple invoice. Im using C# in developing my add on app.
Heres my code.
foreach (var i in pay.Details)
{
InvoiceHeader inv = new InvoiceHeader();
int r = 0;
inv = context.InvoiceHeaders.FirstOrDefault(x => x.Id == i.TransactionDocumentNo);
if (inv.IsPosted == "N") r = PostInvoice(inv);
if (r > 0) inv = context.InvoiceHeaders.FirstOrDefault(x => x.Id == i.TransactionDocumentNo);
_pay.Invoices.DocEntry = Convert.ToInt32(inv.DocumentNumber);
errCode = _pay.Add();
if (errCode != 0)
{
string _errMsg = "";
company.GetLastError(out errCode, out _errMsg);
}
else
{
var _p = context.PaymentHeaders.FirstOrDefault(x => x.Id == pay.Id);
_p.IsPosted = "Y";
_p.UpdatedBy = "SAP POSTING";
_p.UpdatedDate = DateTime.Now;
_p.DocumentNumber = docnum;
context.SaveChanges();
}
}
Hi Farrah,
For pay multiples invoices, use the object Invoices inside the payment object.
A piece of sample:
Payments oVendorPay = oCompany.GetBusinessObject(BoObjectTypes.oVendorPayments);
oVendorPay.CardCode = "your bp";
foreach(InvoiceInfo inv in lstInvoices)
{
if (oVendorPay.Invoices.DocEntry != 0)
oVendorPay.Invoices.Add();
oVendorPay.Invoices.DocEntry = inv.DocEntry; //The primary key of your document
oVendorPay.Invoices.InvoiceType = inv.InvType; //The type of the document that you are paying
oVendorPay.Invoices.InstallmentId = inv.InstallmentId; //Use this property if you refer a installment of a document
// oVendorPay.Invoices.DocLine = 0; //Use this property if you are paying a journal entry, this property specifies what line you are paying
oVendorPay.Invoices.SumApplied = inv.InstallmentValue; //The value that you are paying
}
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.