refactor: use existing expense_income_type field from jey_erp

Replace custom kb_account_type field with the existing
expense_income_type field (label: Expense/Income) defined
in jey_erp. Remove the now-unnecessary ensure_journal_entry_custom_fields()
function from setup.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ali 2026-03-16 16:32:16 +04:00
parent 2f10fb4aa0
commit 3fbb02a7fc
3 changed files with 2 additions and 18 deletions

View File

@ -1645,7 +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" je.expense_income_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)

View File

@ -497,7 +497,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" je.expense_income_type = "Expense" if is_pay else "Income"
if is_multi: if is_multi:
je.multi_currency = 1 je.multi_currency = 1

View File

@ -4,13 +4,11 @@ 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 = [
@ -34,20 +32,6 @@ 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: