Merge remote-tracking branch 'origin/master' into ncc1701
Conflicts: endpoints/web.py static/directives/signup-form.html static/js/app.js static/js/controllers.js static/partials/landing.html static/partials/view-repo.html test/data/test.db
This commit is contained in:
commit
0827e0fbac
45 changed files with 1149 additions and 306 deletions
36
tools/renderinvoice.py
Normal file
36
tools/renderinvoice.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
from app import stripe
|
||||
from app import app
|
||||
|
||||
from util.invoice import renderInvoiceToPdf
|
||||
|
||||
from data import model
|
||||
|
||||
import argparse
|
||||
|
||||
from flask import Flask, current_app
|
||||
from flask_mail import Mail
|
||||
|
||||
def sendInvoice(invoice_id):
|
||||
invoice = stripe.Invoice.retrieve(invoice_id)
|
||||
if not invoice['customer']:
|
||||
print 'No customer found'
|
||||
return
|
||||
|
||||
customer_id = invoice['customer']
|
||||
user = model.get_user_or_org_by_customer_id(customer_id)
|
||||
if not user:
|
||||
print 'No user found for customer %s' % (customer_id)
|
||||
return
|
||||
|
||||
|
||||
with app.app_context():
|
||||
file_data = renderInvoiceToPdf(invoice, user)
|
||||
with open('invoice.pdf', 'wb') as f:
|
||||
f.write(file_data)
|
||||
|
||||
print 'Invoice output as invoice.pdf'
|
||||
|
||||
parser = argparse.ArgumentParser(description='Generate an invoice')
|
||||
parser.add_argument('invoice_id', help='The invoice ID')
|
||||
args = parser.parse_args()
|
||||
sendInvoice(args.invoice_id)
|
Reference in a new issue