当前位置: 首页>>代码示例>>Python>>正文


Python CourseRegCodeItem.get_total_amount_of_purchased_item方法代码示例

本文整理汇总了Python中shoppingcart.models.CourseRegCodeItem.get_total_amount_of_purchased_item方法的典型用法代码示例。如果您正苦于以下问题:Python CourseRegCodeItem.get_total_amount_of_purchased_item方法的具体用法?Python CourseRegCodeItem.get_total_amount_of_purchased_item怎么用?Python CourseRegCodeItem.get_total_amount_of_purchased_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shoppingcart.models.CourseRegCodeItem的用法示例。


在下文中一共展示了CourseRegCodeItem.get_total_amount_of_purchased_item方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _section_e_commerce

# 需要导入模块: from shoppingcart.models import CourseRegCodeItem [as 别名]
# 或者: from shoppingcart.models.CourseRegCodeItem import get_total_amount_of_purchased_item [as 别名]
def _section_e_commerce(course, access, paid_mode, coupons_enabled, reports_enabled):
    """ Provide data for the corresponding dashboard section """
    course_key = course.id
    coupons = Coupon.objects.filter(course_id=course_key).order_by("-is_active")
    course_price = paid_mode.min_price

    total_amount = None
    if access["finance_admin"]:
        single_purchase_total = PaidCourseRegistration.get_total_amount_of_purchased_item(course_key)
        bulk_purchase_total = CourseRegCodeItem.get_total_amount_of_purchased_item(course_key)
        total_amount = single_purchase_total + bulk_purchase_total

    section_data = {
        "section_key": "e-commerce",
        "section_display_name": _("E-Commerce"),
        "access": access,
        "course_id": unicode(course_key),
        "currency_symbol": settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
        "ajax_remove_coupon_url": reverse("remove_coupon", kwargs={"course_id": unicode(course_key)}),
        "ajax_get_coupon_info": reverse("get_coupon_info", kwargs={"course_id": unicode(course_key)}),
        "get_user_invoice_preference_url": reverse(
            "get_user_invoice_preference", kwargs={"course_id": unicode(course_key)}
        ),
        "sale_validation_url": reverse("sale_validation", kwargs={"course_id": unicode(course_key)}),
        "ajax_update_coupon": reverse("update_coupon", kwargs={"course_id": unicode(course_key)}),
        "ajax_add_coupon": reverse("add_coupon", kwargs={"course_id": unicode(course_key)}),
        "get_sale_records_url": reverse("get_sale_records", kwargs={"course_id": unicode(course_key)}),
        "get_sale_order_records_url": reverse("get_sale_order_records", kwargs={"course_id": unicode(course_key)}),
        "instructor_url": reverse("instructor_dashboard", kwargs={"course_id": unicode(course_key)}),
        "get_registration_code_csv_url": reverse("get_registration_codes", kwargs={"course_id": unicode(course_key)}),
        "generate_registration_code_csv_url": reverse(
            "generate_registration_codes", kwargs={"course_id": unicode(course_key)}
        ),
        "active_registration_code_csv_url": reverse(
            "active_registration_codes", kwargs={"course_id": unicode(course_key)}
        ),
        "spent_registration_code_csv_url": reverse(
            "spent_registration_codes", kwargs={"course_id": unicode(course_key)}
        ),
        "set_course_mode_url": reverse("set_course_mode_price", kwargs={"course_id": unicode(course_key)}),
        "download_coupon_codes_url": reverse("get_coupon_codes", kwargs={"course_id": unicode(course_key)}),
        "enrollment_report_url": reverse("get_enrollment_report", kwargs={"course_id": unicode(course_key)}),
        "exec_summary_report_url": reverse("get_exec_summary_report", kwargs={"course_id": unicode(course_key)}),
        "list_financial_report_downloads_url": reverse(
            "list_financial_report_downloads", kwargs={"course_id": unicode(course_key)}
        ),
        "list_instructor_tasks_url": reverse("list_instructor_tasks", kwargs={"course_id": unicode(course_key)}),
        "look_up_registration_code": reverse("look_up_registration_code", kwargs={"course_id": unicode(course_key)}),
        "coupons": coupons,
        "sales_admin": access["sales_admin"],
        "coupons_enabled": coupons_enabled,
        "reports_enabled": reports_enabled,
        "course_price": course_price,
        "total_amount": total_amount,
    }
    return section_data
开发者ID:lemontreeran,项目名称:edx-platform,代码行数:58,代码来源:instructor_dashboard.py

示例2: _section_e_commerce

