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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2026, sammish and contributors
// For license information, please see license.txt

frappe.ui.form.on("Daliy Cash Entry", {
refresh:function(frm) {
if (frm.doc.paid_type && frm.doc.docstatus === 1) {
frm.add_custom_button(__("Payment Entry"),function () {
frappe.call({
method:"calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.create_payment_entry",
args:{daliy_cash_entry:frm.doc.name},
callback:function (r) {
var doc = frappe.model.sync(r.message);
frappe.set_route("Form", doc[0].doctype, doc[0].name);
}
})
},__("Create"));
}
if(frm.doc.docstatus === 1){
frm.add_custom_button(__("Journal Entry"),function () {
frappe.call({
method:"calicut_textiles.calicut_textiles.doctype.daliy_cash_entry.daliy_cash_entry.create_journal_entry",
args:{daliy_cash_entry:frm.doc.name},
callback:function (r) {
var doc = frappe.model.sync(r.message);
frappe.set_route("Form", doc[0].doctype, doc[0].name);
}
})
},__("Create"));
}
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2026-01-26 17:22:26.542287",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"posting_date",
"paid_to",
"paid_type",
"paid_name",
"column_break_rdjj",
"amount",
"note",
"attatchment",
"section_break_m8ry",
"payment_entry",
"journal_entry",
"amended_from"
],
"fields": [
{
"fieldname": "section_break_m8ry",
"fieldtype": "Section Break"
},
{
"default": "Today",
"fieldname": "posting_date",
"fieldtype": "Date",
"in_list_view": 1,
"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"
},
{
"fieldname": "amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Amount ",
"reqd": 1
},
{
"fieldname": "note",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Note",
"reqd": 1
},
{
"fieldname": "attatchment",
"fieldtype": "Attach",
"label": "Attatchment "
},
{
"fieldname": "paid_type",
"fieldtype": "Data",
"hidden": 1,
"label": "Paid Type"
},
{
"fieldname": "paid_name",
"fieldtype": "Data",
"hidden": 1,
"label": "Paid Name"
},
{
"allow_on_submit": 1,
"fieldname": "payment_entry",
"fieldtype": "Link",
"hidden": 1,
"label": "Payment Entry",
"options": "Payment Entry"
},
{
"allow_on_submit": 1,
"fieldname": "journal_entry",
"fieldtype": "Link",
"hidden": 1,
"label": "Journal Entry",
"options": "Journal Entry"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Daliy Cash Entry",
"print_hide": 1,
"read_only": 1,
"search_index": 1
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2026-01-27 14:12:51.675806",
"modified_by": "Administrator",
"module": "Calicut Textiles",
"name": "Daliy Cash Entry",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"submit": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "CT CASH COUNTER",
"select": 1,
"share": 1,
"write": 1
},
{
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "CT CASH APPROVER",
"select": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "CT CASH APPROVER UNDER 5000",
"select": 1,
"share": 1,
"submit": 1,
"write": 1
}
],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright (c) 2026, sammish and contributors
# For license information, please see license.txt

import frappe
from frappe.model.document import Document


class DaliyCashEntry(Document):
def on_cancel(self):
if self.payment_entry:
pe = frappe.get_doc("Payment Entry", self.payment_entry)
if pe.docstatus == 1:
pe.cancel()
frappe.db.set_value(self.doctype, self.name, "payment_entry", None)
frappe.db.commit()
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 = ""

@frappe.whitelist()
def create_payment_entry(daliy_cash_entry):
doc = frappe.get_doc("Daliy Cash Entry", daliy_cash_entry)
company = frappe.db.get_single_value("Global Defaults", "default_company")
if doc.paid_type:
payment_entry = frappe.get_doc({
"doctype": "Payment Entry",
"payment_type": "Pay",
"mode_of_payment": "Cash",
"company": company,
"paid_from": frappe.db.get_value("Company", company, "default_cash_account"),
"party_type": doc.paid_type,
"party": doc.paid_name,
"received_amount":doc.amount,
"paid_amount": doc.amount,
"source_exchange_rate": 1,
"target_exchange_rate": 1,
"cost_center": frappe.db.get_value("Company", company, "cost_center"),
"remarks": doc.note
})
payment_entry.insert()
frappe.db.set_value(doc.doctype, doc.name, "payment_entry", payment_entry.name)
frappe.db.commit()
return payment_entry

@frappe.whitelist()
def create_journal_entry(daliy_cash_entry):
doc = frappe.get_doc("Daliy Cash Entry", daliy_cash_entry)
company = frappe.db.get_single_value("Global Defaults", "default_company")
journal_entry = frappe.get_doc({
"doctype": "Journal Entry",
"company": company,
"posting_date": doc.posting_date,
"user_remark": f"Paid To :{doc.paid_to}, Note:{doc.note}",
"accounts": [
{
"account": frappe.db.get_value("Company", company, "default_cash_account"),
"debit_in_account_currency": doc.amount,
"debit": doc.amount,
"cost_center": frappe.db.get_value("Company", company, "cost_center"),
},
{
"account": frappe.db.get_value("Company", company, "default_expense_account"),
"credit_in_account_currency": doc.amount,
"credit": doc.amount,
"cost_center": frappe.db.get_value("Company", company, "cost_center"),
}
]
})
journal_entry.insert()
frappe.db.set_value(doc.doctype, doc.name, "journal_entry", journal_entry.name)
frappe.db.commit()
return journal_entry
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2026, sammish and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestDaliyCashEntry(FrappeTestCase):
pass
Loading
Loading