Example #1
0
        public async Task <IActionResult> InvoiceView([FromQuery] Guid invoiceId, IFormCollection formData)
        {
            var token = await _tokenService.GetAccessTokenAsync(User.XeroUserId());

            var connections = await _xeroClient.GetConnectionsAsync(token);

            var tenantId = connections[0].TenantId.ToString();

            Payment payment = new Payment()
            {
                Invoice = new Invoice()
                {
                    InvoiceID = invoiceId
                },
                Account = new Account()
                {
                    Code = "200"
                },
                Date   = DateTime.Now,
                Amount = double.Parse(formData["amount"])
            };

            await _accountingApi.CreatePaymentAsync(token.AccessToken, tenantId, payment);

            return(RedirectToAction("Index"));
        }
Example #2
0
        private async Task InvoicePayment(string accessToken, string tenantId, Guid?accid)
        {
            var draftinvoicelist = new List <Invoice>();
            //var outstandingInvoices = await _accountingApi.GetInvoicesAsync(accessToken, tenantId, statuses: new List<string> { "DRAFT" }, where: "Type == \"ACCREC\"");
            var outstandingInvoices = await _accountingApi.GetInvoicesAsync(accessToken, tenantId, where : "Type == \"ACCREC\"");

            foreach (var o in outstandingInvoices._Invoices)
            {
                Console.WriteLine("Invoice Number :" + o.InvoiceNumber + " Amount Due :" + o.AmountDue + " STATUS :" + o.Status);
                if (o.InvoiceNumber.Contains("VER3_"))
                {
                    Payment paymentToChangeStatus = new Payment
                    {
                        Invoice = new Invoice
                        {
                            InvoiceID = o.InvoiceID,
                        },
                        Account = new Account
                        {
                            AccountID = accid
                        },
                        Amount = 1
                    };
                    try
                    {
                        var x = await _accountingApi.CreatePaymentAsync(accessToken, tenantId, paymentToChangeStatus);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }
        public async Task <IActionResult> Create(FromFormAttribute formData)
        {
            var token = await _tokenService.GetAccessTokenAsync(User.XeroUserId());

            var connections = await _xeroClient.GetConnectionsAsync(token);

            var tenantId = connections[0].TenantId.ToString();

            Payment payment = new Payment()
            {
                Invoice = new Invoice()
                {
                    InvoiceNumber = "INV-0002"
                },
                Account = new Account()
                {
                    Code = "200"
                },
                Date   = DateTime.Now,
                Amount = 3
            };

            await _accountingApi.CreatePaymentAsync(token.AccessToken, tenantId, payment);

            return(RedirectToAction("Index", "Invoices"));
        }