1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

remove jsreport pdfs. use stripe invoice pages.

This commit is contained in:
Kyle Spearrin
2018-09-13 16:03:04 -04:00
parent ecd569fa0b
commit 18131ba1e3
7 changed files with 13 additions and 276 deletions

View File

@ -1,76 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Models.Table;
using Stripe;
namespace Bit.Api.Models
{
public class InvoiceModel
{
public InvoiceModel(Organization organization, StripeInvoice invoice, ApiSettings apiSettings)
{
OurAddress1 = apiSettings.OurAddress1;
OurAddress2 = apiSettings.OurAddress2;
OurAddress3 = apiSettings.OurAddress3;
CustomerName = organization.BusinessName ?? "--";
CustomerAddress1 = organization.BusinessAddress1;
CustomerAddress2 = organization.BusinessAddress2;
CustomerAddress3 = organization.BusinessAddress3;
CustomerCountry = organization.BusinessCountry;
CustomerVatNumber = organization.BusinessTaxNumber;
InvoiceDate = invoice.Date?.ToLongDateString();
InvoiceDueDate = invoice.DueDate?.ToLongDateString();
InvoiceNumber = invoice.Number;
Items = invoice.StripeInvoiceLineItems.Select(i => new Item(i));
SubtotalAmount = (invoice.Total / 100).ToString("C");
VatTotalAmount = 0.ToString("C");
TotalAmount = SubtotalAmount;
Paid = invoice.Paid;
}
public string OurAddress1 { get; set; }
public string OurAddress2 { get; set; }
public string OurAddress3 { get; set; }
public string InvoiceDate { get; set; }
public string InvoiceDueDate { get; set; }
public string InvoiceNumber { get; set; }
public string CustomerName { get; set; }
public string CustomerVatNumber { get; set; }
public string CustomerAddress1 { get; set; }
public string CustomerAddress2 { get; set; }
public string CustomerAddress3 { get; set; }
public string CustomerCountry { get; set; }
public IEnumerable<Item> Items { get; set; }
public string SubtotalAmount { get; set; }
public string VatTotalAmount { get; set; }
public string TotalAmount { get; set; }
public bool Paid { get; set; }
public bool UsesVat => !string.IsNullOrWhiteSpace(CustomerVatNumber);
public class Item
{
public Item(StripeInvoiceLineItem item)
{
Amount = (item.Amount / 100).ToString("F");
if(!string.IsNullOrWhiteSpace(item.Description))
{
Description = item.Description;
}
else if(!string.IsNullOrWhiteSpace(item.Plan?.Nickname) && item.Quantity.GetValueOrDefault() > 0)
{
Description = $"{item.Quantity} x {item.Plan.Nickname}";
}
else
{
Description = "--";
}
}
public string Description { get; set; }
public string Amount { get; set; }
}
}
}