本文整理汇总了Python中corehq.apps.accounting.interface.InvoiceInterface类的典型用法代码示例。如果您正苦于以下问题:Python InvoiceInterface类的具体用法?Python InvoiceInterface怎么用?Python InvoiceInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InvoiceInterface类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_bookkeeper_email
def send_bookkeeper_email(month=None, year=None, emails=None):
today = datetime.date.today()
# now, make sure that we send out LAST month's invoices if we did
# not specify a month or year.
today = utils.get_previous_month_date_range(today)[0]
month = month or today.month
year = year or today.year
from corehq.apps.accounting.interface import InvoiceInterface
request = HttpRequest()
params = urlencode((
('report_filter_statement_period_use_filter', 'on'),
('report_filter_statement_period_month', month),
('report_filter_statement_period_year', year),
))
request.GET = QueryDict(params)
request.couch_user = FakeUser(
domain="hqadmin",
username="[email protected]",
)
invoice = InvoiceInterface(request)
invoice.is_rendered_as_email = True
first_of_month = datetime.date(year, month, 1)
email_context = {
'month': first_of_month.strftime("%B"),
}
email_content = render_to_string(
'accounting/bookkeeper_email.html', email_context)
email_content_plaintext = render_to_string(
'accounting/bookkeeper_email_plaintext.html', email_context)
format_dict = Format.FORMAT_DICT[Format.CSV]
excel_attachment = {
'title': 'Invoices_%(period)s.%(extension)s' % {
'period': first_of_month.strftime('%B_%Y'),
'extension': format_dict['extension'],
},
'mimetype': format_dict['mimetype'],
'file_obj': invoice.excel_response,
}
emails = emails or settings.BOOKKEEPER_CONTACT_EMAILS
for email in emails:
send_HTML_email(
"Invoices for %s" % datetime.date(year, month, 1).strftime("%B %Y"),
email,
email_content,
email_from=settings.DEFAULT_FROM_EMAIL,
text_content=email_content_plaintext,
file_attachments=[excel_attachment],
)
logger.info(
"[BILLING] Sent Bookkeeper Invoice Summary for %(month)s "
"to %(emails)s." % {
'month': first_of_month.strftime("%B %Y"),
'emails': ", ".join(emails)
})
示例2: post
def post(self, request, *args, **kwargs):
if 'adjust' in self.request.POST:
if self.adjust_balance_form.is_valid():
self.adjust_balance_form.adjust_balance(
web_user=self.request.user.username,
)
return HttpResponseRedirect(request.META.get('HTTP_REFERER') or self.page_url)
elif 'resend' in self.request.POST:
if self.resend_email_form.is_valid():
try:
self.resend_email_form.resend_email()
return HttpResponseRedirect(self.page_url)
except Exception as e:
messages.error(request,
"Could not send emails due to: %s" % e)
elif SuppressInvoiceForm.submit_kwarg in self.request.POST:
if self.suppress_invoice_form.is_valid():
self.suppress_invoice_form.suppress_invoice()
if self.invoice.is_customer_invoice:
return HttpResponseRedirect(CustomerInvoiceInterface.get_url())
else:
return HttpResponseRedirect(InvoiceInterface.get_url())
elif HideInvoiceForm.submit_kwarg in self.request.POST:
if self.hide_invoice_form.is_valid():
self.hide_invoice_form.hide_invoice()
return self.get(request, *args, **kwargs)
示例3: invoice_context
def invoice_context(self):
subscriber_domain = self.subscription.subscriber.domain
invoice_report = InvoiceInterface(self.request)
invoice_report.filters.update(subscription__subscriber__domain=subscriber_domain)
# Tied to InvoiceInterface.
encoded_params = urlencode({'subscriber': subscriber_domain})
invoice_report_url = "{}?{}".format(invoice_report.get_url(), encoded_params)
invoice_export_url = "{}?{}".format(invoice_report.get_url(render_as='export'), encoded_params)
return {
'invoice_headers': invoice_report.headers,
'invoice_rows': invoice_report.rows,
'invoice_export_url': invoice_export_url,
'invoice_report_url': invoice_report_url,
'adjust_balance_forms': invoice_report.adjust_balance_forms,
}
示例4: parent_pages
def parent_pages(self):
return [{"title": InvoiceInterface.name, "url": InvoiceInterface.get_url()}]