當前位置: 首頁>>代碼示例>>Python>>正文


Python interface.InvoiceInterface類代碼示例

本文整理匯總了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)
        })
開發者ID:kkaczmarczyk,項目名稱:commcare-hq,代碼行數:60,代碼來源:tasks.py

示例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)
開發者ID:kkrampa,項目名稱:commcare-hq,代碼行數:26,代碼來源:views.py

示例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,
        }
開發者ID:bazuzi,項目名稱:commcare-hq,代碼行數:16,代碼來源:views.py

示例4: parent_pages

 def parent_pages(self):
     return [{"title": InvoiceInterface.name, "url": InvoiceInterface.get_url()}]
開發者ID:kkrampa,項目名稱:commcare-hq,代碼行數:2,代碼來源:views.py


注:本文中的corehq.apps.accounting.interface.InvoiceInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。