Skip to content

Commit

Permalink
Merge branch 'ft/payment-gateways' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
meaziz authored Mar 11, 2024
2 parents 3e03828 + e84bb84 commit b1f266a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-02-13 11:37:44.390686",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"gateway_name",
"gateway_account"
],
"fields": [
{
"fieldname": "gateway_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Gateway Name"
},
{
"fieldname": "gateway_account",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Gateway Account",
"options": "Account"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-02-13 11:37:44.390686",
"modified_by": "Administrator",
"module": "Ecommerce Integrations",
"name": "Payment Gateways",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023, Frappe and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document

class PaymentGateways(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"default_sales_tax_account",
"column_break_qibo",
"default_shipping_charges_account",
"payment_gateways_section",
"payment_gateways",
"erpnext_to_shopify_sync_section",
"upload_erpnext_items",
"update_shopify_item_on_update",
Expand Down Expand Up @@ -388,11 +390,21 @@
"label": "Default Shipping Charges Account",
"options": "Account"
}
"fieldname": "payment_gateways_section",
"fieldtype": "Section Break",
"label": "Payment Gateways"
},
{
"fieldname": "payment_gateways",
"fieldtype": "Table",
"label": "Payment Gateways",
"options": "Payment Gateways"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-10-24 10:38:49.247431",
"modified": "2023-02-13 12:24:10.208168",
"modified_by": "Administrator",
"module": "shopify",
"name": "Shopify Setting",
Expand All @@ -411,6 +423,5 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
16 changes: 13 additions & 3 deletions ecommerce_integrations/shopify/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create_sales_invoice(shopify_order, setting, so):
sales_invoice.insert(ignore_mandatory=True)
sales_invoice.submit()
if sales_invoice.grand_total > 0:
make_payament_entry_against_sales_invoice(sales_invoice, setting, posting_date)
make_payament_entry_against_sales_invoice(sales_invoice, setting, shopify_order, posting_date)

if shopify_order.get("note"):
sales_invoice.add_comment(text=f"Order Note: {shopify_order.get('note')}")
Expand All @@ -63,13 +63,23 @@ def set_cost_center(items, cost_center):
item.cost_center = cost_center


def make_payament_entry_against_sales_invoice(doc, setting, posting_date=None):
def make_payament_entry_against_sales_invoice(doc, setting, shopify_order, posting_date=None):
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
_bank_account = setting.get('cash_bank_account')

payment_entry = get_payment_entry(doc.doctype, doc.name, bank_account=setting.cash_bank_account)
if len(shopify_order.get('payment_gateway_names')):
doc_gatewaty = shopify_order.get('payment_gateway_names')[0]

if len(setting.get("payment_gateways")):
for gateway in setting.get("payment_gateways"):
if doc_gatewaty == gateway.get("gateway_name"):
_bank_account = gateway.get("gateway_account")

payment_entry = get_payment_entry(doc.doctype, doc.name, bank_account=_bank_account)
payment_entry.flags.ignore_mandatory = True
payment_entry.reference_no = doc.name
payment_entry.posting_date = posting_date or nowdate()
payment_entry.reference_date = posting_date or nowdate()
payment_entry.insert(ignore_permissions=True)
payment_entry.submit()
frappe.db.commit()

0 comments on commit b1f266a

Please sign in to comment.