# 需要导入模块: from shoppingcart.models import CourseRegCodeItem [as 别名]
# 或者: from shoppingcart.models.CourseRegCodeItem import get_total_amount_of_purchased_item [as 别名]
def _section_e_commerce(course, access, paid_mode, coupons_enabled, reports_enabled):
    """ Provide data for the corresponding dashboard section """
    course_key = course.id
    coupons = Coupon.objects.filter(course_id=course_key).order_by('-is_active')
    course_price = paid_mode.min_price

    total_amount = None
    if access['finance_admin']:
        single_purchase_total = PaidCourseRegistration.get_total_amount_of_purchased_item(course_key)
        bulk_purchase_total = CourseRegCodeItem.get_total_amount_of_purchased_item(course_key)
        total_amount = single_purchase_total + bulk_purchase_total

    section_data = {
        'section_key': 'e-commerce',
        'section_display_name': _('E-Commerce'),
        'access': access,
        'course_id': unicode(course_key),
        'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
        'ajax_remove_coupon_url': reverse('remove_coupon', kwargs={'course_id': unicode(course_key)}),
        'ajax_get_coupon_info': reverse('get_coupon_info', kwargs={'course_id': unicode(course_key)}),
        'get_user_invoice_preference_url': reverse('get_user_invoice_preference', kwargs={'course_id': unicode(course_key)}),
        'sale_validation_url': reverse('sale_validation', kwargs={'course_id': unicode(course_key)}),
        'ajax_update_coupon': reverse('update_coupon', kwargs={'course_id': unicode(course_key)}),
        'ajax_add_coupon': reverse('add_coupon', kwargs={'course_id': unicode(course_key)}),
        'get_sale_records_url': reverse('get_sale_records', kwargs={'course_id': unicode(course_key)}),
        'get_sale_order_records_url': reverse('get_sale_order_records', kwargs={'course_id': unicode(course_key)}),
        'instructor_url': reverse('instructor_dashboard', kwargs={'course_id': unicode(course_key)}),
        'get_registration_code_csv_url': reverse('get_registration_codes', kwargs={'course_id': unicode(course_key)}),
        'generate_registration_code_csv_url': reverse('generate_registration_codes', kwargs={'course_id': unicode(course_key)}),
        'active_registration_code_csv_url': reverse('active_registration_codes', kwargs={'course_id': unicode(course_key)}),
        'spent_registration_code_csv_url': reverse('spent_registration_codes', kwargs={'course_id': unicode(course_key)}),
        'set_course_mode_url': reverse('set_course_mode_price', kwargs={'course_id': unicode(course_key)}),
        'download_coupon_codes_url': reverse('get_coupon_codes', kwargs={'course_id': unicode(course_key)}),
        'enrollment_report_url': reverse('get_enrollment_report', kwargs={'course_id': unicode(course_key)}),
        'exec_summary_report_url': reverse('get_exec_summary_report', kwargs={'course_id': unicode(course_key)}),
        'list_financial_report_downloads_url': reverse('list_financial_report_downloads',
                                                       kwargs={'course_id': unicode(course_key)}),
        'list_instructor_tasks_url': reverse(
            'api_instructor:list_instructor_tasks',
            kwargs={'course_id': unicode(course_key)}
        ),
        'look_up_registration_code': reverse('look_up_registration_code', kwargs={'course_id': unicode(course_key)}),
        'coupons': coupons,
        'sales_admin': access['sales_admin'],
        'coupons_enabled': coupons_enabled,
        'reports_enabled': reports_enabled,
        'course_price': course_price,
        'total_amount': total_amount,
        'is_ecommerce_course': is_ecommerce_course(course_key)
    }
    return section_data
开发者ID:edx-solutions,项目名称:edx-platform,代码行数:53,代码来源:instructor_dashboard.py

示例3: test_total_credit_cart_sales_amount

# 需要导入模块: from shoppingcart.models import CourseRegCodeItem [as 别名]
# 或者: from shoppingcart.models.CourseRegCodeItem import get_total_amount_of_purchased_item [as 别名]
    def test_total_credit_cart_sales_amount(self):
        """
        Test to check the total amount for all the credit card purchases.
        """
        student = UserFactory.create()
        self.client.login(username=student.username, password="test")
        student_cart = Order.get_cart_for_user(student)
        item = self.add_course_to_user_cart(student_cart, self.course.id)
        resp = self.client.post(reverse('shoppingcart.views.update_user_cart'), {'ItemId': item.id, 'qty': 4})
        self.assertEqual(resp.status_code, 200)
        student_cart.purchase()

        self.client.login(username=self.instructor.username, password="test")
        CourseFinanceAdminRole(self.course.id).add_users(self.instructor)
        single_purchase_total = PaidCourseRegistration.get_total_amount_of_purchased_item(self.course.id)
        bulk_purchase_total = CourseRegCodeItem.get_total_amount_of_purchased_item(self.course.id)
        total_amount = single_purchase_total + bulk_purchase_total
        response = self.client.get(self.url)
        self.assertIn('{currency}{amount}'.format(currency='$', amount=total_amount), response.content)
