internal static void VerifyBillPayment_BillPaymentCheck(BillPayment billPaymentAdded, BillPayment billPaymentToAdd) { Assert.IsNotNull(billPaymentToAdd); Assert.IsNotNull(billPaymentAdded); Assert.IsNotNull(billPaymentAdded.CurrencyRef); Assert.IsNotNull(billPaymentAdded.VendorRef); BillPaymentCheck billPayment_BillPaymentCheckToAdd = (BillPaymentCheck)billPaymentToAdd.AnyIntuitObject; BillPaymentCheck billPayment_BillPaymentCheckAdded = (BillPaymentCheck)billPaymentAdded.AnyIntuitObject; Assert.AreEqual(billPayment_BillPaymentCheckAdded.BankAccountRef.name.ToString(), billPayment_BillPaymentCheckToAdd.BankAccountRef.name.ToString()); Assert.AreEqual(billPayment_BillPaymentCheckAdded.BankAccountRef.Value.ToString(), billPayment_BillPaymentCheckToAdd.BankAccountRef.Value.ToString()); Assert.AreEqual(billPaymentAdded.PayType.ToString(), billPaymentToAdd.PayType.ToString()); }
internal static BillPayment CreateBillPayment_CheckPayment() { BillPayment billPayment = new BillPayment(); Vendor vendor = new Vendor(); //vendor.DisplayName = "00124a1f-ff2a-41ad-b3f9-8"; vendor.Id = "35"; BillPaymentCheck billPaymentCheck = new BillPaymentCheck(); billPaymentCheck.BankAccountRef = new ReferenceType() { //name = "Bank (1091836770)", Value = "136" }; CheckPayment checkPayment = new CheckPayment(); checkPayment.AcctNum = "AcctNum" + GetGuid().Substring(0, 5); checkPayment.BankName = "BankName" + GetGuid().Substring(0, 5); checkPayment.CheckNum = "CheckNum" + GetGuid().Substring(0, 5); checkPayment.NameOnAcct = "Name" + GetGuid().Substring(0, 5); checkPayment.Status = "Status" + GetGuid().Substring(0, 5); billPaymentCheck.CheckDetail = checkPayment; PhysicalAddress payeeAddr = new PhysicalAddress(); payeeAddr.Line1 = "Line 1"; payeeAddr.Line2 = "Line 2"; payeeAddr.City = "Mountain View"; payeeAddr.CountrySubDivisionCode = "CA"; payeeAddr.PostalCode = "94043"; billPaymentCheck.PayeeAddr = payeeAddr; billPaymentCheck.PrintStatus = PrintStatusEnum.NeedToPrint; billPaymentCheck.PrintStatusSpecified = true; List <Line> lineList = new List <Line>(); Line line1 = new Line(); //line.LineNum = "LineNum"; //line.Description = "Description"; line1.Amount = 100; line1.AmountSpecified = true; List <LinkedTxn> LinkedTxnList1 = new List <LinkedTxn>(); LinkedTxn linkedTxn1 = new LinkedTxn(); linkedTxn1.TxnId = "547"; linkedTxn1.TxnType = TxnTypeEnum.Bill.ToString(); LinkedTxnList1.Add(linkedTxn1); line1.LinkedTxn = LinkedTxnList1.ToArray(); lineList.Add(line1); billPayment.AnyIntuitObject = billPaymentCheck; billPayment.PayType = BillPaymentTypeEnum.Check; billPayment.PayTypeSpecified = true; billPayment.Line = lineList.ToArray(); billPayment.TotalAmt = 100; billPayment.TotalAmtSpecified = true; billPayment.VendorRef = new ReferenceType() { //name = vendor.DisplayName, Value = vendor.Id }; return(billPayment); }
public JsonResult MakePaymentData(PaymentModel objPaymentModel, PaymentModel ObjData) { eTracLoginModel ObjLoginModel = null; long Vendor = 0; var result = ""; var resultPayment = new BillPayment(); if (Session["eTrac"] != null) { ObjLoginModel = (eTracLoginModel)(Session["eTrac"]); } try { if (objPaymentModel != null && ObjData != null) { objPaymentModel.UserId = ObjLoginModel.UserId; string realmId = CallbackController.RealMId.ToString(); // Session["realmId"].ToString(); try { if (realmId != null) { string AccessToken = CallbackController.AccessToken.ToString(); //Session["access_token"].ToString(); var principal = User as ClaimsPrincipal; OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(AccessToken); // Create a ServiceContext with Auth tokens and realmId ServiceContext serviceContext = new ServiceContext(realmId, IntuitServicesType.QBO, oauthValidator); serviceContext.IppConfiguration.MinorVersion.Qbo = "23"; DataService commonServiceQBO = new DataService(serviceContext); // Create a QuickBooks QueryService using ServiceContext QueryService <Vendor> querySvc = new QueryService <Vendor>(serviceContext); List <Vendor> vendorList = querySvc.ExecuteIdsQuery("SELECT * FROM Vendor MaxResults 1000").ToList(); QueryService <Account> querySvcAccount = new QueryService <Account>(serviceContext); List <Account> accountData = querySvcAccount.ExecuteIdsQuery("SELECT * FROM Account MaxResults 1000").ToList(); var VendorDetails = _IVendorManagement.GetCompanyQuickBookId(Convert.ToInt64(ObjData.VendorId)); //var getAccountDetails = _IVendorManagement.GetAccountDetailsByVendorId(Convert.ToInt64(objPaymentModel.OpeartorCAD_Id)); // (Convert.ToInt64(ObjData.VendorId)); var getAccountDetails = _IVendorManagement.GetAccountDetailsByVendorId(Convert.ToInt64(objPaymentModel.CompanyAccountId)); // (Convert.ToInt64(ObjData.VendorId)); var getBill = _IBillDataManager.GetBillQBKId(Convert.ToInt64(ObjData.BillNo)); QueryService <Bill> querySvcBill = new QueryService <Bill>(serviceContext); List <Bill> billData = querySvcBill.ExecuteIdsQuery("SELECT * FROM Bill MaxResults 1000").ToList(); var bill = billData.Where(x => x.Id == getBill.ToString()).FirstOrDefault(); // var vendorData = vendorList.Where(x => x.Id == "64").FirstOrDefault(); var payment = new BillPayment(); //Vendor Reference var reference = new ReferenceType(); var accountRef = new AccountBasedExpenseLineDetail(); var billPaymentCheck = new BillPaymentCheck(); var billPaymentCredit = new BillPaymentCreditCard(); var line = new Line(); var lineList = new List <Line>(); if (VendorDetails > 0) { var vendorData = vendorList.Where(x => x.Id == VendorDetails.ToString()).FirstOrDefault(); //Vendor Reference payment.VendorRef = new ReferenceType() { name = vendorData.DisplayName, Value = vendorData.Id }; } line.LineNum = "1"; var any = new IntuitAnyType(); if (getAccountDetails != null) { var ayintuit = new IntuitAnyType(); var accountsDetails = accountData.Where(x => x.Id == getAccountDetails.QuickbookAcountId.ToString()).FirstOrDefault();//getAccountDetails.QuickbookAcountId.ToString() if (ObjData.PaymentMode == "Wired") { payment.PayType = BillPaymentTypeEnum.CreditCard; var CCD = new CreditCardPayment(); billPaymentCredit.CCAccountRef = new ReferenceType() { name = accountsDetails.Name, Value = accountsDetails.Id, }; payment.AnyIntuitObject = billPaymentCredit; } else if (ObjData.PaymentMode == "Card") { payment.PayType = BillPaymentTypeEnum.CreditCard; var CCD = new CreditCardPayment(); billPaymentCredit.CCAccountRef = new ReferenceType() { name = accountsDetails.Name, Value = accountsDetails.Id, }; payment.AnyIntuitObject = billPaymentCredit; } else if (ObjData.PaymentMode == "Check") { var checking = new CheckPayment(); payment.PayType = BillPaymentTypeEnum.Check; billPaymentCheck.BankAccountRef = new ReferenceType() { name = accountsDetails.Name, Value = accountsDetails.Id }; billPaymentCheck.PrintStatus = PrintStatusEnum.NeedToPrint; payment.AnyIntuitObject = billPaymentCheck; } } payment.APAccountRef = new ReferenceType() { name = "Accounts Payable (A/P)", Value = "33" }; QueryService <Department> querySvcDept = new QueryService <Department>(serviceContext); var LocationName = _IBillDataManager.GetLocationDataByLocId(Convert.ToInt64(ObjData.LocationId)); payment.DepartmentRef = new ReferenceType() { name = LocationName.LocationName, Value = LocationName.QBK_Id.ToString() }; line.Amount = Convert.ToDecimal(ObjData.BillAmount); line.AmountSpecified = true; var linkedlist = new List <LinkedTxn>(); var linked = new LinkedTxn(); linked.TxnId = bill.Id; linked.TxnType = "Bill"; linkedlist.Add(linked); line.LinkedTxn = linkedlist.ToArray(); line.DetailType = LineDetailTypeEnum.PaymentLineDetail; lineList.Add(line); payment.Line = lineList.ToArray(); //payment.PayType = BillPaymentTypeEnum.CreditCard; payment.PayTypeSpecified = true; payment.TotalAmt = Convert.ToDecimal(ObjData.BillAmount); payment.TotalAmtSpecified = true; var metaData = new ModificationMetaData(); metaData.CreateTime = Convert.ToDateTime(ObjData.BillDate); payment.MetaData = metaData; payment.PayTypeSpecified = true; resultPayment = commonServiceQBO.Add(payment) as BillPayment; //To close PO after Payment. Update Payment in Quickbook. QueryService <PurchaseOrder> querySvcPO = new QueryService <PurchaseOrder>(serviceContext); List <PurchaseOrder> POList = querySvcPO.ExecuteIdsQuery("SELECT * FROM PurchaseOrder MaxResults 1000").ToList(); if (ObjData.BillType == "PO") { var getPOQData = _IPaymentManager.GetPODetails(objPaymentModel, ObjData); if (getPOQData.QuickBookPOId > 0) { var data = POList.Where(x => x.Id == getPOQData.QuickBookPOId.ToString()).FirstOrDefault(); data.POStatus = PurchaseOrderStatusEnum.Closed; var update = commonServiceQBO.Update(data) as PurchaseOrder; } } } else { ViewBag.Message = CommonMessage.FailureMessage(); result = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; return(Json(result, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; } result = _IPaymentManager.MakePayment(objPaymentModel, ObjData); if (result != null) { return(Json(result, JsonRequestBehavior.AllowGet)); } else { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; return(Json(result, JsonRequestBehavior.AllowGet)); } } else { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; } } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } //return null; return(Json(result, JsonRequestBehavior.AllowGet)); }