From ef0bce1da5fbe7bd42ee205e116194e62bc10f52 Mon Sep 17 00:00:00 2001 From: Bread Genie Date: Thu, 13 Jun 2024 16:24:56 +0530 Subject: [PATCH] fix(BillingInvoice): show proper titles and plan names on invoice --- press/press/doctype/invoice/invoice.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/press/press/doctype/invoice/invoice.py b/press/press/doctype/invoice/invoice.py index 6e399e855e..90b535f25a 100644 --- a/press/press/doctype/invoice/invoice.py +++ b/press/press/doctype/invoice/invoice.py @@ -170,6 +170,23 @@ def get_list_query(query, filters=None, **list_args): def get_doc(self, doc): doc.invoice_pdf = self.invoice_pdf or (self.currency == "USD" and self.get_pdf()) + currency = frappe.get_value("Team", self.team, "currency") + price_field = "price_inr" if currency == "INR" else "price_usd" + currency_symbol = "₹" if currency == "INR" else "$" + + for item in doc["items"]: + if item.document_type in ("Server", "Database Server"): + item.document_name = frappe.get_value( + item.document_type, item.document_name, "title" + ) + item.plan = ( + f"{currency_symbol}{frappe.get_value('Server Plan', item.plan, price_field)}" + ) + elif item.document_type == "Marketplace App": + item.document_name = frappe.get_value( + item.document_type, item.document_name, "title" + ) + item.plan = f"{currency_symbol}{frappe.get_value('Marketplace App Plan', item.plan, price_field)}" @dashboard_whitelist() def stripe_payment_url(self):