Go to file
Ali 213329afff perf(amas): parallel detail fetch + per-Asan-Login import lock
Bulk import is now two-phase:

Phase A — parallel network. Up to BULK_IMPORT_PARALLELISM (=10)
ThreadPoolExecutor workers call get_employee_detail() concurrently.
Workers run in stateless mode via the new _post_amas helper and the
_state= parameter threaded through make_amas_request and the seven
detail helpers (get_edit_form_data, get_staff_data, get_person_data,
get_address_data, get_doc_main_data, get_contract_attachments,
download_contract_file). They share an in-memory snapshot of the
ƏMAS session/csrf/cookies and never touch the DB. If any worker is
rejected with HTTP 419 or a response-level CSRF code the whole
import aborts cleanly with a hint to lower BULK_IMPORT_PARALLELISM.

Phase B — sequential DB writes. create_single_employee_from_amas
takes a new prefetched_detail kwarg; the worker loop passes the
Phase-A payload through so the per-employee 7-call fetch is skipped.
Frappe ORM is not thread-safe, so writes stay sequential — that's
where the previous flow spent most of its time anyway.

Concurrency control:
- Asan Login picks up two new hidden Check fields,
  amas_import_running and amas_import_cancel_requested.
- import_bulk_employees refuses to enqueue if the running flag is
  already set, returning {success: False, already_running: True,
  message}. The flag is set BEFORE frappe.enqueue (atomic guard
  against fast double-clicks) and cleared in the worker's finally
  block no matter how it exits.
- New whitelisted endpoints get_amas_import_status and
  cancel_amas_import expose the flag to the UI. The worker checks
  the cancel flag between Phase A futures and between Phase B
  iterations.

Realtime events upgraded:
- amas_import_progress now carries phase: "fetch" | "save".
- amas_import_complete carries cancelled and aborted flags.

Frontend (employee.js):
- Bootstrap-4.6 stacked-modal fix re-applies modal-open class on
  body when a nested modal closes (cancel-confirm over progress)
  so the underlying backdrop isn't orphaned.
- reattach_amas_import_if_running re-binds the realtime listeners
  on listview onload by polling get_connected_asan_logins +
  get_amas_import_status, so refreshing /app/employee while an
  import is in flight still shows the progress bar + Cancel button.

Plus the side fixes from the same session: connect_amas now opens
the org-picker dialog on success, error humanizer for common ƏMAS
codes, skip the dashboard prefetch when the cached CSRF is still
good. Schema changes need bench migrate.
2026-05-01 16:04:16 +00:00
invoice_az perf(amas): parallel detail fetch + per-Asan-Login import lock 2026-05-01 16:04:16 +00:00
test_invoice.git Fixed bugs, added new tabs and subtabs, load from everywhere and etc 2025-07-23 12:39:40 +04:00
.editorconfig feat: Initialize App 2025-04-24 18:29:13 +04:00
.eslintrc feat: Initialize App 2025-04-24 18:29:13 +04:00
.gitignore feat: Company Data Loading + Tax Policy reference lists 2026-04-21 13:59:29 +00:00
.pre-commit-config.yaml feat: Initialize App 2025-04-24 18:29:13 +04:00
BUGFIX_STATUS_201.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
BUGFIX_TAX_TYPE.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
BUGS_VAT_OPERATIONS.md added import from etaxes to journal entry, with all bugfixes 2026-01-13 22:31:30 +04:00
CLAUDE.md feat: Company Data Loading + Tax Policy reference lists 2026-04-21 13:59:29 +00:00
IMPLEMENTATION_COMPLETE.txt added purchase invoice act sending 2026-01-29 16:49:01 +04:00
IMPLEMENTATION_SUMMARY.md bug fix 2026-01-30 20:38:24 +04:00
MIGRATION_GUIDE.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
PLASTIC_DISPOSAL_IMPLEMENTATION.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
PROJECT_OVERVIEW.md added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
QA_SEND_INVOICE.md added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
README.md feat: Initialize App 2025-04-24 18:29:13 +04:00
README_TAX_TYPE_FEATURE.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
TECHNICAL_SPEC_TAX_TYPE.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
TIRE_DISPOSAL_IMPLEMENTATION.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
USER_GUIDE_TAX_TYPE.md added purchase invoice act sending 2026-01-29 16:49:01 +04:00
classification_codes.txt added more fucntionality in journal entry import 2026-01-14 23:00:55 +04:00
invoice asan.txt added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
invoice.txt added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
item_group_codes.txt added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
item_group_codes_service.txt added invoice sending to etaxes 2025-12-19 15:39:51 +04:00
license.txt feat: Initialize App 2025-04-24 18:29:13 +04:00
pyproject.toml feat: Initialize App 2025-04-24 18:29:13 +04:00

README.md

Invoice Az

This application uploads and downloads invoices from e taxes gov az

Installation

You can install this app using the bench CLI:

cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch develop
bench install-app invoice_az

Contributing

This app uses pre-commit for code formatting and linting. Please install pre-commit and enable it for this repository:

cd apps/invoice_az
pre-commit install

Pre-commit is configured to use the following tools for checking and formatting your code:

  • ruff
  • eslint
  • prettier
  • pyupgrade

License

unlicense