fix(payment gateway): add missing removeAccount function

This commit is contained in:
raizasafeel
2026-03-02 13:02:06 +05:30
parent b95a308f7a
commit 5ae5634753
2 changed files with 26 additions and 0 deletions

View File

@@ -88,6 +88,7 @@
import {
Badge,
Button,
call,
createListResource,
FeatherIcon,
ListView,
@@ -97,10 +98,12 @@ import {
ListRow,
ListRowItem,
ListSelectBanner,
toast,
} from 'frappe-ui'
import { computed, ref } from 'vue'
import { Plus, Trash2 } from 'lucide-vue-next'
import PaymentGatewayDetails from '@/components/Settings/PaymentGatewayDetails.vue'
import { cleanError } from '@/utils'
const showForm = ref(false)
const currentGateway = ref(null)
@@ -128,6 +131,23 @@ const openForm = (gatewayID) => {
showForm.value = true
}
const removeAccount = (selections, unselectAll) => {
call('lms.lms.api.delete_documents', {
doctype: 'Payment Gateway',
documents: Array.from(selections),
})
.then(() => {
paymentGateways.reload()
toast.success(__('Payment gateways deleted successfully'))
unselectAll()
})
.catch((err) => {
toast.error(
cleanError(err.messages[0]) || __('Error deleting payment gateways')
)
})
}
const columns = computed(() => {
return [
{

View File

@@ -702,7 +702,13 @@ def save_certificate_details(
@frappe.whitelist()
def delete_documents(doctype: str, documents: list):
frappe.only_for("Moderator")
meta = frappe.get_meta(doctype)
non_lms_allowed = ["Payment Gateway", "Email Template"]
if meta.module != "LMS" and doctype not in non_lms_allowed:
frappe.throw(_("Deletion not allowed for {0}").format(doctype))
for doc in documents:
if not isinstance(doc, str) or not doc.strip():
frappe.throw(_("Invalid document name"))
frappe.delete_doc(doctype, doc)