Rushabh Mehta | 3daa49a | 2014-10-21 16:16:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import frappe |
| 6 | from frappe import _ |
| 7 | from frappe.utils import flt, fmt_money |
| 8 | from shopping_cart.templates.utils import get_transaction_context |
| 9 | |
| 10 | no_cache = 1 |
| 11 | no_sitemap = 1 |
| 12 | |
| 13 | def get_context(context): |
| 14 | invoice_context = frappe._dict({ |
| 15 | "parent_link": "invoices", |
| 16 | "parent_title": "Invoices" |
| 17 | }) |
| 18 | invoice_context.update(get_transaction_context("Sales Invoice", frappe.form_dict.name)) |
| 19 | modify_status(invoice_context.doc) |
| 20 | return invoice_context |
| 21 | |
| 22 | def modify_status(doc): |
| 23 | doc.status = "" |
| 24 | if flt(doc.outstanding_amount): |
| 25 | doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \ |
| 26 | ("label-warning", "icon-exclamation-sign", |
| 27 | _("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency)) |
| 28 | else: |
| 29 | doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \ |
| 30 | ("label-success", "icon-ok", _("Paid")) |
| 31 | |