コード例 #1
0
def create_gateway_bank_account(name):
	"""Creates a gateway bank account of the same name"""

	company = frappe.db.get_value("Global Defaults", None, "default_company")

	if not company:
		return

	account = frappe.db.get_value(
		"Account",
		{"account_name": _(name), "company": company},
		["name", "account_currency"],
		as_dict=True)

	if not account:
		account = frappe.db.get_value(
			"Account",
			{"account_name": name, "company": company},
			["name", "account_currency"],
			as_dict=True)

	if not account:
		account = create_bank_account({
			"company_name": company,
			"bank_account": _(name)
		})

	if not account:
		frappe.msgprint(_("Payment Gatway '{0}' was not created. Please create one manually.".format(name)))
		return None

	return account
コード例 #2
0
def create_payment_gateway_account(gateway, payment_channel="Email"):
    from erpnext.setup.setup_wizard.operations.company_setup import create_bank_account

    company = frappe.db.get_value("Global Defaults", None, "default_company")
    if not company:
        return

    # NOTE: we translate Payment Gateway account name because that is going to be used by the end user
    bank_account = frappe.db.get_value("Account", {
        "account_name": _(gateway),
        "company": company
    }, ["name", 'account_currency'],
                                       as_dict=1)

    if not bank_account:
        # check for untranslated one
        bank_account = frappe.db.get_value("Account", {
            "account_name": gateway,
            "company": company
        }, ["name", 'account_currency'],
                                           as_dict=1)

    if not bank_account:
        # try creating one
        bank_account = create_bank_account({
            "company_name": company,
            "bank_account": _(gateway)
        })

    if not bank_account:
        frappe.msgprint(
            _("Payment Gateway Account not created, please create one manually."
              ))
        return

    # if payment gateway account exists, return
    if frappe.db.exists("Payment Gateway Account", {
            "payment_gateway": gateway,
            "currency": bank_account.account_currency
    }):
        return

    try:
        frappe.get_doc({
            "doctype": "Payment Gateway Account",
            "is_default": 1,
            "payment_gateway": gateway,
            "payment_account": bank_account.name,
            "currency": bank_account.account_currency,
            "payment_channel": payment_channel
        }).insert(ignore_permissions=True)

    except frappe.DuplicateEntryError:
        # already exists, due to a reinstall?
        pass
コード例 #3
0
ファイル: utils.py プロジェクト: Aptronics/erpnext
def create_payment_gateway_account(gateway):
	from erpnext.setup.setup_wizard.operations.company_setup import create_bank_account

	company = frappe.db.get_value("Global Defaults", None, "default_company")
	if not company:
		return

	# NOTE: we translate Payment Gateway account name because that is going to be used by the end user
	bank_account = frappe.db.get_value("Account", {"account_name": _(gateway), "company": company},
		["name", 'account_currency'], as_dict=1)

	if not bank_account:
		# check for untranslated one
		bank_account = frappe.db.get_value("Account", {"account_name": gateway, "company": company},
			["name", 'account_currency'], as_dict=1)

	if not bank_account:
		# try creating one
		bank_account = create_bank_account({"company_name": company, "bank_account": _(gateway)})

	if not bank_account:
		frappe.msgprint(_("Payment Gateway Account not created, please create one manually."))
		return

	# if payment gateway account exists, return
	if frappe.db.exists("Payment Gateway Account",
		{"payment_gateway": gateway, "currency": bank_account.account_currency}):
		return

	try:
		frappe.get_doc({
			"doctype": "Payment Gateway Account",
			"is_default": 1,
			"payment_gateway": gateway,
			"payment_account": bank_account.name,
			"currency": bank_account.account_currency
		}).insert(ignore_permissions=True)

	except frappe.DuplicateEntryError:
		# already exists, due to a reinstall?
		pass