blob: 9d6a558b7c1628115abf3566adac4a7aa6fcd7fb [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshi330dae92013-09-10 13:46:15 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
Anand Doshi1be5bb72013-09-12 15:25:38 +05306from webnotes import _
7from webnotes.utils import flt, fmt_money
Anand Doshi330dae92013-09-10 13:46:15 +05308
Anand Doshib0d996f2013-09-10 18:29:39 +05309no_cache = True
10
Anand Doshi330dae92013-09-10 13:46:15 +053011def get_context():
Rushabh Mehtadf200f32013-12-25 15:19:22 +053012 from erpnext.templates.utils import get_transaction_context
Anand Doshi330dae92013-09-10 13:46:15 +053013 context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
Anand Doshi1be5bb72013-09-12 15:25:38 +053014 modify_status(context.get("doc"))
Anand Doshi330dae92013-09-10 13:46:15 +053015 context.update({
16 "parent_link": "invoices",
17 "parent_title": "Invoices"
18 })
Anand Doshi1be5bb72013-09-12 15:25:38 +053019 return context
20
21def modify_status(doc):
22 doc.status = ""
23 if flt(doc.outstanding_amount):
24 doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
25 ("label-warning", "icon-exclamation-sign",
26 _("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
27 else:
28 doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
29 ("label-success", "icon-ok", _("Paid"))
30