public void MoveBetweenAccount() { using (var client = CreateClient()) { var accountRef = new AccountRef { AppAccountId = UserId }; var payment = new Payment { Amount = AMOUNT, Beneficiary = accountRef, Message = "Test -" + TimedId }; var result = client.PostPayment(payment, CHARGED_USER_ID); Assert.IsNotNull(result); Assert.AreEqual(CHARGED_USER_ID, result.Sender.AppAccountId); accountRef.AppAccountId = CHARGED_USER_ID; result = client.PostPayment(payment, UserId); Assert.IsNotNull(result); Assert.AreEqual(UserId, result.Sender.AppAccountId); } }
private void Post() { if (chkReport.IsChecked != true) { return; } if (string.IsNullOrWhiteSpace(Token)) { return; } var httpClient = new HttpClient(); var client = MantisHTTPClientFactory.New( Url, Token, httpClient ); var user = client.UserGetMe(); var account = new AccountRef { Name = user.Name, Id = user.Id, Email = user.Email }; var projectRef = user.Projects.FirstOrDefault(p => p.Name == Project); if (projectRef == null) { return; } var project = new Identifier { Id = projectRef.Id, Name = projectRef.Name, }; var category = new Identifier { Id = 0, Name = "General" }; var issue = new Issue { Summary = "[" + Exception.Source + "]" + Exception.Message, Reporter = account, Project = project, Category = category, Description = txtComment.Text, Additional_information = Exception.StackTrace, }; client.IssueAdd(issue); }
public XElement GenerateAddRq() { XElement Add = new XElement(nameof(ExpenseLine) + "Add"); Add.Add(AccountRef.ToQBXML(nameof(AccountRef))); Add.Add(Amount.ToQBXML(nameof(Amount))); Add.Add(Memo.ToQBXML(nameof(Memo))); Add.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); Add.Add(ClassRef.ToQBXML(nameof(ClassRef))); Add.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); Add.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); Add.Add(DataExt.ToQBXML(nameof(DataExt))); return(Add); }
public XElement GenerateModRq() { XElement Mod = new XElement(nameof(ExpenseLine) + "Mod"); Mod.Add(TxnLineID.ToQBXML(nameof(TxnLineID))); Mod.Add(AccountRef.ToQBXML(nameof(AccountRef))); Mod.Add(Amount.ToQBXML(nameof(Amount))); Mod.Add(Memo.ToQBXML(nameof(Memo))); Mod.Add(CustomerRef.ToQBXML(nameof(CustomerRef))); Mod.Add(ClassRef.ToQBXML(nameof(ClassRef))); Mod.Add(BillableStatus.ToQBXML(nameof(BillableStatus))); Mod.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef))); return(Mod); }
public string toXmlAdd() { if (Amount > 0) { string xml = Environment.NewLine + "<ExpenseLineAdd>"; if (AccountRef != null) { xml += Environment.NewLine + AccountRef.toXmlRef(); } System.Globalization.CultureInfo myInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"); xml += Environment.NewLine + "<Amount>" + Amount.ToString("0.00", myInfo) + "</Amount>"; if (Memo != string.Empty) { xml += Environment.NewLine + "<Memo>" + Memo + "</Memo>"; } if (CustomerRef != null) { xml += CustomerRef.toXmlRef(); } if (ClassRef != null) { xml += ClassRef.toXmlRef(); } if (BillableStatus != null && BillableStatus != string.Empty) { xml += Environment.NewLine + "<BillableStatus>" + BillableStatus + "</BillableStatus> "; } xml += Environment.NewLine + "</ExpenseLineAdd>"; return(xml); } else { return(string.Empty); } }
private void ProcessInvoice(VendIvc invoice, ApexDataDataContext apexData) { PO po = apexData.POs.Where(s => s.Po1 == invoice.PO).SingleOrDefault(); //get the corresponding P/O if (po == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "The invoice points to an invalid P/O!?" }); return; } if (po.Vendor == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "There is no vendor on this P/O" }); return; } Job job = apexData.Jobs.Where(s => s.Job1 == po.Job).SingleOrDefault(); //get the job if (job == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "There is no job on this P/O" }); return; } QBJob qbjob = apexData.QBJobs.Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexJobID == po.Job).SingleOrDefault(); if (qbjob == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "This P/O has an invalid QuickBooks job reference" }); return; } QBVendor qbvendor = apexData.QBVendors.Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexVendorID == po.Vendor).SingleOrDefault(); if (qbvendor == null) { _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = "This P/O has an invalid QuickBooks vendor reference" }); return; } var qbxml = new QBXML(); qbxml.ItemsElementName = new ItemsChoiceType99[1] { ItemsChoiceType99.QBXMLMsgsRq }; var qbMsgsRq = new QBXMLMsgsRq(); qbMsgsRq.onError = QBXMLMsgsRqOnError.continueOnError; var billaddrq = new BillAddRqType(); billaddrq.requestID = "1"; TermsRef termsref = new TermsRef { FullName = po.VendorTerms }; string ApexGLRef = apexData.Costcodes .Where(s => s.Schedule == "STD" && s.CostCode1 == po.POLines.Select(l => l.CostCode).FirstOrDefault()) .Select(s => s.GL).FirstOrDefault(); if (String.IsNullOrEmpty(ApexGLRef)) { ApexGLRef = "M"; } string QBGLAcctFullName = GLAcctUtility.GLAcctList .Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexGLRef == ApexGLRef) .Select(s => s.QBGLAcctFullName).SingleOrDefault(); AccountRef accountref = new AccountRef { FullName = QBGLAcctFullName }; AccountRef creditaccountref = new AccountRef { FullName = "Cash Discount on Payables" }; //Classes in QuickBooks equate to Divisions in Apex for this client ClassRef classref = new ClassRef { FullName = apexData.Divisions.Where(s => s.Company == po.Company && s.Division1 == po.Division).Select(s => s.Name).SingleOrDefault() }; CustomerRef customerref = new CustomerRef { ListID = qbjob.QBListID }; ExpenseLineAdd expenseline = new ExpenseLineAdd { AccountRef = accountref, Amount = invoice.IvcAmt?.ToString("F2"), CustomerRef = customerref, Memo = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':')) }; if (classref.FullName != null) { expenseline.ClassRef = classref; } ExpenseLineAdd[] expenseLines; if ((invoice.Discount ?? 0) != 0) //Add an expense line for the discount amount if the discount is not zero { ExpenseLineAdd creditexpenseline = new ExpenseLineAdd { AccountRef = creditaccountref, Amount = (0 - invoice.Discount ?? 0).ToString("F2"), ClassRef = classref, Memo = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':')) }; expenseLines = new ExpenseLineAdd[2]; expenseLines[0] = expenseline; expenseLines[1] = creditexpenseline; } else { expenseLines = new ExpenseLineAdd[1]; expenseLines[0] = expenseline; } VendorRef vendorref = new VendorRef { ListID = qbvendor.QBListID }; var billadd = new BillAdd { DueDate = invoice.PayDate?.ToString("yyyy-MM-dd"), Memo = "From Apex", RefNumber = invoice.Invoice, TermsRef = termsref, TxnDate = invoice.IvcDate?.ToString("yyyy-MM-dd"), ExpenseLineAdd = expenseLines, VendorRef = vendorref }; qbMsgsRq.Items = new object[1] { billaddrq }; qbxml.Items = new object[1] { qbMsgsRq }; billaddrq.BillAdd = billadd; XmlSerializer serializer = new XmlSerializer(typeof(QBXML)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); //Don't use a namespace in the XML for QuickBooks MemoryStream ms = new MemoryStream(); serializer.Serialize(ms, qbxml, ns); ms.Seek(0, SeekOrigin.Begin); var sr = new StreamReader(ms); string xmlRequest = sr.ReadToEnd(); xmlRequest = xmlRequest.Replace("<?xml version=\"1.0\"?>", "<?xml version=\"1.0\"?><?qbxml version=\"4.0\"?>"); if (DEBUGMODE) { File.WriteAllText("c:\\QB\\BillAddQBXML.xml", xmlRequest); } _Response = _Rp.ProcessRequest(_Ticket, xmlRequest); if (DEBUGMODE) { File.WriteAllText("c:\\QB\\BillAddResponse.xml", _Response); } QBXML rsXML = GetQbxml(serializer); string message = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusMessage; string statuscode = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusCode; _StatusLines.Add(new StatusLine { Invoice = invoice.Invoice, PO = invoice.PO.Trim(), Message = message, StatusCode = statuscode }); if (statuscode == "0") //Apex's part is done now that the invoice has been successfully sent to QuickBooks to be paid { QBInvoice qbIvc = new QBInvoice { Invoice = invoice.Invoice, PO = invoice.PO, SentDate = DateTime.Now }; apexData.QBInvoices.InsertOnSubmit(qbIvc); invoice.IvcStatus = "P"; apexData.SubmitChanges(); } }