本文整理汇总了Python中models.Order.subscription_general_sales_tax方法的典型用法代码示例。如果您正苦于以下问题:Python Order.subscription_general_sales_tax方法的具体用法?Python Order.subscription_general_sales_tax怎么用?Python Order.subscription_general_sales_tax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.subscription_general_sales_tax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import subscription_general_sales_tax [as 别名]
def post(self):
# Get customer and create an invoice.
customer = Customer.get_by_key_name(self.get_current_username())
invoice = Invoice(customer=customer)
invoice.put()
# Now start processing subscription data.
subscription_data = self.session['subscription-data']
products = db.get([db.Key(key) for key in subscription_data.get('products')])
period = subscription_data.get('period')
subscription_period = SubscriptionPeriod.get_by_period(period)
units = [product for product in products if 'product_keys' not in product.properties()]
baskets = [product for product in products if 'product_keys' in product.properties()]
activation_credentials_list = []
orders = []
for unit in units:
subscription = Subscription.get_by_product_and_period(unit, period)
order = Order(customer=customer, invoice=invoice, subscription=subscription)
order.subscription_price = subscription.price
order.subscription_general_sales_tax = subscription.general_sales_tax
order.subscription_period_in_months = subscription.period_in_months
order.subscription_free_period_in_months = subscription_period.free_period_in_months
order.price = subscription.price + subscription.general_sales_tax
order.subscription_currency = subscription.currency
orders.append(order)
order.put()
unit_id = unit.key().id()
activation_credentials = ActivationCredentials()
activation_credentials.serial_number = self.get_argument('u_%d_serial_number' % unit_id)
activation_credentials.machine_id = self.get_argument('u_%d_machine_id' % unit_id)
activation_credentials.order = order
activation_credentials.product = unit
activation_credentials.customer = customer
logging.info(activation_credentials)
activation_credentials_list.append(activation_credentials)
for basket in baskets:
subscription = Subscription.get_by_product_and_period(basket, period)
order = Order(customer=customer, invoice=invoice, subscription=subscription)
order.subscription_price = subscription.price
order.subscription_general_sales_tax = subscription.general_sales_tax
order.subscription_period_in_months = subscription.period_in_months
order.subscription_free_period_in_months = subscription_period.free_period_in_months
order.price = subscription.price + subscription.general_sales_tax
order.subscription_currency = subscription.currency
orders.append(order)
order.put()
for unit in basket.products:
basket_id = basket.key().id()
unit_id = unit.key().id()
activation_credentials = ActivationCredentials()
activation_credentials.serial_number = self.get_argument('b_%d_u_%d_serial_number' % (basket_id, unit_id,))
activation_credentials.machine_id = self.get_argument('b_%d_u_%d_machine_id' % (basket_id, unit_id,))
activation_credentials.order = order
activation_credentials.product = unit
activation_credentials.customer = customer
logging.info(activation_credentials)
activation_credentials_list.append(activation_credentials)
db.put(activation_credentials_list)
invoice.total_price = sum([order.price for order in orders])
invoice.currency = orders[0].subscription_currency
invoice.put()
self.session['activation-invoice-key'] = str(invoice.key())
self.redirect('/activate/overview')