Commit Graph

240 Commits

Author SHA1 Message Date
Ali 0672441be3 feat(bank-integration): Excel Preset rework — sample-driven columns, auto date format
- Sample File on Preset: upload once, headers populate the Excel Column
  Autocomplete in the mapping table; Clear Sample button reverts to free text.
- Date format: hidden behind "Use Custom Date Format" checkbox; parser tries
  24 common formats (ISO/EU/US × -./\\\\ × with/without time) automatically.
  Surfaces a clear "open the preset and enable custom format" dialog on
  unparseable dates, instead of silently dropping rows.
- Standard Field options renamed from machine codes (date, reference_number…)
  to readable labels (Date, Reference Number…); parser maps labels → codes.
  Idempotent migration converts existing rows.
- Header matching is now case- and whitespace-insensitive.
- Direction-column aliases extended with Azerbaijani terms (Mədaxil/Məxaric/
  Daxil/Çıxıb/Gəlir/Xərc).
- cost_center in transaction_mappings filtered to is_group:0 in the form.
- Load Data result surfaces dropped_date / dropped_amount counts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 10:44:15 +00:00
Ali 751154efa8 feat(bank-integration): name Customer/Supplier registry records after their text name
Bank Integration Customer/Supplier used generic BIC-####/BIS-#### ids.
Switched to the Kapital Bank scheme: an autoname() controller method
sets the record name to customer_name / supplier_name (truncated to 140,
-N on collision since multiple Bank Integrations can hold the same
counterparty). The after_migrate pass renames any existing BIC-/BIS-/
BIP-#### records to their readable names.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 13:20:55 +00:00
Ali fcdfffbcf0 refactor(bank-integration): registries only via "Load Data"; resolve party at reconcile time
The Excel import dialog no longer has the "Also load counterparties &
purposes" checkbox — BT import now only creates Bank Transactions.
Registries (Bank Integration Customer/Supplier/Purpose) are populated
exclusively through the "Load Data" button on the Bank Integration form.

