Nobody realised that loyalty point calculation is completely wrong when expiry date is used?
loyalty_point_details = []
if party_type == "Customer":
loyalty_point_details = frappe._dict(
frappe.get_all(
"Loyalty Point Entry",
filters={
"customer": party,
"expiry_date": (">=", getdate()),
},
group_by="company",
fields=["company", "sum(loyalty_points) as loyalty_points"],
as_list=1,
)
)
This is the most basic way to calculation loyalty point and it completely ignores those points which are already used.