feat: add kb_account_type custom field to Journal Entry
Adds a hidden, read-only 'KB Account Type' (Income/Expense) field to Journal Entry via Custom Field, visible only in list view. Populated automatically when a JE is created from a KB transaction: - Pay (drcr=D) → Expense - Receive (drcr=C) → Income Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
62bc550186
commit
3b44f5a694
|
|
@ -1645,6 +1645,7 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold
|
||||||
je.cheque_no = ref_no
|
je.cheque_no = ref_no
|
||||||
je.cheque_date = parsed_date
|
je.cheque_date = parsed_date
|
||||||
je.user_remark = purpose
|
je.user_remark = purpose
|
||||||
|
je.kb_account_type = "Expense" if payment_type == "Pay" else "Income"
|
||||||
|
|
||||||
# Compute per-account amounts with proper multi-currency handling
|
# Compute per-account amounts with proper multi-currency handling
|
||||||
currency_precision = cint(frappe.db.get_single_value("System Settings", "currency_precision") or 2)
|
currency_precision = cint(frappe.db.get_single_value("System Settings", "currency_precision") or 2)
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,7 @@ def _create_journal_entry_for_brt(txn, paid_from, paid_to, bank_txn, multi_curre
|
||||||
je.cheque_no = ref_no
|
je.cheque_no = ref_no
|
||||||
je.cheque_date = posting_date
|
je.cheque_date = posting_date
|
||||||
je.user_remark = bank_txn.description or txn.get("purpose") or ""
|
je.user_remark = bank_txn.description or txn.get("purpose") or ""
|
||||||
|
je.kb_account_type = "Expense" if is_pay else "Income"
|
||||||
if is_multi:
|
if is_multi:
|
||||||
je.multi_currency = 1
|
je.multi_currency = 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@ import frappe
|
||||||
def after_install():
|
def after_install():
|
||||||
cleanup_payment_entry_custom_fields()
|
cleanup_payment_entry_custom_fields()
|
||||||
ensure_bank_transaction_custom_fields()
|
ensure_bank_transaction_custom_fields()
|
||||||
|
ensure_journal_entry_custom_fields()
|
||||||
|
|
||||||
|
|
||||||
def after_migrate():
|
def after_migrate():
|
||||||
cleanup_payment_entry_custom_fields()
|
cleanup_payment_entry_custom_fields()
|
||||||
ensure_bank_transaction_custom_fields()
|
ensure_bank_transaction_custom_fields()
|
||||||
|
ensure_journal_entry_custom_fields()
|
||||||
|
|
||||||
|
|
||||||
KB_FIELDS = [
|
KB_FIELDS = [
|
||||||
|
|
@ -32,6 +34,21 @@ def ensure_bank_transaction_custom_fields():
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_journal_entry_custom_fields():
|
||||||
|
if not frappe.db.exists("Custom Field", {"dt": "Journal Entry", "fieldname": "kb_account_type"}):
|
||||||
|
cf = frappe.new_doc("Custom Field")
|
||||||
|
cf.dt = "Journal Entry"
|
||||||
|
cf.fieldname = "kb_account_type"
|
||||||
|
cf.fieldtype = "Select"
|
||||||
|
cf.options = "\nIncome\nExpense"
|
||||||
|
cf.label = "KB Account Type"
|
||||||
|
cf.in_list_view = 1
|
||||||
|
cf.hidden = 1
|
||||||
|
cf.read_only = 1
|
||||||
|
cf.insert(ignore_permissions=True)
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
|
|
||||||
def cleanup_payment_entry_custom_fields():
|
def cleanup_payment_entry_custom_fields():
|
||||||
for fieldname in KB_FIELDS:
|
for fieldname in KB_FIELDS:
|
||||||
if frappe.db.exists("Custom Field", {"dt": "Payment Entry", "fieldname": fieldname}):
|
if frappe.db.exists("Custom Field", {"dt": "Payment Entry", "fieldname": fieldname}):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue