I am new to QuickBooks Application, I am integrating the same in my C# console application. I need to add Vendor bill payment using QBFC library, any kind of help or sample code would be appreciated.
Thanks
I am new to QuickBooks Application, I am integrating the same in my C# console application. I need to add Vendor bill payment using QBFC library, any kind of help or sample code would be appreciated.
Thanks
You can use the BillPaymentCheckAdd procedure for checks and BillPaymentCreditCardAdd procedure for credit card payments. You need to send in a list of bill transaction IDs where you want to apply the payment to. Below is a method that does that, assuming you already have the ListIDs for the payee (would be Vendor.ListID here), the AP account, and the bank account as well as the bill transaction IDs.
public class BillPayDetails
{
public string TxnId { get; set; }
public double Amount { get; set; }
}
public IBillPaymentCheckRet InsertBillPayment(string PayeeListId, string APAccountListId, string BankAccountListId, DateTime TxnDate, List<BillPayDetails> BillsTxnIds)
{
var qbSsnMgr = new QBSessionManager();
qbSsnMgr.OpenConnection("", "Your App Name");
qbSsnMgr.BeginSession("Your_QB_File_Name", ENOpenMode.omDontCare);
IMsgSetRequest rqMsgSet = qbSsnMgr.CreateMsgSetRequest("US", 13, 0);
rqMsgSet.Attributes.OnError = ENRqOnError.roeStop;
rqMsgSet.ClearRequests();
IBillPaymentCheckAdd billPaymentCheckAdd = rqMsgSet.AppendBillPaymentCheckAddRq();
billPaymentCheckAdd.PayeeEntityRef.ListID.SetValue(PayeeListId);
billPaymentCheckAdd.APAccountRef.ListID.SetValue(APAccountListId);
billPaymentCheckAdd.BankAccountRef.ListID.SetValue(BankAccountListId);
billPaymentCheckAdd.TxnDate.SetValue(TxnDate);
foreach(var txn in BillsTxnIds)
{
var applyTo = billPaymentCheckAdd.AppliedToTxnAddList.Append();
applyTo.TxnID.SetValue(txn.TxnId);
applyTo.PaymentAmount.SetValue(txn.Amount);
}
IMsgSetResponse rsMsgSet = qbSsnMgr.DoRequests(rqMsgSet);
qbSsnMgr.EndSession();
qbSsnMgr.CloseConnection();
IResponse res = rsMsgSet.ResponseList.GetAt(0);
if (res.StatusCode != 0 && res.StatusCode != 1)
throw (new ApplicationException($"{res.StatusCode}-{res.StatusMessage}"));
return res.Detail as IBillPaymentCheckRet;
}