From 28dd000da9095b6505a8e1b205942aec0bf5d421 Mon Sep 17 00:00:00 2001 From: Sajin SR Date: Thu, 5 Dec 2024 15:45:28 +0530 Subject: [PATCH] fix(Package Subscription): restrict payment for draft subscriptions --- .../doctype/package_subscription/package_subscription.js | 2 +- .../doctype/package_subscription/package_subscription.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/healthcare/healthcare/doctype/package_subscription/package_subscription.js b/healthcare/healthcare/doctype/package_subscription/package_subscription.js index 5172033ba1..8b7d2c5eac 100644 --- a/healthcare/healthcare/doctype/package_subscription/package_subscription.js +++ b/healthcare/healthcare/doctype/package_subscription/package_subscription.js @@ -20,7 +20,7 @@ frappe.ui.form.on("Package Subscription", { }, refresh: function (frm) { - if (frm.doc.outstanding_amount > 0) { + if (frm.doc.outstanding_amount > 0 && frm.doc.docstatus == 1) { frm.add_custom_button(__("Payment Entry"), function() { frappe.call({ method: "healthcare.healthcare.doctype.package_subscription.package_subscription.create_payment_entry", diff --git a/healthcare/healthcare/doctype/package_subscription/package_subscription.py b/healthcare/healthcare/doctype/package_subscription/package_subscription.py index 57d030145b..54c113ae69 100644 --- a/healthcare/healthcare/doctype/package_subscription/package_subscription.py +++ b/healthcare/healthcare/doctype/package_subscription/package_subscription.py @@ -8,6 +8,7 @@ class PackageSubscription(Document): def validate(self): + self.get_package_details() if self.total_package_amount: self.outstanding_amount = self.total_package_amount - self.paid_amount