Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"engine": "InnoDB",
"field_order": [
"posting_date",
"paid_to",
"paid_type",
"paid_to",
"paid_name",
"column_break_rdjj",
"amount",
Expand All @@ -31,25 +31,20 @@
"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,
"label": "Amount ",
"reqd": 1
},
{
"allow_in_quick_entry": 1,
"fieldname": "note",
"fieldtype": "Small Text",
"in_list_view": 1,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand All @@ -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"),
Expand All @@ -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
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()
8 changes: 7 additions & 1 deletion calicut_textiles/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
# }

}

Expand Down
Loading