This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ALYF Banking is a Frappe/ERPNext app that integrates bank accounts with ERPNext through EBICS (Electronic Banking Internet Communication Standard) protocol. It provides automated transaction synchronization, advanced bank reconciliation, and SEPA payment order processing for German, Austrian, French, and Swiss banks.
# Run all tests
bench --site [sitename] run-tests --app banking
# Run specific test file
bench --site [sitename] run-tests --app banking --module banking.ebics.doctype.sepa_payment_order.test_sepa_payment_order
# Run with coverage
bench --site [sitename] run-tests --app banking --coverage# Format Python code (uses ruff)
ruff format .
# Lint Python code
ruff check . --fix
# Format JavaScript
npx prettier --write "banking/**/*.js"
# Lint JavaScript
npx eslint "banking/**/*.js" --fix
# Run pre-commit hooks manually
pre-commit run --all-files# Build assets (from bench root)
bench build --app banking
# Clear cache and rebuild
bench clear-cache && bench build --app banking# Install app on a site
bench --site [sitename] install-app banking
# Uninstall (safely removes all customizations)
bench --site [sitename] uninstall-app bankingbanking/ebics/ - EBICS protocol integration
- Manages direct bank connections via EBICS protocol (H004/H005)
- Downloads CAMT documents (camt.052 intraday, camt.053 statements, camt.054 batches)
- Key files:
manager.py: EBICS session management using fintech libraryutils.py: Transaction sync, CAMT parsing, Bank Transaction creationdoctype/ebics_user/: EBICS credentials (keyring, passphrase, bank connection)doctype/ebics_request/: Audit log of EBICS downloadsdoctype/sepa_payment_order/: Outgoing payment batch managementdoctype/sepa_payment/: Individual payment records within orders
banking/klarna_kosma_integration/ - ALYF Banking Admin portal integration
- Communicates with ALYF's backend for license validation and user registration
- Key files:
admin.py: HTTP client for Banking Admin APIdoctype/banking_settings/: Central configuration (API tokens, feature flags)doctype/bank_reconciliation_tool_beta/: Advanced transaction matchingbank_reconciliation_tool_beta.py: Main DocTypeutils.py: SQL query builders for flexible matchingunpaid_vouchers.py: Payment Entry/Journal Entry creation
banking/overrides/ - ERPNext DocType customizations
bank_transaction.py: Enhanced reconciliation validation (CustomBankTransaction)bank_account.py: IBAN validation hooks
banking/connectors/ - External service communication
admin_request.py: Generic HTTP client for Admin APIadmin_transaction.py: Transaction data parsing
banking/custom/ - Custom fields and hooks for ERPNext DocTypes
purchase_invoice.py: SEPA payment order creation, discount calculationsbank.js,employee.js,supplier.js: Frontend customizations
EBICS Integration Flow:
EBICS User → EBICS Request → Bank Transaction → Bank Reconciliation Tool Beta
Outgoing Payment Flow:
Purchase Invoice → SEPA Payment Order → SEPA Payment (child) → EBICS Upload
Configuration:
Banking Settings (singleton)
├─ Banking Reference Mapping (custom field mappings per DocType)
└─ Voucher Matching Default (default DocTypes for reconciliation)
The reconciliation tool uses a scoring system (0-7 points) to rank potential matches:
- Amount match: 1 point
- Date match: 1 point
- Reference number match: 1 point
- Description contains document number: 1+ points
- Party validation: filters non-matching parties
Custom fields can be added via Banking Settings → Banking Reference Mapping to match on additional fields like PO numbers or custom references.
Scheduled Jobs (see hooks.py):
- Intraday sync: Every hour 7 AM - 6 PM on weekdays (
intraday_sync_ebics) - Full sync: Every 4 hours (
sync_all_accounts_and_transactions)
Sync Process:
- Retrieve EBICS Users with credentials
- Initialize EBICS Manager with keyring
- Download CAMT documents (C52/C53/C54)
- Parse SEPA transactions from XML
- Create Bank Transactions in ERPNext
- Handle batch transaction splitting (uses subtransaction_id)
Flow:
- Create from Purchase Invoice (button or bulk action)
- Auto-populates recipient bank account and outstanding amount
- Supports early payment discounts via
get_sepa_payment_amount()hook - Status: Draft → Approved → Transmitted
- Transmission options:
- Download XML (manual upload to bank)
- Send via EBICS (automated upload)
Discount Handling: If execution_date ≤ discount_date on Payment Schedule, discounted amount is used automatically.
Use @frappe.whitelist() for methods called from frontend. Example:
@frappe.whitelist()
def send_to_bank(self):
# Method callable via frappe.call()For complex matching queries, use pypika in utils.py:
from pypika import CustomFunction
from banking.klarna_kosma_integration.doctype.bank_reconciliation_tool_beta.utils import (
amount_rank_condition,
get_description_match_condition,
)Custom properties are defined in hooks.py as alyf_banking_property_setters and automatically reset on uninstall.
Tests use before_tests() in utils.py to initialize a test company with German settings. Inherit from frappe.tests.utils.FrappeTestCase.
Key hooks in hooks.py:
override_doctype_class: Replace Bank Transaction with CustomBankTransactiondoc_events: Validation and status change hooksbank_reconciliation_doctypes: Register Bank Transaction for reconciliationget_matching_queries: Point to custom matching logicget_payment_entries: Point to custom payment entry creation
Bank:
ebics_host_id: Bank's EBICS host identifierebics_url: Bank's EBICS endpoint URL
Bank Account:
- Validation: Auto-removes spaces from IBAN
Purchase Invoice:
supplier_bank_account: Link to supplier's Bank Accountemployee_bank_account: For business trip reimbursementssepa_payment_order_status: Tracks payment order lifecycle
Payment Schedule (of Purchase Invoice):
sepa_payment_order_status: Synced from linked SEPA Payment Order
Bank Transaction:
subtransaction_id: For split batch transactionstransaction_id: No longer unique (supports batch transactions)
- Uses tabs for indentation (see
pyproject.toml) - Line length: 110 characters
- Ruff for formatting and linting
- Type hints encouraged (typing-modules includes
frappe.types.DF)
- Prettier for formatting
- ESLint for linting
- Uses Frappe's
frappe.ui.form.on()pattern for DocType scripts
- Follows conventional commits (via commitlint)
- Format:
type(scope): description - Types: feat, fix, docs, style, refactor, test, chore
Edit unpaid_vouchers.py → get_payment_entries() to handle new DocTypes.
Add via Banking Settings → Banking Reference Mapping to match bank transactions on custom fields (e.g., custom_po_number).
Implement get_sepa_payment_amount() in your custom DocType via doc_events hook. Return the amount to pay based on execution_date.
Use before_reconcile hook in Bank Reconciliation Tool Beta frontend to prompt for additional fields:
frappe.ui.form.on("Bank Reconciliation Tool Beta", {
before_reconcile: function(frm, transaction, selected_vouchers) {
return new Promise((resolve) => {
frappe.prompt([{...}], (values) => resolve(values));
});
}
});- fintech: EBICS protocol implementation, SEPA XML parsing and IBAN/BIC validation
- frappe: Full-stack framework
- erpnext: ERP-System
- Check EBICS User status (keys initialized, certificates submitted)
- Review EBICS Request list for error messages
- Verify bank's EBICS URL and Host ID in Bank master
- Check Banking Settings → Enable EBICS
- Check EBICS User → start_date (transactions before this are ignored)
- Review error logs in ERPNext Error Log
- Check Banking Settings → Fintech License Key validity
- Verify Bank Account IBAN matches downloaded transactions
- Verify Banking Settings → Voucher Matching Defaults includes the DocType
- Check Banking Reference Mapping for custom field configurations
- Review Bank Transaction description and reference_number fields
- Test matching queries in Bank Reconciliation Tool Beta with debug mode
- Verify supplier/employee has bank account with IBAN
- Check Purchase Invoice → supplier_bank_account is set
- Ensure Payment Schedule has outstanding amount
- Review SEPA Payment Order status transitions
- Check EBICS User is activated for upload (HIA/INI sent)