开发者ID:edx,项目名称:edx-platform,代码行数:21,代码来源:test_instructor_dashboard.py

示例4: get_executive_report

# 需要导入模块: from shoppingcart.models import CourseRegCodeItem [as 别名]
# 或者: from shoppingcart.models.CourseRegCodeItem import get_total_amount_of_purchased_item [as 别名]
def get_executive_report(course_id):
    """
    Returns dict containing information about the course executive summary.
    """
    single_purchase_total = PaidCourseRegistration.get_total_amount_of_purchased_item(course_id)
    bulk_purchase_total = CourseRegCodeItem.get_total_amount_of_purchased_item(course_id)
    paid_invoices_total = InvoiceTransaction.get_total_amount_of_paid_course_invoices(course_id)
    gross_paid_revenue = single_purchase_total + bulk_purchase_total + paid_invoices_total

    all_invoices_total = Invoice.get_invoice_total_amount_for_course(course_id)
    gross_pending_revenue = all_invoices_total - float(paid_invoices_total)

    gross_revenue = float(gross_paid_revenue) + float(gross_pending_revenue)

    refunded_self_purchased_seats = PaidCourseRegistration.get_self_purchased_seat_count(
        course_id, status='refunded'
    )
    refunded_bulk_purchased_seats = CourseRegCodeItem.get_bulk_purchased_seat_count(
        course_id, status='refunded'
    )
    total_seats_refunded = refunded_self_purchased_seats + refunded_bulk_purchased_seats

    self_purchased_refunds = PaidCourseRegistration.get_total_amount_of_purchased_item(
        course_id,
        status='refunded'
    )
    bulk_purchase_refunds = CourseRegCodeItem.get_total_amount_of_purchased_item(course_id, status='refunded')
    total_amount_refunded = self_purchased_refunds + bulk_purchase_refunds

    top_discounted_codes = CouponRedemption.get_top_discount_codes_used(course_id)
    total_coupon_codes_purchases = CouponRedemption.get_total_coupon_code_purchases(course_id)

    bulk_purchased_codes = CourseRegistrationCode.order_generated_registration_codes(course_id)

    unused_registration_codes = 0
    for registration_code in bulk_purchased_codes:
        if not RegistrationCodeRedemption.is_registration_code_redeemed(registration_code.code):
            unused_registration_codes += 1

    self_purchased_seat_count = PaidCourseRegistration.get_self_purchased_seat_count(course_id)
    bulk_purchased_seat_count = CourseRegCodeItem.get_bulk_purchased_seat_count(course_id)
    total_invoiced_seats = CourseRegistrationCode.invoice_generated_registration_codes(course_id).count()

    total_seats = self_purchased_seat_count + bulk_purchased_seat_count + total_invoiced_seats

    self_purchases_percentage = 0.0
    bulk_purchases_percentage = 0.0
    invoice_purchases_percentage = 0.0
    avg_price_paid = 0.0

    if total_seats != 0:
        self_purchases_percentage = (float(self_purchased_seat_count) / float(total_seats)) * 100
        bulk_purchases_percentage = (float(bulk_purchased_seat_count) / float(total_seats)) * 100
        invoice_purchases_percentage = (float(total_invoiced_seats) / float(total_seats)) * 100
        avg_price_paid = gross_revenue / total_seats

    course = get_course_by_id(course_id, depth=0)
    currency = settings.PAID_COURSE_REGISTRATION_CURRENCY[1]

    return {
        'display_name': course.display_name,
        'start_date': course.start.strftime("%Y-%m-%d") if course.start is not None else 'N/A',
        'end_date': course.end.strftime("%Y-%m-%d") if course.end is not None else 'N/A',
        'total_seats': total_seats,
        'currency': currency,
        'gross_revenue': float(gross_revenue),
        'gross_paid_revenue': float(gross_paid_revenue),
        'gross_pending_revenue': gross_pending_revenue,
        'total_seats_refunded': total_seats_refunded,
        'total_amount_refunded': float(total_amount_refunded),
        'average_paid_price': float(avg_price_paid),
        'discount_codes_data': top_discounted_codes,
        'total_seats_using_discount_codes': total_coupon_codes_purchases,
        'total_self_purchase_seats': self_purchased_seat_count,
        'total_bulk_purchase_seats': bulk_purchased_seat_count,
        'total_invoiced_seats': total_invoiced_seats,
        'unused_bulk_purchase_code_count': unused_registration_codes,
        'self_purchases_percentage': self_purchases_percentage,
        'bulk_purchases_percentage': bulk_purchases_percentage,
        'invoice_purchases_percentage': invoice_purchases_percentage,
    }
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:83,代码来源:enrollments.py


注:本文中的shoppingcart.models.CourseRegCodeItem.get_total_amount_of_purchased_item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。