fix: create custom pos fields

This commit is contained in:
Mangesh-Khairnar
2020-09-15 14:38:06 +05:30
parent 757fa5d010
commit 27f81e06ea
3 changed files with 70 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import frappe
from frappe import _
import base64, hashlib, hmac
from six.moves.urllib.parse import urlparse
from erpnext import get_default_company
def validate_webhooks_request(doctype, hmac_key, secret_key='secret'):
def innerfn(fn):
@@ -41,3 +42,22 @@ def get_webhook_address(connector_name, method, exclude_uri=False):
server_url = '{uri.scheme}://{uri.netloc}/api/method/{endpoint}'.format(uri=urlparse(url), endpoint=endpoint)
return server_url
def create_mode_of_payment(gateway):
payment_gateway_account = frappe.db.get_value("Payment Gateway Account", {
"payment_gateway": gateway
}, ['payment_account'])
if not frappe.db.exists("Mode of Payment", gateway) and payment_gateway_account:
mode_of_payment = frappe.get_doc({
"doctype": "Mode of Payment",
"mode_of_payment": gateway,
"enabled": 1,
"type": "General",
"account": {
"doctype": "Mode of Payment Account",
"company": get_default_company(),
"default_account": payment_gateway_account
}
})
mode_of_payment.insert(ignore_permissions=True)