fix: Create mode of payment if doesn't exists
This commit is contained in:
parent
a0599e5ac2
commit
db682d9e4c
@ -7,6 +7,7 @@ import frappe
|
||||
import unittest
|
||||
from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_settings import process_balance_info, verify_transaction
|
||||
from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice
|
||||
from erpnext.erpnext_integrations.utils import create_mode_of_payment
|
||||
|
||||
class TestMpesaSettings(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@ -20,7 +21,7 @@ class TestMpesaSettings(unittest.TestCase):
|
||||
frappe.db.sql('delete from `tabIntegration Request` where integration_request_service = "Mpesa"')
|
||||
|
||||
def test_creation_of_payment_gateway(self):
|
||||
mode_of_payment = frappe.get_doc("Mode of Payment", "Mpesa-_Test")
|
||||
mode_of_payment = create_mode_of_payment('Mpesa-_Test', payment_type="Phone")
|
||||
self.assertTrue(frappe.db.exists("Payment Gateway Account", {'payment_gateway': "Mpesa-_Test"}))
|
||||
self.assertTrue(mode_of_payment.name)
|
||||
self.assertEqual(mode_of_payment.type, "Phone")
|
||||
|
@ -52,7 +52,8 @@ def create_mode_of_payment(gateway, payment_type="General"):
|
||||
"payment_gateway": gateway
|
||||
}, ['payment_account'])
|
||||
|
||||
if not frappe.db.exists("Mode of Payment", gateway) and payment_gateway_account:
|
||||
mode_of_payment = frappe.db.exists("Mode of Payment", gateway)
|
||||
if not mode_of_payment and payment_gateway_account:
|
||||
mode_of_payment = frappe.get_doc({
|
||||
"doctype": "Mode of Payment",
|
||||
"mode_of_payment": gateway,
|
||||
@ -66,6 +67,10 @@ def create_mode_of_payment(gateway, payment_type="General"):
|
||||
})
|
||||
mode_of_payment.insert(ignore_permissions=True)
|
||||
|
||||
return mode_of_payment
|
||||
else:
|
||||
return frappe.get_doc("Mode of Payment", mode_of_payment)
|
||||
|
||||
def get_tracking_url(carrier, tracking_number):
|
||||
# Return the formatted Tracking URL.
|
||||
tracking_url = ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user