Since BTs are now always imported without a party, Create & Reconcile
resolves it: a BT's bank_party_name (the counterparty text from the
file) is looked up in the customer/supplier mappings, and if that
counterparty is mapped to an ERPNext party, the txn gets that party —
so counterparty-based transaction-mapping rules match and the created
PE/JE carries the party. A safety guard: a party is only attached to a
Payment Entry when one of the GL accounts is Receivable/Payable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 13:01:27 +00:00
Ali 42cac5a006 feat(bank-integration): fuzzy purpose matching in BRT Create & Reconcile
_find_mapping_for_txn now tries exact-substring purpose matches first
(unchanged), then falls back to a partial-ratio fuzzy match against
similarity_threshold_purpose — so a short/imprecise purpose keyword can
match somewhere inside a long bank-statement description. Order:
purpose+counterparty (exact) > purpose-only (exact) > purpose+
counterparty (fuzzy) > purpose-only (fuzzy) > counterparty-only >
fallback. Set the threshold to 100 to keep the old substring-only
behaviour. This makes similarity_threshold_purpose actually do something
in the BRT path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:22:40 +00:00
Ali cd162c1f89 feat(bank-integration): name purposes after the purpose text (like Kapital Bank)
Bank Integration Purpose used a generic BIP-#### id. Switched to the
Kapital Bank Purpose scheme: an autoname() controller method sets the
record name to the purpose_keyword text (truncated to 140, -N on
collision). A migration in after_migrate renames any existing BIP-####
records to their readable names (Link references update automatically).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 11:45:57 +00:00
Ali 8043b43875 fix(bank-integration): clearing a mapping row's ERP link resets the registry record
On save, a Bank Integration Customer/Supplier whose mapping row had its
erp_customer / erp_supplier cleared (not just whose row was deleted) is
now flipped back to status=New with mapped_customer/customer_group/
territory/payment_terms cleared — so a registry record never keeps a
phantom mapping.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 11:38:02 +00:00
Ali ac7be1021f fix(bank-integration): create party without a group when none is configured
The first-leaf fallback meant customers always landed in "Individual"
even when no Customer Group was chosen. Customer/Supplier/Territory
aren't actually mandatory in ERPNext, so now: a configured value is
validated (exists + leaf) and used; nothing configured -> the party is
created with an empty customer_group / supplier_group / territory.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 11:05:04 +00:00
Ali 1abdedce20 feat(bank-integration): fall back to first leaf node when no group is configured + filter group fields
Creating customers/suppliers no longer requires a default Customer/
Supplier Group or Territory on the Bank Integration — when none is set,
the first leaf (non-group) node of the tree is used. A configured value
is still validated (must exist and be a leaf), with a clear message.
Also: the default-group / default-territory Link fields (and the
matching mapping child-table fields) now filter to is_group=0 so a group
node can't be selected in the first place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:53:23 +00:00
Ali 94ce72e4fb fix(bank-integration): reject group-node Customer/Supplier Group / Territory upfront
Customer/Supplier require a leaf node for customer_group/supplier_group/
territory; selecting a group node makes ERPNext throw "Cannot select a
Group type ...". The upfront validation now also checks is_group and
returns a clear message before any record is touched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:45:21 +00:00
Ali 7e862e48e5 feat(bank-integration): populate the Data tab subtabs
The Accounts / Customers / Suppliers / Purposes subtabs under "Data"
were stuck on "Loading..." — nothing rendered into them. Added
get_bi_reference_data_list (paginated rows for each registry, scoped to
the Bank Integration record) and the client-side rendering in
bank_integration.js (tables with status pills, links to the underlying
records and their ERPNext mappings, plus a Refresh button per subtab) —
mirroring the kapital_bank_settings Data tab.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:40:23 +00:00
Ali 2dba6908b0 fix(bank-integration): clear validation message when default groups aren't set
Creating customers/suppliers/bank accounts from unmapped rows fell back
to "All Customer Groups" / "All Territories" / "All Supplier Groups",
which don't exist on localized sites — ERPNext then threw a cryptic
"Could not find Customer Group: All Customer Groups". Now creation
validates upfront and returns a clear message ("Set a Default Customer
Group on the Bank Integration ...") before touching any records. Same
for Territory, Supplier Group, and (for Bank Accounts) Company / Bank.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 10:31:34 +00:00
Ali 1d6bdc8424 feat(bank-integration): optional registry loading + "Load Data" button
The Excel import dialog on the Bank Transaction list gains an "Also load
counterparties & purposes" checkbox (default on — preserves current
behaviour). When unchecked, only Bank Transactions are created and the
Bank Integration Customer/Supplier/Purpose registries are left alone.

The Bank Integration form gains a "Load Data" button: pick an Excel
preset + file and choose which registries to populate (Customers /
Suppliers / Purposes checkboxes, like the standard data import). It runs
the same upsert logic but creates no Bank Transactions — the file-based
counterpart to kapital_bank's API-driven counterparty/purpose loaders.
Backed by jey_erp.bank_integration.import_api.load_registries_from_excel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 13:49:10 +00:00
Ali e600a77806 fix(bank-integration): keep "use original description" hidden state across Action changes
The previous attempt double-set custom_purpose's hidden property
(visible in the forEach, then hidden in a follow-up if) and relied on
refresh_fields, which didn't re-render the hidden state. Now
_applyModeVisibility computes the final hidden value for each field in
one pass — folding the "Use original description" checkbox into the
custom_purpose decision — and calls refresh() on each field explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 13:30:44 +00:00
Ali 6c395f9e3b fix(bank-integration): no checkbox flicker + keep "use original description" on mode change
Two BRT polish fixes:
- The checkbox column was added by destroying and rebuilding the
  DataTable after each "Get Unreconciled Entries", which visibly redrew
  the rows. Replaced with a wholesale override of DataTableManager's
  get_datatable that creates the table with checkboxColumn:true from the
  start and injects the toolbar there — no rebuild, no flicker. The
  render-event polling is gone.
