diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 62539e34..25c3c708 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -11,7 +11,7 @@ from frappe.website.utils import get_comment_list class Bounty(WebsiteGenerator): def get_context(self, context): - paid_backers = [backer for backer in self.bounty_backer if backer.paid] + paid_backers = get_paid_backers(self.bounty_backer) no_of_backers = len(paid_backers) if no_of_backers == 0: no_of_backers = 'Be the first to back this bounty' @@ -37,12 +37,11 @@ class Bounty(WebsiteGenerator): from frappe.utils.user import get_user_fullname self.bounty_collected = 0.0 - for backer in self.bounty_backer: - if backer.paid: - amount = backer.amount - if backer.currency == 'INR': - amount = backer.amount / 65.00 - self.bounty_collected += amount + for backer in get_paid_backers(self.bounty_backer): + amount = backer.amount + if backer.currency == 'INR': + amount = backer.amount / 65.00 + self.bounty_collected += amount if not self.route: self.published = 1 @@ -62,4 +61,8 @@ def get_list_context(context): context.no_breadcrumbs = True context.order_by = 'creation desc' context.introduction = 'Start a new Bounty' - context.fmt_money = fmt_money \ No newline at end of file + context.fmt_money = fmt_money + context.get_paid_backers = get_paid_backers + +def get_paid_backers(backers): + return [backer for backer in backers if backer.paid] \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html index f4e82142..573023b2 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -12,10 +12,11 @@
{{ fmt_money(doc.goal, currency="USD") }} Ends on {{ doc.end_date }} - {% if doc.bounty_backer %} + {% set paid_backers = get_paid_backers(doc.bounty_backer) %} + {% if paid_backers|len > 0 %} - {{ doc.bounty_backer|len }} - {% if doc.bounty_backer|len > 1 %} + {{ paid_backers|len }} + {% if paid_backers|len > 1 %} Backers {% else %} Backer