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