- _applyModeVisibility unconditionally un-hid "Custom Purpose Keyword"
  when leaving "Documents & Reconcile" mode, overriding the effect of
  the "Use original description" checkbox. Now it re-applies the
  checkbox state after the mode-driven visibility pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 13:21:52 +00:00
Ali 71e2c06a35 fix(bank-integration): port kapital_bank's proven BRT dialog into jey_erp
The first jey_erp BRT implementation read row.name from dtm.transactions,
but those rows are arrays (per ERPNext's DataTableManager.format_row), so
the BT name was always undefined ("Could not resolve Bank Transaction
names"). Replaced it with a faithful port of kapital_bank's BRT
extension: the same checkbox column, "Create & Reconcile" toolbar, and
3-mode dialog (Both / Mappings Only / Documents & Reconcile), reading
the BT name from the row array the way kb did.

The dialog gains a "Mapping Source" select (defaulting from the Bank
Account's hidden bank_integration field, written back on submit). For a
Bank Integration source it calls the new
jey_erp.bank_integration.create_reconcile.create_purpose_mappings (a
port of kapital_bank/mapping.py adapted for the multi-record Bank
Integration doctype and Bank Integration Purpose); for a Kapital Bank
Settings source it calls kapital_bank.mapping.create_purpose_mappings
directly, leaving kb's proven backend untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 13:10:11 +00:00
Ali b4b1d1b9b6 fix(bank-integration): re-add BRT checkbox column on every "Get Unreconciled Entries"
The checkbox column + Create & Reconcile toolbar setup was on the form's
`refresh` event, which fires only once. On a second "Get Unreconciled
Entries" ERPNext rebuilds the DataTableManager without the checkbox
column and the polling interval never restarted. Moved the enhancement
to the `render` event (fires on every rebuild), matching the pattern
the kapital_bank BRT extension used. The prototype patch that adds the
"Bank Transaction" column stays on `refresh` since it is idempotent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 13:02:53 +00:00
Ali f1876b6088 reverse changes push 2026-05-11 12:45:28 +00:00
Ali 3c1dee9a72 feat(bank-integration): redesign Excel Preset UX with Detect & preview
Standard Field is now a Link to a new "Bank Integration Standard Field"
doctype (autoname=Prompt). Each entry holds a display name like "Date" /
"Reference Number" — the field that the user picks in Column Mappings —
and a `field_name` column with the technical key used by the parser.
Twelve standard fields ship as a fixture. The change replaces the old
Select with technical names (date, reference_number, debit, ...) which
were noisy in the UI.

Excel Preset gets two new fields:
  - sample_file (Attach) — user uploads a sample of their bank's xlsx
  - preview_html (HTML) — first 5 rows are rendered after detection

A "Detect Columns from Sample" custom button on the form calls a new
whitelisted endpoint detect_columns_from_sample() that reads the header
row + first 5 data rows. The Column Mappings table is repopulated with
one row per Excel header (Standard Field left empty for the user to
fill in), and the preview HTML shows what the parser actually sees so
the user can validate header_row / skip_rows. After detection the
sample File doc is removed via delete_sample_file().

excel_parser now resolves row.standard_field through Standard Field
to obtain the technical field_name. The Generic Bank Statement fixture
is updated to reference the new Link values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 16:53:10 +00:00
Ali f35b19cf14 feat(bank-integration): universal Excel-based bank statement import
Adds 10 doctypes (Bank Integration + 4 child mapping tables + 3
registries + Excel Preset + Excel Column Mapping), 7 backend modules
(parser, import API, matching, creation, mapping resolver, create &
reconcile, migrations), 3 JS files, and a Generic Excel preset fixture.

Two hidden Dynamic Link custom fields on Bank Account
(bank_integration_type / bank_integration) point to either the new
Bank Integration record or the existing Kapital Bank Settings, letting
the universal Create & Reconcile in BRT read mappings from either source
through one resolver. Both apps now share an "Import From..." dropdown
on Bank Transaction list.

Plan and rationale: BANK_INTEGRATION_PLAN.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 16:23:44 +00:00
Ali cae1de7682 feat(landed-cost-voucher): item-driven taxes table with vendor invoice import
Replaces the free-text description in Landed Cost Taxes and Charges with a
service-item link, drives expense_account from a new Item.default_landed_cost_account,
adds an in-form "Get Items from Vendor Invoices" button, and validates totals
against vendor invoices on submit. Also fixes ERPNext's no-op items_remove
(its `this.trigger` call hits a non-existent method) so applicable_charges
recalculate correctly when rows are deleted from items or taxes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 16:01:41 +00:00
Ali 91268cc466 feat(default-data): auto-sync leave types and company defaults on migrate
Mirrors the salary-component pattern for two more pieces of master data:

- sync_leave_types(): full upsert from default_data/leave_types.json.
  Creates missing, updates existing, deletes those no longer in JSON.
  Leave Type has no `disabled` field, so when a deletion fails due to
  linked Leave Allocation/Application records, the sync logs and skips
  (vs. marking disabled like Salary Component does).

- sync_company_defaults(): for every Company, resolves each account_number
  in default_data/company_defaults.json to the company-scoped Account
  name and sets the corresponding Company field. Non-destructive: if
  the company has no account with that number, the field is left as-is.

Both hooked into after_migrate_combined after sync_salary_components,
since Leave Type's earning_component references a Salary Component.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:55:27 +00:00
Ali eef0c82032 chore(default-data): refresh salary components and leave types from accountant
Updated bookkeeper-supplied master data:
- leave_types.json: leave types restructured per AZ Labor Code articles
  (Maddə 95, 130.e, 143.1.4, …) — names now reference statute, flags
  adjusted accordingly.
- salary_components.json: "Keyfiim bonusu" renamed to "Premiya";
  obsolete disabled components removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:48:15 +00:00
Ali 408bacfc84 feat(salary-components): auto-sync from default_data on migrate
Adds sync_salary_components() — full upsert from default_data JSON:
creates missing components, updates existing ones (formula, condition,
flags, accounts), and deletes those no longer in the JSON. If a
component cannot be deleted due to linked records, it is marked
disabled instead. Idempotent and safe to re-run.

Hooked into after_migrate_combined so every "bench migrate" picks up
the latest formulas — single source of truth is the JSON file.

Replaced default_data/salary_components.json with the current
production export (14 components, formulas use the f(base) + g(LE)
pattern for separate ƏH/MK accounting).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:45:11 +00:00
Ali 3aa4e61a1d perf: idempotent bulk update for custom fields on migrate
Replace per-field delete+create loop (which forced ALTER TABLE on all 222
custom fields every migrate) with idempotent bulk update that only writes
when a field's definition actually changed. Saves with ignore_version=True
to bypass the Frappe Version diff bug that crashes on certain int values.

Also remove the top-level create_custom_fields() call so the function only
runs from after_migrate, not on every module import.

Optional JEY_ERP_FORCE_RECREATE_FIELDS=1 env var preserves the old
delete+create path for development.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 10:55:21 +00:00
Ali 511e91cbf1 new translations 2026-04-24 20:29:53 +00:00
Ali 5d1e2adee3 feat(company): add E-Taxes reference sections to Tax Policy tab
Adds six new collapsible sections at the very end of the Tax Policy
tab on Company form, each with an HTML field for a reference-data
table rendered by invoice_az/client/company.js:
- E-Taxes Objects
- Cash Registers
- POS Terminals
- Bank Accounts
- Obligation Pacts
- Presented Certificates

Tax Closing Wizards moved to the bottom (insert_after changed from
accounting_method to presented_certificates_list_html) so wizards
sit under the new sections.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 13:59:41 +00:00
Ali cf4d66c2d2 feat: add Tax Free tab to Salary Slip with Tax Free Indicator DocType
Adds a Tax Free tab to Salary Slip with 4 nested sub-tabs (Vergi, MDSS,
İşsizlik sığorta, İcbari Tibbi Sığorta) rendered via the custom_subtabs
app. Each sub-tab has a Göstəricilər (Link to Tax Free Indicator, filtered
by group) and an Amount (Currency) field arranged in two columns.

Introduces a new Tax Free Indicator tree DocType mirroring the tax_article
pattern from taxes_az, seeded via fixtures with 74 indicators scraped from
the e-taxes.gov.az unified declaration (32 Vergi + 30 MDSS + 5 İşsizlik
+ 7 İcbari Tibbi Sığorta) grouped under 4 roots.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 11:06:04 +00:00
Ali 72f9973000 feat: also rename default groups after setup wizard completion
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:33:23 +04:00
Ali 5ea710d77c feat: rename default Item/Supplier Groups to Azerbaijani
Add rename_default_groups.py that uses frappe.rename_doc to rename
standard ERPNext groups (Products -> Məhsullar, etc.) instead of
modifying ERPNext source files directly. Runs on after_migrate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:30:00 +04:00
Ali 09af27e22b added new fields 2026-04-02 20:36:50 +04:00
Ali a9d18c05db fix Link field dropdown not opening on focus when value is already set
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 19:34:44 +04:00
Ali aa9d5640c0 remove broken account_tree_custom.js, fix COA balance offset
Removed account_tree_custom.js which caused console errors due to
accessing undefined treeview fields. Export functionality is already
available via account_list.js.

Added CSS fix for Chart of Accounts tree view where account balances
were visually shifted down by one row due to float:right on balance-area.
Fix uses flexbox on tree nodes instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 17:04:35 +04:00
Ali fa1efba44d renewed company_defaults 2026-03-26 17:44:45 +04:00
Ali ad1f6783b5 use account_number instead of account_name for company defaults export/import
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 17:35:31 +04:00
Ali ac7a3fe42e move Company Export Defaults button from list to form view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 17:23:37 +04:00
Ali ee421cf613 add Company default accounts export/import
- Export: company_export.py exports all Link-to-Account fields as account_name
- Import: create_default_company_accounts() resolves account names to full accounts in new company, applied via setup_wizard_complete
- JS: Export Defaults button in Company list view downloads company_defaults.json
- default_data/company_defaults.json: initial defaults

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 17:10:46 +04:00
Ali ea5847b353 fix NameError: restore company variable in create_default_salary_components
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:41:41 +04:00
Ali 6b3324704c update default salary components data with accounts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:36:48 +04:00
Ali fae51ca7ef export SC accounts as account_name, resolve to full account on import
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:31:24 +04:00
Ali 0699beb3ba fix SC accounts validation error; delete default HRMS leave types on setup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:26:18 +04:00
Ali b91ff07f56 add default leave types data
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:16:21 +04:00
Ali 4c2eb7e400 add Leave Type export button and default setup from JSON
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:04:06 +04:00
Ali dc273b3f2b fix IBAN masking: support alphanumeric chars, keep AZ prefix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 15:43:16 +04:00
Ali df9f72be11 add Chart of Accounts export button to list and tree views
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 15:24:00 +04:00
Ali 989cce52b4 delete default HRMS salary components on setup wizard complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 15:03:42 +04:00
Ali 6f17b644f2 update default salary components data
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 14:53:18 +04:00
Ali 7cd7b5d887 add salary component export button and default setup from JSON
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 14:46:40 +04:00
Ali 116efda4f2 add test setup_wizard_complete hook that creates TEST COMP salary component
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 14:27:41 +04:00
Ali 24934219f1 added test salary component create 2026-03-26 14:19:38 +04:00
Ali b8b111b74a hide residence_permit_fin when not_available checkbox is checked
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 13:55:44 +04:00