public async Task <InvoicePreview> PostInvoicesPreview(int ownerId, string IsoAlpha3Code = "USA")
        {
            InvoicePreview ret = new InvoicePreview();

            try
            {
                // get a invoice
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                List <InvoiceWithItems> invoices = await GetAccountInvoices(accounts.First().Id.ToString());

                // preview invoice
                InvoicePreviewCriteria   crtieria = BuildInvoicePreviewCriteriaFromInvoice(ownerCollection, invoices.First(), IsoAlpha3Code);
                RestRequestSpecification req      = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/invoices/previews";
                req.Content     = JsonSerializer.Serialize(crtieria);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <InvoicePreview>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
Beispiel #2
0
        public async Task InvoicesPreviewTest()
        {
            ownerId = EnrollTestSettings.Default.AccountUpdateTestOwnerId;
            InvoicePreview respond = await billingRestClient.PostInvoicesPreview(ownerId);

            Assert.IsNotNull(respond, $"failed to preview invoice");
            Assert.IsTrue(respond.Items.First().ChargeName.Equals("Pet Insurance Monthly Premium"), $"unexpected item - {respond}");
        }
Beispiel #3
0
        public async Task InvoicesPreview_success()
        {
            request.Content = JsonSerializer.Serialize(previewCriteria);
            invoicesResult  = await asyncRestClientBilling.ExecuteAsync <string>(request);

            Assert.IsNotNull(invoicesResult.Success, $"failed to restclient get from billing service");
            InvoicePreview preview = JsonSerializer.Deserialize <InvoicePreview>(((RestResult <string>)invoicesResult).Value);

            Assert.IsTrue(preview.Items.First().ChargeName.Equals("Pet Insurance Monthly Premium"), $"unexpected item - {preview}");
        }
        public async Task <IActionResult> GenerateInvoice(string id)
        {
            var invHtml = await this.invoicesService.GenerateInvoiceHtml(id);

            var invModel = new InvoicePreview {
                Html = invHtml, InvoiceId = id
            };

            return(this.View(invModel));
        }