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>
In "Both" mode, mappings were saved before documents were created,
so a failed document still produced a mapping entry.
Now for "Both" mode: document is created first, and the mapping row
is added only on success. Settings are saved once after all transactions.
"Mappings Only" and "Documents & Reconcile" modes are unaffected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
Replace ad-hoc if/elif branches with a unified approach:
1. Read txn_currency from the transaction data
2. Convert amount → company currency via txn_rate
3. Derive each account's amount in its own currency
4. Recompute exact exchange rates from rounded amounts
to keep Frappe's debit == credit in company currency
Fixes the bug where a $40 debit was recorded as ~$25 debit
and 40 AZN credit due to dividing instead of multiplying
when the transaction currency matched the foreign account.
Applies to both bank_api.py (_import_one_transaction JE path)
and mapping.py (_create_journal_entry_for_brt).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
For Receive transactions, paid_to (bank account) should be debited
and paid_from (income/receivable account) should be credited.
The logic was inverted in both bank_api.py and mapping.py.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>