Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
0613c2dd
Commit
0613c2dd
authored
Jun 18, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treat aggregate sums of None as 0
parent
2b63ddb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
lms/djangoapps/shoppingcart/models.py
+4
-2
lms/djangoapps/shoppingcart/tests/test_models.py
+34
-0
No files found.
lms/djangoapps/shoppingcart/models.py
View file @
0613c2dd
...
...
@@ -850,7 +850,8 @@ class Invoice(TimeStampedModel):
"""
result
=
cls
.
objects
.
filter
(
course_id
=
course_key
,
is_valid
=
True
)
.
aggregate
(
total
=
Sum
(
'total_amount'
))
# pylint: disable=no-member
return
result
.
get
(
'total'
,
0
)
total
=
result
.
get
(
'total'
,
0
)
return
total
if
total
else
0
def
generate_pdf_invoice
(
self
,
course
,
course_price
,
quantity
,
sale_price
):
"""
...
...
@@ -1022,7 +1023,8 @@ class InvoiceTransaction(TimeStampedModel):
total
=
Sum
(
'amount'
)
)
# pylint: disable=no-member
return
result
.
get
(
'total'
,
0
)
total
=
result
.
get
(
'total'
,
0
)
return
total
if
total
else
0
def
snapshot
(
self
):
"""Create a snapshot of the invoice transaction.
...
...
lms/djangoapps/shoppingcart/tests/test_models.py
View file @
0613c2dd
...
...
@@ -499,6 +499,14 @@ class PaidCourseRegistrationTest(ModuleStoreTestCase):
total_amount
=
PaidCourseRegistration
.
get_total_amount_of_purchased_item
(
course_key
=
self
.
course_key
)
self
.
assertEqual
(
total_amount
,
40.00
)
def
test_get_total_amount_empty
(
self
):
"""
Test to check the total amount of the
purchased items.
"""
total_amount
=
PaidCourseRegistration
.
get_total_amount_of_purchased_item
(
course_key
=
self
.
course_key
)
self
.
assertEqual
(
total_amount
,
0.00
)
def
test_add_to_order
(
self
):
reg1
=
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_key
)
...
...
@@ -527,6 +535,25 @@ class PaidCourseRegistrationTest(ModuleStoreTestCase):
registration_codes
=
CourseRegistrationCode
.
order_generated_registration_codes
(
self
.
course_key
)
self
.
assertEqual
(
registration_codes
.
count
(),
item
.
qty
)
def
test_order_generated_totals
(
self
):
"""
Test to check for the order generated registration
codes.
"""
total_amount
=
CourseRegCodeItem
.
get_total_amount_of_purchased_item
(
self
.
course_key
)
self
.
assertEqual
(
total_amount
,
0
)
self
.
cart
.
order_type
=
'business'
self
.
cart
.
save
()
item
=
CourseRegCodeItem
.
add_to_order
(
self
.
cart
,
self
.
course_key
,
2
)
self
.
cart
.
purchase
()
registration_codes
=
CourseRegistrationCode
.
order_generated_registration_codes
(
self
.
course_key
)
self
.
assertEqual
(
registration_codes
.
count
(),
item
.
qty
)
total_amount
=
CourseRegCodeItem
.
get_total_amount_of_purchased_item
(
self
.
course_key
)
self
.
assertEqual
(
total_amount
,
80.00
)
def
add_coupon
(
self
,
course_key
,
is_active
,
code
):
"""
add dummy coupon into models
...
...
@@ -1169,6 +1196,13 @@ class InvoiceHistoryTest(TestCase):
total_amount_paid
=
InvoiceTransaction
.
get_total_amount_of_paid_course_invoices
(
self
.
course_key
)
self
.
assertEqual
(
float
(
total_amount_paid
),
123.45
)
def
test_get_total_amount_of_no_invoices
(
self
):
"""
Test to check the Invoice Transactions amount.
"""
total_amount_paid
=
InvoiceTransaction
.
get_total_amount_of_paid_course_invoices
(
self
.
course_key
)
self
.
assertEqual
(
float
(
total_amount_paid
),
0
)
def
test_invoice_contact_info_history
(
self
):
self
.
_assert_history_invoice_info
(
is_valid
=
True
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment