(fix)test case: loyalty program, course schedule and more

This commit is contained in:
Nabin Hait 2018-08-29 17:05:11 +05:30
parent a804d6d487
commit 28f9b0a9ab
6 changed files with 22 additions and 17 deletions

View File

@ -344,12 +344,12 @@
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_create": 1,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-21 16:15:49.911384",
"modified": "2018-08-29 16:05:22.810347",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Loyalty Point Entry",
@ -422,6 +422,5 @@
"sort_order": "DESC",
"title_field": "customer",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
"track_seen": 0
}

View File

@ -18,7 +18,7 @@ def get_loyalty_point_entries(customer, loyalty_program, company, expiry_date=No
date = today()
return frappe.db.sql('''
select name, loyalty_points, expiry_date, loyalty_program_tier
select name, loyalty_points, expiry_date, loyalty_program_tier, sales_invoice
from `tabLoyalty Point Entry`
where customer=%s and loyalty_program=%s
and expiry_date>=%s and loyalty_points>0 and company=%s

View File

@ -188,6 +188,9 @@ def create_sales_invoice_record(qty=1):
def create_records():
# create a new loyalty Account
if frappe.db.exists("Account", "Loyalty - _TC"):
return
frappe.get_doc({
"doctype": "Account",
"account_name": "Loyalty",

View File

@ -101,7 +101,7 @@
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "ACC-SINV-.YYYY.-",
"options": "ACC-SINV-.YYYY.-\n",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
@ -2575,6 +2575,7 @@
"label": "Loyalty Amount",
"length": 0,
"no_copy": 1,
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -2807,7 +2808,7 @@
"label": "Apply Additional Discount On",
"length": 0,
"no_copy": 0,
"options": "\nGrand Total\nNet Total",
"options": "\nGrand Total\nNet Total\n",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -4661,7 +4662,7 @@
"label": "Status",
"length": 0,
"no_copy": 1,
"options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled",
"options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled\n",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -4833,7 +4834,7 @@
"no_copy": 0,
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
"options": "No\nYes",
"options": "No\nYes\n",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
@ -4865,7 +4866,7 @@
"label": "C-Form Applicable",
"length": 0,
"no_copy": 1,
"options": "No\nYes",
"options": "No\nYes\n",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
@ -5480,7 +5481,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-08-21 14:44:47.783382",
"modified": "2018-08-29 16:23:03.940415",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
@ -5574,6 +5575,5 @@
"timeline_field": "customer",
"title_field": "title",
"track_changes": 1,
"track_seen": 1,
"track_views": 0
"track_seen": 1
}

View File

@ -1035,6 +1035,8 @@ class SalesInvoice(SellingController):
points_to_redeem = self.loyalty_points
for lp_entry in loyalty_point_entries:
if lp_entry.sales_invoice == self.name:
continue
available_points = lp_entry.loyalty_points - flt(redemption_details.get(lp_entry.name))
if available_points > points_to_redeem:
redeemed_points = points_to_redeem

View File

@ -9,6 +9,7 @@ import unittest
import datetime
from frappe.utils import today, to_timedelta
from erpnext.education.utils import OverlapError
from frappe.utils.make_random import get_random
# test_records = frappe.get_test_records('Course Schedule')
@ -17,14 +18,14 @@ class TestCourseSchedule(unittest.TestCase):
cs1 = make_course_schedule_test_record(simulate= True)
cs2 = make_course_schedule_test_record(schedule_date=cs1.schedule_date, from_time= cs1.from_time,
to_time= cs1.to_time, instructor="_Test Instructor 2", room="RM0002", do_not_save= 1)
to_time= cs1.to_time, instructor="_Test Instructor 2", room=frappe.get_all("Room")[1].name, do_not_save= 1)
self.assertRaises(OverlapError, cs2.save)
def test_instructor_conflict(self):
cs1 = make_course_schedule_test_record(simulate= True)
cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
student_group="Course-TC101-2014-2015 (_Test Academic Term)", room="RM0002", do_not_save= 1)
student_group="Course-TC101-2014-2015 (_Test Academic Term)", room=frappe.get_all("Room")[1].name, do_not_save= 1)
self.assertRaises(OverlapError, cs2.save)
def test_room_conflict(self):
@ -38,7 +39,7 @@ class TestCourseSchedule(unittest.TestCase):
cs1 = make_course_schedule_test_record(simulate= True)
make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
student_group="Course-TC102-2014-2015 (_Test Academic Term)", instructor="_Test Instructor 2", room="RM0002")
student_group="Course-TC102-2014-2015 (_Test Academic Term)", instructor="_Test Instructor 2", room=frappe.get_all("Room")[1].name)
def make_course_schedule_test_record(**args):
args = frappe._dict(args)
@ -47,7 +48,7 @@ def make_course_schedule_test_record(**args):
course_schedule.student_group = args.student_group or "Course-TC101-2014-2015 (_Test Academic Term)"
course_schedule.course = args.course or "TC101"
course_schedule.instructor = args.instructor or "_Test Instructor"
course_schedule.room = args.room or "RM0001"
course_schedule.room = args.room or frappe.get_all("Room")[0].name
course_schedule.schedule_date = args.schedule_date or today()
course_schedule.from_time = args.from_time or to_timedelta("01:00:00")