From 0d47d5140742467de0bbd3b30725faafda664fb0 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 14 Mar 2017 14:46:05 +0530 Subject: [PATCH] [fix] modified payment request to cope with new payment structure (#7957) * [fix] modified payment request to cope with new payment structure * [fix] moved payment gateway doctype from accounts to core --- .../doctype/payment_gateway/__init__.py | 0 .../payment_gateway/payment_gateway.js | 8 -- .../payment_gateway/payment_gateway.json | 104 ------------------ .../payment_gateway/payment_gateway.py | 10 -- .../payment_gateway/test_payment_gateway.py | 12 -- .../payment_request/payment_request.py | 6 +- erpnext/accounts/utils.py | 12 +- erpnext/hooks.py | 2 +- 8 files changed, 5 insertions(+), 149 deletions(-) delete mode 100644 erpnext/accounts/doctype/payment_gateway/__init__.py delete mode 100644 erpnext/accounts/doctype/payment_gateway/payment_gateway.js delete mode 100644 erpnext/accounts/doctype/payment_gateway/payment_gateway.json delete mode 100644 erpnext/accounts/doctype/payment_gateway/payment_gateway.py delete mode 100644 erpnext/accounts/doctype/payment_gateway/test_payment_gateway.py diff --git a/erpnext/accounts/doctype/payment_gateway/__init__.py b/erpnext/accounts/doctype/payment_gateway/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/erpnext/accounts/doctype/payment_gateway/payment_gateway.js b/erpnext/accounts/doctype/payment_gateway/payment_gateway.js deleted file mode 100644 index 0eff5a56084..00000000000 --- a/erpnext/accounts/doctype/payment_gateway/payment_gateway.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Payment Gateway', { - refresh: function(frm) { - - } -}); diff --git a/erpnext/accounts/doctype/payment_gateway/payment_gateway.json b/erpnext/accounts/doctype/payment_gateway/payment_gateway.json deleted file mode 100644 index ca4ba5d1736..00000000000 --- a/erpnext/accounts/doctype/payment_gateway/payment_gateway.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "allow_copy": 0, - "allow_import": 0, - "allow_rename": 0, - "autoname": "field:gateway", - "beta": 0, - "creation": "2015-12-15 22:26:45.221162", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "fields": [ - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "gateway", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Gateway", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 1, - "in_dialog": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2016-07-25 05:24:22.726993", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Payment Gateway", - "name_case": "", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "System Manager", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Accounts Manager", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - } - ], - "quick_entry": 1, - "read_only": 1, - "read_only_onload": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_gateway/payment_gateway.py b/erpnext/accounts/doctype/payment_gateway/payment_gateway.py deleted file mode 100644 index 80799e311b9..00000000000 --- a/erpnext/accounts/doctype/payment_gateway/payment_gateway.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe.model.document import Document - -class PaymentGateway(Document): - pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_gateway/test_payment_gateway.py b/erpnext/accounts/doctype/payment_gateway/test_payment_gateway.py deleted file mode 100644 index 2faf1a7fb4f..00000000000 --- a/erpnext/accounts/doctype/payment_gateway/test_payment_gateway.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt -from __future__ import unicode_literals - -import frappe -import unittest - -# test_records = frappe.get_test_records('Payment Gateway') - -class TestPaymentGateway(unittest.TestCase): - pass diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 99deb3fd96f..fdb598e55e6 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -10,7 +10,7 @@ from frappe.utils import flt, nowdate, get_url from erpnext.accounts.party import get_party_account from erpnext.accounts.utils import get_account_currency from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, get_company_defaults -from frappe.integration_broker.doctype.integration_service.integration_service import get_integration_controller +from frappe.integrations.utils import get_payment_gateway_controller class PaymentRequest(Document): def validate(self): @@ -65,11 +65,11 @@ class PaymentRequest(Document): data = frappe.db.get_value(self.reference_doctype, self.reference_name, ["company", "customer_name"], as_dict=1) - controller = get_integration_controller(self.payment_gateway) + controller = get_payment_gateway_controller(self.payment_gateway) controller.validate_transaction_currency(self.currency) return controller.get_payment_url(**{ - "amount": self.grand_total, + "amount": flt(self.grand_total, self.precision("grand_total")), "title": data.company, "description": self.subject, "reference_doctype": "Payment Request", diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index c2812d486e1..4827e76b1c2 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -693,19 +693,9 @@ def get_children(): return acc -def create_payment_gateway_and_account(gateway): - create_payment_gateway(gateway) +def create_payment_gateway_account(gateway): create_payment_gateway_account(gateway) -def create_payment_gateway(gateway): - # NOTE: we don't translate Payment Gateway name because it is an internal doctype - if not frappe.db.exists("Payment Gateway", gateway): - payment_gateway = frappe.get_doc({ - "doctype": "Payment Gateway", - "gateway": gateway - }) - payment_gateway.insert(ignore_permissions=True) - def create_payment_gateway_account(gateway): from erpnext.setup.setup_wizard.setup_wizard import create_bank_account diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 3e69340bb7f..514ee86c0e3 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -194,4 +194,4 @@ bot_parsers = [ get_site_info = 'erpnext.utilities.get_site_info' -payment_gateway_enabled = "erpnext.accounts.utils.create_payment_gateway_and_account" +payment_gateway_enabled = "erpnext.accounts.utils.create_payment_gateway_account"