Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
Anand Doshi | 1be5bb7 | 2013-09-12 15:25:38 +0530 | [diff] [blame] | 6 | from webnotes import _ |
| 7 | from webnotes.utils import flt, fmt_money |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 8 | |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 9 | no_cache = True |
| 10 | |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 11 | def get_context(): |
Rushabh Mehta | df200f3 | 2013-12-25 15:19:22 +0530 | [diff] [blame^] | 12 | from erpnext.templates.utils import get_transaction_context |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 13 | context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) |
Anand Doshi | 1be5bb7 | 2013-09-12 15:25:38 +0530 | [diff] [blame] | 14 | modify_status(context.get("doc")) |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 15 | context.update({ |
| 16 | "parent_link": "invoices", |
| 17 | "parent_title": "Invoices" |
| 18 | }) |
Anand Doshi | 1be5bb7 | 2013-09-12 15:25:38 +0530 | [diff] [blame] | 19 | return context |
| 20 | |
| 21 | def 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 | |