Centarra/panel2 — pull request #24 by nasonfish (2014-04-26 02:40:01+00:00)
Title: Add timestamps to the invoice view page; Add categories to invoices

This is in a pull request so a database update can occur.

Categories were added to `InvoiceItem`s to indicate the cause of each item, without having to dig through descriptions.

```sql
ALTER TABLE `invoice_item`
ADD `category` STRING;
```

Next, something big for the database likely has to occur to update past tickets to include categories.

```python

from panel2 import db

items = {
"PayPal Payment": "Paypal payment",
"Bitcoin": "Coinbase payment",
"Stripe Payment": "Stripe payment",
"Service credit (per": "Service credit",
"Add Service Credit": "Add service credit",
"Service Credit -": "Applied credit",
"Prepaid Credit": "Prepaid credit",
"renewal": "Service renewal"
}

for item in InvoiceItem.query.all():
for i in items:
if i in item.description:
item.category = items[i]
db.session.add(item)
continue
item.category = "Custom line item"
db.session.add(item)
db.session.commit()
```

Let me know if this idea is stupid or useless, or if the category names are weird.