Compare commits
9 Commits
rohitwaghc
...
holiday_so
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c5ea7417c | ||
|
|
2a7d1c4c8d | ||
|
|
14b009b093 | ||
|
|
530922848f | ||
|
|
79d51a0a0b | ||
|
|
ce7ac29d06 | ||
|
|
ff7108a3b1 | ||
|
|
77cc91d06b | ||
|
|
40cdde8820 |
@@ -9,13 +9,6 @@ trim_trailing_whitespace = true
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
|
||||||
# python, js indentation settings
|
# python, js indentation settings
|
||||||
[{*.py,*.js,*.vue,*.css,*.scss,*.html}]
|
[{*.py,*.js}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
max_line_length = 110
|
|
||||||
|
|
||||||
# JSON files - mostly doctype schema files
|
|
||||||
[{*.json}]
|
|
||||||
insert_final_newline = false
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|||||||
@@ -124,7 +124,6 @@
|
|||||||
"beforeEach": true,
|
"beforeEach": true,
|
||||||
"onScan": true,
|
"onScan": true,
|
||||||
"extend_cscript": true,
|
"extend_cscript": true,
|
||||||
"localforage": true,
|
"localforage": true
|
||||||
"Plaid": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
.github/helper/translation.py
vendored
Normal file
60
.github/helper/translation.py
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
errors_encounter = 0
|
||||||
|
pattern = re.compile(r"_\(([\"']{,3})(?P<message>((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P<py_context>((?!\5).)*)\5)*(\s*,(\s*?.*?\n*?)*(,\s*([\"'])(?P<js_context>((?!\11).)*)\11)*)*\)")
|
||||||
|
words_pattern = re.compile(r"_{1,2}\([\"'`]{1,3}.*?[a-zA-Z]")
|
||||||
|
start_pattern = re.compile(r"_{1,2}\([f\"'`]{1,3}")
|
||||||
|
f_string_pattern = re.compile(r"_\(f[\"']")
|
||||||
|
starts_with_f_pattern = re.compile(r"_\(f")
|
||||||
|
|
||||||
|
# skip first argument
|
||||||
|
files = sys.argv[1:]
|
||||||
|
files_to_scan = [_file for _file in files if _file.endswith(('.py', '.js'))]
|
||||||
|
|
||||||
|
for _file in files_to_scan:
|
||||||
|
with open(_file, 'r') as f:
|
||||||
|
print(f'Checking: {_file}')
|
||||||
|
file_lines = f.readlines()
|
||||||
|
for line_number, line in enumerate(file_lines, 1):
|
||||||
|
if 'frappe-lint: disable-translate' in line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
start_matches = start_pattern.search(line)
|
||||||
|
if start_matches:
|
||||||
|
starts_with_f = starts_with_f_pattern.search(line)
|
||||||
|
|
||||||
|
if starts_with_f:
|
||||||
|
has_f_string = f_string_pattern.search(line)
|
||||||
|
if has_f_string:
|
||||||
|
errors_encounter += 1
|
||||||
|
print(f'\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}')
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
match = pattern.search(line)
|
||||||
|
error_found = False
|
||||||
|
|
||||||
|
if not match and line.endswith((',\n', '[\n')):
|
||||||
|
# concat remaining text to validate multiline pattern
|
||||||
|
line = "".join(file_lines[line_number - 1:])
|
||||||
|
line = line[start_matches.start() + 1:]
|
||||||
|
match = pattern.match(line)
|
||||||
|
|
||||||
|
if not match:
|
||||||
|
error_found = True
|
||||||
|
print(f'\nTranslation syntax error at line number {line_number}\n{line.strip()[:100]}')
|
||||||
|
|
||||||
|
if not error_found and not words_pattern.search(line):
|
||||||
|
error_found = True
|
||||||
|
print(f'\nTranslation is useless because it has no words at line number {line_number}\n{line.strip()[:100]}')
|
||||||
|
|
||||||
|
if error_found:
|
||||||
|
errors_encounter += 1
|
||||||
|
|
||||||
|
if errors_encounter > 0:
|
||||||
|
print('\nVisit "https://frappeframework.com/docs/user/en/translations" to learn about valid translation strings.')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print('\nGood To Go!')
|
||||||
26
.github/workflows/backport.yml
vendored
Normal file
26
.github/workflows/backport.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Backport
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
- labeled
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
steps:
|
||||||
|
- name: Checkout Actions
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: "frappe/backport"
|
||||||
|
path: ./actions
|
||||||
|
ref: develop
|
||||||
|
- name: Install Actions
|
||||||
|
run: npm install --production --prefix ./actions
|
||||||
|
- name: Run backport
|
||||||
|
uses: ./actions/backport
|
||||||
|
with:
|
||||||
|
token: ${{secrets.BACKPORT_BOT_TOKEN}}
|
||||||
|
labelsToAdd: "backport"
|
||||||
|
title: "{{originalTitle}}"
|
||||||
32
.github/workflows/initiate_release.yml
vendored
Normal file
32
.github/workflows/initiate_release.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# This workflow is agnostic to branches. Only maintain on develop branch.
|
||||||
|
# To add/remove versions just modify the matrix.
|
||||||
|
|
||||||
|
name: Create weekly release pull requests
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# 9:30 UTC => 3 PM IST Tuesday
|
||||||
|
- cron: "30 9 * * 2"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stable-release:
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version: ["13", "14"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: octokit/request-action@v2.x
|
||||||
|
with:
|
||||||
|
route: POST /repos/{owner}/{repo}/pulls
|
||||||
|
owner: frappe
|
||||||
|
repo: erpnext
|
||||||
|
title: |-
|
||||||
|
"chore: release v${{ matrix.version }}"
|
||||||
|
body: "Automated weekly release."
|
||||||
|
base: version-${{ matrix.version }}
|
||||||
|
head: version-${{ matrix.version }}-hotfix
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
1
.github/workflows/patch.yml
vendored
1
.github/workflows/patch.yml
vendored
@@ -134,6 +134,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_to_version 14
|
update_to_version 14
|
||||||
|
update_to_version 15
|
||||||
|
|
||||||
echo "Updating to latest version"
|
echo "Updating to latest version"
|
||||||
git -C "apps/frappe" checkout -q -f "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}"
|
git -C "apps/frappe" checkout -q -f "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}"
|
||||||
|
|||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -2,23 +2,21 @@ name: Generate Semantic Release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- version-15
|
- version-13
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Entire Repository
|
- name: Checkout Entire Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 18
|
||||||
|
|
||||||
- name: Setup dependencies
|
- name: Setup dependencies
|
||||||
run: |
|
run: |
|
||||||
npm install @semantic-release/git @semantic-release/exec --no-save
|
npm install @semantic-release/git @semantic-release/exec --no-save
|
||||||
|
|||||||
26
.github/workflows/server-tests-mariadb.yml
vendored
26
.github/workflows/server-tests-mariadb.yml
vendored
@@ -117,7 +117,7 @@ jobs:
|
|||||||
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
|
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --total-builds 4 --build-number ${{ matrix.container }}'
|
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --with-coverage --total-builds 4 --build-number ${{ matrix.container }}'
|
||||||
env:
|
env:
|
||||||
TYPE: server
|
TYPE: server
|
||||||
CI_BUILD_ID: ${{ github.run_id }}
|
CI_BUILD_ID: ${{ github.run_id }}
|
||||||
@@ -126,3 +126,27 @@ jobs:
|
|||||||
- name: Show bench output
|
- name: Show bench output
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat ~/frappe-bench/bench_start.log || true
|
run: cat ~/frappe-bench/bench_start.log || true
|
||||||
|
|
||||||
|
- name: Upload coverage data
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: coverage-${{ matrix.container }}
|
||||||
|
path: /home/runner/frappe-bench/sites/coverage.xml
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
name: Coverage Wrap Up
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
|
||||||
|
- name: Upload coverage data
|
||||||
|
uses: codecov/codecov-action@v2
|
||||||
|
with:
|
||||||
|
name: MariaDB
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
|||||||
46
.mergify.yml
46
.mergify.yml
@@ -17,6 +17,7 @@ pull_request_rules:
|
|||||||
- base=version-12
|
- base=version-12
|
||||||
- base=version-14
|
- base=version-14
|
||||||
- base=version-15
|
- base=version-15
|
||||||
|
- base=version-16
|
||||||
actions:
|
actions:
|
||||||
close:
|
close:
|
||||||
comment:
|
comment:
|
||||||
@@ -24,16 +25,6 @@ pull_request_rules:
|
|||||||
@{{author}}, thanks for the contribution, but we do not accept pull requests on a stable branch. Please raise PR on an appropriate hotfix branch.
|
@{{author}}, thanks for the contribution, but we do not accept pull requests on a stable branch. Please raise PR on an appropriate hotfix branch.
|
||||||
https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist#which-branch
|
https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist#which-branch
|
||||||
|
|
||||||
- name: Auto-close PRs on pre-release branch
|
|
||||||
conditions:
|
|
||||||
- base=version-13-pre-release
|
|
||||||
actions:
|
|
||||||
close:
|
|
||||||
comment:
|
|
||||||
message: |
|
|
||||||
@{{author}}, pre-release branch is not maintained anymore. Releases are directly done by merging hotfix branch to stable branches.
|
|
||||||
|
|
||||||
|
|
||||||
- name: backport to develop
|
- name: backport to develop
|
||||||
conditions:
|
conditions:
|
||||||
- label="backport develop"
|
- label="backport develop"
|
||||||
@@ -54,13 +45,13 @@ pull_request_rules:
|
|||||||
assignees:
|
assignees:
|
||||||
- "{{ author }}"
|
- "{{ author }}"
|
||||||
|
|
||||||
- name: backport to version-14-pre-release
|
- name: backport to version-15-hotfix
|
||||||
conditions:
|
conditions:
|
||||||
- label="backport version-14-pre-release"
|
- label="backport version-15-hotfix"
|
||||||
actions:
|
actions:
|
||||||
backport:
|
backport:
|
||||||
branches:
|
branches:
|
||||||
- version-14-pre-release
|
- version-15-hotfix
|
||||||
assignees:
|
assignees:
|
||||||
- "{{ author }}"
|
- "{{ author }}"
|
||||||
|
|
||||||
@@ -74,35 +65,6 @@ pull_request_rules:
|
|||||||
assignees:
|
assignees:
|
||||||
- "{{ author }}"
|
- "{{ author }}"
|
||||||
|
|
||||||
- name: backport to version-13-pre-release
|
|
||||||
conditions:
|
|
||||||
- label="backport version-13-pre-release"
|
|
||||||
actions:
|
|
||||||
backport:
|
|
||||||
branches:
|
|
||||||
- version-13-pre-release
|
|
||||||
assignees:
|
|
||||||
- "{{ author }}"
|
|
||||||
|
|
||||||
- name: backport to version-12-hotfix
|
|
||||||
conditions:
|
|
||||||
- label="backport version-12-hotfix"
|
|
||||||
actions:
|
|
||||||
backport:
|
|
||||||
branches:
|
|
||||||
- version-12-hotfix
|
|
||||||
assignees:
|
|
||||||
- "{{ author }}"
|
|
||||||
|
|
||||||
- name: backport to version-12-pre-release
|
|
||||||
conditions:
|
|
||||||
- label="backport version-12-pre-release"
|
|
||||||
actions:
|
|
||||||
backport:
|
|
||||||
branches:
|
|
||||||
- version-12-pre-release
|
|
||||||
assignees:
|
|
||||||
- "{{ author }}"
|
|
||||||
|
|
||||||
- name: Automatic merge on CI success and review
|
- name: Automatic merge on CI success and review
|
||||||
conditions:
|
conditions:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ fail_fast: false
|
|||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.3.0
|
rev: v4.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
files: "erpnext.*"
|
files: "erpnext.*"
|
||||||
@@ -15,27 +15,6 @@ repos:
|
|||||||
args: ['--branch', 'develop']
|
args: ['--branch', 'develop']
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-json
|
|
||||||
- id: check-toml
|
|
||||||
- id: check-yaml
|
|
||||||
- id: debug-statements
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
||||||
rev: v2.7.1
|
|
||||||
hooks:
|
|
||||||
- id: prettier
|
|
||||||
types_or: [javascript, vue, scss]
|
|
||||||
# Ignore any files that might contain jinja / bundles
|
|
||||||
exclude: |
|
|
||||||
(?x)^(
|
|
||||||
erpnext/public/dist/.*|
|
|
||||||
cypress/.*|
|
|
||||||
.*node_modules.*|
|
|
||||||
.*boilerplate.*|
|
|
||||||
erpnext/public/js/controllers/.*|
|
|
||||||
erpnext/templates/pages/order.js|
|
|
||||||
erpnext/templates/includes/.*
|
|
||||||
)$
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||||
rev: v8.44.0
|
rev: v8.44.0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"branches": ["version-15"],
|
"branches": ["version-13"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@semantic-release/commit-analyzer", {
|
"@semantic-release/commit-analyzer", {
|
||||||
"preset": "angular",
|
"preset": "angular",
|
||||||
@@ -21,4 +21,4 @@
|
|||||||
],
|
],
|
||||||
"@semantic-release/github"
|
"@semantic-release/github"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,25 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
parserPreset: "conventional-changelog-conventionalcommits",
|
parserPreset: 'conventional-changelog-conventionalcommits',
|
||||||
rules: {
|
rules: {
|
||||||
"subject-empty": [2, "never"],
|
'subject-empty': [2, 'never'],
|
||||||
"type-case": [2, "always", "lower-case"],
|
'type-case': [2, 'always', 'lower-case'],
|
||||||
"type-empty": [2, "never"],
|
'type-empty': [2, 'never'],
|
||||||
"type-enum": [
|
'type-enum': [
|
||||||
2,
|
2,
|
||||||
"always",
|
'always',
|
||||||
["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"],
|
[
|
||||||
|
'build',
|
||||||
|
'chore',
|
||||||
|
'ci',
|
||||||
|
'docs',
|
||||||
|
'feat',
|
||||||
|
'fix',
|
||||||
|
'perf',
|
||||||
|
'refactor',
|
||||||
|
'revert',
|
||||||
|
'style',
|
||||||
|
'test',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import inspect
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
__version__ = "15.16.2"
|
__version__ = "15.0.0-dev"
|
||||||
|
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
@@ -13,7 +13,7 @@ def get_default_company(user=None):
|
|||||||
if not user:
|
if not user:
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
|
|
||||||
companies = get_user_default_as_list("company", user)
|
companies = get_user_default_as_list(user, "company")
|
||||||
if companies:
|
if companies:
|
||||||
default_company = companies[0]
|
default_company = companies[0]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
frappe.provide("frappe.dashboards.chart_sources");
|
frappe.provide('frappe.dashboards.chart_sources');
|
||||||
|
|
||||||
frappe.dashboards.chart_sources["Account Balance Timeline"] = {
|
frappe.dashboards.chart_sources["Account Balance Timeline"] = {
|
||||||
method: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get",
|
method: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get",
|
||||||
@@ -9,14 +9,14 @@ frappe.dashboards.chart_sources["Account Balance Timeline"] = {
|
|||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Company",
|
options: "Company",
|
||||||
default: frappe.defaults.get_user_default("Company"),
|
default: frappe.defaults.get_user_default("Company"),
|
||||||
reqd: 1,
|
reqd: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "account",
|
fieldname: "account",
|
||||||
label: __("Account"),
|
label: __("Account"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Account",
|
options: "Account",
|
||||||
reqd: 1,
|
reqd: 1
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,14 +26,19 @@ frappe.ui.form.on("Account", {
|
|||||||
frm.toggle_enable(["is_group", "company"], false);
|
frm.toggle_enable(["is_group", "company"], false);
|
||||||
|
|
||||||
if (cint(frm.doc.is_group) == 0) {
|
if (cint(frm.doc.is_group) == 0) {
|
||||||
frm.toggle_display("freeze_account", frm.doc.__onload && frm.doc.__onload.can_freeze_account);
|
frm.toggle_display(
|
||||||
|
"freeze_account",
|
||||||
|
frm.doc.__onload && frm.doc.__onload.can_freeze_account
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read-only for root accounts
|
// read-only for root accounts
|
||||||
if (!frm.is_new()) {
|
if (!frm.is_new()) {
|
||||||
if (!frm.doc.parent_account) {
|
if (!frm.doc.parent_account) {
|
||||||
frm.set_read_only();
|
frm.set_read_only();
|
||||||
frm.set_intro(__("This is a root account and cannot be edited."));
|
frm.set_intro(
|
||||||
|
__("This is a root account and cannot be edited.")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// credit days and type if customer or supplier
|
// credit days and type if customer or supplier
|
||||||
frm.set_intro(null);
|
frm.set_intro(null);
|
||||||
@@ -75,33 +80,27 @@ frappe.ui.form.on("Account", {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (frm.doc.is_group == 1) {
|
if (frm.doc.is_group == 1) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(__('Convert to Non-Group'), function () {
|
||||||
__("Convert to Non-Group"),
|
return frappe.call({
|
||||||
function () {
|
doc: frm.doc,
|
||||||
return frappe.call({
|
method: 'convert_group_to_ledger',
|
||||||
doc: frm.doc,
|
callback: function() {
|
||||||
method: "convert_group_to_ledger",
|
frm.refresh();
|
||||||
callback: function () {
|
}
|
||||||
frm.refresh();
|
});
|
||||||
},
|
}, __('Actions'));
|
||||||
});
|
|
||||||
},
|
} else if (cint(frm.doc.is_group) == 0
|
||||||
__("Actions")
|
&& frappe.boot.user.can_read.indexOf("GL Entry") !== -1) {
|
||||||
);
|
frm.add_custom_button(__('General Ledger'), function () {
|
||||||
} else if (cint(frm.doc.is_group) == 0 && frappe.boot.user.can_read.indexOf("GL Entry") !== -1) {
|
frappe.route_options = {
|
||||||
frm.add_custom_button(
|
"account": frm.doc.name,
|
||||||
__("General Ledger"),
|
"from_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||||
function () {
|
"to_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||||
frappe.route_options = {
|
"company": frm.doc.company
|
||||||
account: frm.doc.name,
|
};
|
||||||
from_date: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
frappe.set_route("query-report", "General Ledger");
|
||||||
to_date: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
}, __('View'));
|
||||||
company: frm.doc.company,
|
|
||||||
};
|
|
||||||
frappe.set_route("query-report", "General Ledger");
|
|
||||||
},
|
|
||||||
__("View")
|
|
||||||
);
|
|
||||||
|
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Convert to Group"),
|
__("Convert to Group"),
|
||||||
@@ -194,8 +193,14 @@ frappe.ui.form.on("Account", {
|
|||||||
if (r.message) {
|
if (r.message) {
|
||||||
frappe.set_route("Form", "Account", r.message);
|
frappe.set_route("Form", "Account", r.message);
|
||||||
} else {
|
} else {
|
||||||
frm.set_value("account_number", data.account_number);
|
frm.set_value(
|
||||||
frm.set_value("account_name", data.account_name);
|
"account_number",
|
||||||
|
data.account_number
|
||||||
|
);
|
||||||
|
frm.set_value(
|
||||||
|
"account_name",
|
||||||
|
data.account_name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
d.hide();
|
d.hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,65 +23,6 @@ class InvalidAccountMergeError(frappe.ValidationError):
|
|||||||
|
|
||||||
|
|
||||||
class Account(NestedSet):
|
class Account(NestedSet):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_currency: DF.Link | None
|
|
||||||
account_name: DF.Data
|
|
||||||
account_number: DF.Data | None
|
|
||||||
account_type: DF.Literal[
|
|
||||||
"",
|
|
||||||
"Accumulated Depreciation",
|
|
||||||
"Asset Received But Not Billed",
|
|
||||||
"Bank",
|
|
||||||
"Cash",
|
|
||||||
"Chargeable",
|
|
||||||
"Capital Work in Progress",
|
|
||||||
"Cost of Goods Sold",
|
|
||||||
"Current Asset",
|
|
||||||
"Current Liability",
|
|
||||||
"Depreciation",
|
|
||||||
"Direct Expense",
|
|
||||||
"Direct Income",
|
|
||||||
"Equity",
|
|
||||||
"Expense Account",
|
|
||||||
"Expenses Included In Asset Valuation",
|
|
||||||
"Expenses Included In Valuation",
|
|
||||||
"Fixed Asset",
|
|
||||||
"Income Account",
|
|
||||||
"Indirect Expense",
|
|
||||||
"Indirect Income",
|
|
||||||
"Liability",
|
|
||||||
"Payable",
|
|
||||||
"Receivable",
|
|
||||||
"Round Off",
|
|
||||||
"Stock",
|
|
||||||
"Stock Adjustment",
|
|
||||||
"Stock Received But Not Billed",
|
|
||||||
"Service Received But Not Billed",
|
|
||||||
"Tax",
|
|
||||||
"Temporary",
|
|
||||||
]
|
|
||||||
balance_must_be: DF.Literal["", "Debit", "Credit"]
|
|
||||||
company: DF.Link
|
|
||||||
disabled: DF.Check
|
|
||||||
freeze_account: DF.Literal["No", "Yes"]
|
|
||||||
include_in_gross: DF.Check
|
|
||||||
is_group: DF.Check
|
|
||||||
lft: DF.Int
|
|
||||||
old_parent: DF.Data | None
|
|
||||||
parent_account: DF.Link
|
|
||||||
report_type: DF.Literal["", "Balance Sheet", "Profit and Loss"]
|
|
||||||
rgt: DF.Int
|
|
||||||
root_type: DF.Literal["", "Asset", "Liability", "Income", "Expense", "Equity"]
|
|
||||||
tax_rate: DF.Float
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
nsm_parent_field = "parent_account"
|
nsm_parent_field = "parent_account"
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
@@ -118,7 +59,6 @@ class Account(NestedSet):
|
|||||||
self.validate_balance_must_be_debit_or_credit()
|
self.validate_balance_must_be_debit_or_credit()
|
||||||
self.validate_account_currency()
|
self.validate_account_currency()
|
||||||
self.validate_root_company_and_sync_account_to_children()
|
self.validate_root_company_and_sync_account_to_children()
|
||||||
self.validate_receivable_payable_account_type()
|
|
||||||
|
|
||||||
def validate_parent_child_account_type(self):
|
def validate_parent_child_account_type(self):
|
||||||
if self.parent_account:
|
if self.parent_account:
|
||||||
@@ -189,24 +129,6 @@ class Account(NestedSet):
|
|||||||
"Balance Sheet" if self.root_type in ("Asset", "Liability", "Equity") else "Profit and Loss"
|
"Balance Sheet" if self.root_type in ("Asset", "Liability", "Equity") else "Profit and Loss"
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_receivable_payable_account_type(self):
|
|
||||||
doc_before_save = self.get_doc_before_save()
|
|
||||||
receivable_payable_types = ["Receivable", "Payable"]
|
|
||||||
if (
|
|
||||||
doc_before_save
|
|
||||||
and doc_before_save.account_type in receivable_payable_types
|
|
||||||
and doc_before_save.account_type != self.account_type
|
|
||||||
):
|
|
||||||
# check for ledger entries
|
|
||||||
if frappe.db.get_all("GL Entry", filters={"account": self.name, "is_cancelled": 0}, limit=1):
|
|
||||||
msg = _(
|
|
||||||
"There are ledger entries against this account. Changing {0} to non-{1} in live system will cause incorrect output in 'Accounts {2}' report"
|
|
||||||
).format(
|
|
||||||
frappe.bold("Account Type"), doc_before_save.account_type, doc_before_save.account_type
|
|
||||||
)
|
|
||||||
frappe.msgprint(msg)
|
|
||||||
self.add_comment("Comment", msg)
|
|
||||||
|
|
||||||
def validate_root_details(self):
|
def validate_root_details(self):
|
||||||
doc_before_save = self.get_doc_before_save()
|
doc_before_save = self.get_doc_before_save()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
frappe.provide("frappe.treeview_settings");
|
frappe.provide("frappe.treeview_settings")
|
||||||
|
|
||||||
frappe.treeview_settings["Account"] = {
|
frappe.treeview_settings["Account"] = {
|
||||||
breadcrumb: "Accounts",
|
breadcrumb: "Accounts",
|
||||||
@@ -7,12 +7,12 @@ frappe.treeview_settings["Account"] = {
|
|||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
fieldname: "company",
|
fieldname: "company",
|
||||||
fieldtype: "Select",
|
fieldtype:"Select",
|
||||||
options: erpnext.utils.get_tree_options("company"),
|
options: erpnext.utils.get_tree_options("company"),
|
||||||
label: __("Company"),
|
label: __("Company"),
|
||||||
default: erpnext.utils.get_tree_default("company"),
|
default: erpnext.utils.get_tree_default("company"),
|
||||||
on_change: function () {
|
on_change: function() {
|
||||||
var me = frappe.treeview_settings["Account"].treeview;
|
var me = frappe.treeview_settings['Account'].treeview;
|
||||||
var company = me.page.fields_dict.company.get_value();
|
var company = me.page.fields_dict.company.get_value();
|
||||||
if (!company) {
|
if (!company) {
|
||||||
frappe.throw(__("Please set a Company"));
|
frappe.throw(__("Please set a Company"));
|
||||||
@@ -22,36 +22,30 @@ frappe.treeview_settings["Account"] = {
|
|||||||
args: {
|
args: {
|
||||||
company: company,
|
company: company,
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
if (r.message) {
|
if(r.message) {
|
||||||
let root_company = r.message.length ? r.message[0] : "";
|
let root_company = r.message.length ? r.message[0] : "";
|
||||||
me.page.fields_dict.root_company.set_value(root_company);
|
me.page.fields_dict.root_company.set_value(root_company);
|
||||||
|
|
||||||
frappe.db.get_value(
|
frappe.db.get_value("Company", {"name": company}, "allow_account_creation_against_child_company", (r) => {
|
||||||
"Company",
|
frappe.flags.ignore_root_company_validation = r.allow_account_creation_against_child_company;
|
||||||
{ name: company },
|
});
|
||||||
"allow_account_creation_against_child_company",
|
|
||||||
(r) => {
|
|
||||||
frappe.flags.ignore_root_company_validation =
|
|
||||||
r.allow_account_creation_against_child_company;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "root_company",
|
fieldname: "root_company",
|
||||||
fieldtype: "Data",
|
fieldtype:"Data",
|
||||||
label: __("Root Company"),
|
label: __("Root Company"),
|
||||||
hidden: true,
|
hidden: true,
|
||||||
disable_onchange: true,
|
disable_onchange: true
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
root_label: "Accounts",
|
root_label: "Accounts",
|
||||||
get_tree_nodes: "erpnext.accounts.utils.get_children",
|
get_tree_nodes: 'erpnext.accounts.utils.get_children',
|
||||||
on_get_node: function (nodes, deep = false) {
|
on_get_node: function(nodes, deep=false) {
|
||||||
if (frappe.boot.user.can_read.indexOf("GL Entry") == -1) return;
|
if (frappe.boot.user.can_read.indexOf("GL Entry") == -1) return;
|
||||||
|
|
||||||
let accounts = [];
|
let accounts = [];
|
||||||
@@ -63,231 +57,151 @@ frappe.treeview_settings["Account"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
frappe.db.get_single_value("Accounts Settings", "show_balance_in_coa").then((value) => {
|
frappe.db.get_single_value("Accounts Settings", "show_balance_in_coa").then((value) => {
|
||||||
if (value) {
|
if(value) {
|
||||||
|
|
||||||
const get_balances = frappe.call({
|
const get_balances = frappe.call({
|
||||||
method: "erpnext.accounts.utils.get_account_balances",
|
method: 'erpnext.accounts.utils.get_account_balances',
|
||||||
args: {
|
args: {
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
company: cur_tree.args.company,
|
company: cur_tree.args.company
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
get_balances.then((r) => {
|
get_balances.then(r => {
|
||||||
if (!r.message || r.message.length == 0) return;
|
if (!r.message || r.message.length == 0) return;
|
||||||
|
|
||||||
for (let account of r.message) {
|
for (let account of r.message) {
|
||||||
|
|
||||||
const node = cur_tree.nodes && cur_tree.nodes[account.value];
|
const node = cur_tree.nodes && cur_tree.nodes[account.value];
|
||||||
if (!node || node.is_root) continue;
|
if (!node || node.is_root) continue;
|
||||||
|
|
||||||
// show Dr if positive since balance is calculated as debit - credit else show Cr
|
// show Dr if positive since balance is calculated as debit - credit else show Cr
|
||||||
const balance = account.balance_in_account_currency || account.balance;
|
const balance = account.balance_in_account_currency || account.balance;
|
||||||
const dr_or_cr = balance > 0 ? "Dr" : "Cr";
|
const dr_or_cr = balance > 0 ? "Dr": "Cr";
|
||||||
const format = (value, currency) => format_currency(Math.abs(value), currency);
|
const format = (value, currency) => format_currency(Math.abs(value), currency);
|
||||||
|
|
||||||
if (account.balance !== undefined) {
|
if (account.balance!==undefined) {
|
||||||
node.parent && node.parent.find(".balance-area").remove();
|
node.parent && node.parent.find('.balance-area').remove();
|
||||||
$(
|
$('<span class="balance-area pull-right">'
|
||||||
'<span class="balance-area pull-right">' +
|
+ (account.balance_in_account_currency ?
|
||||||
(account.balance_in_account_currency
|
(format(account.balance_in_account_currency, account.account_currency) + " / ") : "")
|
||||||
? format(
|
+ format(account.balance, account.company_currency)
|
||||||
account.balance_in_account_currency,
|
+ " " + dr_or_cr
|
||||||
account.account_currency
|
+ '</span>').insertBefore(node.$ul);
|
||||||
) + " / "
|
|
||||||
: "") +
|
|
||||||
format(account.balance, account.company_currency) +
|
|
||||||
" " +
|
|
||||||
dr_or_cr +
|
|
||||||
"</span>"
|
|
||||||
).insertBefore(node.$ul);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
add_tree_node: "erpnext.accounts.utils.add_ac",
|
add_tree_node: 'erpnext.accounts.utils.add_ac',
|
||||||
menu_items: [
|
menu_items:[
|
||||||
{
|
{
|
||||||
label: __("New Company"),
|
label: __('New Company'),
|
||||||
action: function () {
|
action: function() { frappe.new_doc("Company", true) },
|
||||||
frappe.new_doc("Company", true);
|
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1'
|
||||||
},
|
}
|
||||||
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
|
||||||
fieldtype: "Data",
|
description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers")},
|
||||||
fieldname: "account_name",
|
{fieldtype:'Data', fieldname:'account_number', label:__('Account Number'),
|
||||||
label: __("New Account Name"),
|
description: __("Number of new Account, it will be included in the account name as a prefix")},
|
||||||
reqd: true,
|
{fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
|
||||||
description: __(
|
description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
|
||||||
"Name of new Account. Note: Please don't create accounts for Customers and Suppliers"
|
{fieldtype:'Select', fieldname:'root_type', label:__('Root Type'),
|
||||||
),
|
options: ['Asset', 'Liability', 'Equity', 'Income', 'Expense'].join('\n'),
|
||||||
},
|
depends_on: 'eval:doc.is_group && !doc.parent_account'},
|
||||||
{
|
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
|
||||||
fieldtype: "Data",
|
options: frappe.get_meta("Account").fields.filter(d => d.fieldname=='account_type')[0].options,
|
||||||
fieldname: "account_number",
|
description: __("Optional. This setting will be used to filter in various transactions.")
|
||||||
label: __("Account Number"),
|
|
||||||
description: __("Number of new Account, it will be included in the account name as a prefix"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Check",
|
|
||||||
fieldname: "is_group",
|
|
||||||
label: __("Is Group"),
|
|
||||||
description: __(
|
|
||||||
"Further accounts can be made under Groups, but entries can be made against non-Groups"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Select",
|
|
||||||
fieldname: "root_type",
|
|
||||||
label: __("Root Type"),
|
|
||||||
options: ["Asset", "Liability", "Equity", "Income", "Expense"].join("\n"),
|
|
||||||
depends_on: "eval:doc.is_group && !doc.parent_account",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Select",
|
|
||||||
fieldname: "account_type",
|
|
||||||
label: __("Account Type"),
|
|
||||||
options: frappe.get_meta("Account").fields.filter((d) => d.fieldname == "account_type")[0]
|
|
||||||
.options,
|
|
||||||
description: __("Optional. This setting will be used to filter in various transactions."),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Float",
|
|
||||||
fieldname: "tax_rate",
|
|
||||||
label: __("Tax Rate"),
|
|
||||||
depends_on: 'eval:doc.is_group==0&&doc.account_type=="Tax"',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Link",
|
|
||||||
fieldname: "account_currency",
|
|
||||||
label: __("Currency"),
|
|
||||||
options: "Currency",
|
|
||||||
description: __("Optional. Sets company's default currency, if not specified."),
|
|
||||||
},
|
},
|
||||||
|
{fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate'),
|
||||||
|
depends_on: 'eval:doc.is_group==0&&doc.account_type=="Tax"'},
|
||||||
|
{fieldtype:'Link', fieldname:'account_currency', label:__('Currency'), options:"Currency",
|
||||||
|
description: __("Optional. Sets company's default currency, if not specified.")}
|
||||||
],
|
],
|
||||||
ignore_fields: ["parent_account"],
|
ignore_fields:["parent_account"],
|
||||||
onload: function (treeview) {
|
onload: function(treeview) {
|
||||||
frappe.treeview_settings["Account"].treeview = {};
|
frappe.treeview_settings['Account'].treeview = {};
|
||||||
$.extend(frappe.treeview_settings["Account"].treeview, treeview);
|
$.extend(frappe.treeview_settings['Account'].treeview, treeview);
|
||||||
function get_company() {
|
function get_company() {
|
||||||
return treeview.page.fields_dict.company.get_value();
|
return treeview.page.fields_dict.company.get_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Chart of Cost Centers"), function() {
|
||||||
__("Chart of Cost Centers"),
|
frappe.set_route('Tree', 'Cost Center', {company: get_company()});
|
||||||
function () {
|
}, __('View'));
|
||||||
frappe.set_route("Tree", "Cost Center", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("View")
|
|
||||||
);
|
|
||||||
|
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Opening Invoice Creation Tool"), function() {
|
||||||
__("Opening Invoice Creation Tool"),
|
frappe.set_route('Form', 'Opening Invoice Creation Tool', {company: get_company()});
|
||||||
function () {
|
}, __('View'));
|
||||||
frappe.set_route("Form", "Opening Invoice Creation Tool", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("View")
|
|
||||||
);
|
|
||||||
|
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Period Closing Voucher"), function() {
|
||||||
__("Period Closing Voucher"),
|
frappe.set_route('List', 'Period Closing Voucher', {company: get_company()});
|
||||||
function () {
|
}, __('View'));
|
||||||
frappe.set_route("List", "Period Closing Voucher", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("View")
|
|
||||||
);
|
|
||||||
|
|
||||||
treeview.page.add_inner_button(
|
|
||||||
__("Journal Entry"),
|
treeview.page.add_inner_button(__("Journal Entry"), function() {
|
||||||
function () {
|
frappe.new_doc('Journal Entry', {company: get_company()});
|
||||||
frappe.new_doc("Journal Entry", { company: get_company() });
|
}, __('Create'));
|
||||||
},
|
treeview.page.add_inner_button(__("Company"), function() {
|
||||||
__("Create")
|
frappe.new_doc('Company');
|
||||||
);
|
}, __('Create'));
|
||||||
treeview.page.add_inner_button(
|
|
||||||
__("Company"),
|
|
||||||
function () {
|
|
||||||
frappe.new_doc("Company");
|
|
||||||
},
|
|
||||||
__("Create")
|
|
||||||
);
|
|
||||||
|
|
||||||
// financial statements
|
// financial statements
|
||||||
for (let report of [
|
for (let report of ['Trial Balance', 'General Ledger', 'Balance Sheet',
|
||||||
"Trial Balance",
|
'Profit and Loss Statement', 'Cash Flow Statement', 'Accounts Payable', 'Accounts Receivable']) {
|
||||||
"General Ledger",
|
treeview.page.add_inner_button(__(report), function() {
|
||||||
"Balance Sheet",
|
frappe.set_route('query-report', report, {company: get_company()});
|
||||||
"Profit and Loss Statement",
|
}, __('Financial Statements'));
|
||||||
"Cash Flow Statement",
|
|
||||||
"Accounts Payable",
|
|
||||||
"Accounts Receivable",
|
|
||||||
]) {
|
|
||||||
treeview.page.add_inner_button(
|
|
||||||
__(report),
|
|
||||||
function () {
|
|
||||||
frappe.set_route("query-report", report, { company: get_company() });
|
|
||||||
},
|
|
||||||
__("Financial Statements")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
post_render: function (treeview) {
|
|
||||||
frappe.treeview_settings["Account"].treeview["tree"] = treeview.tree;
|
|
||||||
treeview.page.set_primary_action(
|
|
||||||
__("New"),
|
|
||||||
function () {
|
|
||||||
let root_company = treeview.page.fields_dict.root_company.get_value();
|
|
||||||
|
|
||||||
if (root_company) {
|
},
|
||||||
frappe.throw(__("Please add the account to root level Company - {0}"), [root_company]);
|
post_render: function(treeview) {
|
||||||
} else {
|
frappe.treeview_settings['Account'].treeview["tree"] = treeview.tree;
|
||||||
treeview.new_node();
|
treeview.page.set_primary_action(__("New"), function() {
|
||||||
}
|
let root_company = treeview.page.fields_dict.root_company.get_value();
|
||||||
},
|
|
||||||
"add"
|
if(root_company) {
|
||||||
);
|
frappe.throw(__("Please add the account to root level Company - {0}"), [root_company]);
|
||||||
|
} else {
|
||||||
|
treeview.new_node();
|
||||||
|
}
|
||||||
|
}, "add");
|
||||||
},
|
},
|
||||||
toolbar: [
|
toolbar: [
|
||||||
{
|
{
|
||||||
label: __("Add Child"),
|
label:__("Add Child"),
|
||||||
condition: function (node) {
|
condition: function(node) {
|
||||||
return (
|
return frappe.boot.user.can_create.indexOf("Account") !== -1
|
||||||
frappe.boot.user.can_create.indexOf("Account") !== -1 &&
|
&& (!frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value()
|
||||||
(!frappe.treeview_settings[
|
|| frappe.flags.ignore_root_company_validation)
|
||||||
"Account"
|
&& node.expandable && !node.hide_add;
|
||||||
].treeview.page.fields_dict.root_company.get_value() ||
|
|
||||||
frappe.flags.ignore_root_company_validation) &&
|
|
||||||
node.expandable &&
|
|
||||||
!node.hide_add
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
click: function () {
|
click: function() {
|
||||||
var me = frappe.views.trees["Account"];
|
var me = frappe.views.trees['Account'];
|
||||||
me.new_node();
|
me.new_node();
|
||||||
},
|
},
|
||||||
btnClass: "hidden-xs",
|
btnClass: "hidden-xs"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
condition: function (node) {
|
condition: function(node) {
|
||||||
return !node.root && frappe.boot.user.can_read.indexOf("GL Entry") !== -1;
|
return !node.root && frappe.boot.user.can_read.indexOf("GL Entry") !== -1
|
||||||
},
|
},
|
||||||
label: __("View Ledger"),
|
label: __("View Ledger"),
|
||||||
click: function (node, btn) {
|
click: function(node, btn) {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
account: node.label,
|
"account": node.label,
|
||||||
from_date: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
"from_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||||
to_date: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
"to_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||||
company:
|
"company": frappe.treeview_settings['Account'].treeview.page.fields_dict.company.get_value()
|
||||||
frappe.treeview_settings["Account"].treeview.page.fields_dict.company.get_value(),
|
|
||||||
};
|
};
|
||||||
frappe.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
},
|
},
|
||||||
btnClass: "hidden-xs",
|
btnClass: "hidden-xs"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
extend_toolbar: true,
|
extend_toolbar: true
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"0360 Bauliche Investitionen in fremden (gepachteten) Betriebs- und Geschäftsgebäuden": {"account_type": "Fixed Asset"},
|
"0360 Bauliche Investitionen in fremden (gepachteten) Betriebs- und Geschäftsgebäuden": {"account_type": "Fixed Asset"},
|
||||||
"0370 Bauliche Investitionen in fremden (gepachteten) Wohn- und Sozialgebäuden": {"account_type": "Fixed Asset"},
|
"0370 Bauliche Investitionen in fremden (gepachteten) Wohn- und Sozialgebäuden": {"account_type": "Fixed Asset"},
|
||||||
"0390 Kumulierte Abschreibungen zu Grundstücken ": {"account_type": "Fixed Asset"},
|
"0390 Kumulierte Abschreibungen zu Grundstücken ": {"account_type": "Fixed Asset"},
|
||||||
"0400 Maschinen und Geräte ": {"account_type": "Fixed Asset"},
|
"0400 Maschinen und Geräte ": {"account_type": "Fixed Asset"},
|
||||||
"0500 Maschinenwerkzeuge ": {"account_type": "Fixed Asset"},
|
"0500 Maschinenwerkzeuge ": {"account_type": "Fixed Asset"},
|
||||||
"0510 Allgemeine Werkzeuge und Handwerkzeuge ": {"account_type": "Fixed Asset"},
|
"0510 Allgemeine Werkzeuge und Handwerkzeuge ": {"account_type": "Fixed Asset"},
|
||||||
"0520 Prototypen, Formen, Modelle ": {"account_type": "Fixed Asset"},
|
"0520 Prototypen, Formen, Modelle ": {"account_type": "Fixed Asset"},
|
||||||
@@ -65,41 +65,42 @@
|
|||||||
"0980 Geleistete Anzahlungen auf Finanzanlagen ": {"account_type": "Fixed Asset"},
|
"0980 Geleistete Anzahlungen auf Finanzanlagen ": {"account_type": "Fixed Asset"},
|
||||||
"0990 Kumulierte Abschreibungen zu Finanzanlagen ": {"account_type": "Fixed Asset"},
|
"0990 Kumulierte Abschreibungen zu Finanzanlagen ": {"account_type": "Fixed Asset"},
|
||||||
"root_type": "Asset"
|
"root_type": "Asset"
|
||||||
},
|
},
|
||||||
"Klasse 1 Aktiva: Vorr\u00e4te": {
|
"Klasse 1 Aktiva: Vorr\u00e4te": {
|
||||||
"1000 Bezugsverrechnung": {"account_type": "Stock"},
|
"1000 Bezugsverrechnung": {"account_type": "Stock"},
|
||||||
"1100 Rohstoffe": {"account_type": "Stock"},
|
"1100 Rohstoffe": {"account_type": "Stock"},
|
||||||
"1200 Bezogene Teile": {"account_type": "Stock"},
|
"1200 Bezogene Teile": {"account_type": "Stock"},
|
||||||
"1300 Hilfsstoffe": {"account_type": "Stock"},
|
"1300 Hilfsstoffe": {"account_type": "Stock"},
|
||||||
"1350 Betriebsstoffe": {"account_type": "Stock"},
|
"1350 Betriebsstoffe": {"account_type": "Stock"},
|
||||||
"1360 Vorrat Energietraeger": {"account_type": "Stock"},
|
"1360 Vorrat Energietraeger": {"account_type": "Stock"},
|
||||||
"1400 Unfertige Erzeugnisse": {"account_type": "Stock"},
|
"1400 Unfertige Erzeugnisse": {"account_type": "Stock"},
|
||||||
"1500 Fertige Erzeugnisse": {"account_type": "Stock"},
|
"1500 Fertige Erzeugnisse": {"account_type": "Stock"},
|
||||||
"1600 Handelswarenvorrat": {"account_type": "Stock Received But Not Billed"},
|
"1600 Handelswarenvorrat": {"account_type": "Stock Received But Not Billed"},
|
||||||
"1700 Noch nicht abrechenbare Leistungen": {"account_type": "Stock"},
|
"1700 Noch nicht abrechenbare Leistungen": {"account_type": "Stock"},
|
||||||
|
"1900 Wertberichtigungen": {"account_type": "Stock"},
|
||||||
"1800 Geleistete Anzahlungen": {"account_type": "Stock"},
|
"1800 Geleistete Anzahlungen": {"account_type": "Stock"},
|
||||||
"1900 Wertberichtigungen": {"account_type": "Stock"},
|
"1900 Wertberichtigungen": {"account_type": "Stock"},
|
||||||
"root_type": "Asset"
|
"root_type": "Asset"
|
||||||
},
|
},
|
||||||
"Klasse 3 Passiva: Verbindlichkeiten": {
|
"Klasse 3 Passiva: Verbindlichkeiten": {
|
||||||
"3000 Allgemeine Verbindlichkeiten (Schuld)": {"account_type": "Payable"},
|
"3000 Allgemeine Verbindlichkeiten (Schuld)": {"account_type": "Payable"},
|
||||||
"3010 R\u00fcckstellungen f\u00fcr Pensionen": {"account_type": "Payable"},
|
"3010 R\u00fcckstellungen f\u00fcr Pensionen": {"account_type": "Payable"},
|
||||||
"3020 Steuerr\u00fcckstellungen": {"account_type": "Tax"},
|
"3020 Steuerr\u00fcckstellungen": {"account_type": "Tax"},
|
||||||
"3041 Sonstige R\u00fcckstellungen": {"account_type": "Payable"},
|
"3041 Sonstige R\u00fcckstellungen": {"account_type": "Payable"},
|
||||||
"3110 Verbindlichkeiten gegen\u00fcber Bank": {"account_type": "Payable"},
|
"3110 Verbindlichkeiten gegen\u00fcber Bank": {"account_type": "Payable"},
|
||||||
"3150 Verbindlichkeiten Darlehen": {"account_type": "Payable"},
|
"3150 Verbindlichkeiten Darlehen": {"account_type": "Payable"},
|
||||||
"3185 Verbindlichkeiten Kreditkarte": {"account_type": "Payable"},
|
"3185 Verbindlichkeiten Kreditkarte": {"account_type": "Payable"},
|
||||||
"3380 Verbindlichkeiten aus der Annahme gezogener Wechsel u. d. Ausstellungen eigener Wechsel": {
|
"3380 Verbindlichkeiten aus der Annahme gezogener Wechsel u. d. Ausstellungen eigener Wechsel": {
|
||||||
"account_type": "Payable"
|
"account_type": "Payable"
|
||||||
},
|
},
|
||||||
"3400 Verbindlichkeiten gegen\u00fc. verb. Untern., Verbindl. gegen\u00fc. Untern., mit denen eine Beteiligungsverh\u00e4lnis besteht": {},
|
"3400 Verbindlichkeiten gegen\u00fc. verb. Untern., Verbindl. gegen\u00fc. Untern., mit denen eine Beteiligungsverh\u00e4lnis besteht": {},
|
||||||
"3460 Verbindlichkeiten gegenueber Gesellschaftern": {"account_type": "Payable"},
|
"3460 Verbindlichkeiten gegenueber Gesellschaftern": {"account_type": "Payable"},
|
||||||
"3470 Einlagen stiller Gesellschafter": {"account_type": "Payable"},
|
"3470 Einlagen stiller Gesellschafter": {"account_type": "Payable"},
|
||||||
"3585 Verbindlichkeiten Lohnsteuer": {"account_type": "Tax"},
|
"3585 Verbindlichkeiten Lohnsteuer": {"account_type": "Tax"},
|
||||||
"3590 Verbindlichkeiten Kommunalabgaben": {"account_type": "Tax"},
|
"3590 Verbindlichkeiten Kommunalabgaben": {"account_type": "Tax"},
|
||||||
"3595 Verbindlichkeiten Dienstgeberbeitrag": {"account_type": "Tax"},
|
"3595 Verbindlichkeiten Dienstgeberbeitrag": {"account_type": "Tax"},
|
||||||
"3600 Verbindlichkeiten Sozialversicherung": {"account_type": "Payable"},
|
"3600 Verbindlichkeiten Sozialversicherung": {"account_type": "Payable"},
|
||||||
"3640 Verbindlichkeiten Loehne und Gehaelter": {"account_type": "Payable"},
|
"3640 Verbindlichkeiten Loehne und Gehaelter": {"account_type": "Payable"},
|
||||||
"3700 Sonstige Verbindlichkeiten": {"account_type": "Payable"},
|
"3700 Sonstige Verbindlichkeiten": {"account_type": "Payable"},
|
||||||
"3900 Passive Rechnungsabgrenzungsposten": {"account_type": "Payable"},
|
"3900 Passive Rechnungsabgrenzungsposten": {"account_type": "Payable"},
|
||||||
"3100 Anleihen (einschlie\u00dflich konvertibler)": {"account_type": "Payable"},
|
"3100 Anleihen (einschlie\u00dflich konvertibler)": {"account_type": "Payable"},
|
||||||
@@ -118,13 +119,13 @@
|
|||||||
},
|
},
|
||||||
"3515 Umsatzsteuer Inland 10%": {
|
"3515 Umsatzsteuer Inland 10%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"3520 Umsatzsteuer aus i.g. Erwerb 20%": {
|
"3520 Umsatzsteuer aus i.g. Erwerb 20%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"3525 Umsatzsteuer aus i.g. Erwerb 10%": {
|
"3525 Umsatzsteuer aus i.g. Erwerb 10%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"3560 Umsatzsteuer-Evidenzkonto f\u00fcr erhaltene Anzahlungen auf Bestellungen": {},
|
"3560 Umsatzsteuer-Evidenzkonto f\u00fcr erhaltene Anzahlungen auf Bestellungen": {},
|
||||||
"3360 Verbindlichkeiten aus Lieferungen u. Leistungen EU": {
|
"3360 Verbindlichkeiten aus Lieferungen u. Leistungen EU": {
|
||||||
"account_type": "Payable"
|
"account_type": "Payable"
|
||||||
@@ -140,7 +141,7 @@
|
|||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"root_type": "Liability"
|
"root_type": "Liability"
|
||||||
},
|
},
|
||||||
"Klasse 2 Aktiva: Umlaufverm\u00f6gen, Rechnungsabgrenzungen": {
|
"Klasse 2 Aktiva: Umlaufverm\u00f6gen, Rechnungsabgrenzungen": {
|
||||||
"2030 Forderungen aus Lieferungen und Leistungen Inland (0% USt, umsatzsteuerfrei)": {
|
"2030 Forderungen aus Lieferungen und Leistungen Inland (0% USt, umsatzsteuerfrei)": {
|
||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
@@ -153,7 +154,7 @@
|
|||||||
},
|
},
|
||||||
"2040 Forderungen aus Lieferungen und Leistungen Inland (sonstiger USt-Satz)": {
|
"2040 Forderungen aus Lieferungen und Leistungen Inland (sonstiger USt-Satz)": {
|
||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
},
|
},
|
||||||
"2100 Forderungen aus Lieferungen und Leistungen EU": {
|
"2100 Forderungen aus Lieferungen und Leistungen EU": {
|
||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
},
|
},
|
||||||
@@ -191,7 +192,7 @@
|
|||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
},
|
},
|
||||||
"2570 Einfuhrumsatzsteuer (bezahlt)": {"account_type": "Tax"},
|
"2570 Einfuhrumsatzsteuer (bezahlt)": {"account_type": "Tax"},
|
||||||
|
|
||||||
"2460 Eingeforderte aber noch nicht eingezahlte Einlagen": {
|
"2460 Eingeforderte aber noch nicht eingezahlte Einlagen": {
|
||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
},
|
},
|
||||||
@@ -242,10 +243,10 @@
|
|||||||
},
|
},
|
||||||
"2800 Guthaben bei Bank": {
|
"2800 Guthaben bei Bank": {
|
||||||
"account_type": "Bank"
|
"account_type": "Bank"
|
||||||
},
|
},
|
||||||
"2801 Guthaben bei Bank - Sparkonto": {
|
"2801 Guthaben bei Bank - Sparkonto": {
|
||||||
"account_type": "Bank"
|
"account_type": "Bank"
|
||||||
},
|
},
|
||||||
"2810 Guthaben bei Paypal": {
|
"2810 Guthaben bei Paypal": {
|
||||||
"account_type": "Bank"
|
"account_type": "Bank"
|
||||||
},
|
},
|
||||||
@@ -263,19 +264,19 @@
|
|||||||
},
|
},
|
||||||
"2895 Schwebende Geldbewegugen": {
|
"2895 Schwebende Geldbewegugen": {
|
||||||
"account_type": "Bank"
|
"account_type": "Bank"
|
||||||
},
|
},
|
||||||
"2513 Vorsteuer Inland 5%": {
|
"2513 Vorsteuer Inland 5%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"2515 Vorsteuer Inland 20%": {
|
"2515 Vorsteuer Inland 20%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"2520 Vorsteuer aus innergemeinschaftlichem Erwerb 10%": {
|
"2520 Vorsteuer aus innergemeinschaftlichem Erwerb 10%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"2525 Vorsteuer aus innergemeinschaftlichem Erwerb 20%": {
|
"2525 Vorsteuer aus innergemeinschaftlichem Erwerb 20%": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
"2530 Vorsteuer \u00a719/Art 19 ( reverse charge ) ": {
|
"2530 Vorsteuer \u00a719/Art 19 ( reverse charge ) ": {
|
||||||
"account_type": "Tax"
|
"account_type": "Tax"
|
||||||
},
|
},
|
||||||
@@ -285,16 +286,16 @@
|
|||||||
"root_type": "Asset"
|
"root_type": "Asset"
|
||||||
},
|
},
|
||||||
"Klasse 4: Betriebliche Erträge": {
|
"Klasse 4: Betriebliche Erträge": {
|
||||||
"4000 Erlöse 20 %": {"account_type": "Income Account"},
|
"4000 Erlöse 20 %": {"account_type": "Income Account"},
|
||||||
"4020 Erl\u00f6se 0 % steuerbefreit": {"account_type": "Income Account"},
|
"4020 Erl\u00f6se 0 % steuerbefreit": {"account_type": "Income Account"},
|
||||||
"4010 Erl\u00f6se 10 %": {"account_type": "Income Account"},
|
"4010 Erl\u00f6se 10 %": {"account_type": "Income Account"},
|
||||||
"4030 Erl\u00f6se 13 %": {"account_type": "Income Account"},
|
"4030 Erl\u00f6se 13 %": {"account_type": "Income Account"},
|
||||||
"4040 Erl\u00f6se 0 % innergemeinschaftliche Lieferungen": {"account_type": "Income Account"},
|
"4040 Erl\u00f6se 0 % innergemeinschaftliche Lieferungen": {"account_type": "Income Account"},
|
||||||
"4400 Erl\u00f6sreduktion 0 % steuerbefreit": {"account_type": "Expense Account"},
|
"4400 Erl\u00f6sreduktion 0 % steuerbefreit": {"account_type": "Expense Account"},
|
||||||
"4410 Erl\u00f6sreduktion 10 %": {"account_type": "Expense Account"},
|
"4410 Erl\u00f6sreduktion 10 %": {"account_type": "Expense Account"},
|
||||||
"4420 Erl\u00f6sreduktion 20 %": {"account_type": "Expense Account"},
|
"4420 Erl\u00f6sreduktion 20 %": {"account_type": "Expense Account"},
|
||||||
"4430 Erl\u00f6sreduktion 13 %": {"account_type": "Expense Account"},
|
"4430 Erl\u00f6sreduktion 13 %": {"account_type": "Expense Account"},
|
||||||
"4440 Erl\u00f6sreduktion 0 % innergemeinschaftliche Lieferungen": {"account_type": "Expense Account"},
|
"4440 Erl\u00f6sreduktion 0 % innergemeinschaftliche Lieferungen": {"account_type": "Expense Account"},
|
||||||
"4500 Ver\u00e4nderungen des Bestandes an fertigen und unfertigen Erzeugn. sowie an noch nicht abrechenbaren Leistungen": {"account_type": "Income Account"},
|
"4500 Ver\u00e4nderungen des Bestandes an fertigen und unfertigen Erzeugn. sowie an noch nicht abrechenbaren Leistungen": {"account_type": "Income Account"},
|
||||||
"4580 Aktivierte Eigenleistungen": {"account_type": "Income Account"},
|
"4580 Aktivierte Eigenleistungen": {"account_type": "Income Account"},
|
||||||
"4600 Erl\u00f6se aus dem Abgang vom Anlageverm\u00f6gen, ausgen. Finanzanlagen": {"account_type": "Income Account"},
|
"4600 Erl\u00f6se aus dem Abgang vom Anlageverm\u00f6gen, ausgen. Finanzanlagen": {"account_type": "Income Account"},
|
||||||
@@ -303,15 +304,15 @@
|
|||||||
"4700 Ertr\u00e4ge aus der Aufl\u00f6sung von R\u00fcckstellungen": {"account_type": "Income Account"},
|
"4700 Ertr\u00e4ge aus der Aufl\u00f6sung von R\u00fcckstellungen": {"account_type": "Income Account"},
|
||||||
"4800 \u00dcbrige betriebliche Ertr\u00e4ge": {"account_type": "Income Account"},
|
"4800 \u00dcbrige betriebliche Ertr\u00e4ge": {"account_type": "Income Account"},
|
||||||
"root_type": "Income"
|
"root_type": "Income"
|
||||||
},
|
},
|
||||||
"Klasse 5: Aufwand f\u00fcr Material und Leistungen": {
|
"Klasse 5: Aufwand f\u00fcr Material und Leistungen": {
|
||||||
"5000 Einkauf Partnerleistungen": {"account_type": "Cost of Goods Sold"},
|
"5000 Einkauf Partnerleistungen": {"account_type": "Cost of Goods Sold"},
|
||||||
"5100 Verbrauch an Rohstoffen": {"account_type": "Cost of Goods Sold"},
|
"5100 Verbrauch an Rohstoffen": {"account_type": "Cost of Goods Sold"},
|
||||||
"5200 Verbrauch von bezogenen Fertig- und Einzelteilen": {"account_type": "Cost of Goods Sold"},
|
"5200 Verbrauch von bezogenen Fertig- und Einzelteilen": {"account_type": "Cost of Goods Sold"},
|
||||||
"5300 Verbrauch von Hilfsstoffen": {"account_type": "Cost of Goods Sold"},
|
"5300 Verbrauch von Hilfsstoffen": {"account_type": "Cost of Goods Sold"},
|
||||||
"5340 Verbrauch Verpackungsmaterial": {"account_type": "Cost of Goods Sold"},
|
"5340 Verbrauch Verpackungsmaterial": {"account_type": "Cost of Goods Sold"},
|
||||||
"5470 Verbrauch von Kleinmaterial": {"account_type": "Cost of Goods Sold"},
|
"5470 Verbrauch von Kleinmaterial": {"account_type": "Cost of Goods Sold"},
|
||||||
"5450 Verbrauch von Reinigungsmaterial": {"account_type": "Cost of Goods Sold"},
|
"5450 Verbrauch von Reinigungsmaterial": {"account_type": "Cost of Goods Sold"},
|
||||||
"5400 Verbrauch von Betriebsstoffen": {"account_type": "Cost of Goods Sold"},
|
"5400 Verbrauch von Betriebsstoffen": {"account_type": "Cost of Goods Sold"},
|
||||||
"5500 Verbrauch von Werkzeugen und anderen Erzeugungshilfsmittel": {"account_type": "Cost of Goods Sold"},
|
"5500 Verbrauch von Werkzeugen und anderen Erzeugungshilfsmittel": {"account_type": "Cost of Goods Sold"},
|
||||||
"5600 Verbrauch von Brenn- und Treibstoffen, Energie und Wasser": {"account_type": "Cost of Goods Sold"},
|
"5600 Verbrauch von Brenn- und Treibstoffen, Energie und Wasser": {"account_type": "Cost of Goods Sold"},
|
||||||
@@ -339,7 +340,7 @@
|
|||||||
"6700 Sonstige Sozialaufwendungen": {"account_type": "Payable"},
|
"6700 Sonstige Sozialaufwendungen": {"account_type": "Payable"},
|
||||||
"6900 Aufwandsstellenrechnung Personal": {"account_type": "Payable"},
|
"6900 Aufwandsstellenrechnung Personal": {"account_type": "Payable"},
|
||||||
"root_type": "Expense"
|
"root_type": "Expense"
|
||||||
},
|
},
|
||||||
"Klasse 7: Abschreibungen und sonstige betriebliche Aufwendungen": {
|
"Klasse 7: Abschreibungen und sonstige betriebliche Aufwendungen": {
|
||||||
"7010 Abschreibungen auf das Anlageverm\u00f6gen (ausgenommen Finanzanlagen)": {"account_type": "Depreciation"},
|
"7010 Abschreibungen auf das Anlageverm\u00f6gen (ausgenommen Finanzanlagen)": {"account_type": "Depreciation"},
|
||||||
"7100 Sonstige Steuern und Geb\u00fchren": {"account_type": "Tax"},
|
"7100 Sonstige Steuern und Geb\u00fchren": {"account_type": "Tax"},
|
||||||
@@ -348,7 +349,7 @@
|
|||||||
"7310 Fahrrad - Aufwand": {"account_type": "Expense Account"},
|
"7310 Fahrrad - Aufwand": {"account_type": "Expense Account"},
|
||||||
"7320 Kfz - Aufwand": {"account_type": "Expense Account"},
|
"7320 Kfz - Aufwand": {"account_type": "Expense Account"},
|
||||||
"7330 LKW - Aufwand": {"account_type": "Expense Account"},
|
"7330 LKW - Aufwand": {"account_type": "Expense Account"},
|
||||||
"7340 Lastenrad - Aufwand": {"account_type": "Expense Account"},
|
"7340 Lastenrad - Aufwand": {"account_type": "Expense Account"},
|
||||||
"7350 Reise- und Fahraufwand": {"account_type": "Expense Account"},
|
"7350 Reise- und Fahraufwand": {"account_type": "Expense Account"},
|
||||||
"7360 Tag- und N\u00e4chtigungsgelder": {"account_type": "Expense Account"},
|
"7360 Tag- und N\u00e4chtigungsgelder": {"account_type": "Expense Account"},
|
||||||
"7380 Nachrichtenaufwand": {"account_type": "Expense Account"},
|
"7380 Nachrichtenaufwand": {"account_type": "Expense Account"},
|
||||||
@@ -408,7 +409,7 @@
|
|||||||
"8990 Gewinnabfuhr bzw. Verlust\u00fcberrechnung aus Ergebnisabf\u00fchrungsvertr\u00e4gen": {"account_type": "Expense Account"},
|
"8990 Gewinnabfuhr bzw. Verlust\u00fcberrechnung aus Ergebnisabf\u00fchrungsvertr\u00e4gen": {"account_type": "Expense Account"},
|
||||||
"8350 nicht ausgenutzte Lieferantenskonti": {"account_type": "Expense Account"},
|
"8350 nicht ausgenutzte Lieferantenskonti": {"account_type": "Expense Account"},
|
||||||
"root_type": "Income"
|
"root_type": "Income"
|
||||||
},
|
},
|
||||||
"Klasse 9 Passiva: Eigenkapital, R\u00fccklagen, stille Einlagen, Abschlusskonten": {
|
"Klasse 9 Passiva: Eigenkapital, R\u00fccklagen, stille Einlagen, Abschlusskonten": {
|
||||||
"9000 Gezeichnetes bzw. gewidmetes Kapital": {
|
"9000 Gezeichnetes bzw. gewidmetes Kapital": {
|
||||||
"account_type": "Equity"
|
"account_type": "Equity"
|
||||||
@@ -434,5 +435,5 @@
|
|||||||
},
|
},
|
||||||
"root_type": "Equity"
|
"root_type": "Equity"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,7 @@
|
|||||||
"Constru\u00e7\u00f5es em Andamento de Im\u00f3veis Destinados \u00e0 Venda": {},
|
"Constru\u00e7\u00f5es em Andamento de Im\u00f3veis Destinados \u00e0 Venda": {},
|
||||||
"Estoques Destinados \u00e0 Doa\u00e7\u00e3o": {},
|
"Estoques Destinados \u00e0 Doa\u00e7\u00e3o": {},
|
||||||
"Im\u00f3veis Destinados \u00e0 Venda": {},
|
"Im\u00f3veis Destinados \u00e0 Venda": {},
|
||||||
"Insumos (materiais diretos)": {
|
"Insumos (materiais diretos)": {},
|
||||||
"account_type": "Stock"
|
|
||||||
},
|
|
||||||
"Insumos Agropecu\u00e1rios": {},
|
"Insumos Agropecu\u00e1rios": {},
|
||||||
"Mercadorias para Revenda": {},
|
"Mercadorias para Revenda": {},
|
||||||
"Outras 11": {},
|
"Outras 11": {},
|
||||||
@@ -148,65 +146,6 @@
|
|||||||
"root_type": "Asset"
|
"root_type": "Asset"
|
||||||
},
|
},
|
||||||
"CUSTOS DE PRODU\u00c7\u00c3O": {
|
"CUSTOS DE PRODU\u00c7\u00c3O": {
|
||||||
"CUSTO DOS PRODUTOS E SERVI\u00c7OS VENDIDOS": {
|
|
||||||
"CUSTO DOS PRODUTOS VENDIDOS": {
|
|
||||||
"CUSTO DOS PRODUTOS VENDIDOS PARA AS DEMAIS ATIVIDADES": {
|
|
||||||
"Custos dos Produtos Vendidos em Geral": {
|
|
||||||
"account_type": "Cost of Goods Sold"
|
|
||||||
},
|
|
||||||
"Outros Custos 4": {},
|
|
||||||
"account_type": "Cost of Goods Sold"
|
|
||||||
},
|
|
||||||
"CUSTO DOS PRODUTOS VENDIDOS PARA ASSIST\u00caNCIA SOCIAL": {
|
|
||||||
"Custos dos Produtos para Assist\u00eancia Social - Gratuidades": {},
|
|
||||||
"Custos dos Produtos para Assist\u00eancia Social - Vendidos": {},
|
|
||||||
"Outras": {}
|
|
||||||
},
|
|
||||||
"CUSTO DOS PRODUTOS VENDIDOS PARA EDUCA\u00c7\u00c3O": {
|
|
||||||
"Custos dos Produtos para Educa\u00e7\u00e3o - Gratuidades": {},
|
|
||||||
"Custos dos Produtos para Educa\u00e7\u00e3o - Vendidos": {},
|
|
||||||
"Outros Custos 6": {}
|
|
||||||
},
|
|
||||||
"CUSTO DOS PRODUTOS VENDIDOS PARA SA\u00daDE": {
|
|
||||||
"Custos dos Produtos para Sa\u00fade - Gratuidades": {},
|
|
||||||
"Custos dos Produtos para Sa\u00fade \u2013 Vendidos": {},
|
|
||||||
"Outros Custos 5": {}
|
|
||||||
},
|
|
||||||
"account_type": "Cost of Goods Sold"
|
|
||||||
},
|
|
||||||
"CUSTO DOS SERVI\u00c7OS PRESTADOS": {
|
|
||||||
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA AS DEMAIS ATIVIDADES": {
|
|
||||||
"Custo dos Servi\u00e7os Prestados em Geral": {},
|
|
||||||
"Outros Custos": {}
|
|
||||||
},
|
|
||||||
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA ASSIST\u00caNCIA SOCIAL": {
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es 1": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas 1": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Gratuidade 1": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Pacientes Particulares": {},
|
|
||||||
"Outros Custos 2": {}
|
|
||||||
},
|
|
||||||
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA EDUCA\u00c7\u00c3O": {
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Alunos N\u00e3o Bolsistas": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias (Exceto PROUNI)": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Gratuidade": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados ao PROUNI": {},
|
|
||||||
"Outros Custos 1": {}
|
|
||||||
},
|
|
||||||
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA SA\u00daDE": {
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios SUS": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias 1": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es 2": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas 2": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Gratuidade 2": {},
|
|
||||||
"Custo dos Servi\u00e7os Prestados a Pacientes Particulares 1": {},
|
|
||||||
"Outros Custos 3": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CUSTO DOS BENS E SERVI\u00c7OS PRODUZIDOS": {
|
"CUSTO DOS BENS E SERVI\u00c7OS PRODUZIDOS": {
|
||||||
"CUSTO DOS PRODUTOS DE FABRICA\u00c7\u00c3O PR\u00d3PRIA PRODUZIDOS": {
|
"CUSTO DOS PRODUTOS DE FABRICA\u00c7\u00c3O PR\u00d3PRIA PRODUZIDOS": {
|
||||||
"Alimenta\u00e7\u00e3o do Trabalhador": {},
|
"Alimenta\u00e7\u00e3o do Trabalhador": {},
|
||||||
@@ -682,9 +621,7 @@
|
|||||||
"Receita das Unidades Imobili\u00e1rias Vendidas": {},
|
"Receita das Unidades Imobili\u00e1rias Vendidas": {},
|
||||||
"Receita de Exporta\u00e7\u00e3o Direta de Mercadorias e Produtos": {},
|
"Receita de Exporta\u00e7\u00e3o Direta de Mercadorias e Produtos": {},
|
||||||
"Receita de Exporta\u00e7\u00e3o de Servi\u00e7os": {},
|
"Receita de Exporta\u00e7\u00e3o de Servi\u00e7os": {},
|
||||||
"Receita de Loca\u00e7\u00e3o de Bens M\u00f3veis e Im\u00f3veis": {
|
"Receita de Loca\u00e7\u00e3o de Bens M\u00f3veis e Im\u00f3veis": {},
|
||||||
"account_type": "Income Account"
|
|
||||||
},
|
|
||||||
"Receita de Vendas de Mercadorias e Produtos a Comercial Exportadora com Fim Espec\u00edfico de Exporta\u00e7\u00e3o": {}
|
"Receita de Vendas de Mercadorias e Produtos a Comercial Exportadora com Fim Espec\u00edfico de Exporta\u00e7\u00e3o": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -708,6 +645,65 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"RESULTADO OPERACIONAL": {
|
"RESULTADO OPERACIONAL": {
|
||||||
|
"CUSTO DOS PRODUTOS E SERVI\u00c7OS VENDIDOS": {
|
||||||
|
"CUSTO DOS PRODUTOS VENDIDOS": {
|
||||||
|
"CUSTO DOS PRODUTOS VENDIDOS PARA AS DEMAIS ATIVIDADES": {
|
||||||
|
"Custos dos Produtos Vendidos em Geral": {
|
||||||
|
"account_type": "Cost of Goods Sold"
|
||||||
|
},
|
||||||
|
"Outros Custos 4": {},
|
||||||
|
"account_type": "Cost of Goods Sold"
|
||||||
|
},
|
||||||
|
"CUSTO DOS PRODUTOS VENDIDOS PARA ASSIST\u00caNCIA SOCIAL": {
|
||||||
|
"Custos dos Produtos para Assist\u00eancia Social - Gratuidades": {},
|
||||||
|
"Custos dos Produtos para Assist\u00eancia Social - Vendidos": {},
|
||||||
|
"Outras": {}
|
||||||
|
},
|
||||||
|
"CUSTO DOS PRODUTOS VENDIDOS PARA EDUCA\u00c7\u00c3O": {
|
||||||
|
"Custos dos Produtos para Educa\u00e7\u00e3o - Gratuidades": {},
|
||||||
|
"Custos dos Produtos para Educa\u00e7\u00e3o - Vendidos": {},
|
||||||
|
"Outros Custos 6": {}
|
||||||
|
},
|
||||||
|
"CUSTO DOS PRODUTOS VENDIDOS PARA SA\u00daDE": {
|
||||||
|
"Custos dos Produtos para Sa\u00fade - Gratuidades": {},
|
||||||
|
"Custos dos Produtos para Sa\u00fade \u2013 Vendidos": {},
|
||||||
|
"Outros Custos 5": {}
|
||||||
|
},
|
||||||
|
"account_type": "Cost of Goods Sold"
|
||||||
|
},
|
||||||
|
"CUSTO DOS SERVI\u00c7OS PRESTADOS": {
|
||||||
|
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA AS DEMAIS ATIVIDADES": {
|
||||||
|
"Custo dos Servi\u00e7os Prestados em Geral": {},
|
||||||
|
"Outros Custos": {}
|
||||||
|
},
|
||||||
|
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA ASSIST\u00caNCIA SOCIAL": {
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es 1": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas 1": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Gratuidade 1": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Pacientes Particulares": {},
|
||||||
|
"Outros Custos 2": {}
|
||||||
|
},
|
||||||
|
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA EDUCA\u00c7\u00c3O": {
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Alunos N\u00e3o Bolsistas": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias (Exceto PROUNI)": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Gratuidade": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados ao PROUNI": {},
|
||||||
|
"Outros Custos 1": {}
|
||||||
|
},
|
||||||
|
"CUSTO DOS SERVI\u00c7OS PRESTADOS PARA SA\u00daDE": {
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios SUS": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Conv\u00eanios/Contratos/Parcerias 1": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es 2": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Doa\u00e7\u00f5es/Subven\u00e7\u00f5es Vinculadas 2": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Gratuidade 2": {},
|
||||||
|
"Custo dos Servi\u00e7os Prestados a Pacientes Particulares 1": {},
|
||||||
|
"Outros Custos 3": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"DESPESAS OPERACIONAIS": {
|
"DESPESAS OPERACIONAIS": {
|
||||||
"DESPESAS OPERACIONAIS 1": {
|
"DESPESAS OPERACIONAIS 1": {
|
||||||
"DESPESAS OPERACIONAIS 2": {
|
"DESPESAS OPERACIONAIS 2": {
|
||||||
|
|||||||
@@ -33,9 +33,7 @@
|
|||||||
},
|
},
|
||||||
"Stocks": {
|
"Stocks": {
|
||||||
"Mati\u00e8res premi\u00e8res": {},
|
"Mati\u00e8res premi\u00e8res": {},
|
||||||
"Stock de produits fini": {
|
"Stock de produits fini": {},
|
||||||
"account_type": "Stock"
|
|
||||||
},
|
|
||||||
"Stock exp\u00e9di\u00e9 non-factur\u00e9": {},
|
"Stock exp\u00e9di\u00e9 non-factur\u00e9": {},
|
||||||
"Travaux en cours": {},
|
"Travaux en cours": {},
|
||||||
"account_type": "Stock"
|
"account_type": "Stock"
|
||||||
@@ -397,11 +395,9 @@
|
|||||||
},
|
},
|
||||||
"Produits": {
|
"Produits": {
|
||||||
"Revenus de ventes": {
|
"Revenus de ventes": {
|
||||||
"Escomptes de volume sur ventes": {},
|
" Escomptes de volume sur ventes": {},
|
||||||
"Autres produits d'exploitation": {},
|
"Autres produits d'exploitation": {},
|
||||||
"Ventes": {
|
"Ventes": {},
|
||||||
"account_type": "Income Account"
|
|
||||||
},
|
|
||||||
"Ventes avec des provinces harmonis\u00e9es": {},
|
"Ventes avec des provinces harmonis\u00e9es": {},
|
||||||
"Ventes avec des provinces non-harmonis\u00e9es": {},
|
"Ventes avec des provinces non-harmonis\u00e9es": {},
|
||||||
"Ventes \u00e0 l'\u00e9tranger": {}
|
"Ventes \u00e0 l'\u00e9tranger": {}
|
||||||
|
|||||||
@@ -53,13 +53,8 @@
|
|||||||
},
|
},
|
||||||
"II. Forderungen und sonstige Vermögensgegenstände": {
|
"II. Forderungen und sonstige Vermögensgegenstände": {
|
||||||
"is_group": 1,
|
"is_group": 1,
|
||||||
"Forderungen aus Lieferungen und Leistungen mit Kontokorrent": {
|
"Ford. a. Lieferungen und Leistungen": {
|
||||||
"account_number": "1400",
|
"account_number": "1400",
|
||||||
"account_type": "Receivable",
|
|
||||||
"is_group": 1
|
|
||||||
},
|
|
||||||
"Forderungen aus Lieferungen und Leistungen ohne Kontokorrent": {
|
|
||||||
"account_number": "1410",
|
|
||||||
"account_type": "Receivable"
|
"account_type": "Receivable"
|
||||||
},
|
},
|
||||||
"Durchlaufende Posten": {
|
"Durchlaufende Posten": {
|
||||||
@@ -185,13 +180,8 @@
|
|||||||
},
|
},
|
||||||
"IV. Verbindlichkeiten aus Lieferungen und Leistungen": {
|
"IV. Verbindlichkeiten aus Lieferungen und Leistungen": {
|
||||||
"is_group": 1,
|
"is_group": 1,
|
||||||
"Verbindlichkeiten aus Lieferungen und Leistungen mit Kontokorrent": {
|
"Verbindlichkeiten aus Lieferungen u. Leistungen": {
|
||||||
"account_number": "1600",
|
"account_number": "1600",
|
||||||
"account_type": "Payable",
|
|
||||||
"is_group": 1
|
|
||||||
},
|
|
||||||
"Verbindlichkeiten aus Lieferungen und Leistungen ohne Kontokorrent": {
|
|
||||||
"account_number": "1610",
|
|
||||||
"account_type": "Payable"
|
"account_type": "Payable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -407,10 +407,13 @@
|
|||||||
"Bewertungskorrektur zu Forderungen aus Lieferungen und Leistungen": {
|
"Bewertungskorrektur zu Forderungen aus Lieferungen und Leistungen": {
|
||||||
"account_number": "9960"
|
"account_number": "9960"
|
||||||
},
|
},
|
||||||
"Forderungen aus Lieferungen und Leistungen mit Kontokorrent": {
|
"Debitoren": {
|
||||||
|
"is_group": 1,
|
||||||
|
"account_number": "10000"
|
||||||
|
},
|
||||||
|
"Forderungen aus Lieferungen und Leistungen": {
|
||||||
"account_number": "1200",
|
"account_number": "1200",
|
||||||
"account_type": "Receivable",
|
"account_type": "Receivable"
|
||||||
"is_group": 1
|
|
||||||
},
|
},
|
||||||
"Forderungen aus Lieferungen und Leistungen ohne Kontokorrent": {
|
"Forderungen aus Lieferungen und Leistungen ohne Kontokorrent": {
|
||||||
"account_number": "1210"
|
"account_number": "1210"
|
||||||
@@ -1135,15 +1138,18 @@
|
|||||||
"Bewertungskorrektur zu Verb. aus Lieferungen und Leistungen": {
|
"Bewertungskorrektur zu Verb. aus Lieferungen und Leistungen": {
|
||||||
"account_number": "9964"
|
"account_number": "9964"
|
||||||
},
|
},
|
||||||
"Verb. aus Lieferungen und Leistungen mit Kontokorrent": {
|
"Kreditoren": {
|
||||||
"account_number": "3300",
|
"account_number": "70000",
|
||||||
"account_type": "Payable",
|
|
||||||
"is_group": 1,
|
"is_group": 1,
|
||||||
"Wareneingangs-Verrechnungskonto" : {
|
"Wareneingangs-Verrechnungskonto" : {
|
||||||
"account_number": "70001",
|
"account_number": "70001",
|
||||||
"account_type": "Stock Received But Not Billed"
|
"account_type": "Stock Received But Not Billed"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Verb. aus Lieferungen und Leistungen": {
|
||||||
|
"account_number": "3300",
|
||||||
|
"account_type": "Payable"
|
||||||
|
},
|
||||||
"Verb. aus Lieferungen und Leistungen ohne Kontokorrent": {
|
"Verb. aus Lieferungen und Leistungen ohne Kontokorrent": {
|
||||||
"account_number": "3310"
|
"account_number": "3310"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{
|
{
|
||||||
"country_code": "hu",
|
|
||||||
"name": "Hungary - Chart of Accounts for Microenterprises",
|
|
||||||
"tree": {
|
"tree": {
|
||||||
"SZ\u00c1MLAOSZT\u00c1LY BEFEKTETETT ESZK\u00d6Z\u00d6K": {
|
"SZ\u00c1MLAOSZT\u00c1LY BEFEKTETETT ESZK\u00d6Z\u00d6K": {
|
||||||
"account_number": 1,
|
"account_number": 1,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import unittest
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.test_runner import make_test_records
|
from frappe.test_runner import make_test_records
|
||||||
from frappe.utils import nowdate
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.account import (
|
from erpnext.accounts.doctype.account.account import (
|
||||||
InvalidAccountMergeError,
|
InvalidAccountMergeError,
|
||||||
@@ -325,19 +324,6 @@ class TestAccount(unittest.TestCase):
|
|||||||
acc.account_currency = "USD"
|
acc.account_currency = "USD"
|
||||||
self.assertRaises(frappe.ValidationError, acc.save)
|
self.assertRaises(frappe.ValidationError, acc.save)
|
||||||
|
|
||||||
def test_account_balance(self):
|
|
||||||
from erpnext.accounts.utils import get_balance_on
|
|
||||||
|
|
||||||
if not frappe.db.exists("Account", "Test Percent Account %5 - _TC"):
|
|
||||||
acc = frappe.new_doc("Account")
|
|
||||||
acc.account_name = "Test Percent Account %5"
|
|
||||||
acc.parent_account = "Tax Assets - _TC"
|
|
||||||
acc.company = "_Test Company"
|
|
||||||
acc.insert()
|
|
||||||
|
|
||||||
balance = get_balance_on(account="Test Percent Account %5 - _TC", date=nowdate())
|
|
||||||
self.assertEqual(balance, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def _make_test_records(verbose=None):
|
def _make_test_records(verbose=None):
|
||||||
from frappe.test_runner import make_test_objects
|
from frappe.test_runner import make_test_objects
|
||||||
|
|||||||
@@ -11,29 +11,6 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
|||||||
|
|
||||||
|
|
||||||
class AccountClosingBalance(Document):
|
class AccountClosingBalance(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account: DF.Link | None
|
|
||||||
account_currency: DF.Link | None
|
|
||||||
closing_date: DF.Date | None
|
|
||||||
company: DF.Link | None
|
|
||||||
cost_center: DF.Link | None
|
|
||||||
credit: DF.Currency
|
|
||||||
credit_in_account_currency: DF.Currency
|
|
||||||
debit: DF.Currency
|
|
||||||
debit_in_account_currency: DF.Currency
|
|
||||||
finance_book: DF.Link | None
|
|
||||||
is_period_closing_voucher_entry: DF.Check
|
|
||||||
period_closing_voucher: DF.Link | None
|
|
||||||
project: DF.Link | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,86 +1,74 @@
|
|||||||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Accounting Dimension", {
|
frappe.ui.form.on('Accounting Dimension', {
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
frm.set_query("document_type", () => {
|
frm.set_query('document_type', () => {
|
||||||
let invalid_doctypes = frappe.model.core_doctypes_list;
|
let invalid_doctypes = frappe.model.core_doctypes_list;
|
||||||
invalid_doctypes.push(
|
invalid_doctypes.push('Accounting Dimension', 'Project',
|
||||||
"Accounting Dimension",
|
'Cost Center', 'Accounting Dimension Detail', 'Company');
|
||||||
"Project",
|
|
||||||
"Cost Center",
|
|
||||||
"Accounting Dimension Detail",
|
|
||||||
"Company"
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
name: ["not in", invalid_doctypes],
|
name: ['not in', invalid_doctypes]
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("offsetting_account", "dimension_defaults", function (doc, cdt, cdn) {
|
frm.set_query("offsetting_account", "dimension_defaults", function(doc, cdt, cdn) {
|
||||||
let d = locals[cdt][cdn];
|
let d = locals[cdt][cdn];
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: d.company,
|
company: d.company,
|
||||||
root_type: ["in", ["Asset", "Liability"]],
|
root_type: ["in", ["Asset", "Liability"]],
|
||||||
is_group: 0,
|
is_group: 0
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!frm.is_new()) {
|
if (!frm.is_new()) {
|
||||||
frm.add_custom_button(__("Show {0}", [frm.doc.document_type]), function () {
|
frm.add_custom_button(__('Show {0}', [frm.doc.document_type]), function () {
|
||||||
frappe.set_route("List", frm.doc.document_type);
|
frappe.set_route("List", frm.doc.document_type);
|
||||||
});
|
});
|
||||||
|
|
||||||
let button = frm.doc.disabled ? "Enable" : "Disable";
|
let button = frm.doc.disabled ? "Enable" : "Disable";
|
||||||
|
|
||||||
frm.add_custom_button(__(button), function () {
|
frm.add_custom_button(__(button), function() {
|
||||||
frm.set_value("disabled", 1 - frm.doc.disabled);
|
|
||||||
|
frm.set_value('disabled', 1 - frm.doc.disabled);
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.disable_dimension",
|
method: "erpnext.accounts.doctype.accounting_dimension.accounting_dimension.disable_dimension",
|
||||||
args: {
|
args: {
|
||||||
doc: frm.doc,
|
doc: frm.doc
|
||||||
},
|
},
|
||||||
freeze: true,
|
freeze: true,
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
let message = frm.doc.disabled ? "Dimension Disabled" : "Dimension Enabled";
|
let message = frm.doc.disabled ? "Dimension Disabled" : "Dimension Enabled";
|
||||||
frm.save();
|
frm.save();
|
||||||
frappe.show_alert({ message: __(message), indicator: "green" });
|
frappe.show_alert({message:__(message), indicator:'green'});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
document_type: function (frm) {
|
document_type: function(frm) {
|
||||||
frm.set_value("label", frm.doc.document_type);
|
|
||||||
frm.set_value("fieldname", frappe.model.scrub(frm.doc.document_type));
|
|
||||||
|
|
||||||
frappe.db.get_value(
|
frm.set_value('label', frm.doc.document_type);
|
||||||
"Accounting Dimension",
|
frm.set_value('fieldname', frappe.model.scrub(frm.doc.document_type));
|
||||||
{ document_type: frm.doc.document_type },
|
|
||||||
"document_type",
|
frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => {
|
||||||
(r) => {
|
if (r && r.document_type) {
|
||||||
if (r && r.document_type) {
|
frm.set_df_property('document_type', 'description', "Document type is already set as dimension");
|
||||||
frm.set_df_property(
|
|
||||||
"document_type",
|
|
||||||
"description",
|
|
||||||
"Document type is already set as dimension"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Accounting Dimension Detail", {
|
frappe.ui.form.on('Accounting Dimension Detail', {
|
||||||
dimension_defaults_add: function (frm, cdt, cdn) {
|
dimension_defaults_add: function(frm, cdt, cdn) {
|
||||||
let row = locals[cdt][cdn];
|
let row = locals[cdt][cdn];
|
||||||
row.reference_document = frm.doc.document_type;
|
row.reference_document = frm.doc.document_type;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,31 +11,8 @@ from frappe.model import core_doctypes_list
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
|
|
||||||
from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import (
|
|
||||||
get_allowed_types_from_settings,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AccountingDimension(Document):
|
class AccountingDimension(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.accounting_dimension_detail.accounting_dimension_detail import (
|
|
||||||
AccountingDimensionDetail,
|
|
||||||
)
|
|
||||||
|
|
||||||
dimension_defaults: DF.Table[AccountingDimensionDetail]
|
|
||||||
disabled: DF.Check
|
|
||||||
document_type: DF.Link
|
|
||||||
fieldname: DF.Data | None
|
|
||||||
label: DF.Data | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def before_insert(self):
|
def before_insert(self):
|
||||||
self.set_fieldname_and_label()
|
self.set_fieldname_and_label()
|
||||||
|
|
||||||
@@ -110,7 +87,6 @@ def make_dimension_in_accounting_doctypes(doc, doclist=None):
|
|||||||
|
|
||||||
doc_count = len(get_accounting_dimensions())
|
doc_count = len(get_accounting_dimensions())
|
||||||
count = 0
|
count = 0
|
||||||
repostable_doctypes = get_allowed_types_from_settings()
|
|
||||||
|
|
||||||
for doctype in doclist:
|
for doctype in doclist:
|
||||||
|
|
||||||
@@ -126,7 +102,6 @@ def make_dimension_in_accounting_doctypes(doc, doclist=None):
|
|||||||
"options": doc.document_type,
|
"options": doc.document_type,
|
||||||
"insert_after": insert_after_field,
|
"insert_after": insert_after_field,
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"allow_on_submit": 1 if doctype in repostable_doctypes else 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta = frappe.get_meta(doctype, cached=False)
|
meta = frappe.get_meta(doctype, cached=False)
|
||||||
|
|||||||
@@ -7,24 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AccountingDimensionDetail(Document):
|
class AccountingDimensionDetail(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
automatically_post_balancing_accounting_entry: DF.Check
|
|
||||||
company: DF.Link | None
|
|
||||||
default_dimension: DF.DynamicLink | None
|
|
||||||
mandatory_for_bs: DF.Check
|
|
||||||
mandatory_for_pl: DF.Check
|
|
||||||
offsetting_account: DF.Link | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
reference_document: DF.Link | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Accounting Dimension Filter", {
|
frappe.ui.form.on('Accounting Dimension Filter', {
|
||||||
refresh: function (frm, cdt, cdn) {
|
refresh: function(frm, cdt, cdn) {
|
||||||
let help_content = `<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
let help_content =
|
||||||
|
`<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<p>
|
<p>
|
||||||
<i class="fa fa-hand-right"></i>
|
<i class="fa fa-hand-right"></i>
|
||||||
@@ -12,80 +13,77 @@ frappe.ui.form.on("Accounting Dimension Filter", {
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>`;
|
</table>`;
|
||||||
|
|
||||||
frm.set_df_property("dimension_filter_help", "options", help_content);
|
frm.set_df_property('dimension_filter_help', 'options', help_content);
|
||||||
},
|
},
|
||||||
onload: function (frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("applicable_on_account", "accounts", function () {
|
frm.set_query('applicable_on_account', 'accounts', function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
'company': frm.doc.company
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.db.get_list("Accounting Dimension", { fields: ["document_type"] }).then((res) => {
|
frappe.db.get_list('Accounting Dimension',
|
||||||
let options = ["Cost Center", "Project"];
|
{fields: ['document_type']}).then((res) => {
|
||||||
|
let options = ['Cost Center', 'Project'];
|
||||||
|
|
||||||
res.forEach((dimension) => {
|
res.forEach((dimension) => {
|
||||||
options.push(dimension.document_type);
|
options.push(dimension.document_type);
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_df_property("accounting_dimension", "options", options);
|
frm.set_df_property('accounting_dimension', 'options', options);
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.trigger("setup_filters");
|
frm.trigger('setup_filters');
|
||||||
},
|
},
|
||||||
|
|
||||||
setup_filters: function (frm) {
|
setup_filters: function(frm) {
|
||||||
let filters = {};
|
let filters = {};
|
||||||
|
|
||||||
if (frm.doc.accounting_dimension) {
|
if (frm.doc.accounting_dimension) {
|
||||||
frappe.model.with_doctype(frm.doc.accounting_dimension, function () {
|
frappe.model.with_doctype(frm.doc.accounting_dimension, function() {
|
||||||
if (frappe.model.is_tree(frm.doc.accounting_dimension)) {
|
if (frappe.model.is_tree(frm.doc.accounting_dimension)) {
|
||||||
filters["is_group"] = 0;
|
filters['is_group'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frappe.meta.has_field(frm.doc.accounting_dimension, "company")) {
|
if (frappe.meta.has_field(frm.doc.accounting_dimension, 'company')) {
|
||||||
filters["company"] = frm.doc.company;
|
filters['company'] = frm.doc.company;
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.set_query("dimension_value", "dimensions", function () {
|
frm.set_query('dimension_value', 'dimensions', function() {
|
||||||
return {
|
return {
|
||||||
filters: filters,
|
filters: filters
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
accounting_dimension: function (frm) {
|
accounting_dimension: function(frm) {
|
||||||
frm.clear_table("dimensions");
|
frm.clear_table("dimensions");
|
||||||
let row = frm.add_child("dimensions");
|
let row = frm.add_child("dimensions");
|
||||||
row.accounting_dimension = frm.doc.accounting_dimension;
|
row.accounting_dimension = frm.doc.accounting_dimension;
|
||||||
frm.fields_dict["dimensions"].grid.update_docfield_property(
|
frm.fields_dict["dimensions"].grid.update_docfield_property("dimension_value", "label", frm.doc.accounting_dimension);
|
||||||
"dimension_value",
|
|
||||||
"label",
|
|
||||||
frm.doc.accounting_dimension
|
|
||||||
);
|
|
||||||
frm.refresh_field("dimensions");
|
frm.refresh_field("dimensions");
|
||||||
frm.trigger("setup_filters");
|
frm.trigger('setup_filters');
|
||||||
},
|
},
|
||||||
apply_restriction_on_values: function (frm) {
|
apply_restriction_on_values: function(frm) {
|
||||||
/** If restriction on values is not applied, we should set "allow_or_restrict" to "Restrict" with an empty allowed dimension table.
|
/** If restriction on values is not applied, we should set "allow_or_restrict" to "Restrict" with an empty allowed dimension table.
|
||||||
* Hence it's not "restricted" on any value.
|
* Hence it's not "restricted" on any value.
|
||||||
*/
|
*/
|
||||||
if (!frm.doc.apply_restriction_on_values) {
|
if (!frm.doc.apply_restriction_on_values) {
|
||||||
frm.set_value("allow_or_restrict", "Restrict");
|
frm.set_value("allow_or_restrict", "Restrict");
|
||||||
frm.clear_table("dimensions");
|
frm.clear_table("dimensions");
|
||||||
frm.refresh_field("dimensions");
|
frm.refresh_field("dimensions");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Allowed Dimension", {
|
frappe.ui.form.on('Allowed Dimension', {
|
||||||
dimensions_add: function (frm, cdt, cdn) {
|
dimensions_add: function(frm, cdt, cdn) {
|
||||||
let row = locals[cdt][cdn];
|
let row = locals[cdt][cdn];
|
||||||
row.accounting_dimension = frm.doc.accounting_dimension;
|
row.accounting_dimension = frm.doc.accounting_dimension;
|
||||||
frm.refresh_field("dimensions");
|
frm.refresh_field("dimensions");
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,28 +8,6 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AccountingDimensionFilter(Document):
|
class AccountingDimensionFilter(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.allowed_dimension.allowed_dimension import AllowedDimension
|
|
||||||
from erpnext.accounts.doctype.applicable_on_account.applicable_on_account import (
|
|
||||||
ApplicableOnAccount,
|
|
||||||
)
|
|
||||||
|
|
||||||
accounting_dimension: DF.Literal
|
|
||||||
accounts: DF.Table[ApplicableOnAccount]
|
|
||||||
allow_or_restrict: DF.Literal["Allow", "Restrict"]
|
|
||||||
apply_restriction_on_values: DF.Check
|
|
||||||
company: DF.Link
|
|
||||||
dimensions: DF.Table[AllowedDimension]
|
|
||||||
disabled: DF.Check
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
# If restriction is not applied on values, then remove all the dimensions and set allow_or_restrict to Restrict
|
# If restriction is not applied on values, then remove all the dimensions and set allow_or_restrict to Restrict
|
||||||
if not self.apply_restriction_on_values:
|
if not self.apply_restriction_on_values:
|
||||||
|
|||||||
@@ -1,33 +1,30 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Accounting Period", {
|
frappe.ui.form.on('Accounting Period', {
|
||||||
onload: function (frm) {
|
onload: function(frm) {
|
||||||
if (
|
if(frm.doc.closed_documents.length === 0 || (frm.doc.closed_documents.length === 1 && frm.doc.closed_documents[0].document_type == undefined)) {
|
||||||
frm.doc.closed_documents.length === 0 ||
|
|
||||||
(frm.doc.closed_documents.length === 1 && frm.doc.closed_documents[0].document_type == undefined)
|
|
||||||
) {
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "get_doctypes_for_closing",
|
method: "get_doctypes_for_closing",
|
||||||
doc: frm.doc,
|
doc:frm.doc,
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
if (r.message) {
|
if(r.message) {
|
||||||
cur_frm.clear_table("closed_documents");
|
cur_frm.clear_table("closed_documents");
|
||||||
r.message.forEach(function (element) {
|
r.message.forEach(function(element) {
|
||||||
var c = frm.add_child("closed_documents");
|
var c = frm.add_child("closed_documents");
|
||||||
c.document_type = element.document_type;
|
c.document_type = element.document_type;
|
||||||
c.closed = element.closed;
|
c.closed = element.closed;
|
||||||
});
|
});
|
||||||
refresh_field("closed_documents");
|
refresh_field("closed_documents");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.set_query("document_type", "closed_documents", () => {
|
frm.set_query("document_type", "closed_documents", () => {
|
||||||
return {
|
return {
|
||||||
query: "erpnext.controllers.queries.get_doctypes_for_closing",
|
query: "erpnext.controllers.queries.get_doctypes_for_closing",
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,23 +16,6 @@ class ClosedAccountingPeriod(frappe.ValidationError):
|
|||||||
|
|
||||||
|
|
||||||
class AccountingPeriod(Document):
|
class AccountingPeriod(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.closed_document.closed_document import ClosedDocument
|
|
||||||
|
|
||||||
closed_documents: DF.Table[ClosedDocument]
|
|
||||||
company: DF.Link
|
|
||||||
end_date: DF.Date
|
|
||||||
period_name: DF.Data
|
|
||||||
start_date: DF.Date
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_overlap()
|
self.validate_overlap()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Accounts Settings", {
|
frappe.ui.form.on('Accounts Settings', {
|
||||||
refresh: function (frm) {},
|
refresh: function(frm) {
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"creation": "2013-06-24 15:49:57",
|
"creation": "2013-06-24 15:49:57",
|
||||||
|
"description": "Settings for Accounts",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Other",
|
"document_type": "Other",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@@ -65,12 +66,7 @@
|
|||||||
"show_balance_in_coa",
|
"show_balance_in_coa",
|
||||||
"banking_tab",
|
"banking_tab",
|
||||||
"enable_party_matching",
|
"enable_party_matching",
|
||||||
"enable_fuzzy_matching",
|
"enable_fuzzy_matching"
|
||||||
"reports_tab",
|
|
||||||
"remarks_section",
|
|
||||||
"general_ledger_remarks_length",
|
|
||||||
"column_break_lvjk",
|
|
||||||
"receivable_payable_remarks_length"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -426,34 +422,6 @@
|
|||||||
"fieldname": "round_row_wise_tax",
|
"fieldname": "round_row_wise_tax",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Round Tax Amount Row-wise"
|
"label": "Round Tax Amount Row-wise"
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "reports_tab",
|
|
||||||
"fieldtype": "Tab Break",
|
|
||||||
"label": "Reports"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"description": "Truncates 'Remarks' column to set character length",
|
|
||||||
"fieldname": "general_ledger_remarks_length",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"label": "General Ledger"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"description": "Truncates 'Remarks' column to set character length",
|
|
||||||
"fieldname": "receivable_payable_remarks_length",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"label": "Accounts Receivable/Payable"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "column_break_lvjk",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "remarks_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Remarks Column Length"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -461,7 +429,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-01-30 14:04:26.553554",
|
"modified": "2023-08-28 00:12:02.740633",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounts Settings",
|
"name": "Accounts Settings",
|
||||||
|
|||||||
@@ -14,52 +14,6 @@ from erpnext.stock.utils import check_pending_reposting
|
|||||||
|
|
||||||
|
|
||||||
class AccountsSettings(Document):
|
class AccountsSettings(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
acc_frozen_upto: DF.Date | None
|
|
||||||
add_taxes_from_item_tax_template: DF.Check
|
|
||||||
allow_multi_currency_invoices_against_single_party_account: DF.Check
|
|
||||||
allow_stale: DF.Check
|
|
||||||
auto_reconcile_payments: DF.Check
|
|
||||||
automatically_fetch_payment_terms: DF.Check
|
|
||||||
automatically_process_deferred_accounting_entry: DF.Check
|
|
||||||
book_asset_depreciation_entry_automatically: DF.Check
|
|
||||||
book_deferred_entries_based_on: DF.Literal["Days", "Months"]
|
|
||||||
book_deferred_entries_via_journal_entry: DF.Check
|
|
||||||
book_tax_discount_loss: DF.Check
|
|
||||||
check_supplier_invoice_uniqueness: DF.Check
|
|
||||||
credit_controller: DF.Link | None
|
|
||||||
delete_linked_ledger_entries: DF.Check
|
|
||||||
determine_address_tax_category_from: DF.Literal["Billing Address", "Shipping Address"]
|
|
||||||
enable_common_party_accounting: DF.Check
|
|
||||||
enable_fuzzy_matching: DF.Check
|
|
||||||
enable_party_matching: DF.Check
|
|
||||||
frozen_accounts_modifier: DF.Link | None
|
|
||||||
general_ledger_remarks_length: DF.Int
|
|
||||||
ignore_account_closing_balance: DF.Check
|
|
||||||
make_payment_via_journal_entry: DF.Check
|
|
||||||
merge_similar_account_heads: DF.Check
|
|
||||||
over_billing_allowance: DF.Currency
|
|
||||||
post_change_gl_entries: DF.Check
|
|
||||||
receivable_payable_remarks_length: DF.Int
|
|
||||||
role_allowed_to_over_bill: DF.Link | None
|
|
||||||
round_row_wise_tax: DF.Check
|
|
||||||
show_balance_in_coa: DF.Check
|
|
||||||
show_inclusive_tax_in_print: DF.Check
|
|
||||||
show_payment_schedule_in_print: DF.Check
|
|
||||||
show_taxes_as_table_in_print: DF.Check
|
|
||||||
stale_days: DF.Int
|
|
||||||
submit_journal_entries: DF.Check
|
|
||||||
unlink_advance_payment_on_cancelation_of_order: DF.Check
|
|
||||||
unlink_payment_on_cancellation_of_invoice: DF.Check
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
old_doc = self.get_doc_before_save()
|
old_doc = self.get_doc_before_save()
|
||||||
clear_cache = False
|
clear_cache = False
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
frappe.ui.form.on("Accounts Settings", {
|
|
||||||
refresh: function (frm) {
|
frappe.ui.form.on('Accounts Settings', {
|
||||||
|
refresh: function(frm) {
|
||||||
frm.set_df_property("acc_frozen_upto", "label", "Books Closed Through");
|
frm.set_df_property("acc_frozen_upto", "label", "Books Closed Through");
|
||||||
frm.set_df_property(
|
frm.set_df_property("frozen_accounts_modifier", "label", "Role Allowed to Close Books & Make Changes to Closed Periods");
|
||||||
"frozen_accounts_modifier",
|
|
||||||
"label",
|
|
||||||
"Role Allowed to Close Books & Make Changes to Closed Periods"
|
|
||||||
);
|
|
||||||
frm.set_df_property("credit_controller", "label", "Credit Manager");
|
frm.set_df_property("credit_controller", "label", "Credit Manager");
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,22 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AdvanceTax(Document):
|
class AdvanceTax(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_head: DF.Link | None
|
|
||||||
allocated_amount: DF.Currency
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
reference_detail: DF.Data | None
|
|
||||||
reference_name: DF.DynamicLink | None
|
|
||||||
reference_type: DF.Link | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -7,33 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AdvanceTaxesandCharges(Document):
|
class AdvanceTaxesandCharges(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_head: DF.Link
|
|
||||||
add_deduct_tax: DF.Literal["Add", "Deduct"]
|
|
||||||
allocated_amount: DF.Currency
|
|
||||||
base_tax_amount: DF.Currency
|
|
||||||
base_total: DF.Currency
|
|
||||||
charge_type: DF.Literal[
|
|
||||||
"", "Actual", "On Paid Amount", "On Previous Row Amount", "On Previous Row Total"
|
|
||||||
]
|
|
||||||
cost_center: DF.Link | None
|
|
||||||
currency: DF.Link | None
|
|
||||||
description: DF.SmallText
|
|
||||||
included_in_paid_amount: DF.Check
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
rate: DF.Float
|
|
||||||
row_id: DF.Data | None
|
|
||||||
tax_amount: DF.Currency
|
|
||||||
total: DF.Currency
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -7,19 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AllowedDimension(Document):
|
class AllowedDimension(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
accounting_dimension: DF.Link | None
|
|
||||||
dimension_value: DF.DynamicLink | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"ignore_user_permissions": 1,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Company",
|
"label": "Company",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
@@ -20,7 +19,7 @@
|
|||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-01-03 11:13:02.669632",
|
"modified": "2020-05-01 12:32:34.044911",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Allowed To Transact With",
|
"name": "Allowed To Transact With",
|
||||||
@@ -29,6 +28,5 @@
|
|||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -6,18 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class AllowedToTransactWith(Document):
|
class AllowedToTransactWith(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
company: DF.Link
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -7,19 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class ApplicableOnAccount(Document):
|
class ApplicableOnAccount(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
applicable_on_account: DF.Link
|
|
||||||
is_mandatory: DF.Check
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,36 +1,38 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
frappe.provide("erpnext.integrations");
|
frappe.provide('erpnext.integrations');
|
||||||
|
|
||||||
frappe.ui.form.on("Bank", {
|
frappe.ui.form.on('Bank', {
|
||||||
onload: function (frm) {
|
onload: function(frm) {
|
||||||
add_fields_to_mapping_table(frm);
|
add_fields_to_mapping_table(frm);
|
||||||
},
|
},
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
add_fields_to_mapping_table(frm);
|
add_fields_to_mapping_table(frm);
|
||||||
frm.toggle_display(["address_html", "contact_html"], !frm.doc.__islocal);
|
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
||||||
|
|
||||||
if (frm.doc.__islocal) {
|
if (frm.doc.__islocal) {
|
||||||
frm.set_df_property("address_and_contact", "hidden", 1);
|
frm.set_df_property('address_and_contact', 'hidden', 1);
|
||||||
frappe.contacts.clear_address_and_contact(frm);
|
frappe.contacts.clear_address_and_contact(frm);
|
||||||
} else {
|
}
|
||||||
frm.set_df_property("address_and_contact", "hidden", 0);
|
else {
|
||||||
|
frm.set_df_property('address_and_contact', 'hidden', 0);
|
||||||
frappe.contacts.render_address_and_contact(frm);
|
frappe.contacts.render_address_and_contact(frm);
|
||||||
}
|
}
|
||||||
if (frm.doc.plaid_access_token) {
|
if (frm.doc.plaid_access_token) {
|
||||||
frm.add_custom_button(__("Refresh Plaid Link"), () => {
|
frm.add_custom_button(__('Refresh Plaid Link'), () => {
|
||||||
new erpnext.integrations.refreshPlaidLink(frm.doc.plaid_access_token);
|
new erpnext.integrations.refreshPlaidLink(frm.doc.plaid_access_token);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let add_fields_to_mapping_table = function (frm) {
|
let add_fields_to_mapping_table = function (frm) {
|
||||||
let options = [];
|
let options = [];
|
||||||
|
|
||||||
frappe.model.with_doctype("Bank Transaction", function () {
|
frappe.model.with_doctype("Bank Transaction", function() {
|
||||||
let meta = frappe.get_meta("Bank Transaction");
|
let meta = frappe.get_meta("Bank Transaction");
|
||||||
meta.fields.forEach((value) => {
|
meta.fields.forEach(value => {
|
||||||
if (!["Section Break", "Column Break"].includes(value.fieldtype)) {
|
if (!["Section Break", "Column Break"].includes(value.fieldtype)) {
|
||||||
options.push(value.fieldname);
|
options.push(value.fieldname);
|
||||||
}
|
}
|
||||||
@@ -38,32 +40,30 @@ let add_fields_to_mapping_table = function (frm) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frm.fields_dict.bank_transaction_mapping.grid.update_docfield_property(
|
frm.fields_dict.bank_transaction_mapping.grid.update_docfield_property(
|
||||||
"bank_transaction_field",
|
'bank_transaction_field', 'options', options
|
||||||
"options",
|
|
||||||
options
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
erpnext.integrations.refreshPlaidLink = class refreshPlaidLink {
|
erpnext.integrations.refreshPlaidLink = class refreshPlaidLink {
|
||||||
constructor(access_token) {
|
constructor(access_token) {
|
||||||
this.access_token = access_token;
|
this.access_token = access_token;
|
||||||
this.plaidUrl = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
|
this.plaidUrl = 'https://cdn.plaid.com/link/v2/stable/link-initialize.js';
|
||||||
this.init_config();
|
this.init_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
async init_config() {
|
async init_config() {
|
||||||
this.plaid_env = await frappe.db.get_single_value("Plaid Settings", "plaid_env");
|
this.plaid_env = await frappe.db.get_single_value('Plaid Settings', 'plaid_env');
|
||||||
this.token = await this.get_link_token_for_update();
|
this.token = await this.get_link_token_for_update();
|
||||||
this.init_plaid();
|
this.init_plaid();
|
||||||
}
|
}
|
||||||
|
|
||||||
async get_link_token_for_update() {
|
async get_link_token_for_update() {
|
||||||
const token = frappe.xcall(
|
const token = frappe.xcall(
|
||||||
"erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.get_link_token_for_update",
|
'erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.get_link_token_for_update',
|
||||||
{ access_token: this.access_token }
|
{ access_token: this.access_token }
|
||||||
);
|
)
|
||||||
if (!token) {
|
if (!token) {
|
||||||
frappe.throw(__("Cannot retrieve link token for update. Check Error Log for more information"));
|
frappe.throw(__('Cannot retrieve link token for update. Check Error Log for more information'));
|
||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
@@ -90,45 +90,35 @@ erpnext.integrations.refreshPlaidLink = class refreshPlaidLink {
|
|||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const el = document.createElement("script");
|
const el = document.createElement('script');
|
||||||
el.type = "text/javascript";
|
el.type = 'text/javascript';
|
||||||
el.async = true;
|
el.async = true;
|
||||||
el.src = src;
|
el.src = src;
|
||||||
el.addEventListener("load", resolve);
|
el.addEventListener('load', resolve);
|
||||||
el.addEventListener("error", reject);
|
el.addEventListener('error', reject);
|
||||||
el.addEventListener("abort", reject);
|
el.addEventListener('abort', reject);
|
||||||
document.head.appendChild(el);
|
document.head.appendChild(el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onScriptLoaded(me) {
|
onScriptLoaded(me) {
|
||||||
me.linkHandler = Plaid.create({
|
me.linkHandler = Plaid.create({ // eslint-disable-line no-undef
|
||||||
// eslint-disable-line no-undef
|
|
||||||
env: me.plaid_env,
|
env: me.plaid_env,
|
||||||
token: me.token,
|
token: me.token,
|
||||||
onSuccess: me.plaid_success,
|
onSuccess: me.plaid_success
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onScriptError(error) {
|
onScriptError(error) {
|
||||||
frappe.msgprint(
|
frappe.msgprint(__("There was an issue connecting to Plaid's authentication server. Check browser console for more information"));
|
||||||
__(
|
|
||||||
"There was an issue connecting to Plaid's authentication server. Check browser console for more information"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
plaid_success(token, response) {
|
plaid_success(token, response) {
|
||||||
frappe
|
frappe.xcall('erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.update_bank_account_ids', {
|
||||||
.xcall(
|
response: response,
|
||||||
"erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings.update_bank_account_ids",
|
}).then(() => {
|
||||||
{
|
frappe.show_alert({ message: __('Plaid Link Updated'), indicator: 'green' });
|
||||||
response: response,
|
});
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
frappe.show_alert({ message: __("Plaid Link Updated"), indicator: "green" });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,25 +10,6 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class Bank(Document):
|
class Bank(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_transaction_mapping.bank_transaction_mapping import (
|
|
||||||
BankTransactionMapping,
|
|
||||||
)
|
|
||||||
|
|
||||||
bank_name: DF.Data
|
|
||||||
bank_transaction_mapping: DF.Table[BankTransactionMapping]
|
|
||||||
plaid_access_token: DF.Data | None
|
|
||||||
swift_number: DF.Data | None
|
|
||||||
website: DF.Data | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
"""Load address and contacts in `__onload`"""
|
"""Load address and contacts in `__onload`"""
|
||||||
load_address_and_contact(self)
|
load_address_and_contact(self)
|
||||||
|
|||||||
@@ -1,49 +1,45 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Account", {
|
frappe.ui.form.on('Bank Account', {
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("account", function () {
|
frm.set_query("account", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
account_type: "Bank",
|
'account_type': 'Bank',
|
||||||
company: frm.doc.company,
|
'company': frm.doc.company,
|
||||||
is_group: 0,
|
'is_group': 0
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
frm.set_query("party_type", function () {
|
frm.set_query("party_type", function() {
|
||||||
return {
|
return {
|
||||||
query: "erpnext.setup.doctype.party_type.party_type.get_party_type",
|
query: "erpnext.setup.doctype.party_type.party_type.get_party_type",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
frappe.dynamic_link = { doc: frm.doc, fieldname: "name", doctype: "Bank Account" };
|
frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Bank Account' }
|
||||||
|
|
||||||
frm.toggle_display(["address_html", "contact_html"], !frm.doc.__islocal);
|
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
||||||
|
|
||||||
if (frm.doc.__islocal) {
|
if (frm.doc.__islocal) {
|
||||||
frappe.contacts.clear_address_and_contact(frm);
|
frappe.contacts.clear_address_and_contact(frm);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
frappe.contacts.render_address_and_contact(frm);
|
frappe.contacts.render_address_and_contact(frm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.integration_id) {
|
if (frm.doc.integration_id) {
|
||||||
frm.add_custom_button(__("Unlink external integrations"), function () {
|
frm.add_custom_button(__("Unlink external integrations"), function() {
|
||||||
frappe.confirm(
|
frappe.confirm(__("This action will unlink this account from any external service integrating ERPNext with your bank accounts. It cannot be undone. Are you certain ?"), function() {
|
||||||
__(
|
frm.set_value("integration_id", "");
|
||||||
"This action will unlink this account from any external service integrating ERPNext with your bank accounts. It cannot be undone. Are you certain ?"
|
});
|
||||||
),
|
|
||||||
function () {
|
|
||||||
frm.set_value("integration_id", "");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
is_company_account: function (frm) {
|
is_company_account: function(frm) {
|
||||||
frm.set_df_property("account", "reqd", frm.doc.is_company_account);
|
frm.set_df_property('account', 'reqd', frm.doc.is_company_account);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,37 +9,9 @@ from frappe.contacts.address_and_contact import (
|
|||||||
load_address_and_contact,
|
load_address_and_contact,
|
||||||
)
|
)
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import comma_and, get_link_to_form
|
|
||||||
|
|
||||||
|
|
||||||
class BankAccount(Document):
|
class BankAccount(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account: DF.Link | None
|
|
||||||
account_name: DF.Data
|
|
||||||
account_subtype: DF.Link | None
|
|
||||||
account_type: DF.Link | None
|
|
||||||
bank: DF.Link
|
|
||||||
bank_account_no: DF.Data | None
|
|
||||||
branch_code: DF.Data | None
|
|
||||||
company: DF.Link | None
|
|
||||||
disabled: DF.Check
|
|
||||||
iban: DF.Data | None
|
|
||||||
integration_id: DF.Data | None
|
|
||||||
is_company_account: DF.Check
|
|
||||||
is_default: DF.Check
|
|
||||||
last_integration_date: DF.Date | None
|
|
||||||
mask: DF.Data | None
|
|
||||||
party: DF.DynamicLink | None
|
|
||||||
party_type: DF.Link | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
"""Load address and contacts in `__onload`"""
|
"""Load address and contacts in `__onload`"""
|
||||||
load_address_and_contact(self)
|
load_address_and_contact(self)
|
||||||
@@ -53,19 +25,6 @@ class BankAccount(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_company()
|
self.validate_company()
|
||||||
self.validate_iban()
|
self.validate_iban()
|
||||||
self.validate_account()
|
|
||||||
|
|
||||||
def validate_account(self):
|
|
||||||
if self.account:
|
|
||||||
if accounts := frappe.db.get_all(
|
|
||||||
"Bank Account", filters={"account": self.account, "name": ["!=", self.name]}, as_list=1
|
|
||||||
):
|
|
||||||
frappe.throw(
|
|
||||||
_("'{0}' account is already used by {1}. Use another account.").format(
|
|
||||||
frappe.bold(self.account),
|
|
||||||
frappe.bold(comma_and([get_link_to_form(self.doctype, x[0]) for x in accounts])),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def validate_company(self):
|
def validate_company(self):
|
||||||
if self.is_company_account and not self.company:
|
if self.is_company_account and not self.company:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Account Subtype", {
|
frappe.ui.form.on('Bank Account Subtype', {
|
||||||
refresh: function () {},
|
refresh: function() {
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,15 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankAccountSubtype(Document):
|
class BankAccountSubtype(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_subtype: DF.Data | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Account Type", {
|
frappe.ui.form.on('Bank Account Type', {
|
||||||
// refresh: function(frm) {
|
// refresh: function(frm) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,15 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankAccountType(Document):
|
class BankAccountType(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_type: DF.Data | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2,76 +2,80 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Clearance", {
|
frappe.ui.form.on("Bank Clearance", {
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.add_fetch("account", "account_currency", "account_currency");
|
frm.add_fetch("account", "account_currency", "account_currency");
|
||||||
|
|
||||||
frm.set_query("account", function () {
|
frm.set_query("account", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
"filters": {
|
||||||
account_type: ["in", ["Bank", "Cash"]],
|
"account_type": ["in",["Bank","Cash"]],
|
||||||
is_group: 0,
|
"is_group": 0,
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("bank_account", function () {
|
frm.set_query("bank_account", function () {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
is_company_account: 1,
|
'is_company_account': 1
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function(frm) {
|
||||||
let default_bank_account = frappe.defaults.get_user_default("Company")
|
|
||||||
? locals[":Company"][frappe.defaults.get_user_default("Company")]["default_bank_account"]
|
let default_bank_account = frappe.defaults.get_user_default("Company")?
|
||||||
: "";
|
locals[":Company"][frappe.defaults.get_user_default("Company")]["default_bank_account"]: "";
|
||||||
frm.set_value("account", default_bank_account);
|
frm.set_value("account", default_bank_account);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frm.set_value("from_date", frappe.datetime.month_start());
|
frm.set_value("from_date", frappe.datetime.month_start());
|
||||||
frm.set_value("to_date", frappe.datetime.month_end());
|
frm.set_value("to_date", frappe.datetime.month_end());
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
frm.add_custom_button(__("Get Payment Entries"), () => frm.trigger("get_payment_entries"));
|
frm.add_custom_button(__('Get Payment Entries'), () =>
|
||||||
|
frm.trigger("get_payment_entries")
|
||||||
|
);
|
||||||
|
|
||||||
frm.change_custom_button_type(__("Get Payment Entries"), null, "primary");
|
frm.change_custom_button_type(__('Get Payment Entries'), null, 'primary');
|
||||||
},
|
},
|
||||||
|
|
||||||
update_clearance_date: function (frm) {
|
update_clearance_date: function(frm) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "update_clearance_date",
|
method: "update_clearance_date",
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
callback: function (r, rt) {
|
callback: function(r, rt) {
|
||||||
frm.refresh_field("payment_entries");
|
frm.refresh_field("payment_entries");
|
||||||
frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
|
|
||||||
if (!frm.doc.payment_entries.length) {
|
if (!frm.doc.payment_entries.length) {
|
||||||
frm.change_custom_button_type(__("Get Payment Entries"), null, "primary");
|
frm.change_custom_button_type(__('Get Payment Entries'), null, 'primary');
|
||||||
frm.change_custom_button_type(__("Update Clearance Date"), null, "default");
|
frm.change_custom_button_type(__('Update Clearance Date'), null, 'default');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
get_payment_entries: function (frm) {
|
get_payment_entries: function(frm) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "get_payment_entries",
|
method: "get_payment_entries",
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
callback: function (r, rt) {
|
callback: function(r, rt) {
|
||||||
frm.refresh_field("payment_entries");
|
frm.refresh_field("payment_entries");
|
||||||
|
|
||||||
if (frm.doc.payment_entries.length) {
|
if (frm.doc.payment_entries.length) {
|
||||||
frm.add_custom_button(__("Update Clearance Date"), () =>
|
frm.add_custom_button(__('Update Clearance Date'), () =>
|
||||||
frm.trigger("update_clearance_date")
|
frm.trigger("update_clearance_date")
|
||||||
);
|
);
|
||||||
|
|
||||||
frm.change_custom_button_type(__("Get Payment Entries"), null, "default");
|
frm.change_custom_button_type(__('Get Payment Entries'), null, 'default');
|
||||||
frm.change_custom_button_type(__("Update Clearance Date"), null, "primary");
|
frm.change_custom_button_type(__('Update Clearance Date'), null, 'primary');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.query_builder.custom import ConstantColumn
|
|
||||||
from frappe.utils import flt, fmt_money, getdate
|
from frappe.utils import flt, fmt_money, getdate
|
||||||
from pypika import Order
|
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
|
|
||||||
@@ -15,28 +13,6 @@ form_grid_templates = {"journal_entries": "templates/form_grid/bank_reconciliati
|
|||||||
|
|
||||||
|
|
||||||
class BankClearance(Document):
|
class BankClearance(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_clearance_detail.bank_clearance_detail import (
|
|
||||||
BankClearanceDetail,
|
|
||||||
)
|
|
||||||
|
|
||||||
account: DF.Link
|
|
||||||
account_currency: DF.Link | None
|
|
||||||
bank_account: DF.Link | None
|
|
||||||
from_date: DF.Date
|
|
||||||
include_pos_transactions: DF.Check
|
|
||||||
include_reconciled_entries: DF.Check
|
|
||||||
payment_entries: DF.Table[BankClearanceDetail]
|
|
||||||
to_date: DF.Date
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entries(self):
|
def get_payment_entries(self):
|
||||||
if not (self.from_date and self.to_date):
|
if not (self.from_date and self.to_date):
|
||||||
@@ -181,62 +157,39 @@ def get_payment_entries_for_bank_clearance(
|
|||||||
|
|
||||||
pos_sales_invoices, pos_purchase_invoices = [], []
|
pos_sales_invoices, pos_purchase_invoices = [], []
|
||||||
if include_pos_transactions:
|
if include_pos_transactions:
|
||||||
si_payment = frappe.qb.DocType("Sales Invoice Payment")
|
pos_sales_invoices = frappe.db.sql(
|
||||||
si = frappe.qb.DocType("Sales Invoice")
|
"""
|
||||||
acc = frappe.qb.DocType("Account")
|
select
|
||||||
|
"Sales Invoice Payment" as payment_document, sip.name as payment_entry, sip.amount as debit,
|
||||||
|
si.posting_date, si.customer as against_account, sip.clearance_date,
|
||||||
|
account.account_currency, 0 as credit
|
||||||
|
from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account
|
||||||
|
where
|
||||||
|
sip.account=%(account)s and si.docstatus=1 and sip.parent = si.name
|
||||||
|
and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s
|
||||||
|
order by
|
||||||
|
si.posting_date ASC, si.name DESC
|
||||||
|
""",
|
||||||
|
{"account": account, "from": from_date, "to": to_date},
|
||||||
|
as_dict=1,
|
||||||
|
)
|
||||||
|
|
||||||
pos_sales_invoices = (
|
pos_purchase_invoices = frappe.db.sql(
|
||||||
frappe.qb.from_(si_payment)
|
"""
|
||||||
.inner_join(si)
|
select
|
||||||
.on(si_payment.parent == si.name)
|
"Purchase Invoice" as payment_document, pi.name as payment_entry, pi.paid_amount as credit,
|
||||||
.inner_join(acc)
|
pi.posting_date, pi.supplier as against_account, pi.clearance_date,
|
||||||
.on(si_payment.account == acc.name)
|
account.account_currency, 0 as debit
|
||||||
.select(
|
from `tabPurchase Invoice` pi, `tabAccount` account
|
||||||
ConstantColumn("Sales Invoice").as_("payment_document"),
|
where
|
||||||
si.name.as_("payment_entry"),
|
pi.cash_bank_account=%(account)s and pi.docstatus=1 and account.name = pi.cash_bank_account
|
||||||
si_payment.reference_no.as_("cheque_number"),
|
and pi.posting_date >= %(from)s and pi.posting_date <= %(to)s
|
||||||
si_payment.amount.as_("debit"),
|
order by
|
||||||
si.posting_date,
|
pi.posting_date ASC, pi.name DESC
|
||||||
si.customer.as_("against_account"),
|
""",
|
||||||
si_payment.clearance_date,
|
{"account": account, "from": from_date, "to": to_date},
|
||||||
acc.account_currency,
|
as_dict=1,
|
||||||
ConstantColumn(0).as_("credit"),
|
)
|
||||||
)
|
|
||||||
.where(
|
|
||||||
(si.docstatus == 1)
|
|
||||||
& (si_payment.account == account)
|
|
||||||
& (si.posting_date >= from_date)
|
|
||||||
& (si.posting_date <= to_date)
|
|
||||||
)
|
|
||||||
.orderby(si.posting_date)
|
|
||||||
.orderby(si.name, order=Order.desc)
|
|
||||||
).run(as_dict=True)
|
|
||||||
|
|
||||||
pi = frappe.qb.DocType("Purchase Invoice")
|
|
||||||
|
|
||||||
pos_purchase_invoices = (
|
|
||||||
frappe.qb.from_(pi)
|
|
||||||
.inner_join(acc)
|
|
||||||
.on(pi.cash_bank_account == acc.name)
|
|
||||||
.select(
|
|
||||||
ConstantColumn("Purchase Invoice").as_("payment_document"),
|
|
||||||
pi.name.as_("payment_entry"),
|
|
||||||
pi.paid_amount.as_("credit"),
|
|
||||||
pi.posting_date,
|
|
||||||
pi.supplier.as_("against_account"),
|
|
||||||
pi.clearance_date,
|
|
||||||
acc.account_currency,
|
|
||||||
ConstantColumn(0).as_("debit"),
|
|
||||||
)
|
|
||||||
.where(
|
|
||||||
(pi.docstatus == 1)
|
|
||||||
& (pi.cash_bank_account == account)
|
|
||||||
& (pi.posting_date >= from_date)
|
|
||||||
& (pi.posting_date <= to_date)
|
|
||||||
)
|
|
||||||
.orderby(pi.posting_date)
|
|
||||||
.orderby(pi.name, order=Order.desc)
|
|
||||||
).run(as_dict=True)
|
|
||||||
|
|
||||||
entries = (
|
entries = (
|
||||||
list(payment_entries)
|
list(payment_entries)
|
||||||
|
|||||||
@@ -6,25 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankClearanceDetail(Document):
|
class BankClearanceDetail(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
against_account: DF.Data | None
|
|
||||||
amount: DF.Data | None
|
|
||||||
cheque_date: DF.Date | None
|
|
||||||
cheque_number: DF.Data | None
|
|
||||||
clearance_date: DF.Date | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
payment_document: DF.Link | None
|
|
||||||
payment_entry: DF.DynamicLink | None
|
|
||||||
posting_date: DF.Date | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
cur_frm.add_fetch("bank_account", "account", "account");
|
cur_frm.add_fetch('bank_account','account','account');
|
||||||
cur_frm.add_fetch("bank_account", "bank_account_no", "bank_account_no");
|
cur_frm.add_fetch('bank_account','bank_account_no','bank_account_no');
|
||||||
cur_frm.add_fetch("bank_account", "iban", "iban");
|
cur_frm.add_fetch('bank_account','iban','iban');
|
||||||
cur_frm.add_fetch("bank_account", "branch_code", "branch_code");
|
cur_frm.add_fetch('bank_account','branch_code','branch_code');
|
||||||
cur_frm.add_fetch("bank", "swift_number", "swift_number");
|
cur_frm.add_fetch('bank','swift_number','swift_number');
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Guarantee", {
|
frappe.ui.form.on('Bank Guarantee', {
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("bank", function () {
|
frm.set_query("bank", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: frm.doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
frm.set_query("bank_account", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
},
|
bank: frm.doc.bank
|
||||||
};
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
frm.set_query("bank_account", function () {
|
frm.set_query("project", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
customer: frm.doc.customer
|
||||||
bank: frm.doc.bank,
|
}
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
frm.set_query("project", function () {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
customer: frm.doc.customer,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
bg_type: function (frm) {
|
bg_type: function(frm) {
|
||||||
if (frm.doc.bg_type == "Receiving") {
|
if (frm.doc.bg_type == "Receiving") {
|
||||||
frm.set_value("reference_doctype", "Sales Order");
|
frm.set_value("reference_doctype", "Sales Order");
|
||||||
} else if (frm.doc.bg_type == "Providing") {
|
} else if (frm.doc.bg_type == "Providing") {
|
||||||
@@ -41,33 +41,34 @@ frappe.ui.form.on("Bank Guarantee", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reference_docname: function (frm) {
|
reference_docname: function(frm) {
|
||||||
if (frm.doc.reference_docname && frm.doc.reference_doctype) {
|
if (frm.doc.reference_docname && frm.doc.reference_doctype) {
|
||||||
let party_field = frm.doc.reference_doctype == "Sales Order" ? "customer" : "supplier";
|
let party_field = frm.doc.reference_doctype == "Sales Order" ? "customer" : "supplier";
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.bank_guarantee.bank_guarantee.get_voucher_details",
|
method: "erpnext.accounts.doctype.bank_guarantee.bank_guarantee.get_voucher_details",
|
||||||
args: {
|
args: {
|
||||||
bank_guarantee_type: frm.doc.bg_type,
|
"bank_guarantee_type": frm.doc.bg_type,
|
||||||
reference_name: frm.doc.reference_docname,
|
"reference_name": frm.doc.reference_docname
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
if (r.message[party_field]) frm.set_value(party_field, r.message[party_field]);
|
if (r.message[party_field]) frm.set_value(party_field, r.message[party_field]);
|
||||||
if (r.message.project) frm.set_value("project", r.message.project);
|
if (r.message.project) frm.set_value("project", r.message.project);
|
||||||
if (r.message.grand_total) frm.set_value("amount", r.message.grand_total);
|
if (r.message.grand_total) frm.set_value("amount", r.message.grand_total);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
start_date: function (frm) {
|
start_date: function(frm) {
|
||||||
var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1);
|
var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1);
|
||||||
cur_frm.set_value("end_date", end_date);
|
cur_frm.set_value("end_date", end_date);
|
||||||
},
|
},
|
||||||
validity: function (frm) {
|
validity: function(frm) {
|
||||||
var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1);
|
var end_date = frappe.datetime.add_days(cur_frm.doc.start_date, cur_frm.doc.validity - 1);
|
||||||
cur_frm.set_value("end_date", end_date);
|
cur_frm.set_value("end_date", end_date);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,40 +8,6 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankGuarantee(Document):
|
class BankGuarantee(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account: DF.Link | None
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
amount: DF.Currency
|
|
||||||
bank: DF.Link | None
|
|
||||||
bank_account: DF.Link | None
|
|
||||||
bank_account_no: DF.Data | None
|
|
||||||
bank_guarantee_number: DF.Data | None
|
|
||||||
bg_type: DF.Literal["", "Receiving", "Providing"]
|
|
||||||
branch_code: DF.Data | None
|
|
||||||
charges: DF.Currency
|
|
||||||
customer: DF.Link | None
|
|
||||||
end_date: DF.Date | None
|
|
||||||
fixed_deposit_number: DF.Data | None
|
|
||||||
iban: DF.Data | None
|
|
||||||
margin_money: DF.Currency
|
|
||||||
more_information: DF.TextEditor | None
|
|
||||||
name_of_beneficiary: DF.Data | None
|
|
||||||
project: DF.Link | None
|
|
||||||
reference_docname: DF.DynamicLink | None
|
|
||||||
reference_doctype: DF.Link | None
|
|
||||||
start_date: DF.Date
|
|
||||||
supplier: DF.Link | None
|
|
||||||
swift_number: DF.Data | None
|
|
||||||
validity: DF.Int
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not (self.customer or self.supplier):
|
if not (self.customer or self.supplier):
|
||||||
frappe.throw(_("Select the customer or supplier."))
|
frappe.throw(_("Select the customer or supplier."))
|
||||||
|
|||||||
@@ -8,22 +8,21 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
is_company_account: 1,
|
'is_company_account': 1
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
let no_bank_transactions_text = `<div class="text-muted text-center">${__(
|
let no_bank_transactions_text =
|
||||||
"No Matching Bank Transactions Found"
|
`<div class="text-muted text-center">${__("No Matching Bank Transactions Found")}</div>`
|
||||||
)}</div>`;
|
|
||||||
set_field_options("no_bank_transactions", no_bank_transactions_text);
|
set_field_options("no_bank_transactions", no_bank_transactions_text);
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
// Set default filter dates
|
// Set default filter dates
|
||||||
let today = frappe.datetime.get_today();
|
let today = frappe.datetime.get_today()
|
||||||
frm.doc.bank_statement_from_date = frappe.datetime.add_months(today, -1);
|
frm.doc.bank_statement_from_date = frappe.datetime.add_months(today, -1);
|
||||||
frm.doc.bank_statement_to_date = today;
|
frm.doc.bank_statement_to_date = today;
|
||||||
frm.trigger("bank_account");
|
frm.trigger('bank_account');
|
||||||
},
|
},
|
||||||
|
|
||||||
filter_by_reference_date: function (frm) {
|
filter_by_reference_date: function (frm) {
|
||||||
@@ -38,27 +37,34 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
frappe.require("bank-reconciliation-tool.bundle.js", () => frm.trigger("make_reconciliation_tool"));
|
frappe.require("bank-reconciliation-tool.bundle.js", () =>
|
||||||
|
frm.trigger("make_reconciliation_tool")
|
||||||
frm.add_custom_button(__("Upload Bank Statement"), () =>
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.accounts.doctype.bank_statement_import.bank_statement_import.upload_bank_statement",
|
|
||||||
args: {
|
|
||||||
dt: frm.doc.doctype,
|
|
||||||
dn: frm.doc.name,
|
|
||||||
company: frm.doc.company,
|
|
||||||
bank_account: frm.doc.bank_account,
|
|
||||||
},
|
|
||||||
callback: function (r) {
|
|
||||||
if (!r.exc) {
|
|
||||||
var doc = frappe.model.sync(r.message);
|
|
||||||
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
frm.add_custom_button(__("Auto Reconcile"), function () {
|
frm.add_custom_button(__("Upload Bank Statement"), () =>
|
||||||
|
frappe.call({
|
||||||
|
method:
|
||||||
|
"erpnext.accounts.doctype.bank_statement_import.bank_statement_import.upload_bank_statement",
|
||||||
|
args: {
|
||||||
|
dt: frm.doc.doctype,
|
||||||
|
dn: frm.doc.name,
|
||||||
|
company: frm.doc.company,
|
||||||
|
bank_account: frm.doc.bank_account,
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
if (!r.exc) {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route(
|
||||||
|
"Form",
|
||||||
|
doc[0].doctype,
|
||||||
|
doc[0].name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
frm.add_custom_button(__('Auto Reconcile'), function() {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.auto_reconcile_vouchers",
|
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.auto_reconcile_vouchers",
|
||||||
args: {
|
args: {
|
||||||
@@ -69,22 +75,33 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
from_reference_date: frm.doc.from_reference_date,
|
from_reference_date: frm.doc.from_reference_date,
|
||||||
to_reference_date: frm.doc.to_reference_date,
|
to_reference_date: frm.doc.to_reference_date,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.add_custom_button(__("Get Unreconciled Entries"), function () {
|
frm.add_custom_button(__('Get Unreconciled Entries'), function() {
|
||||||
frm.trigger("make_reconciliation_tool");
|
frm.trigger("make_reconciliation_tool");
|
||||||
});
|
});
|
||||||
frm.change_custom_button_type(__("Get Unreconciled Entries"), null, "primary");
|
frm.change_custom_button_type(__('Get Unreconciled Entries'), null, 'primary');
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
bank_account: function (frm) {
|
bank_account: function (frm) {
|
||||||
frappe.db.get_value("Bank Account", frm.doc.bank_account, "account", (r) => {
|
frappe.db.get_value(
|
||||||
frappe.db.get_value("Account", r.account, "account_currency", (r) => {
|
"Bank Account",
|
||||||
frm.doc.account_currency = r.account_currency;
|
frm.doc.bank_account,
|
||||||
frm.trigger("render_chart");
|
"account",
|
||||||
});
|
(r) => {
|
||||||
});
|
frappe.db.get_value(
|
||||||
|
"Account",
|
||||||
|
r.account,
|
||||||
|
"account_currency",
|
||||||
|
(r) => {
|
||||||
|
frm.doc.account_currency = r.account_currency;
|
||||||
|
frm.trigger("render_chart");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
frm.trigger("get_account_opening_balance");
|
frm.trigger("get_account_opening_balance");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -103,7 +120,11 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
) {
|
) {
|
||||||
frm.trigger("render_chart");
|
frm.trigger("render_chart");
|
||||||
frm.trigger("render");
|
frm.trigger("render");
|
||||||
frappe.utils.scroll_to(frm.get_field("reconciliation_tool_cards").$wrapper, true, 30);
|
frappe.utils.scroll_to(
|
||||||
|
frm.get_field("reconciliation_tool_cards").$wrapper,
|
||||||
|
true,
|
||||||
|
30
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,10 +133,11 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
get_account_opening_balance(frm) {
|
get_account_opening_balance(frm) {
|
||||||
if (frm.doc.bank_account && frm.doc.bank_statement_from_date) {
|
if (frm.doc.bank_account && frm.doc.bank_statement_from_date) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_account_balance",
|
method:
|
||||||
|
"erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_account_balance",
|
||||||
args: {
|
args: {
|
||||||
bank_account: frm.doc.bank_account,
|
bank_account: frm.doc.bank_account,
|
||||||
till_date: frappe.datetime.add_days(frm.doc.bank_statement_from_date, -1),
|
till_date: frm.doc.bank_statement_from_date,
|
||||||
},
|
},
|
||||||
callback: (response) => {
|
callback: (response) => {
|
||||||
frm.set_value("account_opening_balance", response.message);
|
frm.set_value("account_opening_balance", response.message);
|
||||||
@@ -127,7 +149,8 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
get_cleared_balance(frm) {
|
get_cleared_balance(frm) {
|
||||||
if (frm.doc.bank_account && frm.doc.bank_statement_to_date) {
|
if (frm.doc.bank_account && frm.doc.bank_statement_to_date) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_account_balance",
|
method:
|
||||||
|
"erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_account_balance",
|
||||||
args: {
|
args: {
|
||||||
bank_account: frm.doc.bank_account,
|
bank_account: frm.doc.bank_account,
|
||||||
till_date: frm.doc.bank_statement_to_date,
|
till_date: frm.doc.bank_statement_to_date,
|
||||||
@@ -140,30 +163,41 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
render_chart(frm) {
|
render_chart(frm) {
|
||||||
frm.cards_manager = new erpnext.accounts.bank_reconciliation.NumberCardManager({
|
frm.cards_manager = new erpnext.accounts.bank_reconciliation.NumberCardManager(
|
||||||
$reconciliation_tool_cards: frm.get_field("reconciliation_tool_cards").$wrapper,
|
{
|
||||||
bank_statement_closing_balance: frm.doc.bank_statement_closing_balance,
|
$reconciliation_tool_cards: frm.get_field(
|
||||||
cleared_balance: frm.cleared_balance,
|
"reconciliation_tool_cards"
|
||||||
currency: frm.doc.account_currency,
|
).$wrapper,
|
||||||
});
|
bank_statement_closing_balance:
|
||||||
|
frm.doc.bank_statement_closing_balance,
|
||||||
|
cleared_balance: frm.cleared_balance,
|
||||||
|
currency: frm.doc.account_currency,
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
render(frm) {
|
render(frm) {
|
||||||
if (frm.doc.bank_account) {
|
if (frm.doc.bank_account) {
|
||||||
frm.bank_reconciliation_data_table_manager =
|
frm.bank_reconciliation_data_table_manager = new erpnext.accounts.bank_reconciliation.DataTableManager(
|
||||||
new erpnext.accounts.bank_reconciliation.DataTableManager({
|
{
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
bank_account: frm.doc.bank_account,
|
bank_account: frm.doc.bank_account,
|
||||||
$reconciliation_tool_dt: frm.get_field("reconciliation_tool_dt").$wrapper,
|
$reconciliation_tool_dt: frm.get_field(
|
||||||
$no_bank_transactions: frm.get_field("no_bank_transactions").$wrapper,
|
"reconciliation_tool_dt"
|
||||||
|
).$wrapper,
|
||||||
|
$no_bank_transactions: frm.get_field(
|
||||||
|
"no_bank_transactions"
|
||||||
|
).$wrapper,
|
||||||
bank_statement_from_date: frm.doc.bank_statement_from_date,
|
bank_statement_from_date: frm.doc.bank_statement_from_date,
|
||||||
bank_statement_to_date: frm.doc.bank_statement_to_date,
|
bank_statement_to_date: frm.doc.bank_statement_to_date,
|
||||||
filter_by_reference_date: frm.doc.filter_by_reference_date,
|
filter_by_reference_date: frm.doc.filter_by_reference_date,
|
||||||
from_reference_date: frm.doc.from_reference_date,
|
from_reference_date: frm.doc.from_reference_date,
|
||||||
to_reference_date: frm.doc.to_reference_date,
|
to_reference_date: frm.doc.to_reference_date,
|
||||||
bank_statement_closing_balance: frm.doc.bank_statement_closing_balance,
|
bank_statement_closing_balance:
|
||||||
|
frm.doc.bank_statement_closing_balance,
|
||||||
cards_manager: frm.cards_manager,
|
cards_manager: frm.cards_manager,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from frappe import _
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.query_builder.custom import ConstantColumn
|
from frappe.query_builder.custom import ConstantColumn
|
||||||
from frappe.utils import cint, flt
|
from frappe.utils import cint, flt
|
||||||
|
from pypika.terms import Parameter
|
||||||
|
|
||||||
from erpnext import get_default_cost_center
|
from erpnext import get_default_cost_center
|
||||||
from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount
|
from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_total_allocated_amount
|
||||||
@@ -17,30 +18,9 @@ from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_s
|
|||||||
get_entries,
|
get_entries,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.utils import get_account_currency, get_balance_on
|
from erpnext.accounts.utils import get_account_currency, get_balance_on
|
||||||
from erpnext.setup.utils import get_exchange_rate
|
|
||||||
|
|
||||||
|
|
||||||
class BankReconciliationTool(Document):
|
class BankReconciliationTool(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account_currency: DF.Link | None
|
|
||||||
account_opening_balance: DF.Currency
|
|
||||||
bank_account: DF.Link | None
|
|
||||||
bank_statement_closing_balance: DF.Currency
|
|
||||||
bank_statement_from_date: DF.Date | None
|
|
||||||
bank_statement_to_date: DF.Date | None
|
|
||||||
company: DF.Link | None
|
|
||||||
filter_by_reference_date: DF.Check
|
|
||||||
from_reference_date: DF.Date | None
|
|
||||||
to_reference_date: DF.Date | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -150,7 +130,7 @@ def create_journal_entry_bts(
|
|||||||
bank_transaction = frappe.db.get_values(
|
bank_transaction = frappe.db.get_values(
|
||||||
"Bank Transaction",
|
"Bank Transaction",
|
||||||
bank_transaction_name,
|
bank_transaction_name,
|
||||||
fieldname=["name", "deposit", "withdrawal", "bank_account", "currency"],
|
fieldname=["name", "deposit", "withdrawal", "bank_account"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)[0]
|
)[0]
|
||||||
company_account = frappe.get_value("Bank Account", bank_transaction.bank_account, "account")
|
company_account = frappe.get_value("Bank Account", bank_transaction.bank_account, "account")
|
||||||
@@ -164,94 +144,29 @@ def create_journal_entry_bts(
|
|||||||
)
|
)
|
||||||
|
|
||||||
company = frappe.get_value("Account", company_account, "company")
|
company = frappe.get_value("Account", company_account, "company")
|
||||||
company_default_currency = frappe.get_cached_value("Company", company, "default_currency")
|
|
||||||
company_account_currency = frappe.get_cached_value("Account", company_account, "account_currency")
|
|
||||||
second_account_currency = frappe.get_cached_value("Account", second_account, "account_currency")
|
|
||||||
|
|
||||||
# determine if multi-currency Journal or not
|
|
||||||
is_multi_currency = (
|
|
||||||
True
|
|
||||||
if company_default_currency != company_account_currency
|
|
||||||
or company_default_currency != second_account_currency
|
|
||||||
or company_default_currency != bank_transaction.currency
|
|
||||||
else False
|
|
||||||
)
|
|
||||||
|
|
||||||
accounts = []
|
accounts = []
|
||||||
second_account_dict = {
|
# Multi Currency?
|
||||||
"account": second_account,
|
accounts.append(
|
||||||
"account_currency": second_account_currency,
|
{
|
||||||
"credit_in_account_currency": bank_transaction.deposit,
|
"account": second_account,
|
||||||
"debit_in_account_currency": bank_transaction.withdrawal,
|
"credit_in_account_currency": bank_transaction.deposit,
|
||||||
"party_type": party_type,
|
"debit_in_account_currency": bank_transaction.withdrawal,
|
||||||
"party": party,
|
"party_type": party_type,
|
||||||
"cost_center": get_default_cost_center(company),
|
"party": party,
|
||||||
}
|
"cost_center": get_default_cost_center(company),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
company_account_dict = {
|
accounts.append(
|
||||||
"account": company_account,
|
{
|
||||||
"account_currency": company_account_currency,
|
"account": company_account,
|
||||||
"bank_account": bank_transaction.bank_account,
|
"bank_account": bank_transaction.bank_account,
|
||||||
"credit_in_account_currency": bank_transaction.withdrawal,
|
"credit_in_account_currency": bank_transaction.withdrawal,
|
||||||
"debit_in_account_currency": bank_transaction.deposit,
|
"debit_in_account_currency": bank_transaction.deposit,
|
||||||
"cost_center": get_default_cost_center(company),
|
"cost_center": get_default_cost_center(company),
|
||||||
}
|
}
|
||||||
|
)
|
||||||
# convert transaction amount to company currency
|
|
||||||
if is_multi_currency:
|
|
||||||
exc_rate = get_exchange_rate(bank_transaction.currency, company_default_currency, posting_date)
|
|
||||||
withdrawal_in_company_currency = flt(exc_rate * abs(bank_transaction.withdrawal))
|
|
||||||
deposit_in_company_currency = flt(exc_rate * abs(bank_transaction.deposit))
|
|
||||||
else:
|
|
||||||
withdrawal_in_company_currency = bank_transaction.withdrawal
|
|
||||||
deposit_in_company_currency = bank_transaction.deposit
|
|
||||||
|
|
||||||
# if second account is of foreign currency, convert and set debit and credit fields.
|
|
||||||
if second_account_currency != company_default_currency:
|
|
||||||
exc_rate = get_exchange_rate(second_account_currency, company_default_currency, posting_date)
|
|
||||||
second_account_dict.update(
|
|
||||||
{
|
|
||||||
"exchange_rate": exc_rate,
|
|
||||||
"credit": deposit_in_company_currency,
|
|
||||||
"debit": withdrawal_in_company_currency,
|
|
||||||
"credit_in_account_currency": flt(deposit_in_company_currency / exc_rate) or 0,
|
|
||||||
"debit_in_account_currency": flt(withdrawal_in_company_currency / exc_rate) or 0,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
second_account_dict.update(
|
|
||||||
{
|
|
||||||
"exchange_rate": 1,
|
|
||||||
"credit": deposit_in_company_currency,
|
|
||||||
"debit": withdrawal_in_company_currency,
|
|
||||||
"credit_in_account_currency": deposit_in_company_currency,
|
|
||||||
"debit_in_account_currency": withdrawal_in_company_currency,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# if company account is of foreign currency, convert and set debit and credit fields.
|
|
||||||
if company_account_currency != company_default_currency:
|
|
||||||
exc_rate = get_exchange_rate(company_account_currency, company_default_currency, posting_date)
|
|
||||||
company_account_dict.update(
|
|
||||||
{
|
|
||||||
"exchange_rate": exc_rate,
|
|
||||||
"credit": withdrawal_in_company_currency,
|
|
||||||
"debit": deposit_in_company_currency,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
company_account_dict.update(
|
|
||||||
{
|
|
||||||
"exchange_rate": 1,
|
|
||||||
"credit": withdrawal_in_company_currency,
|
|
||||||
"debit": deposit_in_company_currency,
|
|
||||||
"credit_in_account_currency": withdrawal_in_company_currency,
|
|
||||||
"debit_in_account_currency": deposit_in_company_currency,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
accounts.append(second_account_dict)
|
|
||||||
accounts.append(company_account_dict)
|
|
||||||
|
|
||||||
journal_entry_dict = {
|
journal_entry_dict = {
|
||||||
"voucher_type": entry_type,
|
"voucher_type": entry_type,
|
||||||
@@ -261,9 +176,6 @@ def create_journal_entry_bts(
|
|||||||
"cheque_no": reference_number,
|
"cheque_no": reference_number,
|
||||||
"mode_of_payment": mode_of_payment,
|
"mode_of_payment": mode_of_payment,
|
||||||
}
|
}
|
||||||
if is_multi_currency:
|
|
||||||
journal_entry_dict.update({"multi_currency": True})
|
|
||||||
|
|
||||||
journal_entry = frappe.new_doc("Journal Entry")
|
journal_entry = frappe.new_doc("Journal Entry")
|
||||||
journal_entry.update(journal_entry_dict)
|
journal_entry.update(journal_entry_dict)
|
||||||
journal_entry.set("accounts", accounts)
|
journal_entry.set("accounts", accounts)
|
||||||
@@ -443,13 +355,7 @@ def reconcile_vouchers(bank_transaction_name, vouchers):
|
|||||||
vouchers = json.loads(vouchers)
|
vouchers = json.loads(vouchers)
|
||||||
transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
|
transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
|
||||||
transaction.add_payment_entries(vouchers)
|
transaction.add_payment_entries(vouchers)
|
||||||
transaction.validate_duplicate_references()
|
return frappe.get_doc("Bank Transaction", bank_transaction_name)
|
||||||
transaction.allocate_payment_entries()
|
|
||||||
transaction.update_allocated_amount()
|
|
||||||
transaction.set_status()
|
|
||||||
transaction.save()
|
|
||||||
|
|
||||||
return transaction
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -508,18 +414,6 @@ def check_matching(
|
|||||||
to_reference_date,
|
to_reference_date,
|
||||||
):
|
):
|
||||||
exact_match = True if "exact_match" in document_types else False
|
exact_match = True if "exact_match" in document_types else False
|
||||||
|
|
||||||
common_filters = frappe._dict(
|
|
||||||
{
|
|
||||||
"amount": transaction.unallocated_amount,
|
|
||||||
"payment_type": "Receive" if transaction.deposit > 0.0 else "Pay",
|
|
||||||
"reference_no": transaction.reference_number,
|
|
||||||
"party_type": transaction.party_type,
|
|
||||||
"party": transaction.party,
|
|
||||||
"bank_account": bank_account,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
queries = get_queries(
|
queries = get_queries(
|
||||||
bank_account,
|
bank_account,
|
||||||
company,
|
company,
|
||||||
@@ -531,12 +425,20 @@ def check_matching(
|
|||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
exact_match,
|
exact_match,
|
||||||
common_filters,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"amount": transaction.unallocated_amount,
|
||||||
|
"payment_type": "Receive" if transaction.deposit > 0.0 else "Pay",
|
||||||
|
"reference_no": transaction.reference_number,
|
||||||
|
"party_type": transaction.party_type,
|
||||||
|
"party": transaction.party,
|
||||||
|
"bank_account": bank_account,
|
||||||
|
}
|
||||||
|
|
||||||
matching_vouchers = []
|
matching_vouchers = []
|
||||||
for query in queries:
|
for query in queries:
|
||||||
matching_vouchers.extend(query.run(as_dict=True))
|
matching_vouchers.extend(frappe.db.sql(query, filters, as_dict=True))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
sorted(matching_vouchers, key=lambda x: x["rank"], reverse=True) if matching_vouchers else []
|
sorted(matching_vouchers, key=lambda x: x["rank"], reverse=True) if matching_vouchers else []
|
||||||
@@ -554,7 +456,6 @@ def get_queries(
|
|||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
exact_match,
|
exact_match,
|
||||||
common_filters,
|
|
||||||
):
|
):
|
||||||
# get queries to get matching vouchers
|
# get queries to get matching vouchers
|
||||||
account_from_to = "paid_to" if transaction.deposit > 0.0 else "paid_from"
|
account_from_to = "paid_to" if transaction.deposit > 0.0 else "paid_from"
|
||||||
@@ -575,7 +476,6 @@ def get_queries(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
)
|
)
|
||||||
or []
|
or []
|
||||||
)
|
)
|
||||||
@@ -595,7 +495,6 @@ def get_matching_queries(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
):
|
):
|
||||||
queries = []
|
queries = []
|
||||||
currency = get_account_currency(bank_account)
|
currency = get_account_currency(bank_account)
|
||||||
@@ -610,7 +509,6 @@ def get_matching_queries(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
)
|
)
|
||||||
queries.append(query)
|
queries.append(query)
|
||||||
|
|
||||||
@@ -623,17 +521,16 @@ def get_matching_queries(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
)
|
)
|
||||||
queries.append(query)
|
queries.append(query)
|
||||||
|
|
||||||
if transaction.deposit > 0.0 and "sales_invoice" in document_types:
|
if transaction.deposit > 0.0 and "sales_invoice" in document_types:
|
||||||
query = get_si_matching_query(exact_match, currency, common_filters)
|
query = get_si_matching_query(exact_match, currency)
|
||||||
queries.append(query)
|
queries.append(query)
|
||||||
|
|
||||||
if transaction.withdrawal > 0.0:
|
if transaction.withdrawal > 0.0:
|
||||||
if "purchase_invoice" in document_types:
|
if "purchase_invoice" in document_types:
|
||||||
query = get_pi_matching_query(exact_match, currency, common_filters)
|
query = get_pi_matching_query(exact_match, currency)
|
||||||
queries.append(query)
|
queries.append(query)
|
||||||
|
|
||||||
if "bank_transaction" in document_types:
|
if "bank_transaction" in document_types:
|
||||||
@@ -688,7 +585,7 @@ def get_bt_matching_query(exact_match, transaction):
|
|||||||
.where(amount_condition)
|
.where(amount_condition)
|
||||||
.where(bt.docstatus == 1)
|
.where(bt.docstatus == 1)
|
||||||
)
|
)
|
||||||
return query
|
return str(query)
|
||||||
|
|
||||||
|
|
||||||
def get_pe_matching_query(
|
def get_pe_matching_query(
|
||||||
@@ -700,7 +597,6 @@ def get_pe_matching_query(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
):
|
):
|
||||||
# get matching payment entries query
|
# get matching payment entries query
|
||||||
to_from = "to" if transaction.deposit > 0.0 else "from"
|
to_from = "to" if transaction.deposit > 0.0 else "from"
|
||||||
@@ -743,7 +639,7 @@ def get_pe_matching_query(
|
|||||||
.where(pe.docstatus == 1)
|
.where(pe.docstatus == 1)
|
||||||
.where(pe.payment_type.isin([payment_type, "Internal Transfer"]))
|
.where(pe.payment_type.isin([payment_type, "Internal Transfer"]))
|
||||||
.where(pe.clearance_date.isnull())
|
.where(pe.clearance_date.isnull())
|
||||||
.where(getattr(pe, account_from_to) == common_filters.bank_account)
|
.where(getattr(pe, account_from_to) == Parameter("%(bank_account)s"))
|
||||||
.where(amount_condition)
|
.where(amount_condition)
|
||||||
.where(filter_by_date)
|
.where(filter_by_date)
|
||||||
.orderby(pe.reference_date if cint(filter_by_reference_date) else pe.posting_date)
|
.orderby(pe.reference_date if cint(filter_by_reference_date) else pe.posting_date)
|
||||||
@@ -752,7 +648,7 @@ def get_pe_matching_query(
|
|||||||
if frappe.flags.auto_reconcile_vouchers == True:
|
if frappe.flags.auto_reconcile_vouchers == True:
|
||||||
query = query.where(ref_condition)
|
query = query.where(ref_condition)
|
||||||
|
|
||||||
return query
|
return str(query)
|
||||||
|
|
||||||
|
|
||||||
def get_je_matching_query(
|
def get_je_matching_query(
|
||||||
@@ -763,7 +659,6 @@ def get_je_matching_query(
|
|||||||
filter_by_reference_date,
|
filter_by_reference_date,
|
||||||
from_reference_date,
|
from_reference_date,
|
||||||
to_reference_date,
|
to_reference_date,
|
||||||
common_filters,
|
|
||||||
):
|
):
|
||||||
# get matching journal entry query
|
# get matching journal entry query
|
||||||
# We have mapping at the bank level
|
# We have mapping at the bank level
|
||||||
@@ -803,7 +698,7 @@ def get_je_matching_query(
|
|||||||
.where(je.docstatus == 1)
|
.where(je.docstatus == 1)
|
||||||
.where(je.voucher_type != "Opening Entry")
|
.where(je.voucher_type != "Opening Entry")
|
||||||
.where(je.clearance_date.isnull())
|
.where(je.clearance_date.isnull())
|
||||||
.where(jea.account == common_filters.bank_account)
|
.where(jea.account == Parameter("%(bank_account)s"))
|
||||||
.where(amount_equality if exact_match else getattr(jea, amount_field) > 0.0)
|
.where(amount_equality if exact_match else getattr(jea, amount_field) > 0.0)
|
||||||
.where(je.docstatus == 1)
|
.where(je.docstatus == 1)
|
||||||
.where(filter_by_date)
|
.where(filter_by_date)
|
||||||
@@ -813,19 +708,19 @@ def get_je_matching_query(
|
|||||||
if frappe.flags.auto_reconcile_vouchers == True:
|
if frappe.flags.auto_reconcile_vouchers == True:
|
||||||
query = query.where(ref_condition)
|
query = query.where(ref_condition)
|
||||||
|
|
||||||
return query
|
return str(query)
|
||||||
|
|
||||||
|
|
||||||
def get_si_matching_query(exact_match, currency, common_filters):
|
def get_si_matching_query(exact_match, currency):
|
||||||
# get matching sales invoice query
|
# get matching sales invoice query
|
||||||
si = frappe.qb.DocType("Sales Invoice")
|
si = frappe.qb.DocType("Sales Invoice")
|
||||||
sip = frappe.qb.DocType("Sales Invoice Payment")
|
sip = frappe.qb.DocType("Sales Invoice Payment")
|
||||||
|
|
||||||
amount_equality = sip.amount == common_filters.amount
|
amount_equality = sip.amount == Parameter("%(amount)s")
|
||||||
amount_rank = frappe.qb.terms.Case().when(amount_equality, 1).else_(0)
|
amount_rank = frappe.qb.terms.Case().when(amount_equality, 1).else_(0)
|
||||||
amount_condition = amount_equality if exact_match else sip.amount > 0.0
|
amount_condition = amount_equality if exact_match else sip.amount > 0.0
|
||||||
|
|
||||||
party_condition = si.customer == common_filters.party
|
party_condition = si.customer == Parameter("%(party)s")
|
||||||
party_rank = frappe.qb.terms.Case().when(party_condition, 1).else_(0)
|
party_rank = frappe.qb.terms.Case().when(party_condition, 1).else_(0)
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
@@ -846,23 +741,23 @@ def get_si_matching_query(exact_match, currency, common_filters):
|
|||||||
)
|
)
|
||||||
.where(si.docstatus == 1)
|
.where(si.docstatus == 1)
|
||||||
.where(sip.clearance_date.isnull())
|
.where(sip.clearance_date.isnull())
|
||||||
.where(sip.account == common_filters.bank_account)
|
.where(sip.account == Parameter("%(bank_account)s"))
|
||||||
.where(amount_condition)
|
.where(amount_condition)
|
||||||
.where(si.currency == currency)
|
.where(si.currency == currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
return query
|
return str(query)
|
||||||
|
|
||||||
|
|
||||||
def get_pi_matching_query(exact_match, currency, common_filters):
|
def get_pi_matching_query(exact_match, currency):
|
||||||
# get matching purchase invoice query when they are also used as payment entries (is_paid)
|
# get matching purchase invoice query when they are also used as payment entries (is_paid)
|
||||||
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
|
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
|
||||||
|
|
||||||
amount_equality = purchase_invoice.paid_amount == common_filters.amount
|
amount_equality = purchase_invoice.paid_amount == Parameter("%(amount)s")
|
||||||
amount_rank = frappe.qb.terms.Case().when(amount_equality, 1).else_(0)
|
amount_rank = frappe.qb.terms.Case().when(amount_equality, 1).else_(0)
|
||||||
amount_condition = amount_equality if exact_match else purchase_invoice.paid_amount > 0.0
|
amount_condition = amount_equality if exact_match else purchase_invoice.paid_amount > 0.0
|
||||||
|
|
||||||
party_condition = purchase_invoice.supplier == common_filters.party
|
party_condition = purchase_invoice.supplier == Parameter("%(party)s")
|
||||||
party_rank = frappe.qb.terms.Case().when(party_condition, 1).else_(0)
|
party_rank = frappe.qb.terms.Case().when(party_condition, 1).else_(0)
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
@@ -882,9 +777,9 @@ def get_pi_matching_query(exact_match, currency, common_filters):
|
|||||||
.where(purchase_invoice.docstatus == 1)
|
.where(purchase_invoice.docstatus == 1)
|
||||||
.where(purchase_invoice.is_paid == 1)
|
.where(purchase_invoice.is_paid == 1)
|
||||||
.where(purchase_invoice.clearance_date.isnull())
|
.where(purchase_invoice.clearance_date.isnull())
|
||||||
.where(purchase_invoice.cash_bank_account == common_filters.bank_account)
|
.where(purchase_invoice.cash_bank_account == Parameter("%(bank_account)s"))
|
||||||
.where(amount_condition)
|
.where(amount_condition)
|
||||||
.where(purchase_invoice.currency == currency)
|
.where(purchase_invoice.currency == currency)
|
||||||
)
|
)
|
||||||
|
|
||||||
return query
|
return str(query)
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ class TestBankReconciliationTool(AccountsTestMixin, FrappeTestCase):
|
|||||||
"deposit": 100,
|
"deposit": 100,
|
||||||
"bank_account": self.bank_account,
|
"bank_account": self.bank_account,
|
||||||
"reference_number": "123",
|
"reference_number": "123",
|
||||||
"currency": "INR",
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.save()
|
.save()
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
frm.import_in_progress = false;
|
frm.import_in_progress = false;
|
||||||
if (data_import !== frm.doc.name) return;
|
if (data_import !== frm.doc.name) return;
|
||||||
frappe.model.clear_doc("Bank Statement Import", frm.doc.name);
|
frappe.model.clear_doc("Bank Statement Import", frm.doc.name);
|
||||||
frappe.model.with_doc("Bank Statement Import", frm.doc.name).then(() => {
|
frappe.model
|
||||||
frm.refresh();
|
.with_doc("Bank Statement Import", frm.doc.name)
|
||||||
});
|
.then(() => {
|
||||||
|
frm.refresh();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
frappe.realtime.on("data_import_progress", (data) => {
|
frappe.realtime.on("data_import_progress", (data) => {
|
||||||
frm.import_in_progress = true;
|
frm.import_in_progress = true;
|
||||||
@@ -36,9 +38,20 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
: __("Updating {0} of {1}, {2}", message_args);
|
: __("Updating {0} of {1}, {2}", message_args);
|
||||||
}
|
}
|
||||||
if (data.skipping) {
|
if (data.skipping) {
|
||||||
message = __("Skipping {0} of {1}, {2}", [data.current, data.total, eta_message]);
|
message = __(
|
||||||
|
"Skipping {0} of {1}, {2}",
|
||||||
|
[
|
||||||
|
data.current,
|
||||||
|
data.total,
|
||||||
|
eta_message,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
frm.dashboard.show_progress(__("Import Progress"), percent, message);
|
frm.dashboard.show_progress(
|
||||||
|
__("Import Progress"),
|
||||||
|
percent,
|
||||||
|
message
|
||||||
|
);
|
||||||
frm.page.set_indicator(__("In Progress"), "orange");
|
frm.page.set_indicator(__("In Progress"), "orange");
|
||||||
|
|
||||||
// hide progress when complete
|
// hide progress when complete
|
||||||
@@ -80,12 +93,15 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
frm.trigger("show_report_error_button");
|
frm.trigger("show_report_error_button");
|
||||||
|
|
||||||
if (frm.doc.status === "Partial Success") {
|
if (frm.doc.status === "Partial Success") {
|
||||||
frm.add_custom_button(__("Export Errored Rows"), () => frm.trigger("export_errored_rows"));
|
frm.add_custom_button(__("Export Errored Rows"), () =>
|
||||||
|
frm.trigger("export_errored_rows")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.status.includes("Success")) {
|
if (frm.doc.status.includes("Success")) {
|
||||||
frm.add_custom_button(__("Go to {0} List", [__(frm.doc.reference_doctype)]), () =>
|
frm.add_custom_button(
|
||||||
frappe.set_route("List", frm.doc.reference_doctype)
|
__("Go to {0} List", [__(frm.doc.reference_doctype)]),
|
||||||
|
() => frappe.set_route("List", frm.doc.reference_doctype)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -102,8 +118,13 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
if (frm.doc.status !== "Success") {
|
if (frm.doc.status !== "Success") {
|
||||||
if (!frm.is_new() && frm.has_import_file()) {
|
if (!frm.is_new() && frm.has_import_file()) {
|
||||||
let label = frm.doc.status === "Pending" ? __("Start Import") : __("Retry");
|
let label =
|
||||||
frm.page.set_primary_action(label, () => frm.events.start_import(frm));
|
frm.doc.status === "Pending"
|
||||||
|
? __("Start Import")
|
||||||
|
: __("Retry");
|
||||||
|
frm.page.set_primary_action(label, () =>
|
||||||
|
frm.events.start_import(frm)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
frm.page.set_primary_action(__("Save"), () => frm.save());
|
frm.page.set_primary_action(__("Save"), () => frm.save());
|
||||||
}
|
}
|
||||||
@@ -145,24 +166,24 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
message =
|
message =
|
||||||
successful_records.length > 1
|
successful_records.length > 1
|
||||||
? __(
|
? __(
|
||||||
"Successfully imported {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully imported {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
)
|
)
|
||||||
: __(
|
: __(
|
||||||
"Successfully imported {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully imported {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
message =
|
message =
|
||||||
successful_records.length > 1
|
successful_records.length > 1
|
||||||
? __(
|
? __(
|
||||||
"Successfully updated {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully updated {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
)
|
)
|
||||||
: __(
|
: __(
|
||||||
"Successfully updated {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully updated {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frm.dashboard.set_headline(message);
|
frm.dashboard.set_headline(message);
|
||||||
@@ -205,7 +226,8 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
download_template() {
|
download_template() {
|
||||||
let method = "/api/method/frappe.core.doctype.data_import.data_import.download_template";
|
let method =
|
||||||
|
"/api/method/frappe.core.doctype.data_import.data_import.download_template";
|
||||||
|
|
||||||
open_url_post(method, {
|
open_url_post(method, {
|
||||||
doctype: "Bank Transaction",
|
doctype: "Bank Transaction",
|
||||||
@@ -218,7 +240,7 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
"description",
|
"description",
|
||||||
"reference_number",
|
"reference_number",
|
||||||
"bank_account",
|
"bank_account",
|
||||||
"currency",
|
"currency"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -289,7 +311,10 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
show_import_preview(frm, preview_data) {
|
show_import_preview(frm, preview_data) {
|
||||||
let import_log = JSON.parse(frm.doc.statement_import_log || "[]");
|
let import_log = JSON.parse(frm.doc.statement_import_log || "[]");
|
||||||
|
|
||||||
if (frm.import_preview && frm.import_preview.doctype === frm.doc.reference_doctype) {
|
if (
|
||||||
|
frm.import_preview &&
|
||||||
|
frm.import_preview.doctype === frm.doc.reference_doctype
|
||||||
|
) {
|
||||||
frm.import_preview.preview_data = preview_data;
|
frm.import_preview.preview_data = preview_data;
|
||||||
frm.import_preview.import_log = import_log;
|
frm.import_preview.import_log = import_log;
|
||||||
frm.import_preview.refresh();
|
frm.import_preview.refresh();
|
||||||
@@ -305,10 +330,19 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
frm,
|
frm,
|
||||||
events: {
|
events: {
|
||||||
remap_column(changed_map) {
|
remap_column(changed_map) {
|
||||||
let template_options = JSON.parse(frm.doc.template_options || "{}");
|
let template_options = JSON.parse(
|
||||||
template_options.column_to_field_map = template_options.column_to_field_map || {};
|
frm.doc.template_options || "{}"
|
||||||
Object.assign(template_options.column_to_field_map, changed_map);
|
);
|
||||||
frm.set_value("template_options", JSON.stringify(template_options));
|
template_options.column_to_field_map =
|
||||||
|
template_options.column_to_field_map || {};
|
||||||
|
Object.assign(
|
||||||
|
template_options.column_to_field_map,
|
||||||
|
changed_map
|
||||||
|
);
|
||||||
|
frm.set_value(
|
||||||
|
"template_options",
|
||||||
|
JSON.stringify(template_options)
|
||||||
|
);
|
||||||
frm.save().then(() => frm.trigger("import_file"));
|
frm.save().then(() => frm.trigger("import_file"));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -342,7 +376,8 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
let other_warnings = [];
|
let other_warnings = [];
|
||||||
for (let warning of warnings) {
|
for (let warning of warnings) {
|
||||||
if (warning.row) {
|
if (warning.row) {
|
||||||
warnings_by_row[warning.row] = warnings_by_row[warning.row] || [];
|
warnings_by_row[warning.row] =
|
||||||
|
warnings_by_row[warning.row] || [];
|
||||||
warnings_by_row[warning.row].push(warning);
|
warnings_by_row[warning.row].push(warning);
|
||||||
} else {
|
} else {
|
||||||
other_warnings.push(warning);
|
other_warnings.push(warning);
|
||||||
@@ -357,7 +392,9 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
if (w.field) {
|
if (w.field) {
|
||||||
let label =
|
let label =
|
||||||
w.field.label +
|
w.field.label +
|
||||||
(w.field.parent !== frm.doc.reference_doctype ? ` (${w.field.parent})` : "");
|
(w.field.parent !== frm.doc.reference_doctype
|
||||||
|
? ` (${w.field.parent})`
|
||||||
|
: "");
|
||||||
return `<li>${label}: ${w.message}</li>`;
|
return `<li>${label}: ${w.message}</li>`;
|
||||||
}
|
}
|
||||||
return `<li>${w.message}</li>`;
|
return `<li>${w.message}</li>`;
|
||||||
@@ -376,9 +413,10 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
.map((warning) => {
|
.map((warning) => {
|
||||||
let header = "";
|
let header = "";
|
||||||
if (warning.col) {
|
if (warning.col) {
|
||||||
let column_number = `<span class="text-uppercase">${__("Column {0}", [
|
let column_number = `<span class="text-uppercase">${__(
|
||||||
warning.col,
|
"Column {0}",
|
||||||
])}</span>`;
|
[warning.col]
|
||||||
|
)}</span>`;
|
||||||
let column_header = columns[warning.col].header_title;
|
let column_header = columns[warning.col].header_title;
|
||||||
header = `${column_number} (${column_header})`;
|
header = `${column_number} (${column_header})`;
|
||||||
}
|
}
|
||||||
@@ -417,28 +455,36 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
let html = "";
|
let html = "";
|
||||||
if (log.success) {
|
if (log.success) {
|
||||||
if (frm.doc.import_type === "Insert New Records") {
|
if (frm.doc.import_type === "Insert New Records") {
|
||||||
html = __("Successfully imported {0}", [
|
html = __(
|
||||||
`<span class="underline">${frappe.utils.get_form_link(
|
"Successfully imported {0}", [
|
||||||
frm.doc.reference_doctype,
|
`<span class="underline">${frappe.utils.get_form_link(
|
||||||
log.docname,
|
frm.doc.reference_doctype,
|
||||||
true
|
log.docname,
|
||||||
)}<span>`,
|
true
|
||||||
]);
|
)}<span>`,
|
||||||
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
html = __("Successfully updated {0}", [
|
html = __(
|
||||||
`<span class="underline">${frappe.utils.get_form_link(
|
"Successfully updated {0}", [
|
||||||
frm.doc.reference_doctype,
|
`<span class="underline">${frappe.utils.get_form_link(
|
||||||
log.docname,
|
frm.doc.reference_doctype,
|
||||||
true
|
log.docname,
|
||||||
)}<span>`,
|
true
|
||||||
]);
|
)}<span>`,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let messages = log.messages
|
let messages = log.messages
|
||||||
.map(JSON.parse)
|
.map(JSON.parse)
|
||||||
.map((m) => {
|
.map((m) => {
|
||||||
let title = m.title ? `<strong>${m.title}</strong>` : "";
|
let title = m.title
|
||||||
let message = m.message ? `<div>${m.message}</div>` : "";
|
? `<strong>${m.title}</strong>`
|
||||||
|
: "";
|
||||||
|
let message = m.message
|
||||||
|
? `<div>${m.message}</div>`
|
||||||
|
: "";
|
||||||
return title + message;
|
return title + message;
|
||||||
})
|
})
|
||||||
.join("");
|
.join("");
|
||||||
|
|||||||
@@ -20,30 +20,6 @@ INVALID_VALUES = ("", None)
|
|||||||
|
|
||||||
|
|
||||||
class BankStatementImport(DataImport):
|
class BankStatementImport(DataImport):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
bank: DF.Link | None
|
|
||||||
bank_account: DF.Link
|
|
||||||
company: DF.Link
|
|
||||||
google_sheets_url: DF.Data | None
|
|
||||||
import_file: DF.Attach | None
|
|
||||||
import_type: DF.Literal["", "Insert New Records", "Update Existing Records"]
|
|
||||||
mute_emails: DF.Check
|
|
||||||
reference_doctype: DF.Link
|
|
||||||
show_failed_logs: DF.Check
|
|
||||||
statement_import_log: DF.Code | None
|
|
||||||
status: DF.Literal["Pending", "Success", "Partial Success", "Error"]
|
|
||||||
submit_after_import: DF.Check
|
|
||||||
template_options: DF.Code | None
|
|
||||||
template_warnings: DF.Code | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BankStatementImport, self).__init__(*args, **kwargs)
|
super(BankStatementImport, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,36 @@
|
|||||||
let imports_in_progress = [];
|
let imports_in_progress = [];
|
||||||
|
|
||||||
frappe.listview_settings["Bank Statement Import"] = {
|
frappe.listview_settings['Bank Statement Import'] = {
|
||||||
onload(listview) {
|
onload(listview) {
|
||||||
frappe.realtime.on("data_import_progress", (data) => {
|
frappe.realtime.on('data_import_progress', data => {
|
||||||
if (!imports_in_progress.includes(data.data_import)) {
|
if (!imports_in_progress.includes(data.data_import)) {
|
||||||
imports_in_progress.push(data.data_import);
|
imports_in_progress.push(data.data_import);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
frappe.realtime.on("data_import_refresh", (data) => {
|
frappe.realtime.on('data_import_refresh', data => {
|
||||||
imports_in_progress = imports_in_progress.filter((d) => d !== data.data_import);
|
imports_in_progress = imports_in_progress.filter(
|
||||||
|
d => d !== data.data_import
|
||||||
|
);
|
||||||
listview.refresh();
|
listview.refresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
get_indicator: function (doc) {
|
get_indicator: function(doc) {
|
||||||
var colors = {
|
var colors = {
|
||||||
Pending: "orange",
|
'Pending': 'orange',
|
||||||
"Not Started": "orange",
|
'Not Started': 'orange',
|
||||||
"Partial Success": "orange",
|
'Partial Success': 'orange',
|
||||||
Success: "green",
|
'Success': 'green',
|
||||||
"In Progress": "orange",
|
'In Progress': 'orange',
|
||||||
Error: "red",
|
'Error': 'red'
|
||||||
};
|
};
|
||||||
let status = doc.status;
|
let status = doc.status;
|
||||||
if (imports_in_progress.includes(doc.name)) {
|
if (imports_in_progress.includes(doc.name)) {
|
||||||
status = "In Progress";
|
status = 'In Progress';
|
||||||
}
|
}
|
||||||
if (status == "Pending") {
|
if (status == 'Pending') {
|
||||||
status = "Not Started";
|
status = 'Not Started';
|
||||||
}
|
}
|
||||||
return [__(status), colors[status], "status,=," + doc.status];
|
return [__(status), colors[status], 'status,=,' + doc.status];
|
||||||
},
|
},
|
||||||
hide_name_column: true,
|
hide_name_column: true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
frappe.ui.form.on("Bank Transaction", {
|
frappe.ui.form.on("Bank Transaction", {
|
||||||
onload(frm) {
|
onload(frm) {
|
||||||
frm.set_query("payment_document", "payment_entries", function () {
|
frm.set_query("payment_document", "payment_entries", function() {
|
||||||
const payment_doctypes = frm.events.get_payment_doctypes(frm);
|
const payment_doctypes = frm.events.get_payment_doctypes(frm);
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -23,7 +23,7 @@ frappe.ui.form.on("Bank Transaction", {
|
|||||||
set_bank_statement_filter(frm);
|
set_bank_statement_filter(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("party_type", function () {
|
frm.set_query("party_type", function () {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -33,10 +33,16 @@ frappe.ui.form.on("Bank Transaction", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
get_payment_doctypes: function () {
|
get_payment_doctypes: function() {
|
||||||
// get payment doctypes from all the apps
|
// get payment doctypes from all the apps
|
||||||
return ["Payment Entry", "Journal Entry", "Sales Invoice", "Purchase Invoice", "Bank Transaction"];
|
return [
|
||||||
},
|
"Payment Entry",
|
||||||
|
"Journal Entry",
|
||||||
|
"Sales Invoice",
|
||||||
|
"Purchase Invoice",
|
||||||
|
"Bank Transaction",
|
||||||
|
];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Bank Transaction Payments", {
|
frappe.ui.form.on("Bank Transaction Payments", {
|
||||||
@@ -48,11 +54,10 @@ frappe.ui.form.on("Bank Transaction Payments", {
|
|||||||
const update_clearance_date = (frm, cdt, cdn) => {
|
const update_clearance_date = (frm, cdt, cdn) => {
|
||||||
if (frm.doc.docstatus === 1) {
|
if (frm.doc.docstatus === 1) {
|
||||||
frappe
|
frappe
|
||||||
.xcall("erpnext.accounts.doctype.bank_transaction.bank_transaction.unclear_reference_payment", {
|
.xcall(
|
||||||
doctype: cdt,
|
"erpnext.accounts.doctype.bank_transaction.bank_transaction.unclear_reference_payment",
|
||||||
docname: cdn,
|
{ doctype: cdt, docname: cdn, bt_name: frm.doc.name }
|
||||||
bt_name: frm.doc.name,
|
)
|
||||||
})
|
|
||||||
.then((e) => {
|
.then((e) => {
|
||||||
if (e == "success") {
|
if (e == "success") {
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
"status",
|
"status",
|
||||||
"bank_account",
|
"bank_account",
|
||||||
"company",
|
"company",
|
||||||
"amended_from",
|
|
||||||
"section_break_4",
|
"section_break_4",
|
||||||
"deposit",
|
"deposit",
|
||||||
"withdrawal",
|
"withdrawal",
|
||||||
@@ -26,10 +25,10 @@
|
|||||||
"transaction_id",
|
"transaction_id",
|
||||||
"transaction_type",
|
"transaction_type",
|
||||||
"section_break_14",
|
"section_break_14",
|
||||||
"column_break_oufv",
|
|
||||||
"payment_entries",
|
"payment_entries",
|
||||||
"section_break_18",
|
"section_break_18",
|
||||||
"allocated_amount",
|
"allocated_amount",
|
||||||
|
"amended_from",
|
||||||
"column_break_17",
|
"column_break_17",
|
||||||
"unallocated_amount",
|
"unallocated_amount",
|
||||||
"party_section",
|
"party_section",
|
||||||
@@ -139,12 +138,10 @@
|
|||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
|
||||||
"fieldname": "allocated_amount",
|
"fieldname": "allocated_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Allocated Amount",
|
"label": "Allocated Amount",
|
||||||
"options": "currency",
|
"options": "currency"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
@@ -160,12 +157,10 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
|
||||||
"fieldname": "unallocated_amount",
|
"fieldname": "unallocated_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Unallocated Amount",
|
"label": "Unallocated Amount",
|
||||||
"options": "currency",
|
"options": "currency"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_section",
|
"fieldname": "party_section",
|
||||||
@@ -230,15 +225,11 @@
|
|||||||
"fieldname": "bank_party_account_number",
|
"fieldname": "bank_party_account_number",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Party Account No. (Bank Statement)"
|
"label": "Party Account No. (Bank Statement)"
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "column_break_oufv",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-11-18 18:32:47.203694",
|
"modified": "2023-06-06 13:58:12.821411",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Bank Transaction",
|
"name": "Bank Transaction",
|
||||||
|
|||||||
@@ -2,139 +2,78 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
|
||||||
from frappe.model.docstatus import DocStatus
|
|
||||||
from frappe.model.document import Document
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
from erpnext.controllers.status_updater import StatusUpdater
|
||||||
|
|
||||||
class BankTransaction(Document):
|
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
class BankTransaction(StatusUpdater):
|
||||||
|
def after_insert(self):
|
||||||
|
self.unallocated_amount = abs(flt(self.withdrawal) - flt(self.deposit))
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
def on_submit(self):
|
||||||
from frappe.types import DF
|
self.clear_linked_payment_entries()
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_transaction_payments.bank_transaction_payments import (
|
|
||||||
BankTransactionPayments,
|
|
||||||
)
|
|
||||||
|
|
||||||
allocated_amount: DF.Currency
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
bank_account: DF.Link | None
|
|
||||||
bank_party_account_number: DF.Data | None
|
|
||||||
bank_party_iban: DF.Data | None
|
|
||||||
bank_party_name: DF.Data | None
|
|
||||||
company: DF.Link | None
|
|
||||||
currency: DF.Link | None
|
|
||||||
date: DF.Date | None
|
|
||||||
deposit: DF.Currency
|
|
||||||
description: DF.SmallText | None
|
|
||||||
naming_series: DF.Literal["ACC-BTN-.YYYY.-"]
|
|
||||||
party: DF.DynamicLink | None
|
|
||||||
party_type: DF.Link | None
|
|
||||||
payment_entries: DF.Table[BankTransactionPayments]
|
|
||||||
reference_number: DF.Data | None
|
|
||||||
status: DF.Literal["", "Pending", "Settled", "Unreconciled", "Reconciled", "Cancelled"]
|
|
||||||
transaction_id: DF.Data | None
|
|
||||||
transaction_type: DF.Data | None
|
|
||||||
unallocated_amount: DF.Currency
|
|
||||||
withdrawal: DF.Currency
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def before_validate(self):
|
|
||||||
self.update_allocated_amount()
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
self.validate_duplicate_references()
|
|
||||||
self.validate_currency()
|
|
||||||
|
|
||||||
def validate_currency(self):
|
|
||||||
"""
|
|
||||||
Bank Transaction should be on the same currency as the Bank Account.
|
|
||||||
"""
|
|
||||||
if self.currency and self.bank_account:
|
|
||||||
account = frappe.get_cached_value("Bank Account", self.bank_account, "account")
|
|
||||||
account_currency = frappe.get_cached_value("Account", account, "account_currency")
|
|
||||||
|
|
||||||
if self.currency != account_currency:
|
|
||||||
frappe.throw(
|
|
||||||
_(
|
|
||||||
"Transaction currency: {0} cannot be different from Bank Account({1}) currency: {2}"
|
|
||||||
).format(
|
|
||||||
frappe.bold(self.currency), frappe.bold(self.bank_account), frappe.bold(account_currency)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_status(self):
|
|
||||||
if self.docstatus == 2:
|
|
||||||
self.db_set("status", "Cancelled")
|
|
||||||
elif self.docstatus == 1:
|
|
||||||
if self.unallocated_amount > 0:
|
|
||||||
self.db_set("status", "Unreconciled")
|
|
||||||
elif self.unallocated_amount <= 0:
|
|
||||||
self.db_set("status", "Reconciled")
|
|
||||||
|
|
||||||
def validate_duplicate_references(self):
|
|
||||||
"""Make sure the same voucher is not allocated twice within the same Bank Transaction"""
|
|
||||||
if not self.payment_entries:
|
|
||||||
return
|
|
||||||
|
|
||||||
pe = []
|
|
||||||
for row in self.payment_entries:
|
|
||||||
reference = (row.payment_document, row.payment_entry)
|
|
||||||
if reference in pe:
|
|
||||||
frappe.throw(
|
|
||||||
_("{0} {1} is allocated twice in this Bank Transaction").format(
|
|
||||||
row.payment_document, row.payment_entry
|
|
||||||
)
|
|
||||||
)
|
|
||||||
pe.append(reference)
|
|
||||||
|
|
||||||
def update_allocated_amount(self):
|
|
||||||
allocated_amount = (
|
|
||||||
sum(p.allocated_amount for p in self.payment_entries) if self.payment_entries else 0.0
|
|
||||||
)
|
|
||||||
unallocated_amount = abs(flt(self.withdrawal) - flt(self.deposit)) - allocated_amount
|
|
||||||
|
|
||||||
self.allocated_amount = flt(allocated_amount, self.precision("allocated_amount"))
|
|
||||||
self.unallocated_amount = flt(unallocated_amount, self.precision("unallocated_amount"))
|
|
||||||
|
|
||||||
def before_submit(self):
|
|
||||||
self.allocate_payment_entries()
|
|
||||||
self.set_status()
|
self.set_status()
|
||||||
|
|
||||||
if frappe.db.get_single_value("Accounts Settings", "enable_party_matching"):
|
if frappe.db.get_single_value("Accounts Settings", "enable_party_matching"):
|
||||||
self.auto_set_party()
|
self.auto_set_party()
|
||||||
|
|
||||||
def before_update_after_submit(self):
|
_saving_flag = False
|
||||||
self.validate_duplicate_references()
|
|
||||||
self.allocate_payment_entries()
|
# nosemgrep: frappe-semgrep-rules.rules.frappe-modifying-but-not-comitting
|
||||||
self.update_allocated_amount()
|
def on_update_after_submit(self):
|
||||||
self.set_status()
|
"Run on save(). Avoid recursion caused by multiple saves"
|
||||||
|
if not self._saving_flag:
|
||||||
|
self._saving_flag = True
|
||||||
|
self.clear_linked_payment_entries()
|
||||||
|
self.update_allocations()
|
||||||
|
self._saving_flag = False
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
for payment_entry in self.payment_entries:
|
self.clear_linked_payment_entries(for_cancel=True)
|
||||||
self.clear_linked_payment_entry(payment_entry, for_cancel=True)
|
self.set_status(update=True)
|
||||||
|
|
||||||
self.set_status()
|
def update_allocations(self):
|
||||||
|
"The doctype does not allow modifications after submission, so write to the db direct"
|
||||||
|
if self.payment_entries:
|
||||||
|
allocated_amount = sum(p.allocated_amount for p in self.payment_entries)
|
||||||
|
else:
|
||||||
|
allocated_amount = 0.0
|
||||||
|
|
||||||
|
amount = abs(flt(self.withdrawal) - flt(self.deposit))
|
||||||
|
self.db_set("allocated_amount", flt(allocated_amount))
|
||||||
|
self.db_set("unallocated_amount", amount - flt(allocated_amount))
|
||||||
|
self.reload()
|
||||||
|
self.set_status(update=True)
|
||||||
|
|
||||||
def add_payment_entries(self, vouchers):
|
def add_payment_entries(self, vouchers):
|
||||||
"Add the vouchers with zero allocation. Save() will perform the allocations and clearance"
|
"Add the vouchers with zero allocation. Save() will perform the allocations and clearance"
|
||||||
if 0.0 >= self.unallocated_amount:
|
if 0.0 >= self.unallocated_amount:
|
||||||
frappe.throw(_("Bank Transaction {0} is already fully reconciled").format(self.name))
|
frappe.throw(frappe._("Bank Transaction {0} is already fully reconciled").format(self.name))
|
||||||
|
|
||||||
|
added = False
|
||||||
for voucher in vouchers:
|
for voucher in vouchers:
|
||||||
self.append(
|
# Can't add same voucher twice
|
||||||
"payment_entries",
|
found = False
|
||||||
{
|
for pe in self.payment_entries:
|
||||||
|
if (
|
||||||
|
pe.payment_document == voucher["payment_doctype"]
|
||||||
|
and pe.payment_entry == voucher["payment_name"]
|
||||||
|
):
|
||||||
|
found = True
|
||||||
|
|
||||||
|
if not found:
|
||||||
|
pe = {
|
||||||
"payment_document": voucher["payment_doctype"],
|
"payment_document": voucher["payment_doctype"],
|
||||||
"payment_entry": voucher["payment_name"],
|
"payment_entry": voucher["payment_name"],
|
||||||
"allocated_amount": 0.0, # Temporary
|
"allocated_amount": 0.0, # Temporary
|
||||||
},
|
}
|
||||||
)
|
child = self.append("payment_entries", pe)
|
||||||
|
added = True
|
||||||
|
|
||||||
|
# runs on_update_after_submit
|
||||||
|
if added:
|
||||||
|
self.save()
|
||||||
|
|
||||||
def allocate_payment_entries(self):
|
def allocate_payment_entries(self):
|
||||||
"""Refactored from bank reconciliation tool.
|
"""Refactored from bank reconciliation tool.
|
||||||
@@ -150,8 +89,8 @@ class BankTransaction(Document):
|
|||||||
- 0 > a: Error: already over-allocated
|
- 0 > a: Error: already over-allocated
|
||||||
- clear means: set the latest transaction date as clearance date
|
- clear means: set the latest transaction date as clearance date
|
||||||
"""
|
"""
|
||||||
|
gl_bank_account = frappe.db.get_value("Bank Account", self.bank_account, "account")
|
||||||
remaining_amount = self.unallocated_amount
|
remaining_amount = self.unallocated_amount
|
||||||
to_remove = []
|
|
||||||
for payment_entry in self.payment_entries:
|
for payment_entry in self.payment_entries:
|
||||||
if payment_entry.allocated_amount == 0.0:
|
if payment_entry.allocated_amount == 0.0:
|
||||||
unallocated_amount, should_clear, latest_transaction = get_clearance_details(
|
unallocated_amount, should_clear, latest_transaction = get_clearance_details(
|
||||||
@@ -161,39 +100,49 @@ class BankTransaction(Document):
|
|||||||
if 0.0 == unallocated_amount:
|
if 0.0 == unallocated_amount:
|
||||||
if should_clear:
|
if should_clear:
|
||||||
latest_transaction.clear_linked_payment_entry(payment_entry)
|
latest_transaction.clear_linked_payment_entry(payment_entry)
|
||||||
to_remove.append(payment_entry)
|
self.db_delete_payment_entry(payment_entry)
|
||||||
|
|
||||||
elif remaining_amount <= 0.0:
|
elif remaining_amount <= 0.0:
|
||||||
to_remove.append(payment_entry)
|
self.db_delete_payment_entry(payment_entry)
|
||||||
|
|
||||||
elif 0.0 < unallocated_amount <= remaining_amount:
|
elif 0.0 < unallocated_amount and unallocated_amount <= remaining_amount:
|
||||||
payment_entry.allocated_amount = unallocated_amount
|
payment_entry.db_set("allocated_amount", unallocated_amount)
|
||||||
remaining_amount -= unallocated_amount
|
remaining_amount -= unallocated_amount
|
||||||
if should_clear:
|
if should_clear:
|
||||||
latest_transaction.clear_linked_payment_entry(payment_entry)
|
latest_transaction.clear_linked_payment_entry(payment_entry)
|
||||||
|
|
||||||
elif 0.0 < unallocated_amount:
|
elif 0.0 < unallocated_amount and unallocated_amount > remaining_amount:
|
||||||
payment_entry.allocated_amount = remaining_amount
|
payment_entry.db_set("allocated_amount", remaining_amount)
|
||||||
remaining_amount = 0.0
|
remaining_amount = 0.0
|
||||||
|
|
||||||
elif 0.0 > unallocated_amount:
|
elif 0.0 > unallocated_amount:
|
||||||
frappe.throw(_("Voucher {0} is over-allocated by {1}").format(unallocated_amount))
|
self.db_delete_payment_entry(payment_entry)
|
||||||
|
frappe.throw(frappe._("Voucher {0} is over-allocated by {1}").format(unallocated_amount))
|
||||||
|
|
||||||
for payment_entry in to_remove:
|
self.reload()
|
||||||
self.remove(to_remove)
|
|
||||||
|
def db_delete_payment_entry(self, payment_entry):
|
||||||
|
frappe.db.delete("Bank Transaction Payments", {"name": payment_entry.name})
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def remove_payment_entries(self):
|
def remove_payment_entries(self):
|
||||||
for payment_entry in self.payment_entries:
|
for payment_entry in self.payment_entries:
|
||||||
self.remove_payment_entry(payment_entry)
|
self.remove_payment_entry(payment_entry)
|
||||||
|
# runs on_update_after_submit
|
||||||
self.save() # runs before_update_after_submit
|
self.save()
|
||||||
|
|
||||||
def remove_payment_entry(self, payment_entry):
|
def remove_payment_entry(self, payment_entry):
|
||||||
"Clear payment entry and clearance"
|
"Clear payment entry and clearance"
|
||||||
self.clear_linked_payment_entry(payment_entry, for_cancel=True)
|
self.clear_linked_payment_entry(payment_entry, for_cancel=True)
|
||||||
self.remove(payment_entry)
|
self.remove(payment_entry)
|
||||||
|
|
||||||
|
def clear_linked_payment_entries(self, for_cancel=False):
|
||||||
|
if for_cancel:
|
||||||
|
for payment_entry in self.payment_entries:
|
||||||
|
self.clear_linked_payment_entry(payment_entry, for_cancel)
|
||||||
|
else:
|
||||||
|
self.allocate_payment_entries()
|
||||||
|
|
||||||
def clear_linked_payment_entry(self, payment_entry, for_cancel=False):
|
def clear_linked_payment_entry(self, payment_entry, for_cancel=False):
|
||||||
clearance_date = None if for_cancel else self.date
|
clearance_date = None if for_cancel else self.date
|
||||||
set_voucher_clearance(
|
set_voucher_clearance(
|
||||||
@@ -214,10 +163,11 @@ class BankTransaction(Document):
|
|||||||
deposit=self.deposit,
|
deposit=self.deposit,
|
||||||
).match()
|
).match()
|
||||||
|
|
||||||
if not result:
|
if result:
|
||||||
return
|
party_type, party = result
|
||||||
|
frappe.db.set_value(
|
||||||
self.party_type, self.party = result
|
"Bank Transaction", self.name, field={"party_type": party_type, "party": party}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -249,7 +199,9 @@ def get_clearance_details(transaction, payment_entry):
|
|||||||
if gle["gl_account"] == gl_bank_account:
|
if gle["gl_account"] == gl_bank_account:
|
||||||
if gle["amount"] <= 0.0:
|
if gle["amount"] <= 0.0:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Voucher {0} value is broken: {1}").format(payment_entry.payment_entry, gle["amount"])
|
frappe._("Voucher {0} value is broken: {1}").format(
|
||||||
|
payment_entry.payment_entry, gle["amount"]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
unmatched_gles -= 1
|
unmatched_gles -= 1
|
||||||
@@ -270,7 +222,7 @@ def get_clearance_details(transaction, payment_entry):
|
|||||||
|
|
||||||
def get_related_bank_gl_entries(doctype, docname):
|
def get_related_bank_gl_entries(doctype, docname):
|
||||||
# nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql
|
# nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql
|
||||||
return frappe.db.sql(
|
result = frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
ABS(gle.credit_in_account_currency - gle.debit_in_account_currency) AS amount,
|
ABS(gle.credit_in_account_currency - gle.debit_in_account_currency) AS amount,
|
||||||
@@ -288,6 +240,7 @@ def get_related_bank_gl_entries(doctype, docname):
|
|||||||
dict(doctype=doctype, docname=docname),
|
dict(doctype=doctype, docname=docname),
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_total_allocated_amount(doctype, docname):
|
def get_total_allocated_amount(doctype, docname):
|
||||||
@@ -397,25 +350,22 @@ def set_voucher_clearance(doctype, docname, clearance_date, self):
|
|||||||
and len(get_reconciled_bank_transactions(doctype, docname)) < 2
|
and len(get_reconciled_bank_transactions(doctype, docname)) < 2
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
if doctype == "Sales Invoice":
|
|
||||||
frappe.db.set_value(
|
|
||||||
"Sales Invoice Payment",
|
|
||||||
dict(parenttype=doctype, parent=docname),
|
|
||||||
"clearance_date",
|
|
||||||
clearance_date,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
frappe.db.set_value(doctype, docname, "clearance_date", clearance_date)
|
frappe.db.set_value(doctype, docname, "clearance_date", clearance_date)
|
||||||
|
|
||||||
|
elif doctype == "Sales Invoice":
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Sales Invoice Payment",
|
||||||
|
dict(parenttype=doctype, parent=docname),
|
||||||
|
"clearance_date",
|
||||||
|
clearance_date,
|
||||||
|
)
|
||||||
|
|
||||||
elif doctype == "Bank Transaction":
|
elif doctype == "Bank Transaction":
|
||||||
# For when a second bank transaction has fixed another, e.g. refund
|
# For when a second bank transaction has fixed another, e.g. refund
|
||||||
bt = frappe.get_doc(doctype, docname)
|
bt = frappe.get_doc(doctype, docname)
|
||||||
if clearance_date:
|
if clearance_date:
|
||||||
vouchers = [{"payment_doctype": "Bank Transaction", "payment_name": self.name}]
|
vouchers = [{"payment_doctype": "Bank Transaction", "payment_name": self.name}]
|
||||||
bt.add_payment_entries(vouchers)
|
bt.add_payment_entries(vouchers)
|
||||||
bt.save()
|
|
||||||
else:
|
else:
|
||||||
for pe in bt.payment_entries:
|
for pe in bt.payment_entries:
|
||||||
if pe.payment_document == self.doctype and pe.payment_entry == self.name:
|
if pe.payment_document == self.doctype and pe.payment_entry == self.name:
|
||||||
@@ -437,21 +387,3 @@ def unclear_reference_payment(doctype, docname, bt_name):
|
|||||||
bt = frappe.get_doc("Bank Transaction", bt_name)
|
bt = frappe.get_doc("Bank Transaction", bt_name)
|
||||||
set_voucher_clearance(doctype, docname, None, bt)
|
set_voucher_clearance(doctype, docname, None, bt)
|
||||||
return docname
|
return docname
|
||||||
|
|
||||||
|
|
||||||
def remove_from_bank_transaction(doctype, docname):
|
|
||||||
"""Remove a (cancelled) voucher from all Bank Transactions."""
|
|
||||||
for bt_name in get_reconciled_bank_transactions(doctype, docname):
|
|
||||||
bt = frappe.get_doc("Bank Transaction", bt_name)
|
|
||||||
if bt.docstatus == DocStatus.cancelled():
|
|
||||||
continue
|
|
||||||
|
|
||||||
modified = False
|
|
||||||
|
|
||||||
for pe in bt.payment_entries:
|
|
||||||
if pe.payment_document == doctype and pe.payment_entry == docname:
|
|
||||||
bt.remove(pe)
|
|
||||||
modified = True
|
|
||||||
|
|
||||||
if modified:
|
|
||||||
bt.save()
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.listview_settings["Bank Transaction"] = {
|
frappe.listview_settings['Bank Transaction'] = {
|
||||||
add_fields: ["unallocated_amount"],
|
add_fields: ["unallocated_amount"],
|
||||||
get_indicator: function (doc) {
|
get_indicator: function(doc) {
|
||||||
if (doc.docstatus == 2) {
|
if(doc.docstatus == 2) {
|
||||||
return [__("Cancelled"), "red", "docstatus,=,2"];
|
return [__("Cancelled"), "red", "docstatus,=,2"];
|
||||||
} else if (flt(doc.unallocated_amount) <= 0) {
|
} else if(flt(doc.unallocated_amount)<=0) {
|
||||||
return [__("Reconciled"), "green", "unallocated_amount,=,0"];
|
return [__("Reconciled"), "green", "unallocated_amount,=,0"];
|
||||||
} else if (flt(doc.unallocated_amount) > 0) {
|
} else if(flt(doc.unallocated_amount)>0) {
|
||||||
return [__("Unreconciled"), "orange", "unallocated_amount,>,0"];
|
return [__("Unreconciled"), "orange", "unallocated_amount,>,0"];
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import utils
|
from frappe import utils
|
||||||
from frappe.model.docstatus import DocStatus
|
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
||||||
@@ -32,16 +32,8 @@ class TestBankTransaction(FrappeTestCase):
|
|||||||
frappe.db.delete(dt)
|
frappe.db.delete(dt)
|
||||||
clear_loan_transactions()
|
clear_loan_transactions()
|
||||||
make_pos_profile()
|
make_pos_profile()
|
||||||
|
add_transactions()
|
||||||
# generate and use a uniq hash identifier for 'Bank Account' and it's linked GL 'Account' to avoid validation error
|
add_vouchers()
|
||||||
uniq_identifier = frappe.generate_hash(length=10)
|
|
||||||
gl_account = create_gl_account("_Test Bank " + uniq_identifier)
|
|
||||||
bank_account = create_bank_account(
|
|
||||||
gl_account=gl_account, bank_account_name="Checking Account " + uniq_identifier
|
|
||||||
)
|
|
||||||
|
|
||||||
add_transactions(bank_account=bank_account)
|
|
||||||
add_vouchers(gl_account=gl_account)
|
|
||||||
|
|
||||||
# This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction.
|
# This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction.
|
||||||
def test_linked_payments(self):
|
def test_linked_payments(self):
|
||||||
@@ -89,29 +81,6 @@ class TestBankTransaction(FrappeTestCase):
|
|||||||
clearance_date = frappe.db.get_value("Payment Entry", payment.name, "clearance_date")
|
clearance_date = frappe.db.get_value("Payment Entry", payment.name, "clearance_date")
|
||||||
self.assertFalse(clearance_date)
|
self.assertFalse(clearance_date)
|
||||||
|
|
||||||
def test_cancel_voucher(self):
|
|
||||||
bank_transaction = frappe.get_doc(
|
|
||||||
"Bank Transaction",
|
|
||||||
dict(description="1512567 BG/000003025 OPSKATTUZWXXX AT776000000098709849 Herr G"),
|
|
||||||
)
|
|
||||||
payment = frappe.get_doc("Payment Entry", dict(party="Mr G", paid_amount=1700))
|
|
||||||
vouchers = json.dumps(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"payment_doctype": "Payment Entry",
|
|
||||||
"payment_name": payment.name,
|
|
||||||
"amount": bank_transaction.unallocated_amount,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
reconcile_vouchers(bank_transaction.name, vouchers)
|
|
||||||
payment.reload()
|
|
||||||
payment.cancel()
|
|
||||||
bank_transaction.reload()
|
|
||||||
self.assertEqual(bank_transaction.docstatus, DocStatus.submitted())
|
|
||||||
self.assertEqual(bank_transaction.unallocated_amount, 1700)
|
|
||||||
self.assertEqual(bank_transaction.payment_entries, [])
|
|
||||||
|
|
||||||
# Check if ERPNext can correctly filter a linked payments based on the debit/credit amount
|
# Check if ERPNext can correctly filter a linked payments based on the debit/credit amount
|
||||||
def test_debit_credit_output(self):
|
def test_debit_credit_output(self):
|
||||||
bank_transaction = frappe.get_doc(
|
bank_transaction = frappe.get_doc(
|
||||||
@@ -227,9 +196,7 @@ def clear_loan_transactions():
|
|||||||
frappe.db.delete("Loan Repayment")
|
frappe.db.delete("Loan Repayment")
|
||||||
|
|
||||||
|
|
||||||
def create_bank_account(
|
def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
|
||||||
bank_name="Citi Bank", gl_account="_Test Bank - _TC", bank_account_name="Checking Account"
|
|
||||||
):
|
|
||||||
try:
|
try:
|
||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
@@ -241,35 +208,21 @@ def create_bank_account(
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bank_account = frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Bank Account",
|
"doctype": "Bank Account",
|
||||||
"account_name": bank_account_name,
|
"account_name": "Checking Account",
|
||||||
"bank": bank_name,
|
"bank": bank_name,
|
||||||
"account": gl_account,
|
"account": account_name,
|
||||||
}
|
}
|
||||||
).insert(ignore_if_duplicate=True)
|
).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return bank_account.name
|
|
||||||
|
|
||||||
|
def add_transactions():
|
||||||
|
create_bank_account()
|
||||||
|
|
||||||
def create_gl_account(gl_account_name="_Test Bank - _TC"):
|
|
||||||
gl_account = frappe.get_doc(
|
|
||||||
{
|
|
||||||
"doctype": "Account",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"parent_account": "Current Assets - _TC",
|
|
||||||
"account_type": "Bank",
|
|
||||||
"is_group": 0,
|
|
||||||
"account_name": gl_account_name,
|
|
||||||
}
|
|
||||||
).insert()
|
|
||||||
return gl_account.name
|
|
||||||
|
|
||||||
|
|
||||||
def add_transactions(bank_account="_Test Bank - _TC"):
|
|
||||||
doc = frappe.get_doc(
|
doc = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Bank Transaction",
|
"doctype": "Bank Transaction",
|
||||||
@@ -277,7 +230,7 @@ def add_transactions(bank_account="_Test Bank - _TC"):
|
|||||||
"date": "2018-10-23",
|
"date": "2018-10-23",
|
||||||
"deposit": 1200,
|
"deposit": 1200,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"bank_account": bank_account,
|
"bank_account": "Checking Account - Citi Bank",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
@@ -289,7 +242,7 @@ def add_transactions(bank_account="_Test Bank - _TC"):
|
|||||||
"date": "2018-10-23",
|
"date": "2018-10-23",
|
||||||
"deposit": 1700,
|
"deposit": 1700,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"bank_account": bank_account,
|
"bank_account": "Checking Account - Citi Bank",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
@@ -301,7 +254,7 @@ def add_transactions(bank_account="_Test Bank - _TC"):
|
|||||||
"date": "2018-10-26",
|
"date": "2018-10-26",
|
||||||
"withdrawal": 690,
|
"withdrawal": 690,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"bank_account": bank_account,
|
"bank_account": "Checking Account - Citi Bank",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
@@ -313,7 +266,7 @@ def add_transactions(bank_account="_Test Bank - _TC"):
|
|||||||
"date": "2018-10-27",
|
"date": "2018-10-27",
|
||||||
"deposit": 3900,
|
"deposit": 3900,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"bank_account": bank_account,
|
"bank_account": "Checking Account - Citi Bank",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
@@ -325,13 +278,13 @@ def add_transactions(bank_account="_Test Bank - _TC"):
|
|||||||
"date": "2018-10-27",
|
"date": "2018-10-27",
|
||||||
"withdrawal": 109080,
|
"withdrawal": 109080,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"bank_account": bank_account,
|
"bank_account": "Checking Account - Citi Bank",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
|
|
||||||
|
|
||||||
def add_vouchers(gl_account="_Test Bank - _TC"):
|
def add_vouchers():
|
||||||
try:
|
try:
|
||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
@@ -347,7 +300,7 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
|
|
||||||
pi = make_purchase_invoice(supplier="Conrad Electronic", qty=1, rate=690)
|
pi = make_purchase_invoice(supplier="Conrad Electronic", qty=1, rate=690)
|
||||||
|
|
||||||
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account=gl_account)
|
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC")
|
||||||
pe.reference_no = "Conrad Oct 18"
|
pe.reference_no = "Conrad Oct 18"
|
||||||
pe.reference_date = "2018-10-24"
|
pe.reference_date = "2018-10-24"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
@@ -366,14 +319,14 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
pi = make_purchase_invoice(supplier="Mr G", qty=1, rate=1200)
|
pi = make_purchase_invoice(supplier="Mr G", qty=1, rate=1200)
|
||||||
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account=gl_account)
|
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC")
|
||||||
pe.reference_no = "Herr G Oct 18"
|
pe.reference_no = "Herr G Oct 18"
|
||||||
pe.reference_date = "2018-10-24"
|
pe.reference_date = "2018-10-24"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
pe.submit()
|
pe.submit()
|
||||||
|
|
||||||
pi = make_purchase_invoice(supplier="Mr G", qty=1, rate=1700)
|
pi = make_purchase_invoice(supplier="Mr G", qty=1, rate=1700)
|
||||||
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account=gl_account)
|
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC")
|
||||||
pe.reference_no = "Herr G Nov 18"
|
pe.reference_no = "Herr G Nov 18"
|
||||||
pe.reference_date = "2018-11-01"
|
pe.reference_date = "2018-11-01"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
@@ -404,10 +357,10 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
pi = make_purchase_invoice(supplier="Poore Simon's", qty=1, rate=3900, is_paid=1, do_not_save=1)
|
pi = make_purchase_invoice(supplier="Poore Simon's", qty=1, rate=3900, is_paid=1, do_not_save=1)
|
||||||
pi.cash_bank_account = gl_account
|
pi.cash_bank_account = "_Test Bank - _TC"
|
||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
pi.submit()
|
||||||
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account=gl_account)
|
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC")
|
||||||
pe.reference_no = "Poore Simon's Oct 18"
|
pe.reference_no = "Poore Simon's Oct 18"
|
||||||
pe.reference_date = "2018-10-28"
|
pe.reference_date = "2018-10-28"
|
||||||
pe.paid_amount = 690
|
pe.paid_amount = 690
|
||||||
@@ -416,7 +369,7 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
pe.submit()
|
pe.submit()
|
||||||
|
|
||||||
si = create_sales_invoice(customer="Poore Simon's", qty=1, rate=3900)
|
si = create_sales_invoice(customer="Poore Simon's", qty=1, rate=3900)
|
||||||
pe = get_payment_entry("Sales Invoice", si.name, bank_account=gl_account)
|
pe = get_payment_entry("Sales Invoice", si.name, bank_account="_Test Bank - _TC")
|
||||||
pe.reference_no = "Poore Simon's Oct 18"
|
pe.reference_no = "Poore Simon's Oct 18"
|
||||||
pe.reference_date = "2018-10-28"
|
pe.reference_date = "2018-10-28"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
@@ -439,12 +392,16 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
if not frappe.db.get_value(
|
if not frappe.db.get_value(
|
||||||
"Mode of Payment Account", {"company": "_Test Company", "parent": "Cash"}
|
"Mode of Payment Account", {"company": "_Test Company", "parent": "Cash"}
|
||||||
):
|
):
|
||||||
mode_of_payment.append("accounts", {"company": "_Test Company", "default_account": gl_account})
|
mode_of_payment.append(
|
||||||
|
"accounts", {"company": "_Test Company", "default_account": "_Test Bank - _TC"}
|
||||||
|
)
|
||||||
mode_of_payment.save()
|
mode_of_payment.save()
|
||||||
|
|
||||||
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_save=1)
|
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_save=1)
|
||||||
si.is_pos = 1
|
si.is_pos = 1
|
||||||
si.append("payments", {"mode_of_payment": "Cash", "account": gl_account, "amount": 109080})
|
si.append(
|
||||||
|
"payments", {"mode_of_payment": "Cash", "account": "_Test Bank - _TC", "amount": 109080}
|
||||||
|
)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankTransactionMapping(Document):
|
class BankTransactionMapping(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
bank_transaction_field: DF.Literal
|
|
||||||
file_field: DF.Data
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,21 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BankTransactionPayments(Document):
|
class BankTransactionPayments(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
allocated_amount: DF.Currency
|
|
||||||
clearance_date: DF.Date | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
payment_document: DF.Link
|
|
||||||
payment_entry: DF.DynamicLink
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2,48 +2,48 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
frappe.provide("erpnext.accounts.dimensions");
|
frappe.provide("erpnext.accounts.dimensions");
|
||||||
|
|
||||||
frappe.ui.form.on("Budget", {
|
frappe.ui.form.on('Budget', {
|
||||||
onload: function (frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("account", "accounts", function () {
|
frm.set_query("account", "accounts", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
report_type: "Profit and Loss",
|
report_type: "Profit and Loss",
|
||||||
is_group: 0,
|
is_group: 0
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("monthly_distribution", function () {
|
frm.set_query("monthly_distribution", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
fiscal_year: frm.doc.fiscal_year,
|
fiscal_year: frm.doc.fiscal_year
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
|
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
frm.trigger("toggle_reqd_fields");
|
frm.trigger("toggle_reqd_fields")
|
||||||
},
|
},
|
||||||
|
|
||||||
budget_against: function (frm) {
|
budget_against: function(frm) {
|
||||||
frm.trigger("set_null_value");
|
frm.trigger("set_null_value")
|
||||||
frm.trigger("toggle_reqd_fields");
|
frm.trigger("toggle_reqd_fields")
|
||||||
},
|
},
|
||||||
|
|
||||||
set_null_value: function (frm) {
|
set_null_value: function(frm) {
|
||||||
if (frm.doc.budget_against == "Cost Center") {
|
if(frm.doc.budget_against == 'Cost Center') {
|
||||||
frm.set_value("project", null);
|
frm.set_value('project', null)
|
||||||
} else {
|
} else {
|
||||||
frm.set_value("cost_center", null);
|
frm.set_value('cost_center', null)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle_reqd_fields: function (frm) {
|
toggle_reqd_fields: function(frm) {
|
||||||
frm.toggle_reqd("cost_center", frm.doc.budget_against == "Cost Center");
|
frm.toggle_reqd("cost_center", frm.doc.budget_against=="Cost Center");
|
||||||
frm.toggle_reqd("project", frm.doc.budget_against == "Project");
|
frm.toggle_reqd("project", frm.doc.budget_against=="Project");
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,36 +22,6 @@ class DuplicateBudgetError(frappe.ValidationError):
|
|||||||
|
|
||||||
|
|
||||||
class Budget(Document):
|
class Budget(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.budget_account.budget_account import BudgetAccount
|
|
||||||
|
|
||||||
accounts: DF.Table[BudgetAccount]
|
|
||||||
action_if_accumulated_monthly_budget_exceeded: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
action_if_accumulated_monthly_budget_exceeded_on_mr: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
action_if_accumulated_monthly_budget_exceeded_on_po: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
action_if_annual_budget_exceeded: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
action_if_annual_budget_exceeded_on_mr: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
action_if_annual_budget_exceeded_on_po: DF.Literal["", "Stop", "Warn", "Ignore"]
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
applicable_on_booking_actual_expenses: DF.Check
|
|
||||||
applicable_on_material_request: DF.Check
|
|
||||||
applicable_on_purchase_order: DF.Check
|
|
||||||
budget_against: DF.Literal["", "Cost Center", "Project"]
|
|
||||||
company: DF.Link
|
|
||||||
cost_center: DF.Link | None
|
|
||||||
fiscal_year: DF.Link
|
|
||||||
monthly_distribution: DF.Link | None
|
|
||||||
naming_series: DF.Data | None
|
|
||||||
project: DF.Link | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.get(frappe.scrub(self.budget_against)):
|
if not self.get(frappe.scrub(self.budget_against)):
|
||||||
frappe.throw(_("{0} is mandatory").format(self.budget_against))
|
frappe.throw(_("{0} is mandatory").format(self.budget_against))
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class BudgetAccount(Document):
|
class BudgetAccount(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
account: DF.Link
|
|
||||||
budget_amount: DF.Currency
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,18 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CampaignItem(Document):
|
class CampaignItem(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
campaign: DF.Link | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Cashier Closing", {
|
frappe.ui.form.on('Cashier Closing', {
|
||||||
setup: function (frm) {
|
|
||||||
|
setup: function(frm){
|
||||||
if (frm.doc.user == "" || frm.doc.user == null) {
|
if (frm.doc.user == "" || frm.doc.user == null) {
|
||||||
frm.doc.user = frappe.session.user;
|
frm.doc.user = frappe.session.user;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,152 +1,457 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"allow_copy": 0,
|
||||||
|
"allow_events_in_timeline": 0,
|
||||||
|
"allow_guest_to_view": 0,
|
||||||
|
"allow_import": 0,
|
||||||
|
"allow_rename": 0,
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
|
"beta": 0,
|
||||||
"creation": "2018-06-18 16:51:49.994750",
|
"creation": "2018-06-18 16:51:49.994750",
|
||||||
|
"custom": 0,
|
||||||
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
|
"document_type": "",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
|
||||||
"naming_series",
|
|
||||||
"user",
|
|
||||||
"date",
|
|
||||||
"from_time",
|
|
||||||
"time",
|
|
||||||
"expense",
|
|
||||||
"custody",
|
|
||||||
"returns",
|
|
||||||
"outstanding_amount",
|
|
||||||
"payments",
|
|
||||||
"net_amount",
|
|
||||||
"amended_from"
|
|
||||||
],
|
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "POS-CLO-",
|
"default": "POS-CLO-",
|
||||||
"fieldname": "naming_series",
|
"fieldname": "naming_series",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Series",
|
"label": "Series",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
"options": "POS-CLO-",
|
"options": "POS-CLO-",
|
||||||
"read_only": 1
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "user",
|
"fieldname": "user",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "User",
|
"label": "User",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
"options": "User",
|
"options": "User",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"reqd": 1
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "Today",
|
"default": "Today",
|
||||||
"fieldname": "date",
|
"fieldname": "date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Date",
|
"label": "Date",
|
||||||
"read_only": 1
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "from_time",
|
"fieldname": "from_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "From Time",
|
"label": "From Time",
|
||||||
"reqd": 1
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"default": "",
|
||||||
"fieldname": "time",
|
"fieldname": "time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "To Time",
|
"label": "To Time",
|
||||||
"reqd": 1
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "0.00",
|
"default": "0.00",
|
||||||
"fieldname": "expense",
|
"fieldname": "expense",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Expense"
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Expense",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "0.00",
|
"default": "0.00",
|
||||||
"fieldname": "custody",
|
"fieldname": "custody",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Custody"
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Custody",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "0.00",
|
"default": "0.00",
|
||||||
"fieldname": "returns",
|
"fieldname": "returns",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Returns",
|
"label": "Returns",
|
||||||
"precision": "2"
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "2",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"default": "0.00",
|
"default": "0.00",
|
||||||
"fieldname": "outstanding_amount",
|
"fieldname": "outstanding_amount",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Outstanding Amount",
|
"label": "Outstanding Amount",
|
||||||
"read_only": 1
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"default": "0.0",
|
||||||
"fieldname": "payments",
|
"fieldname": "payments",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Payments",
|
"label": "Payments",
|
||||||
"options": "Cashier Closing Payments"
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Cashier Closing Payments",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "net_amount",
|
"fieldname": "net_amount",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Net Amount",
|
"label": "Net Amount",
|
||||||
"read_only": 1
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
"label": "Amended From",
|
"label": "Amended From",
|
||||||
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Cashier Closing",
|
"options": "Cashier Closing",
|
||||||
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"has_web_view": 0,
|
||||||
|
"hide_heading": 0,
|
||||||
|
"hide_toolbar": 0,
|
||||||
|
"idx": 0,
|
||||||
|
"image_view": 0,
|
||||||
|
"in_create": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"issingle": 0,
|
||||||
"modified": "2023-12-28 13:15:46.858427",
|
"istable": 0,
|
||||||
|
"max_attachments": 0,
|
||||||
|
"modified": "2019-02-19 08:35:24.157327",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Cashier Closing",
|
"name": "Cashier Closing",
|
||||||
"naming_rule": "By \"Naming Series\" field",
|
"name_case": "",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
|
"if_owner": 0,
|
||||||
|
"import": 0,
|
||||||
|
"permlevel": 0,
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "System Manager",
|
"role": "System Manager",
|
||||||
|
"set_user_permissions": 0,
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 1,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"quick_entry": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"read_only_onload": 0,
|
||||||
|
"show_name_in_global_search": 0,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"track_changes": 1,
|
||||||
"track_changes": 1
|
"track_seen": 0,
|
||||||
}
|
"track_views": 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,32 +9,6 @@ from frappe.utils import flt
|
|||||||
|
|
||||||
|
|
||||||
class CashierClosing(Document):
|
class CashierClosing(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.cashier_closing_payments.cashier_closing_payments import (
|
|
||||||
CashierClosingPayments,
|
|
||||||
)
|
|
||||||
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
custody: DF.Float
|
|
||||||
date: DF.Date | None
|
|
||||||
expense: DF.Float
|
|
||||||
from_time: DF.Time
|
|
||||||
naming_series: DF.Literal["POS-CLO-"]
|
|
||||||
net_amount: DF.Float
|
|
||||||
outstanding_amount: DF.Float
|
|
||||||
payments: DF.Table[CashierClosingPayments]
|
|
||||||
returns: DF.Float
|
|
||||||
time: DF.Time
|
|
||||||
user: DF.Link
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_time()
|
self.validate_time()
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CashierClosingPayments(Document):
|
class CashierClosingPayments(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
amount: DF.Float
|
|
||||||
mode_of_payment: DF.Link
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
frappe.ui.form.on("Chart of Accounts Importer", {
|
frappe.ui.form.on('Chart of Accounts Importer', {
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
frm.set_value("company", "");
|
frm.set_value("company", "");
|
||||||
frm.set_value("import_file", "");
|
frm.set_value("import_file", "");
|
||||||
@@ -8,34 +8,31 @@ frappe.ui.form.on("Chart of Accounts Importer", {
|
|||||||
frm.disable_save();
|
frm.disable_save();
|
||||||
|
|
||||||
// make company mandatory
|
// make company mandatory
|
||||||
frm.set_df_property("company", "reqd", frm.doc.company ? 0 : 1);
|
frm.set_df_property('company', 'reqd', frm.doc.company ? 0 : 1);
|
||||||
frm.set_df_property("import_file_section", "hidden", frm.doc.company ? 0 : 1);
|
frm.set_df_property('import_file_section', 'hidden', frm.doc.company ? 0 : 1);
|
||||||
|
|
||||||
if (frm.doc.import_file) {
|
if (frm.doc.import_file) {
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
() => generate_tree_preview(frm),
|
() => generate_tree_preview(frm),
|
||||||
() => create_import_button(frm),
|
() => create_import_button(frm),
|
||||||
() => frm.set_df_property("chart_preview", "hidden", 0),
|
() => frm.set_df_property('chart_preview', 'hidden', 0)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.set_df_property(
|
frm.set_df_property('chart_preview', 'hidden',
|
||||||
"chart_preview",
|
$(frm.fields_dict['chart_tree'].wrapper).html()!="" ? 0 : 1);
|
||||||
"hidden",
|
|
||||||
$(frm.fields_dict["chart_tree"].wrapper).html() != "" ? 0 : 1
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
download_template: function (frm) {
|
download_template: function(frm) {
|
||||||
var d = new frappe.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title: __("Download Template"),
|
title: __("Download Template"),
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
label: "File Type",
|
label : "File Type",
|
||||||
fieldname: "file_type",
|
fieldname: "file_type",
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
options: ["Excel", "CSV"],
|
options: ["Excel", "CSV"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Template Type",
|
label: "Template Type",
|
||||||
@@ -44,53 +41,38 @@ frappe.ui.form.on("Chart of Accounts Importer", {
|
|||||||
reqd: 1,
|
reqd: 1,
|
||||||
options: ["Sample Template", "Blank Template"],
|
options: ["Sample Template", "Blank Template"],
|
||||||
change: () => {
|
change: () => {
|
||||||
let template_type = d.get_value("template_type");
|
let template_type = d.get_value('template_type');
|
||||||
|
|
||||||
if (template_type === "Sample Template") {
|
if (template_type === "Sample Template") {
|
||||||
d.set_df_property(
|
d.set_df_property('template_type', 'description',
|
||||||
"template_type",
|
|
||||||
"description",
|
|
||||||
`The Sample Template contains all the required accounts pre filled in the template.
|
`The Sample Template contains all the required accounts pre filled in the template.
|
||||||
You can add more accounts or change existing accounts in the template as per your choice.`
|
You can add more accounts or change existing accounts in the template as per your choice.`);
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
d.set_df_property(
|
d.set_df_property('template_type', 'description',
|
||||||
"template_type",
|
|
||||||
"description",
|
|
||||||
`The Blank Template contains just the account type and root type required to build the Chart
|
`The Blank Template contains just the account type and root type required to build the Chart
|
||||||
of Accounts. Please enter the account names and add more rows as per your requirement.`
|
of Accounts. Please enter the account names and add more rows as per your requirement.`);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
label: "Company",
|
|
||||||
fieldname: "company",
|
|
||||||
fieldtype: "Link",
|
|
||||||
reqd: 1,
|
|
||||||
hidden: 1,
|
|
||||||
default: frm.doc.company,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
primary_action: function () {
|
primary_action: function() {
|
||||||
let data = d.get_values();
|
var data = d.get_values();
|
||||||
|
|
||||||
if (!data.template_type) {
|
if (!data.template_type) {
|
||||||
frappe.throw(__("Please select <b>Template Type</b> to download template"));
|
frappe.throw(__('Please select <b>Template Type</b> to download template'));
|
||||||
}
|
}
|
||||||
|
|
||||||
open_url_post(
|
open_url_post(
|
||||||
"/api/method/erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.download_template",
|
'/api/method/erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.download_template',
|
||||||
{
|
{
|
||||||
file_type: data.file_type,
|
file_type: data.file_type,
|
||||||
template_type: data.template_type,
|
template_type: data.template_type
|
||||||
company: data.company,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
d.hide();
|
d.hide();
|
||||||
},
|
},
|
||||||
primary_action_label: __("Download"),
|
primary_action_label: __('Download')
|
||||||
});
|
});
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
@@ -98,7 +80,7 @@ frappe.ui.form.on("Chart of Accounts Importer", {
|
|||||||
import_file: function (frm) {
|
import_file: function (frm) {
|
||||||
if (!frm.doc.import_file) {
|
if (!frm.doc.import_file) {
|
||||||
frm.page.set_indicator("");
|
frm.page.set_indicator("");
|
||||||
$(frm.fields_dict["chart_tree"].wrapper).empty(); // empty wrapper on removing file
|
$(frm.fields_dict['chart_tree'].wrapper).empty(); // empty wrapper on removing file
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -108,97 +90,89 @@ frappe.ui.form.on("Chart of Accounts Importer", {
|
|||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.validate_company",
|
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.validate_company",
|
||||||
args: {
|
args: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
if (r.message === false) {
|
if(r.message===false) {
|
||||||
frm.set_value("company", "");
|
frm.set_value("company", "");
|
||||||
frappe.throw(
|
frappe.throw(__("Transactions against the Company already exist! Chart of Accounts can only be imported for a Company with no transactions."));
|
||||||
__(
|
|
||||||
"Transactions against the Company already exist! Chart of Accounts can only be imported for a Company with no transactions."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
frm.trigger("refresh");
|
frm.trigger("refresh");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var create_import_button = function (frm) {
|
var create_import_button = function(frm) {
|
||||||
frm.page
|
frm.page.set_primary_action(__("Import"), function () {
|
||||||
.set_primary_action(__("Import"), function () {
|
|
||||||
return frappe.call({
|
|
||||||
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.import_coa",
|
|
||||||
args: {
|
|
||||||
file_name: frm.doc.import_file,
|
|
||||||
company: frm.doc.company,
|
|
||||||
},
|
|
||||||
freeze: true,
|
|
||||||
freeze_message: __("Creating Accounts..."),
|
|
||||||
callback: function (r) {
|
|
||||||
if (!r.exc) {
|
|
||||||
clearInterval(frm.page["interval"]);
|
|
||||||
frm.page.set_indicator(__("Import Successful"), "blue");
|
|
||||||
create_reset_button(frm);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.addClass("btn btn-primary");
|
|
||||||
};
|
|
||||||
|
|
||||||
var create_reset_button = function (frm) {
|
|
||||||
frm.page
|
|
||||||
.set_primary_action(__("Reset"), function () {
|
|
||||||
frm.page.clear_primary_action();
|
|
||||||
delete frm.page["show_import_button"];
|
|
||||||
frm.reload_doc();
|
|
||||||
})
|
|
||||||
.addClass("btn btn-primary");
|
|
||||||
};
|
|
||||||
|
|
||||||
var validate_coa = function (frm) {
|
|
||||||
if (frm.doc.import_file) {
|
|
||||||
let parent = __("All Accounts");
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.get_coa",
|
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.import_coa",
|
||||||
args: {
|
args: {
|
||||||
file_name: frm.doc.import_file,
|
file_name: frm.doc.import_file,
|
||||||
parent: parent,
|
company: frm.doc.company
|
||||||
doctype: "Chart of Accounts Importer",
|
|
||||||
file_type: frm.doc.file_type,
|
|
||||||
for_validate: 1,
|
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
freeze: true,
|
||||||
if (r.message["show_import_button"]) {
|
freeze_message: __("Creating Accounts..."),
|
||||||
frm.page["show_import_button"] = Boolean(r.message["show_import_button"]);
|
callback: function(r) {
|
||||||
|
if (!r.exc) {
|
||||||
|
clearInterval(frm.page["interval"]);
|
||||||
|
frm.page.set_indicator(__('Import Successful'), 'blue');
|
||||||
|
create_reset_button(frm);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).addClass('btn btn-primary');
|
||||||
|
};
|
||||||
|
|
||||||
|
var create_reset_button = function(frm) {
|
||||||
|
frm.page.set_primary_action(__("Reset"), function () {
|
||||||
|
frm.page.clear_primary_action();
|
||||||
|
delete frm.page["show_import_button"];
|
||||||
|
frm.reload_doc();
|
||||||
|
}).addClass('btn btn-primary');
|
||||||
|
};
|
||||||
|
|
||||||
|
var validate_coa = function(frm) {
|
||||||
|
if (frm.doc.import_file) {
|
||||||
|
let parent = __('All Accounts');
|
||||||
|
return frappe.call({
|
||||||
|
'method': 'erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.get_coa',
|
||||||
|
'args': {
|
||||||
|
file_name: frm.doc.import_file,
|
||||||
|
parent: parent,
|
||||||
|
doctype: 'Chart of Accounts Importer',
|
||||||
|
file_type: frm.doc.file_type,
|
||||||
|
for_validate: 1
|
||||||
},
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message['show_import_button']) {
|
||||||
|
frm.page['show_import_button'] = Boolean(r.message['show_import_button']);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var generate_tree_preview = function (frm) {
|
var generate_tree_preview = function(frm) {
|
||||||
let parent = __("All Accounts");
|
let parent = __('All Accounts');
|
||||||
$(frm.fields_dict["chart_tree"].wrapper).empty(); // empty wrapper to load new data
|
$(frm.fields_dict['chart_tree'].wrapper).empty(); // empty wrapper to load new data
|
||||||
|
|
||||||
// generate tree structure based on the csv data
|
// generate tree structure based on the csv data
|
||||||
return new frappe.ui.Tree({
|
return new frappe.ui.Tree({
|
||||||
parent: $(frm.fields_dict["chart_tree"].wrapper),
|
parent: $(frm.fields_dict['chart_tree'].wrapper),
|
||||||
label: parent,
|
label: parent,
|
||||||
expandable: true,
|
expandable: true,
|
||||||
method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.get_coa",
|
method: 'erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.get_coa',
|
||||||
args: {
|
args: {
|
||||||
file_name: frm.doc.import_file,
|
file_name: frm.doc.import_file,
|
||||||
parent: parent,
|
parent: parent,
|
||||||
doctype: "Chart of Accounts Importer",
|
doctype: 'Chart of Accounts Importer',
|
||||||
file_type: frm.doc.file_type,
|
file_type: frm.doc.file_type
|
||||||
},
|
},
|
||||||
onclick: function (node) {
|
onclick: function(node) {
|
||||||
parent = node.value;
|
parent = node.value;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from functools import reduce
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.desk.form.linked_with import get_linked_fields
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, cstr
|
from frappe.utils import cint, cstr
|
||||||
from frappe.utils.csvutils import UnicodeWriter
|
from frappe.utils.csvutils import UnicodeWriter
|
||||||
@@ -24,18 +23,6 @@ from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import
|
|||||||
|
|
||||||
|
|
||||||
class ChartofAccountsImporter(Document):
|
class ChartofAccountsImporter(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
company: DF.Link | None
|
|
||||||
import_file: DF.Attach | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if self.import_file:
|
if self.import_file:
|
||||||
get_coa(
|
get_coa(
|
||||||
@@ -125,7 +112,7 @@ def generate_data_from_csv(file_doc, as_dict=False):
|
|||||||
if as_dict:
|
if as_dict:
|
||||||
data.append({frappe.scrub(header): row[index] for index, header in enumerate(headers)})
|
data.append({frappe.scrub(header): row[index] for index, header in enumerate(headers)})
|
||||||
else:
|
else:
|
||||||
if not row[1] and len(row) > 1:
|
if not row[1]:
|
||||||
row[1] = row[0]
|
row[1] = row[0]
|
||||||
row[3] = row[2]
|
row[3] = row[2]
|
||||||
data.append(row)
|
data.append(row)
|
||||||
@@ -307,8 +294,10 @@ def build_response_as_excel(writer):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def download_template(file_type, template_type, company):
|
def download_template(file_type, template_type):
|
||||||
writer = get_template(template_type, company)
|
data = frappe._dict(frappe.local.form_dict)
|
||||||
|
|
||||||
|
writer = get_template(template_type)
|
||||||
|
|
||||||
if file_type == "CSV":
|
if file_type == "CSV":
|
||||||
# download csv file
|
# download csv file
|
||||||
@@ -319,7 +308,8 @@ def download_template(file_type, template_type, company):
|
|||||||
build_response_as_excel(writer)
|
build_response_as_excel(writer)
|
||||||
|
|
||||||
|
|
||||||
def get_template(template_type, company):
|
def get_template(template_type):
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"Account Name",
|
"Account Name",
|
||||||
"Parent Account",
|
"Parent Account",
|
||||||
@@ -345,17 +335,34 @@ def get_template(template_type, company):
|
|||||||
["", "", "", "", 0, account_type.get("account_type"), account_type.get("root_type")]
|
["", "", "", "", 0, account_type.get("account_type"), account_type.get("root_type")]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
writer = get_sample_template(writer, company)
|
writer = get_sample_template(writer)
|
||||||
|
|
||||||
return writer
|
return writer
|
||||||
|
|
||||||
|
|
||||||
def get_sample_template(writer, company):
|
def get_sample_template(writer):
|
||||||
currency = frappe.db.get_value("Company", company, "default_currency")
|
template = [
|
||||||
with open(os.path.join(os.path.dirname(__file__), "coa_sample_template.csv"), "r") as f:
|
["Application Of Funds(Assets)", "", "", "", 1, "", "Asset"],
|
||||||
for row in f:
|
["Sources Of Funds(Liabilities)", "", "", "", 1, "", "Liability"],
|
||||||
row = row.strip().split(",") + [currency]
|
["Equity", "", "", "", 1, "", "Equity"],
|
||||||
writer.writerow(row)
|
["Expenses", "", "", "", 1, "", "Expense"],
|
||||||
|
["Income", "", "", "", 1, "", "Income"],
|
||||||
|
["Bank Accounts", "Application Of Funds(Assets)", "", "", 1, "Bank", "Asset"],
|
||||||
|
["Cash In Hand", "Application Of Funds(Assets)", "", "", 1, "Cash", "Asset"],
|
||||||
|
["Stock Assets", "Application Of Funds(Assets)", "", "", 1, "Stock", "Asset"],
|
||||||
|
["Cost Of Goods Sold", "Expenses", "", "", 0, "Cost of Goods Sold", "Expense"],
|
||||||
|
["Asset Depreciation", "Expenses", "", "", 0, "Depreciation", "Expense"],
|
||||||
|
["Fixed Assets", "Application Of Funds(Assets)", "", "", 0, "Fixed Asset", "Asset"],
|
||||||
|
["Accounts Payable", "Sources Of Funds(Liabilities)", "", "", 0, "Payable", "Liability"],
|
||||||
|
["Accounts Receivable", "Application Of Funds(Assets)", "", "", 1, "Receivable", "Asset"],
|
||||||
|
["Stock Expenses", "Expenses", "", "", 0, "Stock Adjustment", "Expense"],
|
||||||
|
["Sample Bank", "Bank Accounts", "", "", 0, "Bank", "Asset"],
|
||||||
|
["Cash", "Cash In Hand", "", "", 0, "Cash", "Asset"],
|
||||||
|
["Stores", "Stock Assets", "", "", 0, "Stock", "Asset"],
|
||||||
|
]
|
||||||
|
|
||||||
|
for row in template:
|
||||||
|
writer.writerow(row)
|
||||||
|
|
||||||
return writer
|
return writer
|
||||||
|
|
||||||
@@ -446,11 +453,14 @@ def get_mandatory_account_types():
|
|||||||
|
|
||||||
|
|
||||||
def unset_existing_data(company):
|
def unset_existing_data(company):
|
||||||
# remove accounts data from company
|
linked = frappe.db.sql(
|
||||||
|
'''select fieldname from tabDocField
|
||||||
|
where fieldtype="Link" and options="Account" and parent="Company"''',
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
|
||||||
fieldnames = get_linked_fields("Account").get("Company", {}).get("fieldname", [])
|
# remove accounts data from company
|
||||||
linked = [{"fieldname": name} for name in fieldnames]
|
update_values = {d.fieldname: "" for d in linked}
|
||||||
update_values = {d.get("fieldname"): "" for d in linked}
|
|
||||||
frappe.db.set_value("Company", company, update_values, update_values)
|
frappe.db.set_value("Company", company, update_values, update_values)
|
||||||
|
|
||||||
# remove accounts data from various doctypes
|
# remove accounts data from various doctypes
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
Application Of Funds(Assets),,,,1,,Asset
|
|
||||||
Sources Of Funds(Liabilities),,,,1,,Liability
|
|
||||||
Equity,,,,1,,Equity
|
|
||||||
Expenses,,,,1,Expense Account,Expense
|
|
||||||
Income,,,,1,Income Account,Income
|
|
||||||
Bank Accounts,Application Of Funds(Assets),,,1,Bank,Asset
|
|
||||||
Cash In Hand,Application Of Funds(Assets),,,1,Cash,Asset
|
|
||||||
Stock Assets,Application Of Funds(Assets),,,1,Stock,Asset
|
|
||||||
Cost Of Goods Sold,Expenses,,,0,Cost of Goods Sold,Expense
|
|
||||||
Asset Depreciation,Expenses,,,0,Depreciation,Expense
|
|
||||||
Fixed Assets,Application Of Funds(Assets),,,0,Fixed Asset,Asset
|
|
||||||
Accounts Payable,Sources Of Funds(Liabilities),,,0,Payable,Liability
|
|
||||||
Accounts Receivable,Application Of Funds(Assets),,,1,Receivable,Asset
|
|
||||||
Stock Expenses,Expenses,,,0,Stock Adjustment,Expense
|
|
||||||
Sample Bank,Bank Accounts,,,0,Bank,Asset
|
|
||||||
Cash,Cash In Hand,,,0,Cash,Asset
|
|
||||||
Stores,Stock Assets,,,0,Stock,Asset
|
|
||||||
|
@@ -3,20 +3,18 @@
|
|||||||
|
|
||||||
frappe.provide("erpnext.cheque_print");
|
frappe.provide("erpnext.cheque_print");
|
||||||
|
|
||||||
frappe.ui.form.on("Cheque Print Template", {
|
frappe.ui.form.on('Cheque Print Template', {
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
if (!frm.doc.__islocal) {
|
if(!frm.doc.__islocal) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(frm.doc.has_print_format?__("Update Print Format"):__("Create Print Format"),
|
||||||
frm.doc.has_print_format ? __("Update Print Format") : __("Create Print Format"),
|
function() {
|
||||||
function () {
|
|
||||||
erpnext.cheque_print.view_cheque_print(frm);
|
erpnext.cheque_print.view_cheque_print(frm);
|
||||||
}
|
}).addClass("btn-primary");
|
||||||
).addClass("btn-primary");
|
|
||||||
|
|
||||||
$(frm.fields_dict.cheque_print_preview.wrapper).empty();
|
$(frm.fields_dict.cheque_print_preview.wrapper).empty()
|
||||||
|
|
||||||
var template =
|
|
||||||
'<div style="position: relative; overflow-x: scroll;">\
|
var template = '<div style="position: relative; overflow-x: scroll;">\
|
||||||
<div id="cheque_preview" style="width: {{ cheque_width }}cm; \
|
<div id="cheque_preview" style="width: {{ cheque_width }}cm; \
|
||||||
height: {{ cheque_height }}cm;\
|
height: {{ cheque_height }}cm;\
|
||||||
background-repeat: no-repeat;\
|
background-repeat: no-repeat;\
|
||||||
@@ -50,30 +48,30 @@ frappe.ui.form.on("Cheque Print Template", {
|
|||||||
</div>\
|
</div>\
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
$(frappe.render(template, frm.doc)).appendTo(frm.fields_dict.cheque_print_preview.wrapper);
|
$(frappe.render(template, frm.doc)).appendTo(frm.fields_dict.cheque_print_preview.wrapper)
|
||||||
|
|
||||||
if (frm.doc.scanned_cheque) {
|
if (frm.doc.scanned_cheque) {
|
||||||
$(frm.fields_dict.cheque_print_preview.wrapper)
|
$(frm.fields_dict.cheque_print_preview.wrapper).find("#cheque_preview").css('background-image', 'url(' + frm.doc.scanned_cheque + ')');
|
||||||
.find("#cheque_preview")
|
|
||||||
.css("background-image", "url(" + frm.doc.scanned_cheque + ")");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
erpnext.cheque_print.view_cheque_print = function (frm) {
|
|
||||||
|
erpnext.cheque_print.view_cheque_print = function(frm) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.cheque_print_template.cheque_print_template.create_or_update_cheque_print_format",
|
method: "erpnext.accounts.doctype.cheque_print_template.cheque_print_template.create_or_update_cheque_print_format",
|
||||||
args: {
|
args:{
|
||||||
template_name: frm.doc.name,
|
"template_name": frm.doc.name
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
if (!r.exe && !frm.doc.has_print_format) {
|
if (!r.exe && !frm.doc.has_print_format) {
|
||||||
var doc = frappe.model.sync(r.message);
|
var doc = frappe.model.sync(r.message);
|
||||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||||
} else {
|
|
||||||
frappe.msgprint(__("Print settings updated in respective print format"));
|
|
||||||
}
|
}
|
||||||
},
|
else {
|
||||||
});
|
frappe.msgprint(__("Print settings updated in respective print format"))
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,41 +8,6 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class ChequePrintTemplate(Document):
|
class ChequePrintTemplate(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
acc_no_dist_from_left_edge: DF.Float
|
|
||||||
acc_no_dist_from_top_edge: DF.Float
|
|
||||||
acc_pay_dist_from_left_edge: DF.Float
|
|
||||||
acc_pay_dist_from_top_edge: DF.Float
|
|
||||||
amt_in_figures_from_left_edge: DF.Float
|
|
||||||
amt_in_figures_from_top_edge: DF.Float
|
|
||||||
amt_in_word_width: DF.Float
|
|
||||||
amt_in_words_from_left_edge: DF.Float
|
|
||||||
amt_in_words_from_top_edge: DF.Float
|
|
||||||
amt_in_words_line_spacing: DF.Float
|
|
||||||
bank_name: DF.Data
|
|
||||||
cheque_height: DF.Float
|
|
||||||
cheque_size: DF.Literal["", "Regular", "A4"]
|
|
||||||
cheque_width: DF.Float
|
|
||||||
date_dist_from_left_edge: DF.Float
|
|
||||||
date_dist_from_top_edge: DF.Float
|
|
||||||
has_print_format: DF.Check
|
|
||||||
is_account_payable: DF.Check
|
|
||||||
message_to_show: DF.Data | None
|
|
||||||
payer_name_from_left_edge: DF.Float
|
|
||||||
payer_name_from_top_edge: DF.Float
|
|
||||||
scanned_cheque: DF.Attach | None
|
|
||||||
signatory_from_left_edge: DF.Float
|
|
||||||
signatory_from_top_edge: DF.Float
|
|
||||||
starting_position_from_top_edge: DF.Float
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class ClosedDocument(Document):
|
class ClosedDocument(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
closed: DF.Check
|
|
||||||
document_type: DF.Link
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,80 +3,75 @@
|
|||||||
|
|
||||||
frappe.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
|
|
||||||
frappe.ui.form.on("Cost Center", {
|
|
||||||
onload: function (frm) {
|
|
||||||
frm.set_query("parent_cost_center", function () {
|
frappe.ui.form.on('Cost Center', {
|
||||||
|
onload: function(frm) {
|
||||||
|
frm.set_query("parent_cost_center", function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
is_group: 1,
|
is_group: 1
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
if (!frm.is_new()) {
|
if (!frm.is_new()) {
|
||||||
frm.add_custom_button(__("Update Cost Center Name / Number"), function () {
|
frm.add_custom_button(__('Update Cost Center Name / Number'), function () {
|
||||||
frm.trigger("update_cost_center_number");
|
frm.trigger("update_cost_center_number");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let intro_txt = "";
|
let intro_txt = '';
|
||||||
let doc = frm.doc;
|
let doc = frm.doc;
|
||||||
frm.toggle_display("cost_center_name", doc.__islocal);
|
frm.toggle_display('cost_center_name', doc.__islocal);
|
||||||
frm.toggle_enable(["is_group", "company"], doc.__islocal);
|
frm.toggle_enable(['is_group', 'company'], doc.__islocal);
|
||||||
|
|
||||||
if (!doc.__islocal && doc.is_group == 1) {
|
if(!doc.__islocal && doc.is_group==1) {
|
||||||
intro_txt += __(
|
intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.');
|
||||||
"Note: This Cost Center is a Group. Cannot make accounting entries against groups."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.events.hide_unhide_group_ledger(frm);
|
frm.events.hide_unhide_group_ledger(frm);
|
||||||
|
|
||||||
frm.toggle_display("sb1", doc.is_group == 0);
|
frm.toggle_display('sb1', doc.is_group==0);
|
||||||
frm.set_intro(intro_txt);
|
frm.set_intro(intro_txt);
|
||||||
|
|
||||||
if (!frm.doc.__islocal) {
|
if(!frm.doc.__islocal) {
|
||||||
frm.add_custom_button(__("Chart of Cost Centers"), function () {
|
frm.add_custom_button(__('Chart of Cost Centers'),
|
||||||
frappe.set_route("Tree", "Cost Center");
|
function() { frappe.set_route("Tree", "Cost Center"); });
|
||||||
});
|
|
||||||
|
|
||||||
frm.add_custom_button(__("Budget"), function () {
|
frm.add_custom_button(__('Budget'),
|
||||||
frappe.set_route("List", "Budget", { cost_center: frm.doc.name });
|
function() { frappe.set_route("List", "Budget", {'cost_center': frm.doc.name}); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update_cost_center_number: function (frm) {
|
update_cost_center_number: function(frm) {
|
||||||
var d = new frappe.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title: __("Update Cost Center Name / Number"),
|
title: __('Update Cost Center Name / Number'),
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
label: "Cost Center Name",
|
"label": "Cost Center Name",
|
||||||
fieldname: "cost_center_name",
|
"fieldname": "cost_center_name",
|
||||||
fieldtype: "Data",
|
"fieldtype": "Data",
|
||||||
reqd: 1,
|
"reqd": 1,
|
||||||
default: frm.doc.cost_center_name,
|
"default": frm.doc.cost_center_name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Cost Center Number",
|
"label": "Cost Center Number",
|
||||||
fieldname: "cost_center_number",
|
"fieldname": "cost_center_number",
|
||||||
fieldtype: "Data",
|
"fieldtype": "Data",
|
||||||
default: frm.doc.cost_center_number,
|
"default": frm.doc.cost_center_number
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __("Merge with existing"),
|
"label": __("Merge with existing"),
|
||||||
fieldname: "merge",
|
"fieldname": "merge",
|
||||||
fieldtype: "Check",
|
"fieldtype": "Check",
|
||||||
default: 0,
|
"default": 0
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
primary_action: function () {
|
primary_action: function() {
|
||||||
let data = d.get_values();
|
let data = d.get_values();
|
||||||
if (
|
if(data.cost_center_name === frm.doc.cost_center_name && data.cost_center_number === frm.doc.cost_center_number) {
|
||||||
data.cost_center_name === frm.doc.cost_center_name &&
|
|
||||||
data.cost_center_number === frm.doc.cost_center_number
|
|
||||||
) {
|
|
||||||
d.hide();
|
d.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,12 +83,12 @@ frappe.ui.form.on("Cost Center", {
|
|||||||
cost_center_name: data.cost_center_name,
|
cost_center_name: data.cost_center_name,
|
||||||
cost_center_number: cstr(data.cost_center_number),
|
cost_center_number: cstr(data.cost_center_number),
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
merge: data.merge,
|
merge: data.merge
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
if (!r.exc) {
|
if(!r.exc) {
|
||||||
if (r.message) {
|
if(r.message) {
|
||||||
frappe.set_route("Form", "Cost Center", r.message);
|
frappe.set_route("Form", "Cost Center", r.message);
|
||||||
} else {
|
} else {
|
||||||
frm.set_value("cost_center_name", data.cost_center_name);
|
frm.set_value("cost_center_name", data.cost_center_name);
|
||||||
@@ -101,42 +96,44 @@ frappe.ui.form.on("Cost Center", {
|
|||||||
}
|
}
|
||||||
d.hide();
|
d.hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
primary_action_label: __("Update"),
|
primary_action_label: __('Update')
|
||||||
});
|
});
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
parent_cost_center(frm) {
|
parent_cost_center(frm) {
|
||||||
if (!frm.doc.company) {
|
if(!frm.doc.company) {
|
||||||
frappe.msgprint(__("Please enter company name first"));
|
frappe.msgprint(__('Please enter company name first'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hide_unhide_group_ledger(frm) {
|
hide_unhide_group_ledger(frm) {
|
||||||
let doc = frm.doc;
|
let doc = frm.doc;
|
||||||
if (doc.is_group == 1) {
|
if (doc.is_group == 1) {
|
||||||
frm.add_custom_button(__("Convert to Non-Group"), () => frm.events.convert_to_ledger(frm));
|
frm.add_custom_button(__('Convert to Non-Group'),
|
||||||
|
() => frm.events.convert_to_ledger(frm));
|
||||||
} else if (doc.is_group == 0) {
|
} else if (doc.is_group == 0) {
|
||||||
frm.add_custom_button(__("Convert to Group"), () => frm.events.convert_to_group(frm));
|
frm.add_custom_button(__('Convert to Group'),
|
||||||
|
() => frm.events.convert_to_group(frm));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
convert_to_group(frm) {
|
convert_to_group(frm) {
|
||||||
frm.call("convert_ledger_to_group").then((r) => {
|
frm.call('convert_ledger_to_group').then(r => {
|
||||||
if (r.message === 1) {
|
if(r.message === 1) {
|
||||||
frm.refresh();
|
frm.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
convert_to_ledger(frm) {
|
convert_to_ledger(frm) {
|
||||||
frm.call("convert_group_to_ledger").then((r) => {
|
frm.call('convert_group_to_ledger').then(r => {
|
||||||
if (r.message === 1) {
|
if(r.message === 1) {
|
||||||
frm.refresh();
|
frm.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Cost Center Number",
|
"label": "Cost Center Number",
|
||||||
"read_only_depends_on": "eval:!doc.__islocal"
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "parent_cost_center",
|
"fieldname": "parent_cost_center",
|
||||||
@@ -170,4 +170,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "ASC",
|
"sort_order": "ASC",
|
||||||
"states": []
|
"states": []
|
||||||
}
|
}
|
||||||
@@ -10,25 +10,6 @@ from erpnext.accounts.utils import validate_field_number
|
|||||||
|
|
||||||
|
|
||||||
class CostCenter(NestedSet):
|
class CostCenter(NestedSet):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
company: DF.Link
|
|
||||||
cost_center_name: DF.Data
|
|
||||||
cost_center_number: DF.Data | None
|
|
||||||
disabled: DF.Check
|
|
||||||
is_group: DF.Check
|
|
||||||
lft: DF.Int
|
|
||||||
old_parent: DF.Link | None
|
|
||||||
parent_cost_center: DF.Link
|
|
||||||
rgt: DF.Int
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
nsm_parent_field = "parent_cost_center"
|
nsm_parent_field = "parent_cost_center"
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
|
|||||||
@@ -1,84 +1,54 @@
|
|||||||
frappe.treeview_settings["Cost Center"] = {
|
frappe.treeview_settings["Cost Center"] = {
|
||||||
breadcrumb: "Accounts",
|
breadcrumb: "Accounts",
|
||||||
get_tree_root: false,
|
get_tree_root: false,
|
||||||
filters: [
|
filters: [{
|
||||||
{
|
fieldname: "company",
|
||||||
fieldname: "company",
|
fieldtype:"Select",
|
||||||
fieldtype: "Select",
|
options: erpnext.utils.get_tree_options("company"),
|
||||||
options: erpnext.utils.get_tree_options("company"),
|
label: __("Company"),
|
||||||
label: __("Company"),
|
default: erpnext.utils.get_tree_default("company")
|
||||||
default: erpnext.utils.get_tree_default("company"),
|
}],
|
||||||
},
|
|
||||||
],
|
|
||||||
root_label: "Cost Centers",
|
root_label: "Cost Centers",
|
||||||
get_tree_nodes: "erpnext.accounts.utils.get_children",
|
get_tree_nodes: 'erpnext.accounts.utils.get_children',
|
||||||
add_tree_node: "erpnext.accounts.utils.add_cc",
|
add_tree_node: 'erpnext.accounts.utils.add_cc',
|
||||||
menu_items: [
|
menu_items:[
|
||||||
{
|
{
|
||||||
label: __("New Company"),
|
label: __('New Company'),
|
||||||
action: function () {
|
action: function() { frappe.new_doc("Company", true) },
|
||||||
frappe.new_doc("Company", true);
|
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1'
|
||||||
},
|
}
|
||||||
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
fields: [
|
fields:[
|
||||||
{ fieldtype: "Data", fieldname: "cost_center_name", label: __("New Cost Center Name"), reqd: true },
|
{fieldtype:'Data', fieldname:'cost_center_name', label:__('New Cost Center Name'), reqd:true},
|
||||||
{
|
{fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
|
||||||
fieldtype: "Check",
|
description:__('Further cost centers can be made under Groups but entries can be made against non-Groups')},
|
||||||
fieldname: "is_group",
|
{fieldtype:'Data', fieldname:'cost_center_number', label:__('Cost Center Number'),
|
||||||
label: __("Is Group"),
|
description: __("Number of new Cost Center, it will be included in the cost center name as a prefix")}
|
||||||
description: __(
|
|
||||||
"Further cost centers can be made under Groups but entries can be made against non-Groups"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldtype: "Data",
|
|
||||||
fieldname: "cost_center_number",
|
|
||||||
label: __("Cost Center Number"),
|
|
||||||
description: __(
|
|
||||||
"Number of new Cost Center, it will be included in the cost center name as a prefix"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
ignore_fields: ["parent_cost_center"],
|
ignore_fields:["parent_cost_center"],
|
||||||
onload: function (treeview) {
|
onload: function(treeview) {
|
||||||
function get_company() {
|
function get_company() {
|
||||||
return treeview.page.fields_dict.company.get_value();
|
return treeview.page.fields_dict.company.get_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Chart of Accounts"), function() {
|
||||||
__("Chart of Accounts"),
|
frappe.set_route('Tree', 'Account', {company: get_company()});
|
||||||
function () {
|
}, __('View'));
|
||||||
frappe.set_route("Tree", "Account", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("View")
|
|
||||||
);
|
|
||||||
|
|
||||||
// make
|
// make
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Budget List"), function() {
|
||||||
__("Budget List"),
|
frappe.set_route('List', 'Budget', {company: get_company()});
|
||||||
function () {
|
}, __('Budget'));
|
||||||
frappe.set_route("List", "Budget", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("Budget")
|
|
||||||
);
|
|
||||||
|
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Monthly Distribution"), function() {
|
||||||
__("Monthly Distribution"),
|
frappe.set_route('List', 'Monthly Distribution', {company: get_company()});
|
||||||
function () {
|
}, __('Budget'));
|
||||||
frappe.set_route("List", "Monthly Distribution", { company: get_company() });
|
|
||||||
},
|
|
||||||
__("Budget")
|
|
||||||
);
|
|
||||||
|
|
||||||
treeview.page.add_inner_button(
|
treeview.page.add_inner_button(__("Budget Variance Report"), function() {
|
||||||
__("Budget Variance Report"),
|
frappe.set_route('query-report', 'Budget Variance Report', {company: get_company()});
|
||||||
function () {
|
}, __('Budget'));
|
||||||
frappe.set_route("query-report", "Budget Variance Report", { company: get_company() });
|
|
||||||
},
|
}
|
||||||
__("Budget")
|
|
||||||
);
|
}
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Cost Center Allocation", {
|
frappe.ui.form.on('Cost Center Allocation', {
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("main_cost_center", function () {
|
let filters = {"is_group": 0};
|
||||||
return {
|
if (frm.doc.company) {
|
||||||
filters: {
|
$.extend(filters, {
|
||||||
company: frm.doc.company,
|
"company": frm.doc.company
|
||||||
is_group: 0,
|
});
|
||||||
},
|
}
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
frm.set_query("cost_center", "allocation_percentages", function () {
|
frm.set_query('main_cost_center', function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: filters
|
||||||
company: frm.doc.company,
|
|
||||||
is_group: 0,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,25 +28,6 @@ class InvalidDateError(frappe.ValidationError):
|
|||||||
|
|
||||||
|
|
||||||
class CostCenterAllocation(Document):
|
class CostCenterAllocation(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.cost_center_allocation_percentage.cost_center_allocation_percentage import (
|
|
||||||
CostCenterAllocationPercentage,
|
|
||||||
)
|
|
||||||
|
|
||||||
allocation_percentages: DF.Table[CostCenterAllocationPercentage]
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
company: DF.Link
|
|
||||||
main_cost_center: DF.Link
|
|
||||||
valid_from: DF.Date
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(CostCenterAllocation, self).__init__(*args, **kwargs)
|
super(CostCenterAllocation, self).__init__(*args, **kwargs)
|
||||||
self._skip_from_date_validation = False
|
self._skip_from_date_validation = False
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CostCenterAllocationPercentage(Document):
|
class CostCenterAllocationPercentage(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
cost_center: DF.Link
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
percentage: DF.Percent
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,41 +1,44 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Coupon Code", {
|
frappe.ui.form.on('Coupon Code', {
|
||||||
setup: function (frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("pricing_rule", function () {
|
frm.set_query("pricing_rule", function() {
|
||||||
return {
|
return {
|
||||||
filters: [["Pricing Rule", "coupon_code_based", "=", "1"]],
|
filters: [
|
||||||
|
["Pricing Rule","coupon_code_based", "=", "1"]
|
||||||
|
]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
coupon_name: function (frm) {
|
coupon_name:function(frm){
|
||||||
if (frm.doc.__islocal === 1) {
|
if (frm.doc.__islocal===1) {
|
||||||
frm.trigger("make_coupon_code");
|
frm.trigger("make_coupon_code");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coupon_type: function (frm) {
|
coupon_type:function(frm){
|
||||||
if (frm.doc.__islocal === 1) {
|
if (frm.doc.__islocal===1) {
|
||||||
frm.trigger("make_coupon_code");
|
frm.trigger("make_coupon_code");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
make_coupon_code: function (frm) {
|
make_coupon_code: function(frm) {
|
||||||
var coupon_name = frm.doc.coupon_name;
|
var coupon_name=frm.doc.coupon_name;
|
||||||
var coupon_code;
|
var coupon_code;
|
||||||
if (frm.doc.coupon_type == "Gift Card") {
|
if (frm.doc.coupon_type=='Gift Card') {
|
||||||
coupon_code = Math.random().toString(12).substring(2, 12).toUpperCase();
|
coupon_code=Math.random().toString(12).substring(2, 12).toUpperCase();
|
||||||
} else if (frm.doc.coupon_type == "Promotional") {
|
|
||||||
coupon_name = coupon_name.replace(/\s/g, "");
|
|
||||||
coupon_code = coupon_name.toUpperCase().slice(0, 8);
|
|
||||||
}
|
}
|
||||||
frm.doc.coupon_code = coupon_code;
|
else if(frm.doc.coupon_type=='Promotional'){
|
||||||
frm.refresh_field("coupon_code");
|
coupon_name=coupon_name.replace(/\s/g,'');
|
||||||
|
coupon_code=coupon_name.toUpperCase().slice(0,8);
|
||||||
|
}
|
||||||
|
frm.doc.coupon_code=coupon_code;
|
||||||
|
frm.refresh_field('coupon_code');
|
||||||
},
|
},
|
||||||
refresh: function (frm) {
|
refresh: function(frm) {
|
||||||
if (frm.doc.pricing_rule) {
|
if (frm.doc.pricing_rule) {
|
||||||
frm.add_custom_button(__("Add/Edit Coupon Conditions"), function () {
|
frm.add_custom_button(__("Add/Edit Coupon Conditions"), function(){
|
||||||
frappe.set_route("Form", "Pricing Rule", frm.doc.pricing_rule);
|
frappe.set_route("Form", "Pricing Rule", frm.doc.pricing_rule);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,27 +9,6 @@ from frappe.utils import strip
|
|||||||
|
|
||||||
|
|
||||||
class CouponCode(Document):
|
class CouponCode(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
coupon_code: DF.Data | None
|
|
||||||
coupon_name: DF.Data
|
|
||||||
coupon_type: DF.Literal["Promotional", "Gift Card"]
|
|
||||||
customer: DF.Link | None
|
|
||||||
description: DF.TextEditor | None
|
|
||||||
maximum_use: DF.Int
|
|
||||||
pricing_rule: DF.Link
|
|
||||||
used: DF.Int
|
|
||||||
valid_from: DF.Date | None
|
|
||||||
valid_upto: DF.Date | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.coupon_name = strip(self.coupon_name)
|
self.coupon_name = strip(self.coupon_name)
|
||||||
self.name = self.coupon_name
|
self.name = self.coupon_name
|
||||||
|
|||||||
@@ -1,27 +1,28 @@
|
|||||||
// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Currency Exchange Settings", {
|
frappe.ui.form.on('Currency Exchange Settings', {
|
||||||
service_provider: function (frm) {
|
service_provider: function(frm) {
|
||||||
if (frm.doc.service_provider == "exchangerate.host") {
|
if (frm.doc.service_provider == "exchangerate.host") {
|
||||||
let result = ["result"];
|
let result = ['result'];
|
||||||
let params = {
|
let params = {
|
||||||
date: "{transaction_date}",
|
date: '{transaction_date}',
|
||||||
from: "{from_currency}",
|
from: '{from_currency}',
|
||||||
to: "{to_currency}",
|
to: '{to_currency}'
|
||||||
};
|
};
|
||||||
add_param(frm, "https://api.exchangerate.host/convert", params, result);
|
add_param(frm, "https://api.exchangerate.host/convert", params, result);
|
||||||
} else if (frm.doc.service_provider == "frankfurter.app") {
|
} else if (frm.doc.service_provider == "frankfurter.app") {
|
||||||
let result = ["rates", "{to_currency}"];
|
let result = ['rates', '{to_currency}'];
|
||||||
let params = {
|
let params = {
|
||||||
base: "{from_currency}",
|
base: '{from_currency}',
|
||||||
symbols: "{to_currency}",
|
symbols: '{to_currency}'
|
||||||
};
|
};
|
||||||
add_param(frm, "https://frankfurter.app/{transaction_date}", params, result);
|
add_param(frm, "https://frankfurter.app/{transaction_date}", params, result);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function add_param(frm, api, params, result) {
|
function add_param(frm, api, params, result) {
|
||||||
var row;
|
var row;
|
||||||
frm.clear_table("req_params");
|
frm.clear_table("req_params");
|
||||||
@@ -29,13 +30,13 @@ function add_param(frm, api, params, result) {
|
|||||||
|
|
||||||
frm.doc.api_endpoint = api;
|
frm.doc.api_endpoint = api;
|
||||||
|
|
||||||
$.each(params, function (key, value) {
|
$.each(params, function(key, value) {
|
||||||
row = frm.add_child("req_params");
|
row = frm.add_child("req_params");
|
||||||
row.key = key;
|
row.key = key;
|
||||||
row.value = value;
|
row.value = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each(result, function (key, value) {
|
$.each(result, function(key, value) {
|
||||||
row = frm.add_child("result_key");
|
row = frm.add_child("result_key");
|
||||||
row.key = value;
|
row.key = value;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,30 +9,6 @@ from frappe.utils import nowdate
|
|||||||
|
|
||||||
|
|
||||||
class CurrencyExchangeSettings(Document):
|
class CurrencyExchangeSettings(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.currency_exchange_settings_details.currency_exchange_settings_details import (
|
|
||||||
CurrencyExchangeSettingsDetails,
|
|
||||||
)
|
|
||||||
from erpnext.accounts.doctype.currency_exchange_settings_result.currency_exchange_settings_result import (
|
|
||||||
CurrencyExchangeSettingsResult,
|
|
||||||
)
|
|
||||||
|
|
||||||
access_key: DF.Data | None
|
|
||||||
api_endpoint: DF.Data
|
|
||||||
disabled: DF.Check
|
|
||||||
req_params: DF.Table[CurrencyExchangeSettingsDetails]
|
|
||||||
result_key: DF.Table[CurrencyExchangeSettingsResult]
|
|
||||||
service_provider: DF.Literal["frankfurter.app", "exchangerate.host", "Custom"]
|
|
||||||
url: DF.Data | None
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_parameters_and_result()
|
self.set_parameters_and_result()
|
||||||
if frappe.flags.in_test or frappe.flags.in_install or frappe.flags.in_setup_wizard:
|
if frappe.flags.in_test or frappe.flags.in_install or frappe.flags.in_setup_wizard:
|
||||||
|
|||||||
@@ -6,19 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CurrencyExchangeSettingsDetails(Document):
|
class CurrencyExchangeSettingsDetails(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
key: DF.Data
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
value: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,18 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CurrencyExchangeSettingsResult(Document):
|
class CurrencyExchangeSettingsResult(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
key: DF.Data
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,18 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CustomerGroupItem(Document):
|
class CustomerGroupItem(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
customer_group: DF.Link | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,18 +6,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CustomerItem(Document):
|
class CustomerItem(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
customer: DF.Link | None
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -7,22 +7,4 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class DiscountedInvoice(Document):
|
class DiscountedInvoice(Document):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
customer: DF.Link | None
|
|
||||||
debit_to: DF.Link | None
|
|
||||||
outstanding_amount: DF.Currency
|
|
||||||
parent: DF.Data
|
|
||||||
parentfield: DF.Data
|
|
||||||
parenttype: DF.Data
|
|
||||||
posting_date: DF.Date | None
|
|
||||||
sales_invoice: DF.Link
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ frappe.ui.form.on("Dunning", {
|
|||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
customer: frm.doc.customer,
|
customer: frm.doc.customer,
|
||||||
outstanding_amount: [">", 0],
|
outstanding_amount: [">", 0],
|
||||||
status: "Overdue",
|
status: "Overdue"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -19,16 +19,16 @@ frappe.ui.form.on("Dunning", {
|
|||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
root_type: "Income",
|
root_type: "Income",
|
||||||
is_group: 0,
|
is_group: 0
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
frm.set_query("cost_center", () => {
|
frm.set_query("cost_center", () => {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
is_group: 0,
|
is_group: 0
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,8 +51,7 @@ frappe.ui.form.on("Dunning", {
|
|||||||
__("Payment"),
|
__("Payment"),
|
||||||
function () {
|
function () {
|
||||||
frm.events.make_payment_entry(frm);
|
frm.events.make_payment_entry(frm);
|
||||||
},
|
}, __("Create")
|
||||||
__("Create")
|
|
||||||
);
|
);
|
||||||
frm.page.set_inner_btn_group_as_primary(__("Create"));
|
frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
}
|
}
|
||||||
@@ -70,7 +69,7 @@ frappe.ui.form.on("Dunning", {
|
|||||||
get_query_filters: {
|
get_query_filters: {
|
||||||
docstatus: 1,
|
docstatus: 1,
|
||||||
status: "Overdue",
|
status: "Overdue",
|
||||||
company: frm.doc.company,
|
company: frm.doc.company
|
||||||
},
|
},
|
||||||
allow_child_item_selection: true,
|
allow_child_item_selection: true,
|
||||||
child_fieldname: "payment_schedule",
|
child_fieldname: "payment_schedule",
|
||||||
@@ -79,12 +78,9 @@ frappe.ui.form.on("Dunning", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.dynamic_link = { doc: frm.doc, fieldname: "customer", doctype: "Customer" };
|
frappe.dynamic_link = { doc: frm.doc, fieldname: 'customer', doctype: 'Customer' };
|
||||||
|
|
||||||
frm.toggle_display(
|
frm.toggle_display("customer_name", (frm.doc.customer_name && frm.doc.customer_name !== frm.doc.customer));
|
||||||
"customer_name",
|
|
||||||
frm.doc.customer_name && frm.doc.customer_name !== frm.doc.customer
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
// When multiple companies are set up. in case company name is changed set default company address
|
// When multiple companies are set up. in case company name is changed set default company address
|
||||||
company: function (frm) {
|
company: function (frm) {
|
||||||
@@ -94,8 +90,8 @@ frappe.ui.form.on("Dunning", {
|
|||||||
args: { name: frm.doc.company, existing_address: frm.doc.company_address || "" },
|
args: { name: frm.doc.company, existing_address: frm.doc.company_address || "" },
|
||||||
debounce: 2000,
|
debounce: 2000,
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
frm.set_value("company_address", (r && r.message) || "");
|
frm.set_value("company_address", r && r.message || "");
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (frm.fields_dict.currency) {
|
if (frm.fields_dict.currency) {
|
||||||
@@ -129,16 +125,16 @@ frappe.ui.form.on("Dunning", {
|
|||||||
transaction_date: frm.doc.posting_date,
|
transaction_date: frm.doc.posting_date,
|
||||||
from_currency: frm.doc.currency,
|
from_currency: frm.doc.currency,
|
||||||
to_currency: company_currency,
|
to_currency: company_currency,
|
||||||
args: "for_selling",
|
args: "for_selling"
|
||||||
},
|
},
|
||||||
freeze: true,
|
freeze: true,
|
||||||
freeze_message: __("Fetching exchange rates ..."),
|
freeze_message: __("Fetching exchange rates ..."),
|
||||||
callback: function (r) {
|
callback: function(r) {
|
||||||
const exchange_rate = flt(r.message);
|
const exchange_rate = flt(r.message);
|
||||||
if (exchange_rate != frm.doc.conversion_rate) {
|
if (exchange_rate != frm.doc.conversion_rate) {
|
||||||
frm.set_value("conversion_rate", exchange_rate);
|
frm.set_value("conversion_rate", exchange_rate);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
frm.trigger("conversion_rate");
|
frm.trigger("conversion_rate");
|
||||||
@@ -170,7 +166,8 @@ frappe.ui.form.on("Dunning", {
|
|||||||
get_dunning_letter_text: function (frm) {
|
get_dunning_letter_text: function (frm) {
|
||||||
if (frm.doc.dunning_type) {
|
if (frm.doc.dunning_type) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.dunning.dunning.get_dunning_letter_text",
|
method:
|
||||||
|
"erpnext.accounts.doctype.dunning.dunning.get_dunning_letter_text",
|
||||||
args: {
|
args: {
|
||||||
dunning_type: frm.doc.dunning_type,
|
dunning_type: frm.doc.dunning_type,
|
||||||
language: frm.doc.language,
|
language: frm.doc.language,
|
||||||
@@ -207,7 +204,10 @@ frappe.ui.form.on("Dunning", {
|
|||||||
calculate_overdue_days: function (frm) {
|
calculate_overdue_days: function (frm) {
|
||||||
frm.doc.overdue_payments.forEach((row) => {
|
frm.doc.overdue_payments.forEach((row) => {
|
||||||
if (frm.doc.posting_date && row.due_date) {
|
if (frm.doc.posting_date && row.due_date) {
|
||||||
const overdue_days = moment(frm.doc.posting_date).diff(row.due_date, "days");
|
const overdue_days = moment(frm.doc.posting_date).diff(
|
||||||
|
row.due_date,
|
||||||
|
"days"
|
||||||
|
);
|
||||||
frappe.model.set_value(row.doctype, row.name, "overdue_days", overdue_days);
|
frappe.model.set_value(row.doctype, row.name, "overdue_days", overdue_days);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -215,16 +215,15 @@ frappe.ui.form.on("Dunning", {
|
|||||||
calculate_interest: function (frm) {
|
calculate_interest: function (frm) {
|
||||||
frm.doc.overdue_payments.forEach((row) => {
|
frm.doc.overdue_payments.forEach((row) => {
|
||||||
const interest_per_day = frm.doc.rate_of_interest / 100 / 365;
|
const interest_per_day = frm.doc.rate_of_interest / 100 / 365;
|
||||||
const interest = flt(
|
const interest = flt((interest_per_day * row.overdue_days * row.outstanding), precision("interest", row));
|
||||||
interest_per_day * row.overdue_days * row.outstanding,
|
|
||||||
precision("interest", row)
|
|
||||||
);
|
|
||||||
frappe.model.set_value(row.doctype, row.name, "interest", interest);
|
frappe.model.set_value(row.doctype, row.name, "interest", interest);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
calculate_totals: function (frm) {
|
calculate_totals: function (frm) {
|
||||||
const total_interest = frm.doc.overdue_payments.reduce((prev, cur) => prev + cur.interest, 0);
|
const total_interest = frm.doc.overdue_payments
|
||||||
const total_outstanding = frm.doc.overdue_payments.reduce((prev, cur) => prev + cur.outstanding, 0);
|
.reduce((prev, cur) => prev + cur.interest, 0);
|
||||||
|
const total_outstanding = frm.doc.overdue_payments
|
||||||
|
.reduce((prev, cur) => prev + cur.outstanding, 0);
|
||||||
const dunning_amount = total_interest + frm.doc.dunning_fee;
|
const dunning_amount = total_interest + frm.doc.dunning_fee;
|
||||||
const base_dunning_amount = dunning_amount * frm.doc.conversion_rate;
|
const base_dunning_amount = dunning_amount * frm.doc.conversion_rate;
|
||||||
const grand_total = total_outstanding + dunning_amount;
|
const grand_total = total_outstanding + dunning_amount;
|
||||||
@@ -241,7 +240,8 @@ frappe.ui.form.on("Dunning", {
|
|||||||
},
|
},
|
||||||
make_payment_entry: function (frm) {
|
make_payment_entry: function (frm) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry",
|
method:
|
||||||
|
"erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry",
|
||||||
args: {
|
args: {
|
||||||
dt: frm.doc.doctype,
|
dt: frm.doc.doctype,
|
||||||
dn: frm.doc.name,
|
dn: frm.doc.name,
|
||||||
@@ -257,5 +257,5 @@ frappe.ui.form.on("Dunning", {
|
|||||||
frappe.ui.form.on("Overdue Payment", {
|
frappe.ui.form.on("Overdue Payment", {
|
||||||
interest: function (frm) {
|
interest: function (frm) {
|
||||||
frm.trigger("calculate_totals");
|
frm.trigger("calculate_totals");
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
@@ -22,52 +22,6 @@ from erpnext.controllers.accounts_controller import AccountsController
|
|||||||
|
|
||||||
|
|
||||||
class Dunning(AccountsController):
|
class Dunning(AccountsController):
|
||||||
# begin: auto-generated types
|
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from frappe.types import DF
|
|
||||||
|
|
||||||
from erpnext.accounts.doctype.overdue_payment.overdue_payment import OverduePayment
|
|
||||||
|
|
||||||
address_display: DF.SmallText | None
|
|
||||||
amended_from: DF.Link | None
|
|
||||||
base_dunning_amount: DF.Currency
|
|
||||||
body_text: DF.TextEditor | None
|
|
||||||
closing_text: DF.TextEditor | None
|
|
||||||
company: DF.Link
|
|
||||||
company_address: DF.Link | None
|
|
||||||
company_address_display: DF.SmallText | None
|
|
||||||
contact_display: DF.SmallText | None
|
|
||||||
contact_email: DF.Data | None
|
|
||||||
contact_mobile: DF.SmallText | None
|
|
||||||
contact_person: DF.Link | None
|
|
||||||
conversion_rate: DF.Float
|
|
||||||
cost_center: DF.Link | None
|
|
||||||
currency: DF.Link | None
|
|
||||||
customer: DF.Link
|
|
||||||
customer_address: DF.Link | None
|
|
||||||
customer_name: DF.Data | None
|
|
||||||
dunning_amount: DF.Currency
|
|
||||||
dunning_fee: DF.Currency
|
|
||||||
dunning_type: DF.Link | None
|
|
||||||
grand_total: DF.Currency
|
|
||||||
income_account: DF.Link | None
|
|
||||||
language: DF.Link | None
|
|
||||||
letter_head: DF.Link | None
|
|
||||||
naming_series: DF.Literal["DUNN-.MM.-.YY.-"]
|
|
||||||
overdue_payments: DF.Table[OverduePayment]
|
|
||||||
posting_date: DF.Date
|
|
||||||
posting_time: DF.Time | None
|
|
||||||
rate_of_interest: DF.Float
|
|
||||||
spacer: DF.Data | None
|
|
||||||
status: DF.Literal["Draft", "Resolved", "Unresolved", "Cancelled"]
|
|
||||||
total_interest: DF.Currency
|
|
||||||
total_outstanding: DF.Currency
|
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_same_currency()
|
self.validate_same_currency()
|
||||||
self.validate_overdue_payments()
|
self.validate_overdue_payments()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user