本文整理汇总了Python中tendenci.apps.invoices.models.Invoice.tax_exempt方法的典型用法代码示例。如果您正苦于以下问题:Python Invoice.tax_exempt方法的具体用法?Python Invoice.tax_exempt怎么用?Python Invoice.tax_exempt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tendenci.apps.invoices.models.Invoice
的用法示例。
在下文中一共展示了Invoice.tax_exempt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_invoice
# 需要导入模块: from tendenci.apps.invoices.models import Invoice [as 别名]
# 或者: from tendenci.apps.invoices.models.Invoice import tax_exempt [as 别名]
def create_invoice(self, billing_cycle, billing_dt):
"""
Create an invoice and update the next_billing_dt for this recurring payment.
"""
try:
profile = self.user.get_profile()
except Profile.DoesNotExist:
profile = Profile.objects.create_profile(user=self.user)
if self.within_trial_period():
amount = self.trial_amount
else:
amount = self.payment_amount
self.next_billing_dt = billing_dt
self.save()
inv = Invoice()
inv.due_date = billing_dt
inv.ship_date = billing_dt
inv.object_type = ContentType.objects.get(app_label=self._meta.app_label,
model=self._meta.module_name)
inv.object_id = self.id
inv.title = "Recurring Payment Invoice for Billing Cycle %s - %s" % (
billing_cycle['start'].strftime('%m/%d/%Y'),
billing_cycle['end'].strftime('%m/%d/%Y'))
inv.bill_to = self.user.get_full_name()
inv.bill_to_company = profile.company
inv.bill_to_address = profile.address
inv.bill_to_city = profile.city
inv.bill_to_state = profile.state
inv.bill_to_zip_code = profile.zipcode
inv.bill_to_country = profile.country
inv.bill_to_phone = profile.phone
inv.bill_to_email = self.user.email
inv.status = True
if self.taxable and self.tax_rate:
inv.tax = self.tax_rate * amount
else:
inv.tax_exempt = 1
inv.tax = 0
inv.subtotal = amount
inv.total = inv.subtotal + inv.tax
inv.balance = inv.total
inv.estimate = True
inv.status_detail = 'estimate'
inv.set_owner(self.user)
inv.save(self.user)
# tender the invoice
inv.tender(self.user)
rp_invoice = RecurringPaymentInvoice(
recurring_payment=self,
invoice=inv,
billing_cycle_start_dt=billing_cycle['start'],
billing_cycle_end_dt=billing_cycle['end'],
billing_dt=billing_dt
)
rp_invoice.save()
return rp_invoice