fix: loyalty test case -> validate against actual database state

This commit is contained in:
David
2024-09-05 14:07:06 +02:00
parent c914ea4adc
commit ad02e4112f
2 changed files with 4 additions and 2 deletions

View File

@@ -80,6 +80,7 @@ class TestLoyaltyProgram(unittest.TestCase):
si_original = create_sales_invoice_record()
si_original.insert()
si_original.submit()
customer.reload()
earned_points = get_points_earned(si_original)
@@ -102,8 +103,8 @@ class TestLoyaltyProgram(unittest.TestCase):
si_redeem.loyalty_points = earned_points
si_redeem.insert()
si_redeem.submit()
customer.reload()
customer = frappe.get_doc("Customer", {"customer_name": "Test Loyalty Customer"})
earned_after_redemption = get_points_earned(si_redeem)
lpe_redeem = frappe.get_doc(

View File

@@ -1776,7 +1776,8 @@ class SalesInvoice(SellingController):
loyalty_program=self.loyalty_program,
include_expired_entry=True,
)
frappe.db.set_value("Customer", self.customer, "loyalty_program_tier", lp_details.tier_name)
customer = frappe.get_doc("Customer", self.customer)
customer.db_set("loyalty_program_tier", lp_details.tier_name)
def get_returned_amount(self):
from frappe.query_builder.functions import Sum