diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 3d87d75b..00000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-name: CI
-
-on:
- push:
- branches:
- - develop
- pull_request:
-
-concurrency:
- group: develop-csf_tz-${{ github.event.number }}
- cancel-in-progress: true
-
-jobs:
- tests:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- name: Server
-
- services:
- redis-cache:
- image: redis:alpine
- ports:
- - 13000:6379
- redis-queue:
- image: redis:alpine
- ports:
- - 11000:6379
- mariadb:
- image: mariadb:10.6
- env:
- MYSQL_ROOT_PASSWORD: root
- ports:
- - 3306:3306
- options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
-
- steps:
- - name: Clone
- uses: actions/checkout@v4
-
- - name: Find tests
- run: |
- echo "Finding tests"
- grep -rn "def test" > /dev/null
-
- - name: Setup Python
- uses: actions/setup-python@v5
- with:
- python-version: '3.10'
-
- - name: Setup Node
- uses: actions/setup-node@v4
- with:
- node-version: 18
- check-latest: true
-
- - name: Cache pip
- uses: actions/cache@v4
- with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- ${{ runner.os }}-
-
- - name: Get yarn cache directory path
- id: yarn-cache-dir-path
- run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT'
-
- - uses: actions/cache@v4
- id: yarn-cache
- with:
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- restore-keys: |
- ${{ runner.os }}-yarn-
-
- - name: Install MariaDB Client
- run: sudo apt-get install -y mariadb-client
-
- - name: Setup
- run: |
- pip install frappe-bench
- bench init --skip-redis-config-generation --skip-assets --frappe-branch version-15 --python "$(which python)" ~/frappe-bench
- mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
- mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
-
- - name: Install
- working-directory: /home/runner/frappe-bench
- run: |
- bench get-app --skip-assets payments --branch version-15
- bench get-app --skip-assets erpnext --branch version-15 --resolve-deps
- bench get-app --skip-assets hrms --branch version-15
- bench get-app --skip-assets csf_tz $GITHUB_WORKSPACE --resolve-deps
- bench setup requirements --dev
- bench new-site --db-root-password root --admin-password admin test_site
- bench --site test_site install-app payments
- bench --site test_site install-app erpnext
- bench --site test_site install-app hrms
- bench --site test_site install-app csf_tz
- env:
- CI: 'Yes'
-
- - name: Smoke Test
- working-directory: /home/runner/frappe-bench
- run: |
- bench --site test_site set-config allow_tests true
- bench --site test_site execute erpnext.setup.utils.before_tests
- bench --site test_site migrate
- bench --site test_site list-apps
- env:
- TYPE: server
diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml
index 357aba35..50b5ccd7 100644
--- a/.github/workflows/linter.yml
+++ b/.github/workflows/linter.yml
@@ -1,4 +1,3 @@
-
name: Linters
on:
@@ -9,51 +8,55 @@ permissions:
contents: read
concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
+ group: linters-csf_tz-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
- linter:
- name: 'Frappe Linter'
+ semgrep:
+ name: Frappe Linter
runs-on: ubuntu-latest
- if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
+
- uses: actions/setup-python@v5
with:
- python-version: '3.10'
+ python-version: "3.11"
cache: pip
- - name: Install pre-commit
- run: pip install pre-commit
- - name: Run pre-commit on changed files
- run: |
- pre-commit run \
- --show-diff-on-failure \
- --color=always \
- --from-ref origin/${{ github.base_ref }} \
- --to-ref HEAD
- name: Download Semgrep rules
run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules
+ - name: Install Semgrep
+ run: pip install semgrep
+
+ # Blocking: real bugs and security issues only
- name: Run Semgrep rules
run: |
- pip install semgrep
- semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness
+ semgrep scan --config ./frappe-semgrep-rules/rules \
+ --config r/python.lang.security \
+ --severity=ERROR --error csf_tz
+
+ # Informational: style and i18n warnings, never fails the build
+ - name: Semgrep warnings (non-blocking)
+ if: always()
+ run: |
+ semgrep scan --config ./frappe-semgrep-rules/rules \
+ --config r/python.lang.security \
+ --severity=WARNING csf_tz || true
deps-vulnerable-check:
- name: 'Vulnerable Dependency Check'
+ name: Vulnerable Dependency Check
runs-on: ubuntu-latest
steps:
+ - uses: actions/checkout@v4
+
- uses: actions/setup-python@v5
with:
- python-version: '3.10'
-
- - uses: actions/checkout@v4
+ python-version: "3.11"
- name: Cache pip
uses: actions/cache@v4
@@ -67,5 +70,4 @@ jobs:
- name: Install and run pip-audit
run: |
pip install pip-audit
- cd ${GITHUB_WORKSPACE}
pip-audit --desc on .
diff --git a/.github/workflows/modernize-frappe.yml b/.github/workflows/modernize-frappe.yml
new file mode 100644
index 00000000..e6e37596
--- /dev/null
+++ b/.github/workflows/modernize-frappe.yml
@@ -0,0 +1,12 @@
+name: Modernize Frappe Packaging
+
+on:
+ workflow_dispatch:
+
+permissions:
+ contents: write
+ pull-requests: write
+
+jobs:
+ modernize:
+ uses: Aakvatech-Limited/frappe-maintenance/.github/workflows/modernize-frappe-reusable.yml@main
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
new file mode 100644
index 00000000..4cc2ffa1
--- /dev/null
+++ b/.github/workflows/pre-commit.yml
@@ -0,0 +1,31 @@
+name: Pre-commit
+
+on:
+ pull_request:
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: precommit-csf_tz-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ pre-commit:
+ name: pre-commit
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+ cache: pip
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+
+ - uses: pre-commit/action@v3.0.1
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 3bc54c76..00000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: Release
-
-on:
- workflow_dispatch:
-
-permissions:
- contents: write
- issues: write
- pull-requests: write
-
-concurrency:
- group: release-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- release:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- persist-credentials: false
-
- - uses: actions/setup-node@v4
- with:
- node-version: 20
-
- - name: Install semantic-release
- run: npm install --no-save semantic-release @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
-
- - name: Run semantic-release
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npx semantic-release
diff --git a/.github/workflows/semantic-commits.yml b/.github/workflows/semantic-commits.yml
index 1370dfe8..7ec0d66a 100644
--- a/.github/workflows/semantic-commits.yml
+++ b/.github/workflows/semantic-commits.yml
@@ -14,6 +14,7 @@ jobs:
commitlint:
name: Check Commit Messages
runs-on: ubuntu-latest
+
steps:
- uses: actions/checkout@v4
with:
diff --git a/.gitignore b/.gitignore
index 119ee615..52faed98 100755
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,6 @@ build/
coverage/
*.lcov
.nyc_output
+
+# Semgrep rules cloned by pre-commit / CI
+frappe-semgrep-rules/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7e4f33eb..f5f05285 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
-exclude: 'node_modules|.git'
+exclude: "^(node_modules/|frappe-semgrep-rules/|[.]vscode/|.*/node_modules/|csf_tz/public/dist/|csf_tz/public/css/)"
default_stages: [pre-commit]
-default_install_hook_types: [pre-commit, commit-msg]
+default_install_hook_types: [pre-commit, commit-msg, pre-push]
fail_fast: false
repos:
@@ -8,37 +8,94 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
- files: "csf_tz.*"
- exclude: ".*json$|.*txt$|.*csv|.*md|.*svg"
+ exclude: '\.(json|txt|csv|md|svg)$'
- id: end-of-file-fixer
+ exclude: '\.(json|csv|svg)$'
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
+ - id: no-commit-to-branch
+ args:
+ - --branch
+ - main
+ - --branch
+ - master
+ - --branch
+ - production
+ - --branch
+ - version-14
+ - --branch
+ - version-15
+ - --branch
+ - version-16
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.8.1
+ rev: v0.13.2
hooks:
- id: ruff
name: "Run ruff import sorter"
args: ["--select=I", "--fix"]
-
+ files: '^csf_tz/.*\.py$'
- id: ruff
name: "Run ruff linter"
-
+ args: ["--fix"]
+ files: '^csf_tz/.*\.py$'
- id: ruff-format
name: "Run ruff formatter"
+ files: '^csf_tz/.*\.py$'
+
+ - repo: https://github.com/pre-commit/mirrors-prettier
+ rev: v2.7.1
+ hooks:
+ - id: prettier
+ name: "Run prettier on frontend sources"
+ types_or: [javascript, vue, css, scss]
+ files: '^(csf_tz|frontend)/.*\.(js|vue|css|scss)$'
+ exclude: |
+ (?x)^(
+ .*/public/dist/.*|
+ .*/public/frontend/.*|
+ .*/public/node_modules/.*|
+ .*\.bundle\.js|
+ .*\.min\.js|
+ frontend/dist/.*|
+ cypress/.*|
+ .*node_modules.*|
+ .*boilerplate.*
+ )$
+
+ - repo: local
+ hooks:
+ - id: frappe-semgrep-rules
+ name: "Frappe Semgrep Security Rules"
+ entry: bash -c 'if [ ! -d frappe-semgrep-rules/.git ]; then rm -rf frappe-semgrep-rules && GIT_TEMPLATE_DIR="" git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules; fi && semgrep scan --config ./frappe-semgrep-rules/rules --config r/python.lang.security --severity=ERROR --error --quiet "$@"' --
+ language: python
+ additional_dependencies: ["semgrep"]
+ types: [python]
+ files: '^csf_tz/.*\.py$'
+ pass_filenames: true
+ require_serial: true
+
+ - id: full-repository-check
+ name: "Full repository check before push"
+ entry: bash -c 'if command -v pre-commit >/dev/null 2>&1; then exec pre-commit run --all-files --hook-stage pre-commit --show-diff-on-failure --color=always; else exec python3 -m pre_commit run --all-files --hook-stage pre-commit --show-diff-on-failure --color=always; fi'
+ language: system
+ stages: [pre-push]
+ pass_filenames: false
+ always_run: true
+ verbose: true
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.22.0
hooks:
- id: commitlint
stages: [commit-msg]
- additional_dependencies: ['conventional-changelog-conventionalcommits']
+ additional_dependencies: ["@commitlint/config-conventional"]
ci:
- autoupdate_schedule: weekly
- skip: []
- submodules: false
+ autoupdate_schedule: weekly
+ skip: [frappe-semgrep-rules, full-repository-check]
+ submodules: false
diff --git a/.releaserc.json b/.releaserc.json
deleted file mode 100644
index e40d8fe7..00000000
--- a/.releaserc.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "branches": ["version-15"],
- "plugins": [
- ["@semantic-release/commit-analyzer", {
- "preset": "conventionalcommits"
- }],
- ["@semantic-release/release-notes-generator", {
- "preset": "conventionalcommits"
- }],
- ["@semantic-release/changelog", {
- "changelogFile": "CHANGELOG.md"
- }],
- ["@semantic-release/exec", {
- "prepareCmd": "sed -i 's/^__version__ = .*/__version__ = \"${nextRelease.version}\"/' csf_tz/__init__.py"
- }],
- ["@semantic-release/git", {
- "assets": ["CHANGELOG.md", "csf_tz/__init__.py"],
- "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
- }],
- "@semantic-release/github"
- ]
-}
diff --git a/.semgrepignore b/.semgrepignore
new file mode 100644
index 00000000..1554660e
--- /dev/null
+++ b/.semgrepignore
@@ -0,0 +1,13 @@
+# Semgrep ignore file. Creating it replaces semgrep's built-in defaults, so they are re-listed.
+.git/
+node_modules/
+__pycache__/
+*.pyc
+*.egg-info/
+dist/
+build/
+frappe-semgrep-rules/
+
+# Test files
+**/test_*.py
+**/tests/
diff --git a/SPEC.md b/SPEC.md
new file mode 100644
index 00000000..97763d4b
--- /dev/null
+++ b/SPEC.md
@@ -0,0 +1,681 @@
+# CSF TZ Spec
+
+CSF TZ provides country-specific functionality for Tanzania on top of Frappe and ERPNext.
+
+The application extends standard ERPNext behaviour rather than replacing ERPNext. Tanzanian statutory requirements, integrations, local business rules, accounting extensions, payroll extensions, banking functionality, and other reusable Tanzania-specific functionality belong in CSF TZ when they cannot reasonably be implemented through standard ERPNext configuration.
+
+The application should preserve ERPNext conventions and upgradeability wherever possible.
+
+## Goals
+
+* Provide reusable Tanzania-specific functionality for ERPNext.
+* Support Tanzanian statutory, taxation, fiscal, payroll, banking, regulatory, and business requirements.
+* Extend standard ERPNext transactions without unnecessarily duplicating ERPNext functionality.
+* Keep integrations with Tanzanian authorities, fiscal systems, banks, and payment providers isolated behind clear interfaces.
+* Keep custom business logic deterministic, auditable, and maintainable.
+* Make upgrades between supported Frappe and ERPNext versions predictable.
+* Keep site-specific or customer-specific functionality outside the common CSF TZ application unless it is genuinely reusable.
+* Prefer standard Frappe extension mechanisms over modifications to Frappe or ERPNext source code.
+
+## Application Model
+
+CSF TZ is an extension application running inside a Frappe/ERPNext site.
+
+The important architectural areas are:
+
+* **DocTypes** own persistent CSF TZ business entities and configuration.
+* **Hooks** connect CSF TZ behaviour to Frappe and ERPNext lifecycle events.
+* **Overrides** replace standard document controller behaviour only when extension through hooks is insufficient.
+* **Client scripts and bundled JavaScript** extend standard Desk behaviour.
+* **APIs** expose explicitly supported server-side operations and integrations.
+* **Integrations** communicate with banks, payment providers, fiscal systems, government authorities, and other external services.
+* **Scheduled jobs** perform recurring reconciliation, synchronization, notification, regulatory, and maintenance work.
+* **Patches** perform controlled schema, metadata, configuration, and data migrations.
+* **Reports** expose business, accounting, operational, and statutory information.
+* **Workspaces** provide user-facing entry points into Tanzania-specific functionality.
+
+Business rules should live as close as possible to the domain that owns them.
+
+Do not place substantial business logic in `hooks.py`. Hooks should primarily map framework events to appropriately grouped implementation functions.
+
+## Functional Domains
+
+The application may contain functionality covering areas including:
+
+* Tanzania tax and fiscal compliance
+* VFD/EFD integrations
+* Sales and receivables extensions
+* Purchasing and payables extensions
+* Withholding taxes
+* Banking and reconciliation
+* Payroll and employee-related localization
+* Inventory and stock controls
+* Importation and landed-cost processes
+* Payment provider integrations
+* Tanzanian geographic and regulatory data
+* Vehicle and authority integrations
+* Education-related extensions where required by supported deployments
+* Operational utilities and reusable ERPNext enhancements
+
+A feature does not belong in CSF TZ merely because it was developed for a Tanzanian customer.
+
+New functionality should normally satisfy at least one of these conditions:
+
+1. It implements a Tanzanian statutory or regulatory requirement.
+2. It integrates with a Tanzania-specific service or institution.
+3. It represents a business requirement broadly reusable by CSF TZ installations.
+4. It provides infrastructure required by another legitimate CSF TZ feature.
+
+Customer-specific workflows, reports, integrations, fields, naming conventions, or business rules should normally live in a customer-specific application.
+
+## Extension Model
+
+Use Frappe's standard extension mechanisms in this order of preference:
+
+1. Configuration and standard ERPNext functionality
+2. Custom fields and property setters managed by the application
+3. Document events
+4. Client-side DocType extensions
+5. Whitelisted methods and APIs
+6. Scheduler events
+7. Controller extension or override where required
+
+Direct modification of Frappe or ERPNext source code is not part of the CSF TZ architecture.
+
+### Document Events
+
+Use `doc_events` when logic belongs to a standard Frappe or ERPNext document lifecycle.
+
+Event handlers should:
+
+* receive the document and event using standard Frappe conventions;
+* perform one clearly identifiable business responsibility;
+* avoid duplicating ERPNext controller logic;
+* avoid committing or rolling back database transactions independently unless specifically required;
+* raise meaningful validation errors when a transaction cannot proceed;
+* remain safe when called during normal framework lifecycle processing.
+
+Large handlers should delegate to domain-specific modules.
+
+### Controller Overrides
+
+Controller overrides are a high-impact extension mechanism.
+
+Use `override_doctype_class` only when the required behaviour cannot safely be implemented through events or supported extension points.
+
+An override should inherit from the corresponding upstream controller wherever practical.
+
+When overriding a standard controller:
+
+* preserve upstream behaviour unless the specification explicitly changes it;
+* call the superclass implementation where appropriate;
+* document why an override is required;
+* consider upstream changes during every major ERPNext upgrade;
+* keep the override narrowly scoped.
+
+Controller overrides should not become independent copies of ERPNext controllers.
+
+## Client-Side Extensions
+
+JavaScript attached through `doctype_js`, `doctype_list_js`, application bundles, or other Frappe hooks should enhance the standard UI rather than reproduce server-side business logic.
+
+Client-side code may:
+
+* improve data entry;
+* provide validations for user convenience;
+* calculate previews;
+* add buttons and actions;
+* call approved server methods;
+* adapt standard forms to CSF TZ workflows.
+
+Business-critical validation must also exist server-side.
+
+Never rely only on browser-side validation for accounting, compliance, authorization, statutory, or data-integrity controls.
+
+## API Model
+
+Server APIs should be grouped by domain rather than accumulating unrelated behaviour in large generic modules.
+
+New APIs should preferably live in a dedicated package or domain module.
+
+Whitelisted methods must explicitly consider:
+
+* authentication;
+* authorization;
+* input validation;
+* document permissions;
+* idempotency;
+* transaction boundaries;
+* external-service failures;
+* logging;
+* exposure of confidential data.
+
+Do not make a method guest-accessible unless anonymous access is a genuine integration requirement.
+
+Public or integration-facing APIs should have stable request and response contracts.
+
+Breaking API changes should be treated as compatibility changes.
+
+## Integration Model
+
+External systems should be treated as unreliable network dependencies.
+
+Integrations may include:
+
+* VFD/EFD providers;
+* TRA-related services;
+* banks;
+* payment gateways;
+* SFTP endpoints;
+* vehicle and licensing authorities;
+* regulatory services;
+* other approved third-party systems.
+
+Integration code should separate:
+
+1. configuration;
+2. authentication;
+3. request construction;
+4. transport;
+5. response parsing;
+6. business processing;
+7. retry/reconciliation behaviour;
+8. logging.
+
+Provider-specific behaviour should remain inside provider-specific modules wherever possible.
+
+Do not spread provider-specific conditionals throughout Sales Invoice, Payment Entry, Payroll Entry, or other unrelated domains.
+
+### Credentials
+
+Credentials, tokens, private keys, API secrets, passwords, and similar material must never be hard-coded in source files.
+
+Use Frappe configuration or password fields appropriate to the sensitivity of the credential.
+
+Logs must not expose credentials or sensitive authentication material.
+
+### External Calls
+
+External calls performed during document submission should be used carefully.
+
+Where an external operation can safely occur asynchronously, prefer a background or reconciliation process rather than making the external provider's availability a prerequisite for completing an ERPNext transaction.
+
+Where synchronous communication is legally or operationally required, failure behaviour must be explicit.
+
+## VFD and Fiscal Processing
+
+Fiscal processing is compliance-sensitive functionality.
+
+VFD functionality should maintain a clear distinction between:
+
+* ERPNext transaction state;
+* fiscal submission state;
+* provider request state;
+* provider response state;
+* retries;
+* successful fiscalization;
+* failure;
+* cancellation or reversal.
+
+A Sales Invoice being submitted in ERPNext does not by itself prove successful fiscal submission.
+
+Fiscal operations should preserve enough information to determine:
+
+* what was submitted;
+* when it was submitted;
+* which provider was used;
+* what response was received;
+* whether the operation succeeded;
+* whether retry is required;
+* whether subsequent cancellation or adjustment occurred.
+
+Provider communication and fiscal business rules should be kept separate wherever practical.
+
+## Accounting Integrity
+
+Any CSF TZ functionality that creates or alters accounting consequences must respect ERPNext's accounting model.
+
+Examples include:
+
+* withholding tax;
+* bank charges;
+* exchange differences;
+* landed costs;
+* import tracking;
+* additional salary accounting;
+* payment integrations.
+
+Accounting logic must:
+
+* use submitted documents where ERPNext requires submission;
+* preserve company and currency context;
+* preserve debit/credit integrity;
+* respect cancellation;
+* avoid orphan accounting references;
+* avoid duplicate GL consequences;
+* remain reproducible from the underlying business transaction.
+
+Do not update accounting tables directly when an ERPNext document or accounting API should own the transaction.
+
+## Scheduled Jobs
+
+Recurring processing is registered through Frappe scheduler hooks.
+
+Scheduled jobs are appropriate for work including:
+
+* synchronization;
+* reconciliation;
+* retries;
+* token renewal;
+* regulatory data refreshes;
+* notifications;
+* queue seeding;
+* periodic cleanup;
+* maintenance;
+* delayed transaction processing.
+
+Scheduler methods must be safe to execute repeatedly.
+
+Where possible they should be idempotent: running the same job again should not create duplicate financial, regulatory, or operational consequences.
+
+A scheduled job should not assume that the previous invocation completed successfully.
+
+Jobs processing potentially large datasets should operate in bounded batches.
+
+Do not load an unbounded number of documents into memory.
+
+Failures affecting one record should not unnecessarily prevent all other independent records from processing.
+
+## Background Work
+
+Operations involving significant network communication, file processing, large datasets, or long-running calculations should normally use Frappe background jobs.
+
+Queue work when synchronous execution would:
+
+* make a user transaction unnecessarily slow;
+* risk HTTP timeouts;
+* depend on unreliable third-party services;
+* process large numbers of records;
+* perform retryable work.
+
+Background jobs must receive enough identifiers to reload authoritative state rather than depending on stale in-memory documents.
+
+## Configuration
+
+CSF TZ configuration should use Frappe DocTypes or supported site configuration.
+
+Configuration belongs at the narrowest appropriate scope:
+
+* system-wide;
+* company;
+* provider;
+* bank;
+* fiscal device;
+* user;
+* transaction.
+
+Do not introduce global settings for configuration that legitimately varies by Company.
+
+Configuration fields should have clear defaults and should fail explicitly when mandatory configuration is missing.
+
+Settings DocTypes should be preferred over scattered custom fields when a feature has substantial configuration of its own.
+
+## Custom Fields and Property Setters
+
+CSF TZ may extend standard DocTypes using Custom Fields and Property Setters.
+
+Application-owned metadata must be reproducible from source.
+
+Do not rely on production sites containing manually created Custom Fields that are absent from application setup or migration logic.
+
+Field creation must be idempotent.
+
+Before changing or deleting existing fields, account for installations that may already contain data.
+
+Fieldnames should be stable after release wherever possible.
+
+## Data Model
+
+A CSF TZ DocType should exist when a concept has an independent lifecycle, configuration role, transactional role, integration role, or audit requirement.
+
+Do not create a new DocType merely to avoid using an appropriate ERPNext model.
+
+Links to ERPNext documents should use proper Link or Dynamic Link fields wherever possible.
+
+Child tables should be used for records that exist only as part of their parent document.
+
+Integration logs should retain identifiers required to trace the corresponding ERPNext transaction and external transaction.
+
+## Migrations and Patches
+
+Database and metadata migrations are part of the application contract.
+
+Use `patches.txt` for one-time migration work.
+
+Use install or migrate hooks for operations that genuinely need to remain repeatable.
+
+A patch should:
+
+* be safe for existing production data;
+* be deterministic;
+* preferably be idempotent;
+* avoid assumptions about optional modules or data;
+* handle already-migrated records safely;
+* avoid silently destroying business data;
+* complete in reasonable bounded operations.
+
+Do not rewrite the behaviour of a previously released patch after installations may already have executed it.
+
+Create a new patch for subsequent corrections.
+
+Destructive migrations require particular care and should be explicitly documented.
+
+## Installation and Migration Hooks
+
+`after_install` prepares newly installed sites.
+
+`after_migrate` may enforce application-owned metadata or configuration that must remain synchronized.
+
+Do not put expensive recurring business processing in migration hooks.
+
+Migration hooks must not rely on external services being available.
+
+A failed external provider must not prevent a normal `bench migrate` unless that provider is fundamentally required to make the schema valid.
+
+## Version Compatibility
+
+Each maintained branch must explicitly declare the supported Frappe and ERPNext major versions in `pyproject.toml`.
+
+A branch should target a defined framework generation.
+
+Do not make one branch silently support incompatible framework majors through extensive version-condition logic.
+
+Compatibility changes involving:
+
+* controller APIs;
+* DocType fields;
+* hooks;
+* accounting behaviour;
+* scheduler behaviour;
+* framework APIs;
+* JavaScript APIs
+
+must be checked against the targeted Frappe and ERPNext versions.
+
+Upstream APIs should not be assumed stable across major releases.
+
+## Modules
+
+Functional modules should group related business behaviour.
+
+Current module boundaries may include areas such as:
+
+* CSF TZ
+* Purchase and Stock Management
+* Sales and Marketing
+* Meal Count
+* Stanbic
+* KCB
+* VFD Providers
+* VFD Settings
+
+New modules should only be introduced when they represent a coherent functional domain.
+
+Do not create a module for every small feature.
+
+## Public Surfaces
+
+The important public surfaces of CSF TZ include:
+
+* DocTypes
+* reports
+* workspaces
+* whitelisted methods
+* hooks into ERPNext documents
+* scheduled jobs
+* integrations consumed by external systems
+* configuration DocTypes
+* print and Jinja helpers where explicitly exposed
+
+Changes to these surfaces may affect installed sites even when no Python import API changes.
+
+Treat fieldnames, DocType names, integration contracts, and externally consumed endpoints as compatibility-sensitive.
+
+## Permissions and Authorization
+
+Server-side permission checks remain authoritative.
+
+Creating a custom form button does not grant permission to perform the corresponding operation.
+
+APIs that read or modify ERPNext documents must respect Frappe permissions unless the integration explicitly requires privileged system processing.
+
+Any deliberate permission bypass must:
+
+* have a documented reason;
+* be scoped narrowly;
+* validate the caller or integration;
+* avoid accepting arbitrary document access from untrusted input.
+
+## Security Model
+
+CSF TZ runs with the privileges of the Frappe application process and has access to site data.
+
+Application code therefore belongs inside the site's trusted computing boundary.
+
+Assume that server-side CSF TZ code can potentially access:
+
+* accounting information;
+* customer and supplier records;
+* employee information;
+* payroll information;
+* integration credentials;
+* regulatory records;
+* uploaded files.
+
+From this:
+
+* validate untrusted input;
+* avoid arbitrary SQL construction;
+* avoid arbitrary filesystem access;
+* do not execute user-supplied code;
+* protect integration credentials;
+* restrict guest endpoints;
+* validate uploaded files;
+* avoid logging unnecessary personal or financial information.
+
+External responses must be treated as untrusted input.
+
+## SQL and Database Access
+
+Prefer Frappe ORM, Query Builder, and standard document APIs.
+
+Direct SQL is acceptable when there is a clear technical reason such as reporting, performance, migration, or functionality not reasonably expressible through supported APIs.
+
+Direct SQL must:
+
+* parameterize dynamic values;
+* respect `docstatus` where relevant;
+* consider Company boundaries;
+* consider permissions when used in user-facing operations;
+* avoid direct writes to framework-owned accounting or stock ledgers unless explicitly required by framework architecture.
+
+Database writes should normally occur through document APIs.
+
+## Error Handling
+
+Errors shown to users should explain the business problem and, where possible, the corrective action.
+
+Do not expose raw provider credentials, tokens, SQL, or internal stack details through user-facing errors.
+
+Integration errors should preserve enough technical information in appropriate logs for diagnosis.
+
+Retryable errors should be distinguishable from permanent validation failures.
+
+## Logging and Auditability
+
+Compliance-sensitive and integration-sensitive operations should be traceable.
+
+Where appropriate, preserve:
+
+* source document;
+* external reference;
+* timestamp;
+* provider;
+* operation;
+* result;
+* error;
+* retry information.
+
+Do not use unrestricted console output as the primary production logging mechanism.
+
+Use Frappe logging, integration log DocTypes, or purpose-built audit records.
+
+## Cancellation and Reversal
+
+Any feature that creates downstream records must explicitly consider cancellation.
+
+When a source ERPNext document is cancelled, CSF TZ must determine whether downstream records should:
+
+* be cancelled;
+* be reversed;
+* be unlinked;
+* remain as immutable audit evidence;
+* trigger an external cancellation;
+* require manual intervention.
+
+Cancellation logic must not silently leave active financial or compliance consequences behind.
+
+## Idempotency
+
+Operations that may be retried must protect against duplicate execution.
+
+This particularly applies to:
+
+* scheduled jobs;
+* webhook/API callbacks;
+* fiscal submissions;
+* payment processing;
+* bank reconciliation;
+* journal creation;
+* background jobs;
+* authority synchronization.
+
+Where an external system provides a transaction identifier, persist and use it for duplicate detection when practical.
+
+## Performance
+
+Code running in transaction hooks must remain bounded.
+
+Avoid:
+
+* queries inside large loops;
+* loading complete tables unnecessarily;
+* performing expensive external calls repeatedly;
+* processing entire transaction histories during ordinary document validation;
+* synchronous bulk processing where a background job is appropriate.
+
+Use batching for high-volume scheduled operations.
+
+Performance optimizations must not compromise accounting or compliance correctness.
+
+## Testing
+
+Business-critical features should have automated tests.
+
+Priority areas include:
+
+* accounting consequences;
+* taxation;
+* VFD/fiscalization;
+* payroll calculations;
+* document submission and cancellation;
+* integration request/response handling;
+* migration patches;
+* scheduled job idempotency;
+* duplicate prevention.
+
+Tests should exercise business outcomes rather than merely whether a function executes.
+
+Where an external provider is involved, provider calls should normally be mocked in automated tests.
+
+Tests must not depend on live banking, fiscal, payment, or authority services.
+
+## Development Rules
+
+When changing existing functionality:
+
+1. Identify the owning domain.
+2. Check existing hooks and overrides before adding another extension point.
+3. Reuse ERPNext behaviour where possible.
+4. Preserve submission and cancellation semantics.
+5. Consider multi-company behaviour.
+6. Consider permissions.
+7. Consider migration requirements.
+8. Consider scheduled or asynchronous execution.
+9. Consider integration retry and duplicate behaviour.
+10. Add or update tests for material business logic.
+
+Avoid adding unrelated convenience functions to `custom_api.py` or other already broad modules.
+
+New substantial features should use dedicated domain modules.
+
+## Naming
+
+Use names that describe the business concept rather than a customer or temporary implementation.
+
+Provider-specific functionality may use the provider name where the provider itself defines the integration.
+
+Avoid abbreviations unless they are established domain terminology such as VAT, VFD, TRA, PAYE, or NSSF.
+
+Do not encode one customer's name into reusable CSF TZ business logic.
+
+## Source of Truth
+
+For application behaviour:
+
+* Python source is the source of truth for server-side logic.
+* JavaScript source is the source of truth for client-side behaviour.
+* DocType JSON is the source of truth for application-owned DocType metadata.
+* patch modules and migration hooks are the source of truth for migrations.
+* `hooks.py` is the source of truth for registered framework extensions and schedules.
+* `pyproject.toml` is the source of truth for Python and Frappe/ERPNext compatibility declarations.
+
+Production-site manual customizations are not substitutes for source-controlled application behaviour.
+
+## Contribution Boundary
+
+Before adding functionality to CSF TZ, ask:
+
+**Is this Tanzania-specific or reusable across a substantial number of CSF TZ installations?**
+
+If no, it probably belongs in:
+
+* standard ERPNext configuration;
+* another reusable application;
+* an industry-specific application; or
+* a customer-specific application.
+
+CSF TZ should not become a collection of unrelated customer customizations.
+
+## Documentation Map
+
+Documentation should progressively cover:
+
+* Architecture
+* Installation and upgrade
+* Tanzanian statutory configuration
+* VFD configuration and providers
+* Tax and withholding configuration
+* Banking integrations
+* Payroll localization
+* Purchase and import processes
+* Scheduled jobs
+* API and integration contracts
+* Migration and compatibility guidance
+* Troubleshooting
+
+`SPEC.md` defines architectural and development rules.
+
+`README.md` should remain the high-level introduction and installation entry point.
+
+Detailed operational and developer documentation should live under `docs/` as the repository grows.
diff --git a/commitlint.config.js b/commitlint.config.js
index 56702092..300da21e 100644
--- a/commitlint.config.js
+++ b/commitlint.config.js
@@ -1,5 +1,5 @@
module.exports = {
- parserPreset: "conventional-changelog-conventionalcommits",
+ extends: ["@commitlint/config-conventional"],
rules: {
"subject-empty": [2, "never"],
"type-case": [2, "always", "lower-case"],
diff --git a/csf_tz/__init__.py b/csf_tz/__init__.py
index 95acbb0d..3f1c0388 100755
--- a/csf_tz/__init__.py
+++ b/csf_tz/__init__.py
@@ -19,11 +19,17 @@ def load_monkey_patches():
if patches_loaded:
return
- patches_loaded = True
+ # Bench-level commands such as asset builds can run without a site context.
+ # Avoid querying installed apps in that case, because it attempts a database
+ # connection and fails with "site must be fully initialized, db_name missing".
+ if not getattr(frappe.local, "site", None):
+ return
if app_name not in frappe.get_installed_apps():
return
+ patches_loaded = True
+
for module_name in os.listdir(frappe.get_app_path(app_name, "monkey_patches")):
if not module_name.endswith(".py") or module_name == "__init__.py":
continue
diff --git a/csf_tz/check-all-git.sh b/csf_tz/check-all-git.sh
index 5f9aaf50..21342bbf 100755
--- a/csf_tz/check-all-git.sh
+++ b/csf_tz/check-all-git.sh
@@ -8,4 +8,3 @@ for dir in apps/* ; do
cd ../..
fi
done
-
diff --git a/csf_tz/csf_tz/additional_salary.js b/csf_tz/csf_tz/additional_salary.js
index 1b6318f5..26dacbe6 100644
--- a/csf_tz/csf_tz/additional_salary.js
+++ b/csf_tz/csf_tz/additional_salary.js
@@ -1,47 +1,50 @@
-frappe.ui.form.on('Additional Salary', {
- refresh: function(frm) {
- cur_frm.add_custom_button(__("Generate Additional Salary Records"), function() {
- frappe.call({
- method: "csf_tz.csftz_hooks.additional_salary.generate_additional_salary_records",
- args: {},
- callback: function () {
- cur_frm.reload_doc();
- }
- });
- });
- },
- payroll_date: function(frm) {
- if (!frm.doc.payroll_date) {
- frm.set_value("no_of_hours", null);
- }
- },
- employee: function(frm) {
- if (!frm.doc.employee) {
- frm.set_value("no_of_hours", null);
- }
- },
- salary_component: function(frm) {
- if (!frm.doc.salary_component) {
- frm.set_value("based_on_hourly_rate", null);
- frm.set_value("hourly_rate", null);
- }
- },
- no_of_hours: function(frm) {
- if (frm.doc.employee && frm.doc.payroll_date) {
- frappe.call({
- method: "csf_tz.csftz_hooks.additional_salary.get_employee_base_salary_in_hours",
- args: {
- employee: frm.doc.employee,
- payroll_date: frm.doc.payroll_date
- },
- async: false,
- callback: function(r) {
- console.log(r.message)
- if(r.message) {
- frm.set_value("amount", frm.doc.hourly_rate / 100 * frm.doc.no_of_hours * r.message.base_salary_in_hours);
- }
- }
- });
- }
- },
-});
+frappe.ui.form.on("Additional Salary", {
+ refresh: function (frm) {
+ cur_frm.add_custom_button(__("Generate Additional Salary Records"), function () {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.additional_salary.generate_additional_salary_records",
+ args: {},
+ callback: function () {
+ cur_frm.reload_doc();
+ },
+ });
+ });
+ },
+ payroll_date: function (frm) {
+ if (!frm.doc.payroll_date) {
+ frm.set_value("no_of_hours", null);
+ }
+ },
+ employee: function (frm) {
+ if (!frm.doc.employee) {
+ frm.set_value("no_of_hours", null);
+ }
+ },
+ salary_component: function (frm) {
+ if (!frm.doc.salary_component) {
+ frm.set_value("based_on_hourly_rate", null);
+ frm.set_value("hourly_rate", null);
+ }
+ },
+ no_of_hours: function (frm) {
+ if (frm.doc.employee && frm.doc.payroll_date) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.additional_salary.get_employee_base_salary_in_hours",
+ args: {
+ employee: frm.doc.employee,
+ payroll_date: frm.doc.payroll_date,
+ },
+ async: false,
+ callback: function (r) {
+ console.log(r.message);
+ if (r.message) {
+ frm.set_value(
+ "amount",
+ (frm.doc.hourly_rate / 100) * frm.doc.no_of_hours * r.message.base_salary_in_hours
+ );
+ }
+ },
+ });
+ }
+ },
+});
diff --git a/csf_tz/csf_tz/bank_reconciliation.js b/csf_tz/csf_tz/bank_reconciliation.js
index fec5229c..926b8ed5 100644
--- a/csf_tz/csf_tz/bank_reconciliation.js
+++ b/csf_tz/csf_tz/bank_reconciliation.js
@@ -1,21 +1,20 @@
-frappe.ui.form.on('Bank Reconciliation', {
- get_payment_entries: function (frm) {
- frappe.call({
- method: 'erpnext.accounts.utils.get_balance_on',
- args: {
- account: frm.doc.account,
- date: frappe.datetime.add_days(frm.doc.from_date, -1),
- },
- async: false,
- callback: function (r) {
- if (r.message) {
- frm.set_value("opening_balance", r.message || 0);
- }
- else {
- frm.set_value("opening_balance", 0);
- }
- }
- });
- frm.set_value("closing_balance", frm.doc.total_amount + frm.doc.opening_balance);
- },
+frappe.ui.form.on("Bank Reconciliation", {
+ get_payment_entries: function (frm) {
+ frappe.call({
+ method: "erpnext.accounts.utils.get_balance_on",
+ args: {
+ account: frm.doc.account,
+ date: frappe.datetime.add_days(frm.doc.from_date, -1),
+ },
+ async: false,
+ callback: function (r) {
+ if (r.message) {
+ frm.set_value("opening_balance", r.message || 0);
+ } else {
+ frm.set_value("opening_balance", 0);
+ }
+ },
+ });
+ frm.set_value("closing_balance", frm.doc.total_amount + frm.doc.opening_balance);
+ },
});
diff --git a/csf_tz/csf_tz/bom_addittional_costs.js b/csf_tz/csf_tz/bom_addittional_costs.js
index 60b1007e..d94041bb 100644
--- a/csf_tz/csf_tz/bom_addittional_costs.js
+++ b/csf_tz/csf_tz/bom_addittional_costs.js
@@ -1,22 +1,21 @@
frappe.ui.form.on("BOM", {
- refresh: function (frm) {
- frm.set_query("expense_account", "additional_costs", function () {
- return {
- filters: {
- account_type: [
- "in",
- [
- "Tax",
- "Chargeable",
- "Income Account",
- "Expenses Included In Valuation",
- "Expenses Included In Asset Valuation",
- ],
- ],
- company: frm.doc.company,
- },
- };
- });
- },
-
+ refresh: function (frm) {
+ frm.set_query("expense_account", "additional_costs", function () {
+ return {
+ filters: {
+ account_type: [
+ "in",
+ [
+ "Tax",
+ "Chargeable",
+ "Income Account",
+ "Expenses Included In Valuation",
+ "Expenses Included In Asset Valuation",
+ ],
+ ],
+ company: frm.doc.company,
+ },
+ };
+ });
+ },
});
diff --git a/csf_tz/csf_tz/company.js b/csf_tz/csf_tz/company.js
index 3de366b9..580d746e 100644
--- a/csf_tz/csf_tz/company.js
+++ b/csf_tz/csf_tz/company.js
@@ -1,153 +1,165 @@
frappe.ui.form.on("Company", {
-
- setup: function(frm) {
- frm.set_query("default_withholding_payable_account", function() {
+ setup: function (frm) {
+ frm.set_query("default_withholding_payable_account", function () {
return {
- "filters": {
- "company": frm.doc.name,
- "account_type": "Payable",
- }
+ filters: {
+ company: frm.doc.name,
+ account_type: "Payable",
+ },
};
});
- frm.set_query("default_withholding_receivable_account", function() {
+ frm.set_query("default_withholding_receivable_account", function () {
return {
- "filters": {
- "company": frm.doc.name,
- "account_type": "Receivable",
- }
+ filters: {
+ company: frm.doc.name,
+ account_type: "Receivable",
+ },
};
});
- frm.set_query("fee_bank_account", function() {
+ frm.set_query("fee_bank_account", function () {
return {
- "filters": {
- "company": frm.doc.name,
- "account_type": ["in",["Cash","Bank"]],
- "account_currency": frm.doc.default_currency,
- }
+ filters: {
+ company: frm.doc.name,
+ account_type: ["in", ["Cash", "Bank"]],
+ account_currency: frm.doc.default_currency,
+ },
};
});
- frm.set_query("student_applicant_fees_revenue_account", function() {
+ frm.set_query("student_applicant_fees_revenue_account", function () {
return {
- "filters": {
- "company": frm.doc.name,
- "account_type": "Income Account",
- "account_currency": frm.doc.default_currency,
- }
+ filters: {
+ company: frm.doc.name,
+ account_type: "Income Account",
+ account_currency: frm.doc.default_currency,
+ },
};
- });
+ });
},
-
- refresh: function(frm) {
- frm.add_custom_button(__('Auto create accounts'), function() {
- frm.trigger("auto_create_account");
- }, __("Setup"));
- frm.add_custom_button(__('create Item Tax Template'), function() {
- frm.trigger("create_tax_template");
- }, __("Setup"));
- frm.add_custom_button(__('Create Tax Category'), function() {
- frm.trigger("make_tax_category");
- }, __("Setup"));
- frm.add_custom_button(__('Create Salary Component'), function() {
- frm.trigger("make_salary_components_and_structure");
- }, __("Setup"));
- frm.add_custom_button(__('Link Item Tax Template'), function() {
- let d = new frappe.ui.Dialog({
- title: 'Enter details',
- fields: [
- {
- fieldtype: 'Link',
- options: 'Item Tax Template',
- label: __('Item Tax Category'),
- fieldname: 'default_tax_template',
- reqd: 1
- }
- ],
- primary_action_label: 'Submit',
- primary_action(values) {
- console.log(values);
-
- frappe.call({
- method: 'csf_tz.custom_api.linking_tax_template',
- args: {
- abbr: frm.doc.abbr,
- doctype: 'Item',
- default_tax_template: {
- default_tax_template: values.default_tax_template
- }
+ refresh: function (frm) {
+ frm.add_custom_button(
+ __("Auto create accounts"),
+ function () {
+ frm.trigger("auto_create_account");
+ },
+ __("Setup")
+ );
+ frm.add_custom_button(
+ __("create Item Tax Template"),
+ function () {
+ frm.trigger("create_tax_template");
+ },
+ __("Setup")
+ );
+ frm.add_custom_button(
+ __("Create Tax Category"),
+ function () {
+ frm.trigger("make_tax_category");
+ },
+ __("Setup")
+ );
+ frm.add_custom_button(
+ __("Create Salary Component"),
+ function () {
+ frm.trigger("make_salary_components_and_structure");
+ },
+ __("Setup")
+ );
+ frm.add_custom_button(
+ __("Link Item Tax Template"),
+ function () {
+ let d = new frappe.ui.Dialog({
+ title: "Enter details",
+ fields: [
+ {
+ fieldtype: "Link",
+ options: "Item Tax Template",
+ label: __("Item Tax Category"),
+ fieldname: "default_tax_template",
+ reqd: 1,
},
- callback: function(response) {
- if (response.message) {
- frappe.msgprint(__('Item Tax Template Linked successfully.'));
- }
- }
- });
-
- d.hide();
- }
- });
+ ],
+ primary_action_label: "Submit",
+ primary_action(values) {
+ console.log(values);
- d.show();
- }, __("Setup"));
+ frappe.call({
+ method: "csf_tz.custom_api.linking_tax_template",
+ args: {
+ abbr: frm.doc.abbr,
+ doctype: "Item",
+ default_tax_template: {
+ default_tax_template: values.default_tax_template,
+ },
+ },
+ callback: function (response) {
+ if (response.message) {
+ frappe.msgprint(__("Item Tax Template Linked successfully."));
+ }
+ },
+ });
+ d.hide();
+ },
+ });
+ d.show();
+ },
+ __("Setup")
+ );
},
- auto_create_account: function(frm) {
+ auto_create_account: function (frm) {
frappe.call({
- method: 'csf_tz.custom_api.auto_create_account',
- args:{
- abbr: frm.doc.abbr
-
+ method: "csf_tz.custom_api.auto_create_account",
+ args: {
+ abbr: frm.doc.abbr,
},
- callback: function(response) {
+ callback: function (response) {
if (response.message) {
- frappe.msgprint(__('Accounts created successfully.'));
+ frappe.msgprint(__("Accounts created successfully."));
}
- }
- })
+ },
+ });
},
- create_tax_template: function(frm) {
+ create_tax_template: function (frm) {
frappe.call({
- method: 'csf_tz.custom_api.create_item_tax_template',
- args:{
- abbr: frm.doc.abbr
-
+ method: "csf_tz.custom_api.create_item_tax_template",
+ args: {
+ abbr: frm.doc.abbr,
},
- callback: function(response) {
+ callback: function (response) {
if (response.message) {
- frappe.msgprint(__('Item Tax Templates created successfully.'));
+ frappe.msgprint(__("Item Tax Templates created successfully."));
}
- }
- })
+ },
+ });
},
- make_tax_category: function(frm) {
+ make_tax_category: function (frm) {
frappe.call({
- method: 'csf_tz.custom_api.create_tax_category',
- args:{
- abbr: frm.doc.abbr
-
+ method: "csf_tz.custom_api.create_tax_category",
+ args: {
+ abbr: frm.doc.abbr,
},
- callback: function(response) {
+ callback: function (response) {
if (response.message) {
- frappe.msgprint(__('Tax Category created successfully.'));
+ frappe.msgprint(__("Tax Category created successfully."));
}
- }
- })
+ },
+ });
},
- make_salary_components_and_structure: function(frm) {
+ make_salary_components_and_structure: function (frm) {
frappe.call({
- method: 'csf_tz.custom_api.make_salary_components_and_structure',
- args:{
- abbr: frm.doc.abbr
-
+ method: "csf_tz.custom_api.make_salary_components_and_structure",
+ args: {
+ abbr: frm.doc.abbr,
},
- callback: function(response) {
+ callback: function (response) {
if (response.message) {
- frappe.msgprint(__('Salary Components and Structure are created successfully.'));
+ frappe.msgprint(__("Salary Components and Structure are created successfully."));
}
- }
- })
+ },
+ });
},
});
diff --git a/csf_tz/csf_tz/custom_field.js b/csf_tz/csf_tz/custom_field.js
index ce24a929..0d50f289 100644
--- a/csf_tz/csf_tz/custom_field.js
+++ b/csf_tz/csf_tz/custom_field.js
@@ -1,82 +1,84 @@
-frappe.listview_settings['Custom Field'] = {
- onload: function (listview) {
- listview.page.add_menu_item(__('Export Selected'), async function () {
- const selected_docs = listview.get_checked_items();
- if (selected_docs.length === 0) {
- frappe.msgprint(__('Please select at least one document.'));
- return;
- }
+frappe.listview_settings["Custom Field"] = {
+ onload: function (listview) {
+ listview.page.add_menu_item(__("Export Selected"), async function () {
+ const selected_docs = listview.get_checked_items();
+ if (selected_docs.length === 0) {
+ frappe.msgprint(__("Please select at least one document."));
+ return;
+ }
- const detailed_docs = await Promise.all(selected_docs.map(doc =>
- fetch(`/api/resource/Custom Field/${doc.name}`)
- .then(response => response.json())
- .then(data => data.data)
- ));
+ const detailed_docs = await Promise.all(
+ selected_docs.map((doc) =>
+ fetch(`/api/resource/Custom Field/${doc.name}`)
+ .then((response) => response.json())
+ .then((data) => data.data)
+ )
+ );
- const data_to_export = detailed_docs.map(doc => {
- return {
- name: doc.name,
- owner: doc.owner,
- creation: doc.creation,
- modified: doc.modified,
- modified_by: doc.modified_by,
- docstatus: doc.docstatus,
- idx: doc.idx,
- is_system_generated: doc.is_system_generated,
- dt: doc.dt,
- label: doc.label,
- fieldname: doc.fieldname,
- insert_after: doc.insert_after,
- length: doc.length,
- fieldtype: doc.fieldtype,
- precision: doc.precision,
- hide_seconds: doc.hide_seconds,
- hide_days: doc.hide_days,
- options: doc.options,
- sort_options: doc.sort_options,
- fetch_if_empty: doc.fetch_if_empty,
- fetch_from: doc.fetch_from,
- collapsible: doc.collapsible,
- non_negative: doc.non_negative,
- mandatory_depends_on: doc.mandatory_depends_on,
- depends_on: doc.depends_on,
- reqd: doc.reqd,
- unique: doc.unique,
- is_virtual: doc.is_virtual,
- read_only: doc.read_only,
- ignore_user_permissions: doc.ignore_user_permissions,
- hidden: doc.hidden,
- print_hide: doc.print_hide,
- print_hide_if_no_value: doc.print_hide_if_no_value,
- no_copy: doc.no_copy,
- allow_on_submit: doc.allow_on_submit,
- in_list_view: doc.in_list_view,
- in_standard_filter: doc.in_standard_filter,
- in_global_search: doc.in_global_search,
- in_preview: doc.in_preview,
- bold: doc.bold,
- report_hide: doc.report_hide,
- search_index: doc.search_index,
- allow_in_quick_entry: doc.allow_in_quick_entry,
- ignore_xss_filter: doc.ignore_xss_filter,
- translatable: doc.translatable,
- hide_border: doc.hide_border,
- show_dashboard: doc.show_dashboard,
- permlevel: doc.permlevel,
- columns: doc.columns,
- doctype: doc.doctype,
- __last_sync_on: doc.__last_sync_on
- };
- });
+ const data_to_export = detailed_docs.map((doc) => {
+ return {
+ name: doc.name,
+ owner: doc.owner,
+ creation: doc.creation,
+ modified: doc.modified,
+ modified_by: doc.modified_by,
+ docstatus: doc.docstatus,
+ idx: doc.idx,
+ is_system_generated: doc.is_system_generated,
+ dt: doc.dt,
+ label: doc.label,
+ fieldname: doc.fieldname,
+ insert_after: doc.insert_after,
+ length: doc.length,
+ fieldtype: doc.fieldtype,
+ precision: doc.precision,
+ hide_seconds: doc.hide_seconds,
+ hide_days: doc.hide_days,
+ options: doc.options,
+ sort_options: doc.sort_options,
+ fetch_if_empty: doc.fetch_if_empty,
+ fetch_from: doc.fetch_from,
+ collapsible: doc.collapsible,
+ non_negative: doc.non_negative,
+ mandatory_depends_on: doc.mandatory_depends_on,
+ depends_on: doc.depends_on,
+ reqd: doc.reqd,
+ unique: doc.unique,
+ is_virtual: doc.is_virtual,
+ read_only: doc.read_only,
+ ignore_user_permissions: doc.ignore_user_permissions,
+ hidden: doc.hidden,
+ print_hide: doc.print_hide,
+ print_hide_if_no_value: doc.print_hide_if_no_value,
+ no_copy: doc.no_copy,
+ allow_on_submit: doc.allow_on_submit,
+ in_list_view: doc.in_list_view,
+ in_standard_filter: doc.in_standard_filter,
+ in_global_search: doc.in_global_search,
+ in_preview: doc.in_preview,
+ bold: doc.bold,
+ report_hide: doc.report_hide,
+ search_index: doc.search_index,
+ allow_in_quick_entry: doc.allow_in_quick_entry,
+ ignore_xss_filter: doc.ignore_xss_filter,
+ translatable: doc.translatable,
+ hide_border: doc.hide_border,
+ show_dashboard: doc.show_dashboard,
+ permlevel: doc.permlevel,
+ columns: doc.columns,
+ doctype: doc.doctype,
+ __last_sync_on: doc.__last_sync_on,
+ };
+ });
- const jsonStr = JSON.stringify(data_to_export);
- let blob = new Blob([jsonStr], { type: "application/json" });
- let a = document.createElement("a");
- a.href = URL.createObjectURL(blob);
- a.download = "exported_custom_fields.json";
- a.click();
- URL.revokeObjectURL(a.href);
- a.remove();
- });
- }
+ const jsonStr = JSON.stringify(data_to_export);
+ let blob = new Blob([jsonStr], { type: "application/json" });
+ let a = document.createElement("a");
+ a.href = URL.createObjectURL(blob);
+ a.download = "exported_custom_fields.json";
+ a.click();
+ URL.revokeObjectURL(a.href);
+ a.remove();
+ });
+ },
};
diff --git a/csf_tz/csf_tz/customer.js b/csf_tz/csf_tz/customer.js
index 3751e049..5404b64d 100644
--- a/csf_tz/csf_tz/customer.js
+++ b/csf_tz/csf_tz/customer.js
@@ -2,20 +2,16 @@
// For license information, please see license.txt
/* eslint-disable */
-
frappe.ui.form.on("Customer", {
-
-
- refresh: function(frm) {
-
- if(!frm.doc.__islocal) {
+ refresh: function (frm) {
+ if (!frm.doc.__islocal) {
// custom buttons
- frm.add_custom_button(__('Multi-Currency Ledger'), function() {
- frappe.set_route('query-report', 'Multi-Currency Ledger',
- {party_type:'Customer', party:frm.doc.name});
+ frm.add_custom_button(__("Multi-Currency Ledger"), function () {
+ frappe.set_route("query-report", "Multi-Currency Ledger", {
+ party_type: "Customer",
+ party: frm.doc.name,
+ });
});
-
}
},
-
});
diff --git a/csf_tz/csf_tz/dashboard_chart_source/multi_account_balance_timeline/multi_account_balance_timeline.js b/csf_tz/csf_tz/dashboard_chart_source/multi_account_balance_timeline/multi_account_balance_timeline.js
index dd8cc988..e154230d 100644
--- a/csf_tz/csf_tz/dashboard_chart_source/multi_account_balance_timeline/multi_account_balance_timeline.js
+++ b/csf_tz/csf_tz/dashboard_chart_source/multi_account_balance_timeline/multi_account_balance_timeline.js
@@ -29,6 +29,6 @@ frappe.dashboards.chart_sources["Multi_Account Balance Timeline"] = {
label: __("Include Inactive Accounts"),
fieldtype: "Check",
default: 0,
- }
+ },
],
};
diff --git a/csf_tz/csf_tz/delivery_note.js b/csf_tz/csf_tz/delivery_note.js
index 4abb786c..41c4dc38 100644
--- a/csf_tz/csf_tz/delivery_note.js
+++ b/csf_tz/csf_tz/delivery_note.js
@@ -1,18 +1,18 @@
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+q',
- action: () => {
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals["Delivery Note Item"][current_doc];
- frappe.call({
- method: 'csf_tz.custom_api.get_item_info',
- args: {item_code: item_row.item_code},
- callback: function(r) {
- if (r.message.length > 0){
- const d = new frappe.ui.Dialog({
- title: __('Item Balance'),
- width: 600
- });
- $(`
+ shortcut: "ctrl+q",
+ action: () => {
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals["Delivery Note Item"][current_doc];
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_info",
+ args: { item_code: item_row.item_code },
+ callback: function (r) {
+ if (r.message.length > 0) {
+ const d = new frappe.ui.Dialog({
+ title: __("Item Balance"),
+ width: 600,
+ });
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Warehouse and click Select :
@@ -22,10 +22,10 @@ frappe.ui.keys.add_shortcut({
`).appendTo(d.body);
- const thead = $(d.body).find('thead');
- if (r.message[0].batch_no){
- r.message.sort((a,b) => a.expiry_status-b.expiry_status);
- $(`
+ const thead = $(d.body).find("thead");
+ if (r.message[0].batch_no) {
+ r.message.sort((a, b) => a.expiry_status - b.expiry_status);
+ $(`
| Check |
Warehouse |
Qty |
@@ -34,115 +34,126 @@ frappe.ui.keys.add_shortcut({
Expires On |
Expires in Days |
`).appendTo(thead);
- } else {
- $(`
+ } else {
+ $(`
| Check |
Warehouse |
Qty |
UOM |
`).appendTo(thead);
- }
- r.message.forEach(element => {
- const tbody = $(d.body).find('tbody');
- const tr = $(`
+ }
+ r.message.forEach((element) => {
+ const tbody = $(d.body).find("tbody");
+ const tr = $(`
|
${element.warehouse} |
${element.actual_qty} |
- ${item_row.stock_uom } |
+ ${item_row.stock_uom} |
`).appendTo(tbody);
- if (element.batch_no) {
- $(`
+ if (element.batch_no) {
+ $(`
${element.batch_no} |
${element.expires_on} |
-
${element.expiry_status } |
+
${element.expiry_status} |
`).appendTo(tr);
- tr.find('.check-warehouse').attr('data-batch',element.batch_no);
- tr.find('.check-warehouse').attr('data-batchQty',element.actual_qty);
- }
- tbody.find('.check-warehouse').on('change', function() {
- $('input.check-warehouse').not(this).prop('checked', false);
- });
- });
- d.set_primary_action("Select", function() {
- $(d.body).find('input:checked').each(function(i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'warehouse', $(input).attr('data-warehouse'));
- if ($(input).attr('data-batch')) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'batch_no', $(input).attr('data-batch'));
- }
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
- cur_frm.rec_dialog = d;
- d.show();
- }
- else {
- frappe.show_alert({message:__('There is No Records'), indicator:'red'}, 5);
- }
- }
- });
- },
- page: this.page,
- description: __('Select Item Warehouse'),
- ignore_inputs: true,
+ tr.find(".check-warehouse").attr("data-batch", element.batch_no);
+ tr.find(".check-warehouse").attr("data-batchQty", element.actual_qty);
+ }
+ tbody.find(".check-warehouse").on("change", function () {
+ $("input.check-warehouse").not(this).prop("checked", false);
+ });
+ });
+ d.set_primary_action("Select", function () {
+ $(d.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "warehouse",
+ $(input).attr("data-warehouse")
+ );
+ if ($(input).attr("data-batch")) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "batch_no",
+ $(input).attr("data-batch")
+ );
+ }
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
+ cur_frm.rec_dialog = d;
+ d.show();
+ } else {
+ frappe.show_alert({ message: __("There is No Records"), indicator: "red" }, 5);
+ }
+ },
+ });
+ },
+ page: this.page,
+ description: __("Select Item Warehouse"),
+ ignore_inputs: true,
});
-
-
frappe.ui.form.on("Delivery Note", {
- refresh: function(frm, dt, dn) {
- if ((!frm.is_return) && (frm.status!="Closed" || frm.is_new())) {
- if (frm.doc.docstatus===0) {
- let query_args = {
- query:"csf_tz.custom_api.get_pending_sales_invoice",
- filters: {
- company: frm.doc.company,
- set_warehouse: frm.doc.set_warehouse || ""
- }
- }
- frm.add_custom_button(__('Sales Invoice'),
- function() {
+ refresh: function (frm, dt, dn) {
+ if (!frm.is_return && (frm.status != "Closed" || frm.is_new())) {
+ if (frm.doc.docstatus === 0) {
+ let query_args = {
+ query: "csf_tz.custom_api.get_pending_sales_invoice",
+ filters: {
+ company: frm.doc.company,
+ set_warehouse: frm.doc.set_warehouse || "",
+ },
+ };
+ frm.add_custom_button(
+ __("Sales Invoice"),
+ function () {
erpnext.utils.map_current_doc({
- method: "csf_tz.custom_api.make_delivery_note",
+ method: "csf_tz.custom_api.make_delivery_note",
source_doctype: "Sales Invoice",
target: frm,
setters: {
- customer: frm.doc.customer || undefined,
- set_warehouse: frm.doc.set_warehouse || "",
- },
- date_field: "posting_date",
- get_query() {
- return query_args;
- },
- })
- }, __("Get items from"));
+ customer: frm.doc.customer || undefined,
+ set_warehouse: frm.doc.set_warehouse || "",
+ },
+ date_field: "posting_date",
+ get_query() {
+ return query_args;
+ },
+ });
+ },
+ __("Get items from")
+ );
}
}
-
- },
- customer: function(frm) {
- if (!frm.doc.customer) {
- return
- }
- setTimeout(function() {
- if (!frm.doc.tax_category){
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function(r) {
- console.log(r.message);
- if(!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
+ },
+ customer: function (frm) {
+ if (!frm.doc.customer) {
+ return;
+ }
+ setTimeout(function () {
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ console.log(r.message);
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
});
diff --git a/csf_tz/csf_tz/doctype/bank_charges_pattern/bank_charges_pattern.js b/csf_tz/csf_tz/doctype/bank_charges_pattern/bank_charges_pattern.js
index d61bb210..23a38147 100644
--- a/csf_tz/csf_tz/doctype/bank_charges_pattern/bank_charges_pattern.js
+++ b/csf_tz/csf_tz/doctype/bank_charges_pattern/bank_charges_pattern.js
@@ -1,8 +1,7 @@
// Copyright (c) 2022, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Bank Charges Pattern', {
+frappe.ui.form.on("Bank Charges Pattern", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/csf_api_response_log/csf_api_response_log.js b/csf_tz/csf_tz/doctype/csf_api_response_log/csf_api_response_log.js
index 7784ad4b..8ade4185 100644
--- a/csf_tz/csf_tz/doctype/csf_api_response_log/csf_api_response_log.js
+++ b/csf_tz/csf_tz/doctype/csf_api_response_log/csf_api_response_log.js
@@ -1,8 +1,7 @@
// Copyright (c) 2021, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF API Response Log', {
+frappe.ui.form.on("CSF API Response Log", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.js b/csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.js
index 4aa44dec..5cb05d5f 100644
--- a/csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.js
+++ b/csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.js
@@ -1,8 +1,7 @@
// Copyright (c) 2024, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Bank Charges', {
+frappe.ui.form.on("CSF TZ Bank Charges", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/csf_tz_settings/csf_tz_settings.js b/csf_tz/csf_tz/doctype/csf_tz_settings/csf_tz_settings.js
index 45165eaa..ca25965c 100644
--- a/csf_tz/csf_tz/doctype/csf_tz_settings/csf_tz_settings.js
+++ b/csf_tz/csf_tz/doctype/csf_tz_settings/csf_tz_settings.js
@@ -2,12 +2,12 @@
// For license information, please see license.txt
frappe.ui.form.on("CSF TZ Settings", {
- start_sle_gle_reporting: function (frm) {
- frappe.call({
- method: "csf_tz.csftz_hooks.item_reposting.enqueue_reposting_sle_gle",
- callback: function (data) {
- console.log(data);
- },
- });
- },
+ start_sle_gle_reporting: function (frm) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.item_reposting.enqueue_reposting_sle_gle",
+ callback: function (data) {
+ console.log(data);
+ },
+ });
+ },
});
diff --git a/csf_tz/csf_tz/doctype/efd_z_report/efd_z_report.js b/csf_tz/csf_tz/doctype/efd_z_report/efd_z_report.js
index f6acd28e..2726d5ce 100644
--- a/csf_tz/csf_tz/doctype/efd_z_report/efd_z_report.js
+++ b/csf_tz/csf_tz/doctype/efd_z_report/efd_z_report.js
@@ -1,44 +1,45 @@
cur_frm.cscript.get_invoices = function (frm) {
- cur_frm.clear_table("efd_z_report_invoices")
+ cur_frm.clear_table("efd_z_report_invoices");
frappe.call({
- method: "get_sales_invoice",
- doc: cur_frm.doc,
- args: {
- "electronic_fiscal_device": cur_frm.doc.electronic_fiscal_device,
- "date_and_time": cur_frm.doc.z_report_date_time,
- },
- freeze: true,
- freeze_message: "Fetching Invoices...",
- callback: function(r) {
- cur_frm.refresh_field("efd_z_report_invoices")
- }
- });
-}
+ method: "get_sales_invoice",
+ doc: cur_frm.doc,
+ args: {
+ electronic_fiscal_device: cur_frm.doc.electronic_fiscal_device,
+ date_and_time: cur_frm.doc.z_report_date_time,
+ },
+ freeze: true,
+ freeze_message: "Fetching Invoices...",
+ callback: function (r) {
+ cur_frm.refresh_field("efd_z_report_invoices");
+ },
+ });
+};
-frappe.ui.form.on('EFD Z Report Invoice', {
+frappe.ui.form.on("EFD Z Report Invoice", {
include: (frm) => {
- let sum_excluding_vat_ticked = 0
- let sum_vat_ticked = 0
- let sum_turnover_exempted_sp_relief_ticked = 0
- let sum_turnover_ticked = 0
- frm.doc.efd_z_report_invoices.forEach(d => {
- if (d.include){
+ let sum_excluding_vat_ticked = 0;
+ let sum_vat_ticked = 0;
+ let sum_turnover_exempted_sp_relief_ticked = 0;
+ let sum_turnover_ticked = 0;
+ frm.doc.efd_z_report_invoices.forEach((d) => {
+ if (d.include) {
sum_excluding_vat_ticked += d.amt_excl_vat;
- sum_vat_ticked += d.vat;
- sum_turnover_exempted_sp_relief_ticked += d.amt_ex__sr;
- sum_turnover_ticked += d.invoice_amount;
+ sum_vat_ticked += d.vat;
+ sum_turnover_exempted_sp_relief_ticked += d.amt_ex__sr;
+ sum_turnover_ticked += d.invoice_amount;
}
});
- frm.set_value("total_excluding_vat_ticked", sum_excluding_vat_ticked - sum_turnover_exempted_sp_relief_ticked);
+ frm.set_value(
+ "total_excluding_vat_ticked",
+ sum_excluding_vat_ticked - sum_turnover_exempted_sp_relief_ticked
+ );
frm.set_value("total_vat_ticked", sum_vat_ticked);
frm.set_value("total_turnover_exempted__sp_relief_ticked", sum_turnover_exempted_sp_relief_ticked);
frm.set_value("total_turnover_ticked", sum_turnover_ticked);
+ },
+});
- }
-})
-
-
-frappe.ui.form.on('EFD Z Report', {
+frappe.ui.form.on("EFD Z Report", {
net_amount: (frm) => {
calculate_total_turnover(frm);
},
@@ -48,9 +49,9 @@ frappe.ui.form.on('EFD Z Report', {
total_turnover_ex_sr: (frm) => {
calculate_total_turnover(frm);
},
-})
+});
const calculate_total_turnover = (frm) => {
- frm.doc.total_turnover = frm.doc.net_amount + frm.doc.total_vat +frm.doc.total_turnover_ex_sr;
+ frm.doc.total_turnover = frm.doc.net_amount + frm.doc.total_vat + frm.doc.total_turnover_ex_sr;
refresh_field("total_turnover");
-}
+};
diff --git a/csf_tz/csf_tz/doctype/efd_z_report/test_efd_z_report.js b/csf_tz/csf_tz/doctype/efd_z_report/test_efd_z_report.js
index 3777e845..c5024dac 100644
--- a/csf_tz/csf_tz/doctype/efd_z_report/test_efd_z_report.js
+++ b/csf_tz/csf_tz/doctype/efd_z_report/test_efd_z_report.js
@@ -10,14 +10,14 @@ QUnit.test("test: EFD Z Report", function (assert) {
frappe.run_serially([
// insert a new EFD Z Report
- () => frappe.tests.make('EFD Z Report', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("EFD Z Report", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/csf_tz/doctype/efd_z_report_invoice/efd_z_report_invoice.js b/csf_tz/csf_tz/doctype/efd_z_report_invoice/efd_z_report_invoice.js
index d992d495..d7ce7cad 100644
--- a/csf_tz/csf_tz/doctype/efd_z_report_invoice/efd_z_report_invoice.js
+++ b/csf_tz/csf_tz/doctype/efd_z_report_invoice/efd_z_report_invoice.js
@@ -1,8 +1,6 @@
// Copyright (c) 2019, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('EFD Z Report Invoice', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("EFD Z Report Invoice", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/csf_tz/doctype/efd_z_report_invoice/test_efd_z_report_invoice.js b/csf_tz/csf_tz/doctype/efd_z_report_invoice/test_efd_z_report_invoice.js
index 682b45bd..f937761d 100644
--- a/csf_tz/csf_tz/doctype/efd_z_report_invoice/test_efd_z_report_invoice.js
+++ b/csf_tz/csf_tz/doctype/efd_z_report_invoice/test_efd_z_report_invoice.js
@@ -10,14 +10,14 @@ QUnit.test("test: EFD Z Report Invoice", function (assert) {
frappe.run_serially([
// insert a new EFD Z Report Invoice
- () => frappe.tests.make('EFD Z Report Invoice', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("EFD Z Report Invoice", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/csf_tz/doctype/electronic_fiscal_device/electronic_fiscal_device.js b/csf_tz/csf_tz/doctype/electronic_fiscal_device/electronic_fiscal_device.js
index 2e9e311a..59074510 100644
--- a/csf_tz/csf_tz/doctype/electronic_fiscal_device/electronic_fiscal_device.js
+++ b/csf_tz/csf_tz/doctype/electronic_fiscal_device/electronic_fiscal_device.js
@@ -1,8 +1,6 @@
// Copyright (c) 2019, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Electronic Fiscal Device', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Electronic Fiscal Device", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/csf_tz/doctype/electronic_fiscal_device/test_electronic_fiscal_device.js b/csf_tz/csf_tz/doctype/electronic_fiscal_device/test_electronic_fiscal_device.js
index 1019e98c..fe2ed74e 100644
--- a/csf_tz/csf_tz/doctype/electronic_fiscal_device/test_electronic_fiscal_device.js
+++ b/csf_tz/csf_tz/doctype/electronic_fiscal_device/test_electronic_fiscal_device.js
@@ -10,14 +10,14 @@ QUnit.test("test: Electronic Fiscal Device", function (assert) {
frappe.run_serially([
// insert a new Electronic Fiscal Device
- () => frappe.tests.make('Electronic Fiscal Device', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Electronic Fiscal Device", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/csf_tz/doctype/foreign_import_transaction/foreign_import_transaction.js b/csf_tz/csf_tz/doctype/foreign_import_transaction/foreign_import_transaction.js
index 91de26a0..8de8bf71 100644
--- a/csf_tz/csf_tz/doctype/foreign_import_transaction/foreign_import_transaction.js
+++ b/csf_tz/csf_tz/doctype/foreign_import_transaction/foreign_import_transaction.js
@@ -1,213 +1,235 @@
// Copyright (c) 2025, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Foreign Import Transaction', {
- refresh: function(frm) {
- if (frm.doc.docstatus === 1 && frm.doc.status !== 'Completed') {
- frm.add_custom_button(__('Recalculate Differences'), function() {
- frappe.call({
- method: 'recalculate_differences',
- doc: frm.doc,
- callback: function(r) {
- if (r.message) {
- frappe.msgprint(__('Exchange differences recalculated successfully'));
- frm.reload_doc();
- }
- }
- });
- });
- }
-
- if (frm.doc.docstatus === 1) {
- frm.add_custom_button(__('View Exchange Report'), function() {
- frappe.route_options = {
- "purchase_invoice": frm.doc.purchase_invoice,
- "supplier": frm.doc.supplier
- };
- frappe.set_route("query-report", "Import Exchange Differences");
- });
-
- // Add debugging button
- frm.add_custom_button(__('Debug Payment Linking'), function() {
- let payment_entry = prompt(__('Enter Payment Entry name to debug:'));
- if (payment_entry) {
- frappe.call({
- method: 'csf_tz.csftz_hooks.exchange_calculations.debug_payment_linking_issue',
- args: {
- payment_entry_name: payment_entry
- },
- callback: function(r) {
- if (r.message && !r.message.error) {
- let debug_info = r.message;
- let msg = `
Payment Details:
+frappe.ui.form.on("Foreign Import Transaction", {
+ refresh: function (frm) {
+ if (frm.doc.docstatus === 1 && frm.doc.status !== "Completed") {
+ frm.add_custom_button(__("Recalculate Differences"), function () {
+ frappe.call({
+ method: "recalculate_differences",
+ doc: frm.doc,
+ callback: function (r) {
+ if (r.message) {
+ frappe.msgprint(__("Exchange differences recalculated successfully"));
+ frm.reload_doc();
+ }
+ },
+ });
+ });
+ }
+
+ if (frm.doc.docstatus === 1) {
+ frm.add_custom_button(__("View Exchange Report"), function () {
+ frappe.route_options = {
+ purchase_invoice: frm.doc.purchase_invoice,
+ supplier: frm.doc.supplier,
+ };
+ frappe.set_route("query-report", "Import Exchange Differences");
+ });
+
+ // Add debugging button
+ frm.add_custom_button(
+ __("Debug Payment Linking"),
+ function () {
+ let payment_entry = prompt(__("Enter Payment Entry name to debug:"));
+ if (payment_entry) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.exchange_calculations.debug_payment_linking_issue",
+ args: {
+ payment_entry_name: payment_entry,
+ },
+ callback: function (r) {
+ if (r.message && !r.message.error) {
+ let debug_info = r.message;
+ let msg = `
Payment Details:
- - Payment Type: ${debug_info.payment_details.payment_type}
- - Party Type: ${debug_info.payment_details.party_type}
+ - Payment Type: ${
+ debug_info.payment_details.payment_type
+ }
+ - Party Type: ${
+ debug_info.payment_details.party_type
+ }
- Party: ${debug_info.payment_details.party}
- - Currency: ${debug_info.payment_details.paid_to_account_currency}
- - Exchange Rate: ${debug_info.payment_details.source_exchange_rate}
- - Amount: ${debug_info.payment_details.paid_amount}
- - Status: ${debug_info.payment_details.docstatus == 1 ? 'Submitted' : 'Draft'}
+ - Currency: ${
+ debug_info.payment_details.paid_to_account_currency
+ }
+ - Exchange Rate: ${
+ debug_info.payment_details.source_exchange_rate
+ }
+ - Amount: ${
+ debug_info.payment_details.paid_amount
+ }
+ - Status: ${
+ debug_info.payment_details.docstatus == 1 ? "Submitted" : "Draft"
+ }
`;
- if (debug_info.issues.length > 0) {
- msg += `
Issues Found:
`;
- debug_info.issues.forEach(issue => {
- msg += `- ${issue}
`;
- });
- msg += `
`;
- }
-
- if (debug_info.potential_trackers.length > 0) {
- msg += `
Potential Trackers:
`;
- debug_info.potential_trackers.forEach(tracker => {
- let color = tracker.issues.length > 0 ? 'red' : 'green';
- msg += `
+ if (debug_info.issues.length > 0) {
+ msg += `
Issues Found:
`;
+ debug_info.issues.forEach((issue) => {
+ msg += `- ${issue}
`;
+ });
+ msg += `
`;
+ }
+
+ if (debug_info.potential_trackers.length > 0) {
+ msg += `
Potential Trackers:
`;
+ debug_info.potential_trackers.forEach((tracker) => {
+ let color = tracker.issues.length > 0 ? "red" : "green";
+ msg += `
${tracker.name} (${tracker.purchase_invoice})
Currency: ${tracker.currency} | Status: ${tracker.status}
- Currency Match: ${tracker.currency_match ? '✅' : '❌'} |
- Status OK: ${tracker.status_ok ? '✅' : '❌'}`;
- if (tracker.issues.length > 0) {
- msg += `
Issues: ${tracker.issues.join(', ')}`;
- }
- msg += `
`;
- });
- } else {
- msg += `
No trackers found for supplier: ${debug_info.payment_details.party}
`;
- }
-
- frappe.msgprint({
- title: __('Payment Linking Debug Info'),
- message: msg,
- indicator: 'blue'
- });
- } else if (r.message && r.message.error) {
- frappe.msgprint(`Error: ${r.message.error}`, 'Error');
- }
- }
- });
- }
- }, __('Debug'));
-
- // Add manual linking button
- frm.add_custom_button(__('Link Payment Manually'), function() {
- let payment_entry = prompt(__('Enter Payment Entry name to link:'));
- if (payment_entry) {
- frappe.call({
- method: 'csf_tz.csftz_hooks.exchange_calculations.manually_link_payment_to_tracker',
- args: {
- payment_entry_name: payment_entry,
- tracker_name: frm.doc.name
- },
- callback: function(r) {
- if (r.message && r.message.success) {
- frappe.msgprint(r.message.success, 'Success');
- frm.reload_doc();
- } else if (r.message && r.message.error) {
- frappe.msgprint(`Error: ${r.message.error}`, 'Error');
- }
- }
- });
- }
- }, __('Debug'));
- }
-
- // Set color indicator based on status
- if (frm.doc.status && frm.dashboard) {
- let color = {
- 'Draft': 'orange',
- 'Active': 'blue',
- 'Completed': 'green',
- 'Cancelled': 'red'
- }[frm.doc.status];
-
- // Use the correct method for setting indicators
- if (frm.dashboard.add_indicator) {
- frm.dashboard.add_indicator(__('Status: {0}', [frm.doc.status]), color);
- }
- }
-
- // Show total differences summary
- if (frm.doc.total_gain_loss && frm.dashboard && frm.dashboard.add_indicator) {
- let message = frm.doc.total_gain_loss >= 0 ?
- __('Total Exchange Gain: {0}', [format_currency(frm.doc.total_gain_loss)]) :
- __('Total Exchange Loss: {0}', [format_currency(Math.abs(frm.doc.total_gain_loss))]);
-
- frm.dashboard.add_indicator(message, frm.doc.total_gain_loss >= 0 ? 'green' : 'red');
- }
- },
-
- purchase_invoice: function(frm) {
- if (frm.doc.purchase_invoice) {
- frappe.call({
- method: 'frappe.client.get',
- args: {
- doctype: 'Purchase Invoice',
- name: frm.doc.purchase_invoice
- },
- callback: function(r) {
- if (r.message) {
- let pi = r.message;
-
- // Check if it's a foreign currency invoice
- frappe.db.get_value('Company', pi.company, 'default_currency')
- .then(result => {
- if (pi.currency === result.message.default_currency) {
- frappe.msgprint(__('Selected Purchase Invoice is not in foreign currency'));
- frm.set_value('purchase_invoice', '');
- return;
- }
-
- // Set fields from PI
- frm.set_value({
- 'supplier': pi.supplier,
- 'transaction_date': pi.posting_date,
- 'currency': pi.currency,
- 'original_exchange_rate': pi.conversion_rate,
- 'invoice_amount_foreign': pi.grand_total,
- 'invoice_amount_base': pi.base_grand_total,
- 'company': pi.company
- });
- });
- }
- }
- });
- }
- }
+ Currency Match: ${tracker.currency_match ? "✅" : "❌"} |
+ Status OK: ${tracker.status_ok ? "✅" : "❌"}`;
+ if (tracker.issues.length > 0) {
+ msg += `
Issues: ${tracker.issues.join(
+ ", "
+ )}`;
+ }
+ msg += `
`;
+ });
+ } else {
+ msg += `
No trackers found for supplier: ${debug_info.payment_details.party}
`;
+ }
+
+ frappe.msgprint({
+ title: __("Payment Linking Debug Info"),
+ message: msg,
+ indicator: "blue",
+ });
+ } else if (r.message && r.message.error) {
+ frappe.msgprint(`Error: ${r.message.error}`, "Error");
+ }
+ },
+ });
+ }
+ },
+ __("Debug")
+ );
+
+ // Add manual linking button
+ frm.add_custom_button(
+ __("Link Payment Manually"),
+ function () {
+ let payment_entry = prompt(__("Enter Payment Entry name to link:"));
+ if (payment_entry) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.exchange_calculations.manually_link_payment_to_tracker",
+ args: {
+ payment_entry_name: payment_entry,
+ tracker_name: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message && r.message.success) {
+ frappe.msgprint(r.message.success, "Success");
+ frm.reload_doc();
+ } else if (r.message && r.message.error) {
+ frappe.msgprint(`Error: ${r.message.error}`, "Error");
+ }
+ },
+ });
+ }
+ },
+ __("Debug")
+ );
+ }
+
+ // Set color indicator based on status
+ if (frm.doc.status && frm.dashboard) {
+ let color = {
+ Draft: "orange",
+ Active: "blue",
+ Completed: "green",
+ Cancelled: "red",
+ }[frm.doc.status];
+
+ // Use the correct method for setting indicators
+ if (frm.dashboard.add_indicator) {
+ frm.dashboard.add_indicator(__("Status: {0}", [frm.doc.status]), color);
+ }
+ }
+
+ // Show total differences summary
+ if (frm.doc.total_gain_loss && frm.dashboard && frm.dashboard.add_indicator) {
+ let message =
+ frm.doc.total_gain_loss >= 0
+ ? __("Total Exchange Gain: {0}", [format_currency(frm.doc.total_gain_loss)])
+ : __("Total Exchange Loss: {0}", [format_currency(Math.abs(frm.doc.total_gain_loss))]);
+
+ frm.dashboard.add_indicator(message, frm.doc.total_gain_loss >= 0 ? "green" : "red");
+ }
+ },
+
+ purchase_invoice: function (frm) {
+ if (frm.doc.purchase_invoice) {
+ frappe.call({
+ method: "frappe.client.get",
+ args: {
+ doctype: "Purchase Invoice",
+ name: frm.doc.purchase_invoice,
+ },
+ callback: function (r) {
+ if (r.message) {
+ let pi = r.message;
+
+ // Check if it's a foreign currency invoice
+ frappe.db.get_value("Company", pi.company, "default_currency").then((result) => {
+ if (pi.currency === result.message.default_currency) {
+ frappe.msgprint(__("Selected Purchase Invoice is not in foreign currency"));
+ frm.set_value("purchase_invoice", "");
+ return;
+ }
+
+ // Set fields from PI
+ frm.set_value({
+ supplier: pi.supplier,
+ transaction_date: pi.posting_date,
+ currency: pi.currency,
+ original_exchange_rate: pi.conversion_rate,
+ invoice_amount_foreign: pi.grand_total,
+ invoice_amount_base: pi.base_grand_total,
+ company: pi.company,
+ });
+ });
+ }
+ },
+ });
+ }
+ },
});
-frappe.ui.form.on('Foreign Import Payment Details', {
- payment_entry: function(frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- if (row.payment_entry) {
- frappe.call({
- method: 'frappe.client.get',
- args: {
- doctype: 'Payment Entry',
- name: row.payment_entry
- },
- callback: function(r) {
- if (r.message) {
- let pe = r.message;
- frappe.model.set_value(cdt, cdn, {
- 'payment_date': pe.posting_date,
- 'payment_amount_foreign': pe.paid_amount,
- 'payment_amount_base': pe.base_paid_amount,
- 'payment_exchange_rate': pe.source_exchange_rate
- });
-
- // Calculate exchange difference
- let original_rate = flt(frm.doc.original_exchange_rate);
- let payment_rate = flt(pe.source_exchange_rate);
- let paid_amount = flt(pe.paid_amount);
-
- if (original_rate !== payment_rate) {
- let exchange_diff = paid_amount * (payment_rate - original_rate);
- frappe.model.set_value(cdt, cdn, 'exchange_difference', exchange_diff);
- }
- }
- }
- });
- }
- }
+frappe.ui.form.on("Foreign Import Payment Details", {
+ payment_entry: function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ if (row.payment_entry) {
+ frappe.call({
+ method: "frappe.client.get",
+ args: {
+ doctype: "Payment Entry",
+ name: row.payment_entry,
+ },
+ callback: function (r) {
+ if (r.message) {
+ let pe = r.message;
+ frappe.model.set_value(cdt, cdn, {
+ payment_date: pe.posting_date,
+ payment_amount_foreign: pe.paid_amount,
+ payment_amount_base: pe.base_paid_amount,
+ payment_exchange_rate: pe.source_exchange_rate,
+ });
+
+ // Calculate exchange difference
+ let original_rate = flt(frm.doc.original_exchange_rate);
+ let payment_rate = flt(pe.source_exchange_rate);
+ let paid_amount = flt(pe.paid_amount);
+
+ if (original_rate !== payment_rate) {
+ let exchange_diff = paid_amount * (payment_rate - original_rate);
+ frappe.model.set_value(cdt, cdn, "exchange_difference", exchange_diff);
+ }
+ }
+ },
+ });
+ }
+ },
});
diff --git a/csf_tz/csf_tz/doctype/nmb_callback/nmb_callback.js b/csf_tz/csf_tz/doctype/nmb_callback/nmb_callback.js
index cd13c810..aea60dc4 100644
--- a/csf_tz/csf_tz/doctype/nmb_callback/nmb_callback.js
+++ b/csf_tz/csf_tz/doctype/nmb_callback/nmb_callback.js
@@ -1,17 +1,15 @@
// Copyright (c) 2020, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('NMB Callback', {
- refresh: function(frm) {
- frm.add_custom_button(__('Make Payment Entry'),
- function () {
- frappe.call({
- method: "csf_tz.bank_api.make_payment_entry_from_call",
- args: {
- docname: frm.doc.name,
- },
- });
- }
- );
- }
+frappe.ui.form.on("NMB Callback", {
+ refresh: function (frm) {
+ frm.add_custom_button(__("Make Payment Entry"), function () {
+ frappe.call({
+ method: "csf_tz.bank_api.make_payment_entry_from_call",
+ args: {
+ docname: frm.doc.name,
+ },
+ });
+ });
+ },
});
diff --git a/csf_tz/csf_tz/doctype/student_applicant_fees/student_applicant_fees.js b/csf_tz/csf_tz/doctype/student_applicant_fees/student_applicant_fees.js
index c6026d90..d0b2285e 100644
--- a/csf_tz/csf_tz/doctype/student_applicant_fees/student_applicant_fees.js
+++ b/csf_tz/csf_tz/doctype/student_applicant_fees/student_applicant_fees.js
@@ -1,44 +1,44 @@
// Copyright (c) 2020, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Student Applicant Fees', {
- setup: function(frm) {
+frappe.ui.form.on("Student Applicant Fees", {
+ setup: function (frm) {
frm.add_fetch("fee_structure", "receivable_account", "receivable_account");
frm.add_fetch("fee_structure", "income_account", "income_account");
frm.add_fetch("fee_structure", "cost_center", "cost_center");
},
- onload: function(frm){
- frm.set_query("academic_term",function(){
- return{
- "filters":{
- "academic_year": (frm.doc.academic_year)
- }
+ onload: function (frm) {
+ frm.set_query("academic_term", function () {
+ return {
+ filters: {
+ academic_year: frm.doc.academic_year,
+ },
};
});
- frm.set_query("fee_structure",function(){
- return{
- "filters":{
- "academic_year": (frm.doc.academic_year)
- }
+ frm.set_query("fee_structure", function () {
+ return {
+ filters: {
+ academic_year: frm.doc.academic_year,
+ },
};
});
- frm.set_query("receivable_account", function(doc) {
+ frm.set_query("receivable_account", function (doc) {
return {
filters: {
- 'account_type': 'Receivable',
- 'is_group': 0,
- 'company': doc.company
- }
+ account_type: "Receivable",
+ is_group: 0,
+ company: doc.company,
+ },
};
});
- frm.set_query("income_account", function(doc) {
+ frm.set_query("income_account", function (doc) {
return {
filters: {
- 'account_type': 'Income Account',
- 'is_group': 0,
- 'company': doc.company
- }
+ account_type: "Income Account",
+ is_group: 0,
+ company: doc.company,
+ },
};
});
if (!frm.doc.posting_date) {
@@ -46,40 +46,40 @@ frappe.ui.form.on('Student Applicant Fees', {
}
},
- refresh: function(frm) {
- if(frm.doc.docstatus == 0 && frm.doc.set_posting_time) {
- frm.set_df_property('posting_date', 'read_only', 0);
- frm.set_df_property('posting_time', 'read_only', 0);
+ refresh: function (frm) {
+ if (frm.doc.docstatus == 0 && frm.doc.set_posting_time) {
+ frm.set_df_property("posting_date", "read_only", 0);
+ frm.set_df_property("posting_time", "read_only", 0);
} else {
- frm.set_df_property('posting_date', 'read_only', 1);
- frm.set_df_property('posting_time', 'read_only', 1);
+ frm.set_df_property("posting_date", "read_only", 1);
+ frm.set_df_property("posting_time", "read_only", 1);
}
},
- student: function(frm) {
+ student: function (frm) {
if (frm.doc.student) {
frappe.call({
- method:"erpnext.education.api.get_current_enrollment",
+ method: "erpnext.education.api.get_current_enrollment",
args: {
- "student": frm.doc.student,
- "academic_year": frm.doc.academic_year
+ student: frm.doc.student,
+ academic_year: frm.doc.academic_year,
},
- callback: function(r) {
- if(r){
- $.each(r.message, function(i, d) {
- frm.set_value(i,d);
+ callback: function (r) {
+ if (r) {
+ $.each(r.message, function (i, d) {
+ frm.set_value(i, d);
});
}
- }
+ },
});
}
},
- set_posting_time: function(frm) {
+ set_posting_time: function (frm) {
frm.refresh();
},
- academic_term: function() {
+ academic_term: function () {
frappe.ui.form.trigger("Fees", "program");
},
});
diff --git a/csf_tz/csf_tz/doctype/tra_tax_inv/tra_tax_inv.js b/csf_tz/csf_tz/doctype/tra_tax_inv/tra_tax_inv.js
index 76c18b32..dab44b7c 100644
--- a/csf_tz/csf_tz/doctype/tra_tax_inv/tra_tax_inv.js
+++ b/csf_tz/csf_tz/doctype/tra_tax_inv/tra_tax_inv.js
@@ -1,43 +1,51 @@
// Copyright (c) 2025, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TRA TAX Inv', {
- refresh: function (frm) {
- // Add Create Invoice button if document is saved and no invoice exists yet
- if (frm.doc.name && !frm.doc.reference_docname) {
- frm.add_custom_button(__('Create Invoice'), function () {
- show_invoice_type_dialog(frm);
- }, __('Actions'));
- }
+frappe.ui.form.on("TRA TAX Inv", {
+ refresh: function (frm) {
+ // Add Create Invoice button if document is saved and no invoice exists yet
+ if (frm.doc.name && !frm.doc.reference_docname) {
+ frm.add_custom_button(
+ __("Create Invoice"),
+ function () {
+ show_invoice_type_dialog(frm);
+ },
+ __("Actions")
+ );
+ }
- // Show reference invoice link if exists
- if (frm.doc.reference_docname && frm.doc.reference_doctype) {
- frm.add_custom_button(__('View ' + frm.doc.reference_doctype), function () {
- frappe.set_route('Form', frm.doc.reference_doctype, frm.doc.reference_docname);
- }, __('Actions'));
- }
- },
+ // Show reference invoice link if exists
+ if (frm.doc.reference_docname && frm.doc.reference_doctype) {
+ frm.add_custom_button(
+ __("View " + frm.doc.reference_doctype),
+ function () {
+ frappe.set_route("Form", frm.doc.reference_doctype, frm.doc.reference_docname);
+ },
+ __("Actions")
+ );
+ }
+ },
});
function show_invoice_type_dialog(frm) {
- let dialog = new frappe.ui.Dialog({
- title: __('Create Invoice'),
- fields: [
- {
- fieldtype: 'Select',
- fieldname: 'invoice_type',
- label: __('Invoice Type'),
- options: [
- { label: __('Purchase Invoice'), value: 'Purchase Invoice' },
- { label: __('Sales Invoice'), value: 'Sales Invoice' }
- ],
- reqd: 1,
- description: __('Select the type of invoice to create from this TRA Tax Invoice')
- },
- {
- fieldtype: 'HTML',
- fieldname: 'info_html',
- options: `
+ let dialog = new frappe.ui.Dialog({
+ title: __("Create Invoice"),
+ fields: [
+ {
+ fieldtype: "Select",
+ fieldname: "invoice_type",
+ label: __("Invoice Type"),
+ options: [
+ { label: __("Purchase Invoice"), value: "Purchase Invoice" },
+ { label: __("Sales Invoice"), value: "Sales Invoice" },
+ ],
+ reqd: 1,
+ description: __("Select the type of invoice to create from this TRA Tax Invoice"),
+ },
+ {
+ fieldtype: "HTML",
+ fieldname: "info_html",
+ options: `
Note:
@@ -46,69 +54,77 @@ function show_invoice_type_dialog(frm) {
The system will validate that all required master records (Items, Customer/Supplier) exist before creating the invoice.
- `
- }
- ],
- primary_action_label: __('Create Invoice'),
- primary_action: function (values) {
- if (!values.invoice_type) {
- frappe.msgprint(__('Please select an invoice type'));
- return;
- }
+ `,
+ },
+ ],
+ primary_action_label: __("Create Invoice"),
+ primary_action: function (values) {
+ if (!values.invoice_type) {
+ frappe.msgprint(__("Please select an invoice type"));
+ return;
+ }
- dialog.hide();
- create_invoice_from_tra_tax_inv(frm, values.invoice_type);
- }
- });
+ dialog.hide();
+ create_invoice_from_tra_tax_inv(frm, values.invoice_type);
+ },
+ });
- dialog.show();
+ dialog.show();
}
function create_invoice_from_tra_tax_inv(frm, invoice_type) {
- frappe.show_progress(__('Creating Invoice'), 50, 100, __('Validating data...'));
+ frappe.show_progress(__("Creating Invoice"), 50, 100, __("Validating data..."));
- frappe.call({
- method: 'csf_tz.csf_tz.doctype.tra_tax_inv.tra_tax_inv.create_invoice_from_tra_tax_inv',
- args: {
- tra_tax_inv_name: frm.doc.name,
- invoice_type: invoice_type
- },
- callback: function (response) {
- frappe.hide_progress();
+ frappe.call({
+ method: "csf_tz.csf_tz.doctype.tra_tax_inv.tra_tax_inv.create_invoice_from_tra_tax_inv",
+ args: {
+ tra_tax_inv_name: frm.doc.name,
+ invoice_type: invoice_type,
+ },
+ callback: function (response) {
+ frappe.hide_progress();
- if (response.message && response.message.success) {
- frappe.show_alert({
- message: __(response.message.message),
- indicator: 'green'
- });
+ if (response.message && response.message.success) {
+ frappe.show_alert({
+ message: __(response.message.message),
+ indicator: "green",
+ });
- // Refresh the form to show the reference
- frm.reload_doc();
+ // Refresh the form to show the reference
+ frm.reload_doc();
- // Ask if user wants to open the created invoice
- frappe.confirm(
- __('Invoice created successfully. Do you want to open the {0}?', [response.message.invoice_type]),
- function () {
- frappe.set_route('Form', response.message.invoice_type, response.message.invoice_name);
- }
- );
- } else {
- let error_message = response.message ? response.message.message : __('Unknown error occurred');
- frappe.msgprint({
- title: __('Error Creating Invoice'),
- message: error_message,
- indicator: 'red'
- });
- }
- },
- error: function (error) {
- frappe.hide_progress();
- frappe.msgprint({
- title: __('Error'),
- message: __('Failed to create invoice. Please try again.'),
- indicator: 'red'
- });
- console.error('Error creating invoice:', error);
- }
- });
+ // Ask if user wants to open the created invoice
+ frappe.confirm(
+ __("Invoice created successfully. Do you want to open the {0}?", [
+ response.message.invoice_type,
+ ]),
+ function () {
+ frappe.set_route(
+ "Form",
+ response.message.invoice_type,
+ response.message.invoice_name
+ );
+ }
+ );
+ } else {
+ let error_message = response.message
+ ? response.message.message
+ : __("Unknown error occurred");
+ frappe.msgprint({
+ title: __("Error Creating Invoice"),
+ message: error_message,
+ indicator: "red",
+ });
+ }
+ },
+ error: function (error) {
+ frappe.hide_progress();
+ frappe.msgprint({
+ title: __("Error"),
+ message: __("Failed to create invoice. Please try again."),
+ indicator: "red",
+ });
+ console.error("Error creating invoice:", error);
+ },
+ });
}
diff --git a/csf_tz/csf_tz/doctype/tz_district/tz_district.js b/csf_tz/csf_tz/doctype/tz_district/tz_district.js
index c4d7fe2c..95109aa4 100644
--- a/csf_tz/csf_tz/doctype/tz_district/tz_district.js
+++ b/csf_tz/csf_tz/doctype/tz_district/tz_district.js
@@ -1,8 +1,7 @@
// Copyright (c) 2021, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TZ District', {
+frappe.ui.form.on("TZ District", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/tz_insurance_cover_note/tz_insurance_cover_note.js b/csf_tz/csf_tz/doctype/tz_insurance_cover_note/tz_insurance_cover_note.js
index 52e9a22a..ae2d0850 100644
--- a/csf_tz/csf_tz/doctype/tz_insurance_cover_note/tz_insurance_cover_note.js
+++ b/csf_tz/csf_tz/doctype/tz_insurance_cover_note/tz_insurance_cover_note.js
@@ -1,8 +1,7 @@
// Copyright (c) 2022, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TZ Insurance Cover Note', {
+frappe.ui.form.on("TZ Insurance Cover Note", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/tz_region/tz_region.js b/csf_tz/csf_tz/doctype/tz_region/tz_region.js
index c4d40aba..932dbea3 100644
--- a/csf_tz/csf_tz/doctype/tz_region/tz_region.js
+++ b/csf_tz/csf_tz/doctype/tz_region/tz_region.js
@@ -1,8 +1,7 @@
// Copyright (c) 2021, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TZ Region', {
+frappe.ui.form.on("TZ Region", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/tz_village/tz_village.js b/csf_tz/csf_tz/doctype/tz_village/tz_village.js
index 7e9e31c2..269ad84d 100644
--- a/csf_tz/csf_tz/doctype/tz_village/tz_village.js
+++ b/csf_tz/csf_tz/doctype/tz_village/tz_village.js
@@ -1,8 +1,7 @@
// Copyright (c) 2021, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TZ Village', {
+frappe.ui.form.on("TZ Village", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/tz_ward/tz_ward.js b/csf_tz/csf_tz/doctype/tz_ward/tz_ward.js
index 515bc994..5632f9e7 100644
--- a/csf_tz/csf_tz/doctype/tz_ward/tz_ward.js
+++ b/csf_tz/csf_tz/doctype/tz_ward/tz_ward.js
@@ -1,8 +1,7 @@
// Copyright (c) 2021, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('TZ Ward', {
+frappe.ui.form.on("TZ Ward", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.js b/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.js
index 2f13cec3..3bb3a8fa 100644
--- a/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.js
+++ b/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.js
@@ -1,8 +1,7 @@
// Copyright (c) 2020, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Vehicle Fine Record', {
+frappe.ui.form.on("Vehicle Fine Record", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.py b/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.py
index b3781bfd..330e73b6 100644
--- a/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.py
+++ b/csf_tz/csf_tz/doctype/vehicle_fine_record/vehicle_fine_record.py
@@ -5,7 +5,6 @@
import hashlib
import json
import re
-from time import sleep
import frappe
import requests
@@ -139,74 +138,20 @@ def sync_vehicle_fines(number_plate):
}
payload = {"vehicle": number_plate}
- max_retries = 3
- response = None
-
- for attempt in range(max_retries):
- try:
- if attempt > 0:
- sleep(5 * attempt)
-
- response = requests.post(url, json=payload, headers=headers, timeout=30)
- if response.status_code == 429:
- return {
- "status": "rate_limited",
- "message": f"TPF rate limited {number_plate}",
- "fine_list": [],
- }
- response.raise_for_status()
- break
-
- except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exc:
- if attempt < max_retries - 1:
- continue
- frappe.logger().warning(
- f"[VehicleFine] Connection timeout for {number_plate} after {max_retries} retries"
- )
- return {
- "status": "retryable_error",
- "message": str(exc),
- "fine_list": [],
- }
-
- except requests.exceptions.HTTPError:
- status = response.status_code if response is not None else 0
- if status in (408,) or status >= 500:
- if attempt < max_retries - 1:
- continue
- frappe.logger().warning(
- f"[VehicleFine] HTTP {status} for {number_plate} after {max_retries} retries"
- )
- return {
- "status": "retryable_error",
- "message": f"HTTP {status}",
- "fine_list": [],
- }
-
- frappe.log_error(
- title="TPF API Error",
- message=(
- f"HTTP {status} for {number_plate}: {response.text[:500] if response is not None else ''}"
- ),
- )
- return {
- "status": "error",
- "message": f"HTTP {status}",
- "fine_list": [],
- }
-
- except requests.exceptions.RequestException as exc:
- frappe.log_error(title="TPF API Error", message=str(exc))
+ try:
+ response = requests.post(url, json=payload, headers=headers, timeout=30)
+ if response.status_code == 429:
return {
- "status": "error",
- "message": str(exc),
+ "status": "rate_limited",
+ "message": f"TPF rate limited {number_plate}",
"fine_list": [],
}
-
- if response is None:
+ response.raise_for_status()
+ except requests.exceptions.RequestException as exc:
+ frappe.logger().warning(f"[VehicleFine] TPF request failed for {number_plate}: {exc}")
return {
"status": "retryable_error",
- "message": "No response from TPF",
+ "message": str(exc),
"fine_list": [],
}
diff --git a/csf_tz/csf_tz/doctype/vehicle_sync_task/processor.py b/csf_tz/csf_tz/doctype/vehicle_sync_task/processor.py
index 8768caca..0c97edaf 100644
--- a/csf_tz/csf_tz/doctype/vehicle_sync_task/processor.py
+++ b/csf_tz/csf_tz/doctype/vehicle_sync_task/processor.py
@@ -45,14 +45,8 @@ def _acquire_rate_limit_slot():
return True
-def _backoff_seconds(attempts):
- exponent = max(attempts - 1, 0)
- return queue.BASE_BACKOFF * (2**exponent)
-
-
@frappe.whitelist()
def run_vehicle_batch():
- started_at = time.monotonic()
processed = 0
errors = 0
@@ -63,16 +57,8 @@ def run_vehicle_batch():
return {"status": "no_tasks", "message": "No pending vehicle sync tasks"}
for task in tasks:
- if (time.monotonic() - started_at) >= queue.TIME_BUDGET_SEC:
- break
-
if not _acquire_rate_limit_slot():
- queue.schedule_next(
- TASK_DOCTYPE,
- task,
- 60,
- "TPF per-minute limit reached for this site",
- )
+ queue.mark_failed(TASK_DOCTYPE, task, "TPF per-minute limit reached for this site")
continue
result = sync_vehicle_fines(task["vehicle_no"])
@@ -83,21 +69,10 @@ def run_vehicle_batch():
processed += 1
continue
- if status in {"rate_limited", "retryable_error"}:
- attempts, _ = queue.bump_attempts(TASK_DOCTYPE, task)
- queue.schedule_next(
- TASK_DOCTYPE,
- task,
- _backoff_seconds(attempts),
- result.get("message") or status,
- )
- errors += 1
- continue
-
queue.mark_failed(
TASK_DOCTYPE,
task,
- result.get("message") or "Unhandled sync error",
+ result.get("message") or status or "Unhandled sync error",
)
errors += 1
diff --git a/csf_tz/csf_tz/doctype/vehicle_sync_task/queue.py b/csf_tz/csf_tz/doctype/vehicle_sync_task/queue.py
index 07afd09b..9e940004 100644
--- a/csf_tz/csf_tz/doctype/vehicle_sync_task/queue.py
+++ b/csf_tz/csf_tz/doctype/vehicle_sync_task/queue.py
@@ -1,31 +1,20 @@
-import secrets
+import os
+import socket
import frappe
-# ------------ CONFIGURATION ------------
+# Identifies the process that claimed a task; stored in the Data field "claimed_by".
+WORKER_ID = f"{socket.gethostname()}:{os.getpid()}"
+
BATCH_SIZE = 1
-TIME_BUDGET_SEC = 50
-MAX_ATTEMPTS = 4
-BASE_BACKOFF = 300
-BACKOFF_JITTER = 0.2
-SUCCESS_INTERVAL_SECONDS = 60 * 60 * 2
+SUCCESS_INTERVAL_SECONDS = 60 * 60 * 24
MAX_CALLS_PER_MINUTE = 1
-# ------------ INTERNAL HELPERS ------------
def _now():
return frappe.utils.now_datetime()
-def _jitter(seconds):
- # Generate cryptographically secure random jitter for backoff timing
- # Range: -BACKOFF_JITTER to +BACKOFF_JITTER
- random_factor = (secrets.randbelow(10000) / 10000.0) * 2 - 1 # -1 to 1
- jitter_factor = 1 + (random_factor * BACKOFF_JITTER)
- return int(seconds * jitter_factor)
-
-
-# ------------ CORE QUEUE OPERATIONS ------------
def claim_batch(doctype, limit=BATCH_SIZE):
try:
now = _now()
@@ -37,13 +26,27 @@ def claim_batch(doctype, limit=BATCH_SIZE):
.where(
(Task.status == "Pending")
& ((Task.next_run_at.isnull()) | (Task.next_run_at <= now))
- & ((Task.is_deleted.isnull()) | (Task.is_deleted == 0)) # ← IGNORE DELETED TASKS
+ & ((Task.is_deleted.isnull()) | (Task.is_deleted == 0))
)
.orderby(Task.priority, order=frappe.qb.terms.Order.desc)
.orderby(Task.name)
.limit(limit)
).run(as_dict=True)
+ if not rows:
+ rows = (
+ frappe.qb.from_(Task)
+ .select(Task.name)
+ .where(
+ (Task.status == "Failed")
+ & (Task.next_run_at <= now)
+ & ((Task.is_deleted.isnull()) | (Task.is_deleted == 0))
+ )
+ .orderby(Task.priority, order=frappe.qb.terms.Order.desc)
+ .orderby(Task.name)
+ .limit(limit)
+ ).run(as_dict=True)
+
if not rows:
return []
@@ -54,7 +57,7 @@ def claim_batch(doctype, limit=BATCH_SIZE):
row["name"],
{
"status": "Processing",
- "claimed_by": frappe.local.site,
+ "claimed_by": WORKER_ID,
"claimed_at": now,
"last_run_at": now,
},
@@ -94,18 +97,17 @@ def mark_done(doctype, task):
def mark_failed(doctype, task, err_msg):
try:
- frappe.db.set_value(
- doctype,
- task["name"],
- {
- "status": "Failed",
- "last_error": err_msg[:1000],
- "last_run_at": _now(),
- "claimed_by": "",
- "claimed_at": None,
- "next_run_at": None,
- },
- )
+ values = {
+ "status": "Failed",
+ "attempts": 0,
+ "backoff_exp": 0,
+ "last_error": err_msg[:1000],
+ "last_run_at": _now(),
+ "claimed_by": "",
+ "claimed_at": None,
+ "next_run_at": _now(),
+ }
+ frappe.db.set_value(doctype, task["name"], values)
except Exception as e:
frappe.log_error(
title="Queue Mark Failed Error",
@@ -113,48 +115,6 @@ def mark_failed(doctype, task, err_msg):
)
-def bump_attempts(doctype, task):
- try:
- current = frappe.db.get_value(doctype, task["name"], ["attempts", "backoff_exp"], as_dict=True)
- attempts = (current.attempts or 0) + 1
- backoff_exp = min((current.backoff_exp or 0) + 1, 6)
- frappe.db.set_value(
- doctype, task["name"], {"attempts": attempts, "backoff_exp": backoff_exp, "last_run_at": _now()}
- )
- return attempts, backoff_exp
- except Exception as e:
- frappe.log_error(
- title="Queue Bump Attempts Failed",
- message=f"Error bumping attempts for task {task.get('name')} in {doctype}: {str(e)}",
- )
- return 1, 1 # Return default values
-
-
-def schedule_next(doctype, task, backoff_seconds, error_msg=""):
- try:
- attempts, _ = bump_attempts(doctype, task)
- if attempts >= MAX_ATTEMPTS:
- mark_failed(doctype, task, error_msg or "Max attempts exceeded")
- return
- next_run = frappe.utils.add_to_date(_now(), seconds=_jitter(backoff_seconds))
- frappe.db.set_value(
- doctype,
- task["name"],
- {
- "status": "Pending",
- "claimed_by": "",
- "claimed_at": None,
- "next_run_at": next_run,
- "last_error": error_msg[:500] if error_msg else "",
- },
- )
- except Exception as e:
- frappe.log_error(
- title="Queue Schedule Next Failed",
- message=f"Error scheduling next run for task {task.get('name')} in {doctype}: {str(e)}",
- )
-
-
def reset_stuck_tasks(doctype, timeout_minutes=10):
try:
timeout_time = frappe.utils.add_to_date(_now(), minutes=-timeout_minutes)
diff --git a/csf_tz/csf_tz/employee_advance.js b/csf_tz/csf_tz/employee_advance.js
index 62b7a4d4..42309b57 100644
--- a/csf_tz/csf_tz/employee_advance.js
+++ b/csf_tz/csf_tz/employee_advance.js
@@ -1,64 +1,68 @@
-frappe.ui.form.on('Employee Advance', {
- validate: function (frm) {
- checkAndValidateMaxUnclaimedEA(frm);
- }
+frappe.ui.form.on("Employee Advance", {
+ validate: function (frm) {
+ checkAndValidateMaxUnclaimedEA(frm);
+ },
});
function checkAndValidateMaxUnclaimedEA(frm) {
- frappe.call({
- method: 'frappe.client.get_value',
- args: {
- doctype: 'CSF TZ Settings',
- fieldname: ['track_unclaimed_employee_advances']
- },
- callback: function (settings_response) {
- if (settings_response && settings_response.message) {
- const trackUnclaimed = settings_response.message.track_unclaimed_employee_advances;
+ frappe.call({
+ method: "frappe.client.get_value",
+ args: {
+ doctype: "CSF TZ Settings",
+ fieldname: ["track_unclaimed_employee_advances"],
+ },
+ callback: function (settings_response) {
+ if (settings_response && settings_response.message) {
+ const trackUnclaimed = settings_response.message.track_unclaimed_employee_advances;
- if (trackUnclaimed == 1) {
- checkUnclaimedEAAndMaxLimit(frm);
- }
- }
- }
- });
+ if (trackUnclaimed == 1) {
+ checkUnclaimedEAAndMaxLimit(frm);
+ }
+ }
+ },
+ });
}
function checkUnclaimedEAAndMaxLimit(frm) {
- frappe.call({
- method: 'frappe.client.get_list',
- args: {
- doctype: 'Employee Advance',
- filters: {
- status: ['not in', ['Claimed', 'Cancelled']],
- employee: frm.doc.employee
- },
- fields: ['name']
- },
- callback: function (ea_response) {
- if (ea_response && ea_response.message) {
- let unclaimed_count = ea_response.message.length;
+ frappe.call({
+ method: "frappe.client.get_list",
+ args: {
+ doctype: "Employee Advance",
+ filters: {
+ status: ["not in", ["Claimed", "Cancelled"]],
+ employee: frm.doc.employee,
+ },
+ fields: ["name"],
+ },
+ callback: function (ea_response) {
+ if (ea_response && ea_response.message) {
+ let unclaimed_count = ea_response.message.length;
- frappe.call({
- method: 'frappe.client.get_value',
- args: {
- doctype: 'Company',
- fieldname: ['max_unclaimed_ea'],
- filters: {
- name: frm.doc.company,
- },
- },
- callback: function (company_response) {
- if (company_response && company_response.message) {
- let max_unclaimed_ea = company_response.message.max_unclaimed_ea;
+ frappe.call({
+ method: "frappe.client.get_value",
+ args: {
+ doctype: "Company",
+ fieldname: ["max_unclaimed_ea"],
+ filters: {
+ name: frm.doc.company,
+ },
+ },
+ callback: function (company_response) {
+ if (company_response && company_response.message) {
+ let max_unclaimed_ea = company_response.message.max_unclaimed_ea;
- if (unclaimed_count >= max_unclaimed_ea) {
- frappe.msgprint(__('The maximum number of unclaimed Employee Advances has been reached. Cannot create a new Employee Advance.'));
- frappe.validated = false;
- }
- }
- }
- });
- }
- }
- });
+ if (unclaimed_count >= max_unclaimed_ea) {
+ frappe.msgprint(
+ __(
+ "The maximum number of unclaimed Employee Advances has been reached. Cannot create a new Employee Advance."
+ )
+ );
+ frappe.validated = false;
+ }
+ }
+ },
+ });
+ }
+ },
+ });
}
diff --git a/csf_tz/csf_tz/employee_contact_qr.js b/csf_tz/csf_tz/employee_contact_qr.js
index 22848971..662374c6 100644
--- a/csf_tz/csf_tz/employee_contact_qr.js
+++ b/csf_tz/csf_tz/employee_contact_qr.js
@@ -1,27 +1,29 @@
-frappe.ui.form.on('Employee', {
- generate_contact_qr: function(frm) {
- frappe.call({
- method: 'csf_tz.csftz_hooks.employee_contact_qr.generate_contact_qr',
- args: {
- employee: frm.doc.name
- },
- callback: function(r) {
- if (r.message) {
- let d = new frappe.ui.Dialog({
- title: __('Employee Contact QR Code'),
- fields: [{
- label: 'QR Code',
- fieldtype: 'HTML',
- fieldname: 'qr_display',
- options: `
+frappe.ui.form.on("Employee", {
+ generate_contact_qr: function (frm) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.employee_contact_qr.generate_contact_qr",
+ args: {
+ employee: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ let d = new frappe.ui.Dialog({
+ title: __("Employee Contact QR Code"),
+ fields: [
+ {
+ label: "QR Code",
+ fieldtype: "HTML",
+ fieldname: "qr_display",
+ options: `
Scan this QR code to add contact
-
`
- }]
- });
- d.show();
- }
- }
- });
- }
+
`,
+ },
+ ],
+ });
+ d.show();
+ }
+ },
+ });
+ },
});
diff --git a/csf_tz/csf_tz/fees.js b/csf_tz/csf_tz/fees.js
index 7b9435d5..5fe212cb 100644
--- a/csf_tz/csf_tz/fees.js
+++ b/csf_tz/csf_tz/fees.js
@@ -1,26 +1,24 @@
-frappe.ui.form.on('Fees', {
- refresh: function (frm) {
- if (frm.doc.docstatus == 1 && frm.doc.outstanding_amount > 0) {
- frm.add_custom_button(__("Invoice Submission"), function () {
- frappe.call({
- method: 'csf_tz.bank_api.invoice_submission',
- args: {
- fees_name: frm.doc.name,
- },
- callback: function (r) {
- if (r.message) {
- console.log(r.message);
- }
- }
- });
- });
- };
- frm.set_query("sales_invoice_income_account", function () {
- return {
- filters: [
- ["Account", "company", "=", frm.doc.company]
- ]
- };
- });
- },
+frappe.ui.form.on("Fees", {
+ refresh: function (frm) {
+ if (frm.doc.docstatus == 1 && frm.doc.outstanding_amount > 0) {
+ frm.add_custom_button(__("Invoice Submission"), function () {
+ frappe.call({
+ method: "csf_tz.bank_api.invoice_submission",
+ args: {
+ fees_name: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ console.log(r.message);
+ }
+ },
+ });
+ });
+ }
+ frm.set_query("sales_invoice_income_account", function () {
+ return {
+ filters: [["Account", "company", "=", frm.doc.company]],
+ };
+ });
+ },
});
diff --git a/csf_tz/csf_tz/landed_cost_voucher.js b/csf_tz/csf_tz/landed_cost_voucher.js
index 72d65d98..85ab727b 100644
--- a/csf_tz/csf_tz/landed_cost_voucher.js
+++ b/csf_tz/csf_tz/landed_cost_voucher.js
@@ -1,33 +1,43 @@
frappe.ui.form.on("Landed Cost Voucher", {
- import_file: function (frm) {
- frm.clear_table("taxes");
- if (frm.doc.import_file) {
- frappe.call({
- method: 'csf_tz.csftz_hooks.landed_cost_voucher.get_landed_cost_expenses',
- args: {
- import_file: frm.doc.import_file,
- },
- async: false,
- callback: function (r) {
- if (r.message) {
- r.message.forEach(element => {
- var child = frm.add_child("taxes");
- frappe.model.set_value(child.doctype, child.name, "expense_account", element.expense_account);
- frappe.model.set_value(child.doctype, child.name, "description", element.description);
- frappe.model.set_value(child.doctype, child.name, "amount", element.amount);
- })
- }
- }
- });
- }
- frm.refresh_field("taxes");
- },
- validate: function(frm) {
- $.each(frm.doc.items, function(i, d) {
- var applicable_item = d.applicable_charges / d.qty;
- var price_item = applicable_item + (d.amount / d.qty);
- frappe.model.set_value(d.doctype, d.name, "applicable_charges_per_item", applicable_item);
- frappe.model.set_value(d.doctype, d.name, "price_per_item", price_item);
- });
- }
+ import_file: function (frm) {
+ frm.clear_table("taxes");
+ if (frm.doc.import_file) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.landed_cost_voucher.get_landed_cost_expenses",
+ args: {
+ import_file: frm.doc.import_file,
+ },
+ async: false,
+ callback: function (r) {
+ if (r.message) {
+ r.message.forEach((element) => {
+ var child = frm.add_child("taxes");
+ frappe.model.set_value(
+ child.doctype,
+ child.name,
+ "expense_account",
+ element.expense_account
+ );
+ frappe.model.set_value(
+ child.doctype,
+ child.name,
+ "description",
+ element.description
+ );
+ frappe.model.set_value(child.doctype, child.name, "amount", element.amount);
+ });
+ }
+ },
+ });
+ }
+ frm.refresh_field("taxes");
+ },
+ validate: function (frm) {
+ $.each(frm.doc.items, function (i, d) {
+ var applicable_item = d.applicable_charges / d.qty;
+ var price_item = applicable_item + d.amount / d.qty;
+ frappe.model.set_value(d.doctype, d.name, "applicable_charges_per_item", applicable_item);
+ frappe.model.set_value(d.doctype, d.name, "price_per_item", price_item);
+ });
+ },
});
diff --git a/csf_tz/csf_tz/material_request.js b/csf_tz/csf_tz/material_request.js
index e49d3dac..f1aafe93 100644
--- a/csf_tz/csf_tz/material_request.js
+++ b/csf_tz/csf_tz/material_request.js
@@ -1,34 +1,32 @@
-frappe.require([
- '/assets/csf_tz/js/shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Material Request", {
- refresh: (frm) => {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- },
+ refresh: (frm) => {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ },
});
-
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+q',
- action: () => {
- ctrlQ("Material Request Item");
- },
- page: this.page,
- description: __('Select Item Warehouse'),
- ignore_inputs: true,
+ shortcut: "ctrl+q",
+ action: () => {
+ ctrlQ("Material Request Item");
+ },
+ page: this.page,
+ description: __("Select Item Warehouse"),
+ ignore_inputs: true,
});
diff --git a/csf_tz/csf_tz/page/jobcards/jobcards.js b/csf_tz/csf_tz/page/jobcards/jobcards.js
index f980aa27..644cd10a 100644
--- a/csf_tz/csf_tz/page/jobcards/jobcards.js
+++ b/csf_tz/csf_tz/page/jobcards/jobcards.js
@@ -1,14 +1,19 @@
-frappe.pages['jobcards'].on_page_load = function (wrapper) {
+frappe.pages["jobcards"].on_page_load = function (wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
- title: 'Job Cards',
- single_column: true
+ title: "Job Cards",
+ single_column: true,
});
this.page.$JobCards = new frappe.JobCards.job_cards(this.page);
-
- $("head").append("
");
- $("head").append("
");
- $("head").append("
");
-}
+ $("head").append(
+ "
"
+ );
+ $("head").append(
+ "
"
+ );
+ $("head").append(
+ "
"
+ );
+};
diff --git a/csf_tz/csf_tz/page/scan_qrcode/scan_qrcode.js b/csf_tz/csf_tz/page/scan_qrcode/scan_qrcode.js
index 6ccfae99..7b084b5d 100644
--- a/csf_tz/csf_tz/page/scan_qrcode/scan_qrcode.js
+++ b/csf_tz/csf_tz/page/scan_qrcode/scan_qrcode.js
@@ -1,46 +1,46 @@
frappe.pages["scan-qrcode"].on_page_load = function (wrapper) {
- var page = frappe.ui.make_app_page({
- parent: wrapper,
- title: "Scan QRCode",
- single_column: true,
- });
- page.main.html(frappe.render_template("scan_qrcode", {}));
- setTimeout(function () {
- startScanner();
- }, 1000);
+ var page = frappe.ui.make_app_page({
+ parent: wrapper,
+ title: "Scan QRCode",
+ single_column: true,
+ });
+ page.main.html(frappe.render_template("scan_qrcode", {}));
+ setTimeout(function () {
+ startScanner();
+ }, 1000);
};
var lastResult,
- countResults = 0;
+ countResults = 0;
function startScanner() {
- var resultContainer = document.getElementById("qr-reader-results");
+ var resultContainer = document.getElementById("qr-reader-results");
- var html5QrcodeScanner = new Html5QrcodeScanner("qr-reader", {
- fps: 10,
- qrbox: 250,
- });
- html5QrcodeScanner.render(onScanSuccess);
+ var html5QrcodeScanner = new Html5QrcodeScanner("qr-reader", {
+ fps: 10,
+ qrbox: 250,
+ });
+ html5QrcodeScanner.render(onScanSuccess);
}
function onScanSuccess(decodedText, decodedResult) {
- if (decodedText !== lastResult) {
- ++countResults;
- lastResult = decodedText;
- // Handle on success condition with the decoded message.
- console.log(`Scan result ${decodedText}`, decodedResult);
- sendApiCall(decodedText);
- }
+ if (decodedText !== lastResult) {
+ ++countResults;
+ lastResult = decodedText;
+ // Handle on success condition with the decoded message.
+ console.log(`Scan result ${decodedText}`, decodedResult);
+ sendApiCall(decodedText);
+ }
}
function sendApiCall(decodedText) {
- frappe.call({
- method: "csf_tz.csf_tz.page.scan_qrcode.scan_qrcode.add_biometric_log",
- args: {
- data: decodedText,
- },
- callback: function (r) {
- console.log(r);
- },
- });
+ frappe.call({
+ method: "csf_tz.csf_tz.page.scan_qrcode.scan_qrcode.add_biometric_log",
+ args: {
+ data: decodedText,
+ },
+ callback: function (r) {
+ console.log(r);
+ },
+ });
}
diff --git a/csf_tz/csf_tz/payment_entry.js b/csf_tz/csf_tz/payment_entry.js
index fe180134..0384c9f0 100644
--- a/csf_tz/csf_tz/payment_entry.js
+++ b/csf_tz/csf_tz/payment_entry.js
@@ -1,373 +1,411 @@
-frappe.ui.form.on("Payment Entry", {
- onload: function (frm) {
- if (frm.is_new()) {
- frm.trigger("payment_type");
- }
- },
- refresh: function (frm) {
- frm.trigger("add_write_off_button");
- },
- payment_type: function (frm) {
- if (frm.is_new()) {
- if (frm.doc.payment_type == "Receive") {
- frm.set_value("naming_series", "RE-.YYYY.-");
- if (!["Student", "Donor"].includes(frm.doc.party_type)) {
- frm.set_value("party_type", "Customer");
- }
- }
- else if (frm.doc.payment_type == "Pay") {
- frm.set_value("naming_series", "PE-.YYYY.-");
- if (frm.doc.party_type != "Employee") {
- frm.set_value("party_type", "Supplier");
- }
- }
- else if (frm.doc.payment_type == "Internal Transfer") {
- frm.set_value("naming_series", "IT-.YYYY.-");
- frm.set_value("party_type", "");
- frm.set_value("party_name", "");
- }
- }
- frm.refresh_fields()
- },
-
- party: function (frm) {
- if (frm.is_new()) {
- // check if the feature is disabled in CSF TZ Settings
- frappe.db.get_single_value("CSF TZ Settings", "disable_get_outstanding_functionality")
- .then(disabled => {
- if (disabled) {
- // Feature is disabled, do not proceed with get_outstanding_documents
- return;
- }
-
- // Feature is enabled, proceed with existing functionality
- const today = frappe.datetime.get_today();
- const filters = {
- from_posting_date: frappe.datetime.add_days(today, -3650),
- to_posting_date: today,
- allocate_payment_amount: 1
- }
- if (["Customer", "Supplier"].includes(frm.doc.party_type) && frm.doc.paid_from_account_currency && frm.doc.paid_to_account_currency) {
- frm.events.get_outstanding_documents(frm, filters);
- }
- });
- }
- },
-
- get_outstanding_documents: function (frm, filters) {
- // first check if the feature s disabled in CSF TZ Settings
- return frappe.db.get_single_value("CSF TZ Settings", "disable_get_outstanding_functionality")
- .then(disabled => {
- if (disabled) {
- // Feature is disabled, do not proceed
- return;
- }
-
- // Continue with normal functionality
- if (typeof frappe.route_history[frappe.route_history.length - 2] != "undefined") {
- if (frappe.route_history[frappe.route_history.length - 2][1] in ["Sales Invoice", "Employee Advance", "Purchase Invoice"]) {
- return;
- }
- }
-
- frm.clear_table("references");
-
- if (!frm.doc.party) {
- return;
- }
-
- frm.events.check_mandatory_to_fetch(frm);
-
- // Ensure party account is set based on payment type
- var party_account = frm.doc.payment_type == "Receive" ? frm.doc.paid_from : frm.doc.paid_to;
- if (!party_account) {
- frappe.msgprint(__("Please set the appropriate account for the selected payment type."));
- return;
- }
-
- var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
-
- var args = {
- "posting_date": frm.doc.posting_date,
- "company": frm.doc.company,
- "party_type": frm.doc.party_type,
- "payment_type": frm.doc.payment_type,
- "party": frm.doc.party,
- "party_account": party_account,
- "cost_center": frm.doc.cost_center
- }
-
- for (let key in filters) {
- args[key] = filters[key];
- }
-
- frappe.flags.allocate_payment_amount = filters['allocate_payment_amount'];
-
-
- return frappe.call({
- method: 'csf_tz.csftz_hooks.payment_entry.get_outstanding_reference_documents',
- args: {
- args: args
- },
- callback: function (r, rt) {
- if (r.message) {
- var total_positive_outstanding = 0;
- var total_negative_outstanding = 0;
-
- $.each(r.message, function (i, d) {
- var c = frm.add_child("references");
- c.reference_doctype = d.voucher_type;
- c.reference_name = d.voucher_no;
- c.due_date = d.due_date;
- c.posting_date = d.posting_date;
- c.total_amount = d.invoice_amount;
- c.outstanding_amount = d.outstanding_amount;
- c.bill_no = d.bill_no;
-
- if (!in_list(["Sales Order", "Purchase Order", "Expense Claim", "Fees"], d.voucher_type)) {
- if (flt(d.outstanding_amount) > 0)
- total_positive_outstanding += flt(d.outstanding_amount);
- else
- total_negative_outstanding += Math.abs(flt(d.outstanding_amount));
- }
-
- var party_account_currency = frm.doc.payment_type == "Receive" ?
- frm.doc.paid_from_account_currency : frm.doc.paid_to_account_currency;
-
- if (party_account_currency != company_currency) {
- c.exchange_rate = d.exchange_rate;
- } else {
- c.exchange_rate = 1;
- }
- if (in_list(['Sales Invoice', 'Purchase Invoice', "Expense Claim", "Fees"], d.reference_doctype)) {
- c.due_date = d.due_date;
- }
- });
-
- if (
- (frm.doc.payment_type == "Receive" && frm.doc.party_type == "Customer") ||
- (frm.doc.payment_type == "Pay" && frm.doc.party_type == "Supplier") ||
- (frm.doc.payment_type == "Pay" && frm.doc.party_type == "Employee") ||
- (frm.doc.payment_type == "Receive" && frm.doc.party_type == "Student")
- ) {
- if (total_positive_outstanding > total_negative_outstanding)
- if (!frm.doc.paid_amount)
- frm.set_value("paid_amount",
- total_positive_outstanding - total_negative_outstanding);
- } else if (
- total_negative_outstanding &&
- total_positive_outstanding < total_negative_outstanding
- ) {
- if (!frm.doc.received_amount)
- frm.set_value("received_amount",
- total_negative_outstanding - total_positive_outstanding);
- }
- }
-
- const paid_amount = frm.doc.payment_type == "Receive" ? frm.doc.paid_amount : frm.doc.received_amount;
- if (paid_amount) {
- frm.events.allocate_party_amount_against_ref_docs(frm, paid_amount, true);
- }
-
- }
- });
- });
- },
- get_outstanding_so: function (frm) {
- const today = frappe.datetime.get_today();
- let fields = [
- { fieldtype: "Section Break", label: __("Posting Date") },
- {
- fieldtype: "Date",
- label: __("From Date"),
- fieldname: "from_posting_date",
- default: frappe.datetime.add_days(today, -30),
- },
- { fieldtype: "Column Break" },
- { fieldtype: "Date", label: __("To Date"), fieldname: "to_posting_date", default: today },
- { fieldtype: "Section Break", label: __("Due Date") },
- { fieldtype: "Date", label: __("From Date"), fieldname: "from_due_date" },
- { fieldtype: "Column Break" },
- { fieldtype: "Date", label: __("To Date"), fieldname: "to_due_date" },
- { fieldtype: "Section Break", label: __("Outstanding Amount") },
- {
- fieldtype: "Float",
- label: __("Greater Than Amount"),
- fieldname: "outstanding_amt_greater_than",
- default: 0,
- },
- { fieldtype: "Column Break" },
- { fieldtype: "Float", label: __("Less Than Amount"), fieldname: "outstanding_amt_less_than" },
- {
- fieldtype: "Check",
- label: __("Allocate Payment Amount"),
- fieldname: "allocate_payment_amount",
- default: 1
- }
- ];
-
- frappe.prompt(
- fields,
- function (filters) {
- frm.clear_table("references");
-
- if (!frm.doc.party) {
- frappe.throw(__("Please select a Party first"));
- return;
- }
-
- frm.events.check_mandatory_to_fetch(frm);
-
- // Ensure party account is set based on payment type
- var party_account = frm.doc.payment_type == "Receive" ? frm.doc.paid_from : frm.doc.paid_to;
- if (!party_account) {
- frappe.msgprint(__("Please set the appropriate account for the selected payment type."));
- return;
- }
-
- frappe.flags.allocate_payment_amount = filters.allocate_payment_amount;
-
- var args = {
- "posting_date": frm.doc.posting_date,
- "company": frm.doc.company,
- "party_type": frm.doc.party_type,
- "payment_type": frm.doc.payment_type,
- "party": frm.doc.party,
- "party_account": party_account,
- "cost_center": frm.doc.cost_center,
- "from_posting_date": filters.from_posting_date,
- "to_posting_date": filters.to_posting_date,
- "from_due_date": filters.from_due_date,
- "to_due_date": filters.to_due_date,
- "outstanding_amt_greater_than": filters.outstanding_amt_greater_than,
- "outstanding_amt_less_than": filters.outstanding_amt_less_than,
- "allocate_payment_amount": filters.allocate_payment_amount
- };
-
- return frappe.call({
- method: 'csf_tz.csftz_hooks.payment_entry.get_outstanding_sales_orders',
- args: {
- args: args
- },
- callback: function (r, rt) {
- if (r.message) {
- var total_positive_outstanding = 0;
-
- $.each(r.message, function (i, d) {
- var c = frm.add_child("references");
- c.reference_doctype = d.voucher_type;
- c.reference_name = d.voucher_no;
- c.due_date = d.due_date;
- c.posting_date = d.posting_date;
- c.total_amount = d.invoice_amount;
- c.outstanding_amount = d.outstanding_amount;
-
- // Add to total outstanding
- total_positive_outstanding += flt(d.outstanding_amount);
-
- var party_account_currency = frm.doc.payment_type == "Receive" ?
- frm.doc.paid_from_account_currency : frm.doc.paid_to_account_currency;
-
- var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
-
- if (party_account_currency != company_currency) {
- c.exchange_rate = d.exchange_rate;
- } else {
- c.exchange_rate = 1;
- }
- });
-
- // Set paid amount based on outstanding sales orders
- if (total_positive_outstanding > 0 && frappe.flags.allocate_payment_amount) {
- if (frm.doc.payment_type == "Receive" && !frm.doc.paid_amount) {
- frm.set_value("paid_amount", total_positive_outstanding);
- } else if (frm.doc.payment_type == "Pay" && !frm.doc.received_amount) {
- frm.set_value("received_amount", total_positive_outstanding);
- }
- }
-
- frm.refresh_fields();
-
- const paid_amount = frm.doc.payment_type == "Receive" ? frm.doc.paid_amount : frm.doc.received_amount;
- if (paid_amount && frappe.flags.allocate_payment_amount) {
- frm.events.allocate_party_amount_against_ref_docs(frm, paid_amount, true);
- }
- }
- }
- });
- },
- __("Filters"),
- __("Get Sales Orders")
- );
- },
-
- // Write-off Journal Entry Feature
- add_write_off_button: function (frm) {
- // Check if feature is enabled and conditions are met
- frappe.db
- .get_single_value("CSF TZ Settings", "enable_write_off_jv_pe")
- .then((enable_write_off) => {
- if (enable_write_off &&
- frm.doc.docstatus === 1 &&
- frm.doc.unallocated_amount > 0) {
-
- frm.add_custom_button(__("Write Off Outstanding"), function () {
- // Fetch the write-off account from Company before showing the dialog
- frappe.db.get_value("Company", frm.doc.company, "write_off_account").then(function(r) {
- let write_off_account = r.message ? r.message.write_off_account : null;
-
- // Show dialog to select write-off account
- let dialog = new frappe.ui.Dialog({
- title: __("Write Off Unallocated Amount"),
- fields: [
- {
- fieldname: "write_off_account",
- label: __("Write Off Account"),
- fieldtype: "Link",
- options: "Account",
- "default": write_off_account,
- reqd: 1,
- get_query: function() {
- return {
- filters: {
- "report_type": "Balance Sheet",
- "is_group": 0,
- "company": frm.doc.company
- }
- };
- }
- },
- {
- fieldname: "unallocated_amount",
- label: __("Unallocated Amount"),
- fieldtype: "Currency",
- default: frm.doc.unallocated_amount,
- read_only: 1
- }
- ],
- primary_action_label: __("Create Write Off Entry"),
- primary_action: function(values) {
- frappe.call({
- method: "csf_tz.custom_api.create_write_off_jv_pe",
- args: {
- payment_entry: frm.doc.name,
- account: values.write_off_account
- },
- callback: function(r) {
- if (r.message) {
- const journal_entry_link = `
${frappe.utils.escape_html(r.message)}`;
- frappe.msgprint(__("Write-off Journal Entry created: {0}", [journal_entry_link]));
- frm.reload_doc();
- }
- }
- });
- dialog.hide();
- }
- });
- dialog.show();
- });
- }, __("Create"));
- }
- });
- }
-});
+frappe.ui.form.on("Payment Entry", {
+ onload: function (frm) {
+ if (frm.is_new()) {
+ frm.trigger("payment_type");
+ }
+ },
+ refresh: function (frm) {
+ frm.trigger("add_write_off_button");
+ },
+ payment_type: function (frm) {
+ if (frm.is_new()) {
+ if (frm.doc.payment_type == "Receive") {
+ frm.set_value("naming_series", "RE-.YYYY.-");
+ if (!["Student", "Donor"].includes(frm.doc.party_type)) {
+ frm.set_value("party_type", "Customer");
+ }
+ } else if (frm.doc.payment_type == "Pay") {
+ frm.set_value("naming_series", "PE-.YYYY.-");
+ if (frm.doc.party_type != "Employee") {
+ frm.set_value("party_type", "Supplier");
+ }
+ } else if (frm.doc.payment_type == "Internal Transfer") {
+ frm.set_value("naming_series", "IT-.YYYY.-");
+ frm.set_value("party_type", "");
+ frm.set_value("party_name", "");
+ }
+ }
+ frm.refresh_fields();
+ },
+
+ party: function (frm) {
+ if (frm.is_new()) {
+ // check if the feature is disabled in CSF TZ Settings
+ frappe.db
+ .get_single_value("CSF TZ Settings", "disable_get_outstanding_functionality")
+ .then((disabled) => {
+ if (disabled) {
+ // Feature is disabled, do not proceed with get_outstanding_documents
+ return;
+ }
+
+ // Feature is enabled, proceed with existing functionality
+ const today = frappe.datetime.get_today();
+ const filters = {
+ from_posting_date: frappe.datetime.add_days(today, -3650),
+ to_posting_date: today,
+ allocate_payment_amount: 1,
+ };
+ if (
+ ["Customer", "Supplier"].includes(frm.doc.party_type) &&
+ frm.doc.paid_from_account_currency &&
+ frm.doc.paid_to_account_currency
+ ) {
+ frm.events.get_outstanding_documents(frm, filters);
+ }
+ });
+ }
+ },
+
+ get_outstanding_documents: function (frm, filters) {
+ // first check if the feature s disabled in CSF TZ Settings
+ return frappe.db
+ .get_single_value("CSF TZ Settings", "disable_get_outstanding_functionality")
+ .then((disabled) => {
+ if (disabled) {
+ // Feature is disabled, do not proceed
+ return;
+ }
+
+ // Continue with normal functionality
+ if (typeof frappe.route_history[frappe.route_history.length - 2] != "undefined") {
+ if (
+ frappe.route_history[frappe.route_history.length - 2][1] in
+ ["Sales Invoice", "Employee Advance", "Purchase Invoice"]
+ ) {
+ return;
+ }
+ }
+
+ frm.clear_table("references");
+
+ if (!frm.doc.party) {
+ return;
+ }
+
+ frm.events.check_mandatory_to_fetch(frm);
+
+ // Ensure party account is set based on payment type
+ var party_account = frm.doc.payment_type == "Receive" ? frm.doc.paid_from : frm.doc.paid_to;
+ if (!party_account) {
+ frappe.msgprint(__("Please set the appropriate account for the selected payment type."));
+ return;
+ }
+
+ var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
+
+ var args = {
+ posting_date: frm.doc.posting_date,
+ company: frm.doc.company,
+ party_type: frm.doc.party_type,
+ payment_type: frm.doc.payment_type,
+ party: frm.doc.party,
+ party_account: party_account,
+ cost_center: frm.doc.cost_center,
+ };
+
+ for (let key in filters) {
+ args[key] = filters[key];
+ }
+
+ frappe.flags.allocate_payment_amount = filters["allocate_payment_amount"];
+
+ return frappe.call({
+ method: "csf_tz.csftz_hooks.payment_entry.get_outstanding_reference_documents",
+ args: {
+ args: args,
+ },
+ callback: function (r, rt) {
+ if (r.message) {
+ var total_positive_outstanding = 0;
+ var total_negative_outstanding = 0;
+
+ $.each(r.message, function (i, d) {
+ var c = frm.add_child("references");
+ c.reference_doctype = d.voucher_type;
+ c.reference_name = d.voucher_no;
+ c.due_date = d.due_date;
+ c.posting_date = d.posting_date;
+ c.total_amount = d.invoice_amount;
+ c.outstanding_amount = d.outstanding_amount;
+ c.bill_no = d.bill_no;
+
+ if (
+ !in_list(
+ ["Sales Order", "Purchase Order", "Expense Claim", "Fees"],
+ d.voucher_type
+ )
+ ) {
+ if (flt(d.outstanding_amount) > 0)
+ total_positive_outstanding += flt(d.outstanding_amount);
+ else total_negative_outstanding += Math.abs(flt(d.outstanding_amount));
+ }
+
+ var party_account_currency =
+ frm.doc.payment_type == "Receive"
+ ? frm.doc.paid_from_account_currency
+ : frm.doc.paid_to_account_currency;
+
+ if (party_account_currency != company_currency) {
+ c.exchange_rate = d.exchange_rate;
+ } else {
+ c.exchange_rate = 1;
+ }
+ if (
+ in_list(
+ ["Sales Invoice", "Purchase Invoice", "Expense Claim", "Fees"],
+ d.reference_doctype
+ )
+ ) {
+ c.due_date = d.due_date;
+ }
+ });
+
+ if (
+ (frm.doc.payment_type == "Receive" && frm.doc.party_type == "Customer") ||
+ (frm.doc.payment_type == "Pay" && frm.doc.party_type == "Supplier") ||
+ (frm.doc.payment_type == "Pay" && frm.doc.party_type == "Employee") ||
+ (frm.doc.payment_type == "Receive" && frm.doc.party_type == "Student")
+ ) {
+ if (total_positive_outstanding > total_negative_outstanding)
+ if (!frm.doc.paid_amount)
+ frm.set_value(
+ "paid_amount",
+ total_positive_outstanding - total_negative_outstanding
+ );
+ } else if (
+ total_negative_outstanding &&
+ total_positive_outstanding < total_negative_outstanding
+ ) {
+ if (!frm.doc.received_amount)
+ frm.set_value(
+ "received_amount",
+ total_negative_outstanding - total_positive_outstanding
+ );
+ }
+ }
+
+ const paid_amount =
+ frm.doc.payment_type == "Receive" ? frm.doc.paid_amount : frm.doc.received_amount;
+ if (paid_amount) {
+ frm.events.allocate_party_amount_against_ref_docs(frm, paid_amount, true);
+ }
+ },
+ });
+ });
+ },
+ get_outstanding_so: function (frm) {
+ const today = frappe.datetime.get_today();
+ let fields = [
+ { fieldtype: "Section Break", label: __("Posting Date") },
+ {
+ fieldtype: "Date",
+ label: __("From Date"),
+ fieldname: "from_posting_date",
+ default: frappe.datetime.add_days(today, -30),
+ },
+ { fieldtype: "Column Break" },
+ { fieldtype: "Date", label: __("To Date"), fieldname: "to_posting_date", default: today },
+ { fieldtype: "Section Break", label: __("Due Date") },
+ { fieldtype: "Date", label: __("From Date"), fieldname: "from_due_date" },
+ { fieldtype: "Column Break" },
+ { fieldtype: "Date", label: __("To Date"), fieldname: "to_due_date" },
+ { fieldtype: "Section Break", label: __("Outstanding Amount") },
+ {
+ fieldtype: "Float",
+ label: __("Greater Than Amount"),
+ fieldname: "outstanding_amt_greater_than",
+ default: 0,
+ },
+ { fieldtype: "Column Break" },
+ { fieldtype: "Float", label: __("Less Than Amount"), fieldname: "outstanding_amt_less_than" },
+ {
+ fieldtype: "Check",
+ label: __("Allocate Payment Amount"),
+ fieldname: "allocate_payment_amount",
+ default: 1,
+ },
+ ];
+
+ frappe.prompt(
+ fields,
+ function (filters) {
+ frm.clear_table("references");
+
+ if (!frm.doc.party) {
+ frappe.throw(__("Please select a Party first"));
+ return;
+ }
+
+ frm.events.check_mandatory_to_fetch(frm);
+
+ // Ensure party account is set based on payment type
+ var party_account = frm.doc.payment_type == "Receive" ? frm.doc.paid_from : frm.doc.paid_to;
+ if (!party_account) {
+ frappe.msgprint(__("Please set the appropriate account for the selected payment type."));
+ return;
+ }
+
+ frappe.flags.allocate_payment_amount = filters.allocate_payment_amount;
+
+ var args = {
+ posting_date: frm.doc.posting_date,
+ company: frm.doc.company,
+ party_type: frm.doc.party_type,
+ payment_type: frm.doc.payment_type,
+ party: frm.doc.party,
+ party_account: party_account,
+ cost_center: frm.doc.cost_center,
+ from_posting_date: filters.from_posting_date,
+ to_posting_date: filters.to_posting_date,
+ from_due_date: filters.from_due_date,
+ to_due_date: filters.to_due_date,
+ outstanding_amt_greater_than: filters.outstanding_amt_greater_than,
+ outstanding_amt_less_than: filters.outstanding_amt_less_than,
+ allocate_payment_amount: filters.allocate_payment_amount,
+ };
+
+ return frappe.call({
+ method: "csf_tz.csftz_hooks.payment_entry.get_outstanding_sales_orders",
+ args: {
+ args: args,
+ },
+ callback: function (r, rt) {
+ if (r.message) {
+ var total_positive_outstanding = 0;
+
+ $.each(r.message, function (i, d) {
+ var c = frm.add_child("references");
+ c.reference_doctype = d.voucher_type;
+ c.reference_name = d.voucher_no;
+ c.due_date = d.due_date;
+ c.posting_date = d.posting_date;
+ c.total_amount = d.invoice_amount;
+ c.outstanding_amount = d.outstanding_amount;
+
+ // Add to total outstanding
+ total_positive_outstanding += flt(d.outstanding_amount);
+
+ var party_account_currency =
+ frm.doc.payment_type == "Receive"
+ ? frm.doc.paid_from_account_currency
+ : frm.doc.paid_to_account_currency;
+
+ var company_currency = frappe.get_doc(
+ ":Company",
+ frm.doc.company
+ ).default_currency;
+
+ if (party_account_currency != company_currency) {
+ c.exchange_rate = d.exchange_rate;
+ } else {
+ c.exchange_rate = 1;
+ }
+ });
+
+ // Set paid amount based on outstanding sales orders
+ if (total_positive_outstanding > 0 && frappe.flags.allocate_payment_amount) {
+ if (frm.doc.payment_type == "Receive" && !frm.doc.paid_amount) {
+ frm.set_value("paid_amount", total_positive_outstanding);
+ } else if (frm.doc.payment_type == "Pay" && !frm.doc.received_amount) {
+ frm.set_value("received_amount", total_positive_outstanding);
+ }
+ }
+
+ frm.refresh_fields();
+
+ const paid_amount =
+ frm.doc.payment_type == "Receive"
+ ? frm.doc.paid_amount
+ : frm.doc.received_amount;
+ if (paid_amount && frappe.flags.allocate_payment_amount) {
+ frm.events.allocate_party_amount_against_ref_docs(frm, paid_amount, true);
+ }
+ }
+ },
+ });
+ },
+ __("Filters"),
+ __("Get Sales Orders")
+ );
+ },
+
+ // Write-off Journal Entry Feature
+ add_write_off_button: function (frm) {
+ // Check if feature is enabled and conditions are met
+ frappe.db.get_single_value("CSF TZ Settings", "enable_write_off_jv_pe").then((enable_write_off) => {
+ if (enable_write_off && frm.doc.docstatus === 1 && frm.doc.unallocated_amount > 0) {
+ frm.add_custom_button(
+ __("Write Off Outstanding"),
+ function () {
+ // Fetch the write-off account from Company before showing the dialog
+ frappe.db
+ .get_value("Company", frm.doc.company, "write_off_account")
+ .then(function (r) {
+ let write_off_account = r.message ? r.message.write_off_account : null;
+
+ // Show dialog to select write-off account
+ let dialog = new frappe.ui.Dialog({
+ title: __("Write Off Unallocated Amount"),
+ fields: [
+ {
+ fieldname: "write_off_account",
+ label: __("Write Off Account"),
+ fieldtype: "Link",
+ options: "Account",
+ default: write_off_account,
+ reqd: 1,
+ get_query: function () {
+ return {
+ filters: {
+ report_type: "Balance Sheet",
+ is_group: 0,
+ company: frm.doc.company,
+ },
+ };
+ },
+ },
+ {
+ fieldname: "unallocated_amount",
+ label: __("Unallocated Amount"),
+ fieldtype: "Currency",
+ default: frm.doc.unallocated_amount,
+ read_only: 1,
+ },
+ ],
+ primary_action_label: __("Create Write Off Entry"),
+ primary_action: function (values) {
+ frappe.call({
+ method: "csf_tz.custom_api.create_write_off_jv_pe",
+ args: {
+ payment_entry: frm.doc.name,
+ account: values.write_off_account,
+ },
+ callback: function (r) {
+ if (r.message) {
+ const journal_entry_link = `
${frappe.utils.escape_html(
+ r.message
+ )}`;
+ frappe.msgprint(
+ __("Write-off Journal Entry created: {0}", [
+ journal_entry_link,
+ ])
+ );
+ frm.reload_doc();
+ }
+ },
+ });
+ dialog.hide();
+ },
+ });
+ dialog.show();
+ });
+ },
+ __("Create")
+ );
+ }
+ });
+ },
+});
diff --git a/csf_tz/csf_tz/payment_entry_list.js b/csf_tz/csf_tz/payment_entry_list.js
index c43954fc..902a7ae0 100644
--- a/csf_tz/csf_tz/payment_entry_list.js
+++ b/csf_tz/csf_tz/payment_entry_list.js
@@ -5,32 +5,27 @@ frappe.listview_settings["Payment Entry"] = {
if (!enabled) {
return;
}
- listview.page.add_actions_menu_item(
- __("Generate KCB Payments Initiation"),
- function () {
- const selected = listview.get_checked_items();
- if (!selected.length) {
- frappe.msgprint(__("Please select at least one Payment Entry."));
- return;
- }
- const eligible = selected.filter(
- (row) => row.docstatus === 1 && row.payment_type === "Pay"
- );
- if (!eligible.length) {
- frappe.msgprint(__("Select submitted Pay type Payment Entries only."));
- return;
- }
- frappe.call({
- method: "csf_tz.kcb.payments.make_kcb_payments_initiation_from_payment_entries",
- args: { payment_entries: eligible.map((row) => row.name) },
- callback: function (r) {
- if (r.message) {
- frappe.set_route("Form", "KCB Payments Initiation", r.message);
- }
- },
- });
+ listview.page.add_actions_menu_item(__("Generate KCB Payments Initiation"), function () {
+ const selected = listview.get_checked_items();
+ if (!selected.length) {
+ frappe.msgprint(__("Please select at least one Payment Entry."));
+ return;
}
- );
+ const eligible = selected.filter((row) => row.docstatus === 1 && row.payment_type === "Pay");
+ if (!eligible.length) {
+ frappe.msgprint(__("Select submitted Pay type Payment Entries only."));
+ return;
+ }
+ frappe.call({
+ method: "csf_tz.kcb.payments.make_kcb_payments_initiation_from_payment_entries",
+ args: { payment_entries: eligible.map((row) => row.name) },
+ callback: function (r) {
+ if (r.message) {
+ frappe.set_route("Form", "KCB Payments Initiation", r.message);
+ }
+ },
+ });
+ });
});
},
};
diff --git a/csf_tz/csf_tz/payroll_entry.js b/csf_tz/csf_tz/payroll_entry.js
index 7b0949ad..521db8e2 100644
--- a/csf_tz/csf_tz/payroll_entry.js
+++ b/csf_tz/csf_tz/payroll_entry.js
@@ -1,149 +1,162 @@
frappe.ui.form.on("Payroll Entry", {
- setup: function(frm) {
- frm.trigger("control_action_buttons");
+ setup: function (frm) {
+ frm.trigger("control_action_buttons");
+ },
+ refresh: function (frm) {
+ frm.trigger("control_action_buttons");
- },
- refresh:function(frm) {
- frm.trigger("control_action_buttons");
-
- if (frm.doc.docstatus === 1) {
- frm.add_custom_button(__('Opening Salary Register'), function () {
- // Redirect with filter
+ if (frm.doc.docstatus === 1) {
+ frm.add_custom_button(__("Opening Salary Register"), function () {
+ // Redirect with filter
const report_name = "Salary Register";
- let report_url = `/app/query-report/${encodeURIComponent(report_name)}?from_date=${encodeURIComponent(frm.doc.start_date)}&to_date=${encodeURIComponent(frm.doc.end_date)}${frm.doc.company ? `&company=${encodeURIComponent(frm.doc.company)}` : ""}&payroll_entry=${encodeURIComponent(frm.doc.name)}`;
+ let report_url = `/app/query-report/${encodeURIComponent(
+ report_name
+ )}?from_date=${encodeURIComponent(frm.doc.start_date)}&to_date=${encodeURIComponent(
+ frm.doc.end_date
+ )}${
+ frm.doc.company ? `&company=${encodeURIComponent(frm.doc.company)}` : ""
+ }&payroll_entry=${encodeURIComponent(frm.doc.name)}`;
window.open(report_url, "_blank");
- }).addClass('btn-primary');
- }
+ }).addClass("btn-primary");
+ }
- frappe.call({
- method: 'csf_tz.csftz_hooks.payroll.get_amounts_summary',
- args: {
- payroll_entry: frm.doc.name
- },
- callback: function (r) {
- if (r.message) {
- const summary = r.message;
- const rows = [];
- const formatCurrency = value => frappe.format(value || 0, { fieldtype: 'Currency' });
- const escapeHtml = value => {
- const stringValue = value || '';
- if (frappe.utils && typeof frappe.utils.escape_html === 'function') {
- return frappe.utils.escape_html(stringValue);
- }
- const element = document.createElement('div');
- element.textContent = stringValue;
- return element.innerHTML;
- };
+ frappe.call({
+ method: "csf_tz.csftz_hooks.payroll.get_amounts_summary",
+ args: {
+ payroll_entry: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ const summary = r.message;
+ const rows = [];
+ const formatCurrency = (value) => frappe.format(value || 0, { fieldtype: "Currency" });
+ const escapeHtml = (value) => {
+ const stringValue = value || "";
+ if (frappe.utils && typeof frappe.utils.escape_html === "function") {
+ return frappe.utils.escape_html(stringValue);
+ }
+ const element = document.createElement("div");
+ element.textContent = stringValue;
+ return element.innerHTML;
+ };
- rows.push(`
| Total Gross Pay | ${formatCurrency(summary.gross_pay)} |
`);
- rows.push(`
| Total Net Pay | ${formatCurrency(summary.net_pay)} |
`);
+ rows.push(
+ `
| Total Gross Pay | ${formatCurrency(
+ summary.gross_pay
+ )} |
`
+ );
+ rows.push(
+ `
| Total Net Pay | ${formatCurrency(summary.net_pay)} |
`
+ );
- if (Array.isArray(summary.components)) {
- summary.components.forEach(item => {
- const label = escapeHtml(item.label || item.component);
- rows.push(`
| ${label} | ${formatCurrency(item.amount)} |
`);
- });
- }
+ if (Array.isArray(summary.components)) {
+ summary.components.forEach((item) => {
+ const label = escapeHtml(item.label || item.component);
+ rows.push(
+ `
| ${label} | ${formatCurrency(item.amount)} |
`
+ );
+ });
+ }
- const html = `
+ const html = `
Amounts Summary
- ${rows.join('')}
+ ${rows.join("")}
`;
- frm.fields_dict.custom_dashboard && frm.fields_dict.custom_dashboard.$wrapper.html(html);
- }
- }
- });
- },
- onload: (frm) => {
- frm.trigger("control_action_buttons");
- },
- workflow_state: (frm) => {
- if (frm.doc.has_payroll_approval == 1) {
- frm.refresh();
- }
- },
- create_update_slips_btn: function (frm) {
- if (frm.doc.docstatus != 1) {
- return
- }
- frm.add_custom_button(__("Update Salary Slips"), function() {
- frappe.call({
- method: 'csf_tz.csftz_hooks.payroll.update_slips',
- args: {
- payroll_entry: frm.doc.name,
- },
- callback: function(r) {
- if (r.message) {
- console.log(r.message);
- }
- }
- });
- });
- },
- create_print_btn: function (frm) {
- if (frm.doc.docstatus != 1) {
- return
- }
- frm.add_custom_button(__("Print Salary Slips"), function() {
- frappe.call({
- method: 'csf_tz.csftz_hooks.payroll.print_slips',
- args: {
- payroll_entry: frm.doc.name,
- },
- // callback: function(r) {
- // if (r.message) {
- // frm.reload_doc();
- // }
- // }
- });
- });
- },
- create_journal_entry_btn: function (frm) {
- if (frm.doc.docstatus != 1 || frm.doc.salary_slips_submitted == 1) {
- return;
- }
- frm.add_custom_button(__("Create Journal Entry"), function () {
- frappe.call({
- method: 'csf_tz.csftz_hooks.payroll.create_journal_entry',
- args: {
- payroll_entry: frm.doc.name,
- },
- // callback: function(r) {
- // if (r.message) {
- // frm.reload_doc();
- // }
- // }
- });
- });
- },
+ frm.fields_dict.custom_dashboard && frm.fields_dict.custom_dashboard.$wrapper.html(html);
+ }
+ },
+ });
+ },
+ onload: (frm) => {
+ frm.trigger("control_action_buttons");
+ },
+ workflow_state: (frm) => {
+ if (frm.doc.has_payroll_approval == 1) {
+ frm.refresh();
+ }
+ },
+ create_update_slips_btn: function (frm) {
+ if (frm.doc.docstatus != 1) {
+ return;
+ }
+ frm.add_custom_button(__("Update Salary Slips"), function () {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.payroll.update_slips",
+ args: {
+ payroll_entry: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ console.log(r.message);
+ }
+ },
+ });
+ });
+ },
+ create_print_btn: function (frm) {
+ if (frm.doc.docstatus != 1) {
+ return;
+ }
+ frm.add_custom_button(__("Print Salary Slips"), function () {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.payroll.print_slips",
+ args: {
+ payroll_entry: frm.doc.name,
+ },
+ // callback: function(r) {
+ // if (r.message) {
+ // frm.reload_doc();
+ // }
+ // }
+ });
+ });
+ },
+ create_journal_entry_btn: function (frm) {
+ if (frm.doc.docstatus != 1 || frm.doc.salary_slips_submitted == 1) {
+ return;
+ }
+ frm.add_custom_button(__("Create Journal Entry"), function () {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.payroll.create_journal_entry",
+ args: {
+ payroll_entry: frm.doc.name,
+ },
+ // callback: function(r) {
+ // if (r.message) {
+ // frm.reload_doc();
+ // }
+ // }
+ });
+ });
+ },
- control_action_buttons: (frm) => {
- if (frm.doc.docstatus == 1 && frm.doc.has_payroll_approval == 1) {
- if (frm.doc.workflow_state == "Salary Slips Created") {
- frm.trigger("create_update_slips_btn");
- $('[data-label="Submit%20Salary%20Slip"]').hide();
- } else if (
- frm.doc.workflow_state == "Approval Requested" ||
- frm.doc.workflow_state == "Change Requested" ||
- frm.doc.workflow_state.includes("Reviewed")
- ) {
- frm.clear_custom_buttons();
- frm.set_intro("");
- frm.set_intro(__("This Payroll Entry is under approval."));
- } else if (frm.doc.workflow_state.includes("Approved")) {
- frm.trigger("create_print_btn");
- frm.trigger("create_journal_entry_btn");
- }
- } else {
- frm.trigger("create_update_slips_btn");
- frm.trigger("create_print_btn");
- frm.trigger("create_journal_entry_btn");
- }
- },
+ control_action_buttons: (frm) => {
+ if (frm.doc.docstatus == 1 && frm.doc.has_payroll_approval == 1) {
+ if (frm.doc.workflow_state == "Salary Slips Created") {
+ frm.trigger("create_update_slips_btn");
+ $('[data-label="Submit%20Salary%20Slip"]').hide();
+ } else if (
+ frm.doc.workflow_state == "Approval Requested" ||
+ frm.doc.workflow_state == "Change Requested" ||
+ frm.doc.workflow_state.includes("Reviewed")
+ ) {
+ frm.clear_custom_buttons();
+ frm.set_intro("");
+ frm.set_intro(__("This Payroll Entry is under approval."));
+ } else if (frm.doc.workflow_state.includes("Approved")) {
+ frm.trigger("create_print_btn");
+ frm.trigger("create_journal_entry_btn");
+ }
+ } else {
+ frm.trigger("create_update_slips_btn");
+ frm.trigger("create_print_btn");
+ frm.trigger("create_journal_entry_btn");
+ }
+ },
});
diff --git a/csf_tz/csf_tz/program_enrollment.js b/csf_tz/csf_tz/program_enrollment.js
index caa0883d..8ee66864 100644
--- a/csf_tz/csf_tz/program_enrollment.js
+++ b/csf_tz/csf_tz/program_enrollment.js
@@ -1,34 +1,34 @@
frappe.ui.form.on("Program Enrollment", {
- program: function (frm) {
- frm.set_value("fees", "");
- frm.events.get_courses(frm);
- if (frm.doc.program) {
- frappe.call({
- method: "csf_tz.csftz_hooks.program_enrollment.get_fee_schedule",
- args: {
- "program": frm.doc.program,
- "student_category": frm.doc.student_category,
- "academic_year": frm.doc.academic_year,
- "academic_term": frm.doc.academic_term
- },
- async: false,
- callback: function (r) {
- if (r.message) {
- frm.set_value("fees", r.message);
- frm.events.get_courses(frm);
- }
- }
- });
- }
- },
+ program: function (frm) {
+ frm.set_value("fees", "");
+ frm.events.get_courses(frm);
+ if (frm.doc.program) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.program_enrollment.get_fee_schedule",
+ args: {
+ program: frm.doc.program,
+ student_category: frm.doc.student_category,
+ academic_year: frm.doc.academic_year,
+ academic_term: frm.doc.academic_term,
+ },
+ async: false,
+ callback: function (r) {
+ if (r.message) {
+ frm.set_value("fees", r.message);
+ frm.events.get_courses(frm);
+ }
+ },
+ });
+ }
+ },
- student_category: function () {
- frappe.ui.form.trigger("program");
- },
+ student_category: function () {
+ frappe.ui.form.trigger("program");
+ },
- validate: function (frm) {
- if (( !frm.doc.fees || !frm.doc.fees.length) && frm.doc.student_category) {
- frm.trigger("program");
- }
- }
+ validate: function (frm) {
+ if ((!frm.doc.fees || !frm.doc.fees.length) && frm.doc.student_category) {
+ frm.trigger("program");
+ }
+ },
});
diff --git a/csf_tz/csf_tz/program_enrollment_tool.js b/csf_tz/csf_tz/program_enrollment_tool.js
index f7da49d7..6db444d4 100644
--- a/csf_tz/csf_tz/program_enrollment_tool.js
+++ b/csf_tz/csf_tz/program_enrollment_tool.js
@@ -1,38 +1,37 @@
frappe.ui.form.on("Program Enrollment Tool", {
- refresh: function (frm) {
- frm.toggle_display(['enroll_students']);
- },
- academic_year: function (frm) {
- frm.toggle_display("enroll_students", is_viewable);
- },
- get_students: function (frm) {
- if (frm.doc.students.length > 0) {
- frm.add_custom_button(__("Enroll All Students"), function () {
- if (frm.doc.students.length > 0) {
- frappe.call({
- method: "csf_tz.custom_api.enroll_all_students",
- args: {
- "self": frm.doc
- },
- callback: function (r) {
- if (r.message === 'queued') {
- frappe.show_alert({
- message: __("Students enrollment has been queued."),
- indicator: 'orange'
- });
- } else {
- frappe.show_alert({
- message: __("{0} students enrolled.", [r.message]),
- indicator: 'green'
- });
- }
- }
- });
- } else {
- frappe.msgprint("No students to enroll")
- }
- })
- }
- },
-
-})
+ refresh: function (frm) {
+ frm.toggle_display(["enroll_students"]);
+ },
+ academic_year: function (frm) {
+ frm.toggle_display("enroll_students", is_viewable);
+ },
+ get_students: function (frm) {
+ if (frm.doc.students.length > 0) {
+ frm.add_custom_button(__("Enroll All Students"), function () {
+ if (frm.doc.students.length > 0) {
+ frappe.call({
+ method: "csf_tz.custom_api.enroll_all_students",
+ args: {
+ self: frm.doc,
+ },
+ callback: function (r) {
+ if (r.message === "queued") {
+ frappe.show_alert({
+ message: __("Students enrollment has been queued."),
+ indicator: "orange",
+ });
+ } else {
+ frappe.show_alert({
+ message: __("{0} students enrolled.", [r.message]),
+ indicator: "green",
+ });
+ }
+ },
+ });
+ } else {
+ frappe.msgprint("No students to enroll");
+ }
+ });
+ }
+ },
+});
diff --git a/csf_tz/csf_tz/property_setter.js b/csf_tz/csf_tz/property_setter.js
index e0f2c1e2..d3216e07 100644
--- a/csf_tz/csf_tz/property_setter.js
+++ b/csf_tz/csf_tz/property_setter.js
@@ -1,47 +1,49 @@
-frappe.listview_settings['Property Setter'] = {
- onload: function (listview) {
- listview.page.add_menu_item(__('Export Selected'), async function () {
- const selected_docs = listview.get_checked_items();
- if (selected_docs.length === 0) {
- frappe.msgprint(__('Please select at least one document.'));
- return;
- }
+frappe.listview_settings["Property Setter"] = {
+ onload: function (listview) {
+ listview.page.add_menu_item(__("Export Selected"), async function () {
+ const selected_docs = listview.get_checked_items();
+ if (selected_docs.length === 0) {
+ frappe.msgprint(__("Please select at least one document."));
+ return;
+ }
- const detailed_docs = await Promise.all(selected_docs.map(doc =>
- fetch(`/api/resource/Property Setter/${doc.name}`)
- .then(response => response.json())
- .then(data => data.data)
- ));
+ const detailed_docs = await Promise.all(
+ selected_docs.map((doc) =>
+ fetch(`/api/resource/Property Setter/${doc.name}`)
+ .then((response) => response.json())
+ .then((data) => data.data)
+ )
+ );
- const data_to_export = detailed_docs.map(doc => {
- return {
- name: doc.name,
- owner: doc.owner,
- creation: doc.creation,
- modified: doc.modified,
- modified_by: doc.modified_by,
- docstatus: doc.docstatus,
- idx: doc.idx,
- is_system_generated: doc.is_system_generated,
- doctype_or_field: doc.doctype_or_field,
- doc_type: doc.doc_type,
- field_name: doc.field_name,
- property: doc.property,
- property_type: doc.property_type,
- value: doc.value,
- doctype: doc.doctype,
- __last_sync_on: doc.__last_sync_on
- };
- });
+ const data_to_export = detailed_docs.map((doc) => {
+ return {
+ name: doc.name,
+ owner: doc.owner,
+ creation: doc.creation,
+ modified: doc.modified,
+ modified_by: doc.modified_by,
+ docstatus: doc.docstatus,
+ idx: doc.idx,
+ is_system_generated: doc.is_system_generated,
+ doctype_or_field: doc.doctype_or_field,
+ doc_type: doc.doc_type,
+ field_name: doc.field_name,
+ property: doc.property,
+ property_type: doc.property_type,
+ value: doc.value,
+ doctype: doc.doctype,
+ __last_sync_on: doc.__last_sync_on,
+ };
+ });
- const jsonStr = JSON.stringify(data_to_export);
- let blob = new Blob([jsonStr], { type: "application/json" });
- let a = document.createElement("a");
- a.href = URL.createObjectURL(blob);
- a.download = "exported_property_setters.json";
- a.click();
- URL.revokeObjectURL(a.href);
- a.remove();
- });
- }
+ const jsonStr = JSON.stringify(data_to_export);
+ let blob = new Blob([jsonStr], { type: "application/json" });
+ let a = document.createElement("a");
+ a.href = URL.createObjectURL(blob);
+ a.download = "exported_property_setters.json";
+ a.click();
+ URL.revokeObjectURL(a.href);
+ a.remove();
+ });
+ },
};
diff --git a/csf_tz/csf_tz/purchase_invoice.js b/csf_tz/csf_tz/purchase_invoice.js
index 758f095f..859e35d0 100644
--- a/csf_tz/csf_tz/purchase_invoice.js
+++ b/csf_tz/csf_tz/purchase_invoice.js
@@ -1,170 +1,183 @@
-frappe.require([
- '/assets/csf_tz/js/shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Purchase Invoice", {
- supplier: function(frm) {
- if (!frm.doc.supplier) {
- return
- }
- setTimeout(function() {
- if (!frm.doc.tax_category){
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function(r) {
- if(!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
- setup: function(frm) {
- frm.set_query("taxes_and_charges", function() {
+ supplier: function (frm) {
+ if (!frm.doc.supplier) {
+ return;
+ }
+ setTimeout(function () {
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
+ setup: function (frm) {
+ frm.set_query("taxes_and_charges", function () {
return {
- "filters": {
- "company": frm.doc.company,
- }
+ filters: {
+ company: frm.doc.company,
+ },
};
- });
- frappe.call({
- method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.get_dimensions",
- callback: function(r) {
- if(!r.exc) {
- const dimensions = [];
- r.message[0].forEach(element => {
- dimensions.push(element.fieldname);
- });
- frm.dimensions = dimensions;
- // console.log(frm.dimensions);
-
- }
- }
- });
- // const dimensions_fields = $("div.frappe-control[data-fieldname='expense_type']")
- // console.log(dimensions_fields);
- },
- refresh: (frm) => {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- frm.trigger("add_write_off_button");
- },
- onload: function(frm){
- frm.dimensions.forEach(i => {
- let dimension_field = $(`div.frappe-control[data-fieldname='${i}']`).find("input");
- dimension_field.on("focusout",function() {
- frm.doc.items.forEach(row => {
- row[i]=frm.doc[i];
- });
- frm.refresh_field("items");
- });
- });
- },
-
- // Write-off Journal Entry Feature
- add_write_off_button: function (frm) {
- // Check if feature is enabled and conditions are met
- frappe.db
- .get_single_value("CSF TZ Settings", "enable_write_off_jv_pi")
- .then((enable_write_off) => {
- if (enable_write_off &&
- frm.doc.docstatus === 1 &&
- frm.doc.outstanding_amount > 0 &&
- !frm.doc.is_return) {
-
- frm.add_custom_button(__("Write Off Outstanding"), function () {
- // Fetch the write-off account from Company before showing the dialog
- frappe.db.get_value("Company", frm.doc.company, "write_off_account").then(function(r) {
- let write_off_account = r.message ? r.message.write_off_account : null;
+ });
+ frappe.call({
+ method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.get_dimensions",
+ callback: function (r) {
+ if (!r.exc) {
+ const dimensions = [];
+ r.message[0].forEach((element) => {
+ dimensions.push(element.fieldname);
+ });
+ frm.dimensions = dimensions;
+ // console.log(frm.dimensions);
+ }
+ },
+ });
+ // const dimensions_fields = $("div.frappe-control[data-fieldname='expense_type']")
+ // console.log(dimensions_fields);
+ },
+ refresh: (frm) => {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ frm.trigger("add_write_off_button");
+ },
+ onload: function (frm) {
+ frm.dimensions.forEach((i) => {
+ let dimension_field = $(`div.frappe-control[data-fieldname='${i}']`).find("input");
+ dimension_field.on("focusout", function () {
+ frm.doc.items.forEach((row) => {
+ row[i] = frm.doc[i];
+ });
+ frm.refresh_field("items");
+ });
+ });
+ },
- // Show dialog to select write-off account
- let dialog = new frappe.ui.Dialog({
- title: __("Write Off Outstanding Amount"),
- fields: [
- {
- fieldname: "write_off_account",
- label: __("Write Off Account"),
- fieldtype: "Link",
- options: "Account",
- "default": write_off_account,
- reqd: 1,
- get_query: function() {
- return {
- filters: {
- "report_type": "Balance Sheet",
- "is_group": 0,
- "company": frm.doc.company
- }
- };
- }
- },
- {
- fieldname: "outstanding_amount",
- label: __("Outstanding Amount"),
- fieldtype: "Currency",
- default: frm.doc.outstanding_amount,
- read_only: 1
- }
- ],
- primary_action_label: __("Create Write Off Entry"),
- primary_action: function(values) {
- frappe.call({
- method: "csf_tz.custom_api.create_write_off_jv_pi",
- args: {
- purchase_invoice: frm.doc.name,
- account: values.write_off_account
- },
- callback: function(r) {
- if (r.message) {
- const journal_entry_link = `
${frappe.utils.escape_html(r.message)}`;
- frappe.msgprint(__("Write-off Journal Entry created: {0}", [journal_entry_link]));
- frm.reload_doc();
- }
- }
- });
- dialog.hide();
- }
- });
- dialog.show();
- });
- }, __("Create"));
- }
- });
- },
+ // Write-off Journal Entry Feature
+ add_write_off_button: function (frm) {
+ // Check if feature is enabled and conditions are met
+ frappe.db.get_single_value("CSF TZ Settings", "enable_write_off_jv_pi").then((enable_write_off) => {
+ if (
+ enable_write_off &&
+ frm.doc.docstatus === 1 &&
+ frm.doc.outstanding_amount > 0 &&
+ !frm.doc.is_return
+ ) {
+ frm.add_custom_button(
+ __("Write Off Outstanding"),
+ function () {
+ // Fetch the write-off account from Company before showing the dialog
+ frappe.db
+ .get_value("Company", frm.doc.company, "write_off_account")
+ .then(function (r) {
+ let write_off_account = r.message ? r.message.write_off_account : null;
+ // Show dialog to select write-off account
+ let dialog = new frappe.ui.Dialog({
+ title: __("Write Off Outstanding Amount"),
+ fields: [
+ {
+ fieldname: "write_off_account",
+ label: __("Write Off Account"),
+ fieldtype: "Link",
+ options: "Account",
+ default: write_off_account,
+ reqd: 1,
+ get_query: function () {
+ return {
+ filters: {
+ report_type: "Balance Sheet",
+ is_group: 0,
+ company: frm.doc.company,
+ },
+ };
+ },
+ },
+ {
+ fieldname: "outstanding_amount",
+ label: __("Outstanding Amount"),
+ fieldtype: "Currency",
+ default: frm.doc.outstanding_amount,
+ read_only: 1,
+ },
+ ],
+ primary_action_label: __("Create Write Off Entry"),
+ primary_action: function (values) {
+ frappe.call({
+ method: "csf_tz.custom_api.create_write_off_jv_pi",
+ args: {
+ purchase_invoice: frm.doc.name,
+ account: values.write_off_account,
+ },
+ callback: function (r) {
+ if (r.message) {
+ const journal_entry_link = `
${frappe.utils.escape_html(
+ r.message
+ )}`;
+ frappe.msgprint(
+ __("Write-off Journal Entry created: {0}", [
+ journal_entry_link,
+ ])
+ );
+ frm.reload_doc();
+ }
+ },
+ });
+ dialog.hide();
+ },
+ });
+ dialog.show();
+ });
+ },
+ __("Create")
+ );
+ }
+ });
+ },
});
frappe.ui.form.on("Purchase Invoice Item", {
- items_add: function(frm, cdt, cdn) {
- var row = frappe.get_doc(cdt, cdn);
- frm.dimensions.forEach(i => {
- row[i]=frm.doc[i];
- });
- frm.refresh_field("items");
- },
- csf_tz_create_wtax_entry: (frm, cdt, cdn) => {
- frappe.call('csf_tz.custom_api.make_withholding_tax_gl_entries_for_purchase', {
- doc: frm.doc, method: 'From Front End'
- }).then(r => {
- frm.refresh();
- });
- }
+ items_add: function (frm, cdt, cdn) {
+ var row = frappe.get_doc(cdt, cdn);
+ frm.dimensions.forEach((i) => {
+ row[i] = frm.doc[i];
+ });
+ frm.refresh_field("items");
+ },
+ csf_tz_create_wtax_entry: (frm, cdt, cdn) => {
+ frappe
+ .call("csf_tz.custom_api.make_withholding_tax_gl_entries_for_purchase", {
+ doc: frm.doc,
+ method: "From Front End",
+ })
+ .then((r) => {
+ frm.refresh();
+ });
+ },
});
diff --git a/csf_tz/csf_tz/purchase_order.js b/csf_tz/csf_tz/purchase_order.js
index 38feadec..b63e6f7a 100644
--- a/csf_tz/csf_tz/purchase_order.js
+++ b/csf_tz/csf_tz/purchase_order.js
@@ -1,73 +1,70 @@
-frappe.require([
- '/assets/csf_tz/js/shortcuts.js',
- '/assets/csf_tz/js/po_shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js", "/assets/csf_tz/js/po_shortcuts.js"]);
frappe.ui.form.on("Purchase Order", {
- refresh: (frm) => {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- },
- supplier: function (frm) {
- setTimeout(function () {
- if (!frm.doc.tax_category) {
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function (r) {
- if (!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
- setup: function (frm) {
- frm.set_query("taxes_and_charges", function () {
- return {
- "filters": {
- "company": frm.doc.company,
- }
- };
- });
- },
+ refresh: (frm) => {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ },
+ supplier: function (frm) {
+ setTimeout(function () {
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
+ setup: function (frm) {
+ frm.set_query("taxes_and_charges", function () {
+ return {
+ filters: {
+ company: frm.doc.company,
+ },
+ };
+ });
+ },
});
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+i',
- action: () => {
- ctrlI("Purchase Order Item");
- },
- page: this.page,
- description: __('Select Customer Item Price'),
- ignore_inputs: true,
+ shortcut: "ctrl+i",
+ action: () => {
+ ctrlI("Purchase Order Item");
+ },
+ page: this.page,
+ description: __("Select Customer Item Price"),
+ ignore_inputs: true,
});
-
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+u',
- action: () => {
- ctrlU("Purchase Order Item");
- },
- page: this.page,
- description: __('Select Item Price'),
- ignore_inputs: true,
+ shortcut: "ctrl+u",
+ action: () => {
+ ctrlU("Purchase Order Item");
+ },
+ page: this.page,
+ description: __("Select Item Price"),
+ ignore_inputs: true,
});
diff --git a/csf_tz/csf_tz/purchase_receipt.js b/csf_tz/csf_tz/purchase_receipt.js
index 7ce848b4..376ec1ae 100644
--- a/csf_tz/csf_tz/purchase_receipt.js
+++ b/csf_tz/csf_tz/purchase_receipt.js
@@ -1,21 +1,21 @@
frappe.ui.form.on("Purchase Receipt", {
- supplier: function(frm) {
- setTimeout(function() {
- if (!frm.doc.tax_category){
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function(r) {
- if(!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
+ supplier: function (frm) {
+ setTimeout(function () {
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
});
diff --git a/csf_tz/csf_tz/quotation.js b/csf_tz/csf_tz/quotation.js
index 4015b65c..6ea0ce7e 100644
--- a/csf_tz/csf_tz/quotation.js
+++ b/csf_tz/csf_tz/quotation.js
@@ -1,42 +1,41 @@
-frappe.require([
- '/assets/csf_tz/js/shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Quotation", {
- refresh: (frm) => {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- },
- party_name: function (frm) {
- setTimeout(function () {
- if (frm.doc.party_name && !frm.doc.tax_category) {
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function (r) {
- if (!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
+ refresh: (frm) => {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ },
+ party_name: function (frm) {
+ setTimeout(function () {
+ if (frm.doc.party_name && !frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
});
diff --git a/csf_tz/csf_tz/report/accounts_receivable_multi_currency/accounts_receivable_multi_currency.js b/csf_tz/csf_tz/report/accounts_receivable_multi_currency/accounts_receivable_multi_currency.js
index d672026a..ce965f6d 100644
--- a/csf_tz/csf_tz/report/accounts_receivable_multi_currency/accounts_receivable_multi_currency.js
+++ b/csf_tz/csf_tz/report/accounts_receivable_multi_currency/accounts_receivable_multi_currency.js
@@ -2,201 +2,210 @@
// License: GNU General Public License v3. See license.txt
frappe.query_reports["Accounts Receivable Multi Currency"] = {
- "filters": [
+ filters: [
{
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "reqd": 1,
- "default": frappe.defaults.get_user_default("Company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ reqd: 1,
+ default: frappe.defaults.get_user_default("Company"),
},
{
- "fieldname":"ageing_based_on",
- "label": __("Ageing Based On"),
- "fieldtype": "Select",
- "options": 'Posting Date\nDue Date',
- "default": "Posting Date"
+ fieldname: "ageing_based_on",
+ label: __("Ageing Based On"),
+ fieldtype: "Select",
+ options: "Posting Date\nDue Date",
+ default: "Posting Date",
},
{
- "fieldname":"report_date",
- "label": __("As on Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
+ fieldname: "report_date",
+ label: __("As on Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
},
{
- "fieldname":"range1",
- "label": __("Ageing Range 1"),
- "fieldtype": "Int",
- "default": "30",
- "reqd": 1
+ fieldname: "range1",
+ label: __("Ageing Range 1"),
+ fieldtype: "Int",
+ default: "30",
+ reqd: 1,
},
{
- "fieldname":"range2",
- "label": __("Ageing Range 2"),
- "fieldtype": "Int",
- "default": "60",
- "reqd": 1
+ fieldname: "range2",
+ label: __("Ageing Range 2"),
+ fieldtype: "Int",
+ default: "60",
+ reqd: 1,
},
{
- "fieldname":"range3",
- "label": __("Ageing Range 3"),
- "fieldtype": "Int",
- "default": "90",
- "reqd": 1
+ fieldname: "range3",
+ label: __("Ageing Range 3"),
+ fieldtype: "Int",
+ default: "90",
+ reqd: 1,
},
{
- "fieldname":"range4",
- "label": __("Ageing Range 4"),
- "fieldtype": "Int",
- "default": "120",
- "reqd": 1
+ fieldname: "range4",
+ label: __("Ageing Range 4"),
+ fieldtype: "Int",
+ default: "120",
+ reqd: 1,
},
{
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
+ fieldname: "finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book",
},
{
- "fieldname":"cost_center",
- "label": __("Cost Center"),
- "fieldtype": "Link",
- "options": "Cost Center",
+ fieldname: "cost_center",
+ label: __("Cost Center"),
+ fieldtype: "Link",
+ options: "Cost Center",
get_query: () => {
- var company = frappe.query_report.get_filter_value('company');
+ var company = frappe.query_report.get_filter_value("company");
return {
filters: {
- 'company': company
- }
- }
- }
+ company: company,
+ },
+ };
+ },
},
{
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer",
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
on_change: () => {
- var customer = frappe.query_report.get_filter_value('customer');
- var company = frappe.query_report.get_filter_value('company');
+ var customer = frappe.query_report.get_filter_value("customer");
+ var company = frappe.query_report.get_filter_value("company");
if (customer) {
- frappe.db.get_value('Customer', customer, ["tax_id", "customer_name", "payment_terms"], function(value) {
- frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
- frappe.query_report.set_filter_value('customer_name', value["customer_name"]);
- frappe.query_report.set_filter_value('payment_terms', value["payment_terms"]);
- });
-
- frappe.db.get_value('Customer Credit Limit', {'parent': customer, 'company': company},
- ["credit_limit"], function(value) {
- if (value) {
- frappe.query_report.set_filter_value('credit_limit', value["credit_limit"]);
+ frappe.db.get_value(
+ "Customer",
+ customer,
+ ["tax_id", "customer_name", "payment_terms"],
+ function (value) {
+ frappe.query_report.set_filter_value("tax_id", value["tax_id"]);
+ frappe.query_report.set_filter_value("customer_name", value["customer_name"]);
+ frappe.query_report.set_filter_value("payment_terms", value["payment_terms"]);
}
- }, "Customer");
+ );
+
+ frappe.db.get_value(
+ "Customer Credit Limit",
+ { parent: customer, company: company },
+ ["credit_limit"],
+ function (value) {
+ if (value) {
+ frappe.query_report.set_filter_value("credit_limit", value["credit_limit"]);
+ }
+ },
+ "Customer"
+ );
} else {
- frappe.query_report.set_filter_value('tax_id', "");
- frappe.query_report.set_filter_value('customer_name', "");
- frappe.query_report.set_filter_value('credit_limit', "");
- frappe.query_report.set_filter_value('payment_terms', "");
+ frappe.query_report.set_filter_value("tax_id", "");
+ frappe.query_report.set_filter_value("customer_name", "");
+ frappe.query_report.set_filter_value("credit_limit", "");
+ frappe.query_report.set_filter_value("payment_terms", "");
}
- }
+ },
},
{
- "fieldname":"customer_group",
- "label": __("Customer Group"),
- "fieldtype": "Link",
- "options": "Customer Group"
+ fieldname: "customer_group",
+ label: __("Customer Group"),
+ fieldtype: "Link",
+ options: "Customer Group",
},
{
- "fieldname":"payment_terms_template",
- "label": __("Payment Terms Template"),
- "fieldtype": "Link",
- "options": "Payment Terms Template"
+ fieldname: "payment_terms_template",
+ label: __("Payment Terms Template"),
+ fieldtype: "Link",
+ options: "Payment Terms Template",
},
{
- "fieldname":"territory",
- "label": __("Territory"),
- "fieldtype": "Link",
- "options": "Territory"
+ fieldname: "territory",
+ label: __("Territory"),
+ fieldtype: "Link",
+ options: "Territory",
},
{
- "fieldname":"sales_partner",
- "label": __("Sales Partner"),
- "fieldtype": "Link",
- "options": "Sales Partner"
+ fieldname: "sales_partner",
+ label: __("Sales Partner"),
+ fieldtype: "Link",
+ options: "Sales Partner",
},
{
- "fieldname":"sales_person",
- "label": __("Sales Person"),
- "fieldtype": "Link",
- "options": "Sales Person"
+ fieldname: "sales_person",
+ label: __("Sales Person"),
+ fieldtype: "Link",
+ options: "Sales Person",
},
{
- "fieldname": "group_by_party",
- "label": __("Group By Customer"),
- "fieldtype": "Check"
+ fieldname: "group_by_party",
+ label: __("Group By Customer"),
+ fieldtype: "Check",
},
{
- "fieldname":"based_on_payment_terms",
- "label": __("Based On Payment Terms"),
- "fieldtype": "Check",
+ fieldname: "based_on_payment_terms",
+ label: __("Based On Payment Terms"),
+ fieldtype: "Check",
},
{
- "fieldname":"show_future_payments",
- "label": __("Show Future Payments"),
- "fieldtype": "Check",
+ fieldname: "show_future_payments",
+ label: __("Show Future Payments"),
+ fieldtype: "Check",
},
{
- "fieldname":"show_delivery_notes",
- "label": __("Show Delivery Notes"),
- "fieldtype": "Check",
+ fieldname: "show_delivery_notes",
+ label: __("Show Delivery Notes"),
+ fieldtype: "Check",
},
{
- "fieldname":"show_sales_person",
- "label": __("Show Sales Person"),
- "fieldtype": "Check",
+ fieldname: "show_sales_person",
+ label: __("Show Sales Person"),
+ fieldtype: "Check",
},
{
- "fieldname":"tax_id",
- "label": __("Tax Id"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "tax_id",
+ label: __("Tax Id"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname":"customer_name",
- "label": __("Customer Name"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "customer_name",
+ label: __("Customer Name"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname":"payment_terms",
- "label": __("Payment Tems"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "payment_terms",
+ label: __("Payment Tems"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname":"credit_limit",
- "label": __("Credit Limit"),
- "fieldtype": "Currency",
- "hidden": 1
- }
+ fieldname: "credit_limit",
+ label: __("Credit Limit"),
+ fieldtype: "Currency",
+ hidden: 1,
+ },
],
- "formatter": function(value, row, column, data, default_formatter) {
+ formatter: function (value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (data && data.bold) {
value = value.bold();
-
}
return value;
},
- onload: function(report) {
- report.page.add_inner_button(__("Accounts Receivable Summary"), function() {
+ onload: function (report) {
+ report.page.add_inner_button(__("Accounts Receivable Summary"), function () {
var filters = report.get_values();
- frappe.set_route('query-report', 'Accounts Receivable Summary', {company: filters.company});
+ frappe.set_route("query-report", "Accounts Receivable Summary", { company: filters.company });
});
- }
-}
+ },
+};
-erpnext.utils.add_dimensions('Accounts Receivable', 9);
+erpnext.utils.add_dimensions("Accounts Receivable", 9);
diff --git a/csf_tz/csf_tz/report/accounts_receivable_summary_multi_currency/accounts_receivable_summary_multi_currency.js b/csf_tz/csf_tz/report/accounts_receivable_summary_multi_currency/accounts_receivable_summary_multi_currency.js
index 4c1629c2..286a4d43 100644
--- a/csf_tz/csf_tz/report/accounts_receivable_summary_multi_currency/accounts_receivable_summary_multi_currency.js
+++ b/csf_tz/csf_tz/report/accounts_receivable_summary_multi_currency/accounts_receivable_summary_multi_currency.js
@@ -3,110 +3,110 @@
/* eslint-disable */
frappe.query_reports["Accounts Receivable Summary Multi Currency"] = {
- "filters": [
+ filters: [
{
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
},
{
- "fieldname":"ageing_based_on",
- "label": __("Ageing Based On"),
- "fieldtype": "Select",
- "options": 'Posting Date\nDue Date',
- "default": "Posting Date"
+ fieldname: "ageing_based_on",
+ label: __("Ageing Based On"),
+ fieldtype: "Select",
+ options: "Posting Date\nDue Date",
+ default: "Posting Date",
},
{
- "fieldname":"report_date",
- "label": __("Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
+ fieldname: "report_date",
+ label: __("Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
},
{
- "fieldname":"range1",
- "label": __("Ageing Range 1"),
- "fieldtype": "Int",
- "default": "30",
- "reqd": 1
+ fieldname: "range1",
+ label: __("Ageing Range 1"),
+ fieldtype: "Int",
+ default: "30",
+ reqd: 1,
},
{
- "fieldname":"range2",
- "label": __("Ageing Range 2"),
- "fieldtype": "Int",
- "default": "60",
- "reqd": 1
+ fieldname: "range2",
+ label: __("Ageing Range 2"),
+ fieldtype: "Int",
+ default: "60",
+ reqd: 1,
},
{
- "fieldname":"range3",
- "label": __("Ageing Range 3"),
- "fieldtype": "Int",
- "default": "90",
- "reqd": 1
+ fieldname: "range3",
+ label: __("Ageing Range 3"),
+ fieldtype: "Int",
+ default: "90",
+ reqd: 1,
},
{
- "fieldname":"range4",
- "label": __("Ageing Range 4"),
- "fieldtype": "Int",
- "default": "120",
- "reqd": 1
+ fieldname: "range4",
+ label: __("Ageing Range 4"),
+ fieldtype: "Int",
+ default: "120",
+ reqd: 1,
},
{
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
+ fieldname: "finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book",
},
{
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer"
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
},
{
- "fieldname":"customer_group",
- "label": __("Customer Group"),
- "fieldtype": "Link",
- "options": "Customer Group"
+ fieldname: "customer_group",
+ label: __("Customer Group"),
+ fieldtype: "Link",
+ options: "Customer Group",
},
{
- "fieldname":"payment_terms_template",
- "label": __("Payment Terms Template"),
- "fieldtype": "Link",
- "options": "Payment Terms Template"
+ fieldname: "payment_terms_template",
+ label: __("Payment Terms Template"),
+ fieldtype: "Link",
+ options: "Payment Terms Template",
},
{
- "fieldname":"territory",
- "label": __("Territory"),
- "fieldtype": "Link",
- "options": "Territory"
+ fieldname: "territory",
+ label: __("Territory"),
+ fieldtype: "Link",
+ options: "Territory",
},
{
- "fieldname":"sales_partner",
- "label": __("Sales Partner"),
- "fieldtype": "Link",
- "options": "Sales Partner"
+ fieldname: "sales_partner",
+ label: __("Sales Partner"),
+ fieldtype: "Link",
+ options: "Sales Partner",
},
{
- "fieldname":"sales_person",
- "label": __("Sales Person"),
- "fieldtype": "Link",
- "options": "Sales Person"
+ fieldname: "sales_person",
+ label: __("Sales Person"),
+ fieldtype: "Link",
+ options: "Sales Person",
},
{
- "fieldname":"currency",
- "label": __("Currency"),
- "fieldtype": "Link",
- "options": "Currency",
- "default": "TZS"
- }
+ fieldname: "currency",
+ label: __("Currency"),
+ fieldtype: "Link",
+ options: "Currency",
+ default: "TZS",
+ },
],
- onload: function(report) {
- report.page.add_inner_button(__("Accounts Receivable"), function() {
+ onload: function (report) {
+ report.page.add_inner_button(__("Accounts Receivable"), function () {
var filters = report.get_values();
- frappe.set_route('query-report', 'Accounts Receivable', { company: filters.company });
+ frappe.set_route("query-report", "Accounts Receivable", { company: filters.company });
});
- }
-}
+ },
+};
diff --git a/csf_tz/csf_tz/report/av_sales_invoice_trend/av_sales_invoice_trend.js b/csf_tz/csf_tz/report/av_sales_invoice_trend/av_sales_invoice_trend.js
index 85b55a92..5906b74d 100644
--- a/csf_tz/csf_tz/report/av_sales_invoice_trend/av_sales_invoice_trend.js
+++ b/csf_tz/csf_tz/report/av_sales_invoice_trend/av_sales_invoice_trend.js
@@ -1,7 +1,4 @@
// Copyright (c) 2025, Aakvatech and contributors
// For license information, please see license.txt
-frappe.query_reports["AV Sales Invoice Trend"] = $.extend(
- {},
- erpnext.sales_trends_filters
-);
+frappe.query_reports["AV Sales Invoice Trend"] = $.extend({}, erpnext.sales_trends_filters);
diff --git a/csf_tz/csf_tz/report/credit_note_list/credit_note_list.js b/csf_tz/csf_tz/report/credit_note_list/credit_note_list.js
index fd96cfcd..a5826059 100644
--- a/csf_tz/csf_tz/report/credit_note_list/credit_note_list.js
+++ b/csf_tz/csf_tz/report/credit_note_list/credit_note_list.js
@@ -1,28 +1,28 @@
-// Copyright (c) 2016, Aakvatech and contributors
-// For license information, please see license.txt
-/* eslint-disable */
-
-frappe.query_reports["Credit Note List"] = {
- "filters": [
- {
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1
- },
- ]
-}
-
-// $(function() {
-// $(wrapper).bind("show", function() {
-// frappe.query_report.load();
-// });
+// Copyright (c) 2016, Aakvatech and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Credit Note List"] = {
+ filters: [
+ {
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ },
+ ],
+};
+
+// $(function() {
+// $(wrapper).bind("show", function() {
+// frappe.query_report.load();
+// });
// });
diff --git a/csf_tz/csf_tz/report/csf_tz_stock_movement/csf_tz_stock_movement.js b/csf_tz/csf_tz/report/csf_tz_stock_movement/csf_tz_stock_movement.js
index 78009e6f..3f46e9a0 100644
--- a/csf_tz/csf_tz/report/csf_tz_stock_movement/csf_tz_stock_movement.js
+++ b/csf_tz/csf_tz/report/csf_tz_stock_movement/csf_tz_stock_movement.js
@@ -3,46 +3,46 @@
/* eslint-disable */
frappe.query_reports["CSF TZ Stock Movement"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1,
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
},
{
- "fieldname": "item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
{
- "fieldname": "item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "options": "Item Group"
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ options: "Item Group",
},
{
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse",
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
],
};
diff --git a/csf_tz/csf_tz/report/employee_salary_register_with_monthly_comparison/employee_salary_register_with_monthly_comparison.js b/csf_tz/csf_tz/report/employee_salary_register_with_monthly_comparison/employee_salary_register_with_monthly_comparison.js
index 3cfbae89..7afd4213 100644
--- a/csf_tz/csf_tz/report/employee_salary_register_with_monthly_comparison/employee_salary_register_with_monthly_comparison.js
+++ b/csf_tz/csf_tz/report/employee_salary_register_with_monthly_comparison/employee_salary_register_with_monthly_comparison.js
@@ -3,71 +3,71 @@
/* eslint-disable */
frappe.query_reports["Employee Salary Register with Monthly Comparison"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "100px"
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "to_date",
- "label": __("To"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "100px"
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "currency",
- "fieldtype": "Link",
- "options": "Currency",
- "label": __("Currency"),
- "default": erpnext.get_currency(frappe.defaults.get_default("Company")),
- "width": "50px"
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
},
{
- "fieldname": "employee",
- "label": __("Employee"),
- "fieldtype": "Link",
- "options": "Employee",
- "width": "100px"
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
},
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "width": "100px",
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
},
{
- "fieldname": "department",
- "label": __("Department"),
- "fieldtype": "Link",
- "options": "Department",
- "default": "",
- "width": "100px",
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Department",
- "filters": {
- "company": company,
- }
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
};
- }
+ },
},
{
- "fieldname": "docstatus",
- "label": __("Document Status"),
- "fieldtype": "Select",
- "options": ["Draft", "Submitted", "Cancelled"],
- "default": "Submitted",
- "width": "100px"
- }
- ]
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/excise_duty_detailed_report/excise_duty_detailed_report.js b/csf_tz/csf_tz/report/excise_duty_detailed_report/excise_duty_detailed_report.js
index cf85cae2..0b4d905d 100644
--- a/csf_tz/csf_tz/report/excise_duty_detailed_report/excise_duty_detailed_report.js
+++ b/csf_tz/csf_tz/report/excise_duty_detailed_report/excise_duty_detailed_report.js
@@ -3,20 +3,20 @@
/* eslint-disable */
frappe.query_reports["Excise Duty Detailed Report"] = {
- "filters": [
- {
- "fieldname": "from_date",
- "fieldtype": "Date",
- "label": "From Date",
- "mandatory": 1,
- "wildcard_filter": 0
- },
- {
- "fieldname": "to_date",
- "fieldtype": "Date",
- "label": "To Date",
- "mandatory": 1,
- "wildcard_filter": 0
- }
- ]
-}
+ filters: [
+ {
+ fieldname: "from_date",
+ fieldtype: "Date",
+ label: "From Date",
+ mandatory: 1,
+ wildcard_filter: 0,
+ },
+ {
+ fieldname: "to_date",
+ fieldtype: "Date",
+ label: "To Date",
+ mandatory: 1,
+ wildcard_filter: 0,
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/excise_duty_report/exise_duty_report.js b/csf_tz/csf_tz/report/excise_duty_report/exise_duty_report.js
index a1e18207..b3e4581b 100644
--- a/csf_tz/csf_tz/report/excise_duty_report/exise_duty_report.js
+++ b/csf_tz/csf_tz/report/excise_duty_report/exise_duty_report.js
@@ -3,20 +3,20 @@
/* eslint-disable */
frappe.query_reports["Excise Duty Report"] = {
- "filters": [
- {
- "fieldname": "from_date",
- "fieldtype": "Date",
- "label": "From Date",
- "mandatory": 1,
- "wildcard_filter": 0
- },
- {
- "fieldname": "to_date",
- "fieldtype": "Date",
- "label": "To Date",
- "mandatory": 1,
- "wildcard_filter": 0
- }
- ]
-}
+ filters: [
+ {
+ fieldname: "from_date",
+ fieldtype: "Date",
+ label: "From Date",
+ mandatory: 1,
+ wildcard_filter: 0,
+ },
+ {
+ fieldname: "to_date",
+ fieldtype: "Date",
+ label: "To Date",
+ mandatory: 1,
+ wildcard_filter: 0,
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/excise_duty_stock/excise_duty_stock.js b/csf_tz/csf_tz/report/excise_duty_stock/excise_duty_stock.js
index 730a0185..e2adae45 100644
--- a/csf_tz/csf_tz/report/excise_duty_stock/excise_duty_stock.js
+++ b/csf_tz/csf_tz/report/excise_duty_stock/excise_duty_stock.js
@@ -3,97 +3,96 @@
/* eslint-disable */
frappe.query_reports["Excise Duty Stock"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Company",
- "default": frappe.defaults.get_default("company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Company",
+ default: frappe.defaults.get_default("company"),
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.get_today()
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.get_today(),
},
{
- "fieldname": "item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item Group"
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item Group",
},
{
- "fieldname": "item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item",
- "get_query": function () {
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item",
+ get_query: function () {
return {
query: "erpnext.controllers.queries.item_query",
};
- }
+ },
},
{
- "fieldname": "warehouse_type",
- "label": __("Warehouse Type"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse Type"
+ fieldname: "warehouse_type",
+ label: __("Warehouse Type"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse Type",
},
{
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse",
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse",
get_query: () => {
- var warehouse_type = frappe.query_report.get_filter_value('warehouse_type');
+ var warehouse_type = frappe.query_report.get_filter_value("warehouse_type");
if (warehouse_type) {
return {
filters: {
- 'warehouse_type': warehouse_type
- }
+ warehouse_type: warehouse_type,
+ },
};
}
- }
+ },
},
{
- "fieldname": "include_uom",
- "label": __("Include UOM"),
- "fieldtype": "Link",
- "options": "UOM"
+ fieldname: "include_uom",
+ label: __("Include UOM"),
+ fieldtype: "Link",
+ options: "UOM",
},
{
- "fieldname": "show_variant_attributes",
- "label": __("Show Variant Attributes"),
- "fieldtype": "Check"
+ fieldname: "show_variant_attributes",
+ label: __("Show Variant Attributes"),
+ fieldtype: "Check",
},
],
- "formatter": function (value, row, column, data, default_formatter) {
+ formatter: function (value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (column.fieldname == "out_qty" && data && data.out_qty > 0) {
value = "
" + value + "";
- }
- else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
+ } else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
value = "
" + value + "";
}
return value;
- }
+ },
};
diff --git a/csf_tz/csf_tz/report/general_ledger_pro/general_ledger_pro.js b/csf_tz/csf_tz/report/general_ledger_pro/general_ledger_pro.js
index 5c9e071d..44a9d58d 100644
--- a/csf_tz/csf_tz/report/general_ledger_pro/general_ledger_pro.js
+++ b/csf_tz/csf_tz/report/general_ledger_pro/general_ledger_pro.js
@@ -3,174 +3,179 @@
/* eslint-disable */
frappe.query_reports["General Ledger Pro"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1,
},
{
- "fieldname": "finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
+ fieldname: "finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book",
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.month_start(frappe.datetime.add_months(frappe.datetime.get_today(), -1)),
- "reqd": 1,
- "width": "60px"
- },
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.month_start(frappe.datetime.add_months(frappe.datetime.get_today(), -1)),
+ reqd: 1,
+ width: "60px",
+ },
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "60px"
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "60px",
},
{
- "fieldname": "account",
- "label": __("Account"),
- "fieldtype": "Link",
- "options": "Account",
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "account",
+ label: __("Account"),
+ fieldtype: "Link",
+ options: "Account",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Account",
- "filters": {
- "company": company,
- }
- }
- }
+ doctype: "Account",
+ filters: {
+ company: company,
+ },
+ };
+ },
},
{
- "fieldname": "voucher_no",
- "label": __("Voucher No"),
- "fieldtype": "Data",
+ fieldname: "voucher_no",
+ label: __("Voucher No"),
+ fieldtype: "Data",
on_change: function () {
- frappe.query_report.set_filter_value('group_by', "Group by Voucher (Consolidated)");
- }
+ frappe.query_report.set_filter_value("group_by", "Group by Voucher (Consolidated)");
+ },
},
{
- "fieldtype": "Break",
+ fieldtype: "Break",
},
{
- "fieldname": "party_type",
- "label": __("Party Type"),
- "fieldtype": "Link",
- "options": "Party Type",
- "default": "Customer",
+ fieldname: "party_type",
+ label: __("Party Type"),
+ fieldtype: "Link",
+ options: "Party Type",
+ default: "Customer",
on_change: function () {
- frappe.query_report.set_filter_value('party', "");
- }
+ frappe.query_report.set_filter_value("party", "");
+ },
},
{
- "fieldname": "party",
- "label": __("Party"),
- "fieldtype": "MultiSelectList",
+ fieldname: "party",
+ label: __("Party"),
+ fieldtype: "MultiSelectList",
get_data: function (txt) {
if (!frappe.query_report.filters) return;
- let party_type = frappe.query_report.get_filter_value('party_type');
+ let party_type = frappe.query_report.get_filter_value("party_type");
if (!party_type) return;
return frappe.db.get_link_options(party_type, txt);
},
on_change: function () {
- var party_type = frappe.query_report.get_filter_value('party_type');
- var parties = frappe.query_report.get_filter_value('party');
+ var party_type = frappe.query_report.get_filter_value("party_type");
+ var parties = frappe.query_report.get_filter_value("party");
if (!party_type || parties.length === 0 || parties.length > 1) {
- frappe.query_report.set_filter_value('party_name', "");
- frappe.query_report.set_filter_value('tax_id', "");
+ frappe.query_report.set_filter_value("party_name", "");
+ frappe.query_report.set_filter_value("tax_id", "");
return;
} else {
var party = parties[0];
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
frappe.db.get_value(party_type, party, fieldname, function (value) {
- frappe.query_report.set_filter_value('party_name', value[fieldname]);
+ frappe.query_report.set_filter_value("party_name", value[fieldname]);
});
if (party_type === "Customer" || party_type === "Supplier") {
frappe.db.get_value(party_type, party, "tax_id", function (value) {
- frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
+ frappe.query_report.set_filter_value("tax_id", value["tax_id"]);
});
}
}
- }
+ },
},
{
- "fieldname": "party_name",
- "label": __("Party Name"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "party_name",
+ label: __("Party Name"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname": "group_by",
- "label": __("Group by"),
- "fieldtype": "Select",
- "options": ["", __("Group by Voucher"), __("Group by Voucher (Consolidated)"),
- __("Group by Account"), __("Group by Party")],
- "default": __("Group by Voucher (Consolidated)")
+ fieldname: "group_by",
+ label: __("Group by"),
+ fieldtype: "Select",
+ options: [
+ "",
+ __("Group by Voucher"),
+ __("Group by Voucher (Consolidated)"),
+ __("Group by Account"),
+ __("Group by Party"),
+ ],
+ default: __("Group by Voucher (Consolidated)"),
},
{
- "fieldname": "tax_id",
- "label": __("Tax Id"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "tax_id",
+ label: __("Tax Id"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname": "presentation_currency",
- "label": __("Currency"),
- "fieldtype": "Select",
- "options": erpnext.get_presentation_currency_list()
+ fieldname: "presentation_currency",
+ label: __("Currency"),
+ fieldtype: "Select",
+ options: erpnext.get_presentation_currency_list(),
},
{
- "fieldname": "cost_center",
- "label": __("Cost Center"),
- "fieldtype": "MultiSelectList",
+ fieldname: "cost_center",
+ label: __("Cost Center"),
+ fieldtype: "MultiSelectList",
get_data: function (txt) {
- return frappe.db.get_link_options('Cost Center', txt);
- }
+ return frappe.db.get_link_options("Cost Center", txt);
+ },
},
{
- "fieldname": "project",
- "label": __("Project"),
- "fieldtype": "MultiSelectList",
+ fieldname: "project",
+ label: __("Project"),
+ fieldtype: "MultiSelectList",
get_data: function (txt) {
- return frappe.db.get_link_options('Project', txt);
- }
+ return frappe.db.get_link_options("Project", txt);
+ },
},
{
- "fieldname": "include_dimensions",
- "label": __("Consider Accounting Dimensions"),
- "fieldtype": "Check",
- "default": 0
+ fieldname: "include_dimensions",
+ label: __("Consider Accounting Dimensions"),
+ fieldtype: "Check",
+ default: 0,
},
{
- "fieldname": "show_opening_entries",
- "label": __("Show Opening Entries"),
- "fieldtype": "Check"
+ fieldname: "show_opening_entries",
+ label: __("Show Opening Entries"),
+ fieldtype: "Check",
},
{
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check",
- "default": 1
+ fieldname: "include_default_book_entries",
+ label: __("Include Default Book Entries"),
+ fieldtype: "Check",
+ default: 1,
},
{
- "fieldname": "show_cancelled_entries",
- "label": __("Show Cancelled Entries"),
- "fieldtype": "Check"
- }
- ]
+ fieldname: "show_cancelled_entries",
+ label: __("Show Cancelled Entries"),
+ fieldtype: "Check",
+ },
+ ],
};
-erpnext.utils.add_dimensions('General Ledger Pro', 15)
+erpnext.utils.add_dimensions("General Ledger Pro", 15);
diff --git a/csf_tz/csf_tz/report/gross_profit_pro/gross_profit_pro.js b/csf_tz/csf_tz/report/gross_profit_pro/gross_profit_pro.js
index 1e47989e..d38d17c6 100644
--- a/csf_tz/csf_tz/report/gross_profit_pro/gross_profit_pro.js
+++ b/csf_tz/csf_tz/report/gross_profit_pro/gross_profit_pro.js
@@ -3,39 +3,40 @@
/* eslint-disable */
frappe.query_reports["Gross Profit Pro"] = {
- "filters": [
+ filters: [
{
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "reqd": 1,
- "default": frappe.defaults.get_user_default("Company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ reqd: 1,
+ default: frappe.defaults.get_user_default("Company"),
},
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_start_date")
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_start_date"),
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_end_date")
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_end_date"),
},
{
- "fieldname":"sales_invoice",
- "label": __("Sales Invoice"),
- "fieldtype": "Link",
- "options": "Sales Invoice"
+ fieldname: "sales_invoice",
+ label: __("Sales Invoice"),
+ fieldtype: "Link",
+ options: "Sales Invoice",
},
{
- "fieldname":"group_by",
- "label": __("Group By"),
- "fieldtype": "Select",
- "options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject",
- "default": "Invoice"
+ fieldname: "group_by",
+ label: __("Group By"),
+ fieldtype: "Select",
+ options:
+ "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject",
+ default: "Invoice",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/csf_tz/report/import_exchange_differences/import_exchange_differences.js b/csf_tz/csf_tz/report/import_exchange_differences/import_exchange_differences.js
index 965955a1..448e2340 100644
--- a/csf_tz/csf_tz/report/import_exchange_differences/import_exchange_differences.js
+++ b/csf_tz/csf_tz/report/import_exchange_differences/import_exchange_differences.js
@@ -3,52 +3,52 @@
/* eslint-disable */
frappe.query_reports["Import Exchange Differences"] = {
- "filters": [
- {
- "fieldname": "company",
- "fieldtype": "Link",
- "label": __("Company"),
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
- },
- {
- "fieldname": "from_date",
- "fieldtype": "Date",
- "label": __("From Date"),
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1
- },
- {
- "fieldname": "to_date",
- "fieldtype": "Date",
- "label": __("To Date"),
- "default": frappe.datetime.get_today(),
- "reqd": 1
- },
- {
- "fieldname": "purchase_invoice",
- "fieldtype": "Link",
- "label": __("Purchase Invoice"),
- "options": "Purchase Invoice"
- },
- {
- "fieldname": "supplier",
- "fieldtype": "Link",
- "label": __("Supplier"),
- "options": "Supplier"
- },
- {
- "fieldname": "currency",
- "fieldtype": "Link",
- "label": __("Currency"),
- "options": "Currency"
- },
- {
- "fieldname": "status",
- "fieldtype": "Select",
- "label": __("Status"),
- "options": "\nDraft\nActive\nCompleted\nCancelled"
- }
- ]
+ filters: [
+ {
+ fieldname: "company",
+ fieldtype: "Link",
+ label: __("Company"),
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1,
+ },
+ {
+ fieldname: "from_date",
+ fieldtype: "Date",
+ label: __("From Date"),
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ },
+ {
+ fieldname: "to_date",
+ fieldtype: "Date",
+ label: __("To Date"),
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ },
+ {
+ fieldname: "purchase_invoice",
+ fieldtype: "Link",
+ label: __("Purchase Invoice"),
+ options: "Purchase Invoice",
+ },
+ {
+ fieldname: "supplier",
+ fieldtype: "Link",
+ label: __("Supplier"),
+ options: "Supplier",
+ },
+ {
+ fieldname: "currency",
+ fieldtype: "Link",
+ label: __("Currency"),
+ options: "Currency",
+ },
+ {
+ fieldname: "status",
+ fieldtype: "Select",
+ label: __("Status"),
+ options: "\nDraft\nActive\nCompleted\nCancelled",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/item_price_by_price_list/item_price_by_price_list.js b/csf_tz/csf_tz/report/item_price_by_price_list/item_price_by_price_list.js
index c5592ea2..f6198e26 100644
--- a/csf_tz/csf_tz/report/item_price_by_price_list/item_price_by_price_list.js
+++ b/csf_tz/csf_tz/report/item_price_by_price_list/item_price_by_price_list.js
@@ -3,26 +3,26 @@
/* eslint-disable */
frappe.query_reports["Item Price by Price List"] = {
- "filters": [
+ filters: [
{
- "fieldname": "item_description",
- "label": __("Item or Part of Description"),
- "fieldtype": "Data",
- "default": "",
+ fieldname: "item_description",
+ label: __("Item or Part of Description"),
+ fieldtype: "Data",
+ default: "",
},
{
- "fieldname": "tax_rate",
- "label": __("Tax Rate"),
- "fieldtype": "Percent",
- "default": "18",
- "mandatory": 1,
+ fieldname: "tax_rate",
+ label: __("Tax Rate"),
+ fieldtype: "Percent",
+ default: "18",
+ mandatory: 1,
},
- {
- "fieldname": "barcode",
- "label": __("Scan Barcode"),
- "fieldtype": "Data",
- "default": "",
- "options": "Barcode"
- },
- ]
-}
+ {
+ fieldname: "barcode",
+ label: __("Scan Barcode"),
+ fieldtype: "Data",
+ default: "",
+ options: "Barcode",
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/itemwise_stock_movement/itemwise_stock_movement.js b/csf_tz/csf_tz/report/itemwise_stock_movement/itemwise_stock_movement.js
index 0d06c8c8..b6ca68e4 100644
--- a/csf_tz/csf_tz/report/itemwise_stock_movement/itemwise_stock_movement.js
+++ b/csf_tz/csf_tz/report/itemwise_stock_movement/itemwise_stock_movement.js
@@ -3,44 +3,44 @@
/* eslint-disable */
frappe.query_reports["Itemwise Stock Movement"] = {
- "filters": [
+ filters: [
{
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ reqd: 1,
},
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ reqd: 1,
},
{
- "fieldname":"warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse",
- "reqd": 1
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
+ reqd: 1,
},
{
- "fieldname":"item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "options": "Item Group",
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ options: "Item Group",
},
{
- "fieldname":"brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "options": "Brand",
- }
- ]
-}
+ fieldname: "brand",
+ label: __("Brand"),
+ fieldtype: "Link",
+ options: "Brand",
+ },
+ ],
+};
diff --git "a/csf_tz/csf_tz/report/itx_230.01.e_\342\200\223_withholding_tax_statement/itx_230.01.e_\342\200\223_withholding_tax_statement.js" "b/csf_tz/csf_tz/report/itx_230.01.e_\342\200\223_withholding_tax_statement/itx_230.01.e_\342\200\223_withholding_tax_statement.js"
index 5b7d3246..2b3b60da 100755
--- "a/csf_tz/csf_tz/report/itx_230.01.e_\342\200\223_withholding_tax_statement/itx_230.01.e_\342\200\223_withholding_tax_statement.js"
+++ "b/csf_tz/csf_tz/report/itx_230.01.e_\342\200\223_withholding_tax_statement/itx_230.01.e_\342\200\223_withholding_tax_statement.js"
@@ -1,24 +1,24 @@
-// Copyright (c) 2016, Aakvatech and contributors
-// For license information, please see license.txt
-/* eslint-disable */
-
-frappe.query_reports["ITX 230.01.E – Withholding Tax Statement"] = {
- "filters": [
- {
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "60px"
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "60px"
- }
- ]
-}
+// Copyright (c) 2016, Aakvatech and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["ITX 230.01.E – Withholding Tax Statement"] = {
+ filters: [
+ {
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "60px",
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "60px",
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/loan_repayment_details/loan_repayment_details.js b/csf_tz/csf_tz/report/loan_repayment_details/loan_repayment_details.js
index 294d3827..946cf6a0 100644
--- a/csf_tz/csf_tz/report/loan_repayment_details/loan_repayment_details.js
+++ b/csf_tz/csf_tz/report/loan_repayment_details/loan_repayment_details.js
@@ -3,12 +3,12 @@
/* eslint-disable */
frappe.query_reports["Loan Repayment Details"] = {
- "filters": [
+ filters: [
{
- "fieldname": "employee",
- "fieldtype": "Link",
- "label": __("Employee"),
- "options": "Employee"
- }
- ]
+ fieldname: "employee",
+ fieldtype: "Link",
+ label: __("Employee"),
+ options: "Employee",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/monthly_account_balance/monthly_account_balance.js b/csf_tz/csf_tz/report/monthly_account_balance/monthly_account_balance.js
index 329918fa..8b8de72d 100644
--- a/csf_tz/csf_tz/report/monthly_account_balance/monthly_account_balance.js
+++ b/csf_tz/csf_tz/report/monthly_account_balance/monthly_account_balance.js
@@ -2,17 +2,17 @@
// For license information, please see license.txt
frappe.query_reports["Monthly Account Balance"] = {
- "filters": [
- {
- "fieldname": "account",
- "label": "Account(s)",
- "fieldtype": "MultiSelectList",
- "get_data": function(txt) {
- return frappe.db.get_link_options('Account', txt, {
- company: frappe.defaults.get_user_default("Company")
- });
- },
- "reqd": 0
- }
- ]
+ filters: [
+ {
+ fieldname: "account",
+ label: "Account(s)",
+ fieldtype: "MultiSelectList",
+ get_data: function (txt) {
+ return frappe.db.get_link_options("Account", txt, {
+ company: frappe.defaults.get_user_default("Company"),
+ });
+ },
+ reqd: 0,
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/monthly_timesheet_report/monthly_timesheet_report.js b/csf_tz/csf_tz/report/monthly_timesheet_report/monthly_timesheet_report.js
index 48ccf1ef..84f49c57 100644
--- a/csf_tz/csf_tz/report/monthly_timesheet_report/monthly_timesheet_report.js
+++ b/csf_tz/csf_tz/report/monthly_timesheet_report/monthly_timesheet_report.js
@@ -3,28 +3,28 @@
/* eslint-disable */
frappe.query_reports["Monthly Timesheet Report"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ reqd: 1,
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ reqd: 1,
},
{
- "fieldname": "hours_per_day",
- "label": __("Hours Per Day"),
- "fieldtype": "Check"
+ fieldname: "hours_per_day",
+ label: __("Hours Per Day"),
+ fieldtype: "Check",
},
{
- "fieldname": "hours_per_project",
- "label": __("Hours Per Project"),
- "fieldtype": "Check"
- }
- ]
+ fieldname: "hours_per_project",
+ label: __("Hours Per Project"),
+ fieldtype: "Check",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/multi_currency_ledger/multi_currency_ledger.js b/csf_tz/csf_tz/report/multi_currency_ledger/multi_currency_ledger.js
index 2d62d6f5..a4fe6c17 100644
--- a/csf_tz/csf_tz/report/multi_currency_ledger/multi_currency_ledger.js
+++ b/csf_tz/csf_tz/report/multi_currency_ledger/multi_currency_ledger.js
@@ -2,170 +2,174 @@
// For license information, please see license.txt
/* eslint-disable */
-
frappe.query_reports["Multi-Currency Ledger"] = {
- "filters": [
+ filters: [
{
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1,
},
{
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
+ fieldname: "finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book",
},
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "60px"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "60px",
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "60px"
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "60px",
},
{
- "fieldname":"account",
- "label": __("Account"),
- "fieldtype": "Link",
- "options": "Account",
- "get_query": function() {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "account",
+ label: __("Account"),
+ fieldtype: "Link",
+ options: "Account",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Account",
- "filters": {
- "company": company,
- }
- }
- }
+ doctype: "Account",
+ filters: {
+ company: company,
+ },
+ };
+ },
},
{
- "fieldname":"voucher_no",
- "label": __("Voucher No"),
- "fieldtype": "Data",
- on_change: function() {
- frappe.query_report.set_filter_value('group_by', "");
- }
+ fieldname: "voucher_no",
+ label: __("Voucher No"),
+ fieldtype: "Data",
+ on_change: function () {
+ frappe.query_report.set_filter_value("group_by", "");
+ },
},
{
- "fieldtype": "Break",
+ fieldtype: "Break",
},
{
- "fieldname":"party_type",
- "label": __("Party Type"),
- "fieldtype": "Link",
- "options": "Party Type",
- "default": "",
- on_change: function() {
- frappe.query_report.set_filter_value('party', "");
- }
+ fieldname: "party_type",
+ label: __("Party Type"),
+ fieldtype: "Link",
+ options: "Party Type",
+ default: "",
+ on_change: function () {
+ frappe.query_report.set_filter_value("party", "");
+ },
},
{
- "fieldname":"party",
- "label": __("Party"),
- "fieldtype": "MultiSelectList",
- get_data: function(txt) {
+ fieldname: "party",
+ label: __("Party"),
+ fieldtype: "MultiSelectList",
+ get_data: function (txt) {
if (!frappe.query_report.filters) return;
- let party_type = frappe.query_report.get_filter_value('party_type');
+ let party_type = frappe.query_report.get_filter_value("party_type");
if (!party_type) return;
return frappe.db.get_link_options(party_type, txt);
},
- on_change: function() {
- var party_type = frappe.query_report.get_filter_value('party_type');
- var parties = frappe.query_report.get_filter_value('party');
+ on_change: function () {
+ var party_type = frappe.query_report.get_filter_value("party_type");
+ var parties = frappe.query_report.get_filter_value("party");
- if(!party_type || parties.length === 0 || parties.length > 1) {
- frappe.query_report.set_filter_value('party_name', "");
- frappe.query_report.set_filter_value('tax_id', "");
+ if (!party_type || parties.length === 0 || parties.length > 1) {
+ frappe.query_report.set_filter_value("party_name", "");
+ frappe.query_report.set_filter_value("tax_id", "");
return;
} else {
var party = parties[0];
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
- frappe.db.get_value(party_type, party, fieldname, function(value) {
- frappe.query_report.set_filter_value('party_name', value[fieldname]);
+ frappe.db.get_value(party_type, party, fieldname, function (value) {
+ frappe.query_report.set_filter_value("party_name", value[fieldname]);
});
if (party_type === "Customer" || party_type === "Supplier") {
- frappe.db.get_value(party_type, party, "tax_id", function(value) {
- frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
+ frappe.db.get_value(party_type, party, "tax_id", function (value) {
+ frappe.query_report.set_filter_value("tax_id", value["tax_id"]);
});
}
}
- }
+ },
},
{
- "fieldname":"party_name",
- "label": __("Party Name"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "party_name",
+ label: __("Party Name"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname":"group_by",
- "label": __("Group by"),
- "fieldtype": "Select",
- "options": ["", __("Group by Voucher"), __("Group by Voucher (Consolidated)"),
- __("Group by Account"), __("Group by Party")],
- "default": __("Group by Voucher (Consolidated)")
+ fieldname: "group_by",
+ label: __("Group by"),
+ fieldtype: "Select",
+ options: [
+ "",
+ __("Group by Voucher"),
+ __("Group by Voucher (Consolidated)"),
+ __("Group by Account"),
+ __("Group by Party"),
+ ],
+ default: __("Group by Voucher (Consolidated)"),
},
{
- "fieldname":"tax_id",
- "label": __("Tax Id"),
- "fieldtype": "Data",
- "hidden": 1
+ fieldname: "tax_id",
+ label: __("Tax Id"),
+ fieldtype: "Data",
+ hidden: 1,
},
{
- "fieldname": "presentation_currency",
- "label": __("Currency"),
- "fieldtype": "Select",
- "options": erpnext.get_presentation_currency_list()
+ fieldname: "presentation_currency",
+ label: __("Currency"),
+ fieldtype: "Select",
+ options: erpnext.get_presentation_currency_list(),
},
{
- "fieldname":"cost_center",
- "label": __("Cost Center"),
- "fieldtype": "MultiSelectList",
- get_data: function(txt) {
- return frappe.db.get_link_options('Cost Center', txt);
- }
+ fieldname: "cost_center",
+ label: __("Cost Center"),
+ fieldtype: "MultiSelectList",
+ get_data: function (txt) {
+ return frappe.db.get_link_options("Cost Center", txt);
+ },
},
{
- "fieldname":"project",
- "label": __("Project"),
- "fieldtype": "MultiSelectList",
- get_data: function(txt) {
- return frappe.db.get_link_options('Project', txt);
- }
+ fieldname: "project",
+ label: __("Project"),
+ fieldtype: "MultiSelectList",
+ get_data: function (txt) {
+ return frappe.db.get_link_options("Project", txt);
+ },
},
{
- "fieldname": "show_opening_entries",
- "label": __("Show Opening Entries"),
- "fieldtype": "Check"
+ fieldname: "show_opening_entries",
+ label: __("Show Opening Entries"),
+ fieldtype: "Check",
},
{
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check"
- }
- ]
-}
+ fieldname: "include_default_book_entries",
+ label: __("Include Default Book Entries"),
+ fieldtype: "Check",
+ },
+ ],
+};
erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Multi-Currency Ledger"].filters.splice(15, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
+ frappe.query_reports["Multi-Currency Ledger"].filters.splice(15, 0, {
+ fieldname: dimension["fieldname"],
+ label: __(dimension["label"]),
+ fieldtype: "Link",
+ options: dimension["document_type"],
});
});
diff --git a/csf_tz/csf_tz/report/output_vat_reconciliation/output_vat_reconciliation.js b/csf_tz/csf_tz/report/output_vat_reconciliation/output_vat_reconciliation.js
index 117b7786..10139054 100644
--- a/csf_tz/csf_tz/report/output_vat_reconciliation/output_vat_reconciliation.js
+++ b/csf_tz/csf_tz/report/output_vat_reconciliation/output_vat_reconciliation.js
@@ -3,27 +3,31 @@
/* eslint-disable */
frappe.query_reports["Output VAT Reconciliation"] = {
- "filters": [
+ filters: [
{
- "fieldname":"efd_report",
- "label": __("EFD Report"),
- "fieldtype": "Link",
- "options": "EFD Z Report",
- "reqd": 1,
- "get_query" : function(){
+ fieldname: "efd_report",
+ label: __("EFD Report"),
+ fieldtype: "Link",
+ options: "EFD Z Report",
+ reqd: 1,
+ get_query: function () {
return {
- "filters":{
- "docstatus":1,
- }
- }
- }
- }
+ filters: {
+ docstatus: 1,
+ },
+ };
+ },
+ },
],
- "formatter": function(value, row, column, data, default_formatter) {
- value = default_formatter(value, row, column, data);
- if (value === "Credit Note - Sales Returns" || value === "Sales - Sales Returns" || value === "Sales as VAT Returns" ){
- value = '
'+value+'';
- }
- return value;
- }
+ formatter: function (value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+ if (
+ value === "Credit Note - Sales Returns" ||
+ value === "Sales - Sales Returns" ||
+ value === "Sales as VAT Returns"
+ ) {
+ value = '
' + value + "";
+ }
+ return value;
+ },
};
diff --git a/csf_tz/csf_tz/report/particular_item_history_report/particular_item_history_report.js b/csf_tz/csf_tz/report/particular_item_history_report/particular_item_history_report.js
index 852451fa..f9f63ef9 100644
--- a/csf_tz/csf_tz/report/particular_item_history_report/particular_item_history_report.js
+++ b/csf_tz/csf_tz/report/particular_item_history_report/particular_item_history_report.js
@@ -3,40 +3,40 @@
/* eslint-disable */
frappe.query_reports["Particular Item History Report"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.month_start(),
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.month_start(),
+ reqd: 1,
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
},
{
- "fieldname": "price_list",
- "label": __("Price List"),
- "fieldtype": "Link",
- "options": "Price List",
- "get_query": () => {
+ fieldname: "price_list",
+ label: __("Price List"),
+ fieldtype: "Link",
+ options: "Price List",
+ get_query: () => {
return {
filters: {
- "selling": 1,
- "enabled": 1
- }
+ selling: 1,
+ enabled: 1,
+ },
};
- }
+ },
},
{
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse"
- }
- ]
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/paye_report_mapping/paye_report_mapping.js b/csf_tz/csf_tz/report/paye_report_mapping/paye_report_mapping.js
index 7831f6fe..79ce1f2c 100644
--- a/csf_tz/csf_tz/report/paye_report_mapping/paye_report_mapping.js
+++ b/csf_tz/csf_tz/report/paye_report_mapping/paye_report_mapping.js
@@ -2,20 +2,20 @@
// For license information, please see license.txt
frappe.query_reports["PAYE Report Mapping"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "reqd": 1,
- "default": frappe.datetime.month_start()
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ reqd: 1,
+ default: frappe.datetime.month_start(),
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "reqd": 1,
- "default": frappe.datetime.month_end()
- }
- ]
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ reqd: 1,
+ default: frappe.datetime.month_end(),
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/salary_register_csf/salary_register_csf.js b/csf_tz/csf_tz/report/salary_register_csf/salary_register_csf.js
index eecfa370..35bed5ee 100644
--- a/csf_tz/csf_tz/report/salary_register_csf/salary_register_csf.js
+++ b/csf_tz/csf_tz/report/salary_register_csf/salary_register_csf.js
@@ -3,90 +3,89 @@
/* eslint-disable */
frappe.query_reports["Salary Register csf"] = {
- onload: function (report) {
- report.page.add_inner_button(__("Approve"), function () {
- return frappe.call({
- method:
- "csf_tz.csf_tz.report.salary_register_csf.salary_register_csf.approve",
- args: { data: report.data },
- callback: function (r) {
- frappe.msgprint("Starting Approve Processing");
- console.info(r.message);
- },
- });
- });
- },
- "filters": [
- {
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "width": "100px",
- "reqd": 1
- },
- {
- "fieldname": "from_date",
- "label": __("From"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "100px"
- },
- {
- "fieldname": "to_date",
- "label": __("To"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "100px"
- },
- {
- "fieldname": "currency",
- "fieldtype": "Link",
- "options": "Currency",
- "label": __("Currency"),
- "default": erpnext.get_currency(frappe.defaults.get_default("Company")),
- "width": "50px",
- "reqd": 1
- },
- {
- "fieldname": "employee",
- "label": __("Employee"),
- "fieldtype": "Link",
- "options": "Employee",
- "width": "100px"
- },
- {
- fieldname: "department",
- label: __("Department"),
- fieldtype: "Link",
- options: "Department",
- default: "",
- width: "100px",
- get_query: function () {
- var company = frappe.query_report.get_filter_value("company");
- return {
- doctype: "Department",
- filters: {
- company: company,
- },
- };
- },
- },
- {
- "fieldname": "docstatus",
- "label": __("Document Status"),
- "fieldtype": "Select",
- "options": ["Draft", "Submitted", "Cancelled"],
- "default": "Submitted",
- "width": "100px"
- },
- {
- "fieldname": "multi_currency",
- "label": __("Multi Currency"),
- "fieldtype": "Check",
- }
- ]
+ onload: function (report) {
+ report.page.add_inner_button(__("Approve"), function () {
+ return frappe.call({
+ method: "csf_tz.csf_tz.report.salary_register_csf.salary_register_csf.approve",
+ args: { data: report.data },
+ callback: function (r) {
+ frappe.msgprint("Starting Approve Processing");
+ console.info(r.message);
+ },
+ });
+ });
+ },
+ filters: [
+ {
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
+ },
+ {
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
+ },
+ {
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
+ },
+ {
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
+ reqd: 1,
+ },
+ {
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
+ },
+ {
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
+ return {
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
+ };
+ },
+ },
+ {
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
+ },
+ {
+ fieldname: "multi_currency",
+ label: __("Multi Currency"),
+ fieldtype: "Check",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/salary_register_ctc/salary_register_ctc.js b/csf_tz/csf_tz/report/salary_register_ctc/salary_register_ctc.js
index 381f1a4f..e18a2fe6 100644
--- a/csf_tz/csf_tz/report/salary_register_ctc/salary_register_ctc.js
+++ b/csf_tz/csf_tz/report/salary_register_ctc/salary_register_ctc.js
@@ -5,77 +5,77 @@
frappe.query_reports["Salary Register CTC"] = {
filters: [
{
- fieldname: "from_date",
- label: __("From"),
- fieldtype: "Date",
- default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- reqd: 1,
- width: "100px",
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
},
{
- fieldname: "to_date",
- label: __("To"),
- fieldtype: "Date",
- default: frappe.datetime.get_today(),
- reqd: 1,
- width: "100px",
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
},
{
- fieldname: "currency",
- fieldtype: "Link",
- options: "Currency",
- label: __("Currency"),
- default: erpnext.get_currency(frappe.defaults.get_default("Company")),
- width: "50px",
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
},
{
- fieldname: "employee",
- label: __("Employee"),
- fieldtype: "Link",
- options: "Employee",
- width: "100px",
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
},
{
- fieldname: "company",
- label: __("Company"),
- fieldtype: "Link",
- options: "Company",
- default: frappe.defaults.get_user_default("Company"),
- width: "100px",
- reqd: 1,
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
},
{
- fieldname: "department",
- label: __("Department"),
- fieldtype: "Link",
- options: "Department",
- default: "",
- width: "100px",
- get_query: function () {
- var company = frappe.query_report.get_filter_value("company");
- return {
- doctype: "Department",
- filters: {
- company: company,
- },
- };
- },
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
+ return {
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
+ };
+ },
},
{
- fieldname: "docstatus",
- label: __("Document Status"),
- fieldtype: "Select",
- options: ["Draft", "Submitted", "Cancelled"],
- default: "Submitted",
- width: "100px",
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
},
{
- fieldname: "workflow_state",
- label: __("Workflow"),
- fieldtype: "Select",
- options: ["", "Pending", "Approved", "Rejected"],
- // default: "Pending",
- width: "100px",
+ fieldname: "workflow_state",
+ label: __("Workflow"),
+ fieldtype: "Select",
+ options: ["", "Pending", "Approved", "Rejected"],
+ // default: "Pending",
+ width: "100px",
},
- ],
+ ],
};
diff --git a/csf_tz/csf_tz/report/salary_register_summary/salary_register_summary.js b/csf_tz/csf_tz/report/salary_register_summary/salary_register_summary.js
index 0f0d3d4c..9de61064 100644
--- a/csf_tz/csf_tz/report/salary_register_summary/salary_register_summary.js
+++ b/csf_tz/csf_tz/report/salary_register_summary/salary_register_summary.js
@@ -3,71 +3,71 @@
/* eslint-disable */
frappe.query_reports["Salary Register Summary"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "100px"
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "to_date",
- "label": __("To"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "100px"
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "currency",
- "fieldtype": "Link",
- "options": "Currency",
- "label": __("Currency"),
- "default": erpnext.get_currency(frappe.defaults.get_default("Company")),
- "width": "50px"
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
},
{
- "fieldname": "employee",
- "label": __("Employee"),
- "fieldtype": "Link",
- "options": "Employee",
- "width": "100px"
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
},
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "width": "100px",
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
},
{
- "fieldname": "department",
- "label": __("Department"),
- "fieldtype": "Link",
- "options": "Department",
- "default": "",
- "width": "100px",
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Department",
- "filters": {
- "company": company,
- }
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
};
- }
+ },
},
{
- "fieldname": "docstatus",
- "label": __("Document Status"),
- "fieldtype": "Select",
- "options": ["Draft", "Submitted", "Cancelled"],
- "default": "Submitted",
- "width": "100px"
- }
- ]
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/salary_register_summary_with_components/salary_register_summary_with_components.js b/csf_tz/csf_tz/report/salary_register_summary_with_components/salary_register_summary_with_components.js
index d9399ba4..b18660a7 100644
--- a/csf_tz/csf_tz/report/salary_register_summary_with_components/salary_register_summary_with_components.js
+++ b/csf_tz/csf_tz/report/salary_register_summary_with_components/salary_register_summary_with_components.js
@@ -3,71 +3,71 @@
/* eslint-disable */
frappe.query_reports["Salary Register Summary with Components"] = {
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "100px"
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "to_date",
- "label": __("To"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "100px"
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "currency",
- "fieldtype": "Link",
- "options": "Currency",
- "label": __("Currency"),
- "default": erpnext.get_currency(frappe.defaults.get_default("Company")),
- "width": "50px"
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
},
{
- "fieldname": "employee",
- "label": __("Employee"),
- "fieldtype": "Link",
- "options": "Employee",
- "width": "100px"
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
},
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "width": "100px",
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
},
{
- "fieldname": "department",
- "label": __("Department"),
- "fieldtype": "Link",
- "options": "Department",
- "default": "",
- "width": "100px",
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Department",
- "filters": {
- "company": company,
- }
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
};
- }
+ },
},
{
- "fieldname": "docstatus",
- "label": __("Document Status"),
- "fieldtype": "Select",
- "options": ["Draft", "Submitted", "Cancelled"],
- "default": "Submitted",
- "width": "100px"
- }
- ]
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/salary_register_summary_with_monthly_comparison/salary_register_summary_with_monthly_comparison.js b/csf_tz/csf_tz/report/salary_register_summary_with_monthly_comparison/salary_register_summary_with_monthly_comparison.js
index 4e5eece1..140d0c75 100644
--- a/csf_tz/csf_tz/report/salary_register_summary_with_monthly_comparison/salary_register_summary_with_monthly_comparison.js
+++ b/csf_tz/csf_tz/report/salary_register_summary_with_monthly_comparison/salary_register_summary_with_monthly_comparison.js
@@ -3,146 +3,144 @@
/* eslint-disable */
frappe.query_reports["Salary Register Summary with Monthly Comparison"] = {
- "onload": function (report) {
- frappe.query_report.set_filter_value('based_on_department', 1);
- var department = frappe.query_report.get_filter('department');
+ onload: function (report) {
+ frappe.query_report.set_filter_value("based_on_department", 1);
+ var department = frappe.query_report.get_filter("department");
department.df.hidden = 0;
department.refresh();
},
- "filters": [
+ filters: [
{
- "fieldname": "from_date",
- "label": __("From"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "100px"
+ fieldname: "from_date",
+ label: __("From"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "to_date",
- "label": __("To"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "100px"
+ fieldname: "to_date",
+ label: __("To"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "100px",
},
{
- "fieldname": "currency",
- "fieldtype": "Link",
- "options": "Currency",
- "label": __("Currency"),
- "default": erpnext.get_currency(frappe.defaults.get_default("Company")),
- "width": "50px"
+ fieldname: "currency",
+ fieldtype: "Link",
+ options: "Currency",
+ label: __("Currency"),
+ default: erpnext.get_currency(frappe.defaults.get_default("Company")),
+ width: "50px",
},
{
- "fieldname": "employee",
- "label": __("Employee"),
- "fieldtype": "Link",
- "options": "Employee",
- "width": "100px"
+ fieldname: "employee",
+ label: __("Employee"),
+ fieldtype: "Link",
+ options: "Employee",
+ width: "100px",
},
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "width": "100px",
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ width: "100px",
+ reqd: 1,
},
{
- "fieldname": "docstatus",
- "label": __("Document Status"),
- "fieldtype": "Select",
- "options": ["Draft", "Submitted", "Cancelled"],
- "default": "Submitted",
- "width": "100px"
+ fieldname: "docstatus",
+ label: __("Document Status"),
+ fieldtype: "Select",
+ options: ["Draft", "Submitted", "Cancelled"],
+ default: "Submitted",
+ width: "100px",
},
{
- "fieldname": "based_on_department",
- "label": __("Based on Department"),
- "fieldtype": "Check",
+ fieldname: "based_on_department",
+ label: __("Based on Department"),
+ fieldtype: "Check",
// "default": 1,
on_change: function () {
- var based_on_department = frappe.query_report.get_filter_value('based_on_department');
- var cost_center = frappe.query_report.get_filter('cost_center');
- var department = frappe.query_report.get_filter('department');
+ var based_on_department = frappe.query_report.get_filter_value("based_on_department");
+ var cost_center = frappe.query_report.get_filter("cost_center");
+ var department = frappe.query_report.get_filter("department");
if (based_on_department) {
- frappe.query_report.set_filter_value('based_on_cost_center', 0);
- frappe.query_report.set_filter_value('cost_center', '');
+ frappe.query_report.set_filter_value("based_on_cost_center", 0);
+ frappe.query_report.set_filter_value("cost_center", "");
cost_center.df.hidden = 1;
department.df.hidden = 0;
- }
- else {
- frappe.query_report.set_filter_value('based_on_cost_center', 1);
- frappe.query_report.set_filter_value('department', '');
+ } else {
+ frappe.query_report.set_filter_value("based_on_cost_center", 1);
+ frappe.query_report.set_filter_value("department", "");
department.df.hidden = 1;
cost_center.df.hidden = 0;
}
cost_center.refresh();
department.refresh();
- }
+ },
},
{
- "fieldname": "department",
- "label": __("Department"),
- "fieldtype": "Link",
- "options": "Department",
- "default": "",
- "width": "100px",
- "hidden": 1,
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "department",
+ label: __("Department"),
+ fieldtype: "Link",
+ options: "Department",
+ default: "",
+ width: "100px",
+ hidden: 1,
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Department",
- "filters": {
- "company": company,
- }
+ doctype: "Department",
+ filters: {
+ company: company,
+ },
};
- }
+ },
},
{
- "fieldname": "based_on_cost_center",
- "label": __("Based on Cost Center"),
- "fieldtype": "Check",
- "default": 0,
+ fieldname: "based_on_cost_center",
+ label: __("Based on Cost Center"),
+ fieldtype: "Check",
+ default: 0,
on_change: function () {
- var based_on_cost_center = frappe.query_report.get_filter_value('based_on_cost_center');
- var cost_center = frappe.query_report.get_filter('cost_center');
- var department = frappe.query_report.get_filter('department');
+ var based_on_cost_center = frappe.query_report.get_filter_value("based_on_cost_center");
+ var cost_center = frappe.query_report.get_filter("cost_center");
+ var department = frappe.query_report.get_filter("department");
if (based_on_cost_center) {
- frappe.query_report.set_filter_value('based_on_department', 0);
- frappe.query_report.set_filter_value('department', '');
+ frappe.query_report.set_filter_value("based_on_department", 0);
+ frappe.query_report.set_filter_value("department", "");
department.df.hidden = 1;
cost_center.df.hidden = 0;
- }
- else {
- frappe.query_report.set_filter_value('based_on_department', 1);
- frappe.query_report.set_filter_value('cost_center', '');
+ } else {
+ frappe.query_report.set_filter_value("based_on_department", 1);
+ frappe.query_report.set_filter_value("cost_center", "");
cost_center.df.hidden = 1;
department.df.hidden = 0;
}
cost_center.refresh();
department.refresh();
- }
+ },
},
{
- "fieldname": "cost_center",
- "label": __("Cost Center"),
- "fieldtype": "Link",
- "options": "Cost Center",
- "default": "",
- "width": "100px",
- "hidden": 1,
- "get_query": function () {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "cost_center",
+ label: __("Cost Center"),
+ fieldtype: "Link",
+ options: "Cost Center",
+ default: "",
+ width: "100px",
+ hidden: 1,
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Cost Center",
- "filters": {
- "company": company,
- }
+ doctype: "Cost Center",
+ filters: {
+ company: company,
+ },
};
- }
+ },
},
- ]
+ ],
};
diff --git a/csf_tz/csf_tz/report/stock_balance_pivot_warehouse/stock_balance_pivot_warehouse.js b/csf_tz/csf_tz/report/stock_balance_pivot_warehouse/stock_balance_pivot_warehouse.js
index 660f7fae..089c637a 100644
--- a/csf_tz/csf_tz/report/stock_balance_pivot_warehouse/stock_balance_pivot_warehouse.js
+++ b/csf_tz/csf_tz/report/stock_balance_pivot_warehouse/stock_balance_pivot_warehouse.js
@@ -3,49 +3,49 @@
/* eslint-disable */
frappe.query_reports["Stock Balance pivot warehouse"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.get_today()
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.get_today(),
},
{
- "fieldname": "item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item Group"
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item Group",
},
{
- "fieldname": "item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item"
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item",
},
{
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse"
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse",
},
{
- "fieldname": "filter_total_zero_qty",
- "label": __("Filter Total Zero Qty"),
- "fieldtype": "Check",
- "default": 1
+ fieldname: "filter_total_zero_qty",
+ label: __("Filter Total Zero Qty"),
+ fieldtype: "Check",
+ default: 1,
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/csf_tz/report/stock_balance_pro/stock_balance_pro.js b/csf_tz/csf_tz/report/stock_balance_pro/stock_balance_pro.js
index c84a0752..f4017169 100644
--- a/csf_tz/csf_tz/report/stock_balance_pro/stock_balance_pro.js
+++ b/csf_tz/csf_tz/report/stock_balance_pro/stock_balance_pro.js
@@ -3,97 +3,96 @@
/* eslint-disable */
frappe.query_reports["Stock Balance Pro"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Company",
- "default": frappe.defaults.get_default("company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Company",
+ default: frappe.defaults.get_default("company"),
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.get_today()
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.get_today(),
},
{
- "fieldname": "item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item Group"
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item Group",
},
{
- "fieldname": "item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item",
- "get_query": function () {
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item",
+ get_query: function () {
return {
query: "erpnext.controllers.queries.item_query",
};
- }
+ },
},
{
- "fieldname": "warehouse_type",
- "label": __("Warehouse Type"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse Type"
+ fieldname: "warehouse_type",
+ label: __("Warehouse Type"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse Type",
},
{
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse",
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse",
get_query: () => {
- var warehouse_type = frappe.query_report.get_filter_value('warehouse_type');
+ var warehouse_type = frappe.query_report.get_filter_value("warehouse_type");
if (warehouse_type) {
return {
filters: {
- 'warehouse_type': warehouse_type
- }
+ warehouse_type: warehouse_type,
+ },
};
}
- }
+ },
},
{
- "fieldname": "include_uom",
- "label": __("Include UOM"),
- "fieldtype": "Link",
- "options": "UOM"
+ fieldname: "include_uom",
+ label: __("Include UOM"),
+ fieldtype: "Link",
+ options: "UOM",
},
{
- "fieldname": "show_variant_attributes",
- "label": __("Show Variant Attributes"),
- "fieldtype": "Check"
+ fieldname: "show_variant_attributes",
+ label: __("Show Variant Attributes"),
+ fieldtype: "Check",
},
],
- "formatter": function (value, row, column, data, default_formatter) {
+ formatter: function (value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (column.fieldname == "out_qty" && data && data.out_qty > 0) {
value = "
" + value + "";
- }
- else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
+ } else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
value = "
" + value + "";
}
return value;
- }
+ },
};
diff --git a/csf_tz/csf_tz/report/tra_input_vat_returns_efiling/tra_input_vat_returns_efiling.js b/csf_tz/csf_tz/report/tra_input_vat_returns_efiling/tra_input_vat_returns_efiling.js
index 056b1013..93ab445a 100644
--- a/csf_tz/csf_tz/report/tra_input_vat_returns_efiling/tra_input_vat_returns_efiling.js
+++ b/csf_tz/csf_tz/report/tra_input_vat_returns_efiling/tra_input_vat_returns_efiling.js
@@ -3,19 +3,19 @@
/* eslint-disable */
frappe.query_reports["TRA Input VAT Returns eFiling"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "width": "80"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ width: "80",
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today()
- }
- ]
-}
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/trial_balance_report_in_usd/trial_balance_report_in_usd.js b/csf_tz/csf_tz/report/trial_balance_report_in_usd/trial_balance_report_in_usd.js
index dd229939..c44d08bd 100644
--- a/csf_tz/csf_tz/report/trial_balance_report_in_usd/trial_balance_report_in_usd.js
+++ b/csf_tz/csf_tz/report/trial_balance_report_in_usd/trial_balance_report_in_usd.js
@@ -2,105 +2,105 @@
// For license information, please see license.txt
/* eslint-disable */
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
+frappe.require("assets/erpnext/js/financial_statements.js", function () {
frappe.query_reports["Trial Balance Report in USD"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1,
},
{
- "fieldname": "fiscal_year",
- "label": __("Fiscal Year"),
- "fieldtype": "Link",
- "options": "Fiscal Year",
- "default": frappe.defaults.get_user_default("fiscal_year"),
- "reqd": 1,
- "on_change": function(query_report) {
+ fieldname: "fiscal_year",
+ label: __("Fiscal Year"),
+ fieldtype: "Link",
+ options: "Fiscal Year",
+ default: frappe.defaults.get_user_default("fiscal_year"),
+ reqd: 1,
+ on_change: function (query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
if (!fiscal_year) {
return;
}
- frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function (r) {
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
frappe.query_report.set_filter_value({
from_date: fy.year_start_date,
- to_date: fy.year_end_date
+ to_date: fy.year_end_date,
});
});
- }
+ },
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_start_date"),
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_start_date"),
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_end_date"),
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_end_date"),
},
{
- "fieldname":"cost_center",
- "label": __("Cost Center"),
- "fieldtype": "Link",
- "options": "Cost Center",
- "get_query": function() {
- var company = frappe.query_report.get_filter_value('company');
+ fieldname: "cost_center",
+ label: __("Cost Center"),
+ fieldtype: "Link",
+ options: "Cost Center",
+ get_query: function () {
+ var company = frappe.query_report.get_filter_value("company");
return {
- "doctype": "Cost Center",
- "filters": {
- "company": company,
- }
- }
- }
+ doctype: "Cost Center",
+ filters: {
+ company: company,
+ },
+ };
+ },
},
{
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book",
+ fieldname: "finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book",
},
{
- "fieldname": "with_period_closing_entry",
- "label": __("Period Closing Entry"),
- "fieldtype": "Check",
- "default": 1
+ fieldname: "with_period_closing_entry",
+ label: __("Period Closing Entry"),
+ fieldtype: "Check",
+ default: 1,
},
{
- "fieldname": "show_zero_values",
- "label": __("Show zero values"),
- "fieldtype": "Check"
+ fieldname: "show_zero_values",
+ label: __("Show zero values"),
+ fieldtype: "Check",
},
{
- "fieldname": "show_unclosed_fy_pl_balances",
- "label": __("Show unclosed fiscal year's P&L balances"),
- "fieldtype": "Check"
+ fieldname: "show_unclosed_fy_pl_balances",
+ label: __("Show unclosed fiscal year's P&L balances"),
+ fieldtype: "Check",
},
{
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check"
- }
+ fieldname: "include_default_book_entries",
+ label: __("Include Default Book Entries"),
+ fieldtype: "Check",
+ },
],
- "formatter": erpnext.financial_statements.formatter,
- "tree": true,
- "name_field": "account",
- "parent_field": "parent_account",
- "initial_depth": 3
+ formatter: erpnext.financial_statements.formatter,
+ tree: true,
+ name_field: "account",
+ parent_field: "parent_account",
+ initial_depth: 3,
};
erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Trial Balance Eport in USD"].filters.splice(5, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
+ frappe.query_reports["Trial Balance Eport in USD"].filters.splice(5, 0, {
+ fieldname: dimension["fieldname"],
+ label: __(dimension["label"]),
+ fieldtype: "Link",
+ options: dimension["document_type"],
});
});
});
diff --git a/csf_tz/csf_tz/report/vat_efiling_returns/vat_efiling_returns.js b/csf_tz/csf_tz/report/vat_efiling_returns/vat_efiling_returns.js
index 7d6aa99f..44424692 100644
--- a/csf_tz/csf_tz/report/vat_efiling_returns/vat_efiling_returns.js
+++ b/csf_tz/csf_tz/report/vat_efiling_returns/vat_efiling_returns.js
@@ -3,30 +3,30 @@
/* eslint-disable */
frappe.query_reports["VAT eFiling Returns"] = {
- "filters": [
+ filters: [
{
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "reqd": 1,
- "default": frappe.defaults.get_user_default("company")
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ reqd: 1,
+ default: frappe.defaults.get_user_default("company"),
},
{
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- "reqd": 1,
- "width": "60px"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ reqd: 1,
+ width: "60px",
},
{
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.datetime.get_today(),
- "reqd": 1,
- "width": "60px"
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ width: "60px",
},
- ]
+ ],
};
diff --git a/csf_tz/csf_tz/report/warehouse_wise_item_balance_and_value/warehouse_wise_item_balance_and_value.js b/csf_tz/csf_tz/report/warehouse_wise_item_balance_and_value/warehouse_wise_item_balance_and_value.js
index 457a9adb..c73cc460 100644
--- a/csf_tz/csf_tz/report/warehouse_wise_item_balance_and_value/warehouse_wise_item_balance_and_value.js
+++ b/csf_tz/csf_tz/report/warehouse_wise_item_balance_and_value/warehouse_wise_item_balance_and_value.js
@@ -3,58 +3,58 @@
/* eslint-disable */
frappe.query_reports["Warehouse wise Item Balance and Value"] = {
- "filters": [
-{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "width": "80",
- "reqd": 1,
- "default": frappe.datetime.get_today()
- },
- {
- "fieldname": "item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item Group",
- "default": "Vouchers"
- },
- {
- "fieldname": "brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Brand",
- "default": "Halotel"
- },
- {
- "fieldname": "item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Item"
- },
- {
- "fieldname": "warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "width": "80",
- "options": "Warehouse"
- },
- {
- "fieldname": "filter_total_zero_qty",
- "label": __("Filter Total Zero Qty"),
- "fieldtype": "Check",
- "default": 1
- },
- ]
-}
+ filters: [
+ {
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ width: "80",
+ reqd: 1,
+ default: frappe.datetime.get_today(),
+ },
+ {
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item Group",
+ default: "Vouchers",
+ },
+ {
+ fieldname: "brand",
+ label: __("Brand"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Brand",
+ default: "Halotel",
+ },
+ {
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Item",
+ },
+ {
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ width: "80",
+ options: "Warehouse",
+ },
+ {
+ fieldname: "filter_total_zero_qty",
+ label: __("Filter Total Zero Qty"),
+ fieldtype: "Check",
+ default: 1,
+ },
+ ],
+};
diff --git a/csf_tz/csf_tz/report/withholding_tax_payment_summary/withholding_tax_payment_summary.js b/csf_tz/csf_tz/report/withholding_tax_payment_summary/withholding_tax_payment_summary.js
index d673eb90..4525b6ef 100644
--- a/csf_tz/csf_tz/report/withholding_tax_payment_summary/withholding_tax_payment_summary.js
+++ b/csf_tz/csf_tz/report/withholding_tax_payment_summary/withholding_tax_payment_summary.js
@@ -3,13 +3,13 @@
/* eslint-disable */
frappe.query_reports["Withholding Tax Payment Summary"] = {
- "filters": [
+ filters: [
{
- "fieldname": "rental",
- "label": __("Rental"),
- "fieldtype": "Select",
- "options": "Commercial Rent\nResidential Rent",
- "default": "Commercial Rent"
- }
- ]
+ fieldname: "rental",
+ label: __("Rental"),
+ fieldtype: "Select",
+ options: "Commercial Rent\nResidential Rent",
+ default: "Commercial Rent",
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/report/withholding_tax_summary_on_sales/withholding_tax_summary_on_sales.js b/csf_tz/csf_tz/report/withholding_tax_summary_on_sales/withholding_tax_summary_on_sales.js
index 61209a22..cb5e8114 100644
--- a/csf_tz/csf_tz/report/withholding_tax_summary_on_sales/withholding_tax_summary_on_sales.js
+++ b/csf_tz/csf_tz/report/withholding_tax_summary_on_sales/withholding_tax_summary_on_sales.js
@@ -3,18 +3,18 @@
/* eslint-disable */
frappe.query_reports["Withholding Tax Summary on Sales"] = {
- "filters": [
- {
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_start_date"),
- },
- {
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": frappe.defaults.get_user_default("year_end_date"),
- },
- ]
+ filters: [
+ {
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_start_date"),
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_end_date"),
+ },
+ ],
};
diff --git a/csf_tz/csf_tz/salary_slip.js b/csf_tz/csf_tz/salary_slip.js
index 74cd8d0a..e5c887c3 100644
--- a/csf_tz/csf_tz/salary_slip.js
+++ b/csf_tz/csf_tz/salary_slip.js
@@ -1,70 +1,68 @@
frappe.ui.form.on("Salary Slip", {
- setup: function(frm) {
- if (frm.doc.has_payroll_approval == 1) {
- $('[data-label="Submit"]').parent().hide();
- $('[data-label="Approve"]').parent().hide();
- $('[data-label="Reject"]').parent().hide();
- $('[data-label="Cancel"]').parent().hide();
- }
+ setup: function (frm) {
+ if (frm.doc.has_payroll_approval == 1) {
+ $('[data-label="Submit"]').parent().hide();
+ $('[data-label="Approve"]').parent().hide();
+ $('[data-label="Reject"]').parent().hide();
+ $('[data-label="Cancel"]').parent().hide();
+ }
+ },
+ refresh: function (frm) {
+ if (frm.doc.has_payroll_approval == 1) {
+ $('[data-label="Submit"]').parent().hide();
+ $('[data-label="Approve"]').parent().hide();
+ $('[data-label="Reject"]').parent().hide();
+ $('[data-label="Cancel"]').parent().hide();
- },
- refresh:function(frm) {
- if (frm.doc.has_payroll_approval == 1) {
- $('[data-label="Submit"]').parent().hide();
- $('[data-label="Approve"]').parent().hide();
- $('[data-label="Reject"]').parent().hide();
- $('[data-label="Cancel"]').parent().hide();
+ if (frm.doc.workflow_state == "Open") {
+ frm.trigger("create_update_slip_btn");
+ } else if (frm.doc.workflow_state == "Ongoing Approval") {
+ frm.clear_custom_buttons();
+ frm.set_intro("");
+ frm.disable_form();
+ frm.set_intro(__("This Salary Slip is awaiting approval."));
+ }
+ } else {
+ frm.trigger("create_update_slip_btn");
+ }
+ },
- if (frm.doc.workflow_state == "Open") {
- frm.trigger("create_update_slip_btn");
- } else if (frm.doc.workflow_state == "Ongoing Approval") {
- frm.clear_custom_buttons();
- frm.set_intro("");
- frm.disable_form();
- frm.set_intro(__("This Salary Slip is awaiting approval."));
- }
+ onload: (frm) => {
+ if (frm.doc.workflow_state == "Open") {
+ frm.trigger("create_update_slip_btn");
+ } else if (frm.doc.has_payroll_approval == 1) {
+ $('[data-label="Submit"]').parent().hide();
+ $('[data-label="Approve"]').parent().hide();
+ $('[data-label="Reject"]').parent().hide();
+ $('[data-label="Cancel"]').parent().hide();
- } else {
- frm.trigger("create_update_slip_btn");
- }
- },
+ if (frm.doc.workflow_state == "Ongoing Approval") {
+ frm.clear_custom_buttons();
+ frm.set_intro("");
+ frm.disable_form();
+ frm.set_intro(__("This Salary Slip is awaiting approval."));
+ }
+ } else {
+ frm.trigger("create_update_slip_btn");
+ }
+ },
- onload: (frm) => {
- if (frm.doc.workflow_state == "Open") {
- frm.trigger("create_update_slip_btn");
- } else if (frm.doc.has_payroll_approval == 1) {
- $('[data-label="Submit"]').parent().hide();
- $('[data-label="Approve"]').parent().hide();
- $('[data-label="Reject"]').parent().hide();
- $('[data-label="Cancel"]').parent().hide();
-
- if (frm.doc.workflow_state == "Ongoing Approval") {
- frm.clear_custom_buttons();
- frm.set_intro("");
- frm.disable_form();
- frm.set_intro(__("This Salary Slip is awaiting approval."));
- }
- } else {
- frm.trigger("create_update_slip_btn");
- }
- },
-
- create_update_slip_btn: function (frm) {
- if (frm.doc.docstatus != 0 || frm.is_new()) {
- return
- }
- frm.add_custom_button(__("Update Salary Slip"), function() {
- frappe.call({
- method: 'csf_tz.csftz_hooks.payroll.update_slip',
- args: {
- salary_slip: frm.doc.name,
- },
- callback: function(r) {
- if (r.message) {
- frm.reload_doc();
- }
- }
- });
- });
- },
+ create_update_slip_btn: function (frm) {
+ if (frm.doc.docstatus != 0 || frm.is_new()) {
+ return;
+ }
+ frm.add_custom_button(__("Update Salary Slip"), function () {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.payroll.update_slip",
+ args: {
+ salary_slip: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ frm.reload_doc();
+ }
+ },
+ });
+ });
+ },
});
diff --git a/csf_tz/csf_tz/sales_invoice.js b/csf_tz/csf_tz/sales_invoice.js
index 2abd08e1..b8d93e63 100644
--- a/csf_tz/csf_tz/sales_invoice.js
+++ b/csf_tz/csf_tz/sales_invoice.js
@@ -1,250 +1,257 @@
-frappe.require([
- "/assets/csf_tz/js/shortcuts.js",
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Sales Invoice", {
- refresh: function (frm) {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- frm.trigger("set_pos");
- frm.trigger("make_sales_invoice_btn");
- frm.trigger("add_write_off_button");
- },
- onload: function (frm) {
- frm.trigger("set_pos");
- if (frm.doc.document_status == "Draft") {
- if (frm.doc.is_return == "0") {
- frm.set_value("naming_series", "ACC-SINV-.YYYY.-");
- } else if (frm.doc.is_return == "1") {
- frm.set_value("naming_series", "ACC-CN-.YYYY.-");
- frm.set_value("select_print_heading", "CREDIT NOTE");
- }
- }
- // frm.trigger("update_stock");
- },
- customer: function (frm) {
- setTimeout(function () {
- if (!frm.doc.customer) {
- return;
- }
- if (!frm.doc.tax_category) {
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function (r) {
- if (!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- },
- });
- }
- }, 1000);
- },
- default_item_discount: function (frm) {
- frm.doc.items.forEach((item) => {
- frappe.model.set_value(
- item.doctype,
- item.name,
- "discount_percentage",
- frm.doc.default_item_discount
- );
- });
- },
- default_item_tax_template: function (frm) {
- frm.doc.items.forEach((item) => {
- frappe.model.set_value(
- item.doctype,
- item.name,
- "item_tax_template",
- frm.doc.default_item_tax_template
- );
- });
- },
- // update_stock: (frm) => {
- // const warehouse_field = frappe.meta.get_docfield("Sales Invoice Item", "warehouse", frm.doc.name);
- // const item_field = frappe.meta.get_docfield("Sales Invoice Item", "item_code", frm.doc.name);
- // const qty_field = frappe.meta.get_docfield("Sales Invoice Item", "qty", frm.doc.name);
- // if (frm.doc.update_stock){
- // warehouse_field.in_list_view = 1;
- // warehouse_field.idx = 3;
- // warehouse_field.columns = 2;
- // item_field.columns =3;
- // qty_field.columns =1;
- // refresh_field("items");
- // }else{
- // warehouse_field.in_list_view = 0;
- // warehouse_field.columns = 0;
- // item_field.columns =4;
- // qty_field.columns =2;
- // refresh_field("items");
- // }
- // },
- make_sales_invoice_btn: function (frm) {
- if (
- frm.doc.docstatus == 1 &&
- frm.doc.enabled_auto_create_delivery_notes == 1
- ) {
- frm.add_custom_button(
- __("Create Delivery Note"),
+ refresh: function (frm) {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ frm.trigger("set_pos");
+ frm.trigger("make_sales_invoice_btn");
+ frm.trigger("add_write_off_button");
+ },
+ onload: function (frm) {
+ frm.trigger("set_pos");
+ if (frm.doc.document_status == "Draft") {
+ if (frm.doc.is_return == "0") {
+ frm.set_value("naming_series", "ACC-SINV-.YYYY.-");
+ } else if (frm.doc.is_return == "1") {
+ frm.set_value("naming_series", "ACC-CN-.YYYY.-");
+ frm.set_value("select_print_heading", "CREDIT NOTE");
+ }
+ }
+ // frm.trigger("update_stock");
+ },
+ customer: function (frm) {
+ setTimeout(function () {
+ if (!frm.doc.customer) {
+ return;
+ }
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
+ default_item_discount: function (frm) {
+ frm.doc.items.forEach((item) => {
+ frappe.model.set_value(
+ item.doctype,
+ item.name,
+ "discount_percentage",
+ frm.doc.default_item_discount
+ );
+ });
+ },
+ default_item_tax_template: function (frm) {
+ frm.doc.items.forEach((item) => {
+ frappe.model.set_value(
+ item.doctype,
+ item.name,
+ "item_tax_template",
+ frm.doc.default_item_tax_template
+ );
+ });
+ },
+ // update_stock: (frm) => {
+ // const warehouse_field = frappe.meta.get_docfield("Sales Invoice Item", "warehouse", frm.doc.name);
+ // const item_field = frappe.meta.get_docfield("Sales Invoice Item", "item_code", frm.doc.name);
+ // const qty_field = frappe.meta.get_docfield("Sales Invoice Item", "qty", frm.doc.name);
+ // if (frm.doc.update_stock){
+ // warehouse_field.in_list_view = 1;
+ // warehouse_field.idx = 3;
+ // warehouse_field.columns = 2;
+ // item_field.columns =3;
+ // qty_field.columns =1;
+ // refresh_field("items");
+ // }else{
+ // warehouse_field.in_list_view = 0;
+ // warehouse_field.columns = 0;
+ // item_field.columns =4;
+ // qty_field.columns =2;
+ // refresh_field("items");
+ // }
+ // },
+ make_sales_invoice_btn: function (frm) {
+ if (frm.doc.docstatus == 1 && frm.doc.enabled_auto_create_delivery_notes == 1) {
+ frm.add_custom_button(
+ __("Create Delivery Note"),
- function () {
- frappe.call({
- method: "csf_tz.custom_api.create_delivery_note",
- args: {
- doc_name: frm.doc.name,
- method: 1,
- },
- });
- }
- );
- }
- },
- set_pos: function (frm) {
- frappe.db
- .get_value("CSF TZ Settings", {}, "auto_pos_for_role")
- .then((r) => {
- if (r.message) {
- if (
- frappe.user_roles.includes(r.message.auto_pos_for_role) &&
- frm.doc.docstatus == 0 &&
- frappe.session.user != "Administrator" &&
- frm.doc.is_pos != 1
- ) {
- frm.set_value("is_pos", true);
- frm.set_df_property("is_pos", "read_only", true);
- }
- }
- });
- },
+ function () {
+ frappe.call({
+ method: "csf_tz.custom_api.create_delivery_note",
+ args: {
+ doc_name: frm.doc.name,
+ method: 1,
+ },
+ });
+ }
+ );
+ }
+ },
+ set_pos: function (frm) {
+ frappe.db.get_value("CSF TZ Settings", {}, "auto_pos_for_role").then((r) => {
+ if (r.message) {
+ if (
+ frappe.user_roles.includes(r.message.auto_pos_for_role) &&
+ frm.doc.docstatus == 0 &&
+ frappe.session.user != "Administrator" &&
+ frm.doc.is_pos != 1
+ ) {
+ frm.set_value("is_pos", true);
+ frm.set_df_property("is_pos", "read_only", true);
+ }
+ }
+ });
+ },
- // Write-off Journal Entry Feature
- add_write_off_button: function (frm) {
- // Check if feature is enabled and conditions are met
- frappe.db
- .get_single_value("CSF TZ Settings", "enable_write_off_jv_si")
- .then((enable_write_off) => {
- if (enable_write_off &&
- frm.doc.docstatus === 1 &&
- frm.doc.outstanding_amount > 0 &&
- !frm.doc.is_return) {
+ // Write-off Journal Entry Feature
+ add_write_off_button: function (frm) {
+ // Check if feature is enabled and conditions are met
+ frappe.db.get_single_value("CSF TZ Settings", "enable_write_off_jv_si").then((enable_write_off) => {
+ if (
+ enable_write_off &&
+ frm.doc.docstatus === 1 &&
+ frm.doc.outstanding_amount > 0 &&
+ !frm.doc.is_return
+ ) {
+ frm.add_custom_button(
+ __("Write Off Outstanding"),
+ function () {
+ // Fetch the write-off account from Company before showing the dialog
+ frappe.db
+ .get_value("Company", frm.doc.company, "write_off_account")
+ .then(function (r) {
+ let write_off_account = r.message ? r.message.write_off_account : null;
- frm.add_custom_button(__("Write Off Outstanding"), function () {
- // Fetch the write-off account from Company before showing the dialog
- frappe.db.get_value("Company", frm.doc.company, "write_off_account").then(function(r) {
- let write_off_account = r.message ? r.message.write_off_account : null;
-
- // Show dialog to select write-off account
- let dialog = new frappe.ui.Dialog({
- title: __("Write Off Outstanding Amount"),
- fields: [
- {
- fieldname: "write_off_account",
- label: __("Write Off Account"),
- fieldtype: "Link",
- options: "Account",
- "default": write_off_account,
- reqd: 1,
- get_query: function() {
- return {
- filters: {
- "report_type": "Balance Sheet",
- "is_group": 0,
- "company": frm.doc.company
- }
- };
- }
- },
- {
- fieldname: "outstanding_amount",
- label: __("Outstanding Amount"),
- fieldtype: "Currency",
- default: frm.doc.outstanding_amount,
- read_only: 1
- }
- ],
- primary_action_label: __("Create Write Off Entry"),
- primary_action: function(values) {
- frappe.call({
- method: "csf_tz.custom_api.create_write_off_jv_si",
- args: {
- sales_invoice: frm.doc.name,
- account: values.write_off_account
- },
- callback: function(r) {
- if (r.message) {
- const journal_entry_link = `
${frappe.utils.escape_html(r.message)}`;
- frappe.msgprint(__("Write-off Journal Entry created: {0}", [journal_entry_link]));
- frm.reload_doc();
- }
- }
- });
- dialog.hide();
- }
- });
- dialog.show();
- });
- }, __("Create"));
- }
- });
- },
+ // Show dialog to select write-off account
+ let dialog = new frappe.ui.Dialog({
+ title: __("Write Off Outstanding Amount"),
+ fields: [
+ {
+ fieldname: "write_off_account",
+ label: __("Write Off Account"),
+ fieldtype: "Link",
+ options: "Account",
+ default: write_off_account,
+ reqd: 1,
+ get_query: function () {
+ return {
+ filters: {
+ report_type: "Balance Sheet",
+ is_group: 0,
+ company: frm.doc.company,
+ },
+ };
+ },
+ },
+ {
+ fieldname: "outstanding_amount",
+ label: __("Outstanding Amount"),
+ fieldtype: "Currency",
+ default: frm.doc.outstanding_amount,
+ read_only: 1,
+ },
+ ],
+ primary_action_label: __("Create Write Off Entry"),
+ primary_action: function (values) {
+ frappe.call({
+ method: "csf_tz.custom_api.create_write_off_jv_si",
+ args: {
+ sales_invoice: frm.doc.name,
+ account: values.write_off_account,
+ },
+ callback: function (r) {
+ if (r.message) {
+ const journal_entry_link = `
${frappe.utils.escape_html(
+ r.message
+ )}`;
+ frappe.msgprint(
+ __("Write-off Journal Entry created: {0}", [
+ journal_entry_link,
+ ])
+ );
+ frm.reload_doc();
+ }
+ },
+ });
+ dialog.hide();
+ },
+ });
+ dialog.show();
+ });
+ },
+ __("Create")
+ );
+ }
+ });
+ },
});
frappe.ui.form.on("Sales Invoice Item", {
- csf_tz_create_wtax_entry: (frm, cdt, cdn) => {
- frappe
- .call("csf_tz.custom_api.make_withholding_tax_gl_entries_for_sales", {
- doc: frm.doc,
- method: "From Front End",
- })
- .then((r) => {
- frm.refresh();
- });
- },
+ csf_tz_create_wtax_entry: (frm, cdt, cdn) => {
+ frappe
+ .call("csf_tz.custom_api.make_withholding_tax_gl_entries_for_sales", {
+ doc: frm.doc,
+ method: "From Front End",
+ })
+ .then((r) => {
+ frm.refresh();
+ });
+ },
});
frappe.ui.keys.add_shortcut({
- shortcut: "ctrl+q",
- action: () => {
- ctrlQ("Sales Invoice Item");
- },
- page: this.page,
- description: __("Select Item Warehouse"),
- ignore_inputs: true,
+ shortcut: "ctrl+q",
+ action: () => {
+ ctrlQ("Sales Invoice Item");
+ },
+ page: this.page,
+ description: __("Select Item Warehouse"),
+ ignore_inputs: true,
});
frappe.ui.keys.add_shortcut({
- shortcut: "ctrl+i",
- action: () => {
- ctrlI("Sales Invoice Item");
- },
- page: this.page,
- description: __("Select Customer Item Price"),
- ignore_inputs: true,
+ shortcut: "ctrl+i",
+ action: () => {
+ ctrlI("Sales Invoice Item");
+ },
+ page: this.page,
+ description: __("Select Customer Item Price"),
+ ignore_inputs: true,
});
frappe.ui.keys.add_shortcut({
- shortcut: "ctrl+u",
- action: () => {
- ctrlU("Sales Invoice Item");
- },
- page: this.page,
- description: __("Select Item Price"),
- ignore_inputs: true,
+ shortcut: "ctrl+u",
+ action: () => {
+ ctrlU("Sales Invoice Item");
+ },
+ page: this.page,
+ description: __("Select Item Price"),
+ ignore_inputs: true,
});
diff --git a/csf_tz/csf_tz/sales_order.js b/csf_tz/csf_tz/sales_order.js
index bf3ec9db..3bda41d3 100644
--- a/csf_tz/csf_tz/sales_order.js
+++ b/csf_tz/csf_tz/sales_order.js
@@ -1,117 +1,115 @@
-frappe.require([
- '/assets/csf_tz/js/csfUtlis.js',
- '/assets/csf_tz/js/shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/csfUtlis.js", "/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Sales Order", {
- // preload settings as a Promise
- onload: function (frm) {
- frm._csf_settings_promise = (async () => {
- try {
- // Fetch both fields in one go
- const limit = await frappe.db.get_single_value(
- "CSF TZ Settings",
- "limit_uom_as_item_uom"
- );
- const show = await frappe.db.get_single_value(
- "CSF TZ Settings",
- "show_customer_outstanding_in_sales_order"
- );
+ // preload settings as a Promise
+ onload: function (frm) {
+ frm._csf_settings_promise = (async () => {
+ try {
+ // Fetch both fields in one go
+ const limit = await frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom");
+ const show = await frappe.db.get_single_value(
+ "CSF TZ Settings",
+ "show_customer_outstanding_in_sales_order"
+ );
- return {
- limit_uom_as_item_uom: Number(limit),
- show_customer_outstanding_in_sales_order: Number(show)
- };
- } catch (e) {
- console.warn("Failed to preload CSF TZ Settings", e);
- return {};
- }
- })();
- },
- refresh: async function (frm) {
- const settings = await frm._csf_settings_promise;
- if (settings.limit_uom_as_item_uom === 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- },
- customer: async function (frm) {
- if (!frm.doc.customer) return;
- const settings = await frm._csf_settings_promise;
- if (settings.show_customer_outstanding_in_sales_order === 1) {
- frappe.call({
- method: 'csf_tz.csftz_hooks.customer.get_customer_total_unpaid_amount',
- args: {
- customer: frm.doc.customer,
- company: frm.doc.company,
- },
- callback: function (r) {
- if (r.message) console.info(r.message);
- }
- });
- } else {
- console.info("Skipping outstanding check: disabled in settings.");
- }
- setTimeout(function () {
- if (!frm.doc.tax_category) {
- frappe.call({
- method: "csf_tz.custom_api.get_tax_category",
- args: {
- doc_type: frm.doc.doctype,
- company: frm.doc.company,
- },
- callback: function (r) {
- if (!r.exc) {
- frm.set_value("tax_category", r.message);
- frm.trigger("tax_category");
- }
- }
- });
- }
- }, 1000);
- },
- default_item_discount: function (frm) {
- frm.doc.items.forEach(item => {
- frappe.model.set_value(item.doctype, item.name, 'discount_percentage', frm.doc.default_item_discount);
- });
- },
+ return {
+ limit_uom_as_item_uom: Number(limit),
+ show_customer_outstanding_in_sales_order: Number(show),
+ };
+ } catch (e) {
+ console.warn("Failed to preload CSF TZ Settings", e);
+ return {};
+ }
+ })();
+ },
+ refresh: async function (frm) {
+ const settings = await frm._csf_settings_promise;
+ if (settings.limit_uom_as_item_uom === 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ },
+ customer: async function (frm) {
+ if (!frm.doc.customer) return;
+ const settings = await frm._csf_settings_promise;
+ if (settings.show_customer_outstanding_in_sales_order === 1) {
+ frappe.call({
+ method: "csf_tz.csftz_hooks.customer.get_customer_total_unpaid_amount",
+ args: {
+ customer: frm.doc.customer,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (r.message) console.info(r.message);
+ },
+ });
+ } else {
+ console.info("Skipping outstanding check: disabled in settings.");
+ }
+ setTimeout(function () {
+ if (!frm.doc.tax_category) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_tax_category",
+ args: {
+ doc_type: frm.doc.doctype,
+ company: frm.doc.company,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frm.set_value("tax_category", r.message);
+ frm.trigger("tax_category");
+ }
+ },
+ });
+ }
+ }, 1000);
+ },
+ default_item_discount: function (frm) {
+ frm.doc.items.forEach((item) => {
+ frappe.model.set_value(
+ item.doctype,
+ item.name,
+ "discount_percentage",
+ frm.doc.default_item_discount
+ );
+ });
+ },
});
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+q',
- action: () => {
- ctrlQ("Sales Order Item");
- },
- page: this.page,
- description: __('Select Item Warehouse'),
- ignore_inputs: true,
+ shortcut: "ctrl+q",
+ action: () => {
+ ctrlQ("Sales Order Item");
+ },
+ page: this.page,
+ description: __("Select Item Warehouse"),
+ ignore_inputs: true,
});
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+i',
- action: () => {
- ctrlI("Sales Order Item");
- },
- page: this.page,
- description: __('Select Customer Item Price'),
- ignore_inputs: true,
+ shortcut: "ctrl+i",
+ action: () => {
+ ctrlI("Sales Order Item");
+ },
+ page: this.page,
+ description: __("Select Customer Item Price"),
+ ignore_inputs: true,
});
-
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+u',
- action: () => {
- ctrlU("Sales Order Item");
- },
- page: this.page,
- description: __('Select Item Price'),
- ignore_inputs: true,
+ shortcut: "ctrl+u",
+ action: () => {
+ ctrlU("Sales Order Item");
+ },
+ page: this.page,
+ description: __("Select Item Price"),
+ ignore_inputs: true,
});
diff --git a/csf_tz/csf_tz/stock_entry.js b/csf_tz/csf_tz/stock_entry.js
index a3402a86..48b778b3 100644
--- a/csf_tz/csf_tz/stock_entry.js
+++ b/csf_tz/csf_tz/stock_entry.js
@@ -1,106 +1,104 @@
-frappe.require([
- '/assets/csf_tz/js/shortcuts.js'
-]);
+frappe.require(["/assets/csf_tz/js/shortcuts.js"]);
frappe.ui.form.on("Stock Entry", {
- setup: function (frm) {
- frm.trigger("set_warehouse_options");
- },
- refresh: (frm) => {
- frappe.db.get_single_value("CSF TZ Settings", "limit_uom_as_item_uom").then(limit_uom_as_item_uom => {
- if (limit_uom_as_item_uom == 1) {
- frm.set_query("uom", "items", function (frm, cdt, cdn) {
- let row = locals[cdt][cdn];
- return {
- query:
- "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
- filters: {
- value: row.item_code,
- apply_on: "Item Code",
- },
- };
- });
- }
- });
- },
- onload: function (frm) {
- if (frm.docstatus == 0) {
- frm.trigger("stock_entry_type");
- frm.trigger("set_warehouse_options");
- }
- },
- company: function (frm) {
- frm.trigger("set_warehouse_options");
- },
- stock_entry_type: function (frm) {
- if (frm.doc.stock_entry_type != "Repack from template") {
- frappe.meta.get_docfield("Stock Entry Detail", "item_code", frm.doc.name).read_only = 0;
- frappe.meta.get_docfield("Stock Entry Detail", "item_group", frm.doc.name).read_only = 0;
- $('.grid-add-multiple-rows').show();
- $('.grid-add-row').show();
- $('.grid-remove-rows').show();
- $('.grid-download').show();
- $('.grid-upload').show();
- frm.toggle_reqd("qty", 0);
- }
- if (["Repack from template", "Manufacture"].includes(frm.doc.stock_entry_type)) {
- frm.set_df_property('total_net_weight', 'hidden', 1)
- }
- else {
- frm.set_df_property('total_net_weight', 'hidden', 0)
- }
- frm.refresh_field("items");
- frm.refresh();
- },
- calculate_net_weight: function (frm) {
- frm.doc.total_net_weight = 0.0;
+ setup: function (frm) {
+ frm.trigger("set_warehouse_options");
+ },
+ refresh: (frm) => {
+ frappe.db
+ .get_single_value("CSF TZ Settings", "limit_uom_as_item_uom")
+ .then((limit_uom_as_item_uom) => {
+ if (limit_uom_as_item_uom == 1) {
+ frm.set_query("uom", "items", function (frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ return {
+ query: "erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
+ filters: {
+ value: row.item_code,
+ apply_on: "Item Code",
+ },
+ };
+ });
+ }
+ });
+ },
+ onload: function (frm) {
+ if (frm.docstatus == 0) {
+ frm.trigger("stock_entry_type");
+ frm.trigger("set_warehouse_options");
+ }
+ },
+ company: function (frm) {
+ frm.trigger("set_warehouse_options");
+ },
+ stock_entry_type: function (frm) {
+ if (frm.doc.stock_entry_type != "Repack from template") {
+ frappe.meta.get_docfield("Stock Entry Detail", "item_code", frm.doc.name).read_only = 0;
+ frappe.meta.get_docfield("Stock Entry Detail", "item_group", frm.doc.name).read_only = 0;
+ $(".grid-add-multiple-rows").show();
+ $(".grid-add-row").show();
+ $(".grid-remove-rows").show();
+ $(".grid-download").show();
+ $(".grid-upload").show();
+ frm.toggle_reqd("qty", 0);
+ }
+ if (["Repack from template", "Manufacture"].includes(frm.doc.stock_entry_type)) {
+ frm.set_df_property("total_net_weight", "hidden", 1);
+ } else {
+ frm.set_df_property("total_net_weight", "hidden", 0);
+ }
+ frm.refresh_field("items");
+ frm.refresh();
+ },
+ calculate_net_weight: function (frm) {
+ frm.doc.total_net_weight = 0.0;
- $.each(frm.doc["items"] || [], function (i, item) {
- frm.doc.total_net_weight += flt(item.total_weight);
- });
- refresh_field("total_net_weight");
- },
- set_warehouse_options: function (frm) {
- frappe.call({
- "method": "csf_tz.custom_api.get_warehouse_options",
- "args": { company: frm.doc.company },
- callback: function (r) {
- if (r.message && r.message.length) {
- // frappe.meta.get_docfield("ModulesT", "module", frm.doc.name).options = r.message;
- // frm.get_docfield("taxes", "rate").reqd = 0;
- frm.set_df_property("final_destination", "options", r.message);
- }
- }
- });
- },
+ $.each(frm.doc["items"] || [], function (i, item) {
+ frm.doc.total_net_weight += flt(item.total_weight);
+ });
+ refresh_field("total_net_weight");
+ },
+ set_warehouse_options: function (frm) {
+ frappe.call({
+ method: "csf_tz.custom_api.get_warehouse_options",
+ args: { company: frm.doc.company },
+ callback: function (r) {
+ if (r.message && r.message.length) {
+ // frappe.meta.get_docfield("ModulesT", "module", frm.doc.name).options = r.message;
+ // frm.get_docfield("taxes", "rate").reqd = 0;
+ frm.set_df_property("final_destination", "options", r.message);
+ }
+ },
+ });
+ },
});
frappe.ui.form.on("Stock Entry Detail", {
- conversion_factor: function (frm, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- item.total_weight = flt(item.transfer_qty * item.weight_per_unit * item.conversion_factor);
- refresh_field("total_weight");
- frm.trigger("calculate_net_weight");
- },
- qty: function (frm, cdt, cdn) {
- frm.script_manager.trigger("conversion_factor", cdt, cdn);
- },
+ conversion_factor: function (frm, cdt, cdn) {
+ var item = frappe.get_doc(cdt, cdn);
+ item.total_weight = flt(item.transfer_qty * item.weight_per_unit * item.conversion_factor);
+ refresh_field("total_weight");
+ frm.trigger("calculate_net_weight");
+ },
+ qty: function (frm, cdt, cdn) {
+ frm.script_manager.trigger("conversion_factor", cdt, cdn);
+ },
});
frappe.ui.keys.add_shortcut({
- shortcut: 'ctrl+q',
- action: () => {
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals["Stock Entry Detail"][current_doc];
- frappe.call({
- method: 'csf_tz.custom_api.get_item_info',
- args: { item_code: item_row.item_code },
- callback: function (r) {
- if (r.message.length > 0) {
- const d = new frappe.ui.Dialog({
- title: __('Item Balance'),
- width: 600
- });
- $(`
+ shortcut: "ctrl+q",
+ action: () => {
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals["Stock Entry Detail"][current_doc];
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_info",
+ args: { item_code: item_row.item_code },
+ callback: function (r) {
+ if (r.message.length > 0) {
+ const d = new frappe.ui.Dialog({
+ title: __("Item Balance"),
+ width: 600,
+ });
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Warehouse and click Select :
@@ -110,10 +108,10 @@ frappe.ui.keys.add_shortcut({
`).appendTo(d.body);
- const thead = $(d.body).find('thead');
- if (r.message[0].batch_no) {
- r.message.sort((a, b) => a.expiry_status - b.expiry_status);
- $(`
+ const thead = $(d.body).find("thead");
+ if (r.message[0].batch_no) {
+ r.message.sort((a, b) => a.expiry_status - b.expiry_status);
+ $(`
| Check |
Warehouse |
Qty |
@@ -122,17 +120,17 @@ frappe.ui.keys.add_shortcut({
Expires On |
Expires in Days |
`).appendTo(thead);
- } else {
- $(`
+ } else {
+ $(`
| Check |
Warehouse |
Qty |
UOM |
`).appendTo(thead);
- }
- r.message.forEach(element => {
- const tbody = $(d.body).find('tbody');
- const tr = $(`
+ }
+ r.message.forEach((element) => {
+ const tbody = $(d.body).find("tbody");
+ const tr = $(`
|
${element.warehouse} |
@@ -140,39 +138,50 @@ frappe.ui.keys.add_shortcut({
${item_row.stock_uom} |
`).appendTo(tbody);
- if (element.batch_no) {
- $(`
+ if (element.batch_no) {
+ $(`
${element.batch_no} |
${element.expires_on} |
${element.expiry_status} |
`).appendTo(tr);
- tr.find('.check-warehouse').attr('data-batch', element.batch_no);
- tr.find('.check-warehouse').attr('data-batchQty', element.actual_qty);
- }
- tbody.find('.check-warehouse').on('change', function () {
- $('input.check-warehouse').not(this).prop('checked', false);
- });
- });
- d.set_primary_action("Select", function () {
- $(d.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 's_warehouse', $(input).attr('data-warehouse'));
- if ($(input).attr('data-batch')) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'batch_no', $(input).attr('data-batch'));
- }
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
- cur_frm.rec_dialog = d;
- d.show();
- }
- else {
- frappe.show_alert({ message: __('There is No Records'), indicator: 'red' }, 5);
- }
- }
- });
- },
- page: this.page,
- description: __('Select Item Warehouse'),
- ignore_inputs: true,
+ tr.find(".check-warehouse").attr("data-batch", element.batch_no);
+ tr.find(".check-warehouse").attr("data-batchQty", element.actual_qty);
+ }
+ tbody.find(".check-warehouse").on("change", function () {
+ $("input.check-warehouse").not(this).prop("checked", false);
+ });
+ });
+ d.set_primary_action("Select", function () {
+ $(d.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "s_warehouse",
+ $(input).attr("data-warehouse")
+ );
+ if ($(input).attr("data-batch")) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "batch_no",
+ $(input).attr("data-batch")
+ );
+ }
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
+ cur_frm.rec_dialog = d;
+ d.show();
+ } else {
+ frappe.show_alert({ message: __("There is No Records"), indicator: "red" }, 5);
+ }
+ },
+ });
+ },
+ page: this.page,
+ description: __("Select Item Warehouse"),
+ ignore_inputs: true,
});
diff --git a/csf_tz/csf_tz/stock_reconciliation.js b/csf_tz/csf_tz/stock_reconciliation.js
index 754da934..58aeb62c 100644
--- a/csf_tz/csf_tz/stock_reconciliation.js
+++ b/csf_tz/csf_tz/stock_reconciliation.js
@@ -1,11 +1,10 @@
-frappe.ui.form.on('Stock Reconciliation', {
+frappe.ui.form.on("Stock Reconciliation", {
sort_items: function (frm, cdt, cdn) {
- const sorted_list =frm.doc.items.sort((a,b) => (a.item_code > b.item_code) ? 1 : -1);
- sorted_list.forEach((i,idx) => {
- const row = locals["Stock Reconciliation Item"][i.name];
- row.idx = idx + 1;
- });
- refresh_field("items");
+ const sorted_list = frm.doc.items.sort((a, b) => (a.item_code > b.item_code ? 1 : -1));
+ sorted_list.forEach((i, idx) => {
+ const row = locals["Stock Reconciliation Item"][i.name];
+ row.idx = idx + 1;
+ });
+ refresh_field("items");
},
-
-})
+});
diff --git a/csf_tz/csf_tz/student_applicant.js b/csf_tz/csf_tz/student_applicant.js
index d941087e..55b801b1 100644
--- a/csf_tz/csf_tz/student_applicant.js
+++ b/csf_tz/csf_tz/student_applicant.js
@@ -1,37 +1,43 @@
-frappe.ui.form.on('Student Applicant', {
- onload: function(frm) {
+frappe.ui.form.on("Student Applicant", {
+ onload: function (frm) {
frm.trigger("setup_btns");
},
- refresh: function(frm) {
+ refresh: function (frm) {
frm.trigger("setup_btns");
},
- setup_btns: function(frm) {
+ setup_btns: function (frm) {
if (!frm.send_fee_details_to_bank) {
return;
}
- if(frm.doc.docstatus == 1 && frm.doc.application_status != "Approved") {
+ if (frm.doc.docstatus == 1 && frm.doc.application_status != "Approved") {
frm.clear_custom_buttons();
- if(frm.doc.application_status == "Applied") {
- frm.add_custom_button(__("Reject"), function() {
- frm.set_value("application_status", "Rejected");
- frm.save_or_update();
- }, 'Student Applicant Actions');
+ if (frm.doc.application_status == "Applied") {
+ frm.add_custom_button(
+ __("Reject"),
+ function () {
+ frm.set_value("application_status", "Rejected");
+ frm.save_or_update();
+ },
+ "Student Applicant Actions"
+ );
}
- if(["Applied", "Rejected"].includes(frm.doc.application_status)) {
- frm.add_custom_button(__("Awaiting Registration Fees"), function() {
- frm.set_value("application_status", "Awaiting Registration Fees");
- frm.save_or_update();
- }, 'Student Applicant Actions');
+ if (["Applied", "Rejected"].includes(frm.doc.application_status)) {
+ frm.add_custom_button(
+ __("Awaiting Registration Fees"),
+ function () {
+ frm.set_value("application_status", "Awaiting Registration Fees");
+ frm.save_or_update();
+ },
+ "Student Applicant Actions"
+ );
}
}
},
- setup: function(frm) {
- frappe.db.get_value('Fee Structure', frm.doc.fee_structure, ["company"], function(value1) {
- frappe.db.get_value('Company', value1.company, ["send_fee_details_to_bank"], function(value2) {
+ setup: function (frm) {
+ frappe.db.get_value("Fee Structure", frm.doc.fee_structure, ["company"], function (value1) {
+ frappe.db.get_value("Company", value1.company, ["send_fee_details_to_bank"], function (value2) {
frm.send_fee_details_to_bank = value2.send_fee_details_to_bank || 0;
-
});
});
- },
-
+ },
});
diff --git a/csf_tz/csf_tz/supplier.js b/csf_tz/csf_tz/supplier.js
index 6054b8b6..acce106c 100644
--- a/csf_tz/csf_tz/supplier.js
+++ b/csf_tz/csf_tz/supplier.js
@@ -2,20 +2,16 @@
// For license information, please see license.txt
/* eslint-disable */
-
frappe.ui.form.on("Supplier", {
-
-
- refresh: function(frm) {
-
- if(!frm.doc.__islocal) {
+ refresh: function (frm) {
+ if (!frm.doc.__islocal) {
// custom buttons
- frm.add_custom_button(__('Multi-Currency Ledger'), function() {
- frappe.set_route('query-report', 'Multi-Currency Ledger',
- {party_type:'Supplier', party:frm.doc.name});
+ frm.add_custom_button(__("Multi-Currency Ledger"), function () {
+ frappe.set_route("query-report", "Multi-Currency Ledger", {
+ party_type: "Supplier",
+ party: frm.doc.name,
+ });
});
-
}
},
-
});
diff --git a/csf_tz/csf_tz/travel_request.js b/csf_tz/csf_tz/travel_request.js
index d3948f51..cbbaf34f 100644
--- a/csf_tz/csf_tz/travel_request.js
+++ b/csf_tz/csf_tz/travel_request.js
@@ -1,152 +1,163 @@
-frappe.ui.form.on('Travel Request', {
- refresh: function (frm) {
- if (frm.doc.docstatus === 1) {
- frm.add_custom_button('Create Employee Advance', function () {
- checkSettingsAndCreateEA(frm);
- });
- }
+frappe.ui.form.on("Travel Request", {
+ refresh: function (frm) {
+ if (frm.doc.docstatus === 1) {
+ frm.add_custom_button("Create Employee Advance", function () {
+ checkSettingsAndCreateEA(frm);
+ });
+ }
- calculateTotalTravelCost(frm);
- },
- validate: function (frm) {
- calculateTotalTravelCost(frm);
- }
+ calculateTotalTravelCost(frm);
+ },
+ validate: function (frm) {
+ calculateTotalTravelCost(frm);
+ },
});
-function makeFrappeCall(method, args, successCallback, errorCallback = () => { }) {
- frappe.call({
- method: method,
- args: args,
- callback: function (response) {
- if (response && response.message) {
- successCallback(response.message);
- } else {
- frappe.msgprint(__('An error occurred during the request.'));
- errorCallback();
- }
- },
- error: function (error) {
- frappe.msgprint(__('Failed to process the request.'));
- console.error(error);
- errorCallback();
- }
- });
+function makeFrappeCall(method, args, successCallback, errorCallback = () => {}) {
+ frappe.call({
+ method: method,
+ args: args,
+ callback: function (response) {
+ if (response && response.message) {
+ successCallback(response.message);
+ } else {
+ frappe.msgprint(__("An error occurred during the request."));
+ errorCallback();
+ }
+ },
+ error: function (error) {
+ frappe.msgprint(__("Failed to process the request."));
+ console.error(error);
+ errorCallback();
+ },
+ });
}
function checkSettingsAndCreateEA(frm) {
- makeFrappeCall(
- 'frappe.client.get_value',
- {
- doctype: 'CSF TZ Settings',
- fieldname: ['track_unclaimed_employee_advances']
- },
- function (settings_response) {
- const trackUnclaimed = settings_response.track_unclaimed_employee_advances;
- if (trackUnclaimed != 0) {
- checkIfEAExists(frm);
- } else {
- frappe.msgprint(__('Please enable
Track Unclaimed Employee Advances in the CSF TZ Settings.'));
- }
- }
- );
+ makeFrappeCall(
+ "frappe.client.get_value",
+ {
+ doctype: "CSF TZ Settings",
+ fieldname: ["track_unclaimed_employee_advances"],
+ },
+ function (settings_response) {
+ const trackUnclaimed = settings_response.track_unclaimed_employee_advances;
+ if (trackUnclaimed != 0) {
+ checkIfEAExists(frm);
+ } else {
+ frappe.msgprint(
+ __("Please enable
Track Unclaimed Employee Advances in the CSF TZ Settings.")
+ );
+ }
+ }
+ );
}
function checkIfEAExists(frm) {
- makeFrappeCall(
- 'frappe.client.get_list',
- {
- doctype: 'Employee Advance',
- filters: {
- travel_request_ref: frm.doc.name,
- docstatus: ['<', 2]
- },
- fields: ['name']
- },
- function (ea_response) {
- if (ea_response.length > 0) {
- let advanceNames = ea_response.map(ea => ea.name).join(', ');
- frappe.msgprint(__('Employee Advances already exist for this Travel Request: {0}. Cannot create another.', [advanceNames]));
- } else {
- checkUnclaimedCountAndCreateEA(frm);
- }
- }
- );
+ makeFrappeCall(
+ "frappe.client.get_list",
+ {
+ doctype: "Employee Advance",
+ filters: {
+ travel_request_ref: frm.doc.name,
+ docstatus: ["<", 2],
+ },
+ fields: ["name"],
+ },
+ function (ea_response) {
+ if (ea_response.length > 0) {
+ let advanceNames = ea_response.map((ea) => ea.name).join(", ");
+ frappe.msgprint(
+ __(
+ "Employee Advances already exist for this Travel Request: {0}. Cannot create another.",
+ [advanceNames]
+ )
+ );
+ } else {
+ checkUnclaimedCountAndCreateEA(frm);
+ }
+ }
+ );
}
function checkUnclaimedCountAndCreateEA(frm) {
- makeFrappeCall(
- 'frappe.client.get_list',
- {
- doctype: 'Employee Advance',
- filters: {
- status: 'Draft',
- employee: frm.doc.employee
- },
- fields: ['name']
- },
- function (ea_response) {
- let unclaimed_count = ea_response.length;
- checkMaxUnclaimedAndCreateEA(frm, unclaimed_count);
- }
- );
+ makeFrappeCall(
+ "frappe.client.get_list",
+ {
+ doctype: "Employee Advance",
+ filters: {
+ status: "Draft",
+ employee: frm.doc.employee,
+ },
+ fields: ["name"],
+ },
+ function (ea_response) {
+ let unclaimed_count = ea_response.length;
+ checkMaxUnclaimedAndCreateEA(frm, unclaimed_count);
+ }
+ );
}
function checkMaxUnclaimedAndCreateEA(frm, unclaimed_count) {
- makeFrappeCall(
- 'frappe.client.get_value',
- {
- doctype: 'Company',
- fieldname: ['max_unclaimed_ea', 'abbr'],
- filters: {
- name: frm.doc.company
- }
- },
- function (company_response) {
- let max_unclaimed_ea = company_response.max_unclaimed_ea;
- let company_abbr = company_response.abbr;
+ makeFrappeCall(
+ "frappe.client.get_value",
+ {
+ doctype: "Company",
+ fieldname: ["max_unclaimed_ea", "abbr"],
+ filters: {
+ name: frm.doc.company,
+ },
+ },
+ function (company_response) {
+ let max_unclaimed_ea = company_response.max_unclaimed_ea;
+ let company_abbr = company_response.abbr;
- if (unclaimed_count < max_unclaimed_ea) {
- createEmployeeAdvance(frm, company_abbr);
- } else {
- frappe.msgprint(__('The maximum number of unclaimed Employee Advances has been reached. Cannot create a new Employee Advance.'));
- }
- }
- );
+ if (unclaimed_count < max_unclaimed_ea) {
+ createEmployeeAdvance(frm, company_abbr);
+ } else {
+ frappe.msgprint(
+ __(
+ "The maximum number of unclaimed Employee Advances has been reached. Cannot create a new Employee Advance."
+ )
+ );
+ }
+ }
+ );
}
function createEmployeeAdvance(frm, company_abbr) {
- let advance_account = "Employee Advances - " + company_abbr;
+ let advance_account = "Employee Advances - " + company_abbr;
- makeFrappeCall(
- 'frappe.client.insert',
- {
- doc: {
- doctype: 'Employee Advance',
- employee: frm.doc.employee,
- employee_name: frm.doc.employee_name,
- posting_date: frappe.datetime.nowdate(),
- purpose: frm.doc.purpose_of_travel,
- advance_amount: frm.doc.costings.reduce((total, costing) => total + costing.total_amount, 0),
- company: frm.doc.company,
- advance_account: advance_account,
- exchange_rate: 1,
- travel_request_ref: frm.doc.name,
- }
- },
- function (response) {
- if (response) {
- frm.set_value('employee_advance_ref', response.name);
- frm.save_or_update();
+ makeFrappeCall(
+ "frappe.client.insert",
+ {
+ doc: {
+ doctype: "Employee Advance",
+ employee: frm.doc.employee,
+ employee_name: frm.doc.employee_name,
+ posting_date: frappe.datetime.nowdate(),
+ purpose: frm.doc.purpose_of_travel,
+ advance_amount: frm.doc.costings.reduce((total, costing) => total + costing.total_amount, 0),
+ company: frm.doc.company,
+ advance_account: advance_account,
+ exchange_rate: 1,
+ travel_request_ref: frm.doc.name,
+ },
+ },
+ function (response) {
+ if (response) {
+ frm.set_value("employee_advance_ref", response.name);
+ frm.save_or_update();
- frappe.set_route('Form', 'Employee Advance', response.name);
- }
- }
- );
+ frappe.set_route("Form", "Employee Advance", response.name);
+ }
+ }
+ );
}
function calculateTotalTravelCost(frm) {
- if (frm.doc.costings) {
- let total_travel_cost = frm.doc.costings.reduce((total, costing) => total + costing.total_amount, 0);
- frm.set_value('total_travel_cost', total_travel_cost);
- }
+ if (frm.doc.costings) {
+ let total_travel_cost = frm.doc.costings.reduce((total, costing) => total + costing.total_amount, 0);
+ frm.set_value("total_travel_cost", total_travel_cost);
+ }
}
diff --git a/csf_tz/csf_tz/warehouse.js b/csf_tz/csf_tz/warehouse.js
index 342a4c34..b262b7a7 100644
--- a/csf_tz/csf_tz/warehouse.js
+++ b/csf_tz/csf_tz/warehouse.js
@@ -1,14 +1,9 @@
frappe.ui.form.on("Warehouse", {
-
- refresh: function(frm, dt, dn) {
-
- frm.add_custom_button(__('Create Stock Reconciliation'),
- function() {
- frappe.call({
- method: 'csf_tz.custom_api.make_stock_reconciliation_for_all_pending_material_request',
- });
- });
-
+ refresh: function (frm, dt, dn) {
+ frm.add_custom_button(__("Create Stock Reconciliation"), function () {
+ frappe.call({
+ method: "csf_tz.custom_api.make_stock_reconciliation_for_all_pending_material_request",
+ });
+ });
},
-
});
diff --git a/csf_tz/hooks.py b/csf_tz/hooks.py
index b91bc488..9e0725d3 100755
--- a/csf_tz/hooks.py
+++ b/csf_tz/hooks.py
@@ -122,7 +122,6 @@
after_migrate = [
"csf_tz.utils.create_custom_fields.execute",
- "csf_tz.utils.authority_notification_settings_fields.execute",
"csf_tz.utils.create_property_setter.execute",
"csf_tz.patches.custom_fields.vfd_providers_updated_custom_fields.execute",
"csf_tz.patches.migrate_vfd_providers_to_csf_tz.execute",
diff --git a/csf_tz/kcb/payroll_entry.js b/csf_tz/kcb/payroll_entry.js
index f63c12f7..a80c0f2e 100644
--- a/csf_tz/kcb/payroll_entry.js
+++ b/csf_tz/kcb/payroll_entry.js
@@ -6,15 +6,15 @@ frappe.ui.form.on("Payroll Entry", {
method: "csf_tz.kcb.api.kcb_api.is_kcb_enabled",
callback: (r) => {
const enabled = !!r.message;
- if (!enabled) {
- frm.remove_custom_button(__(kcbButtonName));
- return;
- }
- if (frm.doc.docstatus === 1) {
- validate_salary_slips(frm);
- } else {
- frm.remove_custom_button(__(kcbButtonName));
- }
+ if (!enabled) {
+ frm.remove_custom_button(__(kcbButtonName));
+ return;
+ }
+ if (frm.doc.docstatus === 1) {
+ validate_salary_slips(frm);
+ } else {
+ frm.remove_custom_button(__(kcbButtonName));
+ }
},
});
},
diff --git a/csf_tz/meal_count/doctype/csf_tz_biometric_device/csf_tz_biometric_device.js b/csf_tz/meal_count/doctype/csf_tz_biometric_device/csf_tz_biometric_device.js
index 1f7475de..b3075b69 100644
--- a/csf_tz/meal_count/doctype/csf_tz_biometric_device/csf_tz_biometric_device.js
+++ b/csf_tz/meal_count/doctype/csf_tz_biometric_device/csf_tz_biometric_device.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Biometric Device', {
+frappe.ui.form.on("CSF TZ Biometric Device", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/meal_count/doctype/csf_tz_biometric_log/csf_tz_biometric_log.js b/csf_tz/meal_count/doctype/csf_tz_biometric_log/csf_tz_biometric_log.js
index a3672254..4bfb8cb6 100644
--- a/csf_tz/meal_count/doctype/csf_tz_biometric_log/csf_tz_biometric_log.js
+++ b/csf_tz/meal_count/doctype/csf_tz_biometric_log/csf_tz_biometric_log.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Biometric Log', {
+frappe.ui.form.on("CSF TZ Biometric Log", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/meal_count/doctype/csf_tz_biometric_user/csf_tz_biometric_user.js b/csf_tz/meal_count/doctype/csf_tz_biometric_user/csf_tz_biometric_user.js
index c08e09f3..4338abd4 100644
--- a/csf_tz/meal_count/doctype/csf_tz_biometric_user/csf_tz_biometric_user.js
+++ b/csf_tz/meal_count/doctype/csf_tz_biometric_user/csf_tz_biometric_user.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Biometric User', {
+frappe.ui.form.on("CSF TZ Biometric User", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/meal_count/doctype/csf_tz_biometric_user_type/csf_tz_biometric_user_type.js b/csf_tz/meal_count/doctype/csf_tz_biometric_user_type/csf_tz_biometric_user_type.js
index ae799a3e..96afe8ac 100644
--- a/csf_tz/meal_count/doctype/csf_tz_biometric_user_type/csf_tz_biometric_user_type.js
+++ b/csf_tz/meal_count/doctype/csf_tz_biometric_user_type/csf_tz_biometric_user_type.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Biometric User Type', {
+frappe.ui.form.on("CSF TZ Biometric User Type", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/meal_count/doctype/csf_tz_meal_type/csf_tz_meal_type.js b/csf_tz/meal_count/doctype/csf_tz_meal_type/csf_tz_meal_type.js
index 0e180ad6..39f87b7b 100644
--- a/csf_tz/meal_count/doctype/csf_tz_meal_type/csf_tz_meal_type.js
+++ b/csf_tz/meal_count/doctype/csf_tz_meal_type/csf_tz_meal_type.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('CSF TZ Meal Type', {
+frappe.ui.form.on("CSF TZ Meal Type", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/public/js/budget_check_utils.js b/csf_tz/public/js/budget_check_utils.js
index e23aa754..30edc0ac 100644
--- a/csf_tz/public/js/budget_check_utils.js
+++ b/csf_tz/public/js/budget_check_utils.js
@@ -9,32 +9,32 @@
* automatically by Frappe's framework.
*/
-frappe.provide('csf_tz.budget_check');
+frappe.provide("csf_tz.budget_check");
/**
* Perform automatic budget check for a document during validate event
* @param {Object} frm - The form object
*/
-csf_tz.budget_check.auto_check = function(frm) {
- // Only check if document is in draft status
- if (frm.doc.docstatus !== 0) {
- return;
- }
+csf_tz.budget_check.auto_check = function (frm) {
+ // Only check if document is in draft status
+ if (frm.doc.docstatus !== 0) {
+ return;
+ }
- // Call server-side method directly
- // The Python method will check if the feature is enabled and perform budget validation
- // ERPNext's budget validation will raise exceptions that Frappe displays automatically
- frappe.call({
- method: 'csf_tz.budget_check.check_budget_before_submit',
- args: {
- doctype: frm.doctype,
- docname: frm.docname
- },
- // No custom callback needed - ERPNext handles displaying budget violations
- error: function(r) {
- // Errors are already displayed by Frappe's framework
- // Just log for debugging purposes
- console.log('Budget check completed');
- }
- });
+ // Call server-side method directly
+ // The Python method will check if the feature is enabled and perform budget validation
+ // ERPNext's budget validation will raise exceptions that Frappe displays automatically
+ frappe.call({
+ method: "csf_tz.budget_check.check_budget_before_submit",
+ args: {
+ doctype: frm.doctype,
+ docname: frm.docname,
+ },
+ // No custom callback needed - ERPNext handles displaying budget violations
+ error: function (r) {
+ // Errors are already displayed by Frappe's framework
+ // Just log for debugging purposes
+ console.log("Budget check completed");
+ },
+ });
};
diff --git a/csf_tz/public/js/jobcards/Card.vue b/csf_tz/public/js/jobcards/Card.vue
index d8f236ea..a04c718c 100644
--- a/csf_tz/public/js/jobcards/Card.vue
+++ b/csf_tz/public/js/jobcards/Card.vue
@@ -1,436 +1,415 @@
-
-
-
-
- {{
- cardData.operation.name
- }}
-
-
- {{ timer.hours }}
- :
- {{ timer.minutes }}
- :
- {{ timer.seconds }}
-
-
- {{ cardData.name }}
-
-
-
-
- Status: {{ cardData.status }}
-
-
-
-
-
-
-
-
- Production Item: {{ cardData.production_item }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Qty To Manufacture: {{ cardData.for_quantity }}
-
-
- Qty Completed: {{ cardData.total_completed_qty }}
-
-
-
-
- Start
- Resume
- Stop
-
-
-
- Submit
- Close
-
-
-
-
+
+
+
+
+ {{ cardData.operation.name }}
+
+
+ {{ timer.hours }}
+ :
+ {{ timer.minutes }}
+ :
+ {{ timer.seconds }}
+
+
+ {{ cardData.name }}
+
+
+
+
+ Status: {{ cardData.status }}
+
+
+
+
+
+
+
+
+ Production Item: {{ cardData.production_item }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Qty To Manufacture: {{ cardData.for_quantity }}
+
+
+ Qty Completed: {{ cardData.total_completed_qty }}
+
+
+
+
+ Start
+ Resume
+ Stop
+
+
+
+ Submit
+ Close
+
+
+
+
-
+
diff --git a/csf_tz/public/js/jobcards/JobCards.vue b/csf_tz/public/js/jobcards/JobCards.vue
index cbcf1431..1cd6979d 100644
--- a/csf_tz/public/js/jobcards/JobCards.vue
+++ b/csf_tz/public/js/jobcards/JobCards.vue
@@ -1,65 +1,69 @@
-
-
-
Working Job Cards
-
-
-
-
-
-
-
-
- {{ item.name }}
-
- {{ item.operation.name }}
-
-
- Qty To Manufacture: {{ item.for_quantity }}
-
-
- Total Completed Qty: {{ item.total_completed_qty }}
-
-
- Production Item: {{ item.production_item }}
-
-
- Satus: {{ item.status }}
-
-
- Current Time:
- {{ get_current(item.current_time).hours }}
- :
- {{ get_current(item.current_time).minutes }}
- :
- {{ get_current(item.current_time).seconds }}
-
-
-
-
-
-
-
-
-
-
-
- open
-
-
-
-
-
-
-
+
+
+
Working Job Cards
+
+
+
+
+
+
+
+
+ {{ item.name }}
+
+ {{ item.operation.name }}
+
+
+ Qty To Manufacture: {{ item.for_quantity }}
+
+
+ Total Completed Qty: {{ item.total_completed_qty }}
+
+
+ Production Item: {{ item.production_item }}
+
+
+ Satus: {{ item.status }}
+
+
+ Current Time:
+ {{
+ get_current(item.current_time).hours
+ }}
+ :
+ {{
+ get_current(item.current_time).minutes
+ }}
+ :
+ {{
+ get_current(item.current_time).seconds
+ }}
+
+
+
+
+
+
+
+
+
+
+ open
+
+
+
+
+
+
diff --git a/csf_tz/public/js/jobcards/jobcards.js b/csf_tz/public/js/jobcards/jobcards.js
index bd9e8e9a..3a7fcc90 100644
--- a/csf_tz/public/js/jobcards/jobcards.js
+++ b/csf_tz/public/js/jobcards/jobcards.js
@@ -1,49 +1,49 @@
// Job Cards functionality - compatible with Frappe bundling
// This file loads the Vue-based JobCards when needed
-frappe.provide('frappe.JobCards');
+frappe.provide("frappe.JobCards");
frappe.JobCards.job_cards = class {
- constructor({ parent }) {
- this.$parent = $(parent);
- this.page = parent.page;
- this.make_body();
- }
-
- make_body() {
- this.$EL = this.$parent.find('.layout-main');
-
- // Check if Vue bundle is available and load Vue component
- if (frappe.JobCards.JobCardsBuilder) {
- this.load_vue_component();
- } else {
- // The jobcards.bundle.js should be loaded automatically via hooks.py
- // If for some reason it's not loaded, show fallback
- this.load_fallback();
- }
- }
-
- load_vue_component() {
- // Use the Vue-based JobCards builder
- this.vue_builder = new frappe.JobCards.JobCardsBuilder({
- wrapper: this.$EL[0],
- page: this.page
- });
- }
-
- load_fallback() {
- // Fallback: Simple placeholder
- this.$EL.html('
Job Cards functionality loading...
');
-
- // Try again after a short delay in case the bundle is still loading
- setTimeout(() => {
- if (frappe.JobCards.JobCardsBuilder) {
- this.load_vue_component();
- }
- }, 1000);
- }
-
- setup_header() {
- // Header setup functionality
- }
+ constructor({ parent }) {
+ this.$parent = $(parent);
+ this.page = parent.page;
+ this.make_body();
+ }
+
+ make_body() {
+ this.$EL = this.$parent.find(".layout-main");
+
+ // Check if Vue bundle is available and load Vue component
+ if (frappe.JobCards.JobCardsBuilder) {
+ this.load_vue_component();
+ } else {
+ // The jobcards.bundle.js should be loaded automatically via hooks.py
+ // If for some reason it's not loaded, show fallback
+ this.load_fallback();
+ }
+ }
+
+ load_vue_component() {
+ // Use the Vue-based JobCards builder
+ this.vue_builder = new frappe.JobCards.JobCardsBuilder({
+ wrapper: this.$EL[0],
+ page: this.page,
+ });
+ }
+
+ load_fallback() {
+ // Fallback: Simple placeholder
+ this.$EL.html('
Job Cards functionality loading...
');
+
+ // Try again after a short delay in case the bundle is still loading
+ setTimeout(() => {
+ if (frappe.JobCards.JobCardsBuilder) {
+ this.load_vue_component();
+ }
+ }, 1000);
+ }
+
+ setup_header() {
+ // Header setup functionality
+ }
};
diff --git a/csf_tz/public/js/po_shortcuts.js b/csf_tz/public/js/po_shortcuts.js
index 4772f68f..f806dd60 100644
--- a/csf_tz/public/js/po_shortcuts.js
+++ b/csf_tz/public/js/po_shortcuts.js
@@ -1,28 +1,28 @@
function ctrlI(TableName) {
- // Get the current document details
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals[TableName][current_doc];
+ // Get the current document details
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals[TableName][current_doc];
- // Prepare filters for the query
- const filters = {
- item_code: item_row.item_code,
- customer: cur_frm.doc.customer || "",
- currency: cur_frm.doc.currency,
- company: cur_frm.doc.company
- };
+ // Prepare filters for the query
+ const filters = {
+ item_code: item_row.item_code,
+ customer: cur_frm.doc.customer || "",
+ currency: cur_frm.doc.currency,
+ company: cur_frm.doc.company,
+ };
- // Call the custom API to fetch data
- frappe.call({
- method: "csf_tz.custom_api.get_item_prices_custom_po",
- args: { filters: filters },
- callback: function (response) {
- if (response.message && response.message.length > 0) {
- const e = new frappe.ui.Dialog({
- title: __('Item Prices'),
- width: 600
- });
+ // Call the custom API to fetch data
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_prices_custom_po",
+ args: { filters: filters },
+ callback: function (response) {
+ if (response.message && response.message.length > 0) {
+ const e = new frappe.ui.Dialog({
+ title: __("Item Prices"),
+ width: 600,
+ });
- $(`
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Price and click Select :
@@ -33,8 +33,8 @@ function ctrlI(TableName) {
`).appendTo(e.body);
- const thead = $(e.body).find('thead');
- $(`
+ const thead = $(e.body).find("thead");
+ $(`
| Check |
Rate |
Qty |
@@ -43,9 +43,9 @@ function ctrlI(TableName) {
Customer |
`).appendTo(thead);
- response.message.forEach(element => {
- const tbody = $(e.body).find('tbody');
- const tr = $(`
+ response.message.forEach((element) => {
+ const tbody = $(e.body).find("tbody");
+ const tr = $(`
|
${element.rate} |
@@ -56,58 +56,65 @@ function ctrlI(TableName) {
`).appendTo(tbody);
- tbody.find('.check-rate').on('change', function () {
- $('input.check-rate').not(this).prop('checked', false);
- });
- });
+ tbody.find(".check-rate").on("change", function () {
+ $("input.check-rate").not(this).prop("checked", false);
+ });
+ });
- e.set_primary_action("Select", function () {
- $(e.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'rate', $(input).attr('data-rate'));
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
+ e.set_primary_action("Select", function () {
+ $(e.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "rate",
+ $(input).attr("data-rate")
+ );
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
- cur_frm.rec_dialog = e;
- e.show();
- } else {
- frappe.msgprint({
- message: "No rates found for the given filters.",
- title: "Warning",
- indicator: "orange"
- });
- }
- },
- error: function (error) {
- // Handle errors
- frappe.msgprint({
- message: "Error fetching rates. Please try again.",
- title: "Error",
- indicator: "red"
- });
- console.error(error);
- }
- });
+ cur_frm.rec_dialog = e;
+ e.show();
+ } else {
+ frappe.msgprint({
+ message: "No rates found for the given filters.",
+ title: "Warning",
+ indicator: "orange",
+ });
+ }
+ },
+ error: function (error) {
+ // Handle errors
+ frappe.msgprint({
+ message: "Error fetching rates. Please try again.",
+ title: "Error",
+ indicator: "red",
+ });
+ console.error(error);
+ },
+ });
}
-function ctrlU (TableName) {
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals[TableName][current_doc];
- frappe.call({
- method: 'csf_tz.custom_api.get_item_prices_po',
- args: {
- item_code: item_row.item_code,
- currency: cur_frm.doc.currency,
- company: cur_frm.doc.company
- },
- callback: function (r) {
- if (r.message.length > 0) {
- const e = new frappe.ui.Dialog({
- title: __('Item Prices'),
- width: 600
- });
- $(`
+function ctrlU(TableName) {
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals[TableName][current_doc];
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_prices_po",
+ args: {
+ item_code: item_row.item_code,
+ currency: cur_frm.doc.currency,
+ company: cur_frm.doc.company,
+ },
+ callback: function (r) {
+ if (r.message.length > 0) {
+ const e = new frappe.ui.Dialog({
+ title: __("Item Prices"),
+ width: 600,
+ });
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Price and click Select :
@@ -117,8 +124,8 @@ function ctrlU (TableName) {
`).appendTo(e.body);
- const thead = $(e.body).find('thead');
- $(`
+ const thead = $(e.body).find("thead");
+ $(`
| Check |
Rate |
Qty |
@@ -126,9 +133,9 @@ function ctrlU (TableName) {
Invoice |
Customer |
`).appendTo(thead);
- r.message.forEach(element => {
- const tbody = $(e.body).find('tbody');
- const tr = $(`
+ r.message.forEach((element) => {
+ const tbody = $(e.body).find("tbody");
+ const tr = $(`
|
${element.price} |
@@ -139,23 +146,29 @@ function ctrlU (TableName) {
`).appendTo(tbody);
- tbody.find('.check-rate').on('change', function () {
- $('input.check-rate').not(this).prop('checked', false);
- });
- });
- e.set_primary_action("Select", function () {
- $(e.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'rate', $(input).attr('data-rate'));
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
- cur_frm.rec_dialog = e;
- e.show();
- }
- else {
- frappe.show_alert({ message: __('There are no records'), indicator: 'red' }, 5);
- }
- }
- });
+ tbody.find(".check-rate").on("change", function () {
+ $("input.check-rate").not(this).prop("checked", false);
+ });
+ });
+ e.set_primary_action("Select", function () {
+ $(e.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "rate",
+ $(input).attr("data-rate")
+ );
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
+ cur_frm.rec_dialog = e;
+ e.show();
+ } else {
+ frappe.show_alert({ message: __("There are no records"), indicator: "red" }, 5);
+ }
+ },
+ });
}
diff --git a/csf_tz/public/js/select_dialog.js b/csf_tz/public/js/select_dialog.js
index 97695f1d..05c0f3a6 100644
--- a/csf_tz/public/js/select_dialog.js
+++ b/csf_tz/public/js/select_dialog.js
@@ -1,249 +1,264 @@
frappe.ui.form.SelectDialog = Class.extend({
- init: function (opts) {
- $.extend(this, opts);
- var me = this;
- this.make();
- },
- make: function () {
- let me = this;
-
- this.page_length = 20;
- this.start = 0;
- let fields = [];
- let count = 0;
- if (!this.date_field) {
- this.date_field = "transaction_date";
- }
-
-
- if ($.isArray(this.query_fields)) {
- for (let df of this.query_fields) {
- if (df.filter) {
- fields.push(df, { fieldtype: "Column Break" });
- }
- }
- }
-
- fields = fields.concat([
- {
- "fieldname": "date_range",
- "label": __("Date Range"),
- "fieldtype": "DateRange",
- },
- { fieldtype: "Section Break" },
- { fieldtype: "HTML", fieldname: "results_area" },
- {
- fieldtype: "Button", fieldname: "more_btn", label: __("More"),
- click: function () {
- me.start += 20;
- frappe.flags.auto_scroll = true;
- me.get_results();
- }
- }
- ]);
-
- this.dialog = new frappe.ui.Dialog({
- title: __(this.title),
- fields: fields,
- primary_action_label: __("Select"),
- primary_action: function () {
- me.action(me.get_checked_values(), me.args);
- cur_dialog.hide();
- },
- });
-
- this.$parent = $(this.dialog.body);
- this.$wrapper = this.dialog.fields_dict.results_area.$wrapper.append(`
`);
- this.$results = this.$wrapper.find('.results');
- this.$results.append(this.make_list_row());
-
- this.args = {};
-
- this.bind_events();
- this.get_results();
- this.dialog.show();
- },
-
- bind_events: function () {
- let me = this;
-
- this.$results.on('click', '.list-item-container', function (e) {
- if (!$(e.target).is(':checkbox') && !$(e.target).is('a')) {
- $(this).find(':checkbox').trigger('click');
-
- }
- });
- this.$results.on('click', '.list-item--head :checkbox', (e) => {
- this.$results.find('.list-item-container .list-row-check')
- .prop("checked", ($(e.target).is(':checked')));
- });
-
- this.$parent.find('.input-with-feedback').on('change', (e) => {
- frappe.flags.auto_scroll = false;
- this.get_results();
-
- });
-
-
- this.$parent.find('[data-fieldname="date_range"]').on('blur', (e) => {
- frappe.flags.auto_scroll = false;
- this.get_results();
- });
-
-
- },
-
- get_checked_values: function () {
- var me = this;
- return this.$results.find('.list-item-container').map(function () {
- if ($(this).find('.list-row-check:checkbox:checked').length > 0) {
- return $(this).find(`[data-item-${me.return_field}]`).attr(`data-item-${me.return_field}`);
- }
- }).get();
- },
-
- make_list_row: function (result = {}) {
- var me = this;
- // Make a head row by default (if result not passed)
- let head = Object.keys(result).length === 0;
-
- let contents = ``;
- let columns = [];
-
- if ($.isArray(this.query_fields)) {
- for (let df of this.query_fields) {
- columns.push(df.fieldname);
- }
- }
- columns.push("Date");
-
- columns.forEach(function (column) {
- contents += `
- ${head ? `
${__(frappe.model.unscrub(column))}`
- : `
${__(result[column])}`
- }
+ this.$results = this.$wrapper.find(".results");
+ this.$results.append(this.make_list_row());
+
+ this.args = {};
+
+ this.bind_events();
+ this.get_results();
+ this.dialog.show();
+ },
+
+ bind_events: function () {
+ let me = this;
+
+ this.$results.on("click", ".list-item-container", function (e) {
+ if (!$(e.target).is(":checkbox") && !$(e.target).is("a")) {
+ $(this).find(":checkbox").trigger("click");
+ }
+ });
+ this.$results.on("click", ".list-item--head :checkbox", (e) => {
+ this.$results
+ .find(".list-item-container .list-row-check")
+ .prop("checked", $(e.target).is(":checked"));
+ });
+
+ this.$parent.find(".input-with-feedback").on("change", (e) => {
+ frappe.flags.auto_scroll = false;
+ this.get_results();
+ });
+
+ this.$parent.find('[data-fieldname="date_range"]').on("blur", (e) => {
+ frappe.flags.auto_scroll = false;
+ this.get_results();
+ });
+ },
+
+ get_checked_values: function () {
+ var me = this;
+ return this.$results
+ .find(".list-item-container")
+ .map(function () {
+ if ($(this).find(".list-row-check:checkbox:checked").length > 0) {
+ return $(this)
+ .find(`[data-item-${me.return_field}]`)
+ .attr(`data-item-${me.return_field}`);
+ }
+ })
+ .get();
+ },
+
+ make_list_row: function (result = {}) {
+ var me = this;
+ // Make a head row by default (if result not passed)
+ let head = Object.keys(result).length === 0;
+
+ let contents = ``;
+ let columns = [];
+
+ if ($.isArray(this.query_fields)) {
+ for (let df of this.query_fields) {
+ columns.push(df.fieldname);
+ }
+ }
+ columns.push("Date");
+
+ columns.forEach(function (column) {
+ contents += `
+ ${
+ head
+ ? `${__(frappe.model.unscrub(column))}`
+ : `${__(
+ result[column]
+ )}`
+ }
`;
- });
+ });
- let $row = $(`
+ let $row = $(`
`);
-
- head ? $row.addClass('list-item--head')
- : $row = $(`
`).append($row);
- if (!me.multi_select) {
- $(".results").find('.list-row-check').on('change', function () {
- $('input.list-row-check').not(this).prop('checked', false);
- });
- }
-
- return $row;
- },
-
- render_result_list: function (results, more = 0) {
- var me = this;
- var more_btn = me.dialog.fields_dict.more_btn.$wrapper;
-
- // Make empty result set if filter is set
- if (!frappe.flags.auto_scroll) {
- this.empty_list();
- }
- more_btn.hide();
-
- if (results.length === 0) return;
- if (more && me.page_length + me.start < results.length) {
- more_btn.show();
- } else { more_btn.hide(); }
- $(".results").find(".list-item-container").remove();
- results.forEach((result) => {
- me.$results.append(me.make_list_row(result));
- });
-
- if (frappe.flags.auto_scroll) {
- this.$results.animate({ scrollTop: me.$results.prop('scrollHeight') }, 500);
- }
- },
-
- empty_list: function () {
- this.$results.find('.list-item-container').remove();
- },
-
- get_results: function () {
- let me = this;
-
- let filters = this.get_query ? this.get_query().filters : {};
- let filter_fields = [me.date_field];
- if ($.isArray(this.query_fields)) {
- for (let df of this.query_fields) {
- if (df.filter) {
- filters[df.fieldname] = me.dialog.fields_dict[df.fieldname].get_value() || undefined;
- me.args[df.fieldname] = filters[df.fieldname];
- filter_fields.push(df.fieldname);
- }
-
- }
- }
-
- let date_val = this.dialog.fields_dict["date_range"].get_value();
- if (date_val) {
- filters[this.date_field] = ['between', date_val];
- }
-
- let args = {
- doctype: "",
- txt: "",
- filters: filters,
- filter_fields: filter_fields,
- start: this.start,
- page_length: this.page_length + 1,
- query: this.get_query ? this.get_query().query : '',
- as_dict: 1
- };
- frappe.call({
- type: "GET",
- method: 'frappe.desk.search.search_widget',
- no_spinner: true,
- args: args,
- callback: function (r) {
- if (r.message) { r.values = r.message; }
- let results = [], more = 0;
- if (r.values.length) {
- if (r.values.length > me.page_length) {
- r.values.pop();
- more = 1;
- }
- r.values.forEach(function (result) {
- if (me.date_field in result) {
- result["Date"] = result[me.date_field];
- }
- result.checked = 0;
- result.parsed_date = Date.parse(result["Date"]);
- results.push(result);
- });
- results.map((result) => {
- result["Date"] = frappe.format(result["Date"], { "fieldtype": "Date" });
- });
-
- results.sort((a, b) => {
- return a.parsed_date - b.parsed_date;
- });
-
- // Preselect oldest entry
- if (me.start < 1 && r.values.length === 1) {
- results[0].checked = 1;
- }
- }
- else {
- frappe.show_alert({ message: __('There is No Records'), indicator: 'red' }, 5);
- }
- me.render_result_list(results, more);
- }
- });
- },
+ head
+ ? $row.addClass("list-item--head")
+ : ($row = $(`
`).append(
+ $row
+ ));
+ if (!me.multi_select) {
+ $(".results")
+ .find(".list-row-check")
+ .on("change", function () {
+ $("input.list-row-check").not(this).prop("checked", false);
+ });
+ }
+
+ return $row;
+ },
+
+ render_result_list: function (results, more = 0) {
+ var me = this;
+ var more_btn = me.dialog.fields_dict.more_btn.$wrapper;
+
+ // Make empty result set if filter is set
+ if (!frappe.flags.auto_scroll) {
+ this.empty_list();
+ }
+ more_btn.hide();
+
+ if (results.length === 0) return;
+ if (more && me.page_length + me.start < results.length) {
+ more_btn.show();
+ } else {
+ more_btn.hide();
+ }
+ $(".results").find(".list-item-container").remove();
+ results.forEach((result) => {
+ me.$results.append(me.make_list_row(result));
+ });
+
+ if (frappe.flags.auto_scroll) {
+ this.$results.animate({ scrollTop: me.$results.prop("scrollHeight") }, 500);
+ }
+ },
+
+ empty_list: function () {
+ this.$results.find(".list-item-container").remove();
+ },
+
+ get_results: function () {
+ let me = this;
+
+ let filters = this.get_query ? this.get_query().filters : {};
+ let filter_fields = [me.date_field];
+ if ($.isArray(this.query_fields)) {
+ for (let df of this.query_fields) {
+ if (df.filter) {
+ filters[df.fieldname] = me.dialog.fields_dict[df.fieldname].get_value() || undefined;
+ me.args[df.fieldname] = filters[df.fieldname];
+ filter_fields.push(df.fieldname);
+ }
+ }
+ }
+
+ let date_val = this.dialog.fields_dict["date_range"].get_value();
+ if (date_val) {
+ filters[this.date_field] = ["between", date_val];
+ }
+
+ let args = {
+ doctype: "",
+ txt: "",
+ filters: filters,
+ filter_fields: filter_fields,
+ start: this.start,
+ page_length: this.page_length + 1,
+ query: this.get_query ? this.get_query().query : "",
+ as_dict: 1,
+ };
+ frappe.call({
+ type: "GET",
+ method: "frappe.desk.search.search_widget",
+ no_spinner: true,
+ args: args,
+ callback: function (r) {
+ if (r.message) {
+ r.values = r.message;
+ }
+ let results = [],
+ more = 0;
+ if (r.values.length) {
+ if (r.values.length > me.page_length) {
+ r.values.pop();
+ more = 1;
+ }
+ r.values.forEach(function (result) {
+ if (me.date_field in result) {
+ result["Date"] = result[me.date_field];
+ }
+ result.checked = 0;
+ result.parsed_date = Date.parse(result["Date"]);
+ results.push(result);
+ });
+ results.map((result) => {
+ result["Date"] = frappe.format(result["Date"], { fieldtype: "Date" });
+ });
+
+ results.sort((a, b) => {
+ return a.parsed_date - b.parsed_date;
+ });
+
+ // Preselect oldest entry
+ if (me.start < 1 && r.values.length === 1) {
+ results[0].checked = 1;
+ }
+ } else {
+ frappe.show_alert({ message: __("There is No Records"), indicator: "red" }, 5);
+ }
+ me.render_result_list(results, more);
+ },
+ });
+ },
});
diff --git a/csf_tz/public/js/shortcuts.js b/csf_tz/public/js/shortcuts.js
index d321fa6b..270db4c5 100644
--- a/csf_tz/public/js/shortcuts.js
+++ b/csf_tz/public/js/shortcuts.js
@@ -1,17 +1,17 @@
// Shortcuts for CSF TZ
-function ctrlQ (TableName) {
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals[TableName][current_doc];
- frappe.call({
- method: 'csf_tz.custom_api.get_item_info',
- args: { item_code: item_row.item_code },
- callback: function (r) {
- if (r.message.length > 0) {
- const d = new frappe.ui.Dialog({
- title: __('Item Balance'),
- width: 600
- });
- $(`
+function ctrlQ(TableName) {
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals[TableName][current_doc];
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_info",
+ args: { item_code: item_row.item_code },
+ callback: function (r) {
+ if (r.message.length > 0) {
+ const d = new frappe.ui.Dialog({
+ title: __("Item Balance"),
+ width: 600,
+ });
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Warehouse and click Select :
@@ -21,10 +21,10 @@ function ctrlQ (TableName) {
`).appendTo(d.body);
- const thead = $(d.body).find('thead');
- if (r.message[0].batch_no) {
- r.message.sort((a, b) => a.expiry_status - b.expiry_status);
- $(`
+ const thead = $(d.body).find("thead");
+ if (r.message[0].batch_no) {
+ r.message.sort((a, b) => a.expiry_status - b.expiry_status);
+ $(`
| Check |
Warehouse |
Qty |
@@ -33,17 +33,17 @@ function ctrlQ (TableName) {
Expires On |
Expires in Days |
`).appendTo(thead);
- } else {
- $(`
+ } else {
+ $(`
| Check |
Warehouse |
Qty |
UOM |
`).appendTo(thead);
- }
- r.message.forEach(element => {
- const tbody = $(d.body).find('tbody');
- const tr = $(`
+ }
+ r.message.forEach((element) => {
+ const tbody = $(d.body).find("tbody");
+ const tr = $(`
|
${element.warehouse} |
@@ -51,64 +51,75 @@ function ctrlQ (TableName) {
${item_row.stock_uom} |
`).appendTo(tbody);
- if (element.batch_no) {
- $(`
+ if (element.batch_no) {
+ $(`
${element.batch_no} |
${element.expires_on} |
${element.expiry_status} |
`).appendTo(tr);
- tr.find('.check-warehouse').attr('data-batch', element.batch_no);
- tr.find('.check-warehouse').attr('data-batchQty', element.actual_qty);
- }
- tbody.find('.check-warehouse').on('change', function () {
- $('input.check-warehouse').not(this).prop('checked', false);
- });
- });
- d.set_primary_action("Select", function () {
- $(d.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'warehouse', $(input).attr('data-warehouse'));
- if ($(input).attr('data-batch')) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'batch_no', $(input).attr('data-batch'));
- }
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
- cur_frm.rec_dialog = d;
- d.show();
- }
- else {
- frappe.show_alert({ message: __('There are no records'), indicator: 'red' }, 5);
- }
- }
- });
+ tr.find(".check-warehouse").attr("data-batch", element.batch_no);
+ tr.find(".check-warehouse").attr("data-batchQty", element.actual_qty);
+ }
+ tbody.find(".check-warehouse").on("change", function () {
+ $("input.check-warehouse").not(this).prop("checked", false);
+ });
+ });
+ d.set_primary_action("Select", function () {
+ $(d.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "warehouse",
+ $(input).attr("data-warehouse")
+ );
+ if ($(input).attr("data-batch")) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "batch_no",
+ $(input).attr("data-batch")
+ );
+ }
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
+ cur_frm.rec_dialog = d;
+ d.show();
+ } else {
+ frappe.show_alert({ message: __("There are no records"), indicator: "red" }, 5);
+ }
+ },
+ });
}
function ctrlI(TableName) {
- // Get the current document details
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals[TableName][current_doc];
+ // Get the current document details
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals[TableName][current_doc];
- // Prepare filters for the query
- const filters = {
- item_code: item_row.item_code,
- customer: cur_frm.doc.customer || "",
- currency: cur_frm.doc.currency,
- company: cur_frm.doc.company
- };
+ // Prepare filters for the query
+ const filters = {
+ item_code: item_row.item_code,
+ customer: cur_frm.doc.customer || "",
+ currency: cur_frm.doc.currency,
+ company: cur_frm.doc.company,
+ };
- // Call the custom API to fetch data
- frappe.call({
- method: "csf_tz.custom_api.get_item_prices_custom",
- args: { filters: filters },
- callback: function (response) {
- if (response.message && response.message.length > 0) {
- const e = new frappe.ui.Dialog({
- title: __('Item Prices'),
- width: 600
- });
+ // Call the custom API to fetch data
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_prices_custom",
+ args: { filters: filters },
+ callback: function (response) {
+ if (response.message && response.message.length > 0) {
+ const e = new frappe.ui.Dialog({
+ title: __("Item Prices"),
+ width: 600,
+ });
- $(`
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Price and click Select :
@@ -119,8 +130,8 @@ function ctrlI(TableName) {
`).appendTo(e.body);
- const thead = $(e.body).find('thead');
- $(`
+ const thead = $(e.body).find("thead");
+ $(`
| Check |
Rate |
Qty |
@@ -129,9 +140,9 @@ function ctrlI(TableName) {
Customer |
`).appendTo(thead);
- response.message.forEach(element => {
- const tbody = $(e.body).find('tbody');
- const tr = $(`
+ response.message.forEach((element) => {
+ const tbody = $(e.body).find("tbody");
+ const tr = $(`
|
${element.rate} |
@@ -142,45 +153,52 @@ function ctrlI(TableName) {
`).appendTo(tbody);
- tbody.find('.check-rate').on('change', function () {
- $('input.check-rate').not(this).prop('checked', false);
- });
- });
+ tbody.find(".check-rate").on("change", function () {
+ $("input.check-rate").not(this).prop("checked", false);
+ });
+ });
- e.set_primary_action("Select", function () {
- $(e.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'rate', $(input).attr('data-rate'));
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
+ e.set_primary_action("Select", function () {
+ $(e.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "rate",
+ $(input).attr("data-rate")
+ );
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
- cur_frm.rec_dialog = e;
- e.show();
- } else {
- frappe.show_alert({ message: __('There are no records'), indicator: 'red' }, 5);
- }
- }
- });
+ cur_frm.rec_dialog = e;
+ e.show();
+ } else {
+ frappe.show_alert({ message: __("There are no records"), indicator: "red" }, 5);
+ }
+ },
+ });
}
-function ctrlU (TableName) {
- const current_doc = $('.data-row.editable-row').parent().attr("data-name");
- const item_row = locals[TableName][current_doc];
- frappe.call({
- method: 'csf_tz.custom_api.get_item_prices',
- args: {
- item_code: item_row.item_code,
- currency: cur_frm.doc.currency,
- company: cur_frm.doc.company
- },
- callback: function (r) {
- if (r.message.length > 0) {
- const e = new frappe.ui.Dialog({
- title: __('Item Prices'),
- width: 600
- });
- $(`
+function ctrlU(TableName) {
+ const current_doc = $(".data-row.editable-row").parent().attr("data-name");
+ const item_row = locals[TableName][current_doc];
+ frappe.call({
+ method: "csf_tz.custom_api.get_item_prices",
+ args: {
+ item_code: item_row.item_code,
+ currency: cur_frm.doc.currency,
+ company: cur_frm.doc.company,
+ },
+ callback: function (r) {
+ if (r.message.length > 0) {
+ const e = new frappe.ui.Dialog({
+ title: __("Item Prices"),
+ width: 600,
+ });
+ $(`
${item_row.item_code} : ${item_row.qty}
Choose Price and click Select :
@@ -190,8 +208,8 @@ function ctrlU (TableName) {
`).appendTo(e.body);
- const thead = $(e.body).find('thead');
- $(`
+ const thead = $(e.body).find("thead");
+ $(`
| Check |
Rate |
Qty |
@@ -199,9 +217,9 @@ function ctrlU (TableName) {
Invoice |
Customer |
`).appendTo(thead);
- r.message.forEach(element => {
- const tbody = $(e.body).find('tbody');
- const tr = $(`
+ r.message.forEach((element) => {
+ const tbody = $(e.body).find("tbody");
+ const tr = $(`
|
${element.price} |
@@ -212,23 +230,29 @@ function ctrlU (TableName) {
`).appendTo(tbody);
- tbody.find('.check-rate').on('change', function () {
- $('input.check-rate').not(this).prop('checked', false);
- });
- });
- e.set_primary_action("Select", function () {
- $(e.body).find('input:checked').each(function (i, input) {
- frappe.model.set_value(item_row.doctype, item_row.name, 'rate', $(input).attr('data-rate'));
- });
- cur_frm.rec_dialog.hide();
- cur_frm.refresh_fields();
- });
- cur_frm.rec_dialog = e;
- e.show();
- }
- else {
- frappe.show_alert({ message: __('There are no records'), indicator: 'red' }, 5);
- }
- }
- });
+ tbody.find(".check-rate").on("change", function () {
+ $("input.check-rate").not(this).prop("checked", false);
+ });
+ });
+ e.set_primary_action("Select", function () {
+ $(e.body)
+ .find("input:checked")
+ .each(function (i, input) {
+ frappe.model.set_value(
+ item_row.doctype,
+ item_row.name,
+ "rate",
+ $(input).attr("data-rate")
+ );
+ });
+ cur_frm.rec_dialog.hide();
+ cur_frm.refresh_fields();
+ });
+ cur_frm.rec_dialog = e;
+ e.show();
+ } else {
+ frappe.show_alert({ message: __("There are no records"), indicator: "red" }, 5);
+ }
+ },
+ });
}
diff --git a/csf_tz/public/js/to_console.js b/csf_tz/public/js/to_console.js
index 4866e4fb..03d5357b 100644
--- a/csf_tz/public/js/to_console.js
+++ b/csf_tz/public/js/to_console.js
@@ -1,7 +1,7 @@
-$(function() {
+$(function () {
console.log("ON Listing");
- frappe.realtime.on('out_to_console', function(data) {
- data.forEach(element => {
+ frappe.realtime.on("out_to_console", function (data) {
+ data.forEach((element) => {
console.log(element);
});
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/bin_setup/bin_setup.js b/csf_tz/purchase_and_stock_management/doctype/bin_setup/bin_setup.js
index 88710da7..3b2d3dfe 100644
--- a/csf_tz/purchase_and_stock_management/doctype/bin_setup/bin_setup.js
+++ b/csf_tz/purchase_and_stock_management/doctype/bin_setup/bin_setup.js
@@ -1,8 +1,8 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Bin Setup', {
- refresh: function(frm) {
+frappe.ui.form.on("Bin Setup", {
+ refresh: function (frm) {
console.log(frm.doc);
- }
+ },
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/bin_setup/test_bin_setup.js b/csf_tz/purchase_and_stock_management/doctype/bin_setup/test_bin_setup.js
index bbc5caf1..6f0d1405 100644
--- a/csf_tz/purchase_and_stock_management/doctype/bin_setup/test_bin_setup.js
+++ b/csf_tz/purchase_and_stock_management/doctype/bin_setup/test_bin_setup.js
@@ -10,14 +10,14 @@ QUnit.test("test: Bin Setup", function (assert) {
frappe.run_serially([
// insert a new Bin Setup
- () => frappe.tests.make('Bin Setup', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Bin Setup", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/item_number/item_number.js b/csf_tz/purchase_and_stock_management/doctype/item_number/item_number.js
index 5178282b..72176483 100644
--- a/csf_tz/purchase_and_stock_management/doctype/item_number/item_number.js
+++ b/csf_tz/purchase_and_stock_management/doctype/item_number/item_number.js
@@ -1,8 +1,6 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Item Number', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Item Number", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/item_number/test_item_number.js b/csf_tz/purchase_and_stock_management/doctype/item_number/test_item_number.js
index cbff0fdb..8af89f41 100644
--- a/csf_tz/purchase_and_stock_management/doctype/item_number/test_item_number.js
+++ b/csf_tz/purchase_and_stock_management/doctype/item_number/test_item_number.js
@@ -10,14 +10,14 @@ QUnit.test("test: Item Number", function (assert) {
frappe.run_serially([
// insert a new Item Number
- () => frappe.tests.make('Item Number', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Item Number", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/order_track/order_track.js b/csf_tz/purchase_and_stock_management/doctype/order_track/order_track.js
index fd9181bb..49e645b1 100644
--- a/csf_tz/purchase_and_stock_management/doctype/order_track/order_track.js
+++ b/csf_tz/purchase_and_stock_management/doctype/order_track/order_track.js
@@ -1,62 +1,66 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Order Track', {
-
- refresh: function(frm) {
- frm.events.show_hide_fields(frm);
- console.log(frm);
- //console.log(hide_show_sections.name);
- //alert(cur_frm.doc.docstatus)
-
- //make product inspection ie. submitted
- if(cur_frm.doc.docstatus === 1 ) {
- cur_frm.add_custom_button(__('Product Inspection'), function(){frm.events.make_product_inspection(frm)}, __("Make"));
-
-
- }
-
-
-
- //Arrival date entered,clearing company and completion date ! blank
- if (frm.doc.arrival_date && frm.doc.arrival_date != null ){
- if (frm.doc.clearing_company == '' || (frm.doc.expected_clearing_completion_date ==null)){
- var msg = "Either Clearing Company or Clearing Completion Date is unfilled,Please fill the fields";
- frappe.msgprint(msg);
- throw msg;
+frappe.ui.form.on("Order Track", {
+ refresh: function (frm) {
+ frm.events.show_hide_fields(frm);
+ console.log(frm);
+ //console.log(hide_show_sections.name);
+ //alert(cur_frm.doc.docstatus)
+
+ //make product inspection ie. submitted
+ if (cur_frm.doc.docstatus === 1) {
+ cur_frm.add_custom_button(
+ __("Product Inspection"),
+ function () {
+ frm.events.make_product_inspection(frm);
+ },
+ __("Make")
+ );
+ }
+ //Arrival date entered,clearing company and completion date ! blank
+ if (frm.doc.arrival_date && frm.doc.arrival_date != null) {
+ if (frm.doc.clearing_company == "" || frm.doc.expected_clearing_completion_date == null) {
+ var msg =
+ "Either Clearing Company or Clearing Completion Date is unfilled,Please fill the fields";
+ frappe.msgprint(msg);
+ throw msg;
}
}
},
+ show_hide_fields: function (frm) {
+ frm.toggle_display(
+ "section_international_supplier",
+ frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type == "International Supplier"
+ );
+ frm.toggle_display(
+ "section_containers",
+ frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type == "International Supplier"
+ );
+ frm.toggle_display(
+ "section_local_supplier",
+ frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type == "Local Supplier"
+ );
+ frm.toggle_display("section_order_progress", frm.doc.supplier && frm.doc.supplier_type);
+ frm.toggle_display("section_items_ordered", frm.doc.supplier && frm.doc.supplier_type);
+ frm.toggle_display("section_status", frm.doc.supplier && frm.doc.supplier_type);
+ },
- show_hide_fields:function(frm){
- frm.toggle_display('section_international_supplier',(frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type=='International Supplier' ));
- frm.toggle_display('section_containers',(frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type=='International Supplier'));
- frm.toggle_display('section_local_supplier', (frm.doc.supplier && frm.doc.supplier_type && frm.doc.supplier_type=='Local Supplier'));
- frm.toggle_display('section_order_progress',(frm.doc.supplier && frm.doc.supplier_type));
- frm.toggle_display('section_items_ordered', (frm.doc.supplier && frm.doc.supplier_type));
- frm.toggle_display('section_status', (frm.doc.supplier && frm.doc.supplier_type));
- },
-
-
-
- supplier:function(frm){
- frm.events.show_hide_fields(frm);
-
- },
+ supplier: function (frm) {
+ frm.events.show_hide_fields(frm);
+ },
- supplier_type:function(frm){
- frm.events.show_hide_fields(frm);
- },
+ supplier_type: function (frm) {
+ frm.events.show_hide_fields(frm);
+ },
- //Product Inspection function
- make_product_inspection:function(){
- frappe.model.open_mapped_doc({
+ //Product Inspection function
+ make_product_inspection: function () {
+ frappe.model.open_mapped_doc({
method: "erpnext.purchase_and_stock_management.doctype.order_track.order_track.make_product_inspection",
- frm: cur_frm
- })
-
- },
-
+ frm: cur_frm,
+ });
+ },
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/order_track/test_order_track.js b/csf_tz/purchase_and_stock_management/doctype/order_track/test_order_track.js
index 576cc20d..5094099b 100644
--- a/csf_tz/purchase_and_stock_management/doctype/order_track/test_order_track.js
+++ b/csf_tz/purchase_and_stock_management/doctype/order_track/test_order_track.js
@@ -10,14 +10,14 @@ QUnit.test("test: Order Track", function (assert) {
frappe.run_serially([
// insert a new Order Track
- () => frappe.tests.make('Order Track', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Order Track", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/purchase_and_stock_management_test.js b/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/purchase_and_stock_management_test.js
index bef824be..17914dfd 100644
--- a/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/purchase_and_stock_management_test.js
+++ b/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/purchase_and_stock_management_test.js
@@ -1,8 +1,6 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Purchase And Stock Management Test', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Purchase And Stock Management Test", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/test_purchase_and_stock_management_test.js b/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/test_purchase_and_stock_management_test.js
index 81320b46..d0ba695b 100644
--- a/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/test_purchase_and_stock_management_test.js
+++ b/csf_tz/purchase_and_stock_management/doctype/purchase_and_stock_management_test/test_purchase_and_stock_management_test.js
@@ -10,14 +10,14 @@ QUnit.test("test: Purchase And Stock Management Test", function (assert) {
frappe.run_serially([
// insert a new Purchase And Stock Management Test
- () => frappe.tests.make('Purchase And Stock Management Test', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Purchase And Stock Management Test", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/purchase_and_stock_management/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.js b/csf_tz/purchase_and_stock_management/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.js
index b7ebd358..5ec37eba 100644
--- a/csf_tz/purchase_and_stock_management/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.js
+++ b/csf_tz/purchase_and_stock_management/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.js
@@ -3,49 +3,49 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 7);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Ordered Items To Be Delivered"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date,
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date,
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ reqd: 1,
},
{
- "fieldname":"item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
{
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer",
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
},
{
- "fieldname":"sales_order",
- "label": __("Sales Order"),
- "fieldtype": "Link",
- "options": "Sales Order",
+ fieldname: "sales_order",
+ label: __("Sales Order"),
+ fieldtype: "Link",
+ options: "Sales Order",
},
{
- "fieldname":"warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse",
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/purchase_and_stock_management/report/pending_ordered_items/pending_ordered_items.js b/csf_tz/purchase_and_stock_management/report/pending_ordered_items/pending_ordered_items.js
index 0a2b6002..204b86a4 100644
--- a/csf_tz/purchase_and_stock_management/report/pending_ordered_items/pending_ordered_items.js
+++ b/csf_tz/purchase_and_stock_management/report/pending_ordered_items/pending_ordered_items.js
@@ -3,49 +3,49 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 7);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Pending Ordered Items"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date,
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date,
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ reqd: 1,
},
{
- "fieldname":"purchase_order",
- "label": __("Purchase Order"),
- "fieldtype": "Link",
- "options": "Purchase Order",
+ fieldname: "purchase_order",
+ label: __("Purchase Order"),
+ fieldtype: "Link",
+ options: "Purchase Order",
},
{
- "fieldname":"item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
{
- "fieldname":"warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse",
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
{
- "fieldname":"supplier",
- "label": __("Supplier"),
- "fieldtype": "Link",
- "options": "Supplier",
+ fieldname: "supplier",
+ label: __("Supplier"),
+ fieldtype: "Link",
+ options: "Supplier",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/purchase_and_stock_management/report/purchase_history/purchase_history.js b/csf_tz/purchase_and_stock_management/report/purchase_history/purchase_history.js
index ba48b602..c8f26afd 100644
--- a/csf_tz/purchase_and_stock_management/report/purchase_history/purchase_history.js
+++ b/csf_tz/purchase_and_stock_management/report/purchase_history/purchase_history.js
@@ -3,43 +3,43 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 7);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Purchase History"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date,
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date,
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ reqd: 1,
},
{
- "fieldname":"supplier",
- "label": __("Supplier"),
- "fieldtype": "Link",
- "options": "Supplier",
+ fieldname: "supplier",
+ label: __("Supplier"),
+ fieldtype: "Link",
+ options: "Supplier",
},
{
- "fieldname":"purchase_order",
- "label": __("Purchase Order"),
- "fieldtype": "Link",
- "options": "Purchase Order",
+ fieldname: "purchase_order",
+ label: __("Purchase Order"),
+ fieldtype: "Link",
+ options: "Purchase Order",
},
{
- "fieldname":"item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/purchase_and_stock_management/report/reordering_items/reordering_items.js b/csf_tz/purchase_and_stock_management/report/reordering_items/reordering_items.js
index 064c6860..828e3e7c 100644
--- a/csf_tz/purchase_and_stock_management/report/reordering_items/reordering_items.js
+++ b/csf_tz/purchase_and_stock_management/report/reordering_items/reordering_items.js
@@ -3,37 +3,37 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 7);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Reordering Items"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date,
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date,
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ reqd: 1,
},
{
- "fieldname":"material_request",
- "label": __("Material Request"),
- "fieldtype": "Link",
- "options": "Material Request",
+ fieldname: "material_request",
+ label: __("Material Request"),
+ fieldtype: "Link",
+ options: "Material Request",
},
{
- "fieldname":"item_code",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item_code",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/purchase_and_stock_management/report/shipment_tracking/shipment_tracking.js b/csf_tz/purchase_and_stock_management/report/shipment_tracking/shipment_tracking.js
index 12968db9..36b96be3 100644
--- a/csf_tz/purchase_and_stock_management/report/shipment_tracking/shipment_tracking.js
+++ b/csf_tz/purchase_and_stock_management/report/shipment_tracking/shipment_tracking.js
@@ -3,41 +3,41 @@
/* eslint-disable */
var aday = new Date();
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() - 30);
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
frappe.query_reports["Shipment Tracking"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
- {
- "fieldname":"order",
- "label": __("Order"),
- "fieldtype": "Link",
- "options": "Order Tracking",
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
},
-/* {
+ {
+ fieldname: "order",
+ label: __("Order"),
+ fieldtype: "Link",
+ options: "Order Tracking",
+ },
+ /* {
"fieldname":"purchase_order",
"label": __("Purchase Order"),
"fieldtype": "Link",
"options": "Purchase Order",
},*/
{
- "fieldname":"supplier",
- "label": __("Supplier"),
- "fieldtype": "Link",
- "options": "Supplier",
+ fieldname: "supplier",
+ label: __("Supplier"),
+ fieldtype: "Link",
+ options: "Supplier",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/purchase_and_stock_management/report/supplier_contacts/supplier_contacts.js b/csf_tz/purchase_and_stock_management/report/supplier_contacts/supplier_contacts.js
index 45869e43..424ccffd 100644
--- a/csf_tz/purchase_and_stock_management/report/supplier_contacts/supplier_contacts.js
+++ b/csf_tz/purchase_and_stock_management/report/supplier_contacts/supplier_contacts.js
@@ -3,32 +3,32 @@
/* eslint-disable */
frappe.query_reports["Supplier Contacts"] = {
- "filters": [
+ filters: [
{
- "reqd": 1,
- "fieldname":"party_type",
- "label": __("Party Type"),
- "fieldtype": "Link",
- "options": "DocType",
- "get_query": function() {
+ reqd: 1,
+ fieldname: "party_type",
+ label: __("Party Type"),
+ fieldtype: "Link",
+ options: "DocType",
+ get_query: function () {
return {
- "filters": {
- "name": ["in","Customer,Supplier,Sales Partner"],
- }
- }
- }
+ filters: {
+ name: ["in", "Customer,Supplier,Sales Partner"],
+ },
+ };
+ },
},
{
- "fieldname":"party_name",
- "label": __("Party Name"),
- "fieldtype": "Dynamic Link",
- "get_options": function() {
+ fieldname: "party_name",
+ label: __("Party Name"),
+ fieldtype: "Dynamic Link",
+ get_options: function () {
let party_type = frappe.query_report_filters_by_name.party_type.get_value();
- if(!party_type) {
+ if (!party_type) {
frappe.throw(__("Please select Party Type first"));
}
return party_type;
- }
- }
- ]
-}
+ },
+ },
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/doctype/allert_custom/allert_custom.js b/csf_tz/sales_and_marketing/doctype/allert_custom/allert_custom.js
index 206a829d..17fb7261 100644
--- a/csf_tz/sales_and_marketing/doctype/allert_custom/allert_custom.js
+++ b/csf_tz/sales_and_marketing/doctype/allert_custom/allert_custom.js
@@ -1,8 +1,6 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Allert Custom', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Allert Custom", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/sales_and_marketing/doctype/allert_custom/test_allert_custom.js b/csf_tz/sales_and_marketing/doctype/allert_custom/test_allert_custom.js
index 3c7889c5..1ddf7f85 100644
--- a/csf_tz/sales_and_marketing/doctype/allert_custom/test_allert_custom.js
+++ b/csf_tz/sales_and_marketing/doctype/allert_custom/test_allert_custom.js
@@ -10,14 +10,14 @@ QUnit.test("test: Allert Custom", function (assert) {
frappe.run_serially([
// insert a new Allert Custom
- () => frappe.tests.make('Allert Custom', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Allert Custom", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/sales_and_marketing/doctype/communications/communications.js b/csf_tz/sales_and_marketing/doctype/communications/communications.js
index 910e174f..cf8c74a6 100644
--- a/csf_tz/sales_and_marketing/doctype/communications/communications.js
+++ b/csf_tz/sales_and_marketing/doctype/communications/communications.js
@@ -1,8 +1,6 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Communications', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Communications", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/sales_and_marketing/doctype/communications/test_communications.js b/csf_tz/sales_and_marketing/doctype/communications/test_communications.js
index 7796c7a7..16cc3773 100644
--- a/csf_tz/sales_and_marketing/doctype/communications/test_communications.js
+++ b/csf_tz/sales_and_marketing/doctype/communications/test_communications.js
@@ -10,14 +10,14 @@ QUnit.test("test: Communications", function (assert) {
frappe.run_serially([
// insert a new Communications
- () => frappe.tests.make('Communications', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Communications", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/sales_and_marketing/doctype/marketing_dept/marketing_dept.js b/csf_tz/sales_and_marketing/doctype/marketing_dept/marketing_dept.js
index 7705d7f1..fce26162 100644
--- a/csf_tz/sales_and_marketing/doctype/marketing_dept/marketing_dept.js
+++ b/csf_tz/sales_and_marketing/doctype/marketing_dept/marketing_dept.js
@@ -1,8 +1,6 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Marketing Dept', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Marketing Dept", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/sales_and_marketing/doctype/marketing_dept/test_marketing_dept.js b/csf_tz/sales_and_marketing/doctype/marketing_dept/test_marketing_dept.js
index ce64aace..09992ab5 100644
--- a/csf_tz/sales_and_marketing/doctype/marketing_dept/test_marketing_dept.js
+++ b/csf_tz/sales_and_marketing/doctype/marketing_dept/test_marketing_dept.js
@@ -10,14 +10,14 @@ QUnit.test("test: Marketing Dept", function (assert) {
frappe.run_serially([
// insert a new Marketing Dept
- () => frappe.tests.make('Marketing Dept', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Marketing Dept", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/sales_and_marketing/doctype/past_sales/past_sales.js b/csf_tz/sales_and_marketing/doctype/past_sales/past_sales.js
index 54dea139..c760ddc3 100644
--- a/csf_tz/sales_and_marketing/doctype/past_sales/past_sales.js
+++ b/csf_tz/sales_and_marketing/doctype/past_sales/past_sales.js
@@ -1,8 +1,6 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Past Sales', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Past Sales", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/sales_and_marketing/doctype/past_sales/test_past_sales.js b/csf_tz/sales_and_marketing/doctype/past_sales/test_past_sales.js
index bdc1bb5e..8d04d5a0 100644
--- a/csf_tz/sales_and_marketing/doctype/past_sales/test_past_sales.js
+++ b/csf_tz/sales_and_marketing/doctype/past_sales/test_past_sales.js
@@ -10,14 +10,14 @@ QUnit.test("test: Past Sales", function (assert) {
frappe.run_serially([
// insert a new Past Sales
- () => frappe.tests.make('Past Sales', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Past Sales", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/sales_and_marketing/doctype/past_serial_no/past_serial_no.js b/csf_tz/sales_and_marketing/doctype/past_serial_no/past_serial_no.js
index 9099ee95..5e5b8baf 100644
--- a/csf_tz/sales_and_marketing/doctype/past_serial_no/past_serial_no.js
+++ b/csf_tz/sales_and_marketing/doctype/past_serial_no/past_serial_no.js
@@ -1,8 +1,6 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Past Serial No', {
- refresh: function(frm) {
-
- }
+frappe.ui.form.on("Past Serial No", {
+ refresh: function (frm) {},
});
diff --git a/csf_tz/sales_and_marketing/doctype/past_serial_no/test_past_serial_no.js b/csf_tz/sales_and_marketing/doctype/past_serial_no/test_past_serial_no.js
index 07363919..75501848 100644
--- a/csf_tz/sales_and_marketing/doctype/past_serial_no/test_past_serial_no.js
+++ b/csf_tz/sales_and_marketing/doctype/past_serial_no/test_past_serial_no.js
@@ -10,14 +10,14 @@ QUnit.test("test: Past Serial No", function (assert) {
frappe.run_serially([
// insert a new Past Serial No
- () => frappe.tests.make('Past Serial No', [
- // values to be set
- {key: 'value'}
- ]),
+ () =>
+ frappe.tests.make("Past Serial No", [
+ // values to be set
+ { key: "value" },
+ ]),
() => {
- assert.equal(cur_frm.doc.key, 'value');
+ assert.equal(cur_frm.doc.key, "value");
},
- () => done()
+ () => done(),
]);
-
});
diff --git a/csf_tz/sales_and_marketing/report/brand_sales_report/brand_sales_report.js b/csf_tz/sales_and_marketing/report/brand_sales_report/brand_sales_report.js
index e4d9b5e1..5844efcd 100644
--- a/csf_tz/sales_and_marketing/report/brand_sales_report/brand_sales_report.js
+++ b/csf_tz/sales_and_marketing/report/brand_sales_report/brand_sales_report.js
@@ -3,35 +3,35 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 30);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Brand Sales Report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
- {
- "fieldname":"brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "options": "Brand"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
},
- {
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer"
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ },
+ {
+ fieldname: "brand",
+ label: __("Brand"),
+ fieldtype: "Link",
+ options: "Brand",
+ },
+ {
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/customer_loan_assistance_report/customer_loan_assistance_report.js b/csf_tz/sales_and_marketing/report/customer_loan_assistance_report/customer_loan_assistance_report.js
index 5de768e3..4f63259c 100644
--- a/csf_tz/sales_and_marketing/report/customer_loan_assistance_report/customer_loan_assistance_report.js
+++ b/csf_tz/sales_and_marketing/report/customer_loan_assistance_report/customer_loan_assistance_report.js
@@ -2,32 +2,31 @@
// For license information, please see license.txt
/* eslint-disable */
var aday = new Date();
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() - 30);
-var from_date = aday.toISOString().split('T')[0];
-
+var from_date = aday.toISOString().split("T")[0];
frappe.query_reports["Customer Loan Assistance report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date,
- "reqd": 1
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ reqd: 1,
},
{
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date,
- "reqd": 1
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ reqd: 1,
},
{
- "fieldname":"loan_supplier",
- "label": __("Loan Supplier"),
- "fieldtype": "Link",
- "options": "Supplier"
- }
- ]
-}
+ fieldname: "loan_supplier",
+ label: __("Loan Supplier"),
+ fieldtype: "Link",
+ options: "Supplier",
+ },
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/item_wise_leads_report/item_wise_leads_report.js b/csf_tz/sales_and_marketing/report/item_wise_leads_report/item_wise_leads_report.js
index 45dd4da5..22b2c73f 100644
--- a/csf_tz/sales_and_marketing/report/item_wise_leads_report/item_wise_leads_report.js
+++ b/csf_tz/sales_and_marketing/report/item_wise_leads_report/item_wise_leads_report.js
@@ -3,35 +3,35 @@
/* eslint-disable */
var aday = new Date();
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() - 30);
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
frappe.query_reports["Item Wise Leads Report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
+ },
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ },
{
- "fieldname":"item",
- "label": __("Item"),
- "fieldtype": "Link",
- "options": "Item",
+ fieldname: "item",
+ label: __("Item"),
+ fieldtype: "Link",
+ options: "Item",
},
{
- "fieldname":"branch",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse"
+ fieldname: "branch",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/items_marked_for_delivery/items_marked_for_delivery.js b/csf_tz/sales_and_marketing/report/items_marked_for_delivery/items_marked_for_delivery.js
index dfd63651..bc2874a4 100644
--- a/csf_tz/sales_and_marketing/report/items_marked_for_delivery/items_marked_for_delivery.js
+++ b/csf_tz/sales_and_marketing/report/items_marked_for_delivery/items_marked_for_delivery.js
@@ -3,23 +3,23 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 30);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Items Marked For Delivery"] = {
- "filters": [
+ filters: [
{
- "fieldname":"warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse"
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
{
- "fieldname":"item_group",
- "label": __("Item Group"),
- "fieldtype": "Link",
- "options": "Item Group"
+ fieldname: "item_group",
+ label: __("Item Group"),
+ fieldtype: "Link",
+ options: "Item Group",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/previous_ams_customer_report/previous_ams_customer_report.js b/csf_tz/sales_and_marketing/report/previous_ams_customer_report/previous_ams_customer_report.js
index 30e3dbfb..212f633e 100644
--- a/csf_tz/sales_and_marketing/report/previous_ams_customer_report/previous_ams_customer_report.js
+++ b/csf_tz/sales_and_marketing/report/previous_ams_customer_report/previous_ams_customer_report.js
@@ -3,35 +3,35 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 30);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Previous Ams Customer Report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
- {
- "fieldname":"brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "options": "Brand"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
},
- {
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer"
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ },
+ {
+ fieldname: "brand",
+ label: __("Brand"),
+ fieldtype: "Link",
+ options: "Brand",
+ },
+ {
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/sales_details_report/sales_details_report.js b/csf_tz/sales_and_marketing/report/sales_details_report/sales_details_report.js
index 5ecf4366..8c87b863 100644
--- a/csf_tz/sales_and_marketing/report/sales_details_report/sales_details_report.js
+++ b/csf_tz/sales_and_marketing/report/sales_details_report/sales_details_report.js
@@ -3,41 +3,41 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 30);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Sales Details Report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
- {
- "fieldname":"cust_group",
- "label": __("Customer Group"),
- "fieldtype": "Link",
- "options": "Customer Group"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
},
- {
- "fieldname":"customer",
- "label": __("Customer"),
- "fieldtype": "Link",
- "options": "Customer"
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ },
+ {
+ fieldname: "cust_group",
+ label: __("Customer Group"),
+ fieldtype: "Link",
+ options: "Customer Group",
+ },
+ {
+ fieldname: "customer",
+ label: __("Customer"),
+ fieldtype: "Link",
+ options: "Customer",
},
{
- "fieldname":"warehouse",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse"
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/sales_and_marketing/report/spare_sales_report/spare_sales_report.js b/csf_tz/sales_and_marketing/report/spare_sales_report/spare_sales_report.js
index a75c31ab..6a121377 100644
--- a/csf_tz/sales_and_marketing/report/spare_sales_report/spare_sales_report.js
+++ b/csf_tz/sales_and_marketing/report/spare_sales_report/spare_sales_report.js
@@ -3,35 +3,35 @@
/* eslint-disable */
var aday = new Date();
-var from_date = aday.toISOString().split('T')[0];
+var from_date = aday.toISOString().split("T")[0];
aday.setDate(aday.getDate() + 30);
-var to_date = aday.toISOString().split('T')[0];
+var to_date = aday.toISOString().split("T")[0];
frappe.query_reports["Spare Sales Report"] = {
- "filters": [
+ filters: [
{
- "fieldname":"from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": from_date
- },
- {
- "fieldname":"to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": to_date
- },
- {
- "fieldname":"brand",
- "label": __("Brand"),
- "fieldtype": "Link",
- "options": "Brand"
+ fieldname: "from_date",
+ label: __("From Date"),
+ fieldtype: "Date",
+ default: from_date,
},
- {
- "fieldname":"shop",
- "label": __("Warehouse"),
- "fieldtype": "Link",
- "options": "Warehouse"
+ {
+ fieldname: "to_date",
+ label: __("To Date"),
+ fieldtype: "Date",
+ default: to_date,
+ },
+ {
+ fieldname: "brand",
+ label: __("Brand"),
+ fieldtype: "Link",
+ options: "Brand",
+ },
+ {
+ fieldname: "shop",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
},
- ]
-}
+ ],
+};
diff --git a/csf_tz/setup_data/accounts.json b/csf_tz/setup_data/accounts.json
index 1e542ea8..41c998cd 100644
--- a/csf_tz/setup_data/accounts.json
+++ b/csf_tz/setup_data/accounts.json
@@ -31,7 +31,7 @@
},
{
"doctype": "Account",
- "account_name": "Bank Charges",
+ "account_name": "Bank Charges Accounts",
"company": "{company}",
"account_currency": "TZS",
"parent_account": "Financial Charges - {abbr}",
@@ -147,7 +147,7 @@
"account_name": "Bank Charges TZS",
"company": "{company}",
"account_currency": "TZS",
- "parent_account": "Bank Charges - {abbr}",
+ "parent_account": "Bank Charges Accounts - {abbr}",
"root_type": "Expense",
"report_type": "Profit and Loss"
},
diff --git a/csf_tz/stanbic/doctype/stanbic_payments_initiation/stanbic_payments_initiation.js b/csf_tz/stanbic/doctype/stanbic_payments_initiation/stanbic_payments_initiation.js
index 75467c52..9600a739 100644
--- a/csf_tz/stanbic/doctype/stanbic_payments_initiation/stanbic_payments_initiation.js
+++ b/csf_tz/stanbic/doctype/stanbic_payments_initiation/stanbic_payments_initiation.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Stanbic Payments Initiation', {
+frappe.ui.form.on("Stanbic Payments Initiation", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/stanbic/doctype/stanbic_setting/stanbic_setting.js b/csf_tz/stanbic/doctype/stanbic_setting/stanbic_setting.js
index dffb3a03..014f4146 100644
--- a/csf_tz/stanbic/doctype/stanbic_setting/stanbic_setting.js
+++ b/csf_tz/stanbic/doctype/stanbic_setting/stanbic_setting.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Stanbic Setting', {
+frappe.ui.form.on("Stanbic Setting", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/stanbic/payroll_entry.js b/csf_tz/stanbic/payroll_entry.js
index e338f1ba..5f671ed9 100644
--- a/csf_tz/stanbic/payroll_entry.js
+++ b/csf_tz/stanbic/payroll_entry.js
@@ -1,54 +1,54 @@
const buttonName = "Generate Stanbic Payments Initiation";
frappe.ui.form.on("Payroll Entry", {
- refresh: function (frm) {
- if (frm.doc.docstatus == 1) generate_payments_initiation(frm);
- else {
- frm.remove_custom_button(__(buttonName));
- // add_generate_payments_initiation_button(frm);
- }
- },
+ refresh: function (frm) {
+ if (frm.doc.docstatus == 1) generate_payments_initiation(frm);
+ else {
+ frm.remove_custom_button(__(buttonName));
+ // add_generate_payments_initiation_button(frm);
+ }
+ },
});
function generate_payments_initiation(frm) {
- let condition = true;
- frappe.db
- .get_list("Salary Slip", {
- fields: ["name", "docstatus"],
- filters: {
- payroll_entry: frm.doc.name,
- },
- })
- .then((res) => {
- if (res.length == 0) condition = false;
- // loop through the salary slips and check if all are submitted
- res.forEach((slip) => {
- if (slip.docstatus != 1) {
- condition = false;
- }
- });
- // if all salary slips are submitted, add custom button
- if (condition == true) {
- add_generate_payments_initiation_button(frm);
- } else {
- frm.remove_custom_button(__(buttonName));
- }
- });
+ let condition = true;
+ frappe.db
+ .get_list("Salary Slip", {
+ fields: ["name", "docstatus"],
+ filters: {
+ payroll_entry: frm.doc.name,
+ },
+ })
+ .then((res) => {
+ if (res.length == 0) condition = false;
+ // loop through the salary slips and check if all are submitted
+ res.forEach((slip) => {
+ if (slip.docstatus != 1) {
+ condition = false;
+ }
+ });
+ // if all salary slips are submitted, add custom button
+ if (condition == true) {
+ add_generate_payments_initiation_button(frm);
+ } else {
+ frm.remove_custom_button(__(buttonName));
+ }
+ });
}
function add_generate_payments_initiation_button(frm) {
- frm.add_custom_button(__(buttonName), function () {
- frappe.call({
- method: "csf_tz.stanbic.payments.make_payments_initiation",
- args: {
- payroll_entry_name: frm.doc.name,
- currency: frm.doc.currency,
- },
- callback: function (r) {
- if (r.message) {
- console.log(r.message);
- }
- },
- });
- });
+ frm.add_custom_button(__(buttonName), function () {
+ frappe.call({
+ method: "csf_tz.stanbic.payments.make_payments_initiation",
+ args: {
+ payroll_entry_name: frm.doc.name,
+ currency: frm.doc.currency,
+ },
+ callback: function (r) {
+ if (r.message) {
+ console.log(r.message);
+ }
+ },
+ });
+ });
}
diff --git a/csf_tz/utils/authority_notification_settings_fields.py b/csf_tz/utils/authority_notification_settings_fields.py
deleted file mode 100644
index 49420c03..00000000
--- a/csf_tz/utils/authority_notification_settings_fields.py
+++ /dev/null
@@ -1,106 +0,0 @@
-from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
-
-
-def execute():
- fields = {
- "CSF TZ Settings": [
- {
- "fieldname": "authority_notification_section",
- "fieldtype": "Section Break",
- "label": "Authority Notifications",
- "insert_after": "tz_regions_populated",
- },
- {
- "fieldname": "enable_latra_license_notifications",
- "fieldtype": "Check",
- "label": "Enable LATRA License Notifications",
- "default": "0",
- "insert_after": "authority_notification_section",
- },
- {
- "fieldname": "enable_latra_offence_notifications",
- "fieldtype": "Check",
- "label": "Enable LATRA Offence Notifications",
- "default": "0",
- "insert_after": "enable_latra_license_notifications",
- },
- {
- "fieldname": "enable_tira_notifications",
- "fieldtype": "Check",
- "label": "Enable TIRA Notifications",
- "default": "0",
- "insert_after": "enable_latra_offence_notifications",
- },
- {
- "fieldname": "enable_vehicle_fine_notifications",
- "fieldtype": "Check",
- "label": "Enable Vehicle Fine Notifications",
- "default": "0",
- "insert_after": "enable_tira_notifications",
- },
- {
- "fieldname": "column_break_authority_notification",
- "fieldtype": "Column Break",
- "insert_after": "enable_vehicle_fine_notifications",
- },
- {
- "fieldname": "latra_license_notify_before_days",
- "fieldtype": "Int",
- "label": "LATRA License Notify Before Days",
- "default": "7",
- "depends_on": "eval:doc.enable_latra_license_notifications",
- "mandatory_depends_on": "eval:doc.enable_latra_license_notifications",
- "insert_after": "column_break_authority_notification",
- },
- {
- "fieldname": "latra_offence_notify_on_new",
- "fieldtype": "Check",
- "label": "LATRA Offence Notify On New",
- "default": "1",
- "depends_on": "eval:doc.enable_latra_offence_notifications",
- "insert_after": "latra_license_notify_before_days",
- },
- {
- "fieldname": "latra_offence_notify_on_status_change",
- "fieldtype": "Check",
- "label": "LATRA Offence Notify On Status Change",
- "default": "0",
- "depends_on": "eval:doc.enable_latra_offence_notifications",
- "insert_after": "latra_offence_notify_on_new",
- },
- {
- "fieldname": "tira_notify_before_days",
- "fieldtype": "Int",
- "label": "TIRA Notify Before Days",
- "default": "7",
- "depends_on": "eval:doc.enable_tira_notifications",
- "mandatory_depends_on": "eval:doc.enable_tira_notifications",
- "insert_after": "latra_offence_notify_on_status_change",
- },
- {
- "fieldname": "vehicle_fine_notify_on_new",
- "fieldtype": "Check",
- "label": "Vehicle Fine Notify On New",
- "default": "1",
- "depends_on": "eval:doc.enable_vehicle_fine_notifications",
- "insert_after": "tira_notify_before_days",
- },
- {
- "fieldname": "vehicle_fine_notify_on_status_change",
- "fieldtype": "Check",
- "label": "Vehicle Fine Notify On Status Change",
- "default": "0",
- "depends_on": "eval:doc.enable_vehicle_fine_notifications",
- "insert_after": "vehicle_fine_notify_on_new",
- },
- {
- "fieldname": "authority_notification_roles",
- "fieldtype": "Table",
- "label": "Authority Notification Roles",
- "options": "Authority Notification Role",
- "insert_after": "vehicle_fine_notify_on_status_change",
- },
- ]
- }
-
- create_custom_fields(fields, update=True)
diff --git a/csf_tz/vfd_providers/doctype/simplify_vfd_settings/simplify_vfd_settings.js b/csf_tz/vfd_providers/doctype/simplify_vfd_settings/simplify_vfd_settings.js
index 49702b39..46a7bced 100644
--- a/csf_tz/vfd_providers/doctype/simplify_vfd_settings/simplify_vfd_settings.js
+++ b/csf_tz/vfd_providers/doctype/simplify_vfd_settings/simplify_vfd_settings.js
@@ -1,7 +1,7 @@
// Copyright (c) 2024, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Simplify VFD Settings', {
+frappe.ui.form.on("Simplify VFD Settings", {
// refresh: function(frm) {
// }
@@ -16,7 +16,7 @@ frappe.ui.form.on('Simplify VFD Settings', {
if (r.message) {
frm.refresh();
}
- }
- })
+ },
+ });
},
});
diff --git a/csf_tz/vfd_providers/doctype/total_vfd_setting/total_vfd_setting.js b/csf_tz/vfd_providers/doctype/total_vfd_setting/total_vfd_setting.js
index 75d19c1a..1ced2596 100644
--- a/csf_tz/vfd_providers/doctype/total_vfd_setting/total_vfd_setting.js
+++ b/csf_tz/vfd_providers/doctype/total_vfd_setting/total_vfd_setting.js
@@ -1,8 +1,7 @@
// Copyright (c) 2024, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Total VFD Setting', {
+frappe.ui.form.on("Total VFD Setting", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/vfd_providers/doctype/vfd_provider/vfd_provider.js b/csf_tz/vfd_providers/doctype/vfd_provider/vfd_provider.js
index e4dbe3d0..feb7457a 100644
--- a/csf_tz/vfd_providers/doctype/vfd_provider/vfd_provider.js
+++ b/csf_tz/vfd_providers/doctype/vfd_provider/vfd_provider.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('VFD Provider', {
+frappe.ui.form.on("VFD Provider", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/vfd_providers/doctype/vfd_provider_posting/vfd_provider_posting.js b/csf_tz/vfd_providers/doctype/vfd_provider_posting/vfd_provider_posting.js
index 73f15733..3800742e 100644
--- a/csf_tz/vfd_providers/doctype/vfd_provider_posting/vfd_provider_posting.js
+++ b/csf_tz/vfd_providers/doctype/vfd_provider_posting/vfd_provider_posting.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('VFD Provider Posting', {
+frappe.ui.form.on("VFD Provider Posting", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/vfd_providers/doctype/vfdplus_settings/vfdplus_settings.js b/csf_tz/vfd_providers/doctype/vfdplus_settings/vfdplus_settings.js
index 768910c4..1663ad91 100644
--- a/csf_tz/vfd_providers/doctype/vfdplus_settings/vfdplus_settings.js
+++ b/csf_tz/vfd_providers/doctype/vfdplus_settings/vfdplus_settings.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('VFDPlus Settings', {
+frappe.ui.form.on("VFDPlus Settings", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/vfd_settings/doctype/company_vfd_provider/company_vfd_provider.js b/csf_tz/vfd_settings/doctype/company_vfd_provider/company_vfd_provider.js
index 69cdd607..e13233cf 100644
--- a/csf_tz/vfd_settings/doctype/company_vfd_provider/company_vfd_provider.js
+++ b/csf_tz/vfd_settings/doctype/company_vfd_provider/company_vfd_provider.js
@@ -1,8 +1,7 @@
// Copyright (c) 2023, Aakvatech Limited and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Company VFD Provider', {
+frappe.ui.form.on("Company VFD Provider", {
// refresh: function(frm) {
-
// }
});
diff --git a/csf_tz/vfd_support/customer.js b/csf_tz/vfd_support/customer.js
index 9b20c488..0ae78dc9 100644
--- a/csf_tz/vfd_support/customer.js
+++ b/csf_tz/vfd_support/customer.js
@@ -1,29 +1,29 @@
frappe.ui.form.on("Customer", {
- vfd_cust_id_type: function (frm) {
- if (frm.doc.vfd_cust_id_type == "1- TIN") {
- let tax_id = frm.doc.tax_id;
- let vfd_cust_id = tax_id.split('-').join('');
- frm.set_value("vfd_cust_id", vfd_cust_id)
- }
- },
- vfd_cust_id: function (frm) {
- // frappe.msgprint(string(frm.doc.vfd_cust_id.length))
- // frappe.msgprint(frm.doc.vfd_cust_id_type.startsWith('1'))
- if (frm.doc.tax_id.length != 9 && frm.doc.vfd_cust_id_type.startsWith('1')) {
- frappe.throw(__("TIN Number is should be 9 numbers only, Please remove the dashes"));
- }
- },
- tax_id: function (frm) {
- frm.fields_dict.tax_id.$input.focusout(function () {
- if (frm.doc.tax_id.length != 9) {
- frappe.throw(__("TIN Number is should be 9 numbers only, Please remove the dashes"));
- }
- if (frm.doc.tax_id) {
- let tax_id = frm.doc.tax_id;
- let vfd_cust_id = tax_id.split('-').join('');
- frm.set_value("vfd_cust_id", vfd_cust_id);
- frm.set_value("vfd_cust_id_type", "1- TIN");
- }
- });
- },
-})
+ vfd_cust_id_type: function (frm) {
+ if (frm.doc.vfd_cust_id_type == "1- TIN") {
+ let tax_id = frm.doc.tax_id;
+ let vfd_cust_id = tax_id.split("-").join("");
+ frm.set_value("vfd_cust_id", vfd_cust_id);
+ }
+ },
+ vfd_cust_id: function (frm) {
+ // frappe.msgprint(string(frm.doc.vfd_cust_id.length))
+ // frappe.msgprint(frm.doc.vfd_cust_id_type.startsWith('1'))
+ if (frm.doc.tax_id.length != 9 && frm.doc.vfd_cust_id_type.startsWith("1")) {
+ frappe.throw(__("TIN Number is should be 9 numbers only, Please remove the dashes"));
+ }
+ },
+ tax_id: function (frm) {
+ frm.fields_dict.tax_id.$input.focusout(function () {
+ if (frm.doc.tax_id.length != 9) {
+ frappe.throw(__("TIN Number is should be 9 numbers only, Please remove the dashes"));
+ }
+ if (frm.doc.tax_id) {
+ let tax_id = frm.doc.tax_id;
+ let vfd_cust_id = tax_id.split("-").join("");
+ frm.set_value("vfd_cust_id", vfd_cust_id);
+ frm.set_value("vfd_cust_id_type", "1- TIN");
+ }
+ });
+ },
+});
diff --git a/csf_tz/vfd_support/sales_invoice.js b/csf_tz/vfd_support/sales_invoice.js
index 2a906f85..42258779 100644
--- a/csf_tz/vfd_support/sales_invoice.js
+++ b/csf_tz/vfd_support/sales_invoice.js
@@ -1,220 +1,229 @@
frappe.ui.form.on("Sales Invoice", {
- refresh: function (frm) {},
- generate_vfd: (frm) => {
- if (!frm.doc.vfd_cust_id) {
- frappe.msgprint({
- title: __("Confirmation Required"),
- message: __("Are you sure you want to send VFD without TIN"),
- primary_action: {
- label: "Proceed",
- action(values) {
- _generate_vfd(frm);
- cur_dialog.cancel();
- },
- },
- });
- } else if (frm.doc.vfd_cust_id && frm.doc.vfd_cust_id != frm.doc.tax_id) {
- frappe.msgprint({
- title: __("Confirmation Required"),
- message: __("TIN an VFD Customer ID mismatch"),
- primary_action: {
- label: "Proceed",
- action(values) {
- _generate_vfd(frm);
- cur_dialog.cancel();
- },
- },
- });
- } else {
- _generate_vfd(frm);
- }
- },
+ refresh: function (frm) {},
+ generate_vfd: (frm) => {
+ if (!frm.doc.vfd_cust_id) {
+ frappe.msgprint({
+ title: __("Confirmation Required"),
+ message: __("Are you sure you want to send VFD without TIN"),
+ primary_action: {
+ label: "Proceed",
+ action(values) {
+ _generate_vfd(frm);
+ cur_dialog.cancel();
+ },
+ },
+ });
+ } else if (frm.doc.vfd_cust_id && frm.doc.vfd_cust_id != frm.doc.tax_id) {
+ frappe.msgprint({
+ title: __("Confirmation Required"),
+ message: __("TIN an VFD Customer ID mismatch"),
+ primary_action: {
+ label: "Proceed",
+ action(values) {
+ _generate_vfd(frm);
+ cur_dialog.cancel();
+ },
+ },
+ });
+ } else {
+ _generate_vfd(frm);
+ }
+ },
});
function _generate_vfd(frm) {
- frappe.call({
- method: "csf_tz.vfd_support.utils.generate_tra_vfd",
- args: {
- docname: frm.doc.name,
- },
- freeze: true,
- freeze_message: __("Preparing VFD preview..."),
- callback: (r) => {
+ frappe.call({
+ method: "csf_tz.vfd_support.utils.generate_tra_vfd",
+ args: {
+ docname: frm.doc.name,
+ },
+ freeze: true,
+ freeze_message: __("Preparing VFD preview..."),
+ callback: (r) => {
+ let data = r.message.data;
+ let vfd_provider = r.message.vfd_provider;
+ let preview = r.message.preview;
- let data = r.message.data
- let vfd_provider = r.message.vfd_provider
- let preview = r.message.preview
-
- if (data && !preview) {
- frm.reload_doc();
- frappe.show_alert({
- message: __("VFD successfully sent to TRA"),
- indicator: "green",
- });
- } else if (data && preview) {
- show_vfd_preview_dialog(frm, data, vfd_provider);
- } else if (!data) {
- frappe.msgprint(__("VFD generation failed"));
- }
- },
- error: () => {
- frappe.msgprint(__("VFD generation failed"));
- },
- });
+ if (data && !preview) {
+ frm.reload_doc();
+ frappe.show_alert({
+ message: __("VFD successfully sent to TRA"),
+ indicator: "green",
+ });
+ } else if (data && preview) {
+ show_vfd_preview_dialog(frm, data, vfd_provider);
+ } else if (!data) {
+ frappe.msgprint(__("VFD generation failed"));
+ }
+ },
+ error: () => {
+ frappe.msgprint(__("VFD generation failed"));
+ },
+ });
}
function show_vfd_preview_dialog(frm, payload, vfd_provider) {
- // Some providers (esp. VFDPlus) may return payload as serialized JSON string.
- if (payload && typeof payload === 'string') {
- try {
- payload = JSON.parse(payload);
- } catch (e) {
- // Leave as-is; normalization will handle empty objects safely.
- }
- }
- // Normalize differing payload structures across providers (SimplifyVFD, VFDPlus, TotalVFD)
- function normalizePayload(raw, provider) {
- const p = raw || {};
- // Customer object differences
- let customerObj = p.customer || {};
- if (provider === "VFDPlus") {
- customerObj = p.customer_info || {};
- }
+ // Some providers (esp. VFDPlus) may return payload as serialized JSON string.
+ if (payload && typeof payload === "string") {
+ try {
+ payload = JSON.parse(payload);
+ } catch (e) {
+ // Leave as-is; normalization will handle empty objects safely.
+ }
+ }
+ // Normalize differing payload structures across providers (SimplifyVFD, VFDPlus, TotalVFD)
+ function normalizePayload(raw, provider) {
+ const p = raw || {};
+ // Customer object differences
+ let customerObj = p.customer || {};
+ if (provider === "VFDPlus") {
+ customerObj = p.customer_info || {};
+ }
- const customerName = customerObj.name || customerObj.cust_name || customerObj.customerName || '';
- const identificationType = customerObj.identificationType || customerObj.cust_id_type || customerObj.idType || '';
- const identificationNumber = customerObj.identificationNumber || customerObj.cust_id || customerObj.idValue || '';
- const vatRegistrationNumber = customerObj.vatRegistrationNumber || customerObj.cust_vrn || customerObj.vrn || '';
+ const customerName = customerObj.name || customerObj.cust_name || customerObj.customerName || "";
+ const identificationType =
+ customerObj.identificationType || customerObj.cust_id_type || customerObj.idType || "";
+ const identificationNumber =
+ customerObj.identificationNumber || customerObj.cust_id || customerObj.idValue || "";
+ const vatRegistrationNumber =
+ customerObj.vatRegistrationNumber || customerObj.cust_vrn || customerObj.vrn || "";
- // Invoice / reference id key differences
- const partnerInvoiceId = p.partnerInvoiceId || p.trans_no || p.referenceNumber || frm.doc.name;
- const invoiceAmountType = p.invoiceAmountType || p.amountType || '';
+ // Invoice / reference id key differences
+ const partnerInvoiceId = p.partnerInvoiceId || p.trans_no || p.referenceNumber || frm.doc.name;
+ const invoiceAmountType = p.invoiceAmountType || p.amountType || "";
- // Date / time differences
- let dateTime = p.dateTime || '';
- if (!dateTime) {
- if (provider === "VFDPlus") {
- if (p.idate) {
- dateTime = p.idate + (p.itime ? " " + p.itime : '');
- }
- }
- // TotalVFD sample does not provide date; fallback handled later
- }
+ // Date / time differences
+ let dateTime = p.dateTime || "";
+ if (!dateTime) {
+ if (provider === "VFDPlus") {
+ if (p.idate) {
+ dateTime = p.idate + (p.itime ? " " + p.itime : "");
+ }
+ }
+ // TotalVFD sample does not provide date; fallback handled later
+ }
- // Items arrays differences
- let items = [];
- if (Array.isArray(p.items)) {
- items = p.items.map(it => ({
- description: it.description || it.name || it.item_name || '',
- quantity: it.quantity || it.qty || it.item_qty || 0,
- unitAmount: it.unitAmount || parseFloat((it.price / (it.qty || 1)).toFixed(2)) || it.usp || 0,
- taxType: (it.taxType || it.vatGroup || it.vat_rate_code || '').toString(),
- _raw: it,
- }));
- } else if (Array.isArray(p.cart_items)) { // VFDPlus
- items = p.cart_items.map(it => ({
- description: it.description || it.item_name || '',
- quantity: it.quantity || it.item_qty || 0,
- unitAmount: it.unitAmount || it.usp || 0,
- taxType: (it.taxType || it.vat_rate_code || '').toString(),
- _raw: it,
- }));
- }
+ // Items arrays differences
+ let items = [];
+ if (Array.isArray(p.items)) {
+ items = p.items.map((it) => ({
+ description: it.description || it.name || it.item_name || "",
+ quantity: it.quantity || it.qty || it.item_qty || 0,
+ unitAmount: it.unitAmount || parseFloat((it.price / (it.qty || 1)).toFixed(2)) || it.usp || 0,
+ taxType: (it.taxType || it.vatGroup || it.vat_rate_code || "").toString(),
+ _raw: it,
+ }));
+ } else if (Array.isArray(p.cart_items)) {
+ // VFDPlus
+ items = p.cart_items.map((it) => ({
+ description: it.description || it.item_name || "",
+ quantity: it.quantity || it.item_qty || 0,
+ unitAmount: it.unitAmount || it.usp || 0,
+ taxType: (it.taxType || it.vat_rate_code || "").toString(),
+ _raw: it,
+ }));
+ }
- // Payments arrays differences
- let payments = [];
- if (Array.isArray(p.payments)) {
- payments = p.payments.map(pm => ({
- type: pm.type || pm.pmt_type || '',
- amount: pm.amount || pm.pmt_amount || 0,
- }));
- } else if (Array.isArray(p.payment_methods)) { // VFDPlus
- payments = p.payment_methods.map(pm => ({
- type: pm.type || pm.pmt_type || '',
- amount: pm.amount || pm.pmt_amount || 0,
- }));
- }
+ // Payments arrays differences
+ let payments = [];
+ if (Array.isArray(p.payments)) {
+ payments = p.payments.map((pm) => ({
+ type: pm.type || pm.pmt_type || "",
+ amount: pm.amount || pm.pmt_amount || 0,
+ }));
+ } else if (Array.isArray(p.payment_methods)) {
+ // VFDPlus
+ payments = p.payment_methods.map((pm) => ({
+ type: pm.type || pm.pmt_type || "",
+ amount: pm.amount || pm.pmt_amount || 0,
+ }));
+ }
- return {
- customerName,
- identificationType,
- identificationNumber,
- vatRegistrationNumber,
- partnerInvoiceId,
- invoiceAmountType,
- dateTime,
- items,
- payments,
- };
- }
+ return {
+ customerName,
+ identificationType,
+ identificationNumber,
+ vatRegistrationNumber,
+ partnerInvoiceId,
+ invoiceAmountType,
+ dateTime,
+ items,
+ payments,
+ };
+ }
- const norm = normalizePayload(payload, vfd_provider);
- const normalizedItems = norm.items || [];
- const normalizedPayments = norm.payments || [];
- const normalizedDateTime = norm.dateTime;
+ const norm = normalizePayload(payload, vfd_provider);
+ const normalizedItems = norm.items || [];
+ const normalizedPayments = norm.payments || [];
+ const normalizedDateTime = norm.dateTime;
- const formatNumber = (val) =>
- new Intl.NumberFormat("en-US", {
- minimumFractionDigits: 2,
- maximumFractionDigits: 2,
- }).format(flt(val));
+ const formatNumber = (val) =>
+ new Intl.NumberFormat("en-US", {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ }).format(flt(val));
- // Compute totals & taxes (assume STANDARD = 18% VAT, others = 0 for preview purposes)
- let totalIncl = 0;
- let taxAmount = 0;
+ // Compute totals & taxes (assume STANDARD = 18% VAT, others = 0 for preview purposes)
+ let totalIncl = 0;
+ let taxAmount = 0;
- (normalizedItems || []).forEach((item) => {
- const lineTotal = (item.unitAmount || 0) * (item.quantity || 0);
- totalIncl += lineTotal;
- const taxCode = (item.taxType || '').toUpperCase();
- const taxRate = ["STANDARD", "A"].includes(taxCode) ? 0.18 : 0;
+ (normalizedItems || []).forEach((item) => {
+ const lineTotal = (item.unitAmount || 0) * (item.quantity || 0);
+ totalIncl += lineTotal;
+ const taxCode = (item.taxType || "").toUpperCase();
+ const taxRate = ["STANDARD", "A"].includes(taxCode) ? 0.18 : 0;
- if (taxRate) {
- const netLineTotal = flt(lineTotal / (1 + taxRate));
- taxAmount += lineTotal - netLineTotal;
- }
- });
+ if (taxRate) {
+ const netLineTotal = flt(lineTotal / (1 + taxRate));
+ taxAmount += lineTotal - netLineTotal;
+ }
+ });
- let totalExcl = totalIncl - taxAmount;
+ let totalExcl = totalIncl - taxAmount;
- // Guard against negative/NaN
- if (totalExcl < 0 || isNaN(totalExcl)) {
- totalExcl = 0;
- }
+ // Guard against negative/NaN
+ if (totalExcl < 0 || isNaN(totalExcl)) {
+ totalExcl = 0;
+ }
- if (isNaN(taxAmount)) {
- taxAmount = 0;
- }
+ if (isNaN(taxAmount)) {
+ taxAmount = 0;
+ }
- const company_name = (frm.doc.company || "").toUpperCase();
- let receipt_date = ''
- if (normalizedDateTime && !["None", "null", "Invalid date", "undefined"].includes(String(normalizedDateTime))) {
- const dt = frappe.datetime.str_to_obj(normalizedDateTime);
- receipt_date = frappe.datetime.str_to_user(frappe.datetime.obj_to_str(dt, "YYYY-MM-DD"));
- } else {
- receipt_date = frappe.datetime.nowdate();
- }
+ const company_name = (frm.doc.company || "").toUpperCase();
+ let receipt_date = "";
+ if (
+ normalizedDateTime &&
+ !["None", "null", "Invalid date", "undefined"].includes(String(normalizedDateTime))
+ ) {
+ const dt = frappe.datetime.str_to_obj(normalizedDateTime);
+ receipt_date = frappe.datetime.str_to_user(frappe.datetime.obj_to_str(dt, "YYYY-MM-DD"));
+ } else {
+ receipt_date = frappe.datetime.nowdate();
+ }
- // Helpers to conditionally build info rows (omit labels if value absent)
- function buildInfoRow(label, value) {
- const hasVal = value !== undefined && value !== null && String(value).trim() !== '';
- if (!hasVal) return '';
- return `
${frappe.utils.escape_html(label)}${frappe.utils.escape_html(String(value))}
`;
- }
+ // Helpers to conditionally build info rows (omit labels if value absent)
+ function buildInfoRow(label, value) {
+ const hasVal = value !== undefined && value !== null && String(value).trim() !== "";
+ if (!hasVal) return "";
+ return `
${frappe.utils.escape_html(
+ label
+ )}${frappe.utils.escape_html(String(value))}
`;
+ }
- const customerInfoHTML = [
- buildInfoRow("Customer Name:", norm.customerName),
- buildInfoRow("Customer ID Type:", norm.identificationType),
- buildInfoRow("Customer ID:", norm.identificationNumber),
- buildInfoRow("VAT Reg No:", norm.vatRegistrationNumber),
- ].join('');
+ const customerInfoHTML = [
+ buildInfoRow("Customer Name:", norm.customerName),
+ buildInfoRow("Customer ID Type:", norm.identificationType),
+ buildInfoRow("Customer ID:", norm.identificationNumber),
+ buildInfoRow("VAT Reg No:", norm.vatRegistrationNumber),
+ ].join("");
- const invoiceInfoHTML = [
- buildInfoRow("Tax Type:", norm.invoiceAmountType),
- buildInfoRow("Invoice ID:", norm.partnerInvoiceId || frm.doc.name),
- ].join('');
+ const invoiceInfoHTML = [
+ buildInfoRow("Tax Type:", norm.invoiceAmountType),
+ buildInfoRow("Invoice ID:", norm.partnerInvoiceId || frm.doc.name),
+ ].join("");
- const receiptHTML = `
+ const receiptHTML = `
${frappe.utils.escape_html(company_name)}
-
TIN: ${frappe.utils.escape_html(frm.doc.tax_id || '-')} | RECEIPT DATE: ${frappe.utils.escape_html(receipt_date)}
+
TIN: ${frappe.utils.escape_html(
+ frm.doc.tax_id || "-"
+ )} | RECEIPT DATE: ${frappe.utils.escape_html(receipt_date)}
@@ -267,16 +278,16 @@ function show_vfd_preview_dialog(frm, payload, vfd_provider) {
${(normalizedItems || [])
- .map((it) => {
- const lineTotal = (it.unitAmount || 0) * (it.quantity || 0);
- return `
- | ${frappe.utils.escape_html(it.description || '')} |
+ .map((it) => {
+ const lineTotal = (it.unitAmount || 0) * (it.quantity || 0);
+ return `
+ | ${frappe.utils.escape_html(it.description || "")} |
${formatNumber(it.quantity || 0)} |
${formatNumber(it.unitAmount || 0)} |
${formatNumber(lineTotal)} |
`;
- })
- .join('')}
+ })
+ .join("")}
@@ -295,69 +306,69 @@ function show_vfd_preview_dialog(frm, payload, vfd_provider) {
`;
- let method = ''
- if (vfd_provider === "VFDPlus") {
- method = "csf_tz.vfd_providers.doctype.vfdplus_settings.vfdplus_settings.post_fiscal_receipt"
- } else if (vfd_provider === "TotalVFD") {
- method = "csf_tz.vfd_providers.doctype.total_vfd_setting.total_vfd_setting.post_fiscal_receipt"
- } else if (vfd_provider === "SimplifyVFD") {
- method = "csf_tz.vfd_providers.doctype.simplify_vfd_settings.simplify_vfd_settings.post_fiscal_receipt"
- }
+ let method = "";
+ if (vfd_provider === "VFDPlus") {
+ method = "csf_tz.vfd_providers.doctype.vfdplus_settings.vfdplus_settings.post_fiscal_receipt";
+ } else if (vfd_provider === "TotalVFD") {
+ method = "csf_tz.vfd_providers.doctype.total_vfd_setting.total_vfd_setting.post_fiscal_receipt";
+ } else if (vfd_provider === "SimplifyVFD") {
+ method =
+ "csf_tz.vfd_providers.doctype.simplify_vfd_settings.simplify_vfd_settings.post_fiscal_receipt";
+ }
- let d = new frappe.ui.Dialog({
- title: __("VFD Receipt Preview"),
- fields: [
- {
- fieldtype: "HTML",
- fieldname: "preview_html",
- options: receiptHTML,
- },
- ],
- primary_action_label: __("Send To TRA"),
- primary_action() {
- // Submit to TRA
- frappe
- .call({
- method: method,
- args: {
- method: "POST",
- payload: payload,
- invoice_id: frm.doc.name
- },
- freeze: true,
- freeze_message: __("Sending to TRA..."),
- })
- .then((res) => {
- d.hide();
- frm.reload_doc();
- if (res.message.data) {
- frappe.show_alert({
- message: __("VFD successfully sent to TRA"),
- indicator: "green",
- });
- } else {
- frappe.show_alert({
- message: __("VFD sending completed with errors"),
- indicator: "orange",
- });
- }
- })
- },
- secondary_action_label: __("Close"),
- secondary_action() {
- d.hide();
- },
- });
+ let d = new frappe.ui.Dialog({
+ title: __("VFD Receipt Preview"),
+ fields: [
+ {
+ fieldtype: "HTML",
+ fieldname: "preview_html",
+ options: receiptHTML,
+ },
+ ],
+ primary_action_label: __("Send To TRA"),
+ primary_action() {
+ // Submit to TRA
+ frappe
+ .call({
+ method: method,
+ args: {
+ method: "POST",
+ payload: payload,
+ invoice_id: frm.doc.name,
+ },
+ freeze: true,
+ freeze_message: __("Sending to TRA..."),
+ })
+ .then((res) => {
+ d.hide();
+ frm.reload_doc();
+ if (res.message.data) {
+ frappe.show_alert({
+ message: __("VFD successfully sent to TRA"),
+ indicator: "green",
+ });
+ } else {
+ frappe.show_alert({
+ message: __("VFD sending completed with errors"),
+ indicator: "orange",
+ });
+ }
+ });
+ },
+ secondary_action_label: __("Close"),
+ secondary_action() {
+ d.hide();
+ },
+ });
- d.$wrapper.find(".modal-content").css("width", "650px");
+ d.$wrapper.find(".modal-content").css("width", "650px");
- d.show();
+ d.show();
}
+//
+//
CUSTOMER
- //
- //
CUSTOMER
-
- //
INVOICE
+//
INVOICE
diff --git a/pyproject.toml b/pyproject.toml
index 1cc098bd..da8fd493 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,15 +22,27 @@ dependencies = [
"selcom-apigw-client",
]
+[project.optional-dependencies]
+dev = [
+ "pre-commit",
+]
+
[build-system]
requires = ["flit_core >=3.4,<4"]
build-backend = "flit_core.buildapi"
[tool.ruff]
line-length = 110
+target-version = "py310"
[tool.ruff.format]
+quote-style = "double"
indent-style = "tab"
+docstring-code-format = true
+
+[tool.ruff.lint]
+select = ["F", "E", "W", "I", "UP", "B"]
+ignore = ["E101", "E402", "E501", "E741", "W191"]
[tool.bench.frappe-dependencies]
frappe = ">=15.0.0,<16.0.0"
diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh
new file mode 100755
index 00000000..58aabf1f
--- /dev/null
+++ b/scripts/setup-git-hooks.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Installs pre-commit and wires up the commit and push hooks for this clone.
+set -euo pipefail
+
+cd "$(git rev-parse --show-toplevel)"
+
+if ! command -v pre-commit >/dev/null 2>&1; then
+ echo "pre-commit not found, installing..."
+ if command -v uv >/dev/null 2>&1; then
+ uv tool install pre-commit
+ elif command -v pipx >/dev/null 2>&1; then
+ pipx install pre-commit
+ else
+ python3 -m pip install --user pre-commit
+ fi
+fi
+
+pre-commit install --install-hooks --overwrite
+
+echo
+echo "Hooks installed:"
+echo " pre-commit staged files only, fast"
+echo " commit-msg conventional commit message check"
+echo " pre-push pre-commit run --all-files, blocks the push on any failure"