From 059d5ab439ec5ca22e3282ecce931e897c57d559 Mon Sep 17 00:00:00 2001 From: AadithPunathilBuildsuite Date: Wed, 28 Jan 2026 13:09:14 +0530 Subject: [PATCH] fix:update the daliy cash --- .../daliy_cash_entry/daliy_cash_entry.js | 4 +- .../daliy_cash_entry/daliy_cash_entry.json | 42 ++++++++------ .../daliy_cash_entry/daliy_cash_entry.py | 56 +++++++++---------- calicut_textiles/hooks.py | 8 ++- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.js b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.js index 5914711..55e4a70 100644 --- a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.js +++ b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.js @@ -3,7 +3,7 @@ frappe.ui.form.on("Daliy Cash Entry", { refresh:function(frm) { - if (frm.doc.paid_type && frm.doc.docstatus === 1) { + if (frm.doc.paid_type!="Other" && frm.doc.docstatus === 1 && !frm.doc.payment_entry) { frm.add_custom_button(__("Payment Entry"),function () { frappe.call({ method:"calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.create_payment_entry", @@ -15,7 +15,7 @@ frappe.ui.form.on("Daliy Cash Entry", { }) },__("Create")); } - if(frm.doc.docstatus === 1){ + if(frm.doc.paid_type=="Other" &&frm.doc.docstatus === 1 && !frm.doc.journal_entry){ frm.add_custom_button(__("Journal Entry"),function () { frappe.call({ method:"calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.create_journal_entry", diff --git a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.json b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.json index 1db7c5c..932f51f 100644 --- a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.json +++ b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.json @@ -6,8 +6,8 @@ "engine": "InnoDB", "field_order": [ "posting_date", - "paid_to", "paid_type", + "paid_to", "paid_name", "column_break_rdjj", "amount", @@ -31,18 +31,12 @@ "label": "Posting Date", "reqd": 1 }, - { - "fieldname": "paid_to", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Paid To", - "reqd": 1 - }, { "fieldname": "column_break_rdjj", "fieldtype": "Column Break" }, { + "allow_in_quick_entry": 1, "fieldname": "amount", "fieldtype": "Currency", "in_list_view": 1, @@ -50,6 +44,7 @@ "reqd": 1 }, { + "allow_in_quick_entry": 1, "fieldname": "note", "fieldtype": "Small Text", "in_list_view": 1, @@ -62,16 +57,12 @@ "label": "Attatchment " }, { - "fieldname": "paid_type", - "fieldtype": "Data", - "hidden": 1, - "label": "Paid Type" - }, - { + "allow_in_quick_entry": 1, + "depends_on": "eval:doc.paid_type==\"Other\"", "fieldname": "paid_name", "fieldtype": "Data", - "hidden": 1, - "label": "Paid Name" + "label": "Paid Name", + "mandatory_depends_on": "eval:doc.paid_type==\"Other\"" }, { "allow_on_submit": 1, @@ -98,13 +89,30 @@ "print_hide": 1, "read_only": 1, "search_index": 1 + }, + { + "allow_in_quick_entry": 1, + "fieldname": "paid_type", + "fieldtype": "Select", + "label": "Paid Type", + "options": "\nCustomer\nEmployee\nSupplier\nOther", + "reqd": 1 + }, + { + "allow_in_quick_entry": 1, + "depends_on": "eval:doc.paid_type!=\"Other\"", + "fieldname": "paid_to", + "fieldtype": "Dynamic Link", + "label": "Paid To", + "mandatory_depends_on": "eval:doc.paid_type!=\"Other\"", + "options": "paid_type" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2026-01-27 14:12:51.675806", + "modified": "2026-01-28 13:08:44.577022", "modified_by": "Administrator", "module": "Calicut Textiles", "name": "Daliy Cash Entry", diff --git a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.py b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.py index 9a512fb..25a7227 100644 --- a/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.py +++ b/calicut_textiles/calicut_textiles/doctype/daliy_cash_entry/daliy_cash_entry.py @@ -13,39 +13,14 @@ def on_cancel(self): pe.cancel() frappe.db.set_value(self.doctype, self.name, "payment_entry", None) frappe.db.commit() - pe.delete() + # pe.delete() if self.journal_entry: je = frappe.get_doc("Journal Entry", self.journal_entry) if je.docstatus == 1: je.cancel() frappe.db.set_value(self.doctype, self.name, "journal_entry", None) frappe.db.commit() - je.delete() - def validate(self): - if not self.paid_to: - return - - emp = frappe.db.get_value( - "Employee", - {"employee_name": ["like", f"%{self.paid_to}%"]}, - "name" - ) - - sup = frappe.db.get_value( - "Supplier", - {"supplier_name": ["like", f"%{self.paid_to}%"]}, - "name" - ) - - if emp: - self.paid_type = "Employee" - self.paid_name = emp - elif sup: - self.paid_type = "Supplier" - self.paid_name = sup - else: - self.paid_type = "" - self.paid_name = "" + # je.delete() @frappe.whitelist() def create_payment_entry(daliy_cash_entry): @@ -59,7 +34,7 @@ def create_payment_entry(daliy_cash_entry): "company": company, "paid_from": frappe.db.get_value("Company", company, "default_cash_account"), "party_type": doc.paid_type, - "party": doc.paid_name, + "party": doc.paid_to, "received_amount":doc.amount, "paid_amount": doc.amount, "source_exchange_rate": 1, @@ -80,7 +55,7 @@ def create_journal_entry(daliy_cash_entry): "doctype": "Journal Entry", "company": company, "posting_date": doc.posting_date, - "user_remark": f"Paid To :{doc.paid_to}, Note:{doc.note}", + "user_remark": f"Paid To :{doc.paid_name}, Note:{doc.note}", "accounts": [ { "account": frappe.db.get_value("Company", company, "default_cash_account"), @@ -99,4 +74,25 @@ def create_journal_entry(daliy_cash_entry): journal_entry.insert() frappe.db.set_value(doc.doctype, doc.name, "journal_entry", journal_entry.name) frappe.db.commit() - return journal_entry \ No newline at end of file + return journal_entry + + +@frappe.whitelist() +def delete_linked_daliy_cash_entry(payment_entry, method): + dce_name = frappe.db.get_value("Daliy Cash Entry", {"payment_entry": payment_entry.name}) + if dce_name: + dce = frappe.get_doc("Daliy Cash Entry", dce_name) + frappe.db.set_value(dce.doctype, dce.name, "payment_entry", None) + frappe.db.commit() + if dce.docstatus == 1: + dce.cancel() + +@frappe.whitelist() +def delete_linked_journal_daliy_cash_entry(journal_entry, method): + dce_name = frappe.db.get_value("Daliy Cash Entry", {"journal_entry": journal_entry.name}) + if dce_name: + dce = frappe.get_doc("Daliy Cash Entry", dce_name) + frappe.db.set_value(dce.doctype, dce.name, "journal_entry", None) + frappe.db.commit() + if dce.docstatus == 1: + dce.cancel() \ No newline at end of file diff --git a/calicut_textiles/hooks.py b/calicut_textiles/hooks.py index fcea814..3014efb 100644 --- a/calicut_textiles/hooks.py +++ b/calicut_textiles/hooks.py @@ -184,7 +184,13 @@ }, "Employee Checkin": { "before_save": "calicut_textiles.calicut_textiles.events.employee_checkin.update_employee_checkin_fields" - } + }, + # "Payment Entry": { + # "before_delete": "calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.delete_linked_daliy_cash_entry" + # }, + # "Journal Entry": { + # "before_delete": "calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.delete_linked_journal_daliy_cash_entry" + # } }