chore: working state on barebones functions
diff --git a/erpnext/accounts/doctype/unreconcile_payment_entries/unreconcile_payment_entries.json b/erpnext/accounts/doctype/unreconcile_payment_entries/unreconcile_payment_entries.json
index 5beb39d..f70f4db 100644
--- a/erpnext/accounts/doctype/unreconcile_payment_entries/unreconcile_payment_entries.json
+++ b/erpnext/accounts/doctype/unreconcile_payment_entries/unreconcile_payment_entries.json
@@ -6,41 +6,18 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
- "voucher_type",
- "voucher_no",
- "reference_type",
+ "reference_doctype",
"reference_name",
"allocated_amount",
"unlinked"
],
"fields": [
{
- "fieldname": "voucher_type",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Voucher Type",
- "options": "DocType"
- },
- {
- "fieldname": "voucher_no",
- "fieldtype": "Dynamic Link",
- "in_list_view": 1,
- "label": "Voucher No",
- "options": "voucher_type"
- },
- {
- "fieldname": "reference_type",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Reference Type",
- "options": "DocType"
- },
- {
"fieldname": "reference_name",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"label": "Reference Name",
- "options": "reference_type"
+ "options": "reference_doctype"
},
{
"fieldname": "allocated_amount",
@@ -54,12 +31,19 @@
"fieldtype": "Check",
"in_list_view": 1,
"label": "Unlinked"
+ },
+ {
+ "fieldname": "reference_doctype",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Reference Type",
+ "options": "DocType"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2023-08-22 11:22:20.381079",
+ "modified": "2023-08-22 15:00:33.203161",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Unreconcile Payment Entries",
diff --git a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.js b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.js
index d667003..03a8253 100644
--- a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.js
+++ b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.js
@@ -1,8 +1,25 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-// frappe.ui.form.on("Unreconcile Payments", {
-// refresh(frm) {
+frappe.ui.form.on("Unreconcile Payments", {
+ refresh(frm) {
+ frm.set_query("voucher_type", function() {
+ return {
+ filters: {
+ name: "Payment Entry"
+ }
+ }
+ });
-// },
-// });
+
+ frm.set_query("voucher_no", function(doc) {
+ return {
+ filters: {
+ company: doc.company,
+ docstatus: 1
+ }
+ }
+ });
+
+ },
+});
diff --git a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.json b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.json
index c182a63..f4b3cd7 100644
--- a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.json
+++ b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.json
@@ -9,7 +9,9 @@
"engine": "InnoDB",
"field_order": [
"company",
- "entries",
+ "voucher_type",
+ "voucher_no",
+ "references",
"amended_from"
],
"fields": [
@@ -29,16 +31,28 @@
"options": "Company"
},
{
- "fieldname": "entries",
+ "fieldname": "voucher_type",
+ "fieldtype": "Link",
+ "label": "Voucher Type",
+ "options": "DocType"
+ },
+ {
+ "fieldname": "voucher_no",
+ "fieldtype": "Dynamic Link",
+ "label": "Voucher No",
+ "options": "voucher_type"
+ },
+ {
+ "fieldname": "references",
"fieldtype": "Table",
- "label": "Entries",
+ "label": "References",
"options": "Unreconcile Payment Entries"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-08-22 11:07:03.854434",
+ "modified": "2023-08-22 14:11:13.073414",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Unreconcile Payments",
diff --git a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.py b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.py
index 96bcc00..df08d79 100644
--- a/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.py
+++ b/erpnext/accounts/doctype/unreconcile_payments/unreconcile_payments.py
@@ -1,9 +1,38 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
-# import frappe
+import frappe
from frappe.model.document import Document
+from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries, update_voucher_outstanding
+
class UnreconcilePayments(Document):
- pass
+ def before_save(self):
+ if self.voucher_type == "Payment Entry":
+ references = frappe.db.get_all(
+ "Payment Entry Reference",
+ filters={"docstatus": 1, "parent": self.voucher_no},
+ fields=["reference_doctype", "reference_name", "allocated_amount"],
+ )
+
+ self.set("references", [])
+ for ref in references:
+ self.append("references", ref)
+
+ def on_submit(self):
+ payment_type, paid_from, paid_to, party_type, party = frappe.db.get_all(
+ self.voucher_type,
+ filters={"name": self.voucher_no},
+ fields=["payment_type", "paid_from", "paid_to", "party_type", "party"],
+ as_list=1,
+ )[0]
+ account = paid_from if payment_type == "Receive" else paid_to
+
+ for ref in self.references:
+ doc = frappe.get_doc(ref.reference_doctype, ref.reference_name)
+ unlink_ref_doc_from_payment_entries(doc)
+ update_voucher_outstanding(
+ ref.reference_doctype, ref.reference_name, account, party_type, party
+ )
+ frappe.db.set_value("Unreconcile Payment Entries", ref.name, "unlinked", True)