diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 566323a9e9..6eaf9ccec6 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -16,3 +16,7 @@ # Whitespace fix throughout codebase 4551d7d6029b6f587f6c99d4f8df5519241c6a86 +b147b85e6ac19a9220cd1e2958a6ebd99373283a + +# sort and cleanup imports +915b34391c2066dfc83e60a5813c5a877cebe7ac diff --git a/.github/helper/.flake8_strict b/.github/helper/.flake8_strict new file mode 100644 index 0000000000..4c7f5f82cf --- /dev/null +++ b/.github/helper/.flake8_strict @@ -0,0 +1,70 @@ +[flake8] +ignore = + B007, + B950, + E101, + E111, + E114, + E116, + E117, + E121, + E122, + E123, + E124, + E125, + E126, + E127, + E128, + E131, + E201, + E202, + E203, + E211, + E221, + E222, + E223, + E224, + E225, + E226, + E228, + E231, + E241, + E242, + E251, + E261, + E262, + E265, + E266, + E271, + E272, + E273, + E274, + E301, + E302, + E303, + E305, + E306, + E402, + E501, + E502, + E701, + E702, + E703, + E741, + F403, + W191, + W291, + W292, + W293, + W391, + W503, + W504, + E711, + E129, + F841, + E713, + E712, + + +max-line-length = 200 +exclude=.github/helper/semgrep_rules,test_*.py diff --git a/.github/helper/semgrep_rules/frappe_correctness.py b/.github/helper/semgrep_rules/frappe_correctness.py index 745e6463b8..83d4acfe4a 100644 --- a/.github/helper/semgrep_rules/frappe_correctness.py +++ b/.github/helper/semgrep_rules/frappe_correctness.py @@ -1,5 +1,5 @@ import frappe -from frappe import _, flt +from frappe import _ from frappe.model.document import Document diff --git a/.github/helper/semgrep_rules/report.py b/.github/helper/semgrep_rules/report.py new file mode 100644 index 0000000000..ff278408e1 --- /dev/null +++ b/.github/helper/semgrep_rules/report.py @@ -0,0 +1,15 @@ +from frappe import _ + + +# ruleid: frappe-missing-translate-function-in-report-python +{"label": "Field Label"} + +# ruleid: frappe-missing-translate-function-in-report-python +dict(label="Field Label") + + +# ok: frappe-missing-translate-function-in-report-python +{"label": _("Field Label")} + +# ok: frappe-missing-translate-function-in-report-python +dict(label=_("Field Label")) diff --git a/.github/helper/semgrep_rules/report.yml b/.github/helper/semgrep_rules/report.yml new file mode 100644 index 0000000000..7f3dd011dc --- /dev/null +++ b/.github/helper/semgrep_rules/report.yml @@ -0,0 +1,21 @@ +rules: +- id: frappe-missing-translate-function-in-report-python + paths: + include: + - "**/report" + exclude: + - "**/regional" + pattern-either: + - patterns: + - pattern: | + {..., "label": "...", ...} + - pattern-not: | + {..., "label": _("..."), ...} + - patterns: + - pattern: dict(..., label="...", ...) + - pattern-not: dict(..., label=_("..."), ...) + message: | + All user facing text must be wrapped in translate function. Please refer to translation documentation. https://frappeframework.com/docs/user/en/guides/basics/translations + languages: [python] + severity: ERROR + diff --git a/.github/workflows/semgrep.yml b/.github/workflows/linters.yml similarity index 56% rename from .github/workflows/semgrep.yml rename to .github/workflows/linters.yml index e27b406df0..16e490a460 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/linters.yml @@ -1,11 +1,12 @@ -name: Semgrep +name: Linters on: pull_request: { } jobs: - semgrep: - name: Frappe Linter + + linters: + name: linters runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -16,3 +17,11 @@ jobs: config: >- r/python.lang.correctness .github/helper/semgrep_rules + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install and Run Pre-commit + uses: pre-commit/action@v2.0.3 diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index f65b0001fe..92a19621d1 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -7,10 +7,13 @@ on: - '**.md' workflow_dispatch: +concurrency: + group: patch-develop-${{ github.event.number }} + cancel-in-progress: true jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest timeout-minutes: 60 name: Patch Test diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index 0a73d74d6b..71e9c2cd13 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -12,9 +12,13 @@ on: - '**.js' - '**.md' +concurrency: + group: server-develop-${{ github.event.number }} + cancel-in-progress: true + jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest timeout-minutes: 60 strategy: @@ -113,7 +117,7 @@ jobs: name: Coverage Wrap Up needs: test container: python:3-slim - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v2 diff --git a/.github/workflows/translation_linter.yml b/.github/workflows/translation_linter.yml deleted file mode 100644 index 4becaebd6b..0000000000 --- a/.github/workflows/translation_linter.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Frappe Linter -on: - pull_request: - branches: - - develop - - version-12-hotfix - - version-11-hotfix -jobs: - check_translation: - name: Translation Syntax Check - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - name: Setup python3 - uses: actions/setup-python@v1 - with: - python-version: 3.6 - - name: Validating Translation Syntax - run: | - git fetch origin $GITHUB_BASE_REF:$GITHUB_BASE_REF -q - files=$(git diff --name-only --diff-filter=d $GITHUB_BASE_REF) - python $GITHUB_WORKSPACE/.github/helper/translation.py $files diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml index 0ece0d8ee6..658892c20e 100644 --- a/.github/workflows/ui-tests.yml +++ b/.github/workflows/ui-tests.yml @@ -6,9 +6,13 @@ on: - '**.md' workflow_dispatch: +concurrency: + group: ui-develop-${{ github.event.number }} + cancel-in-progress: true + jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest timeout-minutes: 60 strategy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..2b3a471f77 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +exclude: 'node_modules|.git' +default_stages: [commit] +fail_fast: false + + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + files: "erpnext.*" + exclude: ".*json$|.*txt$|.*csv|.*md" + - id: check-yaml + - id: no-commit-to-branch + args: ['--branch', 'develop'] + - id: check-merge-conflict + - id: check-ast + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + args: ['--config', '.github/helper/.flake8_strict'] + exclude: ".*setup.py$" + + - repo: https://github.com/timothycrosley/isort + rev: 5.9.1 + hooks: + - id: isort + exclude: ".*setup.py$" + +ci: + autoupdate_schedule: weekly + skip: [] + submodules: false diff --git a/cypress/integration/test_organizational_chart_desktop.js b/cypress/integration/test_organizational_chart_desktop.js index 820a23a207..39b00d3263 100644 --- a/cypress/integration/test_organizational_chart_desktop.js +++ b/cypress/integration/test_organizational_chart_desktop.js @@ -2,8 +2,11 @@ context('Organizational Chart', () => { before(() => { cy.login(); cy.visit('/app/website'); + }); + + it('navigates to org chart', () => { + cy.visit('/app'); cy.awesomebar('Organizational Chart'); - cy.wait(500); cy.url().should('include', '/organizational-chart'); cy.window().its('frappe.csrf_token').then(csrf_token => { diff --git a/cypress/integration/test_organizational_chart_mobile.js b/cypress/integration/test_organizational_chart_mobile.js index df90dbfa22..6e75151396 100644 --- a/cypress/integration/test_organizational_chart_mobile.js +++ b/cypress/integration/test_organizational_chart_mobile.js @@ -1,9 +1,14 @@ context('Organizational Chart Mobile', () => { before(() => { cy.login(); - cy.viewport(375, 667); cy.visit('/app/website'); + }); + + it('navigates to org chart', () => { + cy.viewport(375, 667); + cy.visit('/app'); cy.awesomebar('Organizational Chart'); + cy.url().should('include', '/organizational-chart'); cy.window().its('frappe.csrf_token').then(csrf_token => { return cy.request({ diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 17d650568a..45218276f6 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals + import inspect + import frappe + from erpnext.hooks import regional_overrides -from frappe.utils import getdate __version__ = '13.9.0' diff --git a/erpnext/accounts/custom/address.py b/erpnext/accounts/custom/address.py index 834227bb58..a6d08d8ff6 100644 --- a/erpnext/accounts/custom/address.py +++ b/erpnext/accounts/custom/address.py @@ -1,7 +1,11 @@ import frappe from frappe import _ -from frappe.contacts.doctype.address.address import Address -from frappe.contacts.doctype.address.address import get_address_templates, get_address_display +from frappe.contacts.doctype.address.address import ( + Address, + get_address_display, + get_address_templates, +) + class ERPNextAddress(Address): def validate(self): @@ -31,7 +35,7 @@ class ERPNextAddress(Address): customers = frappe.db.get_all("Customer", filters=filters, as_list=True) for customer_name in customers: frappe.db.set_value("Customer", customer_name[0], "primary_address", address_display) - + @frappe.whitelist() def get_shipping_address(company, address = None): filters = [ diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py index 85f54f98ba..5eb857719a 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py @@ -2,14 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json + +import frappe from frappe import _ -from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day, formatdate, get_link_to_form -from erpnext.accounts.report.general_ledger.general_ledger import execute +from frappe.utils import add_to_date, formatdate, get_link_to_form, getdate, nowdate from frappe.utils.dashboard import cache_source from frappe.utils.dateutils import get_from_date_from_timespan, get_period_ending from frappe.utils.nestedset import get_descendants_of + @frappe.whitelist() @cache_source def get(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None, diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 0c81d83ed8..bcd07718a5 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -2,11 +2,26 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import date_diff, add_months, today, getdate, add_days, flt, get_last_day, get_first_day, cint, get_link_to_form, rounded -from erpnext.accounts.utils import get_account_currency from frappe.email import sendmail_to_system_managers -from frappe.utils.background_jobs import enqueue -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions +from frappe.utils import ( + add_days, + add_months, + cint, + date_diff, + flt, + get_first_day, + get_last_day, + get_link_to_form, + getdate, + rounded, + today, +) + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) +from erpnext.accounts.utils import get_account_currency + def validate_service_stop_date(doc): ''' Validates service_stop_date for Purchase Invoice and Sales Invoice ''' @@ -359,7 +374,7 @@ def make_gl_entries(doc, credit_account, debit_account, against, try: make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True) frappe.db.commit() - except: + except Exception: frappe.db.rollback() traceback = frappe.get_traceback() frappe.log_error(message=traceback) @@ -430,7 +445,7 @@ def book_revenue_via_journal_entry(doc, credit_account, debit_account, against, if submit: journal_entry.submit() - except: + except Exception: frappe.db.rollback() traceback = frappe.get_traceback() frappe.log_error(message=traceback) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index f763df0852..f6198eb23b 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -2,11 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe +from frappe import _, throw from frappe.utils import cint, cstr -from frappe import throw, _ from frappe.utils.nestedset import NestedSet, get_ancestors_of, get_descendants_of + class RootNotEditable(frappe.ValidationError): pass class BalanceMismatchError(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index 927adc7086..d6ccd16936 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -2,12 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals +import json +import os -import frappe, os, json +import frappe from frappe.utils import cstr -from unidecode import unidecode -from six import iteritems from frappe.utils.nestedset import rebuild_tree +from six import iteritems +from unidecode import unidecode + def create_charts(company, chart_template=None, existing_company=None, custom_chart=None): chart = custom_chart or get_chart(chart_template, existing_company) @@ -91,11 +94,14 @@ def get_chart(chart_template, existing_company=None): return get_account_tree_from_existing_company(existing_company) elif chart_template == "Standard": - from erpnext.accounts.doctype.account.chart_of_accounts.verified import standard_chart_of_accounts + from erpnext.accounts.doctype.account.chart_of_accounts.verified import ( + standard_chart_of_accounts, + ) return standard_chart_of_accounts.get() elif chart_template == "Standard with Numbers": - from erpnext.accounts.doctype.account.chart_of_accounts.verified \ - import standard_chart_of_accounts_with_account_number + from erpnext.accounts.doctype.account.chart_of_accounts.verified import ( + standard_chart_of_accounts_with_account_number, + ) return standard_chart_of_accounts_with_account_number.get() else: folders = ("verified",) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py index eb3e7ffd90..72223573a2 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py @@ -6,12 +6,13 @@ Import chart of accounts from OpenERP sources """ from __future__ import print_function, unicode_literals -import os, json import ast +import json +import os from xml.etree import ElementTree as ET -from frappe.utils.csvutils import read_csv_content -import frappe +import frappe +from frappe.utils.csvutils import read_csv_content from six import iteritems path = "/Users/nabinhait/projects/odoo/addons" diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py index 161e52a67d..f058afba6a 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py @@ -2,8 +2,10 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get(): return { _("Application of Funds (Assets)"): { diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py index acb11e557a..9f33952035 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py @@ -2,8 +2,10 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get(): return { _("Application of Funds (Assets)"): { diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index 533eda31d5..0c3b33e0b9 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -2,10 +2,14 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import unittest + import frappe -from erpnext.stock import get_warehouse_account, get_company_default_inventory_account -from erpnext.accounts.doctype.account.account import update_account_number, merge_account + +from erpnext.accounts.doctype.account.account import merge_account, update_account_number +from erpnext.stock import get_company_default_inventory_account, get_warehouse_account + class TestAccount(unittest.TestCase): def test_rename_account(self): diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py index fac28c9239..af8255f944 100644 --- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py @@ -3,15 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe import _ + import json -from frappe.model.document import Document + +import frappe +from frappe import _, scrub from frappe.custom.doctype.custom_field.custom_field import create_custom_field -from frappe import scrub -from frappe.utils import cstr -from frappe.utils.background_jobs import enqueue from frappe.model import core_doctypes_list +from frappe.model.document import Document +from frappe.utils import cstr + class AccountingDimension(Document): def before_insert(self): @@ -47,9 +48,9 @@ class AccountingDimension(Document): def on_trash(self): if frappe.flags.in_test: - delete_accounting_dimension(doc=self, queue='long') + delete_accounting_dimension(doc=self) else: - frappe.enqueue(delete_accounting_dimension, doc=self) + frappe.enqueue(delete_accounting_dimension, doc=self, queue='long') def set_fieldname_and_label(self): if not self.label: diff --git a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py index 4f3ee7643a..3769fc1270 100644 --- a/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py @@ -3,10 +3,12 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice + +import frappe + from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice test_dependencies = ['Cost Center', 'Location', 'Warehouse', 'Department'] diff --git a/erpnext/accounts/doctype/accounting_dimension_detail/accounting_dimension_detail.py b/erpnext/accounts/doctype/accounting_dimension_detail/accounting_dimension_detail.py index 17cf549fc4..c116f16453 100644 --- a/erpnext/accounts/doctype/accounting_dimension_detail/accounting_dimension_detail.py +++ b/erpnext/accounts/doctype/accounting_dimension_detail/accounting_dimension_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AccountingDimensionDetail(Document): pass diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py index 6aef9caa74..cb8c7d1c98 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _, scrub from frappe.model.document import Document + class AccountingDimensionFilter(Document): def validate(self): self.validate_applicable_accounts() diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py index 7f6254f99f..9968f68991 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/test_accounting_dimension_filter.py @@ -3,10 +3,15 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe + +from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import ( + create_dimension, + disable_dimension, +) from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice -from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import create_dimension, disable_dimension from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError test_dependencies = ['Location', 'Cost Center', 'Department'] diff --git a/erpnext/accounts/doctype/accounting_period/accounting_period.py b/erpnext/accounts/doctype/accounting_period/accounting_period.py index 739d8f6bc6..67d1a8a09b 100644 --- a/erpnext/accounts/doctype/accounting_period/accounting_period.py +++ b/erpnext/accounts/doctype/accounting_period/accounting_period.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ +from frappe.model.document import Document + class OverlapError(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py index dc472c7695..5885b58e48 100644 --- a/erpnext/accounts/doctype/accounting_period/test_accounting_period.py +++ b/erpnext/accounts/doctype/accounting_period/test_accounting_period.py @@ -3,12 +3,14 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import nowdate, add_months -from erpnext.accounts.general_ledger import ClosedAccountingPeriod + +import frappe +from frappe.utils import add_months, nowdate + from erpnext.accounts.doctype.accounting_period.accounting_period import OverlapError from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.accounts.general_ledger import ClosedAccountingPeriod test_dependencies = ['Item'] diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 62c97f24d5..f54473351a 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -4,11 +4,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cint -from frappe.model.document import Document from frappe.custom.doctype.property_setter.property_setter import make_property_setter +from frappe.model.document import Document +from frappe.utils import cint class AccountsSettings(Document): diff --git a/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py index 014cf45e51..c1c156fa65 100644 --- a/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + import unittest import frappe diff --git a/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py index 597d2ccc62..0c98f24874 100644 --- a/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py +++ b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AdvanceTaxesandCharges(Document): pass diff --git a/erpnext/accounts/doctype/allowed_dimension/allowed_dimension.py b/erpnext/accounts/doctype/allowed_dimension/allowed_dimension.py index c2afc1a262..b5e7ad3fbe 100644 --- a/erpnext/accounts/doctype/allowed_dimension/allowed_dimension.py +++ b/erpnext/accounts/doctype/allowed_dimension/allowed_dimension.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AllowedDimension(Document): pass diff --git a/erpnext/accounts/doctype/allowed_to_transact_with/allowed_to_transact_with.py b/erpnext/accounts/doctype/allowed_to_transact_with/allowed_to_transact_with.py index a3e4bbcd09..3e84c3071b 100644 --- a/erpnext/accounts/doctype/allowed_to_transact_with/allowed_to_transact_with.py +++ b/erpnext/accounts/doctype/allowed_to_transact_with/allowed_to_transact_with.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class AllowedToTransactWith(Document): pass diff --git a/erpnext/accounts/doctype/applicable_on_account/applicable_on_account.py b/erpnext/accounts/doctype/applicable_on_account/applicable_on_account.py index 0fccaf302f..91331fadd5 100644 --- a/erpnext/accounts/doctype/applicable_on_account/applicable_on_account.py +++ b/erpnext/accounts/doctype/applicable_on_account/applicable_on_account.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class ApplicableOnAccount(Document): pass diff --git a/erpnext/accounts/doctype/bank/bank.py b/erpnext/accounts/doctype/bank/bank.py index 99fa21c8f9..e1eb984f5f 100644 --- a/erpnext/accounts/doctype/bank/bank.py +++ b/erpnext/accounts/doctype/bank/bank.py @@ -3,9 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + +from frappe.contacts.address_and_contact import ( + delete_contact_and_address, + load_address_and_contact, +) from frappe.model.document import Document -from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address + class Bank(Document): def onload(self): diff --git a/erpnext/accounts/doctype/bank/test_bank.py b/erpnext/accounts/doctype/bank/test_bank.py index d8741f24c5..62d14d6fc6 100644 --- a/erpnext/accounts/doctype/bank/test_bank.py +++ b/erpnext/accounts/doctype/bank/test_bank.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestBank(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_account/bank_account.py b/erpnext/accounts/doctype/bank_account/bank_account.py index 3e08c2812e..703f55de80 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.py +++ b/erpnext/accounts/doctype/bank_account/bank_account.py @@ -3,10 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ +from frappe.contacts.address_and_contact import ( + delete_contact_and_address, + load_address_and_contact, +) from frappe.model.document import Document -from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address + class BankAccount(Document): def onload(self): diff --git a/erpnext/accounts/doctype/bank_account/test_bank_account.py b/erpnext/accounts/doctype/bank_account/test_bank_account.py index ed34d17ee7..dc970f3d99 100644 --- a/erpnext/accounts/doctype/bank_account/test_bank_account.py +++ b/erpnext/accounts/doctype/bank_account/test_bank_account.py @@ -3,11 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe -from frappe import _ -from frappe import ValidationError import unittest +import frappe +from frappe import ValidationError + # test_records = frappe.get_test_records('Bank Account') class TestBankAccount(unittest.TestCase): diff --git a/erpnext/accounts/doctype/bank_account_subtype/bank_account_subtype.py b/erpnext/accounts/doctype/bank_account_subtype/bank_account_subtype.py index ab52c4af77..84fa0c92b8 100644 --- a/erpnext/accounts/doctype/bank_account_subtype/bank_account_subtype.py +++ b/erpnext/accounts/doctype/bank_account_subtype/bank_account_subtype.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class BankAccountSubtype(Document): pass diff --git a/erpnext/accounts/doctype/bank_account_subtype/test_bank_account_subtype.py b/erpnext/accounts/doctype/bank_account_subtype/test_bank_account_subtype.py index ca3addc979..d4eb88b365 100644 --- a/erpnext/accounts/doctype/bank_account_subtype/test_bank_account_subtype.py +++ b/erpnext/accounts/doctype/bank_account_subtype/test_bank_account_subtype.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestBankAccountSubtype(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_account_type/bank_account_type.py b/erpnext/accounts/doctype/bank_account_type/bank_account_type.py index b7dc0e0dc3..bba43dc486 100644 --- a/erpnext/accounts/doctype/bank_account_type/bank_account_type.py +++ b/erpnext/accounts/doctype/bank_account_type/bank_account_type.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class BankAccountType(Document): pass diff --git a/erpnext/accounts/doctype/bank_account_type/test_bank_account_type.py b/erpnext/accounts/doctype/bank_account_type/test_bank_account_type.py index f04725a2e5..00fd4338d2 100644 --- a/erpnext/accounts/doctype/bank_account_type/test_bank_account_type.py +++ b/erpnext/accounts/doctype/bank_account_type/test_bank_account_type.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBankAccountType(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 79f5596384..340b448178 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -2,10 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt, getdate, nowdate, fmt_money -from frappe import msgprint, _ +from frappe import _, msgprint from frappe.model.document import Document +from frappe.utils import flt, fmt_money, getdate, nowdate form_grid_templates = { "journal_entries": "templates/form_grid/bank_reconciliation_grid.html" diff --git a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py index 833abde5ce..bdf3c7f48a 100644 --- a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBankClearance(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_clearance_detail/bank_clearance_detail.py b/erpnext/accounts/doctype/bank_clearance_detail/bank_clearance_detail.py index 59299f81e5..1b23400cd3 100644 --- a/erpnext/accounts/doctype/bank_clearance_detail/bank_clearance_detail.py +++ b/erpnext/accounts/doctype/bank_clearance_detail/bank_clearance_detail.py @@ -2,8 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class BankClearanceDetail(Document): pass diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py index a0aac6ab17..8043c5f04e 100644 --- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py +++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.py @@ -3,10 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json -from frappe.model.document import Document + +import json + +import frappe from frappe import _ from frappe.desk.search import sanitize_searchfield +from frappe.model.document import Document + class BankGuarantee(Document): def validate(self): diff --git a/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py index 816743a9b0..5cd455fd6c 100644 --- a/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py +++ b/erpnext/accounts/doctype/bank_guarantee/test_bank_guarantee.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestBankGuarantee(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py index 8a17233cf7..ce64ee4f5a 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py @@ -3,17 +3,21 @@ # For license information, please see license.txt from __future__ import unicode_literals + import json import frappe -from frappe.model.document import Document from frappe import _ +from frappe.model.document import Document from frappe.utils import flt from erpnext import get_company_currency -from erpnext.accounts.utils import get_balance_on -from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import get_entries, get_amounts_not_reflected_in_system from erpnext.accounts.doctype.bank_transaction.bank_transaction import get_paid_amount +from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import ( + get_amounts_not_reflected_in_system, + get_entries, +) +from erpnext.accounts.utils import get_balance_on class BankReconciliationTool(Document): diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py index d96950abbc..55b83b6bdf 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBankReconciliationTool(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py index ffc9d1c465..25d1023c27 100644 --- a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py +++ b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py @@ -3,22 +3,22 @@ # For license information, please see license.txt from __future__ import unicode_literals + import csv import json import re +import frappe import openpyxl +from frappe import _ +from frappe.core.doctype.data_import.data_import import DataImport +from frappe.core.doctype.data_import.importer import Importer, ImportFile +from frappe.utils.background_jobs import enqueue +from frappe.utils.xlsxutils import ILLEGAL_CHARACTERS_RE, handle_html from openpyxl.styles import Font from openpyxl.utils import get_column_letter from six import string_types -import frappe -from frappe.core.doctype.data_import.importer import Importer, ImportFile -from frappe.utils.background_jobs import enqueue -from frappe.utils.xlsxutils import handle_html, ILLEGAL_CHARACTERS_RE -from frappe import _ - -from frappe.core.doctype.data_import.data_import import DataImport class BankStatementImport(DataImport): def __init__(self, *args, **kwargs): diff --git a/erpnext/accounts/doctype/bank_statement_import/test_bank_statement_import.py b/erpnext/accounts/doctype/bank_statement_import/test_bank_statement_import.py index cd5831412d..5b45fa204b 100644 --- a/erpnext/accounts/doctype/bank_statement_import/test_bank_statement_import.py +++ b/erpnext/accounts/doctype/bank_statement_import/test_bank_statement_import.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBankStatementImport(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index 7ea71fc103..c4cf37e0c8 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -3,11 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from erpnext.controllers.status_updater import StatusUpdater from frappe.utils import flt from six.moves import reduce -from frappe import _ + +from erpnext.controllers.status_updater import StatusUpdater + class BankTransaction(StatusUpdater): def after_insert(self): @@ -21,7 +23,7 @@ class BankTransaction(StatusUpdater): self.update_allocations() self.clear_linked_payment_entries() self.set_status(update=True) - + def on_cancel(self): self.clear_linked_payment_entries(for_cancel=True) self.set_status(update=True) @@ -45,7 +47,7 @@ class BankTransaction(StatusUpdater): frappe.db.set_value(self.doctype, self.name, "status", "Reconciled") self.reload() - + def clear_linked_payment_entries(self, for_cancel=False): for payment_entry in self.payment_entries: if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]: @@ -77,7 +79,7 @@ class BankTransaction(StatusUpdater): def get_reconciled_bank_transactions(payment_entry): reconciled_bank_transactions = frappe.get_all( - 'Bank Transaction Payments', + 'Bank Transaction Payments', filters = { 'payment_entry': payment_entry.payment_entry }, diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction_upload.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction_upload.py index dc3b867470..e8d032be36 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction_upload.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction_upload.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe.utils import getdate from frappe.utils.dateutils import parse_date from six import iteritems + @frappe.whitelist() def upload_bank_statement(): if getattr(frappe, "uploaded_file", None): diff --git a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py index 439d489119..35d08bd803 100644 --- a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py @@ -3,14 +3,19 @@ # See license.txt from __future__ import unicode_literals -import frappe -import unittest import json -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice -from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice +import unittest + +import frappe + +from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import ( + get_linked_payments, + reconcile_vouchers, +) from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry -from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import reconcile_vouchers, get_linked_payments from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice test_dependencies = ["Item", "Cost Center"] diff --git a/erpnext/accounts/doctype/bank_transaction_mapping/bank_transaction_mapping.py b/erpnext/accounts/doctype/bank_transaction_mapping/bank_transaction_mapping.py index 95a5bc3388..8b809fe705 100644 --- a/erpnext/accounts/doctype/bank_transaction_mapping/bank_transaction_mapping.py +++ b/erpnext/accounts/doctype/bank_transaction_mapping/bank_transaction_mapping.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class BankTransactionMapping(Document): pass diff --git a/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.py b/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.py index d6d7c109cf..2546f27a46 100644 --- a/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.py +++ b/erpnext/accounts/doctype/bank_transaction_payments/bank_transaction_payments.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class BankTransactionPayments(Document): pass diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index d93b6ffbaf..9c20e82f16 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -1,15 +1,20 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, getdate, add_months, get_last_day, fmt_money, nowdate -from frappe.model.naming import make_autoname -from erpnext.accounts.utils import get_fiscal_year from frappe.model.document import Document -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions +from frappe.model.naming import make_autoname +from frappe.utils import add_months, flt, fmt_money, get_last_day, getdate + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) +from erpnext.accounts.utils import get_fiscal_year + class BudgetError(frappe.ValidationError): pass class DuplicateBudgetError(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py index 6c25f0024d..cc8220920e 100644 --- a/erpnext/accounts/doctype/budget/test_budget.py +++ b/erpnext/accounts/doctype/budget/test_budget.py @@ -3,13 +3,15 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import nowdate, now_datetime + +import frappe +from frappe.utils import now_datetime, nowdate + +from erpnext.accounts.doctype.budget.budget import BudgetError, get_actual_expense +from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry from erpnext.accounts.utils import get_fiscal_year from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order -from erpnext.accounts.doctype.budget.budget import get_actual_expense, BudgetError -from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry test_dependencies = ['Monthly Distribution'] diff --git a/erpnext/accounts/doctype/budget_account/budget_account.py b/erpnext/accounts/doctype/budget_account/budget_account.py index 81b2709ba8..454e47d7a1 100644 --- a/erpnext/accounts/doctype/budget_account/budget_account.py +++ b/erpnext/accounts/doctype/budget_account/budget_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class BudgetAccount(Document): pass diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py index cfe28f3ff9..b1ab648159 100644 --- a/erpnext/accounts/doctype/c_form/c_form.py +++ b/erpnext/accounts/doctype/c_form/c_form.py @@ -2,10 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt from frappe import _ from frappe.model.document import Document +from frappe.utils import flt + class CForm(Document): def validate(self): diff --git a/erpnext/accounts/doctype/c_form/test_c_form.py b/erpnext/accounts/doctype/c_form/test_c_form.py index c4c95db0f2..e5c5615731 100644 --- a/erpnext/accounts/doctype/c_form/test_c_form.py +++ b/erpnext/accounts/doctype/c_form/test_c_form.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('C-Form') diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py index 20e423a610..1316227df9 100644 --- a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py +++ b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py @@ -2,8 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class CFormInvoiceDetail(Document): pass diff --git a/erpnext/accounts/doctype/campaign_item/campaign_item.py b/erpnext/accounts/doctype/campaign_item/campaign_item.py index 4f5fd7f7d7..d78fdf5285 100644 --- a/erpnext/accounts/doctype/campaign_item/campaign_item.py +++ b/erpnext/accounts/doctype/campaign_item/campaign_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class CampaignItem(Document): pass diff --git a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py b/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py index 7251533837..96920b329e 100644 --- a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py +++ b/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py b/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py index b1ad2972be..9ec466a7a6 100644 --- a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py +++ b/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py b/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py index 499c820479..5e44c61379 100644 --- a/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py +++ b/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py @@ -3,9 +3,10 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + class TestCashFlowMapping(unittest.TestCase): def setUp(self): diff --git a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py b/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py index fc63b8f9af..5174035319 100644 --- a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py +++ b/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py b/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py index 6f77a39bab..fabf5796bc 100644 --- a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py +++ b/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py b/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py index e10b63829f..f0ff33fb38 100644 --- a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py +++ b/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/cashier_closing/cashier_closing.py b/erpnext/accounts/doctype/cashier_closing/cashier_closing.py index 081c6fa471..cab7d407b5 100644 --- a/erpnext/accounts/doctype/cashier_closing/cashier_closing.py +++ b/erpnext/accounts/doctype/cashier_closing/cashier_closing.py @@ -3,10 +3,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe +from frappe import _ from frappe.model.document import Document -from frappe.utils import cint, flt, cstr -from frappe import _, msgprint, throw +from frappe.utils import flt + class CashierClosing(Document): def validate(self): diff --git a/erpnext/accounts/doctype/cashier_closing/test_cashier_closing.py b/erpnext/accounts/doctype/cashier_closing/test_cashier_closing.py index 3c489a7872..981093f3d0 100644 --- a/erpnext/accounts/doctype/cashier_closing/test_cashier_closing.py +++ b/erpnext/accounts/doctype/cashier_closing/test_cashier_closing.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestCashierClosing(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.py b/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.py index f73703158d..a2a8b9437e 100644 --- a/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.py +++ b/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.py @@ -3,8 +3,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class CashierClosingPayments(Document): pass diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py index 8456b49c8e..61968cf627 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py @@ -3,14 +3,26 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import csv +import os from functools import reduce -import frappe, csv, os + +import frappe from frappe import _ -from frappe.utils import cstr, cint from frappe.model.document import Document +from frappe.utils import cint, cstr from frappe.utils.csvutils import UnicodeWriter -from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts, build_tree_from_json -from frappe.utils.xlsxutils import read_xlsx_file_from_attached_file, read_xls_file_from_attached_file +from frappe.utils.xlsxutils import ( + read_xls_file_from_attached_file, + read_xlsx_file_from_attached_file, +) + +from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import ( + build_tree_from_json, + create_charts, +) + class ChartofAccountsImporter(Document): def validate(self): diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py index 6ab19b771b..ca9cf699aa 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/test_chart_of_accounts_importer.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestChartofAccountsImporter(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py index d62ee9deeb..0f595ba933 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ +from frappe.model.document import Document + class ChequePrintTemplate(Document): pass diff --git a/erpnext/accounts/doctype/cheque_print_template/test_cheque_print_template.py b/erpnext/accounts/doctype/cheque_print_template/test_cheque_print_template.py index fa9c5b5eb0..8ce8794cfc 100644 --- a/erpnext/accounts/doctype/cheque_print_template/test_cheque_print_template.py +++ b/erpnext/accounts/doctype/cheque_print_template/test_cheque_print_template.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Cheque Print Template') diff --git a/erpnext/accounts/doctype/closed_document/closed_document.py b/erpnext/accounts/doctype/closed_document/closed_document.py index 048ceeecbf..50469bc19c 100644 --- a/erpnext/accounts/doctype/closed_document/closed_document.py +++ b/erpnext/accounts/doctype/closed_document/closed_document.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ClosedDocument(Document): pass diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 981fec308c..166ebb83ac 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -2,10 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cint, cstr +from frappe.utils import cint from frappe.utils.nestedset import NestedSet + from erpnext.accounts.utils import validate_field_number diff --git a/erpnext/accounts/doctype/cost_center/test_cost_center.py b/erpnext/accounts/doctype/cost_center/test_cost_center.py index 7779ccefc2..142b925c2e 100644 --- a/erpnext/accounts/doctype/cost_center/test_cost_center.py +++ b/erpnext/accounts/doctype/cost_center/test_cost_center.py @@ -1,7 +1,9 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import unittest + import frappe test_records = frappe.get_test_records('Cost Center') diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.py b/erpnext/accounts/doctype/coupon_code/coupon_code.py index 92a816d25e..bb2615b361 100644 --- a/erpnext/accounts/doctype/coupon_code/coupon_code.py +++ b/erpnext/accounts/doctype/coupon_code/coupon_code.py @@ -3,10 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import (strip) +from frappe.utils import strip + + class CouponCode(Document): def autoname(self): self.coupon_name = strip(self.coupon_name) diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py index 06987a8a4a..bf8c014a5b 100644 --- a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py @@ -3,11 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe + from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -from erpnext.stock.get_item_details import get_item_details -from frappe.test_runner import make_test_objects test_dependencies = ['Item'] diff --git a/erpnext/accounts/doctype/customer_group_item/customer_group_item.py b/erpnext/accounts/doctype/customer_group_item/customer_group_item.py index df782ac9e0..100bfd5e66 100644 --- a/erpnext/accounts/doctype/customer_group_item/customer_group_item.py +++ b/erpnext/accounts/doctype/customer_group_item/customer_group_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class CustomerGroupItem(Document): pass diff --git a/erpnext/accounts/doctype/customer_item/customer_item.py b/erpnext/accounts/doctype/customer_item/customer_item.py index a577145e4e..da3533fcc6 100644 --- a/erpnext/accounts/doctype/customer_item/customer_item.py +++ b/erpnext/accounts/doctype/customer_item/customer_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class CustomerItem(Document): pass diff --git a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.py b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.py index 93dfcc14bd..11faa773c6 100644 --- a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.py +++ b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class DiscountedInvoice(Document): pass diff --git a/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py index 48c589f0c0..436704008e 100644 --- a/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py +++ b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class DistributedCostCenter(Document): pass diff --git a/erpnext/accounts/doctype/dunning/dunning.py b/erpnext/accounts/doctype/dunning/dunning.py index 1ef512a489..65ada530df 100644 --- a/erpnext/accounts/doctype/dunning/dunning.py +++ b/erpnext/accounts/doctype/dunning/dunning.py @@ -3,13 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe +from frappe.utils import cint, flt, getdate from six import string_types -from frappe.utils import getdate, get_datetime, rounded, flt, cint -from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_year + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.controllers.accounts_controller import AccountsController diff --git a/erpnext/accounts/doctype/dunning/dunning_dashboard.py b/erpnext/accounts/doctype/dunning/dunning_dashboard.py index 33c6ab080c..fa3330f7cf 100644 --- a/erpnext/accounts/doctype/dunning/dunning_dashboard.py +++ b/erpnext/accounts/doctype/dunning/dunning_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'dunning', diff --git a/erpnext/accounts/doctype/dunning/test_dunning.py b/erpnext/accounts/doctype/dunning/test_dunning.py index 67692ecc47..9e8b655336 100644 --- a/erpnext/accounts/doctype/dunning/test_dunning.py +++ b/erpnext/accounts/doctype/dunning/test_dunning.py @@ -3,13 +3,19 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import add_days, today, nowdate -from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice_against_cost_center + +import frappe +from frappe.utils import add_days, nowdate, today + from erpnext.accounts.doctype.dunning.dunning import calculate_interest_and_amount from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry +from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + unlink_payment_on_cancel_of_invoice, +) +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import ( + create_sales_invoice_against_cost_center, +) class TestDunning(unittest.TestCase): diff --git a/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py index 426497b607..b14fdc11f2 100644 --- a/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py +++ b/erpnext/accounts/doctype/dunning_letter_text/dunning_letter_text.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class DunningLetterText(Document): pass diff --git a/erpnext/accounts/doctype/dunning_type/dunning_type.py b/erpnext/accounts/doctype/dunning_type/dunning_type.py index 8708748428..64e7cf420f 100644 --- a/erpnext/accounts/doctype/dunning_type/dunning_type.py +++ b/erpnext/accounts/doctype/dunning_type/dunning_type.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class DunningType(Document): pass diff --git a/erpnext/accounts/doctype/dunning_type/test_dunning_type.py b/erpnext/accounts/doctype/dunning_type/test_dunning_type.py index b2fb26f34a..ae08907273 100644 --- a/erpnext/accounts/doctype/dunning_type/test_dunning_type.py +++ b/erpnext/accounts/doctype/dunning_type/test_dunning_type.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestDunningType(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py index dbbcedcadf..9c173d0c51 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py @@ -3,13 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ -from frappe.utils import flt from frappe.model.document import Document from frappe.model.meta import get_field_precision -from erpnext.setup.utils import get_exchange_rate +from frappe.utils import flt + +import erpnext from erpnext.accounts.doctype.journal_entry.journal_entry import get_balance_on +from erpnext.setup.utils import get_exchange_rate + class ExchangeRateRevaluation(Document): def validate(self): diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py index b5cfa04ed6..7358f561ed 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def get_data(): return { 'fieldname': 'reference_name', diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py index 3b037d1dc4..e725ce4da4 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestExchangeRateRevaluation(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.py b/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.py index 87d7b67346..58375dd4ef 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation_account/exchange_rate_revaluation_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ExchangeRateRevaluationAccount(Document): pass diff --git a/erpnext/accounts/doctype/finance_book/finance_book.py b/erpnext/accounts/doctype/finance_book/finance_book.py index bc9fce2ce8..527b8e6788 100644 --- a/erpnext/accounts/doctype/finance_book/finance_book.py +++ b/erpnext/accounts/doctype/finance_book/finance_book.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class FinanceBook(Document): pass diff --git a/erpnext/accounts/doctype/finance_book/test_finance_book.py b/erpnext/accounts/doctype/finance_book/test_finance_book.py index 2ba21397ad..87a8ae260c 100644 --- a/erpnext/accounts/doctype/finance_book/test_finance_book.py +++ b/erpnext/accounts/doctype/finance_book/test_finance_book.py @@ -2,11 +2,13 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals -from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry +import unittest import frappe -import unittest + +from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry + class TestFinanceBook(unittest.TestCase): def test_finance_book(self): @@ -40,4 +42,4 @@ def create_finance_book(): else: finance_book = frappe.get_doc("Finance Book", "_Test Finance Book") - return finance_book \ No newline at end of file + return finance_book diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index 42556269fd..6854ac910d 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -2,12 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from frappe import msgprint, _ -from frappe.utils import getdate, add_days, add_years, cstr -from dateutil.relativedelta import relativedelta +import frappe +from dateutil.relativedelta import relativedelta +from frappe import _, msgprint from frappe.model.document import Document +from frappe.utils import add_days, add_years, cstr, getdate + class FiscalYearIncorrectDate(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py index cec4f4492d..b0365afa82 100644 --- a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py @@ -3,7 +3,9 @@ from __future__ import unicode_literals -import frappe, unittest +import unittest + +import frappe from erpnext.accounts.doctype.fiscal_year.fiscal_year import FiscalYearIncorrectDate diff --git a/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py index 8dfc2fa7e2..b9c57f67b0 100644 --- a/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py +++ b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class FiscalYearCompany(Document): pass diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 0844995f29..1e983b1d42 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -2,20 +2,30 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ -from frappe.utils import flt, fmt_money, getdate, formatdate, cint from frappe.model.document import Document -from frappe.model.naming import set_name_from_naming_options from frappe.model.meta import get_field_precision -from erpnext.accounts.party import validate_party_gle_currency, validate_party_frozen_disabled -from erpnext.accounts.utils import get_account_currency -from erpnext.accounts.utils import get_fiscal_year -from erpnext.exceptions import InvalidAccountCurrency, InvalidAccountDimensionError, MandatoryAccountDimensionError -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts -from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_filter import get_dimension_filter_map +from frappe.model.naming import set_name_from_naming_options +from frappe.utils import flt, fmt_money from six import iteritems +import erpnext +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_checks_for_pl_and_bs_accounts, +) +from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_filter import ( + get_dimension_filter_map, +) +from erpnext.accounts.party import validate_party_frozen_disabled, validate_party_gle_currency +from erpnext.accounts.utils import get_account_currency, get_fiscal_year +from erpnext.exceptions import ( + InvalidAccountCurrency, + InvalidAccountDimensionError, + MandatoryAccountDimensionError, +) + exclude_from_linked_with = True class GLEntry(Document): def autoname(self): diff --git a/erpnext/accounts/doctype/gl_entry/test_gl_entry.py b/erpnext/accounts/doctype/gl_entry/test_gl_entry.py index 4167ca70df..1495952076 100644 --- a/erpnext/accounts/doctype/gl_entry/test_gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/test_gl_entry.py @@ -2,10 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, unittest + +import unittest + +import frappe from frappe.model.naming import parse_naming_series -from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry + from erpnext.accounts.doctype.gl_entry.gl_entry import rename_gle_sle_docs +from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry + class TestGLEntry(unittest.TestCase): def test_round_off_entry(self): diff --git a/erpnext/accounts/doctype/gst_account/gst_account.py b/erpnext/accounts/doctype/gst_account/gst_account.py index d7848495a6..9ca3f9ac51 100644 --- a/erpnext/accounts/doctype/gst_account/gst_account.py +++ b/erpnext/accounts/doctype/gst_account/gst_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class GSTAccount(Document): pass diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py index b73d8bfbb1..8867f1cd9b 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py @@ -3,12 +3,20 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json, erpnext + +import json + +import frappe from frappe import _ -from frappe.utils import flt, getdate, nowdate, add_days -from erpnext.controllers.accounts_controller import AccountsController +from frappe.utils import add_days, flt, getdate, nowdate + +import erpnext +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) from erpnext.accounts.general_ledger import make_gl_entries -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions +from erpnext.controllers.accounts_controller import AccountsController + class InvoiceDiscounting(AccountsController): def validate(self): diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting_dashboard.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting_dashboard.py index 6d35ca2439..bab8e46c31 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting_dashboard.py +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'reference_name', diff --git a/erpnext/accounts/doctype/invoice_discounting/test_invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/test_invoice_discounting.py index 919dd0cba7..58aea92e81 100644 --- a/erpnext/accounts/doctype/invoice_discounting/test_invoice_discounting.py +++ b/erpnext/accounts/doctype/invoice_discounting/test_invoice_discounting.py @@ -3,13 +3,17 @@ # See license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import nowdate, add_days, flt import unittest -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries + +import frappe +from frappe.utils import add_days, flt, nowdate + from erpnext.accounts.doctype.account.test_account import create_account from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries + + class TestInvoiceDiscounting(unittest.TestCase): def setUp(self): self.ar_credit = create_account(account_name="_Test Accounts Receivable Credit", parent_account = "Accounts Receivable - _TC", company="_Test Company") diff --git a/erpnext/accounts/doctype/item_tax_template/item_tax_template.py b/erpnext/accounts/doctype/item_tax_template/item_tax_template.py index d9155cbab4..1e26afe025 100644 --- a/erpnext/accounts/doctype/item_tax_template/item_tax_template.py +++ b/erpnext/accounts/doctype/item_tax_template/item_tax_template.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ +from frappe.model.document import Document + class ItemTaxTemplate(Document): def validate(self): diff --git a/erpnext/accounts/doctype/item_tax_template/test_item_tax_template.py b/erpnext/accounts/doctype/item_tax_template/test_item_tax_template.py index acf1e446e7..46bb300e37 100644 --- a/erpnext/accounts/doctype/item_tax_template/test_item_tax_template.py +++ b/erpnext/accounts/doctype/item_tax_template/test_item_tax_template.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestItemTaxTemplate(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/item_tax_template_detail/item_tax_template_detail.py b/erpnext/accounts/doctype/item_tax_template_detail/item_tax_template_detail.py index d51bed0520..aa3b5420d6 100644 --- a/erpnext/accounts/doctype/item_tax_template_detail/item_tax_template_detail.py +++ b/erpnext/accounts/doctype/item_tax_template_detail/item_tax_template_detail.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ItemTaxTemplateDetail(Document): pass diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 72648753a7..24368f0441 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -2,19 +2,30 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext, json -from frappe.utils import cstr, flt, fmt_money, formatdate, getdate, nowdate, cint, get_link_to_form -from frappe import msgprint, _, scrub -from erpnext.controllers.accounts_controller import AccountsController -from erpnext.accounts.utils import get_balance_on, get_stock_accounts, get_stock_and_account_balance, \ - get_account_currency, check_if_stock_and_account_balance_synced -from erpnext.accounts.party import get_party_account -from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount -from erpnext.accounts.doctype.invoice_discounting.invoice_discounting \ - import get_party_account_based_on_invoice_discounting -from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts -from six import string_types, iteritems +import json + +import frappe +from frappe import _, msgprint, scrub +from frappe.utils import cint, cstr, flt, fmt_money, formatdate, get_link_to_form, nowdate +from six import iteritems, string_types + +import erpnext +from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts +from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import ( + get_party_account_based_on_invoice_discounting, +) +from erpnext.accounts.party import get_party_account +from erpnext.accounts.utils import ( + check_if_stock_and_account_balance_synced, + get_account_currency, + get_balance_on, + get_stock_accounts, + get_stock_and_account_balance, +) +from erpnext.controllers.accounts_controller import AccountsController +from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount + class StockAccountInvalidTransaction(frappe.ValidationError): pass @@ -66,6 +77,7 @@ class JournalEntry(AccountsController): self.update_expense_claim() self.update_inter_company_jv() self.update_invoice_discounting() + self.update_status_for_full_and_final_statement() check_if_stock_and_account_balance_synced(self.posting_date, self.company, self.doctype, self.name) @@ -83,6 +95,7 @@ class JournalEntry(AccountsController): self.unlink_inter_company_jv() self.unlink_asset_adjustment_entry() self.update_invoice_discounting() + self.update_status_for_full_and_final_statement() def get_title(self): return self.pay_to_recd_from or self.accounts[0].account @@ -98,6 +111,15 @@ class JournalEntry(AccountsController): for voucher_no in list(set(order_list)): frappe.get_doc(voucher_type, voucher_no).set_total_advance_paid() + def update_status_for_full_and_final_statement(self): + for entry in self.accounts: + if entry.reference_type == "Full and Final Statement": + if self.docstatus == 1: + frappe.db.set_value("Full and Final Statement", entry.reference_name, "status", "Paid") + elif self.docstatus == 2: + frappe.db.set_value("Full and Final Statement", entry.reference_name, "status", "Unpaid") + + def validate_inter_company_accounts(self): if self.voucher_type == "Inter Company Journal Entry" and self.inter_company_journal_entry_reference: doc = frappe.get_doc("Journal Entry", self.inter_company_journal_entry_reference) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 5835d462ae..d03a08851a 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -2,11 +2,16 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import unittest, frappe + +import unittest + +import frappe from frappe.utils import flt, nowdate + from erpnext.accounts.doctype.account.test_account import get_inventory_account -from erpnext.exceptions import InvalidAccountCurrency from erpnext.accounts.doctype.journal_entry.journal_entry import StockAccountInvalidTransaction +from erpnext.exceptions import InvalidAccountCurrency + class TestJournalEntry(unittest.TestCase): def test_journal_entry_with_against_jv(self): diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json index a89fefde07..dff883aef9 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json @@ -202,7 +202,7 @@ "fieldname": "reference_type", "fieldtype": "Select", "label": "Reference Type", - "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nLoan\nPayroll Entry\nEmployee Advance\nExchange Rate Revaluation\nInvoice Discounting\nFees" + "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nLoan\nPayroll Entry\nEmployee Advance\nExchange Rate Revaluation\nInvoice Discounting\nFees\nFull and Final Statement" }, { "fieldname": "reference_name", @@ -280,7 +280,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-06-26 14:06:54.833738", + "modified": "2021-08-30 21:27:32.200299", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Account", diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py index 2e77cf2b44..86d3df4dc2 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class JournalEntryAccount(Document): pass diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py index e0b9cbc919..f0813f5e27 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class JournalEntryTemplate(Document): pass diff --git a/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py b/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py index 5f74a2042f..61fea94e82 100644 --- a/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py +++ b/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestJournalEntryTemplate(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py index 48e6abbc28..d0408ca2fc 100644 --- a/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py +++ b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class JournalEntryTemplateAccount(Document): pass diff --git a/erpnext/accounts/doctype/loyalty_point_entry/loyalty_point_entry.py b/erpnext/accounts/doctype/loyalty_point_entry/loyalty_point_entry.py index 3579a1a960..0813926f5f 100644 --- a/erpnext/accounts/doctype/loyalty_point_entry/loyalty_point_entry.py +++ b/erpnext/accounts/doctype/loyalty_point_entry/loyalty_point_entry.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document from frappe.utils import today diff --git a/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py b/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py index b6e2d57b9f..07856cfd5d 100644 --- a/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py +++ b/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestLoyaltyPointEntry(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/loyalty_point_entry_redemption/loyalty_point_entry_redemption.py b/erpnext/accounts/doctype/loyalty_point_entry_redemption/loyalty_point_entry_redemption.py index e4382b6c78..506e2ce839 100644 --- a/erpnext/accounts/doctype/loyalty_point_entry_redemption/loyalty_point_entry_redemption.py +++ b/erpnext/accounts/doctype/loyalty_point_entry_redemption/loyalty_point_entry_redemption.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LoyaltyPointEntryRedemption(Document): pass diff --git a/erpnext/accounts/doctype/loyalty_program/loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/loyalty_program.py index cb753a3723..89ed461fd5 100644 --- a/erpnext/accounts/doctype/loyalty_program/loyalty_program.py +++ b/erpnext/accounts/doctype/loyalty_program/loyalty_program.py @@ -3,11 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe +import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import today, flt +from frappe.utils import flt, today + class LoyaltyProgram(Document): pass diff --git a/erpnext/accounts/doctype/loyalty_program/loyalty_program_dashboard.py b/erpnext/accounts/doctype/loyalty_program/loyalty_program_dashboard.py index 189004f5ec..267bbbf00b 100644 --- a/erpnext/accounts/doctype/loyalty_program/loyalty_program_dashboard.py +++ b/erpnext/accounts/doctype/loyalty_program/loyalty_program_dashboard.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -from frappe import _ - def get_data(): return { diff --git a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py index 31994885aa..a039e32b8b 100644 --- a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py +++ b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py @@ -3,12 +3,17 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import today, cint, flt, getdate -from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points + +import frappe +from frappe.utils import cint, flt, getdate, today + +from erpnext.accounts.doctype.loyalty_program.loyalty_program import ( + get_loyalty_program_details_with_points, +) from erpnext.accounts.party import get_dashboard_info + class TestLoyaltyProgram(unittest.TestCase): @classmethod def setUpClass(self): diff --git a/erpnext/accounts/doctype/loyalty_program_collection/loyalty_program_collection.py b/erpnext/accounts/doctype/loyalty_program_collection/loyalty_program_collection.py index 42cc38cb4c..4bbcf3ae9f 100644 --- a/erpnext/accounts/doctype/loyalty_program_collection/loyalty_program_collection.py +++ b/erpnext/accounts/doctype/loyalty_program_collection/loyalty_program_collection.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LoyaltyProgramCollection(Document): pass diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py index cea921e999..dfe42df226 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py @@ -2,10 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from frappe.model.document import Document +import frappe from frappe import _ +from frappe.model.document import Document + class ModeofPayment(Document): def validate(self): diff --git a/erpnext/accounts/doctype/mode_of_payment/test_mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/test_mode_of_payment.py index ad6cd4795f..299687b067 100644 --- a/erpnext/accounts/doctype/mode_of_payment/test_mode_of_payment.py +++ b/erpnext/accounts/doctype/mode_of_payment/test_mode_of_payment.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Mode of Payment') diff --git a/erpnext/accounts/doctype/mode_of_payment_account/mode_of_payment_account.py b/erpnext/accounts/doctype/mode_of_payment_account/mode_of_payment_account.py index 5cb195a3ba..40b5f302f2 100644 --- a/erpnext/accounts/doctype/mode_of_payment_account/mode_of_payment_account.py +++ b/erpnext/accounts/doctype/mode_of_payment_account/mode_of_payment_account.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ModeofPaymentAccount(Document): pass diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py index ad8623fb4e..c0e00d6209 100644 --- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py +++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py @@ -2,10 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import (flt, add_months) from frappe.model.document import Document +from frappe.utils import add_months, flt + class MonthlyDistribution(Document): @frappe.whitelist() diff --git a/erpnext/accounts/doctype/monthly_distribution/test_monthly_distribution.py b/erpnext/accounts/doctype/monthly_distribution/test_monthly_distribution.py index efbf4eb105..63faa158f1 100644 --- a/erpnext/accounts/doctype/monthly_distribution/test_monthly_distribution.py +++ b/erpnext/accounts/doctype/monthly_distribution/test_monthly_distribution.py @@ -2,9 +2,11 @@ # See license.txt from __future__ import unicode_literals -import frappe + import unittest +import frappe + test_records = frappe.get_test_records('Monthly Distribution') class TestMonthlyDistribution(unittest.TestCase): diff --git a/erpnext/accounts/doctype/monthly_distribution_percentage/monthly_distribution_percentage.py b/erpnext/accounts/doctype/monthly_distribution_percentage/monthly_distribution_percentage.py index d9e8bf9c77..8ec30c79af 100644 --- a/erpnext/accounts/doctype/monthly_distribution_percentage/monthly_distribution_percentage.py +++ b/erpnext/accounts/doctype/monthly_distribution_percentage/monthly_distribution_percentage.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class MonthlyDistributionPercentage(Document): pass diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py index 9914b45dfc..2b94bf4c1f 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py @@ -3,14 +3,19 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import traceback from json import dumps + +import frappe from frappe import _, scrub -from frappe.utils import flt, nowdate from frappe.model.document import Document +from frappe.utils import flt, nowdate from frappe.utils.background_jobs import enqueue -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) class OpeningInvoiceCreationTool(Document): diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py index 8d6de2d562..ed3c6a9da0 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py @@ -3,12 +3,15 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe from frappe.cache_manager import clear_doctype_cache from frappe.custom.doctype.property_setter.property_setter import make_property_setter -from erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_creation_tool import get_temporary_opening_account + +from erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_creation_tool import ( + get_temporary_opening_account, +) test_dependencies = ["Customer", "Supplier"] diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py index d47c3e94ec..4008022a26 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class OpeningInvoiceCreationToolItem(Document): pass diff --git a/erpnext/accounts/doctype/party_account/party_account.py b/erpnext/accounts/doctype/party_account/party_account.py index 21cfb96dba..08d67c7a7b 100644 --- a/erpnext/accounts/doctype/party_account/party_account.py +++ b/erpnext/accounts/doctype/party_account/party_account.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PartyAccount(Document): pass diff --git a/erpnext/accounts/doctype/party_link/party_link.py b/erpnext/accounts/doctype/party_link/party_link.py index 7d58506ce7..daf667caf0 100644 --- a/erpnext/accounts/doctype/party_link/party_link.py +++ b/erpnext/accounts/doctype/party_link/party_link.py @@ -5,19 +5,20 @@ import frappe from frappe import _ from frappe.model.document import Document + class PartyLink(Document): def validate(self): if self.primary_role not in ['Customer', 'Supplier']: frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."), title=_("Invalid Primary Role")) - + existing_party_link = frappe.get_all('Party Link', { 'primary_party': self.secondary_party }, pluck="primary_role") if existing_party_link: frappe.throw(_('{} {} is already linked with another {}') .format(self.secondary_role, self.secondary_party, existing_party_link[0])) - + existing_party_link = frappe.get_all('Party Link', { 'secondary_party': self.primary_party }, pluck="primary_role") diff --git a/erpnext/accounts/doctype/party_link/test_party_link.py b/erpnext/accounts/doctype/party_link/test_party_link.py index a3ea3959ba..2ae338133e 100644 --- a/erpnext/accounts/doctype/party_link/test_party_link.py +++ b/erpnext/accounts/doctype/party_link/test_party_link.py @@ -4,5 +4,6 @@ # import frappe import unittest + class TestPartyLink(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index d96bc271ef..3be3925b5a 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -872,7 +872,7 @@ frappe.ui.form.on('Payment Entry', { && frm.doc.base_total_allocated_amount < frm.doc.base_received_amount + total_deductions && frm.doc.total_allocated_amount < frm.doc.paid_amount + (total_deductions / frm.doc.source_exchange_rate)) { unallocated_amount = (frm.doc.base_received_amount + total_deductions + frm.doc.base_total_taxes_and_charges - + frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate; + - frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate; } else if (frm.doc.payment_type == "Pay" && frm.doc.base_total_allocated_amount < frm.doc.base_paid_amount - total_deductions && frm.doc.total_allocated_amount < frm.doc.received_amount + (total_deductions / frm.doc.target_exchange_rate)) { diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index a5fcad4996..a5303215d5 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -3,22 +3,37 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext, json -from frappe import _, scrub, ValidationError, throw -from frappe.utils import flt, comma_or, nowdate, getdate, cint -from erpnext.accounts.utils import get_outstanding_invoices, get_account_currency, get_balance_on -from erpnext.accounts.party import get_party_account -from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account -from erpnext.setup.utils import get_exchange_rate -from erpnext.accounts.general_ledger import make_gl_entries -from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount -from erpnext.accounts.doctype.bank_account.bank_account import get_party_bank_account, get_bank_account_details -from erpnext.controllers.accounts_controller import AccountsController, get_supplier_block_status -from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import get_party_account_based_on_invoice_discounting -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details -from six import string_types, iteritems -from erpnext.controllers.accounts_controller import validate_taxes_and_charges +import json + +import frappe +from frappe import ValidationError, _, scrub, throw +from frappe.utils import cint, comma_or, flt, getdate, nowdate +from six import iteritems, string_types + +import erpnext +from erpnext.accounts.doctype.bank_account.bank_account import ( + get_bank_account_details, + get_party_bank_account, +) +from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import ( + get_party_account_based_on_invoice_discounting, +) +from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account +from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import ( + get_party_tax_withholding_details, +) +from erpnext.accounts.general_ledger import make_gl_entries +from erpnext.accounts.party import get_party_account +from erpnext.accounts.utils import get_account_currency, get_balance_on, get_outstanding_invoices +from erpnext.controllers.accounts_controller import ( + AccountsController, + get_supplier_block_status, + validate_taxes_and_charges, +) +from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount +from erpnext.setup.utils import get_exchange_rate + class InvalidPaymentEntry(ValidationError): pass @@ -484,7 +499,7 @@ class PaymentEntry(AccountsController): def validate_amounts(self): self.validate_received_amount() - + def validate_received_amount(self): if self.paid_from_account_currency == self.paid_to_account_currency: if self.paid_amount != self.received_amount: @@ -1390,7 +1405,7 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre }) def get_amounts_based_on_reference_doctype(reference_doctype, ref_doc, party_account_currency, company_currency, reference_name): - total_amount, outstanding_amount, exchange_rate = None + total_amount = outstanding_amount = exchange_rate = None if reference_doctype == "Fees": total_amount = ref_doc.get("grand_total") exchange_rate = 1 @@ -1410,7 +1425,7 @@ def get_amounts_based_on_reference_doctype(reference_doctype, ref_doc, party_acc return total_amount, outstanding_amount, exchange_rate def get_amounts_based_on_ref_doc(reference_doctype, ref_doc, party_account_currency, company_currency): - total_amount, outstanding_amount, exchange_rate = None + total_amount = outstanding_amount = exchange_rate = None if ref_doc.doctype == "Expense Claim": total_amount = flt(ref_doc.total_sanctioned_amount) + flt(ref_doc.total_taxes_and_charges) elif ref_doc.doctype == "Employee Advance": @@ -1450,7 +1465,7 @@ def get_total_amount_exchange_rate_base_on_currency(party_account_currency, comp return total_amount, exchange_rate def get_bill_no_and_update_amounts(reference_doctype, ref_doc, total_amount, exchange_rate, party_account_currency, company_currency): - outstanding_amount, bill_no = None + outstanding_amount = bill_no = None if reference_doctype in ("Sales Invoice", "Purchase Invoice"): outstanding_amount = ref_doc.get("outstanding_amount") bill_no = ref_doc.get("bill_no") diff --git a/erpnext/accounts/doctype/payment_entry/regional/india.js b/erpnext/accounts/doctype/payment_entry/regional/india.js new file mode 100644 index 0000000000..abb344581c --- /dev/null +++ b/erpnext/accounts/doctype/payment_entry/regional/india.js @@ -0,0 +1,29 @@ +frappe.ui.form.on("Payment Entry", { + company: function(frm) { + frappe.call({ + 'method': 'frappe.contacts.doctype.address.address.get_default_address', + 'args': { + 'doctype': 'Company', + 'name': frm.doc.company + }, + 'callback': function(r) { + frm.set_value('company_address', r.message); + } + }); + }, + + party: function(frm) { + if (frm.doc.party_type == "Customer" && frm.doc.party) { + frappe.call({ + 'method': 'frappe.contacts.doctype.address.address.get_default_address', + 'args': { + 'doctype': 'Customer', + 'name': frm.doc.party + }, + 'callback': function(r) { + frm.set_value('customer_address', r.message); + } + }); + } + } +}); \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index dac927b2ce..c90a3c503c 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -3,14 +3,25 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import flt, nowdate -from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, InvalidPaymentEntry -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice, create_sales_invoice_against_cost_center -from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice, make_purchase_invoice_against_cost_center + +from erpnext.accounts.doctype.payment_entry.payment_entry import ( + InvalidPaymentEntry, + get_payment_entry, +) +from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + make_purchase_invoice, + make_purchase_invoice_against_cost_center, +) +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import ( + create_sales_invoice, + create_sales_invoice_against_cost_center, +) from erpnext.hr.doctype.expense_claim.test_expense_claim import make_expense_claim +from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order test_dependencies = ["Item"] @@ -324,7 +335,10 @@ class TestPaymentEntry(unittest.TestCase): self.assertEqual(flt(pe.unallocated_amount, 2), 0.0) def test_payment_entry_retrieves_last_exchange_rate(self): - from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records, save_new_records + from erpnext.setup.doctype.currency_exchange.test_currency_exchange import ( + save_new_records, + test_records, + ) save_new_records(test_records) diff --git a/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.py b/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.py index d6686bbe42..9cfed7b56d 100644 --- a/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.py +++ b/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PaymentEntryDeduction(Document): pass diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py index 51f8c06165..a686f495cd 100644 --- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py +++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PaymentEntryReference(Document): pass diff --git a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.py b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.py index 3529c16a1c..1d8a8ac5e1 100644 --- a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.py +++ b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class PaymentGatewayAccount(Document): def autoname(self): self.name = self.payment_gateway + " - " + self.currency diff --git a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account_dashboard.py b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account_dashboard.py index 08982296f3..2edc1a1590 100644 --- a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account_dashboard.py +++ b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account_dashboard.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -from frappe import _ - def get_data(): return { diff --git a/erpnext/accounts/doctype/payment_gateway_account/test_payment_gateway_account.py b/erpnext/accounts/doctype/payment_gateway_account/test_payment_gateway_account.py index 84c3bc4a60..f76aa4a80f 100644 --- a/erpnext/accounts/doctype/payment_gateway_account/test_payment_gateway_account.py +++ b/erpnext/accounts/doctype/payment_gateway_account/test_payment_gateway_account.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Payment Gateway Account') diff --git a/erpnext/accounts/doctype/payment_order/payment_order.py b/erpnext/accounts/doctype/payment_order/payment_order.py index 8d29ae70ae..e9b5ad9dc4 100644 --- a/erpnext/accounts/doctype/payment_order/payment_order.py +++ b/erpnext/accounts/doctype/payment_order/payment_order.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import nowdate -from erpnext.accounts.party import get_party_account from frappe.model.document import Document +from frappe.utils import nowdate + +from erpnext.accounts.party import get_party_account + class PaymentOrder(Document): def on_submit(self): diff --git a/erpnext/accounts/doctype/payment_order/payment_order_dashboard.py b/erpnext/accounts/doctype/payment_order/payment_order_dashboard.py index a4f335833e..d9262be9b8 100644 --- a/erpnext/accounts/doctype/payment_order/payment_order_dashboard.py +++ b/erpnext/accounts/doctype/payment_order/payment_order_dashboard.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from frappe import _ + def get_data(): return { diff --git a/erpnext/accounts/doctype/payment_order/test_payment_order.py b/erpnext/accounts/doctype/payment_order/test_payment_order.py index 9ba57aef30..6414473346 100644 --- a/erpnext/accounts/doctype/payment_order/test_payment_order.py +++ b/erpnext/accounts/doctype/payment_order/test_payment_order.py @@ -3,13 +3,19 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import getdate + from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account -from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, make_payment_order +from erpnext.accounts.doctype.payment_entry.payment_entry import ( + get_payment_entry, + make_payment_order, +) from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice + class TestPaymentOrder(unittest.TestCase): def setUp(self): create_bank_account() diff --git a/erpnext/accounts/doctype/payment_order_reference/payment_order_reference.py b/erpnext/accounts/doctype/payment_order_reference/payment_order_reference.py index b3a92940e2..4bb98a3b61 100644 --- a/erpnext/accounts/doctype/payment_order_reference/payment_order_reference.py +++ b/erpnext/accounts/doctype/payment_order_reference/payment_order_reference.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PaymentOrderReference(Document): pass diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index c71a62dfb3..b1f3e6fd01 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -2,46 +2,10 @@ // For license information, please see license.txt frappe.provide("erpnext.accounts"); - -frappe.ui.form.on("Payment Reconciliation Payment", { - invoice_number: function(frm, cdt, cdn) { - var row = locals[cdt][cdn]; - if(row.invoice_number) { - var parts = row.invoice_number.split(' | '); - var invoice_type = parts[0]; - var invoice_number = parts[1]; - - var invoice_amount = frm.doc.invoices.filter(function(d) { - return d.invoice_type === invoice_type && d.invoice_number === invoice_number; - })[0].outstanding_amount; - - frappe.model.set_value(cdt, cdn, "allocated_amount", Math.min(invoice_amount, row.amount)); - - frm.call({ - doc: frm.doc, - method: 'get_difference_amount', - args: { - child_row: row - }, - callback: function(r, rt) { - if(r.message) { - frappe.model.set_value(cdt, cdn, - "difference_amount", r.message); - } - } - }); - } - } -}); - erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationController extends frappe.ui.form.Controller { onload() { var me = this; - this.frm.set_query("party", function() { - check_mandatory(me.frm); - }); - this.frm.set_query("party_type", function() { return { "filters": { @@ -88,15 +52,36 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo refresh() { this.frm.disable_save(); - this.toggle_primary_action(); + + if (this.frm.doc.receivable_payable_account) { + this.frm.add_custom_button(__('Get Unreconciled Entries'), () => + this.frm.trigger("get_unreconciled_entries") + ); + } + if (this.frm.doc.invoices.length && this.frm.doc.payments.length) { + this.frm.add_custom_button(__('Allocate'), () => + this.frm.trigger("allocate") + ); + } + if (this.frm.doc.allocation.length) { + this.frm.add_custom_button(__('Reconcile'), () => + this.frm.trigger("reconcile") + ); + } } - onload_post_render() { - this.toggle_primary_action(); + company() { + var me = this; + this.frm.set_value('receivable_payable_account', ''); + me.frm.clear_table("allocation"); + me.frm.clear_table("invoices"); + me.frm.clear_table("payments"); + me.frm.refresh_fields(); + me.frm.trigger('party'); } party() { - var me = this + var me = this; if (!me.frm.doc.receivable_payable_account && me.frm.doc.party_type && me.frm.doc.party) { return frappe.call({ method: "erpnext.accounts.party.get_party_account", @@ -109,6 +94,7 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo if (!r.exc && r.message) { me.frm.set_value("receivable_payable_account", r.message); } + me.frm.refresh(); } }); } @@ -120,16 +106,41 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo doc: me.frm.doc, method: 'get_unreconciled_entries', callback: function(r, rt) { - me.set_invoice_options(); - me.toggle_primary_action(); + if (!(me.frm.doc.payments.length || me.frm.doc.invoices.length)) { + frappe.throw({message: __("No invoice and payment records found for this party")}); + } + me.frm.refresh(); } }); } + allocate() { + var me = this; + let payments = me.frm.fields_dict.payments.grid.get_selected_children(); + if (!(payments.length)) { + payments = me.frm.doc.payments; + } + let invoices = me.frm.fields_dict.invoices.grid.get_selected_children(); + if (!(invoices.length)) { + invoices = me.frm.doc.invoices; + } + return me.frm.call({ + doc: me.frm.doc, + method: 'allocate_entries', + args: { + payments: payments, + invoices: invoices + }, + callback: function() { + me.frm.refresh(); + } + }); + } + reconcile() { var me = this; - var show_dialog = me.frm.doc.payments.filter(d => d.difference_amount && !d.difference_account); + var show_dialog = me.frm.doc.allocation.filter(d => d.difference_amount && !d.difference_account); if (show_dialog && show_dialog.length) { @@ -138,7 +149,7 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo title: __("Select Difference Account"), fields: [ { - fieldname: "payments", fieldtype: "Table", label: __("Payments"), + fieldname: "allocation", fieldtype: "Table", label: __("Allocation"), data: this.data, in_place_edit: true, get_data: () => { return this.data; @@ -179,10 +190,10 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo }, ], primary_action: function() { - const args = dialog.get_values()["payments"]; + const args = dialog.get_values()["allocation"]; args.forEach(d => { - frappe.model.set_value("Payment Reconciliation Payment", d.docname, + frappe.model.set_value("Payment Reconciliation Allocation", d.docname, "difference_account", d.difference_account); }); @@ -192,9 +203,9 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo primary_action_label: __('Reconcile Entries') }); - this.frm.doc.payments.forEach(d => { + this.frm.doc.allocation.forEach(d => { if (d.difference_amount && !d.difference_account) { - dialog.fields_dict.payments.df.data.push({ + dialog.fields_dict.allocation.df.data.push({ 'docname': d.name, 'reference_name': d.reference_name, 'difference_amount': d.difference_amount, @@ -203,8 +214,8 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo } }); - this.data = dialog.fields_dict.payments.df.data; - dialog.fields_dict.payments.grid.refresh(); + this.data = dialog.fields_dict.allocation.df.data; + dialog.fields_dict.allocation.grid.refresh(); dialog.show(); } else { this.reconcile_payment_entries(); @@ -218,48 +229,12 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo doc: me.frm.doc, method: 'reconcile', callback: function(r, rt) { - me.set_invoice_options(); - me.toggle_primary_action(); + me.frm.clear_table("allocation"); + me.frm.refresh_fields(); + me.frm.refresh(); } }); } - - set_invoice_options() { - var me = this; - var invoices = []; - - $.each(me.frm.doc.invoices || [], function(i, row) { - if (row.invoice_number && !in_list(invoices, row.invoice_number)) - invoices.push(row.invoice_type + " | " + row.invoice_number); - }); - - if (invoices) { - this.frm.fields_dict.payments.grid.update_docfield_property( - 'invoice_number', 'options', "\n" + invoices.join("\n") - ); - - $.each(me.frm.doc.payments || [], function(i, p) { - if(!in_list(invoices, cstr(p.invoice_number))) p.invoice_number = null; - }); - } - - refresh_field("payments"); - } - - toggle_primary_action() { - if ((this.frm.doc.payments || []).length) { - this.frm.fields_dict.reconcile.$input - && this.frm.fields_dict.reconcile.$input.addClass("btn-primary"); - this.frm.fields_dict.get_unreconciled_entries.$input - && this.frm.fields_dict.get_unreconciled_entries.$input.removeClass("btn-primary"); - } else { - this.frm.fields_dict.reconcile.$input - && this.frm.fields_dict.reconcile.$input.removeClass("btn-primary"); - this.frm.fields_dict.get_unreconciled_entries.$input - && this.frm.fields_dict.get_unreconciled_entries.$input.addClass("btn-primary"); - } - } - }; extend_cscript(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json index cfb24c3954..9023b3646f 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json @@ -1,622 +1,206 @@ { - "allow_copy": 1, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2014-07-09 12:04:51.681583", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 0, - "engine": "InnoDB", + "actions": [], + "allow_copy": 1, + "creation": "2014-07-09 12:04:51.681583", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "company", + "party_type", + "column_break_4", + "party", + "receivable_payable_account", + "col_break1", + "from_invoice_date", + "to_invoice_date", + "minimum_invoice_amount", + "maximum_invoice_amount", + "invoice_limit", + "column_break_13", + "from_payment_date", + "to_payment_date", + "minimum_payment_amount", + "maximum_payment_amount", + "payment_limit", + "bank_cash_account", + "sec_break1", + "invoices", + "column_break_15", + "payments", + "sec_break2", + "allocation" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "company", - "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": "Company", - "length": 0, - "no_copy": 0, - "options": "Company", - "permlevel": 0, - "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 - }, + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "party_type", - "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": "Party Type", - "length": 0, - "no_copy": 0, - "options": "DocType", - "permlevel": 0, - "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 - }, + "fieldname": "party_type", + "fieldtype": "Link", + "label": "Party Type", + "options": "DocType", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "fieldname": "party", - "fieldtype": "Dynamic 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": "Party", - "length": 0, - "no_copy": 0, - "options": "party_type", - "permlevel": 0, - "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 - }, + "depends_on": "eval:doc.party_type", + "fieldname": "party", + "fieldtype": "Dynamic Link", + "label": "Party", + "options": "party_type", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "receivable_payable_account", - "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": "Receivable / Payable Account", - "length": 0, - "no_copy": 0, - "options": "Account", - "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 - }, + "depends_on": "eval:doc.company && doc.party", + "fieldname": "receivable_payable_account", + "fieldtype": "Link", + "label": "Receivable / Payable Account", + "options": "Account", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "bank_cash_account", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Bank / Cash Account", - "length": 0, - "no_copy": 0, - "options": "Account", - "permlevel": 0, - "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 - }, + "description": "This filter will be applied to Journal Entry.", + "fieldname": "bank_cash_account", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Bank / Cash Account", + "options": "Account" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "col_break1", - "fieldtype": "Column Break", - "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": "", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "collapsible": 1, + "collapsible_depends_on": "eval: doc.invoices.length == 0", + "depends_on": "eval:doc.receivable_payable_account", + "fieldname": "col_break1", + "fieldtype": "Section Break", + "label": "Filters" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "from_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "From Invoice Date", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "depends_on": "eval:(doc.payments).length || (doc.invoices).length", + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "label": "Unreconciled Entries" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "to_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "To Invoice Date", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "payments", + "fieldtype": "Table", + "label": "Payments", + "options": "Payment Reconciliation Payment" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "minimum_amount", - "fieldtype": "Currency", - "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": "Minimum Invoice Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "depends_on": "allocation", + "fieldname": "sec_break2", + "fieldtype": "Section Break", + "label": "Allocated Entries" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "maximum_amount", - "fieldtype": "Currency", - "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": "Maximum Invoice Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "invoices", + "fieldtype": "Table", + "label": "Invoices", + "options": "Payment Reconciliation Invoice" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "System will fetch all the entries if limit value is zero.", - "fieldname": "limit", - "fieldtype": "Int", - "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": "Limit", - "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 - }, + "fieldname": "column_break_15", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "get_unreconciled_entries", - "fieldtype": "Button", - "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": "Get Unreconciled Entries", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "allocation", + "fieldtype": "Table", + "label": "Allocation", + "options": "Payment Reconciliation Allocation" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "sec_break1", - "fieldtype": "Section Break", - "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": "Unreconciled Payment Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "payments", - "fieldtype": "Table", - "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": "Payments", - "length": 0, - "no_copy": 0, - "options": "Payment Reconciliation Payment", - "permlevel": 0, - "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 - }, + "fieldname": "from_invoice_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Invoice Date" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "reconcile", - "fieldtype": "Button", - "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": "Reconcile", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "to_invoice_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "To Invoice Date" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "sec_break2", - "fieldtype": "Section Break", - "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": "Invoice/Journal Entry Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "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 - }, + "fieldname": "minimum_invoice_amount", + "fieldtype": "Currency", + "label": "Minimum Invoice Amount" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "invoices", - "fieldtype": "Table", - "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": "Invoices", - "length": 0, - "no_copy": 0, - "options": "Payment Reconciliation Invoice", - "permlevel": 0, - "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 + "description": "System will fetch all the entries if limit value is zero.", + "fieldname": "invoice_limit", + "fieldtype": "Int", + "label": "Invoice Limit" + }, + { + "fieldname": "column_break_13", + "fieldtype": "Column Break" + }, + { + "fieldname": "from_payment_date", + "fieldtype": "Date", + "label": "From Payment Date" + }, + { + "fieldname": "to_payment_date", + "fieldtype": "Date", + "label": "To Payment Date" + }, + { + "fieldname": "minimum_payment_amount", + "fieldtype": "Currency", + "label": "Minimum Payment Amount" + }, + { + "fieldname": "maximum_payment_amount", + "fieldtype": "Currency", + "label": "Maximum Payment Amount" + }, + { + "fieldname": "payment_limit", + "fieldtype": "Int", + "label": "Payment Limit" + }, + { + "fieldname": "maximum_invoice_amount", + "fieldtype": "Currency", + "label": "Maximum Invoice Amount" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 1, - "icon": "icon-resize-horizontal", - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 1, - "istable": 0, - "max_attachments": 0, - "menu_index": 0, - "modified": "2019-01-15 17:42:21.135214", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Payment Reconciliation", - "name_case": "", - "owner": "Administrator", + ], + "hide_toolbar": 1, + "icon": "icon-resize-horizontal", + "issingle": 1, + "links": [], + "modified": "2021-08-30 13:05:51.977861", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Accounts Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "read": 1, + "role": "Accounts Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "read": 1, + "role": "Accounts User", + "share": 1, "write": 1 } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index acfe1fef2e..9de79aee58 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -2,14 +2,17 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext -from frappe.utils import flt, today -from frappe import msgprint, _ + +import frappe +from frappe import _, msgprint from frappe.model.document import Document -from erpnext.accounts.utils import (get_outstanding_invoices, - update_reference_in_payment_entry, reconcile_against_document) +from frappe.utils import flt, getdate, nowdate, today + +import erpnext +from erpnext.accounts.utils import get_outstanding_invoices, reconcile_against_document from erpnext.controllers.accounts_controller import get_advance_payment_entries + class PaymentReconciliation(Document): @frappe.whitelist() def get_unreconciled_entries(self): @@ -27,24 +30,32 @@ class PaymentReconciliation(Document): else: dr_or_cr_notes = [] - self.add_payment_entries(payment_entries + journal_entries + dr_or_cr_notes) + non_reconciled_payments = payment_entries + journal_entries + dr_or_cr_notes + + if self.payment_limit: + non_reconciled_payments = non_reconciled_payments[:self.payment_limit] + + non_reconciled_payments = sorted(non_reconciled_payments, key=lambda k: k['posting_date'] or getdate(nowdate())) + + self.add_payment_entries(non_reconciled_payments) def get_payment_entries(self): order_doctype = "Sales Order" if self.party_type=="Customer" else "Purchase Order" + condition = self.get_conditions(get_payments=True) payment_entries = get_advance_payment_entries(self.party_type, self.party, - self.receivable_payable_account, order_doctype, against_all_orders=True, limit=self.limit) + self.receivable_payable_account, order_doctype, against_all_orders=True, limit=self.payment_limit, + condition=condition) return payment_entries def get_jv_entries(self): + condition = self.get_conditions() dr_or_cr = ("credit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency") bank_account_condition = "t2.against_account like %(bank_cash_account)s" \ if self.bank_cash_account else "1=1" - limit_cond = "limit %s" % self.limit if self.limit else "" - journal_entries = frappe.db.sql(""" select "Journal Entry" as reference_type, t1.name as reference_name, @@ -56,7 +67,7 @@ class PaymentReconciliation(Document): where t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1 and t2.party_type = %(party_type)s and t2.party = %(party)s - and t2.account = %(account)s and {dr_or_cr} > 0 + and t2.account = %(account)s and {dr_or_cr} > 0 {condition} and (t2.reference_type is null or t2.reference_type = '' or (t2.reference_type in ('Sales Order', 'Purchase Order') and t2.reference_name is not null and t2.reference_name != '')) @@ -65,11 +76,11 @@ class PaymentReconciliation(Document): THEN 1=1 ELSE {bank_account_condition} END) - order by t1.posting_date {limit_cond} + order by t1.posting_date """.format(**{ "dr_or_cr": dr_or_cr, "bank_account_condition": bank_account_condition, - "limit_cond": limit_cond + "condition": condition }), { "party_type": self.party_type, "party": self.party, @@ -80,6 +91,7 @@ class PaymentReconciliation(Document): return list(journal_entries) def get_dr_or_cr_notes(self): + condition = self.get_conditions(get_return_invoices=True) dr_or_cr = ("credit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency") @@ -90,7 +102,7 @@ class PaymentReconciliation(Document): if self.party_type == 'Customer' else "Purchase Invoice") return frappe.db.sql(""" SELECT doc.name as reference_name, %(voucher_type)s as reference_type, - (sum(gl.{dr_or_cr}) - sum(gl.{reconciled_dr_or_cr})) as amount, + (sum(gl.{dr_or_cr}) - sum(gl.{reconciled_dr_or_cr})) as amount, doc.posting_date, account_currency as currency FROM `tab{doc}` doc, `tabGL Entry` gl WHERE @@ -100,15 +112,17 @@ class PaymentReconciliation(Document): and gl.against_voucher_type = %(voucher_type)s and doc.docstatus = 1 and gl.party = %(party)s and gl.party_type = %(party_type)s and gl.account = %(account)s - and gl.is_cancelled = 0 + and gl.is_cancelled = 0 {condition} GROUP BY doc.name Having amount > 0 + ORDER BY doc.posting_date """.format( doc=voucher_type, dr_or_cr=dr_or_cr, reconciled_dr_or_cr=reconciled_dr_or_cr, - party_type_field=frappe.scrub(self.party_type)), + party_type_field=frappe.scrub(self.party_type), + condition=condition or ""), { 'party': self.party, 'party_type': self.party_type, @@ -116,22 +130,23 @@ class PaymentReconciliation(Document): 'account': self.receivable_payable_account }, as_dict=1) - def add_payment_entries(self, entries): + def add_payment_entries(self, non_reconciled_payments): self.set('payments', []) - for e in entries: + + for payment in non_reconciled_payments: row = self.append('payments', {}) - row.update(e) + row.update(payment) def get_invoice_entries(self): #Fetch JVs, Sales and Purchase Invoices for 'invoices' to reconcile against - condition = self.check_condition() + condition = self.get_conditions(get_invoices=True) non_reconciled_invoices = get_outstanding_invoices(self.party_type, self.party, self.receivable_payable_account, condition=condition) - if self.limit: - non_reconciled_invoices = non_reconciled_invoices[:self.limit] + if self.invoice_limit: + non_reconciled_invoices = non_reconciled_invoices[:self.invoice_limit] self.add_invoice_entries(non_reconciled_invoices) @@ -139,41 +154,78 @@ class PaymentReconciliation(Document): #Populate 'invoices' with JVs and Invoices to reconcile against self.set('invoices', []) - for e in non_reconciled_invoices: - ent = self.append('invoices', {}) - ent.invoice_type = e.get('voucher_type') - ent.invoice_number = e.get('voucher_no') - ent.invoice_date = e.get('posting_date') - ent.amount = flt(e.get('invoice_amount')) - ent.currency = e.get('currency') - ent.outstanding_amount = e.get('outstanding_amount') + for entry in non_reconciled_invoices: + inv = self.append('invoices', {}) + inv.invoice_type = entry.get('voucher_type') + inv.invoice_number = entry.get('voucher_no') + inv.invoice_date = entry.get('posting_date') + inv.amount = flt(entry.get('invoice_amount')) + inv.currency = entry.get('currency') + inv.outstanding_amount = flt(entry.get('outstanding_amount')) @frappe.whitelist() - def reconcile(self, args): - for e in self.get('payments'): - e.invoice_type = None - if e.invoice_number and " | " in e.invoice_number: - e.invoice_type, e.invoice_number = e.invoice_number.split(" | ") + def allocate_entries(self, args): + self.validate_entries() + entries = [] + for pay in args.get('payments'): + pay.update({'unreconciled_amount': pay.get('amount')}) + for inv in args.get('invoices'): + if pay.get('amount') >= inv.get('outstanding_amount'): + res = self.get_allocated_entry(pay, inv, inv['outstanding_amount']) + pay['amount'] = flt(pay.get('amount')) - flt(inv.get('outstanding_amount')) + inv['outstanding_amount'] = 0 + else: + res = self.get_allocated_entry(pay, inv, pay['amount']) + inv['outstanding_amount'] = flt(inv.get('outstanding_amount')) - flt(pay.get('amount')) + pay['amount'] = 0 + if pay.get('amount') == 0: + entries.append(res) + break + elif inv.get('outstanding_amount') == 0: + entries.append(res) + continue + else: + break - self.get_invoice_entries() - self.validate_invoice() + self.set('allocation', []) + for entry in entries: + if entry['allocated_amount'] != 0: + row = self.append('allocation', {}) + row.update(entry) + + def get_allocated_entry(self, pay, inv, allocated_amount): + return frappe._dict({ + 'reference_type': pay.get('reference_type'), + 'reference_name': pay.get('reference_name'), + 'reference_row': pay.get('reference_row'), + 'invoice_type': inv.get('invoice_type'), + 'invoice_number': inv.get('invoice_number'), + 'unreconciled_amount': pay.get('unreconciled_amount'), + 'amount': pay.get('amount'), + 'allocated_amount': allocated_amount, + 'difference_amount': pay.get('difference_amount') + }) + + @frappe.whitelist() + def reconcile(self): + self.validate_allocation() dr_or_cr = ("credit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency") - lst = [] + entry_list = [] dr_or_cr_notes = [] - for e in self.get('payments'): + for row in self.get('allocation'): reconciled_entry = [] - if e.invoice_number and e.allocated_amount: - if e.reference_type in ['Sales Invoice', 'Purchase Invoice']: + if row.invoice_number and row.allocated_amount: + if row.reference_type in ['Sales Invoice', 'Purchase Invoice']: reconciled_entry = dr_or_cr_notes else: - reconciled_entry = lst + reconciled_entry = entry_list - reconciled_entry.append(self.get_payment_details(e, dr_or_cr)) + reconciled_entry.append(self.get_payment_details(row, dr_or_cr)) - if lst: - reconcile_against_document(lst) + if entry_list: + reconcile_against_document(entry_list) if dr_or_cr_notes: reconcile_dr_cr_note(dr_or_cr_notes, self.company) @@ -183,98 +235,104 @@ class PaymentReconciliation(Document): def get_payment_details(self, row, dr_or_cr): return frappe._dict({ - 'voucher_type': row.reference_type, - 'voucher_no' : row.reference_name, - 'voucher_detail_no' : row.reference_row, - 'against_voucher_type' : row.invoice_type, - 'against_voucher' : row.invoice_number, + 'voucher_type': row.get('reference_type'), + 'voucher_no' : row.get('reference_name'), + 'voucher_detail_no' : row.get('reference_row'), + 'against_voucher_type' : row.get('invoice_type'), + 'against_voucher' : row.get('invoice_number'), 'account' : self.receivable_payable_account, 'party_type': self.party_type, 'party': self.party, - 'is_advance' : row.is_advance, + 'is_advance' : row.get('is_advance'), 'dr_or_cr' : dr_or_cr, - 'unadjusted_amount' : flt(row.amount), - 'allocated_amount' : flt(row.allocated_amount), - 'difference_amount': row.difference_amount, - 'difference_account': row.difference_account + 'unreconciled_amount': flt(row.get('unreconciled_amount')), + 'unadjusted_amount' : flt(row.get('amount')), + 'allocated_amount' : flt(row.get('allocated_amount')), + 'difference_amount': flt(row.get('difference_amount')), + 'difference_account': row.get('difference_account') }) - @frappe.whitelist() - def get_difference_amount(self, child_row): - if child_row.get("reference_type") != 'Payment Entry': return - - child_row = frappe._dict(child_row) - - if child_row.invoice_number and " | " in child_row.invoice_number: - child_row.invoice_type, child_row.invoice_number = child_row.invoice_number.split(" | ") - - dr_or_cr = ("credit_in_account_currency" - if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency") - - row = self.get_payment_details(child_row, dr_or_cr) - - doc = frappe.get_doc(row.voucher_type, row.voucher_no) - update_reference_in_payment_entry(row, doc, do_not_save=True) - - return doc.difference_amount - def check_mandatory_to_fetch(self): for fieldname in ["company", "party_type", "party", "receivable_payable_account"]: if not self.get(fieldname): frappe.throw(_("Please select {0} first").format(self.meta.get_label(fieldname))) - def validate_invoice(self): + def validate_entries(self): if not self.get("invoices"): - frappe.throw(_("No records found in the Invoice table")) + frappe.throw(_("No records found in the Invoices table")) if not self.get("payments"): - frappe.throw(_("No records found in the Payment table")) + frappe.throw(_("No records found in the Payments table")) + def validate_allocation(self): unreconciled_invoices = frappe._dict() - for d in self.get("invoices"): - unreconciled_invoices.setdefault(d.invoice_type, {}).setdefault(d.invoice_number, d.outstanding_amount) + + for inv in self.get("invoices"): + unreconciled_invoices.setdefault(inv.invoice_type, {}).setdefault(inv.invoice_number, inv.outstanding_amount) invoices_to_reconcile = [] - for p in self.get("payments"): - if p.invoice_type and p.invoice_number and p.allocated_amount: - invoices_to_reconcile.append(p.invoice_number) + for row in self.get("allocation"): + if row.invoice_type and row.invoice_number and row.allocated_amount: + invoices_to_reconcile.append(row.invoice_number) - if p.invoice_number not in unreconciled_invoices.get(p.invoice_type, {}): - frappe.throw(_("{0}: {1} not found in Invoice Details table") - .format(p.invoice_type, p.invoice_number)) + if flt(row.amount) - flt(row.allocated_amount) < 0: + frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equal to remaining payment amount {2}") + .format(row.idx, row.allocated_amount, row.amount)) - if flt(p.allocated_amount) > flt(p.amount): - frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to Payment Entry amount {2}") - .format(p.idx, p.allocated_amount, p.amount)) - - invoice_outstanding = unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number) - if flt(p.allocated_amount) - invoice_outstanding > 0.009: - frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to invoice outstanding amount {2}") - .format(p.idx, p.allocated_amount, invoice_outstanding)) + invoice_outstanding = unreconciled_invoices.get(row.invoice_type, {}).get(row.invoice_number) + if flt(row.allocated_amount) - invoice_outstanding > 0.009: + frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equal to invoice outstanding amount {2}") + .format(row.idx, row.allocated_amount, invoice_outstanding)) if not invoices_to_reconcile: - frappe.throw(_("Please select Allocated Amount, Invoice Type and Invoice Number in atleast one row")) + frappe.throw(_("No records found in Allocation table")) - def check_condition(self): - cond = " and posting_date >= {0}".format(frappe.db.escape(self.from_date)) if self.from_date else "" - cond += " and posting_date <= {0}".format(frappe.db.escape(self.to_date)) if self.to_date else "" - dr_or_cr = ("debit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' - else "credit_in_account_currency") + def get_conditions(self, get_invoices=False, get_payments=False, get_return_invoices=False): + condition = " and company = '{0}' ".format(self.company) - if self.minimum_amount: - cond += " and `{0}` >= {1}".format(dr_or_cr, flt(self.minimum_amount)) - if self.maximum_amount: - cond += " and `{0}` <= {1}".format(dr_or_cr, flt(self.maximum_amount)) + if get_invoices: + condition += " and posting_date >= {0}".format(frappe.db.escape(self.from_invoice_date)) if self.from_invoice_date else "" + condition += " and posting_date <= {0}".format(frappe.db.escape(self.to_invoice_date)) if self.to_invoice_date else "" + dr_or_cr = ("debit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' + else "credit_in_account_currency") - return cond + if self.minimum_invoice_amount: + condition += " and `{0}` >= {1}".format(dr_or_cr, flt(self.minimum_invoice_amount)) + if self.maximum_invoice_amount: + condition += " and `{0}` <= {1}".format(dr_or_cr, flt(self.maximum_invoice_amount)) + + elif get_return_invoices: + condition = " and doc.company = '{0}' ".format(self.company) + condition += " and doc.posting_date >= {0}".format(frappe.db.escape(self.from_payment_date)) if self.from_payment_date else "" + condition += " and doc.posting_date <= {0}".format(frappe.db.escape(self.to_payment_date)) if self.to_payment_date else "" + dr_or_cr = ("gl.debit_in_account_currency" if erpnext.get_party_account_type(self.party_type) == 'Receivable' + else "gl.credit_in_account_currency") + + if self.minimum_invoice_amount: + condition += " and `{0}` >= {1}".format(dr_or_cr, flt(self.minimum_payment_amount)) + if self.maximum_invoice_amount: + condition += " and `{0}` <= {1}".format(dr_or_cr, flt(self.maximum_payment_amount)) + + else: + condition += " and posting_date >= {0}".format(frappe.db.escape(self.from_payment_date)) if self.from_payment_date else "" + condition += " and posting_date <= {0}".format(frappe.db.escape(self.to_payment_date)) if self.to_payment_date else "" + + if self.minimum_payment_amount: + condition += " and unallocated_amount >= {0}".format(flt(self.minimum_payment_amount)) if get_payments \ + else " and total_debit >= {0}".format(flt(self.minimum_payment_amount)) + if self.maximum_payment_amount: + condition += " and unallocated_amount <= {0}".format(flt(self.maximum_payment_amount)) if get_payments \ + else " and total_debit <= {0}".format(flt(self.maximum_payment_amount)) + + return condition def reconcile_dr_cr_note(dr_cr_notes, company): - for d in dr_cr_notes: + for inv in dr_cr_notes: voucher_type = ('Credit Note' - if d.voucher_type == 'Sales Invoice' else 'Debit Note') + if inv.voucher_type == 'Sales Invoice' else 'Debit Note') reconcile_dr_or_cr = ('debit_in_account_currency' - if d.dr_or_cr == 'credit_in_account_currency' else 'credit_in_account_currency') + if inv.dr_or_cr == 'credit_in_account_currency' else 'credit_in_account_currency') company_currency = erpnext.get_company_currency(company) @@ -283,25 +341,25 @@ def reconcile_dr_cr_note(dr_cr_notes, company): "voucher_type": voucher_type, "posting_date": today(), "company": company, - "multi_currency": 1 if d.currency != company_currency else 0, + "multi_currency": 1 if inv.currency != company_currency else 0, "accounts": [ { - 'account': d.account, - 'party': d.party, - 'party_type': d.party_type, - d.dr_or_cr: abs(d.allocated_amount), - 'reference_type': d.against_voucher_type, - 'reference_name': d.against_voucher, + 'account': inv.account, + 'party': inv.party, + 'party_type': inv.party_type, + inv.dr_or_cr: abs(inv.allocated_amount), + 'reference_type': inv.against_voucher_type, + 'reference_name': inv.against_voucher, 'cost_center': erpnext.get_default_cost_center(company) }, { - 'account': d.account, - 'party': d.party, - 'party_type': d.party_type, - reconcile_dr_or_cr: (abs(d.allocated_amount) - if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)), - 'reference_type': d.voucher_type, - 'reference_name': d.voucher_no, + 'account': inv.account, + 'party': inv.party, + 'party_type': inv.party_type, + reconcile_dr_or_cr: (abs(inv.allocated_amount) + if abs(inv.unadjusted_amount) > abs(inv.allocated_amount) else abs(inv.unadjusted_amount)), + 'reference_type': inv.voucher_type, + 'reference_name': inv.voucher_no, 'cost_center': erpnext.get_default_cost_center(company) } ] diff --git a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py new file mode 100644 index 0000000000..2271f48a2b --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py @@ -0,0 +1,9 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +import unittest + + +class TestPaymentReconciliation(unittest.TestCase): + pass diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/__init__.py b/erpnext/accounts/doctype/payment_reconciliation_allocation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json new file mode 100644 index 0000000000..3653501432 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json @@ -0,0 +1,137 @@ +{ + "actions": [], + "creation": "2021-08-16 17:04:40.185167", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "reference_type", + "reference_name", + "column_break_3", + "invoice_type", + "invoice_number", + "section_break_6", + "allocated_amount", + "unreconciled_amount", + "amount", + "column_break_8", + "is_advance", + "section_break_5", + "difference_amount", + "column_break_7", + "difference_account" + ], + "fields": [ + { + "fieldname": "invoice_number", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Invoice Number", + "options": "invoice_type", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "allocated_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Allocated Amount", + "options": "Currency", + "reqd": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_5", + "fieldtype": "Section Break" + }, + { + "fieldname": "difference_account", + "fieldtype": "Link", + "label": "Difference Account", + "options": "Account", + "read_only": 1 + }, + { + "fieldname": "column_break_7", + "fieldtype": "Column Break" + }, + { + "fieldname": "difference_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Difference Amount", + "options": "Currency", + "read_only": 1 + }, + { + "fieldname": "reference_name", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "label": "Reference Name", + "options": "reference_type", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "is_advance", + "fieldtype": "Data", + "hidden": 1, + "label": "Is Advance", + "read_only": 1 + }, + { + "fieldname": "reference_type", + "fieldtype": "Link", + "label": "Reference Type", + "options": "DocType", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "invoice_type", + "fieldtype": "Link", + "label": "Invoice Type", + "options": "DocType", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_8", + "fieldtype": "Column Break" + }, + { + "fieldname": "unreconciled_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Unreconciled Amount", + "options": "Currency", + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Amount", + "options": "Currency", + "read_only": 1 + } + ], + "istable": 1, + "links": [], + "modified": "2021-08-30 10:58:42.665107", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation Allocation", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.py b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.py new file mode 100644 index 0000000000..9db8e62af0 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.py @@ -0,0 +1,9 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class PaymentReconciliationAllocation(Document): + pass diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json index 6a79a85c34..00c9e1240c 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -44,7 +44,6 @@ { "fieldname": "amount", "fieldtype": "Currency", - "in_list_view": 1, "label": "Amount", "options": "currency", "read_only": 1 @@ -67,7 +66,7 @@ ], "istable": 1, "links": [], - "modified": "2020-07-19 18:12:27.964073", + "modified": "2021-08-24 22:42:40.923179", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Invoice", diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py index 800d800975..5ac1855c03 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PaymentReconciliationInvoice(Document): pass diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index 925a6f10a5..add07e870d 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -11,11 +11,7 @@ "is_advance", "reference_row", "col_break1", - "invoice_number", "amount", - "allocated_amount", - "section_break_10", - "difference_account", "difference_amount", "sec_break1", "remark", @@ -41,6 +37,7 @@ { "fieldname": "posting_date", "fieldtype": "Date", + "in_list_view": 1, "label": "Posting Date", "read_only": 1 }, @@ -62,14 +59,6 @@ "fieldname": "col_break1", "fieldtype": "Column Break" }, - { - "columns": 2, - "fieldname": "invoice_number", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Invoice Number", - "reqd": 1 - }, { "columns": 2, "fieldname": "amount", @@ -79,15 +68,6 @@ "options": "currency", "read_only": 1 }, - { - "columns": 2, - "fieldname": "allocated_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Allocated amount", - "options": "currency", - "reqd": 1 - }, { "fieldname": "sec_break1", "fieldtype": "Section Break" @@ -95,41 +75,27 @@ { "fieldname": "remark", "fieldtype": "Small Text", - "in_list_view": 1, "label": "Remark", "read_only": 1 }, - { - "columns": 2, - "fieldname": "difference_account", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Difference Account", - "options": "Account" - }, - { - "fieldname": "difference_amount", - "fieldtype": "Currency", - "label": "Difference Amount", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "section_break_10", - "fieldtype": "Section Break" - }, { "fieldname": "currency", "fieldtype": "Link", "hidden": 1, "label": "Currency", "options": "Currency" + }, + { + "fieldname": "difference_amount", + "fieldtype": "Currency", + "label": "Difference Amount", + "options": "currency", + "read_only": 1 } ], "istable": 1, "links": [], - "modified": "2020-07-19 18:12:41.682347", + "modified": "2021-08-30 10:51:48.140062", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py index c76f7852c8..78c84ff5a6 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py @@ -2,8 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PaymentReconciliationPayment(Document): pass diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index f83cb375fc..2c967497d5 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -3,18 +3,25 @@ # For license information, please see license.txt from __future__ import unicode_literals + import json + import frappe from frappe import _ +from frappe.integrations.utils import get_payment_gateway_controller from frappe.model.document import Document -from frappe.utils import flt, nowdate, get_url +from frappe.utils import flt, get_url, nowdate +from frappe.utils.background_jobs import enqueue + +from erpnext.accounts.doctype.payment_entry.payment_entry import ( + get_company_defaults, + get_payment_entry, +) +from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate from erpnext.accounts.party import get_party_account, get_party_bank_account from erpnext.accounts.utils import get_account_currency -from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, get_company_defaults -from frappe.integrations.utils import get_payment_gateway_controller -from frappe.utils.background_jobs import enqueue from erpnext.erpnext_integrations.stripe_integration import create_stripe_subscription -from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate + class PaymentRequest(Document): def validate(self): @@ -542,3 +549,11 @@ def make_payment_order(source_name, target_doc=None): }, target_doc, set_missing_values) return doclist + +def validate_payment(doc, method=""): + if not frappe.db.has_column(doc.reference_doctype, 'status'): + return + + status = frappe.db.get_value(doc.reference_doctype, doc.reference_docname, 'status') + if status == 'Paid': + frappe.throw(_("The Payment Request {0} is already paid, cannot process payment twice").format(doc.reference_docname)) \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index ad6ff6f555..c97c873fc4 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -3,11 +3,13 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order + +import frappe + from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.setup.utils import get_exchange_rate test_dependencies = ["Currency Exchange", "Journal Entry", "Contact", "Address"] diff --git a/erpnext/accounts/doctype/payment_schedule/payment_schedule.py b/erpnext/accounts/doctype/payment_schedule/payment_schedule.py index 41740170f0..33d5efa10e 100644 --- a/erpnext/accounts/doctype/payment_schedule/payment_schedule.py +++ b/erpnext/accounts/doctype/payment_schedule/payment_schedule.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/payment_term/payment_term.py b/erpnext/accounts/doctype/payment_term/payment_term.py index 5d4df053fb..a04c183bed 100644 --- a/erpnext/accounts/doctype/payment_term/payment_term.py +++ b/erpnext/accounts/doctype/payment_term/payment_term.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/payment_term/test_payment_term.py b/erpnext/accounts/doctype/payment_term/test_payment_term.py index d9baa5907b..bc0645f9a6 100644 --- a/erpnext/accounts/doctype/payment_term/test_payment_term.py +++ b/erpnext/accounts/doctype/payment_term/test_payment_term.py @@ -2,6 +2,7 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest diff --git a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py index 39627eb376..3568591132 100644 --- a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py +++ b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py @@ -5,9 +5,9 @@ from __future__ import unicode_literals import frappe -from frappe.model.document import Document -from frappe.utils import flt, cint from frappe import _ +from frappe.model.document import Document +from frappe.utils import flt class PaymentTermsTemplate(Document): diff --git a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py index 6daaf1ed74..2052a5093d 100644 --- a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py +++ b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py @@ -2,6 +2,7 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest import frappe diff --git a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py index 54c0fda011..c857a88b9f 100644 --- a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py +++ b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 289278ea8d..888bf9fd94 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -2,13 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt from frappe import _ +from frappe.utils import flt + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimensions, +) from erpnext.accounts.utils import get_account_currency from erpnext.controllers.accounts_controller import AccountsController -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (get_accounting_dimensions, - get_dimensions) + class PeriodClosingVoucher(AccountsController): def validate(self): @@ -54,7 +59,7 @@ class PeriodClosingVoucher(AccountsController): if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries make_gl_entries(gl_entries) - + def get_gl_entries(self): gl_entries = [] pl_accounts = self.get_pl_balances() @@ -77,7 +82,7 @@ class PeriodClosingVoucher(AccountsController): gl_entries += gle_for_net_pl_bal return gl_entries - + def get_pnl_gl_entry(self, pl_accounts): company_cost_center = frappe.db.get_value("Company", self.company, "cost_center") gl_entries = [] diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index 2a636bb338..2d417a4cfb 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -3,13 +3,17 @@ from __future__ import unicode_literals + import unittest + import frappe -from frappe.utils import flt, today -from erpnext.accounts.utils import get_fiscal_year, now -from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry +from frappe.utils import today + from erpnext.accounts.doctype.finance_book.test_finance_book import create_finance_book +from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.accounts.utils import get_fiscal_year, now + class TestPeriodClosingVoucher(unittest.TestCase): def test_closing_entry(self): diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py index 82528728dd..896ebdfd5e 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py @@ -3,13 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -import json from frappe import _ -from frappe.utils import get_datetime, flt +from frappe.utils import flt, get_datetime + +from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import ( + consolidate_pos_invoices, + unconsolidate_pos_invoices, +) from erpnext.controllers.status_updater import StatusUpdater -from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data -from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import consolidate_pos_invoices, unconsolidate_pos_invoices + class POSClosingEntry(StatusUpdater): def validate(self): diff --git a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py index 5b18ebb40d..44c87d6e41 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py @@ -2,14 +2,19 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals -import frappe + import unittest -from frappe.utils import nowdate -from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + +import frappe + +from erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry import ( + make_closing_entry_from_opening, +) from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice -from erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry import make_closing_entry_from_opening from erpnext.accounts.doctype.pos_opening_entry.test_pos_opening_entry import create_opening_entry from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + class TestPOSClosingEntry(unittest.TestCase): def setUp(self): diff --git a/erpnext/accounts/doctype/pos_closing_entry_detail/pos_closing_entry_detail.py b/erpnext/accounts/doctype/pos_closing_entry_detail/pos_closing_entry_detail.py index 46b6c773bc..4293abdfdc 100644 --- a/erpnext/accounts/doctype/pos_closing_entry_detail/pos_closing_entry_detail.py +++ b/erpnext/accounts/doctype/pos_closing_entry_detail/pos_closing_entry_detail.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class POSClosingEntryDetail(Document): pass diff --git a/erpnext/accounts/doctype/pos_closing_entry_taxes/pos_closing_entry_taxes.py b/erpnext/accounts/doctype/pos_closing_entry_taxes/pos_closing_entry_taxes.py index f72d9a61e1..74cf754031 100644 --- a/erpnext/accounts/doctype/pos_closing_entry_taxes/pos_closing_entry_taxes.py +++ b/erpnext/accounts/doctype/pos_closing_entry_taxes/pos_closing_entry_taxes.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class POSClosingEntryTaxes(Document): pass diff --git a/erpnext/accounts/doctype/pos_customer_group/pos_customer_group.py b/erpnext/accounts/doctype/pos_customer_group/pos_customer_group.py index 85c1c9f8dd..570eb9ea17 100644 --- a/erpnext/accounts/doctype/pos_customer_group/pos_customer_group.py +++ b/erpnext/accounts/doctype/pos_customer_group/pos_customer_group.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class POSCustomerGroup(Document): pass diff --git a/erpnext/accounts/doctype/pos_field/pos_field.py b/erpnext/accounts/doctype/pos_field/pos_field.py index b4720b309b..00faebb7ab 100644 --- a/erpnext/accounts/doctype/pos_field/pos_field.py +++ b/erpnext/accounts/doctype/pos_field/pos_field.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSField(Document): pass diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json index 19c6c8f347..bff8587278 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json @@ -622,6 +622,7 @@ "read_only": 1 }, { + "depends_on": "packed_items", "fieldname": "packing_list", "fieldtype": "Section Break", "label": "Packing List", @@ -629,6 +630,7 @@ "print_hide": 1 }, { + "depends_on": "packed_items", "fieldname": "packed_items", "fieldtype": "Table", "label": "Packed Items", @@ -1564,7 +1566,7 @@ "icon": "fa fa-file-text", "is_submittable": 1, "links": [], - "modified": "2021-08-24 18:19:20.728433", + "modified": "2021-08-27 20:12:57.306772", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice", diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 034a217a26..d6e41e6f90 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -3,19 +3,24 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.model.document import Document -from erpnext.accounts.utils import get_account_currency -from erpnext.accounts.party import get_party_account, get_due_date -from frappe.utils import cint, flt, getdate, nowdate, get_link_to_form -from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request -from erpnext.accounts.doctype.loyalty_program.loyalty_program import validate_loyalty_points -from erpnext.stock.doctype.serial_no.serial_no import get_pos_reserved_serial_nos, get_serial_nos -from erpnext.accounts.doctype.sales_invoice.sales_invoice import SalesInvoice, get_bank_cash_account, update_multi_mode_option, get_mode_of_payment_info - +from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate from six import iteritems +from erpnext.accounts.doctype.loyalty_program.loyalty_program import validate_loyalty_points +from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request +from erpnext.accounts.doctype.sales_invoice.sales_invoice import ( + SalesInvoice, + get_bank_cash_account, + get_mode_of_payment_info, + update_multi_mode_option, +) +from erpnext.accounts.party import get_due_date, get_party_account +from erpnext.stock.doctype.serial_no.serial_no import get_pos_reserved_serial_nos, get_serial_nos + + class POSInvoice(SalesInvoice): def __init__(self, *args, **kwargs): super(POSInvoice, self).__init__(*args, **kwargs) @@ -309,7 +314,7 @@ class POSInvoice(SalesInvoice): def set_pos_fields(self, for_validate=False): """Set retail related fields from POS Profiles""" - from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile + from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details if not self.pos_profile: pos_profile = get_pos_profile(self.company) or {} if not pos_profile: @@ -519,6 +524,7 @@ def make_sales_return(source_name, target_doc=None): @frappe.whitelist() def make_merge_log(invoices): import json + from six import string_types if isinstance(invoices, string_types): diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index d2527fb2e5..e6e0dd238f 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -3,14 +3,18 @@ # See license.txt from __future__ import unicode_literals +import copy +import unittest + import frappe -import unittest, copy, time -from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile + from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return -from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt -from erpnext.stock.doctype.item.test_item import make_item +from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.stock.doctype.item.test_item import make_item +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt +from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry + class TestPOSInvoice(unittest.TestCase): @classmethod @@ -213,8 +217,8 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(pos_return.get('payments')[1].amount, -500) def test_pos_return_for_serialized_item(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item(company='_Test Company', target_warehouse="Stores - _TC", cost_center='Main - _TC', expense_account='Cost of Goods Sold - _TC') @@ -239,8 +243,8 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(pos_return.get('items')[0].serial_no, serial_nos[0]) def test_partial_pos_returns(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item(company='_Test Company', target_warehouse="Stores - _TC", cost_center='Main - _TC', expense_account='Cost of Goods Sold - _TC') @@ -293,8 +297,8 @@ class TestPOSInvoice(unittest.TestCase): self.assertRaises(frappe.ValidationError, inv.insert) def test_serialized_item_transaction(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item(company='_Test Company', target_warehouse="Stores - _TC", cost_center='Main - _TC', expense_account='Cost of Goods Sold - _TC') @@ -324,8 +328,8 @@ class TestPOSInvoice(unittest.TestCase): self.assertRaises(frappe.ValidationError, pos2.submit) def test_delivered_serialized_item_transaction(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item(company='_Test Company', target_warehouse="Stores - _TC", cost_center='Main - _TC', expense_account='Cost of Goods Sold - _TC') @@ -353,8 +357,10 @@ class TestPOSInvoice(unittest.TestCase): self.assertRaises(frappe.ValidationError, pos2.submit) def test_loyalty_points(self): + from erpnext.accounts.doctype.loyalty_program.loyalty_program import ( + get_loyalty_program_details_with_points, + ) from erpnext.accounts.doctype.loyalty_program.test_loyalty_program import create_records - from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points create_records() frappe.db.set_value("Customer", "Test Loyalty Customer", "loyalty_program", "Test Single Loyalty") @@ -374,7 +380,10 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(after_cancel_lp_details.loyalty_points, before_lp_details.loyalty_points) def test_loyalty_points_redeemption(self): - from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points + from erpnext.accounts.doctype.loyalty_program.loyalty_program import ( + get_loyalty_program_details_with_points, + ) + # add 10 loyalty points create_pos_invoice(customer="Test Loyalty Customer", rate=10000) @@ -392,8 +401,12 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(after_redeem_lp_details.loyalty_points, 9) def test_merging_into_sales_invoice_with_discount(self): - from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile - from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import consolidate_pos_invoices + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import ( + init_user_and_profile, + ) + from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import ( + consolidate_pos_invoices, + ) frappe.db.sql("delete from `tabPOS Invoice`") test_user, pos_profile = init_user_and_profile() @@ -416,8 +429,12 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(rounded_total, 3470) def test_merging_into_sales_invoice_with_discount_and_inclusive_tax(self): - from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile - from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import consolidate_pos_invoices + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import ( + init_user_and_profile, + ) + from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import ( + consolidate_pos_invoices, + ) frappe.db.sql("delete from `tabPOS Invoice`") test_user, pos_profile = init_user_and_profile() @@ -457,8 +474,12 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(rounded_total, 840) def test_merging_with_validate_selling_price(self): - from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile - from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import consolidate_pos_invoices + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import ( + init_user_and_profile, + ) + from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import ( + consolidate_pos_invoices, + ) if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"): frappe.db.set_value("Selling Settings", "Selling Settings", "validate_selling_price", 1) diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py index 92ce61be52..99e471991c 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSInvoiceItem(Document): pass diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py index e50d437ba6..0be8ca7ee6 100644 --- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py +++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py @@ -3,17 +3,19 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import json + import frappe +import six from frappe import _ -from frappe.model import default_fields +from frappe.core.page.background_jobs.background_jobs import get_info from frappe.model.document import Document +from frappe.model.mapper import map_child_doc, map_doc from frappe.utils import flt, getdate, nowdate from frappe.utils.background_jobs import enqueue -from frappe.model.mapper import map_doc, map_child_doc from frappe.utils.scheduler import is_scheduler_inactive -from frappe.core.page.background_jobs.background_jobs import get_info -import json -import six + class POSInvoiceMergeLog(Document): def validate(self): diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py index 1b9659409c..c531bb9f07 100644 --- a/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py +++ b/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py @@ -3,13 +3,18 @@ # See license.txt from __future__ import unicode_literals -import frappe -import unittest import json -from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice -from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return -from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import consolidate_pos_invoices +import unittest + +import frappe + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile +from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return +from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice +from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import ( + consolidate_pos_invoices, +) + class TestPOSInvoiceMergeLog(unittest.TestCase): def test_consolidated_invoice_creation(self): diff --git a/erpnext/accounts/doctype/pos_invoice_reference/pos_invoice_reference.py b/erpnext/accounts/doctype/pos_invoice_reference/pos_invoice_reference.py index 4c45265f60..9bce082c95 100644 --- a/erpnext/accounts/doctype/pos_invoice_reference/pos_invoice_reference.py +++ b/erpnext/accounts/doctype/pos_invoice_reference/pos_invoice_reference.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSInvoiceReference(Document): pass diff --git a/erpnext/accounts/doctype/pos_item_group/pos_item_group.py b/erpnext/accounts/doctype/pos_item_group/pos_item_group.py index ceaa57ba60..b5ff794ccc 100644 --- a/erpnext/accounts/doctype/pos_item_group/pos_item_group.py +++ b/erpnext/accounts/doctype/pos_item_group/pos_item_group.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class POSItemGroup(Document): pass diff --git a/erpnext/accounts/doctype/pos_opening_entry/pos_opening_entry.py b/erpnext/accounts/doctype/pos_opening_entry/pos_opening_entry.py index 3318fefab1..979479ffb5 100644 --- a/erpnext/accounts/doctype/pos_opening_entry/pos_opening_entry.py +++ b/erpnext/accounts/doctype/pos_opening_entry/pos_opening_entry.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import cint, get_link_to_form + from erpnext.controllers.status_updater import StatusUpdater + class POSOpeningEntry(StatusUpdater): def validate(self): self.validate_pos_profile_and_cashier() diff --git a/erpnext/accounts/doctype/pos_opening_entry/test_pos_opening_entry.py b/erpnext/accounts/doctype/pos_opening_entry/test_pos_opening_entry.py index c115be5ae9..35a2b5835f 100644 --- a/erpnext/accounts/doctype/pos_opening_entry/test_pos_opening_entry.py +++ b/erpnext/accounts/doctype/pos_opening_entry/test_pos_opening_entry.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestPOSOpeningEntry(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/pos_opening_entry_detail/pos_opening_entry_detail.py b/erpnext/accounts/doctype/pos_opening_entry_detail/pos_opening_entry_detail.py index 555706227f..be5d876a16 100644 --- a/erpnext/accounts/doctype/pos_opening_entry_detail/pos_opening_entry_detail.py +++ b/erpnext/accounts/doctype/pos_opening_entry_detail/pos_opening_entry_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSOpeningEntryDetail(Document): pass diff --git a/erpnext/accounts/doctype/pos_payment_method/pos_payment_method.py b/erpnext/accounts/doctype/pos_payment_method/pos_payment_method.py index 8a46d84bfe..851d8efde1 100644 --- a/erpnext/accounts/doctype/pos_payment_method/pos_payment_method.py +++ b/erpnext/accounts/doctype/pos_payment_method/pos_payment_method.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSPaymentMethod(Document): pass diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index cf7ed26d27..b64e2eda2d 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -2,11 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe import msgprint, _ -from frappe.utils import cint, now, get_link_to_form -from six import iteritems +from frappe import _, msgprint from frappe.model.document import Document +from frappe.utils import get_link_to_form, now +from six import iteritems + class POSProfile(Document): def validate(self): diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index 0033965700..83ecfb47bb 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -3,10 +3,12 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.stock.get_item_details import get_pos_profile + +import frappe + from erpnext.accounts.doctype.pos_profile.pos_profile import get_child_nodes +from erpnext.stock.get_item_details import get_pos_profile test_dependencies = ['Item'] diff --git a/erpnext/accounts/doctype/pos_profile_user/pos_profile_user.py b/erpnext/accounts/doctype/pos_profile_user/pos_profile_user.py index d77cddea61..404c4ab629 100644 --- a/erpnext/accounts/doctype/pos_profile_user/pos_profile_user.py +++ b/erpnext/accounts/doctype/pos_profile_user/pos_profile_user.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class POSProfileUser(Document): pass diff --git a/erpnext/accounts/doctype/pos_profile_user/test_pos_profile_user.py b/erpnext/accounts/doctype/pos_profile_user/test_pos_profile_user.py index 5c69ab1fb8..dca3556408 100644 --- a/erpnext/accounts/doctype/pos_profile_user/test_pos_profile_user.py +++ b/erpnext/accounts/doctype/pos_profile_user/test_pos_profile_user.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestPOSProfileUser(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/pos_search_fields/pos_search_fields.py b/erpnext/accounts/doctype/pos_search_fields/pos_search_fields.py index 720ea77745..32f9f9298b 100644 --- a/erpnext/accounts/doctype/pos_search_fields/pos_search_fields.py +++ b/erpnext/accounts/doctype/pos_search_fields/pos_search_fields.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class POSSearchFields(Document): pass diff --git a/erpnext/accounts/doctype/pos_settings/pos_settings.py b/erpnext/accounts/doctype/pos_settings/pos_settings.py index d925dd9d86..5c5aaa04ed 100644 --- a/erpnext/accounts/doctype/pos_settings/pos_settings.py +++ b/erpnext/accounts/doctype/pos_settings/pos_settings.py @@ -3,9 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class POSSettings(Document): def validate(self): pass diff --git a/erpnext/accounts/doctype/pos_settings/test_pos_settings.py b/erpnext/accounts/doctype/pos_settings/test_pos_settings.py index a3df10803c..949fed775b 100644 --- a/erpnext/accounts/doctype/pos_settings/test_pos_settings.py +++ b/erpnext/accounts/doctype/pos_settings/test_pos_settings.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestPOSSettings(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 4903c50e17..e5bf3b8064 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -3,15 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -import json + import copy +import json import re -from frappe import throw, _ -from frappe.utils import flt, cint, getdate +import frappe +from frappe import _, throw from frappe.model.document import Document - +from frappe.utils import cint, flt, getdate from six import string_types apply_on_dict = {"Item Code": "items", @@ -203,13 +203,13 @@ def apply_pricing_rule(args, doc=None): serialized_items = dict() for item_code, val in query_items: serialized_items.setdefault(item_code, val) - + for item in item_list: args_copy = copy.deepcopy(args) args_copy.update(item) data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc) out.append(data) - + if serialized_items.get(item.get('item_code')) and not item.get("serial_no") and set_serial_nos_based_on_fifo and not args.get('is_return'): out[0].update(get_serial_no_for_item(args_copy)) @@ -228,8 +228,12 @@ def get_serial_no_for_item(args): return item_details def get_pricing_rule_for_item(args, price_list_rate=0, doc=None, for_validate=False): - from erpnext.accounts.doctype.pricing_rule.utils import (get_pricing_rules, - get_applied_pricing_rules, get_pricing_rule_items, get_product_discount_rule) + from erpnext.accounts.doctype.pricing_rule.utils import ( + get_applied_pricing_rules, + get_pricing_rule_items, + get_pricing_rules, + get_product_discount_rule, + ) if isinstance(doc, string_types): doc = json.loads(doc) @@ -315,9 +319,8 @@ def update_args_for_pricing_rule(args): if not (args.item_group and args.brand): try: args.item_group, args.brand = frappe.get_cached_value("Item", args.item_code, ["item_group", "brand"]) - except TypeError: - # invalid item_code - return item_details + except frappe.DoesNotExistError: + return if not args.item_group: frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code)) @@ -390,8 +393,10 @@ def apply_price_discount_rule(pricing_rule, item_details, args): if pricing_rule else args.get(field, 0)) def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None): - from erpnext.accounts.doctype.pricing_rule.utils import (get_applied_pricing_rules, - get_pricing_rule_items) + from erpnext.accounts.doctype.pricing_rule.utils import ( + get_applied_pricing_rules, + get_pricing_rule_items, + ) for d in get_applied_pricing_rules(pricing_rules): if not d or not frappe.db.exists("Pricing Rule", d): continue pricing_rule = frappe.get_cached_doc('Pricing Rule', d) diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index 680370b6af..2e2d425dab 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -3,14 +3,18 @@ from __future__ import unicode_literals + import unittest + import frappe -from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice -from erpnext.stock.get_item_details import get_item_details from frappe import MandatoryError -from erpnext.stock.doctype.item.test_item import make_item + +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.healthcare.doctype.lab_test_template.lab_test_template import make_item_price +from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order +from erpnext.stock.doctype.item.test_item import make_item +from erpnext.stock.get_item_details import get_item_details + class TestPricingRule(unittest.TestCase): def setUp(self): @@ -21,9 +25,10 @@ class TestPricingRule(unittest.TestCase): delete_existing_pricing_rules() def test_pricing_rule_for_discount(self): - from erpnext.stock.get_item_details import get_item_details from frappe import MandatoryError + from erpnext.stock.get_item_details import get_item_details + test_record = { "doctype": "Pricing Rule", "title": "_Test Pricing Rule", @@ -103,9 +108,10 @@ class TestPricingRule(unittest.TestCase): self.assertEqual(details.get("discount_percentage"), 15) def test_pricing_rule_for_margin(self): - from erpnext.stock.get_item_details import get_item_details from frappe import MandatoryError + from erpnext.stock.get_item_details import get_item_details + test_record = { "doctype": "Pricing Rule", "title": "_Test Pricing Rule", @@ -196,9 +202,10 @@ class TestPricingRule(unittest.TestCase): self.assertEqual(details.get("discount_percentage"), 10) def test_pricing_rule_for_variants(self): - from erpnext.stock.get_item_details import get_item_details from frappe import MandatoryError + from erpnext.stock.get_item_details import get_item_details + if not frappe.db.exists("Item", "Test Variant PRT"): frappe.get_doc({ "doctype": "Item", diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 5467cb0bc5..12b486e45e 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -8,14 +8,14 @@ from __future__ import unicode_literals import copy import json -from six import string_types - import frappe +from frappe import _, bold +from frappe.utils import cint, flt, fmt_money, get_link_to_form, getdate, today + from erpnext.setup.doctype.item_group.item_group import get_child_item_groups from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses from erpnext.stock.get_item_details import get_conversion_factor -from frappe import _, bold -from frappe.utils import cint, flt, get_link_to_form, getdate, today, fmt_money + class MultiplePricingRuleConflict(frappe.ValidationError): pass @@ -81,7 +81,7 @@ def filter_pricing_rule_based_on_condition(pricing_rules, doc=None): try: if frappe.safe_eval(pricing_rule.condition, None, doc.as_dict()): filtered_pricing_rules.append(pricing_rule) - except: + except Exception: pass else: filtered_pricing_rules.append(pricing_rule) diff --git a/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py index e2f70af4a1..5e10b8411a 100644 --- a/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py +++ b/erpnext/accounts/doctype/pricing_rule_brand/pricing_rule_brand.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PricingRuleBrand(Document): pass diff --git a/erpnext/accounts/doctype/pricing_rule_detail/pricing_rule_detail.py b/erpnext/accounts/doctype/pricing_rule_detail/pricing_rule_detail.py index 3cb7da9158..a90ecbb6f7 100644 --- a/erpnext/accounts/doctype/pricing_rule_detail/pricing_rule_detail.py +++ b/erpnext/accounts/doctype/pricing_rule_detail/pricing_rule_detail.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PricingRuleDetail(Document): pass diff --git a/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py index 4468620314..4746b39e17 100644 --- a/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py +++ b/erpnext/accounts/doctype/pricing_rule_item_code/pricing_rule_item_code.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PricingRuleItemCode(Document): pass diff --git a/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py index d3c36197c7..ff1ba75a60 100644 --- a/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py +++ b/erpnext/accounts/doctype/pricing_rule_item_group/pricing_rule_item_group.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PricingRuleItemGroup(Document): pass diff --git a/erpnext/accounts/doctype/process_deferred_accounting/process_deferred_accounting.py b/erpnext/accounts/doctype/process_deferred_accounting/process_deferred_accounting.py index 5e7583a974..72b7b23e14 100644 --- a/erpnext/accounts/doctype/process_deferred_accounting/process_deferred_accounting.py +++ b/erpnext/accounts/doctype/process_deferred_accounting/process_deferred_accounting.py @@ -3,13 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -import erpnext from frappe import _ from frappe.model.document import Document + +from erpnext.accounts.deferred_revenue import ( + build_conditions, + convert_deferred_expense_to_expense, + convert_deferred_revenue_to_income, +) from erpnext.accounts.general_ledger import make_reverse_gl_entries -from erpnext.accounts.deferred_revenue import convert_deferred_expense_to_expense, \ - convert_deferred_revenue_to_income, build_conditions + class ProcessDeferredAccounting(Document): def validate(self): diff --git a/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py b/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py index 03c269ac76..69e2caa8e8 100644 --- a/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py +++ b/erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py @@ -3,11 +3,17 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe + from erpnext.accounts.doctype.account.test_account import create_account +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import ( + check_gl_entries, + create_sales_invoice, +) from erpnext.stock.doctype.item.test_item import create_item -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice, check_gl_entries + class TestProcessDeferredAccounting(unittest.TestCase): def test_creation_of_ledger_entry_on_submit(self): diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index a12ea4033d..73f3038512 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -3,22 +3,24 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import copy + import frappe from frappe import _ from frappe.model.document import Document -from erpnext.accounts.report.general_ledger.general_ledger import execute as get_soa -from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import execute as get_ageing +from frappe.utils import add_days, add_months, format_date, getdate, today +from frappe.utils.jinja import validate_template +from frappe.utils.pdf import get_pdf +from frappe.www.printview import get_print_style + from erpnext import get_company_currency from erpnext.accounts.party import get_party_account_currency +from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import ( + execute as get_ageing, +) +from erpnext.accounts.report.general_ledger.general_ledger import execute as get_soa -from frappe.utils.print_format import report_to_pdf -from frappe.utils.pdf import get_pdf -from frappe.utils import today, add_days, add_months, getdate, format_date -from frappe.utils.jinja import validate_template - -import copy -from datetime import timedelta -from frappe.www.printview import get_print_style class ProcessStatementOfAccounts(Document): def validate(self): @@ -158,7 +160,7 @@ def get_recipients_and_cc(customer, doc): if doc.cc_to != '': try: cc=[frappe.get_value('User', doc.cc_to, 'email')] - except: + except Exception: pass return recipients, cc diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py index 30efbb3683..7ddcd105af 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestProcessStatementOfAccounts(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/process_statement_of_accounts_customer/process_statement_of_accounts_customer.py b/erpnext/accounts/doctype/process_statement_of_accounts_customer/process_statement_of_accounts_customer.py index 1a760101db..fe94009407 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts_customer/process_statement_of_accounts_customer.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts_customer/process_statement_of_accounts_customer.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class ProcessStatementOfAccountsCustomer(Document): pass diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py index 3d7a891f33..d09f7dc2da 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py @@ -3,10 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cstr -from frappe.model.naming import make_autoname from frappe.model.document import Document pricing_rule_fields = ['apply_on', 'mixed_conditions', 'is_cumulative', 'other_item_code', 'other_item_group', diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme_dashboard.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme_dashboard.py index 54fedb7738..6d07924268 100644 --- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme_dashboard.py +++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme_dashboard.py @@ -1,5 +1,6 @@ from frappe import _ + def get_data(): return { 'fieldname': 'promotional_scheme', diff --git a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py index 286f7cf6ed..190b734cc1 100644 --- a/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py +++ b/erpnext/accounts/doctype/promotional_scheme/test_promotional_scheme.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestPromotionalScheme(unittest.TestCase): def test_promotional_scheme(self): ps = make_promotional_scheme() diff --git a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py index 380ae32f9a..ab8efc3314 100644 --- a/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py +++ b/erpnext/accounts/doctype/promotional_scheme_price_discount/promotional_scheme_price_discount.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PromotionalSchemePriceDiscount(Document): pass diff --git a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py index 2931106f76..85019b4e45 100644 --- a/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py +++ b/erpnext/accounts/doctype/promotional_scheme_product_discount/promotional_scheme_product_discount.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PromotionalSchemeProductDiscount(Document): pass diff --git a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py index 0aeef3ed3a..cb5aaa9c5e 100644 --- a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py +++ b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PSOACostCenter(Document): pass diff --git a/erpnext/accounts/doctype/psoa_project/psoa_project.py b/erpnext/accounts/doctype/psoa_project/psoa_project.py index f4a5dee975..1cd995179d 100644 --- a/erpnext/accounts/doctype/psoa_project/psoa_project.py +++ b/erpnext/accounts/doctype/psoa_project/psoa_project.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PSOAProject(Document): pass diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index e2f02f37ee..62cd90ee9f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -3,29 +3,43 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import frappe, erpnext -from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate, get_link_to_form -from frappe import _, throw -import frappe.defaults -from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account -from erpnext.controllers.buying_controller import BuyingController -from erpnext.accounts.party import get_party_account, get_due_date -from erpnext.accounts.utils import get_account_currency, get_fiscal_year -from erpnext.stock.doctype.purchase_receipt.purchase_receipt import update_billed_amount_based_on_po -from erpnext.stock import get_warehouse_account_map -from erpnext.accounts.general_ledger import make_gl_entries, merge_similar_entries, make_reverse_gl_entries -from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt -from erpnext.buying.utils import check_on_hold_or_closed_status -from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center -from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled +import frappe +from frappe import _, throw from frappe.model.mapper import get_mapped_doc +from frappe.utils import cint, cstr, flt, formatdate, get_link_to_form, getdate, nowdate from six import iteritems -from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_doc,\ - unlink_inter_company_doc, check_if_return_invoice_linked_with_payment_entry -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details + +import erpnext from erpnext.accounts.deferred_revenue import validate_service_stop_date -from erpnext.stock.doctype.purchase_receipt.purchase_receipt import get_item_account_wise_additional_cost +from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt +from erpnext.accounts.doctype.sales_invoice.sales_invoice import ( + check_if_return_invoice_linked_with_payment_entry, + unlink_inter_company_doc, + update_linked_doc, + validate_inter_company_party, +) +from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import ( + get_party_tax_withholding_details, +) +from erpnext.accounts.general_ledger import ( + get_round_off_account_and_cost_center, + make_gl_entries, + make_reverse_gl_entries, + merge_similar_entries, +) +from erpnext.accounts.party import get_due_date, get_party_account +from erpnext.accounts.utils import get_account_currency, get_fiscal_year +from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled +from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account +from erpnext.buying.utils import check_on_hold_or_closed_status +from erpnext.controllers.buying_controller import BuyingController +from erpnext.stock import get_warehouse_account_map +from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( + get_item_account_wise_additional_cost, + update_billed_amount_based_on_po, +) + class WarehouseMissingError(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_dashboard.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_dashboard.py index b6467a3d5c..4cc319d594 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_dashboard.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'purchase_invoice', diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 06f4fdb799..51f58b7402 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -3,20 +3,25 @@ from __future__ import unicode_literals + import unittest -import frappe, erpnext -import frappe.model + +import frappe +from frappe.utils import add_days, cint, flt, getdate, nowdate, today + +import erpnext +from erpnext.accounts.doctype.account.test_account import create_account, get_inventory_account from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry -from frappe.utils import cint, flt, today, nowdate, add_days, getdate -import frappe.defaults -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt, get_taxes +from erpnext.buying.doctype.supplier.test_supplier import create_supplier from erpnext.controllers.accounts_controller import get_payment_terms from erpnext.exceptions import InvalidCurrency -from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction from erpnext.projects.doctype.project.test_project import make_project -from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account from erpnext.stock.doctype.item.test_item import create_item -from erpnext.buying.doctype.supplier.test_supplier import create_supplier +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import ( + get_taxes, + make_purchase_receipt, +) +from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"] test_ignore = ["Serial No"] @@ -231,7 +236,9 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(expected_values[gle.account][2], gle.credit) def test_purchase_invoice_with_exchange_rate_difference(self): - from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice as create_purchase_invoice + from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( + make_purchase_invoice as create_purchase_invoice, + ) pr = make_purchase_receipt(company="_Test Company with perpetual inventory", warehouse='Stores - TCP1', currency = "USD", conversion_rate = 70) @@ -401,8 +408,9 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(tax.total, expected_values[i][2]) def test_purchase_invoice_with_advance(self): - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.copy_doc(jv_test_records[1]) jv.insert() @@ -441,8 +449,9 @@ class TestPurchaseInvoice(unittest.TestCase): where reference_type='Purchase Invoice' and reference_name=%s""", pi.name)) def test_invoice_with_advance_and_multi_payment_terms(self): - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.copy_doc(jv_test_records[1]) jv.insert() @@ -714,8 +723,9 @@ class TestPurchaseInvoice(unittest.TestCase): "warehouse"), pi.get("items")[0].rejected_warehouse) def test_outstanding_amount_after_advance_jv_cancelation(self): - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.copy_doc(jv_test_records[1]) jv.accounts[0].is_advance = 'Yes' @@ -794,8 +804,7 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(flt(pi.outstanding_amount), flt(pi.rounded_total + pi.total_advance)) def test_purchase_invoice_with_shipping_rule(self): - from erpnext.accounts.doctype.shipping_rule.test_shipping_rule \ - import create_shipping_rule + from erpnext.accounts.doctype.shipping_rule.test_shipping_rule import create_shipping_rule shipping_rule = create_shipping_rule(shipping_rule_type = "Buying", shipping_rule_name = "Shipping Rule - Purchase Invoice Test") @@ -1133,9 +1142,9 @@ class TestPurchaseInvoice(unittest.TestCase): frappe.db.set_value("Company", "_Test Company", "exchange_gain_loss_account", original_account) def test_purchase_invoice_advance_taxes(self): - from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry from erpnext.buying.doctype.purchase_order.purchase_order import get_mapped_purchase_invoice + from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order # create a new supplier to test supplier = create_supplier(supplier_name = '_Test TDS Advance Supplier', diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py index d157837a7a..ec2ce65168 100644 --- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py +++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PurchaseInvoiceAdvance(Document): pass diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index a7618e2c74..d39a9fc058 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -8,6 +8,7 @@ "engine": "InnoDB", "field_order": [ "item_code", + "product_bundle", "col_break1", "item_name", "description_section", @@ -857,12 +858,19 @@ "fieldtype": "Link", "label": "Discount Account", "options": "Account" + }, + { + "fieldname": "product_bundle", + "fieldtype": "Link", + "label": "Product Bundle", + "options": "Product Bundle", + "read_only": 1 } ], "idx": 1, "istable": 1, "links": [], - "modified": "2021-08-12 20:14:48.506639", + "modified": "2021-09-01 16:04:03.538643", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py index 50ec7d8b4d..ad2a24c0e2 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PurchaseInvoiceItem(Document): pass diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py index 5854ddee94..34ac25753b 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PurchaseTaxesandCharges(Document): pass diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.py index efcef469bd..53b549f682 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.py @@ -3,10 +3,14 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document -from erpnext.accounts.doctype.sales_taxes_and_charges_template.sales_taxes_and_charges_template \ - import valdiate_taxes_and_charges_template + +from erpnext.accounts.doctype.sales_taxes_and_charges_template.sales_taxes_and_charges_template import ( + valdiate_taxes_and_charges_template, +) + class PurchaseTaxesandChargesTemplate(Document): def validate(self): diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.py index 97fbca31b6..c60c81b723 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Purchase Taxes and Charges Template') diff --git a/erpnext/accounts/doctype/salary_component_account/salary_component_account.py b/erpnext/accounts/doctype/salary_component_account/salary_component_account.py index 983d0156a5..d96ef62c29 100644 --- a/erpnext/accounts/doctype/salary_component_account/salary_component_account.py +++ b/erpnext/accounts/doctype/salary_component_account/salary_component_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SalaryComponentAccount(Document): pass diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 2dd3d690e9..2cb9acfa2a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -578,6 +578,9 @@ frappe.ui.form.on('Sales Invoice', { frm.add_fetch('payment_term', 'invoice_portion', 'invoice_portion'); frm.add_fetch('payment_term', 'description', 'description'); + frm.set_df_property('packed_items', 'cannot_add_rows', true); + frm.set_df_property('packed_items', 'cannot_delete_rows', true); + frm.set_query("account_for_change_amount", function() { return { filters: { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index d8aa32e224..b5620ae6a9 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -247,7 +247,7 @@ "depends_on": "customer", "fetch_from": "customer.customer_name", "fieldname": "customer_name", - "fieldtype": "Small Text", + "fieldtype": "Data", "hide_days": 1, "hide_seconds": 1, "in_global_search": 1, @@ -695,7 +695,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "Scan Barcode", - "length": 1, "options": "Barcode" }, { @@ -727,6 +726,7 @@ "read_only": 1 }, { + "depends_on": "packed_items", "fieldname": "packing_list", "fieldtype": "Section Break", "hide_days": 1, @@ -736,6 +736,7 @@ "print_hide": 1 }, { + "depends_on": "packed_items", "fieldname": "packed_items", "fieldtype": "Table", "hide_days": 1, @@ -1060,7 +1061,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "Apply Additional Discount On", - "length": 15, "options": "\nGrand Total\nNet Total", "print_hide": 1 }, @@ -1147,7 +1147,7 @@ { "description": "In Words will be visible once you save the Sales Invoice.", "fieldname": "base_in_words", - "fieldtype": "Small Text", + "fieldtype": "Data", "hide_days": 1, "hide_seconds": 1, "label": "In Words (Company Currency)", @@ -1207,7 +1207,7 @@ }, { "fieldname": "in_words", - "fieldtype": "Small Text", + "fieldtype": "Data", "hide_days": 1, "hide_seconds": 1, "label": "In Words", @@ -1560,7 +1560,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "Print Language", - "length": 6, "print_hide": 1, "read_only": 1 }, @@ -1648,7 +1647,6 @@ "hide_seconds": 1, "in_standard_filter": 1, "label": "Status", - "length": 30, "no_copy": 1, "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nUnpaid and Discounted\nOverdue and Discounted\nOverdue\nCancelled\nInternal Transfer", "print_hide": 1, @@ -1708,7 +1706,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "Is Opening Entry", - "length": 4, "oldfieldname": "is_opening", "oldfieldtype": "Select", "options": "No\nYes", @@ -1720,7 +1717,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "C-Form Applicable", - "length": 4, "no_copy": 1, "options": "No\nYes", "print_hide": 1 @@ -2021,7 +2017,7 @@ "link_fieldname": "consolidated_invoice" } ], - "modified": "2021-08-25 14:46:05.279588", + "modified": "2021-08-27 20:13:40.456462", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index fe3ed1670d..ec249c2419 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -2,34 +2,51 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext -import frappe.defaults -from frappe.utils import cint, flt, getdate, add_days, add_months, cstr, nowdate, get_link_to_form, formatdate + +import frappe from frappe import _, msgprint, throw -from erpnext.accounts.party import get_party_account, get_due_date, get_party_details -from frappe.model.mapper import get_mapped_doc -from erpnext.controllers.selling_controller import SellingController -from erpnext.accounts.utils import get_account_currency -from erpnext.stock.doctype.delivery_note.delivery_note import update_billed_amount_based_on_so -from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data -from erpnext.assets.doctype.asset.depreciation \ - import get_disposal_account_and_cost_center, get_gl_entries_on_asset_disposal, get_gl_entries_on_asset_regain, post_depreciation_entries -from erpnext.stock.doctype.batch.batch import set_batch_nos -from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, get_delivery_note_serial_no -from erpnext.setup.doctype.company.company import update_company_current_month_sales -from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center -from erpnext.accounts.doctype.loyalty_program.loyalty_program import \ - get_loyalty_program_details_with_points, get_loyalty_details, validate_loyalty_points -from erpnext.accounts.deferred_revenue import validate_service_stop_date -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details -from frappe.model.utils import get_fetch_values from frappe.contacts.doctype.address.address import get_address_display -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details - -from erpnext.healthcare.utils import manage_invoice_submit_cancel - +from frappe.model.mapper import get_mapped_doc +from frappe.model.utils import get_fetch_values +from frappe.utils import ( + add_days, + add_months, + cint, + cstr, + flt, + formatdate, + get_link_to_form, + getdate, + nowdate, +) from six import iteritems +import erpnext +from erpnext.accounts.deferred_revenue import validate_service_stop_date +from erpnext.accounts.doctype.loyalty_program.loyalty_program import ( + get_loyalty_program_details_with_points, + validate_loyalty_points, +) +from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import ( + get_party_tax_withholding_details, +) +from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center +from erpnext.accounts.party import get_due_date, get_party_account, get_party_details +from erpnext.accounts.utils import get_account_currency +from erpnext.assets.doctype.asset.depreciation import ( + get_disposal_account_and_cost_center, + get_gl_entries_on_asset_disposal, + get_gl_entries_on_asset_regain, + post_depreciation_entries, +) +from erpnext.controllers.selling_controller import SellingController +from erpnext.healthcare.utils import manage_invoice_submit_cancel +from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data +from erpnext.setup.doctype.company.company import update_company_current_month_sales +from erpnext.stock.doctype.batch.batch import set_batch_nos +from erpnext.stock.doctype.delivery_note.delivery_note import update_billed_amount_based_on_so +from erpnext.stock.doctype.serial_no.serial_no import get_delivery_note_serial_no, get_serial_nos + form_grid_templates = { "items": "templates/form_grid/item_grid.html" } @@ -481,7 +498,7 @@ class SalesInvoice(SellingController): if not self.account_for_change_amount: self.account_for_change_amount = frappe.get_cached_value('Company', self.company, 'default_cash_account') - from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile + from erpnext.stock.get_item_details import get_pos_profile, get_pos_profile_item_details if not self.pos_profile: pos_profile = get_pos_profile(self.company) or {} if not pos_profile: @@ -1375,8 +1392,10 @@ class SalesInvoice(SellingController): # redeem the loyalty points. def apply_loyalty_points(self): - from erpnext.accounts.doctype.loyalty_point_entry.loyalty_point_entry \ - import get_loyalty_point_entries, get_redemption_details + from erpnext.accounts.doctype.loyalty_point_entry.loyalty_point_entry import ( + get_loyalty_point_entries, + get_redemption_details, + ) loyalty_point_entries = get_loyalty_point_entries(self.customer, self.loyalty_program, self.company, self.posting_date) redemption_details = get_redemption_details(self.customer, self.loyalty_program, self.company) @@ -2009,7 +2028,11 @@ def get_mode_of_payment_info(mode_of_payment, company): @frappe.whitelist() def create_dunning(source_name, target_doc=None): from frappe.model.mapper import get_mapped_doc - from erpnext.accounts.doctype.dunning.dunning import get_dunning_letter_text, calculate_interest_and_amount + + from erpnext.accounts.doctype.dunning.dunning import ( + calculate_interest_and_amount, + get_dunning_letter_text, + ) def set_missing_values(source, target): target.sales_invoice = source_name target.outstanding_amount = source.outstanding_amount diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py index 3238ead431..64b35b2987 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'sales_invoice', diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index e06a3bb5b1..da0c315193 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2,31 +2,39 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext +import copy +import unittest -import unittest, copy, time -from frappe.utils import nowdate, flt, getdate, cint, add_days, add_months +import frappe from frappe.model.dynamic_links import get_dynamic_link_map -from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction -from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice -from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import WarehouseMissingError -from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile -from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data -from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries -from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency -from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError from frappe.model.naming import make_autoname -from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account -from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data -from erpnext.stock.doctype.item.test_item import create_item +from frappe.utils import add_days, flt, getdate, nowdate from six import iteritems + +import erpnext +from erpnext.accounts.doctype.account.test_account import create_account, get_inventory_account +from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import WarehouseMissingError +from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + unlink_payment_on_cancel_of_invoice, +) from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_transaction -from erpnext.regional.india.utils import get_ewb_data -from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt -from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice -from erpnext.stock.utils import get_incoming_rate from erpnext.accounts.utils import PaymentEntryUnlinkError +from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries +from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data +from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data +from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency +from erpnext.regional.india.utils import get_ewb_data +from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice +from erpnext.stock.doctype.item.test_item import create_item +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt +from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError +from erpnext.stock.doctype.stock_entry.test_stock_entry import ( + get_qty_after_transaction, + make_stock_entry, +) +from erpnext.stock.utils import get_incoming_rate + class TestSalesInvoice(unittest.TestCase): def make(self): @@ -677,8 +685,9 @@ class TestSalesInvoice(unittest.TestCase): def test_payment(self): w = self.make() - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.get_doc(frappe.copy_doc(jv_test_records[0])) jv.get("accounts")[0].reference_type = w.doctype @@ -944,16 +953,18 @@ class TestSalesInvoice(unittest.TestCase): def _insert_purchase_receipt(self): - from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ - as pr_test_records + from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import ( + test_records as pr_test_records, + ) pr = frappe.copy_doc(pr_test_records[0]) pr.naming_series = "_T-Purchase Receipt-" pr.insert() pr.submit() def _insert_delivery_note(self): - from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \ - as dn_test_records + from erpnext.stock.doctype.delivery_note.test_delivery_note import ( + test_records as dn_test_records, + ) dn = frappe.copy_doc(dn_test_records[0]) dn.naming_series = "_T-Delivery Note-" dn.insert() @@ -961,8 +972,9 @@ class TestSalesInvoice(unittest.TestCase): return dn def test_sales_invoice_with_advance(self): - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.copy_doc(jv_test_records[0]) jv.insert() @@ -994,8 +1006,8 @@ class TestSalesInvoice(unittest.TestCase): si.cancel() def test_serialized(self): - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item() serial_nos = get_serial_nos(se.get("items")[0].serial_no) @@ -1048,9 +1060,9 @@ class TestSalesInvoice(unittest.TestCase): check if the sales invoice item serial numbers and the delivery note items serial numbers are same """ - from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item se = make_serialized_item() serial_nos = get_serial_nos(se.get("items")[0].serial_no) @@ -1290,8 +1302,9 @@ class TestSalesInvoice(unittest.TestCase): self.assertEqual(si.get("items")[0].rate, flt((price_list_rate*25)/100 + price_list_rate)) def test_outstanding_amount_after_advance_jv_cancelation(self): - from erpnext.accounts.doctype.journal_entry.test_journal_entry \ - import test_records as jv_test_records + from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( + test_records as jv_test_records, + ) jv = frappe.copy_doc(jv_test_records[0]) jv.accounts[0].is_advance = 'Yes' @@ -1577,8 +1590,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEqual(expected_values[gle.account][2], gle.credit) def test_sales_invoice_with_shipping_rule(self): - from erpnext.accounts.doctype.shipping_rule.test_shipping_rule \ - import create_shipping_rule + from erpnext.accounts.doctype.shipping_rule.test_shipping_rule import create_shipping_rule shipping_rule = create_shipping_rule(shipping_rule_type = "Selling", shipping_rule_name = "Shipping Rule - Sales Invoice Test") @@ -2129,7 +2141,9 @@ class TestSalesInvoice(unittest.TestCase): self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC") def test_sales_invoice_with_discount_accounting_enabled(self): - from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting + from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + enable_discount_accounting, + ) enable_discount_accounting() @@ -2147,7 +2161,9 @@ class TestSalesInvoice(unittest.TestCase): enable_discount_accounting(enable=0) def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self): - from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting + from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + enable_discount_accounting, + ) enable_discount_accounting() additional_discount_account = create_account(account_name="Discount Account", @@ -2201,7 +2217,9 @@ class TestSalesInvoice(unittest.TestCase): self.assertTrue(schedule.journal_entry) def test_sales_invoice_against_supplier(self): - from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import make_customer + from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import ( + make_customer, + ) from erpnext.buying.doctype.supplier.test_supplier import create_supplier # create a customer diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py index 28aeef4d5e..ae69598a66 100644 --- a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py +++ b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class SalesInvoiceAdvance(Document): pass diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index a73b03acc8..063c591f76 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class SalesInvoiceItem(Document): pass diff --git a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.py b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.py index cc0b7a620d..a980ece580 100644 --- a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.py +++ b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SalesInvoicePayment(Document): pass diff --git a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.py b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.py index afc05ab7ed..e8d4b114fe 100644 --- a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.py +++ b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SalesInvoiceTimesheet(Document): pass diff --git a/erpnext/accounts/doctype/sales_partner_item/sales_partner_item.py b/erpnext/accounts/doctype/sales_partner_item/sales_partner_item.py index 9796c7b0cc..97489d155f 100644 --- a/erpnext/accounts/doctype/sales_partner_item/sales_partner_item.py +++ b/erpnext/accounts/doctype/sales_partner_item/sales_partner_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class SalesPartnerItem(Document): pass diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py index b1de9d85fd..39872f3377 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class SalesTaxesandCharges(Document): pass diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js index 97a6fdd336..066c4eae43 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js @@ -4,4 +4,3 @@ cur_frm.cscript.tax_table = "Sales Taxes and Charges"; {% include "erpnext/public/js/controllers/accounts.js" %} - diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.py b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.py index 8f9eb6577b..0a0bb3e00b 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.py @@ -2,11 +2,19 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt from frappe.model.document import Document -from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax, validate_cost_center, validate_account_head +from frappe.utils import flt + +from erpnext.controllers.accounts_controller import ( + validate_account_head, + validate_cost_center, + validate_inclusive_tax, + validate_taxes_and_charges, +) + class SalesTaxesandChargesTemplate(Document): def validate(self): diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.py b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.py index 1c0c0c77e7..1cad4129f8 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.py @@ -3,9 +3,10 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + test_records = frappe.get_test_records('Sales Taxes and Charges Template') class TestSalesTaxesandChargesTemplate(unittest.TestCase): diff --git a/erpnext/accounts/doctype/share_balance/share_balance.py b/erpnext/accounts/doctype/share_balance/share_balance.py index bd165cd38a..0353e99823 100644 --- a/erpnext/accounts/doctype/share_balance/share_balance.py +++ b/erpnext/accounts/doctype/share_balance/share_balance.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ShareBalance(Document): pass diff --git a/erpnext/accounts/doctype/share_transfer/share_transfer.py b/erpnext/accounts/doctype/share_transfer/share_transfer.py index 3d4543fb05..5117ef8b5b 100644 --- a/erpnext/accounts/doctype/share_transfer/share_transfer.py +++ b/erpnext/accounts/doctype/share_transfer/share_transfer.py @@ -3,13 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.model.document import Document -from frappe.model.naming import make_autoname from frappe.exceptions import ValidationError +from frappe.model.document import Document +from frappe.model.naming import make_autoname from frappe.utils import nowdate + class ShareDontExists(ValidationError): pass class ShareTransfer(Document): diff --git a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py index 2ff9b02129..b40e5fbbf8 100644 --- a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py +++ b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py @@ -3,8 +3,10 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe + from erpnext.accounts.doctype.share_transfer.share_transfer import ShareDontExists test_dependencies = ["Share Type", "Shareholder"] diff --git a/erpnext/accounts/doctype/share_type/share_type.py b/erpnext/accounts/doctype/share_type/share_type.py index ab4b8bc1ef..5b133aa34a 100644 --- a/erpnext/accounts/doctype/share_type/share_type.py +++ b/erpnext/accounts/doctype/share_type/share_type.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ShareType(Document): pass diff --git a/erpnext/accounts/doctype/share_type/test_share_type.py b/erpnext/accounts/doctype/share_type/test_share_type.py index 1c1f051658..a6f8d611c1 100644 --- a/erpnext/accounts/doctype/share_type/test_share_type.py +++ b/erpnext/accounts/doctype/share_type/test_share_type.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestShareType(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/shareholder/shareholder.py b/erpnext/accounts/doctype/shareholder/shareholder.py index c507fcfaa9..12c50c8283 100644 --- a/erpnext/accounts/doctype/shareholder/shareholder.py +++ b/erpnext/accounts/doctype/shareholder/shareholder.py @@ -3,9 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + +from frappe.contacts.address_and_contact import ( + delete_contact_and_address, + load_address_and_contact, +) from frappe.model.document import Document -from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address + class Shareholder(Document): def onload(self): diff --git a/erpnext/accounts/doctype/shareholder/shareholder_dashboard.py b/erpnext/accounts/doctype/shareholder/shareholder_dashboard.py index 3b77fd51b5..0084f2567a 100644 --- a/erpnext/accounts/doctype/shareholder/shareholder_dashboard.py +++ b/erpnext/accounts/doctype/shareholder/shareholder_dashboard.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -from frappe import _ - def get_data(): return { diff --git a/erpnext/accounts/doctype/shareholder/test_shareholder.py b/erpnext/accounts/doctype/shareholder/test_shareholder.py index 9ce00932fa..6790fdd2ff 100644 --- a/erpnext/accounts/doctype/shareholder/test_shareholder.py +++ b/erpnext/accounts/doctype/shareholder/test_shareholder.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestShareholder(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index d32a348741..2852101472 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -4,10 +4,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _, msgprint, throw -from frappe.utils import flt, fmt_money from frappe.model.document import Document +from frappe.utils import flt, fmt_money + +import erpnext + class OverlappingConditionError(frappe.ValidationError): pass class FromGreaterThanToError(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py index abc6ab82d3..bdd9be3bed 100644 --- a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py @@ -2,9 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError + +import frappe + +from erpnext.accounts.doctype.shipping_rule.shipping_rule import ( + FromGreaterThanToError, + ManyBlankToValuesError, + OverlappingConditionError, +) test_records = frappe.get_test_records('Shipping Rule') diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py index db6ef117c2..66cd269e51 100644 --- a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py +++ b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py @@ -4,9 +4,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class ShippingRuleCondition(Document): pass diff --git a/erpnext/accounts/doctype/shipping_rule_country/shipping_rule_country.py b/erpnext/accounts/doctype/shipping_rule_country/shipping_rule_country.py index b9646cfc29..9576acd0ab 100644 --- a/erpnext/accounts/doctype/shipping_rule_country/shipping_rule_country.py +++ b/erpnext/accounts/doctype/shipping_rule_country/shipping_rule_country.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ShippingRuleCountry(Document): pass diff --git a/erpnext/accounts/doctype/south_africa_vat_account/south_africa_vat_account.py b/erpnext/accounts/doctype/south_africa_vat_account/south_africa_vat_account.py index 4bd8c65a04..d9a3bcc0df 100644 --- a/erpnext/accounts/doctype/south_africa_vat_account/south_africa_vat_account.py +++ b/erpnext/accounts/doctype/south_africa_vat_account/south_africa_vat_account.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class SouthAfricaVATAccount(Document): pass diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index 8bf7b78f58..445eb3c709 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -6,13 +6,27 @@ from __future__ import unicode_literals import frappe -import erpnext from frappe import _ from frappe.model.document import Document -from frappe.utils.data import nowdate, getdate, cstr, cint, add_days, date_diff, get_last_day, add_to_date, flt -from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions +from frappe.utils.data import ( + add_days, + add_to_date, + cint, + cstr, + date_diff, + flt, + get_last_day, + getdate, + nowdate, +) + +import erpnext from erpnext import get_default_company +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) +from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate + class Subscription(Document): def before_insert(self): diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index 4f2cf487a4..e2cf4d5a44 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -6,9 +6,18 @@ from __future__ import unicode_literals import unittest import frappe +from frappe.utils.data import ( + add_days, + add_months, + add_to_date, + date_diff, + flt, + get_date_str, + nowdate, +) + from erpnext.accounts.doctype.subscription.subscription import get_prorata_factor -from frappe.utils.data import (nowdate, add_days, add_to_date, add_months, date_diff, flt, get_date_str, - get_first_day, get_last_day) + def create_plan(): if not frappe.db.exists('Subscription Plan', '_Test Plan Name'): diff --git a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py index 6f459b4790..687c94cce2 100644 --- a/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py +++ b/erpnext/accounts/doctype/subscription_invoice/subscription_invoice.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SubscriptionInvoice(Document): pass diff --git a/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py b/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py index e60a4eeca9..2cc3038d91 100644 --- a/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py +++ b/erpnext/accounts/doctype/subscription_invoice/test_subscription_invoice.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestSubscriptionInvoice(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py index a341c2af6a..c7bb58cb26 100644 --- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py +++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import get_first_day, get_last_day, date_diff, flt, getdate from frappe.model.document import Document +from frappe.utils import date_diff, flt, get_first_day, get_last_day, getdate + from erpnext.utilities.product import get_price + class SubscriptionPlan(Document): def validate(self): self.validate_interval_count() diff --git a/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py b/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py index 73afbf620e..ba99763247 100644 --- a/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py +++ b/erpnext/accounts/doctype/subscription_plan/test_subscription_plan.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestSubscriptionPlan(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py b/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py index 1d9606ff78..a63a27700c 100644 --- a/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py +++ b/erpnext/accounts/doctype/subscription_plan_detail/subscription_plan_detail.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SubscriptionPlanDetail(Document): pass diff --git a/erpnext/accounts/doctype/subscription_settings/subscription_settings.py b/erpnext/accounts/doctype/subscription_settings/subscription_settings.py index cc378e4d9f..54735834ba 100644 --- a/erpnext/accounts/doctype/subscription_settings/subscription_settings.py +++ b/erpnext/accounts/doctype/subscription_settings/subscription_settings.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SubscriptionSettings(Document): pass diff --git a/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py b/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py index 82c7e1d269..5875ee069e 100644 --- a/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py +++ b/erpnext/accounts/doctype/subscription_settings/test_subscription_settings.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestSubscriptionSettings(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/supplier_group_item/supplier_group_item.py b/erpnext/accounts/doctype/supplier_group_item/supplier_group_item.py index de0444ee19..61c16fe0ff 100644 --- a/erpnext/accounts/doctype/supplier_group_item/supplier_group_item.py +++ b/erpnext/accounts/doctype/supplier_group_item/supplier_group_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class SupplierGroupItem(Document): pass diff --git a/erpnext/accounts/doctype/supplier_item/supplier_item.py b/erpnext/accounts/doctype/supplier_item/supplier_item.py index ad66e230c8..2105b1d332 100644 --- a/erpnext/accounts/doctype/supplier_item/supplier_item.py +++ b/erpnext/accounts/doctype/supplier_item/supplier_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class SupplierItem(Document): pass diff --git a/erpnext/accounts/doctype/tax_category/tax_category.py b/erpnext/accounts/doctype/tax_category/tax_category.py index 2870e3200f..df31a5e45f 100644 --- a/erpnext/accounts/doctype/tax_category/tax_category.py +++ b/erpnext/accounts/doctype/tax_category/tax_category.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class TaxCategory(Document): pass diff --git a/erpnext/accounts/doctype/tax_category/test_tax_category.py b/erpnext/accounts/doctype/tax_category/test_tax_category.py index 548d00852a..90931058f0 100644 --- a/erpnext/accounts/doctype/tax_category/test_tax_category.py +++ b/erpnext/accounts/doctype/tax_category/test_tax_category.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestTaxCategory(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py index 5814231817..150498d6ac 100644 --- a/erpnext/accounts/doctype/tax_rule/tax_rule.py +++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py @@ -3,19 +3,21 @@ # For license information, please see license.txt from __future__ import unicode_literals -from past.builtins import cmp -import frappe -from frappe import _ -from frappe.model.document import Document -from frappe.utils import cstr, cint -from frappe.contacts.doctype.address.address import get_default_address -from frappe.utils.nestedset import get_root_of -from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups import functools +import frappe +from frappe import _ +from frappe.contacts.doctype.address.address import get_default_address +from frappe.model.document import Document +from frappe.utils import cint, cstr +from frappe.utils.nestedset import get_root_of +from past.builtins import cmp from six import iteritems +from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups + + class IncorrectCustomerGroup(frappe.ValidationError): pass class IncorrectSupplierType(frappe.ValidationError): pass class ConflictingTaxRule(frappe.ValidationError): pass diff --git a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py index cf7226822e..f937274edf 100644 --- a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py +++ b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py @@ -3,16 +3,19 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.accounts.doctype.tax_rule.tax_rule import IncorrectCustomerGroup, IncorrectSupplierType, ConflictingTaxRule, get_tax_template -from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity + +import frappe + +from erpnext.accounts.doctype.tax_rule.tax_rule import ConflictingTaxRule, get_tax_template from erpnext.crm.doctype.opportunity.opportunity import make_quotation +from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity test_records = frappe.get_test_records('Tax Rule') from six import iteritems + class TestTaxRule(unittest.TestCase): @classmethod def setUpClass(cls): diff --git a/erpnext/accounts/doctype/tax_withholding_account/tax_withholding_account.py b/erpnext/accounts/doctype/tax_withholding_account/tax_withholding_account.py index 76e3fa32b0..fd194829e5 100644 --- a/erpnext/accounts/doctype/tax_withholding_account/tax_withholding_account.py +++ b/erpnext/accounts/doctype/tax_withholding_account/tax_withholding_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class TaxWithholdingAccount(Document): pass diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index 06b8df1dfe..33b7e475e5 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import flt, getdate, cint +from frappe.utils import cint, getdate + from erpnext.accounts.utils import get_fiscal_year + class TaxWithholdingCategory(Document): def validate(self): self.validate_dates() @@ -255,7 +258,7 @@ def get_deducted_tax(taxable_vouchers, tax_details): def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers): tds_amount = 0 invoice_filters = { - 'name': ('in', vouchers), + 'name': ('in', vouchers), 'docstatus': 1, 'apply_tds': 1 } diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category_dashboard.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category_dashboard.py index d51ba65b13..152ee46081 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category_dashboard.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category_dashboard.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -from frappe import _ - def get_data(): return { diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py index 138aaec6ab..8a88d798d8 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py @@ -3,11 +3,12 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import today + from erpnext.accounts.utils import get_fiscal_year -from erpnext.buying.doctype.supplier.test_supplier import create_supplier test_dependencies = ["Supplier Group", "Customer Group"] diff --git a/erpnext/accounts/doctype/tax_withholding_rate/tax_withholding_rate.py b/erpnext/accounts/doctype/tax_withholding_rate/tax_withholding_rate.py index 6e32abec39..6556277509 100644 --- a/erpnext/accounts/doctype/tax_withholding_rate/tax_withholding_rate.py +++ b/erpnext/accounts/doctype/tax_withholding_rate/tax_withholding_rate.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class TaxWithholdingRate(Document): pass diff --git a/erpnext/accounts/doctype/territory_item/territory_item.py b/erpnext/accounts/doctype/territory_item/territory_item.py index d46edc9dca..bcc02be2dd 100644 --- a/erpnext/accounts/doctype/territory_item/territory_item.py +++ b/erpnext/accounts/doctype/territory_item/territory_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class TerritoryItem(Document): pass diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index 3126138408..4bf2b828ed 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -2,12 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext -from frappe.utils import flt, cstr, cint, comma_and, today, getdate, formatdate, now + +import frappe from frappe import _ from frappe.model.meta import get_field_precision +from frappe.utils import cint, cstr, flt, formatdate, getdate, now + +import erpnext +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions + class ClosedAccountingPeriod(frappe.ValidationError): pass diff --git a/erpnext/accounts/notification/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py b/erpnext/accounts/notification/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py index 1bc4d1874c..f57de916dd 100644 --- a/erpnext/accounts/notification/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py +++ b/erpnext/accounts/notification/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def get_context(context): # do your magic here pass diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index de7dde9dd1..7ea6ccee5b 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -3,20 +3,37 @@ from __future__ import unicode_literals -import frappe, erpnext +import frappe from frappe import _, msgprint, scrub +from frappe.contacts.doctype.address.address import ( + get_address_display, + get_company_address, + get_default_address, +) +from frappe.contacts.doctype.contact.contact import get_contact_details from frappe.core.doctype.user_permission.user_permission import get_permitted_documents from frappe.model.utils import get_fetch_values -from frappe.utils import (add_days, getdate, formatdate, date_diff, - add_years, get_timestamp, nowdate, flt, cstr, add_months, get_last_day, cint) -from frappe.contacts.doctype.address.address import (get_address_display, - get_default_address, get_company_address) -from frappe.contacts.doctype.contact.contact import get_contact_details -from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency -from erpnext.accounts.utils import get_fiscal_year -from erpnext import get_company_currency +from frappe.utils import ( + add_days, + add_months, + add_years, + cint, + cstr, + date_diff, + flt, + formatdate, + get_last_day, + get_timestamp, + getdate, + nowdate, +) +from six import iteritems + +import erpnext +from erpnext import get_company_currency +from erpnext.accounts.utils import get_fiscal_year +from erpnext.exceptions import InvalidAccountCurrency, PartyDisabled, PartyFrozen -from six import iteritems, string_types class DuplicatePartyAccountError(frappe.ValidationError): pass @@ -386,7 +403,7 @@ def get_address_tax_category(tax_category=None, billing_address=None, shipping_a @frappe.whitelist() def set_taxes(party, party_type, posting_date, company, customer_group=None, supplier_group=None, tax_category=None, billing_address=None, shipping_address=None, use_for_shopping_cart=None): - from erpnext.accounts.doctype.tax_rule.tax_rule import get_tax_template, get_party_details + from erpnext.accounts.doctype.tax_rule.tax_rule import get_party_details, get_tax_template args = { party_type.lower(): party, "company": company @@ -648,7 +665,7 @@ def get_default_contact(doctype, name): if out: try: return out[0][0] - except: + except Exception: return None else: return None diff --git a/erpnext/accounts/report/account_balance/account_balance.py b/erpnext/accounts/report/account_balance/account_balance.py index be64c327fd..9ae61ddcfd 100644 --- a/erpnext/accounts/report/account_balance/account_balance.py +++ b/erpnext/accounts/report/account_balance/account_balance.py @@ -2,10 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + from erpnext.accounts.utils import get_balance_on + def execute(filters=None): filters = frappe._dict(filters or {}) columns = get_columns(filters) diff --git a/erpnext/accounts/report/account_balance/test_account_balance.py b/erpnext/accounts/report/account_balance/test_account_balance.py index f5c9449e85..94c73f5264 100644 --- a/erpnext/accounts/report/account_balance/test_account_balance.py +++ b/erpnext/accounts/report/account_balance/test_account_balance.py @@ -1,10 +1,13 @@ from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import getdate -from erpnext.accounts.report.account_balance.account_balance import execute + from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.accounts.report.account_balance.account_balance import execute + class TestAccountBalance(unittest.TestCase): def test_account_balance(self): diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.py b/erpnext/accounts/report/accounts_payable/accounts_payable.py index 246ead6016..0de573e454 100644 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.py +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.py @@ -2,9 +2,10 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport + def execute(filters=None): args = { "party_type": "Supplier", diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.py b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.py index c08582b564..6034ec0d83 100644 --- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.py +++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary \ - import AccountsReceivableSummary + +from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_summary import ( + AccountsReceivableSummary, +) + def execute(filters=None): args = { diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index cedfc0f58b..e91fdf27cd 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -2,12 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext -from frappe import _, scrub -from frappe.utils import getdate, nowdate, flt, cint, formatdate, cstr, now, time_diff_in_seconds + from collections import OrderedDict + +import frappe +from frappe import _, scrub +from frappe.utils import cint, cstr, flt, getdate, nowdate + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) from erpnext.accounts.utils import get_currency_precision -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children # This report gives a summary of all Outstanding Invoices considering the following diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index cca6760823..1d24561bb3 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -1,11 +1,14 @@ from __future__ import unicode_literals -import frappe -import frappe.defaults + import unittest -from frappe.utils import today, getdate, add_days -from erpnext.accounts.report.accounts_receivable.accounts_receivable import execute -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice + +import frappe +from frappe.utils import add_days, getdate, today + from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry +from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice +from erpnext.accounts.report.accounts_receivable.accounts_receivable import execute + class TestAccountsReceivable(unittest.TestCase): def test_accounts_receivable(self): diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index 4bfb022c4e..106f224a74 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -2,12 +2,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _, scrub -from frappe.utils import flt, cint +from frappe.utils import cint +from six import iteritems + from erpnext.accounts.party import get_partywise_advanced_payment_amount from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport -from six import iteritems + def execute(filters=None): args = { diff --git a/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py b/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py index 2162a02eff..0fd4ca0f24 100644 --- a/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py +++ b/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext -from frappe.utils import flt + +import frappe from frappe import _ +from frappe.utils import flt + def execute(filters=None): columns, data = get_columns(), get_data(filters) diff --git a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py index 5001ad9f12..d34bc854bb 100644 --- a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py +++ b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py @@ -2,9 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import formatdate, flt, add_days +from frappe.utils import add_days, flt, formatdate def execute(filters=None): diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py index 7838385dc5..78ee7cab9a 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -2,11 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, cint -from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data, - get_filtered_list_for_consolidated_report) +from frappe.utils import cint, flt + +from erpnext.accounts.report.financial_statements import ( + get_columns, + get_data, + get_filtered_list_for_consolidated_report, + get_period_list, +) + def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py index 95f724cc58..1a1fa964fe 100644 --- a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py +++ b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import nowdate, getdate +from frappe.utils import getdate, nowdate + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py index 63317c52d8..b9843068a1 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt, getdate, nowdate from frappe import _ +from frappe.utils import flt, getdate, nowdate + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py b/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py index 2dcea22f7e..6c4cd671b2 100644 --- a/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py +++ b/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): data = get_data(filters) or [] columns = get_columns() diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py index 443126e465..c204250377 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py @@ -2,12 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import datetime -from six import iteritems import frappe from frappe import _ from frappe.utils import flt, formatdate +from six import iteritems from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index 3577457c98..d5271885b7 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -2,14 +2,23 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import cint, cstr -from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data, get_filtered_list_for_consolidated_report) -from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import get_net_profit_loss -from erpnext.accounts.utils import get_fiscal_year from six import iteritems +from erpnext.accounts.report.financial_statements import ( + get_columns, + get_data, + get_filtered_list_for_consolidated_report, + get_period_list, +) +from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( + get_net_profit_loss, +) +from erpnext.accounts.utils import get_fiscal_year + def execute(filters=None): if cint(frappe.db.get_single_value('Accounts Settings', 'use_custom_cash_flow')): diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py index c11c15390b..bbc020e591 100644 --- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py +++ b/erpnext/accounts/report/cash_flow/custom_cash_flow.py @@ -2,11 +2,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import add_to_date -from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) -from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import get_net_profit_loss + +from erpnext.accounts.report.financial_statements import get_columns, get_data, get_period_list +from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( + get_net_profit_loss, +) def get_mapper_for(mappers, position): diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index fc4212733a..e419727c2d 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -2,17 +2,37 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ -from frappe.utils import flt, cint, getdate -from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency +from frappe.utils import cint, flt, getdate + +from erpnext.accounts.report.balance_sheet.balance_sheet import ( + check_opening_balance, + get_chart_data, + get_provisional_profit_loss, +) +from erpnext.accounts.report.balance_sheet.balance_sheet import ( + get_report_summary as get_bs_summary, +) +from erpnext.accounts.report.cash_flow.cash_flow import ( + add_total_row_account, + get_account_type_based_gl_data, + get_cash_flow_accounts, +) +from erpnext.accounts.report.cash_flow.cash_flow import get_report_summary as get_cash_flow_summary from erpnext.accounts.report.financial_statements import get_fiscal_year_data, sort_accounts -from erpnext.accounts.report.balance_sheet.balance_sheet import (get_provisional_profit_loss, - check_opening_balance, get_chart_data, get_report_summary as get_bs_summary) -from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import (get_net_profit_loss, - get_chart_data as get_pl_chart_data, get_report_summary as get_pl_summary) -from erpnext.accounts.report.cash_flow.cash_flow import (get_cash_flow_accounts, get_account_type_based_gl_data, - add_total_row_account, get_report_summary as get_cash_flow_summary) +from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( + get_chart_data as get_pl_chart_data, +) +from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( + get_net_profit_loss, +) +from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( + get_report_summary as get_pl_summary, +) +from erpnext.accounts.report.utils import convert_to_presentation_currency + def execute(filters=None): columns, data, message, chart = [], [], [], [] diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py index c79d7401e6..603fbac5aa 100644 --- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py @@ -2,12 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -import erpnext from frappe import _, scrub from frappe.utils import getdate, nowdate from six import iteritems, itervalues + class PartyLedgerSummaryReport(object): def __init__(self, filters=None): self.filters = frappe._dict(filters or {}) diff --git a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.py b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.py index 9953d8fcaf..f096094296 100644 --- a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.py +++ b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe import _ + from erpnext.accounts.report.non_billed_report import get_ordered_to_be_billed_data + def execute(filters=None): columns = get_column() args = get_args() diff --git a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.py b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.py index de7ed4926e..4212137d7a 100644 --- a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.py +++ b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.py @@ -2,14 +2,19 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext -from frappe import _ -from frappe.utils import (flt, cstr) -from erpnext.accounts.report.financial_statements import filter_accounts, filter_out_zero_value_rows +import frappe +from frappe import _ +from frappe.utils import cstr, flt +from six import itervalues + +import erpnext +from erpnext.accounts.report.financial_statements import ( + filter_accounts, + filter_out_zero_value_rows, +) from erpnext.accounts.report.trial_balance.trial_balance import validate_filters -from six import itervalues def execute(filters=None): validate_filters(filters) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 39ff804518..2cb8a6802a 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -5,19 +5,23 @@ from __future__ import unicode_literals -import re -from past.builtins import cmp import functools import math +import re -import frappe, erpnext -from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency -from erpnext.accounts.utils import get_fiscal_year +import frappe from frappe import _ -from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, formatdate, cstr, cint) - +from frappe.utils import add_days, add_months, cint, cstr, flt, formatdate, get_first_day, getdate +from past.builtins import cmp from six import itervalues -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) +from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency +from erpnext.accounts.utils import get_fiscal_year + def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_end_date, filter_based_on, periodicity, accumulated_values=False, company=None, reset_period_on_fy_change=True, ignore_fiscal_year=False): @@ -339,7 +343,7 @@ def sort_accounts(accounts, is_root=False, key="name"): """Sort root types as Asset, Liability, Equity, Income, Expense""" def compare_accounts(a, b): - if re.split('\W+', a[key])[0].isdigit(): + if re.split(r'\W+', a[key])[0].isdigit(): # if chart of accounts is numbered, then sort by number return cmp(a[key], b[key]) elif is_root: diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 3723c8e0d2..a044518749 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -2,17 +2,24 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext -from erpnext import get_company_currency, get_default_company -from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency -from frappe.utils import getdate, cstr, flt, fmt_money -from frappe import _, _dict -from erpnext.accounts.utils import get_account_currency -from erpnext.accounts.report.financial_statements import get_cost_centers_with_children -from six import iteritems -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children + from collections import OrderedDict +import frappe +from frappe import _, _dict +from frappe.utils import cstr, flt, getdate +from six import iteritems + +from erpnext import get_company_currency, get_default_company +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) +from erpnext.accounts.report.financial_statements import get_cost_centers_with_children +from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency +from erpnext.accounts.utils import get_account_currency + + def execute(filters=None): if not filters: return [], [] diff --git a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py index 8e33af7ee8..49522d9c87 100644 --- a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py +++ b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.py @@ -2,11 +2,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import copy + import frappe from frappe import _ from frappe.utils import flt -from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) -import copy + +from erpnext.accounts.report.financial_statements import get_columns, get_data, get_period_list + def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.period_start_date, diff --git a/erpnext/accounts/report/gross_profit/gross_profit.js b/erpnext/accounts/report/gross_profit/gross_profit.js index ba17a94e8d..856b97d164 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.js +++ b/erpnext/accounts/report/gross_profit/gross_profit.js @@ -36,5 +36,20 @@ frappe.query_reports["Gross Profit"] = { "options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject", "default": "Invoice" }, - ] + ], + "tree": true, + "name_field": "parent", + "parent_field": "parent_invoice", + "initial_depth": 3, + "formatter": function(value, row, column, data, default_formatter) { + value = default_formatter(value, row, column, data); + + if (data && data.indent == 0.0) { + value = $(`${value}`); + var $value = $(value).css("font-weight", "bold"); + value = $value.wrap("

").parent().html(); + } + + return value; + }, } diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index c949d9b74e..f08bca9dda 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -2,11 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _, scrub -from erpnext.stock.utils import get_incoming_rate +from frappe.utils import cint, flt + from erpnext.controllers.queries import get_match_cond -from frappe.utils import flt, cint +from erpnext.stock.utils import get_incoming_rate def execute(filters=None): @@ -41,6 +43,34 @@ def execute(filters=None): columns = get_columns(group_wise_columns, filters) + if filters.group_by == 'Invoice': + get_data_when_grouped_by_invoice(columns, gross_profit_data, filters, group_wise_columns, data) + + else: + get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_columns, data) + + return columns, data + +def get_data_when_grouped_by_invoice(columns, gross_profit_data, filters, group_wise_columns, data): + column_names = get_column_names() + + # to display item as Item Code: Item Name + columns[0] = 'Sales Invoice:Link/Item:300' + # removing Item Code and Item Name columns + del columns[4:6] + + for src in gross_profit_data.si_list: + row = frappe._dict() + row.indent = src.indent + row.parent_invoice = src.parent_invoice + row.currency = filters.currency + + for col in group_wise_columns.get(scrub(filters.group_by)): + row[column_names[col]] = src.get(col) + + data.append(row) + +def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_columns, data): for idx, src in enumerate(gross_profit_data.grouped_data): row = [] for col in group_wise_columns.get(scrub(filters.group_by)): @@ -51,8 +81,6 @@ def execute(filters=None): row[0] = frappe.bold("Total") data.append(row) - return columns, data - def get_columns(group_wise_columns, filters): columns = [] column_map = frappe._dict({ @@ -93,12 +121,38 @@ def get_columns(group_wise_columns, filters): return columns +def get_column_names(): + return frappe._dict({ + 'parent': 'sales_invoice', + 'customer': 'customer', + 'customer_group': 'customer_group', + 'posting_date': 'posting_date', + 'item_code': 'item_code', + 'item_name': 'item_name', + 'item_group': 'item_group', + 'brand': 'brand', + 'description': 'description', + 'warehouse': 'warehouse', + 'qty': 'qty', + 'base_rate': 'avg._selling_rate', + 'buying_rate': 'valuation_rate', + 'base_amount': 'selling_amount', + 'buying_amount': 'buying_amount', + 'gross_profit': 'gross_profit', + 'gross_profit_percent': 'gross_profit_%', + 'project': 'project' + }) + class GrossProfitGenerator(object): def __init__(self, filters=None): self.data = [] self.average_buying_rate = {} self.filters = frappe._dict(filters) self.load_invoice_items() + + if filters.group_by == 'Invoice': + self.group_items_by_invoice() + self.load_stock_ledger_entries() self.load_product_bundle() self.load_non_stock_items() @@ -112,7 +166,12 @@ class GrossProfitGenerator(object): self.currency_precision = cint(frappe.db.get_default("currency_precision")) or 3 self.float_precision = cint(frappe.db.get_default("float_precision")) or 2 - for row in self.si_list: + grouped_by_invoice = True if self.filters.get("group_by") == "Invoice" else False + + if grouped_by_invoice: + buying_amount = 0 + + for row in reversed(self.si_list): if self.skip_row(row, self.product_bundles): continue @@ -134,12 +193,20 @@ class GrossProfitGenerator(object): row.buying_amount = flt(self.get_buying_amount(row, row.item_code), self.currency_precision) + if grouped_by_invoice: + if row.indent == 1.0: + buying_amount += row.buying_amount + elif row.indent == 0.0: + row.buying_amount = buying_amount + buying_amount = 0 + # get buying rate - if row.qty: - row.buying_rate = flt(row.buying_amount / row.qty, self.float_precision) - row.base_rate = flt(row.base_amount / row.qty, self.float_precision) + if flt(row.qty): + row.buying_rate = flt(row.buying_amount / flt(row.qty), self.float_precision) + row.base_rate = flt(row.base_amount / flt(row.qty), self.float_precision) else: - row.buying_rate, row.base_rate = 0.0, 0.0 + if self.is_not_invoice_row(row): + row.buying_rate, row.base_rate = 0.0, 0.0 # calculate gross profit row.gross_profit = flt(row.base_amount - row.buying_amount, self.currency_precision) @@ -171,7 +238,7 @@ class GrossProfitGenerator(object): if i==0: new_row = row else: - new_row.qty += row.qty + new_row.qty += flt(row.qty) new_row.buying_amount += flt(row.buying_amount, self.currency_precision) new_row.base_amount += flt(row.base_amount, self.currency_precision) new_row = self.set_average_rate(new_row) @@ -183,16 +250,19 @@ class GrossProfitGenerator(object): and row.item_code in self.returned_invoices[row.parent]: returned_item_rows = self.returned_invoices[row.parent][row.item_code] for returned_item_row in returned_item_rows: - row.qty += returned_item_row.qty + row.qty += flt(returned_item_row.qty) row.base_amount += flt(returned_item_row.base_amount, self.currency_precision) - row.buying_amount = flt(row.qty * row.buying_rate, self.currency_precision) - if row.qty or row.base_amount: + row.buying_amount = flt(flt(row.qty) * flt(row.buying_rate), self.currency_precision) + if (flt(row.qty) or row.base_amount) and self.is_not_invoice_row(row): row = self.set_average_rate(row) self.grouped_data.append(row) self.add_to_totals(row) self.set_average_gross_profit(self.totals) self.grouped_data.append(self.totals) + def is_not_invoice_row(self, row): + return (self.filters.get("group_by") == "Invoice" and row.indent != 0.0) or self.filters.get("group_by") != "Invoice" + def set_average_rate(self, new_row): self.set_average_gross_profit(new_row) new_row.buying_rate = flt(new_row.buying_amount / new_row.qty, self.float_precision) if new_row.qty else 0 @@ -354,6 +424,109 @@ class GrossProfitGenerator(object): .format(conditions=conditions, sales_person_cols=sales_person_cols, sales_team_table=sales_team_table, match_cond = get_match_cond('Sales Invoice')), self.filters, as_dict=1) + def group_items_by_invoice(self): + """ + Turns list of Sales Invoice Items to a tree of Sales Invoices with their Items as children. + """ + + parents = [] + + for row in self.si_list: + if row.parent not in parents: + parents.append(row.parent) + + parents_index = 0 + for index, row in enumerate(self.si_list): + if parents_index < len(parents) and row.parent == parents[parents_index]: + invoice = self.get_invoice_row(row) + self.si_list.insert(index, invoice) + parents_index += 1 + + else: + # skipping the bundle items rows + if not row.indent: + row.indent = 1.0 + row.parent_invoice = row.parent + row.parent = row.item_code + + if frappe.db.exists('Product Bundle', row.item_code): + self.add_bundle_items(row, index) + + def get_invoice_row(self, row): + return frappe._dict({ + 'parent_invoice': "", + 'indent': 0.0, + 'parent': row.parent, + 'posting_date': row.posting_date, + 'posting_time': row.posting_time, + 'project': row.project, + 'update_stock': row.update_stock, + 'customer': row.customer, + 'customer_group': row.customer_group, + 'item_code': None, + 'item_name': None, + 'description': None, + 'warehouse': None, + 'item_group': None, + 'brand': None, + 'dn_detail': None, + 'delivery_note': None, + 'qty': None, + 'item_row': None, + 'is_return': row.is_return, + 'cost_center': row.cost_center, + 'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total') + }) + + def add_bundle_items(self, product_bundle, index): + bundle_items = self.get_bundle_items(product_bundle) + + for i, item in enumerate(bundle_items): + bundle_item = self.get_bundle_item_row(product_bundle, item) + self.si_list.insert((index+i+1), bundle_item) + + def get_bundle_items(self, product_bundle): + return frappe.get_all( + 'Product Bundle Item', + filters = { + 'parent': product_bundle.item_code + }, + fields = ['item_code', 'qty'] + ) + + def get_bundle_item_row(self, product_bundle, item): + item_name, description, item_group, brand = self.get_bundle_item_details(item.item_code) + + return frappe._dict({ + 'parent_invoice': product_bundle.item_code, + 'indent': product_bundle.indent + 1, + 'parent': item.item_code, + 'posting_date': product_bundle.posting_date, + 'posting_time': product_bundle.posting_time, + 'project': product_bundle.project, + 'customer': product_bundle.customer, + 'customer_group': product_bundle.customer_group, + 'item_code': item.item_code, + 'item_name': item_name, + 'description': description, + 'warehouse': product_bundle.warehouse, + 'item_group': item_group, + 'brand': brand, + 'dn_detail': product_bundle.dn_detail, + 'delivery_note': product_bundle.delivery_note, + 'qty': (flt(product_bundle.qty) * flt(item.qty)), + 'item_row': None, + 'is_return': product_bundle.is_return, + 'cost_center': product_bundle.cost_center + }) + + def get_bundle_item_details(self, item_code): + return frappe.db.get_value( + 'Item', + item_code, + ['item_name', 'description', 'item_group', 'brand'] + ) + def load_stock_ledger_entries(self): res = frappe.db.sql("""select item_code, voucher_type, voucher_no, voucher_detail_no, stock_value, warehouse, actual_qty as qty diff --git a/erpnext/accounts/report/inactive_sales_items/inactive_sales_items.py b/erpnext/accounts/report/inactive_sales_items/inactive_sales_items.py index 7dea80cbe2..8f822711a7 100644 --- a/erpnext/accounts/report/inactive_sales_items/inactive_sales_items.py +++ b/erpnext/accounts/report/inactive_sales_items/inactive_sales_items.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import getdate, add_days, today, cint from frappe import _ +from frappe.utils import cint + def execute(filters=None): columns = get_columns() diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py index 685419a17e..cd25c05004 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py @@ -2,14 +2,23 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ from frappe.utils import flt -from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import (get_tax_accounts, - get_grand_total, add_total_row, get_display_value, get_group_by_and_display_fields, add_sub_total_row, - get_group_by_conditions) + +import erpnext +from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import ( + add_sub_total_row, + add_total_row, + get_grand_total, + get_group_by_and_display_fields, + get_group_by_conditions, + get_tax_accounts, +) from erpnext.selling.report.item_wise_sales_history.item_wise_sales_history import get_item_details + def execute(filters=None): return _execute(filters) diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py index c9c22c246e..847a127d36 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py @@ -2,13 +2,19 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ -from frappe.utils import flt, cstr from frappe.model.meta import get_field_precision +from frappe.utils import cstr, flt from frappe.utils.xlsxutils import handle_html + from erpnext.accounts.report.sales_register.sales_register import get_mode_of_payments -from erpnext.selling.report.item_wise_sales_history.item_wise_sales_history import get_item_details, get_customer_details +from erpnext.selling.report.item_wise_sales_history.item_wise_sales_history import ( + get_customer_details, + get_item_details, +) + def execute(filters=None): return _execute(filters) diff --git a/erpnext/accounts/report/non_billed_report.py b/erpnext/accounts/report/non_billed_report.py index 5173505689..b61f87df5b 100644 --- a/erpnext/accounts/report/non_billed_report.py +++ b/erpnext/accounts/report/non_billed_report.py @@ -2,11 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import _ -from erpnext import get_default_currency from frappe.model.meta import get_field_precision +from erpnext import get_default_currency + + def get_ordered_to_be_billed_data(args): doctype, party = args.get('doctype'), args.get('party') child_tab = doctype + " Item" diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py index 556f5ad4f7..6c6af1cc5a 100644 --- a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py +++ b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py @@ -2,10 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ +from frappe.utils import flt, getdate + from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport -from frappe.utils import getdate, flt def execute(filters=None): diff --git a/erpnext/accounts/report/pos_register/pos_register.py b/erpnext/accounts/report/pos_register/pos_register.py index b7e112c0c9..c9463caa6d 100644 --- a/erpnext/accounts/report/pos_register/pos_register.py +++ b/erpnext/accounts/report/pos_register/pos_register.py @@ -2,11 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import _, _dict -from erpnext import get_company_currency, get_default_company +from frappe import _ + from erpnext.accounts.report.sales_register.sales_register import get_mode_of_payments + def execute(filters=None): if not filters: return [], [] diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py index 5d04824b57..ef799f63bf 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py @@ -2,11 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import flt -from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data, - get_filtered_list_for_consolidated_report) + +from erpnext.accounts.report.financial_statements import ( + get_columns, + get_data, + get_filtered_list_for_consolidated_report, + get_period_list, +) + def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py index 48bd7308bc..ad97808973 100644 --- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py +++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py @@ -2,10 +2,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, getdate, formatdate, cstr -from erpnext.accounts.report.financial_statements import filter_accounts, filter_out_zero_value_rows +from frappe.utils import cstr, flt + +from erpnext.accounts.report.financial_statements import ( + filter_accounts, + filter_out_zero_value_rows, +) from erpnext.accounts.report.trial_balance.trial_balance import validate_filters value_fields = ("income", "expense", "gross_profit_loss") diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py index ba236b9969..b26c733bc7 100644 --- a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py +++ b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py @@ -2,8 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from erpnext.controllers.trends import get_columns,get_data + +from erpnext.controllers.trends import get_columns, get_data + def execute(filters=None): if not filters: filters ={} diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index 10edd41aa8..5d4a03ce60 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -2,10 +2,16 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe +from frappe import _, msgprint from frappe.utils import flt -from frappe import msgprint, _ -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) + def execute(filters=None): return _execute(filters) diff --git a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.py b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.py index a5eced5f80..adf6b29ea8 100644 --- a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.py +++ b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe import _ + from erpnext.accounts.report.non_billed_report import get_ordered_to_be_billed_data + def execute(filters=None): columns = get_column() args = get_args() diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.py b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.py index ee3992f6f4..0ec54c932b 100644 --- a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.py +++ b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.py @@ -2,8 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from erpnext.controllers.trends import get_columns,get_data + +from erpnext.controllers.trends import get_columns, get_data + def execute(filters=None): if not filters: filters ={} diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py index ff774681a2..9ad7007a2c 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -1,6 +1,7 @@ # Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import cstr diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index e4a3d3527f..9fd7bc3de7 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -2,11 +2,17 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import unittest + import frappe -from erpnext.accounts.report.sales_payment_summary.sales_payment_summary import get_mode_of_payments, get_mode_of_payment_details from frappe.utils import today + from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry +from erpnext.accounts.report.sales_payment_summary.sales_payment_summary import ( + get_mode_of_payment_details, + get_mode_of_payments, +) test_dependencies = ["Sales Invoice"] diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py index f38bd78c0d..57b69aa818 100644 --- a/erpnext/accounts/report/sales_register/sales_register.py +++ b/erpnext/accounts/report/sales_register/sales_register.py @@ -2,11 +2,17 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt -from frappe import msgprint, _ +from frappe import _, msgprint from frappe.model.meta import get_field_precision -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children +from frappe.utils import flt + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) + def execute(filters=None): return _execute(filters) diff --git a/erpnext/accounts/report/share_balance/share_balance.py b/erpnext/accounts/report/share_balance/share_balance.py index 9f22f81d2b..03efc9ec33 100644 --- a/erpnext/accounts/report/share_balance/share_balance.py +++ b/erpnext/accounts/report/share_balance/share_balance.py @@ -2,8 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import msgprint, _ +from frappe import _ + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/accounts/report/share_ledger/share_ledger.py b/erpnext/accounts/report/share_ledger/share_ledger.py index 3ed3c91141..9be662220d 100644 --- a/erpnext/accounts/report/share_ledger/share_ledger.py +++ b/erpnext/accounts/report/share_ledger/share_ledger.py @@ -3,9 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import cstr, cint, getdate -from frappe import msgprint, _ +from frappe import _ + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.py b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.py index fbd25b13bb..00316ba265 100644 --- a/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.py +++ b/erpnext/accounts/report/supplier_ledger_summary/supplier_ledger_summary.py @@ -2,8 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from erpnext.accounts.report.customer_ledger_summary.customer_ledger_summary import PartyLedgerSummaryReport + +from erpnext.accounts.report.customer_ledger_summary.customer_ledger_summary import ( + PartyLedgerSummaryReport, +) + def execute(filters=None): args = { diff --git a/erpnext/accounts/report/tax_detail/tax_detail.py b/erpnext/accounts/report/tax_detail/tax_detail.py index 18436de3d8..f03498d5b2 100644 --- a/erpnext/accounts/report/tax_detail/tax_detail.py +++ b/erpnext/accounts/report/tax_detail/tax_detail.py @@ -3,8 +3,10 @@ # Contributed by Case Solved and sponsored by Nulight Studios from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe import _ # NOTE: Payroll is implemented using Journal Entries which are included as GL Entries diff --git a/erpnext/accounts/report/tax_detail/test_tax_detail.py b/erpnext/accounts/report/tax_detail/test_tax_detail.py index 743ddba024..e74b905db1 100644 --- a/erpnext/accounts/report/tax_detail/test_tax_detail.py +++ b/erpnext/accounts/report/tax_detail/test_tax_detail.py @@ -1,16 +1,26 @@ from __future__ import unicode_literals -import frappe -import unittest import datetime import json import os -from frappe.utils import getdate, add_to_date, get_first_day, get_last_day, get_year_start, get_year_ending +import unittest + +import frappe +from frappe.utils import ( + add_to_date, + get_first_day, + get_last_day, + get_year_ending, + get_year_start, + getdate, +) + from .tax_detail import filter_match, save_custom_report + class TestTaxDetail(unittest.TestCase): def load_testdocs(self): - from erpnext.accounts.utils import get_fiscal_year, FiscalYearError + from erpnext.accounts.utils import FiscalYearError, get_fiscal_year datapath, _ = os.path.splitext(os.path.realpath(__file__)) with open(datapath + '.json', 'r') as fp: docs = json.load(fp) diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index 6b9df41f54..c4a8c7a899 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -1,10 +1,15 @@ from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import flt + +from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import ( + get_advance_vouchers, + get_debit_note_amount, +) from erpnext.accounts.utils import get_fiscal_year -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category \ - import get_advance_vouchers, get_debit_note_amount + def execute(filters=None): validate_filters(filters) diff --git a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py index ceefa31cfa..9e1382b922 100644 --- a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py +++ b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py @@ -2,9 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import getdate + def execute(filters=None): filters["invoices"] = frappe.cache().hget("invoices", frappe.session.user) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 1fc0faab3a..d65bcc4ada 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -2,12 +2,21 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ -from frappe.utils import flt, getdate, formatdate, cstr -from erpnext.accounts.report.financial_statements \ - import filter_accounts, set_gl_entries_by_account, filter_out_zero_value_rows -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children +from frappe.utils import cstr, flt, formatdate, getdate + +import erpnext +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, + get_dimension_with_children, +) +from erpnext.accounts.report.financial_statements import ( + filter_accounts, + filter_out_zero_value_rows, + set_gl_entries_by_account, +) value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit") diff --git a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py index f034e7450e..8e245443c3 100644 --- a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py +++ b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py @@ -2,11 +2,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, cint +from frappe.utils import cint, flt + from erpnext.accounts.report.trial_balance.trial_balance import validate_filters + def execute(filters=None): validate_filters(filters) diff --git a/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py index 1250d676a0..71fe4a294a 100644 --- a/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py +++ b/erpnext/accounts/report/unpaid_expense_claim/unpaid_expense_claim.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): columns, data = [], [] columns = get_columns() diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index ba461edaf8..57ff9b0ec9 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -1,9 +1,11 @@ from __future__ import unicode_literals + import frappe +from frappe.utils import flt, formatdate, get_datetime_str + from erpnext import get_company_currency, get_default_company -from erpnext.setup.utils import get_exchange_rate from erpnext.accounts.doctype.fiscal_year.fiscal_year import get_from_and_to_date -from frappe.utils import cint, get_datetime_str, formatdate, flt +from erpnext.setup.utils import get_exchange_rate __exchange_rates = {} diff --git a/erpnext/accounts/test/test_utils.py b/erpnext/accounts/test/test_utils.py index 628c8ce646..d7b60daa37 100644 --- a/erpnext/accounts/test/test_utils.py +++ b/erpnext/accounts/test/test_utils.py @@ -1,8 +1,11 @@ from __future__ import unicode_literals + import unittest -from erpnext.accounts.party import get_party_shipping_address + from frappe.test_runner import make_test_objects +from erpnext.accounts.party import get_party_shipping_address + class TestUtils(unittest.TestCase): @classmethod diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 5ed4a1947c..4692869343 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -4,18 +4,19 @@ from __future__ import unicode_literals -import frappe, erpnext +import frappe import frappe.defaults -from frappe.utils import nowdate, cstr, flt, cint, now, getdate -from frappe import throw, _ -from frappe.utils import formatdate, get_number_format_info -from six import iteritems -# imported to enable erpnext.accounts.utils.get_account_currency -from erpnext.accounts.doctype.account.account import get_account_currency +from frappe import _, throw from frappe.model.meta import get_field_precision +from frappe.utils import cint, cstr, flt, formatdate, get_number_format_info, getdate, now, nowdate -from erpnext.stock.utils import get_stock_value_on +import erpnext + +# imported to enable erpnext.accounts.utils.get_account_currency +from erpnext.accounts.doctype.account.account import get_account_currency # noqa from erpnext.stock import get_warehouse_account_map +from erpnext.stock.utils import get_stock_value_on + class StockValueAndAccountBalanceOutOfSync(frappe.ValidationError): pass class FiscalYearError(frappe.ValidationError): pass @@ -341,31 +342,42 @@ def add_cc(args=None): def reconcile_against_document(args): """ - Cancel JV, Update aginst document, split if required and resubmit jv + Cancel PE or JV, Update against document, split if required and resubmit """ - for d in args: + # To optimize making GL Entry for PE or JV with multiple references + reconciled_entries = {} + for row in args: + if not reconciled_entries.get((row.voucher_type, row.voucher_no)): + reconciled_entries[(row.voucher_type, row.voucher_no)] = [] - check_if_advance_entry_modified(d) - validate_allocated_amount(d) + reconciled_entries[(row.voucher_type, row.voucher_no)].append(row) + + for key, entries in reconciled_entries.items(): + voucher_type = key[0] + voucher_no = key[1] # cancel advance entry - doc = frappe.get_doc(d.voucher_type, d.voucher_no) - + doc = frappe.get_doc(voucher_type, voucher_no) frappe.flags.ignore_party_validation = True doc.make_gl_entries(cancel=1, adv_adj=1) - # update ref in advance entry - if d.voucher_type == "Journal Entry": - update_reference_in_journal_entry(d, doc) - else: - update_reference_in_payment_entry(d, doc) + for entry in entries: + check_if_advance_entry_modified(entry) + validate_allocated_amount(entry) + # update ref in advance entry + if voucher_type == "Journal Entry": + update_reference_in_journal_entry(entry, doc, do_not_save=True) + else: + update_reference_in_payment_entry(entry, doc, do_not_save=True) + + doc.save(ignore_permissions=True) # re-submit advance entry - doc = frappe.get_doc(d.voucher_type, d.voucher_no) + doc = frappe.get_doc(entry.voucher_type, entry.voucher_no) doc.make_gl_entries(cancel = 0, adv_adj =1) frappe.flags.ignore_party_validation = False - if d.voucher_type in ('Payment Entry', 'Journal Entry'): + if entry.voucher_type in ('Payment Entry', 'Journal Entry'): doc.update_expense_claim() def check_if_advance_entry_modified(args): @@ -374,6 +386,9 @@ def check_if_advance_entry_modified(args): check if amount is same check if jv is submitted """ + if not args.get('unreconciled_amount'): + args.update({'unreconciled_amount': args.get('unadjusted_amount')}) + ret = None if args.voucher_type == "Journal Entry": ret = frappe.db.sql(""" @@ -395,14 +410,14 @@ def check_if_advance_entry_modified(args): and t1.name = %(voucher_no)s and t2.name = %(voucher_detail_no)s and t1.party_type = %(party_type)s and t1.party = %(party)s and t1.{0} = %(account)s and t2.reference_doctype in ("", "Sales Order", "Purchase Order") - and t2.allocated_amount = %(unadjusted_amount)s + and t2.allocated_amount = %(unreconciled_amount)s """.format(party_account_field), args) else: ret = frappe.db.sql("""select name from `tabPayment Entry` where name = %(voucher_no)s and docstatus = 1 and party_type = %(party_type)s and party = %(party)s and {0} = %(account)s - and unallocated_amount = %(unadjusted_amount)s + and unallocated_amount = %(unreconciled_amount)s """.format(party_account_field), args) if not ret: @@ -415,58 +430,44 @@ def validate_allocated_amount(args): elif flt(args.get("allocated_amount"), precision) > flt(args.get("unadjusted_amount"), precision): throw(_("Allocated amount cannot be greater than unadjusted amount")) -def update_reference_in_journal_entry(d, jv_obj): +def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): """ Updates against document, if partial amount splits into rows """ - jv_detail = jv_obj.get("accounts", {"name": d["voucher_detail_no"]})[0] - jv_detail.set(d["dr_or_cr"], d["allocated_amount"]) - jv_detail.set('debit' if d['dr_or_cr']=='debit_in_account_currency' else 'credit', - d["allocated_amount"]*flt(jv_detail.exchange_rate)) - - original_reference_type = jv_detail.reference_type - original_reference_name = jv_detail.reference_name - - jv_detail.set("reference_type", d["against_voucher_type"]) - jv_detail.set("reference_name", d["against_voucher"]) - - if d['allocated_amount'] < d['unadjusted_amount']: - jvd = frappe.db.sql(""" - select cost_center, balance, against_account, is_advance, - account_type, exchange_rate, account_currency - from `tabJournal Entry Account` where name = %s - """, d['voucher_detail_no'], as_dict=True) + jv_detail = journal_entry.get("accounts", {"name": d["voucher_detail_no"]})[0] + if flt(d['unadjusted_amount']) - flt(d['allocated_amount']) != 0: + # adjust the unreconciled balance amount_in_account_currency = flt(d['unadjusted_amount']) - flt(d['allocated_amount']) - amount_in_company_currency = amount_in_account_currency * flt(jvd[0]['exchange_rate']) + amount_in_company_currency = amount_in_account_currency * flt(jv_detail.exchange_rate) + jv_detail.set(d['dr_or_cr'], amount_in_account_currency) + jv_detail.set('debit' if d['dr_or_cr'] == 'debit_in_account_currency' else 'credit', amount_in_company_currency) + else: + journal_entry.remove(jv_detail) - # new entry with balance amount - ch = jv_obj.append("accounts") - ch.account = d['account'] - ch.account_type = jvd[0]['account_type'] - ch.account_currency = jvd[0]['account_currency'] - ch.exchange_rate = jvd[0]['exchange_rate'] - ch.party_type = d["party_type"] - ch.party = d["party"] - ch.cost_center = cstr(jvd[0]["cost_center"]) - ch.balance = flt(jvd[0]["balance"]) + # new row with references + new_row = journal_entry.append("accounts") + new_row.update(jv_detail.as_dict().copy()) - ch.set(d['dr_or_cr'], amount_in_account_currency) - ch.set('debit' if d['dr_or_cr']=='debit_in_account_currency' else 'credit', amount_in_company_currency) + new_row.set(d["dr_or_cr"], d["allocated_amount"]) + new_row.set('debit' if d['dr_or_cr'] == 'debit_in_account_currency' else 'credit', + d["allocated_amount"] * flt(jv_detail.exchange_rate)) - ch.set('credit_in_account_currency' if d['dr_or_cr']== 'debit_in_account_currency' - else 'debit_in_account_currency', 0) - ch.set('credit' if d['dr_or_cr']== 'debit_in_account_currency' else 'debit', 0) + new_row.set('credit_in_account_currency' if d['dr_or_cr'] == 'debit_in_account_currency' + else 'debit_in_account_currency', 0) + new_row.set('credit' if d['dr_or_cr'] == 'debit_in_account_currency' else 'debit', 0) - ch.against_account = cstr(jvd[0]["against_account"]) - ch.reference_type = original_reference_type - ch.reference_name = original_reference_name - ch.is_advance = cstr(jvd[0]["is_advance"]) - ch.docstatus = 1 + new_row.set("reference_type", d["against_voucher_type"]) + new_row.set("reference_name", d["against_voucher"]) + + new_row.against_account = cstr(jv_detail.against_account) + new_row.is_advance = cstr(jv_detail.is_advance) + new_row.docstatus = 1 # will work as update after submit - jv_obj.flags.ignore_validate_update_after_submit = True - jv_obj.save(ignore_permissions=True) + journal_entry.flags.ignore_validate_update_after_submit = True + if not do_not_save: + journal_entry.save(ignore_permissions=True) def update_reference_in_payment_entry(d, payment_entry, do_not_save=False): reference_details = { @@ -576,7 +577,7 @@ def remove_ref_doc_link_from_pe(ref_type, ref_no): @frappe.whitelist() def get_company_default(company, fieldname, ignore_validation=False): - value = frappe.get_cached_value('Company', company, fieldname) + value = frappe.get_cached_value('Company', company, fieldname) if not ignore_validation and not value: throw(_("Please set default {0} in Company {1}") @@ -886,7 +887,9 @@ def get_autoname_with_number(number_value, doc_title, name, company): @frappe.whitelist() def get_coa(doctype, parent, is_root, chart=None): - from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import build_tree_from_json + from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import ( + build_tree_from_json, + ) # add chart to flags to retrieve when called from expand all function chart = chart if chart else frappe.flags.chart diff --git a/erpnext/agriculture/doctype/agriculture_analysis_criteria/agriculture_analysis_criteria.py b/erpnext/agriculture/doctype/agriculture_analysis_criteria/agriculture_analysis_criteria.py index 3bd3d7db06..b0441c236f 100644 --- a/erpnext/agriculture/doctype/agriculture_analysis_criteria/agriculture_analysis_criteria.py +++ b/erpnext/agriculture/doctype/agriculture_analysis_criteria/agriculture_analysis_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AgricultureAnalysisCriteria(Document): pass diff --git a/erpnext/agriculture/doctype/agriculture_analysis_criteria/test_agriculture_analysis_criteria.py b/erpnext/agriculture/doctype/agriculture_analysis_criteria/test_agriculture_analysis_criteria.py index d79970b742..4213e45c07 100644 --- a/erpnext/agriculture/doctype/agriculture_analysis_criteria/test_agriculture_analysis_criteria.py +++ b/erpnext/agriculture/doctype/agriculture_analysis_criteria/test_agriculture_analysis_criteria.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestAgricultureAnalysisCriteria(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/agriculture_task/agriculture_task.py b/erpnext/agriculture/doctype/agriculture_task/agriculture_task.py index ce39368cd9..642f49189d 100644 --- a/erpnext/agriculture/doctype/agriculture_task/agriculture_task.py +++ b/erpnext/agriculture/doctype/agriculture_task/agriculture_task.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AgricultureTask(Document): pass diff --git a/erpnext/agriculture/doctype/agriculture_task/test_agriculture_task.py b/erpnext/agriculture/doctype/agriculture_task/test_agriculture_task.py index e828151d0d..2b3c338697 100644 --- a/erpnext/agriculture/doctype/agriculture_task/test_agriculture_task.py +++ b/erpnext/agriculture/doctype/agriculture_task/test_agriculture_task.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestAgricultureTask(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/crop/crop_dashboard.py b/erpnext/agriculture/doctype/crop/crop_dashboard.py index 8f37735c81..02b937a74b 100644 --- a/erpnext/agriculture/doctype/crop/crop_dashboard.py +++ b/erpnext/agriculture/doctype/crop/crop_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'transactions': [ diff --git a/erpnext/agriculture/doctype/crop/test_crop.py b/erpnext/agriculture/doctype/crop/test_crop.py index b3079837c3..1968a04796 100644 --- a/erpnext/agriculture/doctype/crop/test_crop.py +++ b/erpnext/agriculture/doctype/crop/test_crop.py @@ -3,9 +3,10 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + test_dependencies = ["Fertilizer"] class TestCrop(unittest.TestCase): diff --git a/erpnext/agriculture/doctype/detected_disease/detected_disease.py b/erpnext/agriculture/doctype/detected_disease/detected_disease.py index 8c90b839b5..b73fc32f7f 100644 --- a/erpnext/agriculture/doctype/detected_disease/detected_disease.py +++ b/erpnext/agriculture/doctype/detected_disease/detected_disease.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class DetectedDisease(Document): pass diff --git a/erpnext/agriculture/doctype/disease/disease.py b/erpnext/agriculture/doctype/disease/disease.py index affa57046e..e474efe515 100644 --- a/erpnext/agriculture/doctype/disease/disease.py +++ b/erpnext/agriculture/doctype/disease/disease.py @@ -3,10 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe import _ + class Disease(Document): def validate(self): diff --git a/erpnext/agriculture/doctype/disease/test_disease.py b/erpnext/agriculture/doctype/disease/test_disease.py index 80861770b0..1959d1f811 100644 --- a/erpnext/agriculture/doctype/disease/test_disease.py +++ b/erpnext/agriculture/doctype/disease/test_disease.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestDisease(unittest.TestCase): def test_treatment_period(self): disease = frappe.get_doc('Disease', 'Aphids') diff --git a/erpnext/agriculture/doctype/fertilizer/fertilizer.py b/erpnext/agriculture/doctype/fertilizer/fertilizer.py index c475f00298..75c2542b85 100644 --- a/erpnext/agriculture/doctype/fertilizer/fertilizer.py +++ b/erpnext/agriculture/doctype/fertilizer/fertilizer.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class Fertilizer(Document): @frappe.whitelist() def load_contents(self): diff --git a/erpnext/agriculture/doctype/fertilizer/test_fertilizer.py b/erpnext/agriculture/doctype/fertilizer/test_fertilizer.py index 4c71d33fe8..c11c61afec 100644 --- a/erpnext/agriculture/doctype/fertilizer/test_fertilizer.py +++ b/erpnext/agriculture/doctype/fertilizer/test_fertilizer.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestFertilizer(unittest.TestCase): def test_fertilizer_creation(self): self.assertEqual(frappe.db.exists('Fertilizer', 'Urea'), 'Urea') diff --git a/erpnext/agriculture/doctype/fertilizer_content/fertilizer_content.py b/erpnext/agriculture/doctype/fertilizer_content/fertilizer_content.py index d385242591..a050b71010 100644 --- a/erpnext/agriculture/doctype/fertilizer_content/fertilizer_content.py +++ b/erpnext/agriculture/doctype/fertilizer_content/fertilizer_content.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class FertilizerContent(Document): pass diff --git a/erpnext/agriculture/doctype/linked_location/linked_location.py b/erpnext/agriculture/doctype/linked_location/linked_location.py index 3e49d3e18f..e622e84dc3 100644 --- a/erpnext/agriculture/doctype/linked_location/linked_location.py +++ b/erpnext/agriculture/doctype/linked_location/linked_location.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LinkedLocation(Document): pass diff --git a/erpnext/agriculture/doctype/linked_plant_analysis/linked_plant_analysis.py b/erpnext/agriculture/doctype/linked_plant_analysis/linked_plant_analysis.py index daea54b613..608bf8c5e3 100644 --- a/erpnext/agriculture/doctype/linked_plant_analysis/linked_plant_analysis.py +++ b/erpnext/agriculture/doctype/linked_plant_analysis/linked_plant_analysis.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LinkedPlantAnalysis(Document): pass diff --git a/erpnext/agriculture/doctype/linked_soil_analysis/linked_soil_analysis.py b/erpnext/agriculture/doctype/linked_soil_analysis/linked_soil_analysis.py index c4e9245cd7..02eb133de9 100644 --- a/erpnext/agriculture/doctype/linked_soil_analysis/linked_soil_analysis.py +++ b/erpnext/agriculture/doctype/linked_soil_analysis/linked_soil_analysis.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LinkedSoilAnalysis(Document): pass diff --git a/erpnext/agriculture/doctype/linked_soil_texture/linked_soil_texture.py b/erpnext/agriculture/doctype/linked_soil_texture/linked_soil_texture.py index 1b7589298e..f580e16576 100644 --- a/erpnext/agriculture/doctype/linked_soil_texture/linked_soil_texture.py +++ b/erpnext/agriculture/doctype/linked_soil_texture/linked_soil_texture.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LinkedSoilTexture(Document): pass diff --git a/erpnext/agriculture/doctype/plant_analysis/plant_analysis.py b/erpnext/agriculture/doctype/plant_analysis/plant_analysis.py index b65f93de0a..6238250016 100644 --- a/erpnext/agriculture/doctype/plant_analysis/plant_analysis.py +++ b/erpnext/agriculture/doctype/plant_analysis/plant_analysis.py @@ -3,10 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.naming import make_autoname from frappe.model.document import Document + class PlantAnalysis(Document): @frappe.whitelist() def load_contents(self): diff --git a/erpnext/agriculture/doctype/plant_analysis/test_plant_analysis.py b/erpnext/agriculture/doctype/plant_analysis/test_plant_analysis.py index cbd2fd7431..6b6e843612 100644 --- a/erpnext/agriculture/doctype/plant_analysis/test_plant_analysis.py +++ b/erpnext/agriculture/doctype/plant_analysis/test_plant_analysis.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestPlantAnalysis(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/plant_analysis_criteria/plant_analysis_criteria.py b/erpnext/agriculture/doctype/plant_analysis_criteria/plant_analysis_criteria.py index c1731846a8..9f719874ed 100644 --- a/erpnext/agriculture/doctype/plant_analysis_criteria/plant_analysis_criteria.py +++ b/erpnext/agriculture/doctype/plant_analysis_criteria/plant_analysis_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class PlantAnalysisCriteria(Document): pass diff --git a/erpnext/agriculture/doctype/soil_analysis/soil_analysis.py b/erpnext/agriculture/doctype/soil_analysis/soil_analysis.py index 234d0d4b01..e0c8177e63 100644 --- a/erpnext/agriculture/doctype/soil_analysis/soil_analysis.py +++ b/erpnext/agriculture/doctype/soil_analysis/soil_analysis.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class SoilAnalysis(Document): @frappe.whitelist() def load_contents(self): diff --git a/erpnext/agriculture/doctype/soil_analysis/test_soil_analysis.py b/erpnext/agriculture/doctype/soil_analysis/test_soil_analysis.py index b89d756311..24fe0748d3 100644 --- a/erpnext/agriculture/doctype/soil_analysis/test_soil_analysis.py +++ b/erpnext/agriculture/doctype/soil_analysis/test_soil_analysis.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestSoilAnalysis(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/soil_analysis_criteria/soil_analysis_criteria.py b/erpnext/agriculture/doctype/soil_analysis_criteria/soil_analysis_criteria.py index b073c200c0..09b917c549 100644 --- a/erpnext/agriculture/doctype/soil_analysis_criteria/soil_analysis_criteria.py +++ b/erpnext/agriculture/doctype/soil_analysis_criteria/soil_analysis_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SoilAnalysisCriteria(Document): pass diff --git a/erpnext/agriculture/doctype/soil_texture/soil_texture.py b/erpnext/agriculture/doctype/soil_texture/soil_texture.py index 209b2c8598..636af77f4f 100644 --- a/erpnext/agriculture/doctype/soil_texture/soil_texture.py +++ b/erpnext/agriculture/doctype/soil_texture/soil_texture.py @@ -3,11 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import flt, cint -from frappe import _ +from frappe.utils import cint, flt + class SoilTexture(Document): soil_edit_order = [2, 1, 0] diff --git a/erpnext/agriculture/doctype/soil_texture/test_soil_texture.py b/erpnext/agriculture/doctype/soil_texture/test_soil_texture.py index 16d105c9c5..c701eb8f27 100644 --- a/erpnext/agriculture/doctype/soil_texture/test_soil_texture.py +++ b/erpnext/agriculture/doctype/soil_texture/test_soil_texture.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestSoilTexture(unittest.TestCase): def test_texture_selection(self): soil_tex = frappe.get_all('Soil Texture', fields=['name'], filters={'collection_datetime': '2017-11-08'}) diff --git a/erpnext/agriculture/doctype/soil_texture_criteria/soil_texture_criteria.py b/erpnext/agriculture/doctype/soil_texture_criteria/soil_texture_criteria.py index a7525ae6e9..9980e8b0ca 100644 --- a/erpnext/agriculture/doctype/soil_texture_criteria/soil_texture_criteria.py +++ b/erpnext/agriculture/doctype/soil_texture_criteria/soil_texture_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SoilTextureCriteria(Document): pass diff --git a/erpnext/agriculture/doctype/water_analysis/test_water_analysis.py b/erpnext/agriculture/doctype/water_analysis/test_water_analysis.py index b6467b7f45..5cddeeb161 100644 --- a/erpnext/agriculture/doctype/water_analysis/test_water_analysis.py +++ b/erpnext/agriculture/doctype/water_analysis/test_water_analysis.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestWaterAnalysis(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/water_analysis/water_analysis.py b/erpnext/agriculture/doctype/water_analysis/water_analysis.py index cb2691d455..228ae340f2 100644 --- a/erpnext/agriculture/doctype/water_analysis/water_analysis.py +++ b/erpnext/agriculture/doctype/water_analysis/water_analysis.py @@ -3,10 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe import _ + class WaterAnalysis(Document): @frappe.whitelist() diff --git a/erpnext/agriculture/doctype/water_analysis_criteria/water_analysis_criteria.py b/erpnext/agriculture/doctype/water_analysis_criteria/water_analysis_criteria.py index 6833f90539..8771733213 100644 --- a/erpnext/agriculture/doctype/water_analysis_criteria/water_analysis_criteria.py +++ b/erpnext/agriculture/doctype/water_analysis_criteria/water_analysis_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class WaterAnalysisCriteria(Document): pass diff --git a/erpnext/agriculture/doctype/weather/test_weather.py b/erpnext/agriculture/doctype/weather/test_weather.py index b4ab3ae6f3..1b4bab9a53 100644 --- a/erpnext/agriculture/doctype/weather/test_weather.py +++ b/erpnext/agriculture/doctype/weather/test_weather.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestWeather(unittest.TestCase): pass diff --git a/erpnext/agriculture/doctype/weather/weather.py b/erpnext/agriculture/doctype/weather/weather.py index 235e684e51..b41964dafd 100644 --- a/erpnext/agriculture/doctype/weather/weather.py +++ b/erpnext/agriculture/doctype/weather/weather.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class Weather(Document): @frappe.whitelist() def load_contents(self): diff --git a/erpnext/agriculture/doctype/weather_parameter/weather_parameter.py b/erpnext/agriculture/doctype/weather_parameter/weather_parameter.py index 89db74cd7c..42fcbcb719 100644 --- a/erpnext/agriculture/doctype/weather_parameter/weather_parameter.py +++ b/erpnext/agriculture/doctype/weather_parameter/weather_parameter.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class WeatherParameter(Document): pass diff --git a/erpnext/assets/dashboard_fixtures.py b/erpnext/assets/dashboard_fixtures.py index 2c70179607..39f0f1a88b 100644 --- a/erpnext/assets/dashboard_fixtures.py +++ b/erpnext/assets/dashboard_fixtures.py @@ -1,13 +1,16 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -import frappe import json -from frappe.utils import nowdate, add_months, get_date_str + +import frappe from frappe import _ +from frappe.utils import get_date_str, nowdate + from erpnext.accounts.dashboard_fixtures import _get_fiscal_year from erpnext.buying.dashboard_fixtures import get_company_for_dashboards + def get_data(): fiscal_year = _get_fiscal_year(nowdate()) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 7afb43b36c..8ff4f9790a 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -3,18 +3,37 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext, math, json + +import json +import math + +import frappe from frappe import _ +from frappe.utils import ( + add_days, + add_months, + cint, + date_diff, + flt, + get_datetime, + get_last_day, + getdate, + month_diff, + nowdate, + today, +) from six import string_types -from frappe.utils import flt, add_months, cint, nowdate, getdate, today, date_diff, month_diff, add_days, get_last_day, get_datetime -from frappe.model.document import Document + +import erpnext +from erpnext.accounts.general_ledger import make_reverse_gl_entries +from erpnext.assets.doctype.asset.depreciation import ( + get_depreciation_accounts, + get_disposal_account_and_cost_center, +) from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account -from erpnext.assets.doctype.asset.depreciation \ - import get_disposal_account_and_cost_center, get_depreciation_accounts -from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries -from erpnext.accounts.utils import get_account_currency from erpnext.controllers.accounts_controller import AccountsController + class Asset(AccountsController): def validate(self): self.validate_asset_values() @@ -546,7 +565,7 @@ class Asset(AccountsController): cwip_account = None try: cwip_account = get_asset_account("capital_work_in_progress_account", self.name, self.asset_category, self.company) - except: + except Exception: # if no cwip account found in category or company and "cwip is enabled" then raise else silently pass if cwip_enabled: raise @@ -783,6 +802,7 @@ def make_journal_entry(asset_name): @frappe.whitelist() def make_asset_movement(assets, purpose=None): import json + from six import string_types if isinstance(assets, string_types): diff --git a/erpnext/assets/doctype/asset/asset_dashboard.py b/erpnext/assets/doctype/asset/asset_dashboard.py index 62bb4be53a..cd04e1d8f0 100644 --- a/erpnext/assets/doctype/asset/asset_dashboard.py +++ b/erpnext/assets/doctype/asset/asset_dashboard.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def get_data(): return { 'non_standard_fieldnames': { diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index 9a61b79ed3..609791012a 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -3,10 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, today, getdate, cint -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts +from frappe.utils import cint, flt, getdate, today + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_checks_for_pl_and_bs_accounts, +) + def post_depreciation_entries(date=None): # Return if automatic booking of asset depreciation is disabled diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 605ce2e250..4cc9be5b05 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -3,14 +3,23 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import cstr, nowdate, getdate, flt, get_last_day, add_days, add_months -from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset, restore_asset -from erpnext.assets.doctype.asset.asset import make_sales_invoice -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt + +import frappe +from frappe.utils import add_days, add_months, cstr, flt, get_last_day, getdate, nowdate + from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice -from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice as make_invoice +from erpnext.assets.doctype.asset.asset import make_sales_invoice +from erpnext.assets.doctype.asset.depreciation import ( + post_depreciation_entries, + restore_asset, + scrap_asset, +) +from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( + make_purchase_invoice as make_invoice, +) +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt + class TestAsset(unittest.TestCase): def setUp(self): diff --git a/erpnext/assets/doctype/asset_category/asset_category.py b/erpnext/assets/doctype/asset_category/asset_category.py index 39032d637b..1e56c010c4 100644 --- a/erpnext/assets/doctype/asset_category/asset_category.py +++ b/erpnext/assets/doctype/asset_category/asset_category.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cint, get_link_to_form from frappe.model.document import Document +from frappe.utils import cint, get_link_to_form + class AssetCategory(Document): def validate(self): diff --git a/erpnext/assets/doctype/asset_category/test_asset_category.py b/erpnext/assets/doctype/asset_category/test_asset_category.py index 9f7ada65d8..53ec4ed38e 100644 --- a/erpnext/assets/doctype/asset_category/test_asset_category.py +++ b/erpnext/assets/doctype/asset_category/test_asset_category.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestAssetCategory(unittest.TestCase): def test_mandatory_fields(self): asset_category = frappe.new_doc("Asset Category") diff --git a/erpnext/assets/doctype/asset_category_account/asset_category_account.py b/erpnext/assets/doctype/asset_category_account/asset_category_account.py index 67925f4fe8..66280acb2e 100644 --- a/erpnext/assets/doctype/asset_category_account/asset_category_account.py +++ b/erpnext/assets/doctype/asset_category_account/asset_category_account.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssetCategoryAccount(Document): pass diff --git a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.py b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.py index bdc2acfb79..c4f095305c 100644 --- a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.py +++ b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssetFinanceBook(Document): pass diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py index e14f1d88dc..ec55fa4efc 100644 --- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py +++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py @@ -3,12 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document +from frappe import _, throw from frappe.desk.form import assign_to -from frappe import throw, _ +from frappe.model.document import Document from frappe.utils import add_days, add_months, add_years, getdate, nowdate + class AssetMaintenance(Document): def validate(self): for task in self.get('asset_maintenance_tasks'): diff --git a/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py index 7610152039..0f915086a9 100644 --- a/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py +++ b/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py @@ -3,11 +3,14 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import nowdate, get_last_day, add_days -from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt + +import frappe +from frappe.utils import add_days, get_last_day, nowdate + from erpnext.assets.doctype.asset_maintenance.asset_maintenance import calculate_next_due_date +from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt + class TestAssetMaintenance(unittest.TestCase): def setUp(self): diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py index 34facd8d05..1f2393649d 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py +++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ -from frappe.utils import nowdate, getdate +from frappe.model.document import Document +from frappe.utils import getdate, nowdate + from erpnext.assets.doctype.asset_maintenance.asset_maintenance import calculate_next_due_date + class AssetMaintenanceLog(Document): def validate(self): if getdate(self.due_date) < getdate(nowdate()) and self.maintenance_status not in ["Completed", "Cancelled"]: diff --git a/erpnext/assets/doctype/asset_maintenance_log/test_asset_maintenance_log.py b/erpnext/assets/doctype/asset_maintenance_log/test_asset_maintenance_log.py index a1ec8792b2..7ad69e92ab 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/test_asset_maintenance_log.py +++ b/erpnext/assets/doctype/asset_maintenance_log/test_asset_maintenance_log.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestAssetMaintenanceLog(unittest.TestCase): pass diff --git a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py index 2a5666d506..2280f55728 100644 --- a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py +++ b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssetMaintenanceTask(Document): pass diff --git a/erpnext/assets/doctype/asset_maintenance_team/asset_maintenance_team.py b/erpnext/assets/doctype/asset_maintenance_team/asset_maintenance_team.py index f741a8fff3..46e9029941 100644 --- a/erpnext/assets/doctype/asset_maintenance_team/asset_maintenance_team.py +++ b/erpnext/assets/doctype/asset_maintenance_team/asset_maintenance_team.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssetMaintenanceTeam(Document): pass diff --git a/erpnext/assets/doctype/asset_maintenance_team/test_asset_maintenance_team.py b/erpnext/assets/doctype/asset_maintenance_team/test_asset_maintenance_team.py index a0c0b146f1..8d757b74c0 100644 --- a/erpnext/assets/doctype/asset_maintenance_team/test_asset_maintenance_team.py +++ b/erpnext/assets/doctype/asset_maintenance_team/test_asset_maintenance_team.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestAssetMaintenanceTeam(unittest.TestCase): pass diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.py b/erpnext/assets/doctype/asset_movement/asset_movement.py index 1771e27ddf..901bdb5c00 100644 --- a/erpnext/assets/doctype/asset_movement/asset_movement.py +++ b/erpnext/assets/doctype/asset_movement/asset_movement.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + class AssetMovement(Document): def validate(self): self.validate_asset() diff --git a/erpnext/assets/doctype/asset_movement/test_asset_movement.py b/erpnext/assets/doctype/asset_movement/test_asset_movement.py index 2b2d2b4400..058bbd1abd 100644 --- a/erpnext/assets/doctype/asset_movement/test_asset_movement.py +++ b/erpnext/assets/doctype/asset_movement/test_asset_movement.py @@ -3,16 +3,16 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -import erpnext -from erpnext.stock.doctype.item.test_item import make_item -from frappe.utils import now, nowdate, get_last_day, add_days + +import frappe +from frappe.utils import now + from erpnext.assets.doctype.asset.test_asset import create_asset_data -from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos from erpnext.hr.doctype.employee.test_employee import make_employee from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt + class TestAssetMovement(unittest.TestCase): def setUp(self): frappe.db.set_value("Company", "_Test Company", "capital_work_in_progress_account", "CWIP Account - _TC") diff --git a/erpnext/assets/doctype/asset_movement_item/asset_movement_item.py b/erpnext/assets/doctype/asset_movement_item/asset_movement_item.py index 4c6aaab58a..24da37176e 100644 --- a/erpnext/assets/doctype/asset_movement_item/asset_movement_item.py +++ b/erpnext/assets/doctype/asset_movement_item/asset_movement_item.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AssetMovementItem(Document): pass diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 746f582fdc..99a7d9bfbf 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -3,13 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import time_diff_in_hours, getdate, add_months, flt, cint +from frappe.utils import add_months, cint, flt, getdate, time_diff_in_hours + from erpnext.accounts.general_ledger import make_gl_entries from erpnext.assets.doctype.asset.asset import get_asset_account from erpnext.controllers.accounts_controller import AccountsController + class AssetRepair(AccountsController): def validate(self): self.asset_doc = frappe.get_doc('Asset', self.asset) diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index 5e727d007a..9945a328cf 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -2,10 +2,18 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import nowdate, flt + import unittest -from erpnext.assets.doctype.asset.test_asset import create_asset_data, create_asset, set_depreciation_settings_in_company + +import frappe +from frappe.utils import flt, nowdate + +from erpnext.assets.doctype.asset.test_asset import ( + create_asset, + create_asset_data, + set_depreciation_settings_in_company, +) + class TestAssetRepair(unittest.TestCase): def setUp(self): @@ -110,8 +118,8 @@ def num_of_depreciations(asset): return asset.finance_books[0].total_number_of_depreciations def create_asset_repair(**args): - from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice + from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse args = frappe._dict(args) diff --git a/erpnext/assets/doctype/asset_repair_consumed_item/asset_repair_consumed_item.py b/erpnext/assets/doctype/asset_repair_consumed_item/asset_repair_consumed_item.py index fa22a5712f..2a8d64ef49 100644 --- a/erpnext/assets/doctype/asset_repair_consumed_item/asset_repair_consumed_item.py +++ b/erpnext/assets/doctype/asset_repair_consumed_item/asset_repair_consumed_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class AssetRepairConsumedItem(Document): pass diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py index 2f6b5ee2dc..2c11018caa 100644 --- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py +++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py @@ -3,12 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, getdate, cint, date_diff, formatdate -from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts from frappe.model.document import Document -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts +from frappe.utils import cint, date_diff, flt, formatdate, getdate + +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_checks_for_pl_and_bs_accounts, +) +from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts + class AssetValueAdjustment(Document): def validate(self): diff --git a/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py index a9dc9795ee..52728d6fd6 100644 --- a/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py +++ b/erpnext/assets/doctype/asset_value_adjustment/test_asset_value_adjustment.py @@ -3,12 +3,17 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import nowdate, get_last_day, add_days + +import frappe +from frappe.utils import add_days, get_last_day, nowdate + from erpnext.assets.doctype.asset.test_asset import create_asset_data +from erpnext.assets.doctype.asset_value_adjustment.asset_value_adjustment import ( + get_current_asset_value, +) from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt -from erpnext.assets.doctype.asset_value_adjustment.asset_value_adjustment import get_current_asset_value + class TestAssetValueAdjustment(unittest.TestCase): def setUp(self): diff --git a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.py b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.py index 54fba3f68c..3199b7dc8d 100644 --- a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.py +++ b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class DepreciationSchedule(Document): pass diff --git a/erpnext/assets/doctype/linked_location/linked_location.py b/erpnext/assets/doctype/linked_location/linked_location.py index 3e49d3e18f..e622e84dc3 100644 --- a/erpnext/assets/doctype/linked_location/linked_location.py +++ b/erpnext/assets/doctype/linked_location/linked_location.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class LinkedLocation(Document): pass diff --git a/erpnext/assets/doctype/location/location.py b/erpnext/assets/doctype/location/location.py index 317894cb58..1430306bec 100644 --- a/erpnext/assets/doctype/location/location.py +++ b/erpnext/assets/doctype/location/location.py @@ -8,8 +8,6 @@ import json import math import frappe -from frappe import _ -from frappe.model.document import Document from frappe.utils import flt from frappe.utils.nestedset import NestedSet, update_nsm diff --git a/erpnext/assets/doctype/maintenance_team_member/maintenance_team_member.py b/erpnext/assets/doctype/maintenance_team_member/maintenance_team_member.py index 3d9e555db6..8fc5c9c43c 100644 --- a/erpnext/assets/doctype/maintenance_team_member/maintenance_team_member.py +++ b/erpnext/assets/doctype/maintenance_team_member/maintenance_team_member.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class MaintenanceTeamMember(Document): pass diff --git a/erpnext/assets/doctype/maintenance_team_member/test_maintenance_team_member.py b/erpnext/assets/doctype/maintenance_team_member/test_maintenance_team_member.py index c805e56e5c..f8958c6bbe 100644 --- a/erpnext/assets/doctype/maintenance_team_member/test_maintenance_team_member.py +++ b/erpnext/assets/doctype/maintenance_team_member/test_maintenance_team_member.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestMaintenanceTeamMember(unittest.TestCase): pass diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py index 7d07397944..e370b9d0cb 100644 --- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py +++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py @@ -2,10 +2,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cstr, today, flt, add_years, formatdate, getdate -from erpnext.accounts.report.financial_statements import get_period_list, get_fiscal_year_data, validate_fiscal_year +from frappe.utils import cstr, flt, formatdate, getdate + +from erpnext.accounts.report.financial_statements import ( + get_fiscal_year_data, + get_period_list, + validate_fiscal_year, +) + def execute(filters=None): filters = frappe._dict(filters or {}) diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.py b/erpnext/buying/doctype/buying_settings/buying_settings.py index a634a0908b..9e72c1890c 100644 --- a/erpnext/buying/doctype/buying_settings/buying_settings.py +++ b/erpnext/buying/doctype/buying_settings/buying_settings.py @@ -4,10 +4,11 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe +import frappe from frappe.model.document import Document + class BuyingSettings(Document): def validate(self): for key in ["supplier_group", "supp_master_name", "maintain_same_rate", "buying_price_list"]: diff --git a/erpnext/buying/doctype/buying_settings/test_buying_settings.py b/erpnext/buying/doctype/buying_settings/test_buying_settings.py index bf6eec67d4..4998aebd6b 100644 --- a/erpnext/buying/doctype/buying_settings/test_buying_settings.py +++ b/erpnext/buying/doctype/buying_settings/test_buying_settings.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBuyingSettings(unittest.TestCase): pass diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index a55a0b7f9f..ef54538fcd 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -144,9 +144,7 @@ { "fieldname": "supplier_section", "fieldtype": "Section Break", - "options": "fa fa-user", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-user" }, { "allow_on_submit": 1, @@ -156,9 +154,7 @@ "hidden": 1, "label": "Title", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "naming_series", @@ -170,9 +166,7 @@ "options": "PUR-ORD-.YYYY.-", "print_hide": 1, "reqd": 1, - "set_only_once": 1, - "show_days": 1, - "show_seconds": 1 + "set_only_once": 1 }, { "bold": 1, @@ -186,18 +180,14 @@ "options": "Supplier", "print_hide": 1, "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "depends_on": "eval:doc.supplier && doc.docstatus===0 && (!(doc.items && doc.items.length) || (doc.items.length==1 && !doc.items[0].item_code))", "description": "Fetch items based on Default Supplier.", "fieldname": "get_items_from_open_material_requests", "fieldtype": "Button", - "label": "Get Items from Open Material Requests", - "show_days": 1, - "show_seconds": 1 + "label": "Get Items from Open Material Requests" }, { "bold": 1, @@ -206,9 +196,7 @@ "fieldtype": "Data", "in_global_search": 1, "label": "Supplier Name", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "company", @@ -220,17 +208,13 @@ "options": "Company", "print_hide": 1, "remember_last_selected_value": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "column_break1", "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -242,35 +226,27 @@ "oldfieldname": "transaction_date", "oldfieldtype": "Date", "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "allow_on_submit": 1, "fieldname": "schedule_date", "fieldtype": "Date", - "label": "Required By", - "show_days": 1, - "show_seconds": 1 + "label": "Required By" }, { "allow_on_submit": 1, "depends_on": "eval:doc.docstatus===1", "fieldname": "order_confirmation_no", "fieldtype": "Data", - "label": "Order Confirmation No", - "show_days": 1, - "show_seconds": 1 + "label": "Order Confirmation No" }, { "allow_on_submit": 1, "depends_on": "eval:doc.order_confirmation_no", "fieldname": "order_confirmation_date", "fieldtype": "Date", - "label": "Order Confirmation Date", - "show_days": 1, - "show_seconds": 1 + "label": "Order Confirmation Date" }, { "fieldname": "amended_from", @@ -282,25 +258,19 @@ "oldfieldtype": "Data", "options": "Purchase Order", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "drop_ship", "fieldtype": "Section Break", - "label": "Drop Ship", - "show_days": 1, - "show_seconds": 1 + "label": "Drop Ship" }, { "fieldname": "customer", "fieldtype": "Link", "label": "Customer", "options": "Customer", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "bold": 1, @@ -308,41 +278,31 @@ "fieldtype": "Data", "label": "Customer Name", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_19", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "customer_contact_person", "fieldtype": "Link", "label": "Customer Contact", - "options": "Contact", - "show_days": 1, - "show_seconds": 1 + "options": "Contact" }, { "fieldname": "customer_contact_display", "fieldtype": "Small Text", "hidden": 1, "label": "Customer Contact", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "customer_contact_mobile", "fieldtype": "Small Text", "hidden": 1, "label": "Customer Mobile No", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "customer_contact_email", @@ -350,35 +310,27 @@ "hidden": 1, "label": "Customer Contact Email", "options": "Email", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, "fieldname": "section_addresses", "fieldtype": "Section Break", - "label": "Address and Contact", - "show_days": 1, - "show_seconds": 1 + "label": "Address and Contact" }, { "fieldname": "supplier_address", "fieldtype": "Link", "label": "Supplier Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "contact_person", "fieldtype": "Link", "label": "Supplier Contact", "options": "Contact", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "address_display", @@ -405,42 +357,32 @@ "label": "Contact Email", "options": "Email", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "col_break_address", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_address", "fieldtype": "Link", "label": "Company Shipping Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "shipping_address_display", "fieldtype": "Small Text", "label": "Shipping Address Details", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "currency_and_price_list", "fieldtype": "Section Break", "label": "Currency and Price List", - "options": "fa fa-tag", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-tag" }, { "fieldname": "currency", @@ -450,9 +392,7 @@ "oldfieldtype": "Select", "options": "Currency", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "conversion_rate", @@ -462,24 +402,18 @@ "oldfieldtype": "Currency", "precision": "9", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "cb_price_list", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "buying_price_list", "fieldtype": "Link", "label": "Price List", "options": "Price List", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "price_list_currency", @@ -487,18 +421,14 @@ "label": "Price List Currency", "options": "Currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "plc_conversion_rate", "fieldtype": "Float", "label": "Price List Exchange Rate", "precision": "9", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "default": "0", @@ -507,9 +437,7 @@ "label": "Ignore Pricing Rule", "no_copy": 1, "permlevel": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "sec_warehouse", @@ -522,15 +450,11 @@ "fieldtype": "Link", "label": "Set Target Warehouse", "options": "Warehouse", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "col_break_warehouse", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "default": "No", @@ -539,35 +463,27 @@ "in_standard_filter": 1, "label": "Supply Raw Materials", "options": "No\nYes", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "depends_on": "eval:doc.is_subcontracted==\"Yes\"", "fieldname": "supplier_warehouse", "fieldtype": "Link", "label": "Supplier Warehouse", - "options": "Warehouse", - "show_days": 1, - "show_seconds": 1 + "options": "Warehouse" }, { "fieldname": "items_section", "fieldtype": "Section Break", "hide_border": 1, "oldfieldtype": "Section Break", - "options": "fa fa-shopping-cart", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-shopping-cart" }, { "fieldname": "scan_barcode", "fieldtype": "Data", "label": "Scan Barcode", - "options": "Barcode", - "show_days": 1, - "show_seconds": 1 + "options": "Barcode" }, { "allow_bulk_edit": 1, @@ -577,34 +493,26 @@ "oldfieldname": "po_details", "oldfieldtype": "Table", "options": "Purchase Order Item", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "collapsible": 1, "fieldname": "section_break_48", "fieldtype": "Section Break", - "label": "Pricing Rules", - "show_days": 1, - "show_seconds": 1 + "label": "Pricing Rules" }, { "fieldname": "pricing_rules", "fieldtype": "Table", "label": "Purchase Order Pricing Rule", "options": "Pricing Rule Detail", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible_depends_on": "supplied_items", "fieldname": "raw_material_details", "fieldtype": "Section Break", - "label": "Raw Materials Supplied", - "show_days": 1, - "show_seconds": 1 + "label": "Raw Materials Supplied" }, { "fieldname": "supplied_items", @@ -615,23 +523,17 @@ "oldfieldtype": "Table", "options": "Purchase Order Item Supplied", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "sb_last_purchase", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "total_qty", "fieldtype": "Float", "label": "Total Quantity", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_total", @@ -639,9 +541,7 @@ "label": "Total (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_net_total", @@ -652,24 +552,18 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_26", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "total", "fieldtype": "Currency", "label": "Total", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "net_total", @@ -679,26 +573,20 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "total_net_weight", "fieldtype": "Float", "label": "Total Net Weight", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "taxes_section", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "fieldname": "taxes_and_charges", @@ -707,24 +595,18 @@ "oldfieldname": "purchase_other_charges", "oldfieldtype": "Link", "options": "Purchase Taxes and Charges Template", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break_50", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_rule", "fieldtype": "Link", "label": "Shipping Rule", "options": "Shipping Rule", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "section_break_52", @@ -737,17 +619,13 @@ "label": "Purchase Taxes and Charges", "oldfieldname": "purchase_tax_details", "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", - "show_days": 1, - "show_seconds": 1 + "options": "Purchase Taxes and Charges" }, { "collapsible": 1, "fieldname": "sec_tax_breakup", "fieldtype": "Section Break", - "label": "Tax Breakup", - "show_days": 1, - "show_seconds": 1 + "label": "Tax Breakup" }, { "fieldname": "other_charges_calculation", @@ -756,18 +634,14 @@ "no_copy": 1, "oldfieldtype": "HTML", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "totals", "fieldtype": "Section Break", "label": "Taxes and Charges", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "depends_on": "base_taxes_and_charges_added", @@ -778,9 +652,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "base_taxes_and_charges_deducted", @@ -791,9 +663,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "base_total_taxes_and_charges", @@ -805,15 +675,11 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_39", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "depends_on": "taxes_and_charges_added", @@ -824,9 +690,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "taxes_and_charges_deducted", @@ -837,9 +701,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "total_taxes_and_charges", @@ -848,18 +710,14 @@ "label": "Total Taxes and Charges", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "collapsible_depends_on": "apply_discount_on", "fieldname": "discount_section", "fieldtype": "Section Break", - "label": "Additional Discount", - "show_days": 1, - "show_seconds": 1 + "label": "Additional Discount" }, { "default": "Grand Total", @@ -867,9 +725,7 @@ "fieldtype": "Select", "label": "Apply Additional Discount On", "options": "\nGrand Total\nNet Total", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "base_discount_amount", @@ -877,32 +733,24 @@ "label": "Additional Discount Amount (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_45", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "additional_discount_percentage", "fieldtype": "Float", "label": "Additional Discount Percentage", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "discount_amount", "fieldtype": "Currency", "label": "Additional Discount Amount", "options": "currency", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "totals_section", @@ -918,9 +766,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "eval:!doc.disable_rounded_total", @@ -930,9 +776,7 @@ "no_copy": 1, "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "description": "In Words will be visible once you save the Purchase Order.", @@ -943,9 +787,7 @@ "oldfieldname": "in_words", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_rounded_total", @@ -955,16 +797,12 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break4", "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Column Break" }, { "fieldname": "grand_total", @@ -974,9 +812,7 @@ "oldfieldname": "grand_total_import", "oldfieldtype": "Currency", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "eval:!doc.disable_rounded_total", @@ -986,26 +822,20 @@ "no_copy": 1, "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "rounded_total", "fieldtype": "Currency", "label": "Rounded Total", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "default": "0", "fieldname": "disable_rounded_total", "fieldtype": "Check", - "label": "Disable Rounded Total", - "show_days": 1, - "show_seconds": 1 + "label": "Disable Rounded Total" }, { "fieldname": "in_words", @@ -1015,9 +845,7 @@ "oldfieldname": "in_words_import", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "advance_paid", @@ -1026,25 +854,19 @@ "no_copy": 1, "options": "party_account_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "payment_schedule_section", "fieldtype": "Section Break", - "label": "Payment Terms", - "show_days": 1, - "show_seconds": 1 + "label": "Payment Terms" }, { "fieldname": "payment_terms_template", "fieldtype": "Link", "label": "Payment Terms Template", - "options": "Payment Terms Template", - "show_days": 1, - "show_seconds": 1 + "options": "Payment Terms Template" }, { "fieldname": "payment_schedule", @@ -1052,9 +874,7 @@ "label": "Payment Schedule", "no_copy": 1, "options": "Payment Schedule", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, @@ -1063,9 +883,7 @@ "fieldtype": "Section Break", "label": "Terms and Conditions", "oldfieldtype": "Section Break", - "options": "fa fa-legal", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-legal" }, { "fieldname": "tc_name", @@ -1074,27 +892,21 @@ "oldfieldname": "tc_name", "oldfieldtype": "Link", "options": "Terms and Conditions", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "terms", "fieldtype": "Text Editor", "label": "Terms and Conditions", "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Text Editor" }, { "collapsible": 1, "fieldname": "more_info", "fieldtype": "Section Break", "label": "More Information", - "oldfieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Section Break" }, { "default": "Draft", @@ -1109,9 +921,7 @@ "print_hide": 1, "read_only": 1, "reqd": 1, - "search_index": 1, - "show_days": 1, - "show_seconds": 1 + "search_index": 1 }, { "fieldname": "ref_sq", @@ -1122,9 +932,7 @@ "oldfieldtype": "Data", "options": "Supplier Quotation", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "party_account_currency", @@ -1134,24 +942,18 @@ "no_copy": 1, "options": "Currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "inter_company_order_reference", "fieldtype": "Link", "label": "Inter Company Order Reference", "options": "Sales Order", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_74", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "depends_on": "eval:!doc.__islocal", @@ -1161,9 +963,7 @@ "label": "% Received", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "eval:!doc.__islocal", @@ -1173,9 +973,7 @@ "label": "% Billed", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, @@ -1185,8 +983,6 @@ "oldfieldtype": "Column Break", "print_hide": 1, "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -1197,9 +993,7 @@ "oldfieldname": "letter_head", "oldfieldtype": "Select", "options": "Letter Head", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "allow_on_submit": 1, @@ -1211,15 +1005,11 @@ "oldfieldtype": "Link", "options": "Print Heading", "print_hide": 1, - "report_hide": 1, - "show_days": 1, - "show_seconds": 1 + "report_hide": 1 }, { "fieldname": "column_break_86", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "allow_on_submit": 1, @@ -1227,25 +1017,19 @@ "fieldname": "group_same_items", "fieldtype": "Check", "label": "Group same items", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "language", "fieldtype": "Data", "label": "Print Language", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, "fieldname": "subscription_section", "fieldtype": "Section Break", - "label": "Subscription Section", - "show_days": 1, - "show_seconds": 1 + "label": "Subscription Section" }, { "allow_on_submit": 1, @@ -1253,9 +1037,7 @@ "fieldtype": "Date", "label": "From Date", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "allow_on_submit": 1, @@ -1263,15 +1045,11 @@ "fieldtype": "Date", "label": "To Date", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break_97", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "auto_repeat", @@ -1280,35 +1058,27 @@ "no_copy": 1, "options": "Auto Repeat", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "allow_on_submit": 1, "depends_on": "eval: doc.auto_repeat", "fieldname": "update_auto_repeat_reference", "fieldtype": "Button", - "label": "Update Auto Repeat Reference", - "show_days": 1, - "show_seconds": 1 + "label": "Update Auto Repeat Reference" }, { "fieldname": "tax_category", "fieldtype": "Link", "label": "Tax Category", - "options": "Tax Category", - "show_days": 1, - "show_seconds": 1 + "options": "Tax Category" }, { "depends_on": "supplied_items", "fieldname": "set_reserve_warehouse", "fieldtype": "Link", "label": "Set Reserve Warehouse", - "options": "Warehouse", - "show_days": 1, - "show_seconds": 1 + "options": "Warehouse" }, { "collapsible": 1, @@ -1318,9 +1088,7 @@ }, { "fieldname": "column_break_75", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "billing_address", @@ -1361,25 +1129,21 @@ "default": "0", "fieldname": "apply_tds", "fieldtype": "Check", - "label": "Apply Tax Withholding Amount", - "show_days": 1, - "show_seconds": 1 + "label": "Apply Tax Withholding Amount" }, { "depends_on": "eval: doc.apply_tds", "fieldname": "tax_withholding_category", "fieldtype": "Link", "label": "Tax Withholding Category", - "options": "Tax Withholding Category", - "show_days": 1, - "show_seconds": 1 + "options": "Tax Withholding Category" } ], "icon": "fa fa-file-text", "idx": 105, "is_submittable": 1, "links": [], - "modified": "2021-08-17 20:16:12.737743", + "modified": "2021-08-30 20:03:14.008804", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index ca3bd90960..ac86337b25 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -2,23 +2,30 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + import json -from frappe.utils import cstr, flt, cint -from frappe import msgprint, _ -from frappe.model.mapper import get_mapped_doc -from erpnext.controllers.buying_controller import BuyingController -from erpnext.stock.doctype.item.item import get_last_purchase_details -from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty + +import frappe +from frappe import _, msgprint from frappe.desk.notifications import clear_doctype_notifications -from erpnext.buying.utils import validate_for_items, check_on_hold_or_closed_status -from erpnext.stock.utils import get_bin +from frappe.model.mapper import get_mapped_doc +from frappe.utils import cint, cstr, flt + +from erpnext.accounts.doctype.sales_invoice.sales_invoice import ( + unlink_inter_company_doc, + update_linked_doc, + validate_inter_company_party, +) +from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import ( + get_party_tax_withholding_details, +) from erpnext.accounts.party import get_party_account_currency -from erpnext.stock.doctype.item.item import get_item_defaults +from erpnext.buying.utils import check_on_hold_or_closed_status, validate_for_items +from erpnext.controllers.buying_controller import BuyingController from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults -from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details -from erpnext.accounts.doctype.sales_invoice.sales_invoice import (validate_inter_company_party, - update_linked_doc, unlink_inter_company_doc) +from erpnext.stock.doctype.item.item import get_item_defaults, get_last_purchase_details +from erpnext.stock.stock_balance import get_ordered_qty, update_bin_qty +from erpnext.stock.utils import get_bin form_grid_templates = { "items": "templates/form_grid/item_grid.html" diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py b/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py index ab514dac30..af1dceb407 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'purchase_order', diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index fa174ba8fa..1453b8e7e4 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -2,24 +2,31 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import unittest -import frappe -import json -import frappe.defaults -from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry -from frappe.utils import flt, add_days, nowdate, getdate -from erpnext.stock.doctype.item.test_item import make_item -from erpnext.buying.doctype.purchase_order.purchase_order \ - import (make_purchase_receipt, make_purchase_invoice as make_pi_from_po, make_rm_stock_entry as make_subcontract_transfer_entry) -from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice as make_pi_from_pr -from erpnext.stock.doctype.material_request.test_material_request import make_material_request -from erpnext.stock.doctype.material_request.material_request import make_purchase_order -from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry -from erpnext.controllers.accounts_controller import update_child_qty_rate -from erpnext.controllers.status_updater import OverAllowanceError -from erpnext.manufacturing.doctype.blanket_order.test_blanket_order import make_blanket_order -from erpnext.stock.doctype.batch.test_batch import make_new_batch +import json +import unittest + +import frappe +from frappe.utils import add_days, flt, getdate, nowdate + +from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry +from erpnext.buying.doctype.purchase_order.purchase_order import ( + make_purchase_invoice as make_pi_from_po, +) +from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt +from erpnext.buying.doctype.purchase_order.purchase_order import ( + make_rm_stock_entry as make_subcontract_transfer_entry, +) +from erpnext.controllers.accounts_controller import update_child_qty_rate +from erpnext.manufacturing.doctype.blanket_order.test_blanket_order import make_blanket_order +from erpnext.stock.doctype.item.test_item import make_item +from erpnext.stock.doctype.material_request.material_request import make_purchase_order +from erpnext.stock.doctype.material_request.test_material_request import make_material_request +from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( + make_purchase_invoice as make_pi_from_pr, +) +from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_receipt(self): @@ -415,10 +422,12 @@ class TestPurchaseOrder(unittest.TestCase): self.assertEqual(po.get("items")[0].received_qty, 9) # Make return purchase receipt, purchase invoice and check quantity - from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \ - import make_purchase_receipt as make_purchase_receipt_return - from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice \ - import make_purchase_invoice as make_purchase_invoice_return + from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import ( + make_purchase_invoice as make_purchase_invoice_return, + ) + from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import ( + make_purchase_receipt as make_purchase_receipt_return, + ) pr1 = make_purchase_receipt_return(is_return=1, return_against=pr.name, qty=-3, do_not_submit=True) pr1.items[0].purchase_order = po.name @@ -484,7 +493,9 @@ class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_invoice_with_terms(self): - from erpnext.selling.doctype.sales_order.test_sales_order import automatically_fetch_payment_terms, compare_payment_schedules + from erpnext.selling.doctype.sales_order.test_sales_order import ( + automatically_fetch_payment_terms, + ) automatically_fetch_payment_terms() po = create_purchase_order(do_not_save=True) @@ -977,9 +988,14 @@ class TestPurchaseOrder(unittest.TestCase): self.assertEqual(po_doc.items[0].blanket_order, None) def test_payment_terms_are_fetched_when_creating_purchase_invoice(self): - from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_terms_template + from erpnext.accounts.doctype.payment_entry.test_payment_entry import ( + create_payment_terms_template, + ) from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice - from erpnext.selling.doctype.sales_order.test_sales_order import automatically_fetch_payment_terms, compare_payment_schedules + from erpnext.selling.doctype.sales_order.test_sales_order import ( + automatically_fetch_payment_terms, + compare_payment_schedules, + ) automatically_fetch_payment_terms() diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json index 132dd1769c..87cd57517e 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -10,6 +10,7 @@ "item_code", "supplier_part_no", "item_name", + "product_bundle", "column_break_4", "schedule_date", "expected_delivery_date", @@ -488,7 +489,6 @@ "no_copy": 1, "options": "Sales Order", "print_hide": 1, - "read_only": 1, "search_index": 1 }, { @@ -830,13 +830,20 @@ "label": "Production Plan Sub Assembly Item", "no_copy": 1, "read_only": 1 + }, + { + "fieldname": "product_bundle", + "fieldtype": "Link", + "label": "Product Bundle", + "options": "Product Bundle", + "read_only": 1 } ], "idx": 1, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-06-28 19:22:22.715365", + "modified": "2021-08-30 20:06:26.712097", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order Item", diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py index b6e28b6c67..a391a3d068 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py @@ -2,10 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe +import frappe from frappe.model.document import Document + class PurchaseOrderItem(Document): pass diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py index c85ca2fbaf..909faeca6a 100644 --- a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py +++ b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PurchaseOrderItemSupplied(Document): pass diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py index 00c93ed1ea..caec4e8b7a 100644 --- a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py +++ b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PurchaseReceiptItemSupplied(Document): pass diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 8ed6c9e2a6..af1a9a907a 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -3,21 +3,24 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json -from frappe import _ -from frappe.model.mapper import get_mapped_doc -from frappe.utils import get_url, cint -from frappe.utils.user import get_user_fullname -from frappe.utils.print_format import download_pdf -from frappe.desk.form.load import get_attachments -from frappe.core.doctype.communication.email import make -from erpnext.accounts.party import get_party_account_currency, get_party_details -from erpnext.stock.doctype.material_request.material_request import set_missing_values -from erpnext.controllers.buying_controller import BuyingController -from erpnext.buying.utils import validate_for_items +import json + +import frappe +from frappe import _ +from frappe.core.doctype.communication.email import make +from frappe.desk.form.load import get_attachments +from frappe.model.mapper import get_mapped_doc +from frappe.utils import get_url +from frappe.utils.print_format import download_pdf +from frappe.utils.user import get_user_fullname from six import string_types +from erpnext.accounts.party import get_party_account_currency, get_party_details +from erpnext.buying.utils import validate_for_items +from erpnext.controllers.buying_controller import BuyingController +from erpnext.stock.doctype.material_request.material_request import set_missing_values + STANDARD_USERS = ("Guest", "Administrator") class RequestforQuotation(BuyingController): diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation_dashboard.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation_dashboard.py index 751336dc4c..0708cab30a 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation_dashboard.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation_dashboard.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from frappe import _ + def get_data(): return { diff --git a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py index 36f87b0b84..33fde8e6dc 100644 --- a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py @@ -7,12 +7,16 @@ import unittest import frappe from frappe.utils import nowdate + +from erpnext.buying.doctype.request_for_quotation.request_for_quotation import ( + create_supplier_quotation, + make_supplier_quotation_from_rfq, +) +from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq +from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity from erpnext.stock.doctype.item.test_item import make_item from erpnext.templates.pages.rfq import check_supplier_has_docname_access -from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation_from_rfq -from erpnext.buying.doctype.request_for_quotation.request_for_quotation import create_supplier_quotation -from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity -from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq + class TestRequestforQuotation(unittest.TestCase): def test_quote_status(self): diff --git a/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.py b/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.py index cc897af944..35f3305b8e 100644 --- a/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.py +++ b/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class RequestforQuotationItem(Document): pass diff --git a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.py b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.py index 4b0bbbee8c..47c0deb39f 100644 --- a/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.py +++ b/erpnext/buying/doctype/request_for_quotation_supplier/request_for_quotation_supplier.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class RequestforQuotationSupplier(Document): pass diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 1766c2c80c..7ee91961ca 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -24,7 +24,26 @@ frappe.ui.form.on("Supplier", { } } }); + + frm.set_query("supplier_primary_contact", function(doc) { + return { + query: "erpnext.buying.doctype.supplier.supplier.get_supplier_primary_contact", + filters: { + "supplier": doc.name + } + }; + }); + + frm.set_query("supplier_primary_address", function(doc) { + return { + filters: { + "link_doctype": "Supplier", + "link_name": doc.name + } + }; + }); }, + refresh: function (frm) { frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Supplier' } @@ -78,6 +97,30 @@ frappe.ui.form.on("Supplier", { }); }, + supplier_primary_address: function(frm) { + if (frm.doc.supplier_primary_address) { + frappe.call({ + method: 'frappe.contacts.doctype.address.address.get_address_display', + args: { + "address_dict": frm.doc.supplier_primary_address + }, + callback: function(r) { + frm.set_value("primary_address", r.message); + } + }); + } + if (!frm.doc.supplier_primary_address) { + frm.set_value("primary_address", ""); + } + }, + + supplier_primary_contact: function(frm) { + if (!frm.doc.supplier_primary_contact) { + frm.set_value("mobile_no", ""); + frm.set_value("email_id", ""); + } + }, + is_internal_supplier: function(frm) { if (frm.doc.is_internal_supplier == 1) { frm.toggle_reqd("represents_company", true); diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 38b8dfdf48..c7a5db5994 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -49,6 +49,13 @@ "address_html", "column_break1", "contact_html", + "primary_address_and_contact_detail_section", + "supplier_primary_contact", + "mobile_no", + "email_id", + "column_break_44", + "supplier_primary_address", + "primary_address", "default_payable_accounts", "accounts", "default_tax_withholding_config", @@ -378,6 +385,47 @@ "fieldname": "allow_purchase_invoice_creation_without_purchase_receipt", "fieldtype": "Check", "label": "Allow Purchase Invoice Creation Without Purchase Receipt" + }, + { + "fieldname": "primary_address_and_contact_detail_section", + "fieldtype": "Section Break", + "label": "Primary Address and Contact Detail" + }, + { + "description": "Reselect, if the chosen contact is edited after save", + "fieldname": "supplier_primary_contact", + "fieldtype": "Link", + "label": "Supplier Primary Contact", + "options": "Contact" + }, + { + "fetch_from": "supplier_primary_contact.mobile_no", + "fieldname": "mobile_no", + "fieldtype": "Read Only", + "label": "Mobile No" + }, + { + "fetch_from": "supplier_primary_contact.email_id", + "fieldname": "email_id", + "fieldtype": "Read Only", + "label": "Email Id" + }, + { + "fieldname": "column_break_44", + "fieldtype": "Column Break" + }, + { + "fieldname": "primary_address", + "fieldtype": "Text", + "label": "Primary Address", + "read_only": 1 + }, + { + "description": "Reselect, if the chosen address is edited after save", + "fieldname": "supplier_primary_address", + "fieldtype": "Link", + "label": "Supplier Primary Address", + "options": "Address" } ], "icon": "fa fa-user", @@ -390,7 +438,7 @@ "link_fieldname": "supplier" } ], - "modified": "2021-05-18 15:10:11.087191", + "modified": "2021-08-27 18:02:44.314077", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index fd16b23c22..2a9f784ec6 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -2,13 +2,18 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe import frappe.defaults -from frappe import msgprint, _ +from frappe import _, msgprint +from frappe.contacts.address_and_contact import ( + delete_contact_and_address, + load_address_and_contact, +) from frappe.model.naming import set_name_by_naming_series -from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address + +from erpnext.accounts.party import get_dashboard_info, validate_party_accounts from erpnext.utilities.transaction_base import TransactionBase -from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this class Supplier(TransactionBase): @@ -42,7 +47,12 @@ class Supplier(TransactionBase): if not self.naming_series: self.naming_series = '' + self.create_primary_contact() + self.create_primary_address() + def validate(self): + self.flags.is_new_doc = self.is_new() + # validation for Naming Series mandatory field... if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series': if not self.naming_series: @@ -76,7 +86,40 @@ class Supplier(TransactionBase): frappe.throw(_("Internal Supplier for company {0} already exists").format( frappe.bold(self.represents_company))) + def create_primary_contact(self): + from erpnext.selling.doctype.customer.customer import make_contact + + if not self.supplier_primary_contact: + if self.mobile_no or self.email_id: + contact = make_contact(self) + self.db_set('supplier_primary_contact', contact.name) + self.db_set('mobile_no', self.mobile_no) + self.db_set('email_id', self.email_id) + + def create_primary_address(self): + from frappe.contacts.doctype.address.address import get_address_display + + from erpnext.selling.doctype.customer.customer import make_address + + if self.flags.is_new_doc and self.get('address_line1'): + address = make_address(self) + address_display = get_address_display(address.name) + + self.db_set("supplier_primary_address", address.name) + self.db_set("primary_address", address_display) + def on_trash(self): + if self.supplier_primary_contact: + frappe.db.sql(""" + UPDATE `tabSupplier` + SET + supplier_primary_contact=null, + supplier_primary_address=null, + mobile_no=null, + email_id=null, + primary_address=null + WHERE name=%(name)s""", {"name": self.name}) + delete_contact_and_address('Supplier', self.name) def after_rename(self, olddn, newdn, merge=False): @@ -104,3 +147,21 @@ class Supplier(TransactionBase): doc.name, args.get('supplier_email_' + str(i))) except frappe.NameError: pass + +@frappe.whitelist() +@frappe.validate_and_sanitize_search_inputs +def get_supplier_primary_contact(doctype, txt, searchfield, start, page_len, filters): + supplier = filters.get("supplier") + return frappe.db.sql(""" + SELECT + `tabContact`.name from `tabContact`, + `tabDynamic Link` + WHERE + `tabContact`.name = `tabDynamic Link`.parent + and `tabDynamic Link`.link_name = %(supplier)s + and `tabDynamic Link`.link_doctype = 'Supplier' + and `tabContact`.name like %(txt)s + """, { + 'supplier': supplier, + 'txt': '%%%s%%' % txt + }) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index 8980466270..8a4eefa4fd 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -2,11 +2,13 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals +import unittest + +import frappe +from frappe.test_runner import make_test_records -import frappe, unittest from erpnext.accounts.party import get_due_date from erpnext.exceptions import PartyDisabled -from frappe.test_runner import make_test_records test_dependencies = ['Payment Term', 'Payment Terms Template'] test_records = frappe.get_test_records('Supplier') diff --git a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py index 4473ddea28..6d71f7d516 100644 --- a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py +++ b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + class SupplierItemGroup(Document): def validate(self): exists = frappe.db.exists({ diff --git a/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py b/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py index c75044d44e..55ba85ef2d 100644 --- a/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py +++ b/erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestSupplierItemGroup(unittest.TestCase): pass diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 25e4e2a4dc..af462fc685 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -2,13 +2,14 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt, nowdate, add_days, getdate from frappe.model.mapper import get_mapped_doc +from frappe.utils import flt, getdate, nowdate -from erpnext.controllers.buying_controller import BuyingController from erpnext.buying.utils import validate_for_items +from erpnext.controllers.buying_controller import BuyingController form_grid_templates = { "items": "templates/form_grid/item_grid.html" diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py index 6b40305e01..014b1025dd 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'supplier_quotation', diff --git a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py index 6f34ca6c39..2db8e22f08 100644 --- a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -3,9 +3,11 @@ from __future__ import unicode_literals + import unittest + import frappe -import frappe.defaults + class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_order(self): diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py index 64dda87945..03adab5462 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class SupplierQuotationItem(Document): pass diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py index e956afdf74..f944fe4466 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py @@ -3,13 +3,19 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe import throw, _ -from frappe.model.document import Document + import time from datetime import timedelta -from frappe.utils import nowdate, get_last_day, getdate, add_days, add_years -from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import make_supplier_scorecard + +import frappe +from frappe import _, throw +from frappe.model.document import Document +from frappe.utils import add_days, add_years, get_last_day, getdate, nowdate + +from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import ( + make_supplier_scorecard, +) + class SupplierScorecard(Document): diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py index 8e5cce5696..7186e01d08 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'heatmap': True, diff --git a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py index a5f05ea525..ef7fae3f11 100644 --- a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestSupplierScorecard(unittest.TestCase): def test_create_scorecard(self): diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py index 33a0dc7837..c456377d9b 100644 --- a/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py +++ b/erpnext/buying/doctype/supplier_scorecard_criteria/supplier_scorecard_criteria.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import re + import frappe from frappe import _ -import re from frappe.model.document import Document + class InvalidFormulaVariable(frappe.ValidationError): pass class SupplierScorecardCriteria(Document): diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py index 3babfc8cab..9fca9a9f17 100644 --- a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py +++ b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestSupplierScorecardCriteria(unittest.TestCase): def test_variables_exist(self): delete_test_scorecards() diff --git a/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py index cc345e96bb..b03d216ce2 100644 --- a/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py +++ b/erpnext/buying/doctype/supplier_scorecard_period/supplier_scorecard_period.py @@ -3,12 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import throw, _ +from frappe import _, throw from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc + import erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable as variable_functions -from erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria import get_variables +from erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria import ( + get_variables, +) + class SupplierScorecardPeriod(Document): diff --git a/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py index 8baa3185ba..de8bc0a027 100644 --- a/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py +++ b/erpnext/buying/doctype/supplier_scorecard_period/test_supplier_scorecard_period.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestSupplierScorecardPeriod(unittest.TestCase): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py index b64abed8a6..79d5082ab6 100644 --- a/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py +++ b/erpnext/buying/doctype/supplier_scorecard_scoring_criteria/supplier_scorecard_scoring_criteria.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SupplierScorecardScoringCriteria(Document): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py index e8ad79f33d..5063b20ddb 100644 --- a/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py +++ b/erpnext/buying/doctype/supplier_scorecard_scoring_standing/supplier_scorecard_scoring_standing.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SupplierScorecardScoringStanding(Document): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py index 58a8a99a09..476cb35e8c 100644 --- a/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py +++ b/erpnext/buying/doctype/supplier_scorecard_scoring_variable/supplier_scorecard_scoring_variable.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SupplierScorecardScoringVariable(Document): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py index 678855a457..4fc45e89c7 100644 --- a/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py +++ b/erpnext/buying/doctype/supplier_scorecard_standing/supplier_scorecard_standing.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class SupplierScorecardStanding(Document): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py b/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py index 4d96651313..5ac5927d08 100644 --- a/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py +++ b/erpnext/buying/doctype/supplier_scorecard_standing/test_supplier_scorecard_standing.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestSupplierScorecardStanding(unittest.TestCase): pass diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py index 89a6459bba..30b2a1893f 100644 --- a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py +++ b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import sys + +import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import getdate + class VariablePathNotFound(frappe.ValidationError): pass class SupplierScorecardVariable(Document): @@ -18,7 +21,9 @@ class SupplierScorecardVariable(Document): def validate_path_exists(self): if '.' in self.path: try: - from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import import_string_path + from erpnext.buying.doctype.supplier_scorecard_period.supplier_scorecard_period import ( + import_string_path, + ) import_string_path(self.path) except AttributeError: frappe.throw(_("Could not find path for " + self.path), VariablePathNotFound) diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py index 14b87105e6..990413cd40 100644 --- a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py +++ b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py @@ -3,10 +3,13 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable import VariablePathNotFound +import frappe + +from erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable import ( + VariablePathNotFound, +) class TestSupplierScorecardVariable(unittest.TestCase): diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py index 99bcbe633c..cb99234282 100644 --- a/erpnext/buying/report/procurement_tracker/procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import flt + def execute(filters=None): columns = get_columns(filters) data = get_data(filters) diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index c36083f2af..a5b09473a0 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -2,15 +2,19 @@ # For license information, please see license.txt from __future__ import unicode_literals + import unittest from datetime import datetime + import frappe -from erpnext.buying.report.procurement_tracker.procurement_tracker import execute -from erpnext.stock.doctype.material_request.test_material_request import make_material_request -from erpnext.stock.doctype.material_request.material_request import make_purchase_order + from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt +from erpnext.buying.report.procurement_tracker.procurement_tracker import execute +from erpnext.stock.doctype.material_request.material_request import make_purchase_order +from erpnext.stock.doctype.material_request.test_material_request import make_material_request from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse + class TestProcurementTracker(unittest.TestCase): def test_result_for_procurement_tracker(self): filters = { diff --git a/erpnext/buying/report/purchase_analytics/purchase_analytics.py b/erpnext/buying/report/purchase_analytics/purchase_analytics.py index 0f949477b1..bef66da481 100644 --- a/erpnext/buying/report/purchase_analytics/purchase_analytics.py +++ b/erpnext/buying/report/purchase_analytics/purchase_analytics.py @@ -2,7 +2,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from erpnext.selling.report.sales_analytics.sales_analytics import Analytics + def execute(filters=None): return Analytics(filters).run() diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py index bda172769a..5d59456550 100644 --- a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py +++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py @@ -2,10 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import copy + +import frappe from frappe import _ -from frappe.utils import flt, date_diff, getdate +from frappe.utils import date_diff, flt, getdate + def execute(filters=None): if not filters: diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py index 095a44319d..9781480afa 100644 --- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py +++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe + from frappe import _ -from erpnext.controllers.trends import get_columns,get_data + +from erpnext.controllers.trends import get_columns, get_data + def execute(filters=None): if not filters: filters ={} diff --git a/erpnext/buying/report/requested_items_to_order_and_receive/requested_items_to_order_and_receive.py b/erpnext/buying/report/requested_items_to_order_and_receive/requested_items_to_order_and_receive.py index faf67c9f7f..42cc6ebc0a 100644 --- a/erpnext/buying/report/requested_items_to_order_and_receive/requested_items_to_order_and_receive.py +++ b/erpnext/buying/report/requested_items_to_order_and_receive/requested_items_to_order_and_receive.py @@ -2,10 +2,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import copy + +import frappe from frappe import _ -from frappe.utils import flt, date_diff, getdate +from frappe.utils import date_diff, flt, getdate + def execute(filters=None): if not filters: diff --git a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py index 9a45972837..202d364185 100644 --- a/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py +++ b/erpnext/buying/report/subcontract_order_summary/subcontract_order_summary.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): columns, data = [], [] columns = get_columns() diff --git a/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py b/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py index 2da53d726b..9299cca0da 100644 --- a/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py +++ b/erpnext/buying/report/subcontracted_item_to_be_received/subcontracted_item_to_be_received.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): if filters.from_date >= filters.to_date: frappe.msgprint(_("To Date must be greater than From Date")) diff --git a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py index cb304a1fda..7aeae45164 100644 --- a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py +++ b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py @@ -3,12 +3,18 @@ # Compiled at: 2019-05-06 09:51:46 # Decompiled by https://python-decompiler.com from __future__ import unicode_literals -from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order + +import unittest + +import frappe + from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt +from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order +from erpnext.buying.report.subcontracted_item_to_be_received.subcontracted_item_to_be_received import ( + execute, +) from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry -from erpnext.buying.report.subcontracted_item_to_be_received.subcontracted_item_to_be_received import execute -import frappe, unittest -from pprint import pprint + class TestSubcontractedItemToBeReceived(unittest.TestCase): diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py index 96cacb6f1b..a8fad967d4 100644 --- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py +++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): if filters.from_date >= filters.to_date: frappe.msgprint(_("To Date must be greater than From Date")) diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py index 2448e17c50..dcdc5e36ab 100644 --- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py +++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py @@ -3,11 +3,19 @@ # Compiled at: 2019-05-06 10:24:35 # Decompiled by https://python-decompiler.com from __future__ import unicode_literals -from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order + +import json +import unittest + +import frappe + from erpnext.buying.doctype.purchase_order.purchase_order import make_rm_stock_entry +from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order +from erpnext.buying.report.subcontracted_raw_materials_to_be_transferred.subcontracted_raw_materials_to_be_transferred import ( + execute, +) from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry -from erpnext.buying.report.subcontracted_raw_materials_to_be_transferred.subcontracted_raw_materials_to_be_transferred import execute -import json, frappe, unittest + class TestSubcontractedItemToBeTransferred(unittest.TestCase): diff --git a/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py b/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py index a5a3105a84..62b83ede04 100644 --- a/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py +++ b/erpnext/buying/report/supplier_quotation_comparison/supplier_quotation_comparison.py @@ -2,12 +2,16 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import flt, cint -from frappe import _ + from collections import defaultdict + +import frappe +from frappe import _ +from frappe.utils import cint, flt + from erpnext.setup.utils import get_exchange_rate + def execute(filters=None): if not filters: return [], [] diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py index 17928634e7..81d995ce8d 100644 --- a/erpnext/buying/utils.py +++ b/erpnext/buying/utils.py @@ -2,13 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import flt, cstr, cint -from frappe import _ + import json -from erpnext.stock.doctype.item.item import get_last_purchase_details -from erpnext.stock.doctype.item.item import validate_end_of_life +import frappe +from frappe import _ +from frappe.utils import cint, cstr, flt + +from erpnext.stock.doctype.item.item import get_last_purchase_details, validate_end_of_life + def update_last_purchase_rate(doc, is_submit): """updates last_purchase_rate in item table for each item""" diff --git a/erpnext/commands/__init__.py b/erpnext/commands/__init__.py index 2276c738fb..f3bf11ad65 100644 --- a/erpnext/commands/__init__.py +++ b/erpnext/commands/__init__.py @@ -1,10 +1,12 @@ # Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt -from __future__ import unicode_literals, absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals + import click import frappe -from frappe.commands import pass_context, get_site +from frappe.commands import get_site, pass_context + def call_command(cmd, context): return click.Context(cmd, obj=context).forward(cmd) diff --git a/erpnext/communication/doctype/communication_medium/communication_medium.py b/erpnext/communication/doctype/communication_medium/communication_medium.py index f233da07d5..b15c3bed71 100644 --- a/erpnext/communication/doctype/communication_medium/communication_medium.py +++ b/erpnext/communication/doctype/communication_medium/communication_medium.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class CommunicationMedium(Document): pass diff --git a/erpnext/communication/doctype/communication_medium_timeslot/communication_medium_timeslot.py b/erpnext/communication/doctype/communication_medium_timeslot/communication_medium_timeslot.py index d68d2d67a7..5189b09dc3 100644 --- a/erpnext/communication/doctype/communication_medium_timeslot/communication_medium_timeslot.py +++ b/erpnext/communication/doctype/communication_medium_timeslot/communication_medium_timeslot.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class CommunicationMediumTimeslot(Document): pass diff --git a/erpnext/config/education.py b/erpnext/config/education.py index 1c8ab10f53..ecd771f608 100644 --- a/erpnext/config/education.py +++ b/erpnext/config/education.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return [ { diff --git a/erpnext/config/projects.py b/erpnext/config/projects.py index ab4db96477..d4d4a72a5d 100644 --- a/erpnext/config/projects.py +++ b/erpnext/config/projects.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return [ { diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f4af8932b6..b90db054b5 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2,27 +2,60 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + import json + +import frappe from frappe import _, throw -from frappe.utils import (today, flt, cint, fmt_money, formatdate, - getdate, add_days, add_months, get_last_day, nowdate, get_link_to_form) -from frappe.model.workflow import get_workflow_name, is_transition_condition_satisfied, WorkflowPermissionError -from erpnext.stock.get_item_details import get_conversion_factor, get_item_details -from erpnext.setup.utils import get_exchange_rate -from erpnext.accounts.utils import get_fiscal_years, validate_fiscal_year, get_account_currency -from erpnext.utilities.transaction_base import TransactionBase -from erpnext.buying.utils import update_last_purchase_rate -from erpnext.controllers.sales_and_purchase_return import validate_return -from erpnext.accounts.party import get_party_account_currency, validate_party_frozen_disabled, get_party_account -from erpnext.accounts.doctype.pricing_rule.utils import (apply_pricing_rule_on_transaction, - apply_pricing_rule_for_free_items, get_applied_pricing_rules) -from erpnext.exceptions import InvalidCurrency +from frappe.model.workflow import get_workflow_name, is_transition_condition_satisfied +from frappe.utils import ( + add_days, + add_months, + cint, + flt, + fmt_money, + formatdate, + get_last_day, + get_link_to_form, + getdate, + nowdate, + today, +) from six import text_type -from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions -from erpnext.stock.get_item_details import get_item_warehouse, _get_item_tax_template, get_item_tax_map + +import erpnext +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) +from erpnext.accounts.doctype.pricing_rule.utils import ( + apply_pricing_rule_for_free_items, + apply_pricing_rule_on_transaction, + get_applied_pricing_rules, +) +from erpnext.accounts.party import ( + get_party_account, + get_party_account_currency, + validate_party_frozen_disabled, +) +from erpnext.accounts.utils import get_account_currency, get_fiscal_years, validate_fiscal_year +from erpnext.buying.utils import update_last_purchase_rate +from erpnext.controllers.print_settings import ( + set_print_templates_for_item_table, + set_print_templates_for_taxes, +) +from erpnext.controllers.sales_and_purchase_return import validate_return +from erpnext.exceptions import InvalidCurrency +from erpnext.setup.utils import get_exchange_rate from erpnext.stock.doctype.packed_item.packed_item import make_packing_list -from erpnext.controllers.print_settings import set_print_templates_for_item_table, set_print_templates_for_taxes +from erpnext.stock.get_item_details import ( + _get_item_tax_template, + get_conversion_factor, + get_item_details, + get_item_tax_map, + get_item_warehouse, +) +from erpnext.utilities.transaction_base import TransactionBase + class AccountMissingError(frappe.ValidationError): pass @@ -1206,7 +1239,7 @@ class AccountsController(TransactionBase): d.base_payment_amount = flt(base_grand_total * flt(d.invoice_portion / 100), d.precision('base_payment_amount')) d.outstanding = d.payment_amount elif not d.invoice_portion: - d.base_payment_amount = flt(base_grand_total * self.get("conversion_rate"), d.precision('base_payment_amount')) + d.base_payment_amount = flt(d.payment_amount * self.get("conversion_rate"), d.precision('base_payment_amount')) def get_order_details(self): @@ -1587,7 +1620,7 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field, def get_advance_payment_entries(party_type, party, party_account, order_doctype, - order_list=None, include_unallocated=True, against_all_orders=False, limit=None): + order_list=None, include_unallocated=True, against_all_orders=False, limit=None, condition=None): party_account_field = "paid_from" if party_type == "Customer" else "paid_to" currency_field = "paid_from_account_currency" if party_type == "Customer" else "paid_to_account_currency" payment_type = "Receive" if party_type == "Customer" else "Pay" @@ -1622,14 +1655,14 @@ def get_advance_payment_entries(party_type, party, party_account, order_doctype, if include_unallocated: unallocated_payment_entries = frappe.db.sql(""" - select "Payment Entry" as reference_type, name as reference_name, - remarks, unallocated_amount as amount, {2} as exchange_rate + select "Payment Entry" as reference_type, name as reference_name, posting_date, + remarks, unallocated_amount as amount, {2} as exchange_rate, {3} as currency from `tabPayment Entry` where {0} = %s and party_type = %s and party = %s and payment_type = %s - and docstatus = 1 and unallocated_amount > 0 + and docstatus = 1 and unallocated_amount > 0 {condition} order by posting_date {1} - """.format(party_account_field, limit_cond, exchange_rate_field), + """.format(party_account_field, limit_cond, exchange_rate_field, currency_field, condition=condition or ""), (party_account, party_type, party, payment_type), as_dict=1) return list(payment_entries_against_order) + list(unallocated_payment_entries) @@ -1811,7 +1844,12 @@ def validate_child_on_delete(row, parent): def update_bin_on_delete(row, doctype): """Update bin for deleted item (row).""" - from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty, get_ordered_qty, get_indented_qty + from erpnext.stock.stock_balance import ( + get_indented_qty, + get_ordered_qty, + get_reserved_qty, + update_bin_qty, + ) qty_dict = {} if doctype == "Sales Order": diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 974ade3584..e0b3ad801e 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -2,24 +2,21 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe import _, msgprint -from frappe.utils import flt,cint, cstr, getdate -from six import iteritems -from collections import OrderedDict -from erpnext.accounts.party import get_party_details -from erpnext.stock.get_item_details import get_conversion_factor -from erpnext.buying.utils import validate_for_items, update_last_purchase_rate -from erpnext.stock.stock_ledger import get_valuation_rate -from erpnext.stock.doctype.serial_no.serial_no import get_auto_serial_nos, auto_make_serial_nos, get_serial_nos from frappe.contacts.doctype.address.address import get_address_display +from frappe.utils import cint, cstr, flt, getdate from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget +from erpnext.accounts.party import get_party_details +from erpnext.buying.utils import update_last_purchase_rate, validate_for_items from erpnext.controllers.sales_and_purchase_return import get_rate_for_return -from erpnext.stock.utils import get_incoming_rate - from erpnext.controllers.stock_controller import StockController from erpnext.controllers.subcontracting import Subcontracting +from erpnext.stock.get_item_details import get_conversion_factor +from erpnext.stock.utils import get_incoming_rate + class BuyingController(StockController, Subcontracting): diff --git a/erpnext/controllers/employee_boarding_controller.py b/erpnext/controllers/employee_boarding_controller.py index f43c80416f..b8dc92efde 100644 --- a/erpnext/controllers/employee_boarding_controller.py +++ b/erpnext/controllers/employee_boarding_controller.py @@ -5,9 +5,11 @@ import frappe from frappe import _ from frappe.desk.form import assign_to from frappe.model.document import Document -from frappe.utils import flt, unique, add_days -from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday +from frappe.utils import add_days, flt, unique + from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee +from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday + class EmployeeBoardingController(Document): ''' diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index 8c361a2e56..1b56ae9d4d 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -2,13 +2,16 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + +import copy +import json + import frappe from frappe import _ from frappe.utils import cstr, flt -import json, copy - from six import string_types + class ItemVariantExistsError(frappe.ValidationError): pass class InvalidItemAttributeValueError(frappe.ValidationError): pass class ItemTemplateCannotHaveStock(frappe.ValidationError): pass diff --git a/erpnext/controllers/print_settings.py b/erpnext/controllers/print_settings.py index e08c400068..f6e061bcdc 100644 --- a/erpnext/controllers/print_settings.py +++ b/erpnext/controllers/print_settings.py @@ -2,8 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import cint + def set_print_templates_for_item_table(doc, settings): doc.print_templates = { diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 4b4c8befa5..aafaf5b9e0 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -2,14 +2,17 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -import erpnext + import json -from frappe.desk.reportview import get_match_cond, get_filters_cond -from frappe.utils import nowdate, getdate from collections import defaultdict + +import frappe +from frappe.desk.reportview import get_filters_cond, get_match_cond +from frappe.utils import nowdate, unique + +import erpnext from erpnext.stock.get_item_details import _get_item_tax_template -from frappe.utils import unique + # searches for active employees @frappe.whitelist() @@ -517,7 +520,9 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters): @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_filtered_dimensions(doctype, txt, searchfield, start, page_len, filters): - from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_filter import get_dimension_filter_map + from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_filter import ( + get_dimension_filter_map, + ) dimension_filters = get_dimension_filter_map() dimension_filters = dimension_filters.get((filters.get('dimension'),filters.get('account'))) query_filters = [] @@ -692,7 +697,9 @@ def get_healthcare_service_units(doctype, txt, searchfield, start, page_len, fil company = frappe.db.escape(filters.get('company')), txt = frappe.db.escape('%{0}%'.format(txt))) if filters and filters.get('inpatient_record'): - from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import get_current_healthcare_service_unit + from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import ( + get_current_healthcare_service_unit, + ) service_unit = get_current_healthcare_service_unit(filters.get('inpatient_record')) # if the patient is admitted, then appointments should be allowed against the admission service unit, diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 01486fcd65..5f2fbeb0c9 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -2,11 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe from frappe import _ from frappe.model.meta import get_field_precision +from frappe.utils import flt, format_datetime, get_datetime + +import erpnext from erpnext.stock.utils import get_incoming_rate -from frappe.utils import flt, get_datetime, format_datetime + class StockOverReturnError(frappe.ValidationError): pass @@ -63,7 +67,7 @@ def validate_returned_items(doc): if doc.doctype in ("Delivery Note", "Sales Invoice"): for d in frappe.db.sql("""select item_code, qty, serial_no, batch_no from `tabPacked Item` - where parent = %s""".format(doc.doctype), doc.return_against, as_dict=1): + where parent = %s""", doc.return_against, as_dict=1): valid_items = get_ref_item_dict(valid_items, d) already_returned_items = get_already_returned_items(doc) @@ -235,6 +239,7 @@ def get_returned_qty_map_for_row(row_name, doctype): def make_return_doc(doctype, source_name, target_doc=None): from frappe.model.mapper import get_mapped_doc + from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos company = frappe.db.get_value("Delivery Note", source_name, "company") default_warehouse_for_sales_return = frappe.db.get_value("Company", company, "default_warehouse_for_sales_return") diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 844c40c8a6..0158a1120f 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -2,18 +2,19 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe -from frappe.utils import cint, flt, cstr, get_link_to_form, nowtime -from frappe import _, bold, throw -from erpnext.stock.get_item_details import get_bin_details -from erpnext.stock.utils import get_incoming_rate -from erpnext.stock.get_item_details import get_conversion_factor -from erpnext.stock.doctype.item.item import set_item_default -from frappe.contacts.doctype.address.address import get_address_display -from erpnext.controllers.accounts_controller import get_taxes_and_charges -from erpnext.controllers.stock_controller import StockController +import frappe +from frappe import _, bold, throw +from frappe.contacts.doctype.address.address import get_address_display +from frappe.utils import cint, cstr, flt, get_link_to_form, nowtime + +from erpnext.controllers.accounts_controller import get_taxes_and_charges from erpnext.controllers.sales_and_purchase_return import get_rate_for_return +from erpnext.controllers.stock_controller import StockController +from erpnext.stock.doctype.item.item import set_item_default +from erpnext.stock.get_item_details import get_bin_details, get_conversion_factor +from erpnext.stock.utils import get_incoming_rate + class SellingController(StockController): def get_feed(self): diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 7b24e50b14..8738204ce0 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -2,10 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import flt, comma_or, nowdate, getdate, now from frappe import _ from frappe.model.document import Document +from frappe.utils import comma_or, flt, getdate, now, nowdate + class OverAllowanceError(frappe.ValidationError): pass diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 17707ecae7..78a6e52e4d 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -5,12 +5,15 @@ import json from collections import defaultdict import frappe -import frappe.defaults from frappe import _ from frappe.utils import cint, cstr, flt, get_link_to_form, getdate import erpnext -from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries, process_gl_map +from erpnext.accounts.general_ledger import ( + make_gl_entries, + make_reverse_gl_entries, + process_gl_map, +) from erpnext.accounts.utils import get_fiscal_year from erpnext.controllers.accounts_controller import AccountsController from erpnext.stock import get_warehouse_account_map diff --git a/erpnext/controllers/subcontracting.py b/erpnext/controllers/subcontracting.py index 969829f965..3addb91aaa 100644 --- a/erpnext/controllers/subcontracting.py +++ b/erpnext/controllers/subcontracting.py @@ -1,10 +1,13 @@ -import frappe import copy -from frappe import _ -from frappe.utils import flt, cint, get_link_to_form from collections import defaultdict + +import frappe +from frappe import _ +from frappe.utils import cint, flt, get_link_to_form + from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos + class Subcontracting(): def set_materials_for_subcontracted_items(self, raw_material_table): if self.doctype == 'Purchase Invoice' and not self.update_stock: diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 7c6d3552f1..70cc8a58bf 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -2,15 +2,23 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import json -import frappe, erpnext + +import frappe from frappe import _, scrub from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction -from erpnext.controllers.accounts_controller import validate_conversion_rate, \ - validate_taxes_and_charges, validate_inclusive_tax -from erpnext.stock.get_item_details import _get_item_tax_template -from erpnext.accounts.doctype.pricing_rule.utils import get_applied_pricing_rules + +import erpnext from erpnext.accounts.doctype.journal_entry.journal_entry import get_exchange_rate +from erpnext.accounts.doctype.pricing_rule.utils import get_applied_pricing_rules +from erpnext.controllers.accounts_controller import ( + validate_conversion_rate, + validate_inclusive_tax, + validate_taxes_and_charges, +) +from erpnext.stock.get_item_details import _get_item_tax_template + class calculate_taxes_and_totals(object): def __init__(self, doc): @@ -686,7 +694,7 @@ class calculate_taxes_and_totals(object): 'mode_of_payment': default_mode_of_payment.mode_of_payment, 'amount': total_amount_to_pay, 'default': 1 - }) + }) def get_itemised_tax_breakup_html(doc): if not doc.taxes: diff --git a/erpnext/controllers/tests/test_item_variant.py b/erpnext/controllers/tests/test_item_variant.py index 813f0a0075..b3633e6ff0 100644 --- a/erpnext/controllers/tests/test_item_variant.py +++ b/erpnext/controllers/tests/test_item_variant.py @@ -1,15 +1,18 @@ from __future__ import unicode_literals -import frappe import json import unittest -from erpnext.stock.doctype.item.test_item import set_item_variant_settings -from erpnext.controllers.item_variant import copy_attributes_to_variant, make_variant_item_code -from erpnext.stock.doctype.quality_inspection.test_quality_inspection import create_quality_inspection_parameter - +import frappe from six import string_types +from erpnext.controllers.item_variant import copy_attributes_to_variant, make_variant_item_code +from erpnext.stock.doctype.item.test_item import set_item_variant_settings +from erpnext.stock.doctype.quality_inspection.test_quality_inspection import ( + create_quality_inspection_parameter, +) + + class TestItemVariant(unittest.TestCase): def test_tables_in_template_copied_to_variant(self): fields = [{'field_name': 'quality_inspection_template'}] diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py index 7a4b2d3614..2d1ae43f07 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -1,12 +1,14 @@ from __future__ import unicode_literals -import unittest -import frappe -import random, json +import json +import unittest + +import frappe import frappe.utils -from frappe.utils import nowdate, add_months from frappe.model import mapper from frappe.test_runner import make_test_records +from frappe.utils import add_months, nowdate + class TestMapper(unittest.TestCase): def test_map_docs(self): diff --git a/erpnext/controllers/tests/test_qty_based_taxes.py b/erpnext/controllers/tests/test_qty_based_taxes.py index aaeac5d939..41673d1e6f 100644 --- a/erpnext/controllers/tests/test_qty_based_taxes.py +++ b/erpnext/controllers/tests/test_qty_based_taxes.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals, print_function +from __future__ import print_function, unicode_literals + import unittest -import frappe from uuid import uuid4 as _uuid4 +import frappe + + def uuid4(): return str(_uuid4()) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 9b4b0eb917..05d900d0f0 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import getdate from frappe import _ +from frappe.utils import getdate + def get_columns(filters, trans): validate_filters(filters) diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 7c072e4fad..ff2ed45bd2 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -2,12 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import json + import frappe from frappe import _ from frappe.utils import flt, has_common from frappe.utils.user import is_website_user + def get_list_context(context=None): return { "global_number_format": frappe.db.get_default("number_format") or "#,###.##", diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py index f7c6b6c799..f2055349bd 100644 --- a/erpnext/crm/doctype/appointment/appointment.py +++ b/erpnext/crm/doctype/appointment/appointment.py @@ -4,15 +4,13 @@ from __future__ import unicode_literals -import urllib from collections import Counter -from datetime import timedelta import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import get_url, getdate -from frappe.utils.verified_command import verify_request, get_signed_params +from frappe.utils.verified_command import get_signed_params class Appointment(Document): diff --git a/erpnext/crm/doctype/appointment/test_appointment.py b/erpnext/crm/doctype/appointment/test_appointment.py index c7563e9d15..59138a9ea9 100644 --- a/erpnext/crm/doctype/appointment/test_appointment.py +++ b/erpnext/crm/doctype/appointment/test_appointment.py @@ -3,9 +3,10 @@ # See license.txt from __future__ import unicode_literals -import frappe -import unittest import datetime +import unittest + +import frappe def create_test_lead(): diff --git a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py index 27f14b1dbd..7e1da67731 100644 --- a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py +++ b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import datetime + import frappe from frappe import _ -import datetime from frappe.model.document import Document @@ -28,10 +30,10 @@ class AppointmentBookingSettings(Document): to_time = datetime.datetime.strptime( self.min_date+record.to_time, self.format_string) timedelta = to_time-from_time - self.validate_from_and_to_time(from_time, to_time) + self.validate_from_and_to_time(from_time, to_time, record) self.duration_is_divisible(from_time, to_time) - def validate_from_and_to_time(self, from_time, to_time): + def validate_from_and_to_time(self, from_time, to_time, record): if from_time > to_time: err_msg = _('From Time cannot be later than To Time for {0}').format(record.day_of_week) frappe.throw(_(err_msg)) diff --git a/erpnext/crm/doctype/appointment_booking_settings/test_appointment_booking_settings.py b/erpnext/crm/doctype/appointment_booking_settings/test_appointment_booking_settings.py index 3dc3c39971..5c5432c524 100644 --- a/erpnext/crm/doctype/appointment_booking_settings/test_appointment_booking_settings.py +++ b/erpnext/crm/doctype/appointment_booking_settings/test_appointment_booking_settings.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestAppointmentBookingSettings(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/appointment_booking_slots/appointment_booking_slots.py b/erpnext/crm/doctype/appointment_booking_slots/appointment_booking_slots.py index 3cadbc9559..4741c8af5a 100644 --- a/erpnext/crm/doctype/appointment_booking_slots/appointment_booking_slots.py +++ b/erpnext/crm/doctype/appointment_booking_slots/appointment_booking_slots.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AppointmentBookingSlots(Document): pass diff --git a/erpnext/crm/doctype/availability_of_slots/availability_of_slots.py b/erpnext/crm/doctype/availability_of_slots/availability_of_slots.py index 8258471eed..e33d87b193 100644 --- a/erpnext/crm/doctype/availability_of_slots/availability_of_slots.py +++ b/erpnext/crm/doctype/availability_of_slots/availability_of_slots.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AvailabilityOfSlots(Document): pass diff --git a/erpnext/crm/doctype/campaign/campaign.py b/erpnext/crm/doctype/campaign/campaign.py index e32799f34e..8b62800409 100644 --- a/erpnext/crm/doctype/campaign/campaign.py +++ b/erpnext/crm/doctype/campaign/campaign.py @@ -5,6 +5,7 @@ import frappe from frappe.model.document import Document from frappe.model.naming import set_name_by_naming_series + class Campaign(Document): def autoname(self): if frappe.defaults.get_global_default('campaign_naming_by') != 'Naming Series': diff --git a/erpnext/crm/doctype/campaign/test_campaign.py b/erpnext/crm/doctype/campaign/test_campaign.py index 7124b8c7d6..2e25eb6a79 100644 --- a/erpnext/crm/doctype/campaign/test_campaign.py +++ b/erpnext/crm/doctype/campaign/test_campaign.py @@ -4,5 +4,6 @@ # import frappe import unittest + class TestCampaign(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/campaign_email_schedule/campaign_email_schedule.py b/erpnext/crm/doctype/campaign_email_schedule/campaign_email_schedule.py index 8445b8a397..f053e6e7e4 100644 --- a/erpnext/crm/doctype/campaign_email_schedule/campaign_email_schedule.py +++ b/erpnext/crm/doctype/campaign_email_schedule/campaign_email_schedule.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class CampaignEmailSchedule(Document): pass diff --git a/erpnext/crm/doctype/contract/contract.py b/erpnext/crm/doctype/contract/contract.py index c39397bf4b..9654613f04 100644 --- a/erpnext/crm/doctype/contract/contract.py +++ b/erpnext/crm/doctype/contract/contract.py @@ -7,7 +7,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import getdate, now_datetime, nowdate +from frappe.utils import getdate, nowdate class Contract(Document): diff --git a/erpnext/crm/doctype/contract/test_contract.py b/erpnext/crm/doctype/contract/test_contract.py index d5f4e71bff..8771636817 100644 --- a/erpnext/crm/doctype/contract/test_contract.py +++ b/erpnext/crm/doctype/contract/test_contract.py @@ -8,6 +8,7 @@ import unittest import frappe from frappe.utils import add_days, nowdate + class TestContract(unittest.TestCase): def setUp(self): diff --git a/erpnext/crm/doctype/contract_fulfilment_checklist/contract_fulfilment_checklist.py b/erpnext/crm/doctype/contract_fulfilment_checklist/contract_fulfilment_checklist.py index 6039035727..ae56f93fc8 100644 --- a/erpnext/crm/doctype/contract_fulfilment_checklist/contract_fulfilment_checklist.py +++ b/erpnext/crm/doctype/contract_fulfilment_checklist/contract_fulfilment_checklist.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ContractFulfilmentChecklist(Document): pass diff --git a/erpnext/crm/doctype/contract_fulfilment_checklist/test_contract_fulfilment_checklist.py b/erpnext/crm/doctype/contract_fulfilment_checklist/test_contract_fulfilment_checklist.py index c78796be6b..82e7ad35c9 100644 --- a/erpnext/crm/doctype/contract_fulfilment_checklist/test_contract_fulfilment_checklist.py +++ b/erpnext/crm/doctype/contract_fulfilment_checklist/test_contract_fulfilment_checklist.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestContractFulfilmentChecklist(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/contract_template/contract_template.py b/erpnext/crm/doctype/contract_template/contract_template.py index 9281220eef..fc1845c372 100644 --- a/erpnext/crm/doctype/contract_template/contract_template.py +++ b/erpnext/crm/doctype/contract_template/contract_template.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import json + import frappe from frappe.model.document import Document from frappe.utils.jinja import validate_template from six import string_types -import json + class ContractTemplate(Document): def validate(self): diff --git a/erpnext/crm/doctype/contract_template/test_contract_template.py b/erpnext/crm/doctype/contract_template/test_contract_template.py index b2b0db66a5..50655054c8 100644 --- a/erpnext/crm/doctype/contract_template/test_contract_template.py +++ b/erpnext/crm/doctype/contract_template/test_contract_template.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestContractTemplate(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/contract_template_fulfilment_terms/contract_template_fulfilment_terms.py b/erpnext/crm/doctype/contract_template_fulfilment_terms/contract_template_fulfilment_terms.py index 767b1901ab..28f844d097 100644 --- a/erpnext/crm/doctype/contract_template_fulfilment_terms/contract_template_fulfilment_terms.py +++ b/erpnext/crm/doctype/contract_template_fulfilment_terms/contract_template_fulfilment_terms.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ContractTemplateFulfilmentTerms(Document): pass diff --git a/erpnext/crm/doctype/email_campaign/email_campaign.py b/erpnext/crm/doctype/email_campaign/email_campaign.py index 71c93e8d39..4b74f25ead 100644 --- a/erpnext/crm/doctype/email_campaign/email_campaign.py +++ b/erpnext/crm/doctype/email_campaign/email_campaign.py @@ -3,11 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import getdate, add_days, today, nowdate, cstr -from frappe.model.document import Document from frappe.core.doctype.communication.email import make +from frappe.model.document import Document +from frappe.utils import add_days, getdate, today + class EmailCampaign(Document): def validate(self): diff --git a/erpnext/crm/doctype/email_campaign/test_email_campaign.py b/erpnext/crm/doctype/email_campaign/test_email_campaign.py index f5eab48333..f68b8c6d29 100644 --- a/erpnext/crm/doctype/email_campaign/test_email_campaign.py +++ b/erpnext/crm/doctype/email_campaign/test_email_campaign.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestEmailCampaign(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index aa6c07b1be..5cf110ff27 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -4,13 +4,23 @@ from __future__ import unicode_literals import frappe -from erpnext.accounts.party import set_taxes -from erpnext.controllers.selling_controller import SellingController from frappe import _ from frappe.contacts.address_and_contact import load_address_and_contact from frappe.email.inbox import link_communication_to_document from frappe.model.mapper import get_mapped_doc -from frappe.utils import cint, comma_and, cstr, getdate, has_gravatar, nowdate, validate_email_address +from frappe.utils import ( + cint, + comma_and, + cstr, + getdate, + has_gravatar, + nowdate, + validate_email_address, +) + +from erpnext.accounts.party import set_taxes +from erpnext.controllers.selling_controller import SellingController + class Lead(SellingController): def get_feed(self): @@ -174,6 +184,7 @@ class Lead(SellingController): "salutation": self.salutation, "gender": self.gender, "designation": self.designation, + "company_name": self.company_name, }) if self.email_id: @@ -371,4 +382,3 @@ def add_lead_to_prospect(lead, prospect): prospect.save(ignore_permissions=True) frappe.msgprint(_('Lead {0} has been added to prospect {1}.').format(frappe.bold(lead), frappe.bold(prospect.name)), title=_('Lead Added'), indicator='green') - \ No newline at end of file diff --git a/erpnext/crm/doctype/lead/lead_dashboard.py b/erpnext/crm/doctype/lead/lead_dashboard.py index 50e88a5188..5edf2b6238 100644 --- a/erpnext/crm/doctype/lead/lead_dashboard.py +++ b/erpnext/crm/doctype/lead/lead_dashboard.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from frappe import _ + def get_data(): return { diff --git a/erpnext/crm/doctype/lead/test_lead.py b/erpnext/crm/doctype/lead/test_lead.py index d7bc46165f..833c43e059 100644 --- a/erpnext/crm/doctype/lead/test_lead.py +++ b/erpnext/crm/doctype/lead/test_lead.py @@ -3,9 +3,10 @@ from __future__ import unicode_literals +import unittest + import frappe from frappe.utils import random_string -import unittest test_records = frappe.get_test_records('Lead') diff --git a/erpnext/crm/doctype/lead_source/lead_source.py b/erpnext/crm/doctype/lead_source/lead_source.py index 5c64fb8b4a..8de1c4301b 100644 --- a/erpnext/crm/doctype/lead_source/lead_source.py +++ b/erpnext/crm/doctype/lead_source/lead_source.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class LeadSource(Document): pass diff --git a/erpnext/crm/doctype/lead_source/test_lead_source.py b/erpnext/crm/doctype/lead_source/test_lead_source.py index b5bc6490cf..ecf61171e9 100644 --- a/erpnext/crm/doctype/lead_source/test_lead_source.py +++ b/erpnext/crm/doctype/lead_source/test_lead_source.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestLeadSource(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py index 9b88d78c1f..03c9d9c762 100644 --- a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py +++ b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py @@ -3,14 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe import requests from frappe import _ -from frappe.utils import get_url_to_form from frappe.model.document import Document +from frappe.utils import get_url_to_form from frappe.utils.file_manager import get_file_path from six.moves.urllib.parse import urlencode + class LinkedInSettings(Document): @frappe.whitelist() def get_authorization_url(self): @@ -146,7 +148,7 @@ class LinkedInSettings(Document): except Exception as e: self.api_error(response) - + return response def get_headers(self): @@ -168,7 +170,7 @@ class LinkedInSettings(Document): raise except Exception: self.api_error(response) - + def get_post(self, post_id): url = "https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn:li:organization:{0}&shares[0]=urn:li:share:{1}".format(self.company_id, post_id) @@ -176,7 +178,7 @@ class LinkedInSettings(Document): response = requests.get(url=url, headers=self.get_headers()) if response.status_code !=200: raise - + except Exception: self.api_error(response) diff --git a/erpnext/crm/doctype/linkedin_settings/test_linkedin_settings.py b/erpnext/crm/doctype/linkedin_settings/test_linkedin_settings.py index 9c3ef3f32f..1d86f0c66f 100644 --- a/erpnext/crm/doctype/linkedin_settings/test_linkedin_settings.py +++ b/erpnext/crm/doctype/linkedin_settings/test_linkedin_settings.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestLinkedInSettings(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/lost_reason_detail/lost_reason_detail.py b/erpnext/crm/doctype/lost_reason_detail/lost_reason_detail.py index 3baa011e64..88abd423cf 100644 --- a/erpnext/crm/doctype/lost_reason_detail/lost_reason_detail.py +++ b/erpnext/crm/doctype/lost_reason_detail/lost_reason_detail.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class LostReasonDetail(Document): pass diff --git a/erpnext/crm/doctype/market_segment/market_segment.py b/erpnext/crm/doctype/market_segment/market_segment.py index 830ea69343..92adf56876 100644 --- a/erpnext/crm/doctype/market_segment/market_segment.py +++ b/erpnext/crm/doctype/market_segment/market_segment.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class MarketSegment(Document): pass diff --git a/erpnext/crm/doctype/market_segment/test_market_segment.py b/erpnext/crm/doctype/market_segment/test_market_segment.py index 2f9ed34f7c..b95cc4cde0 100644 --- a/erpnext/crm/doctype/market_segment/test_market_segment.py +++ b/erpnext/crm/doctype/market_segment/test_market_segment.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestMarketSegment(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index a74a94afd6..0b3f50897a 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -2,14 +2,19 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json -from frappe.utils import cstr, cint, get_fullname -from frappe import msgprint, _ + +import json + +import frappe +from frappe import _ +from frappe.email.inbox import link_communication_to_document from frappe.model.mapper import get_mapped_doc +from frappe.utils import cint, cstr, get_fullname + +from erpnext.accounts.party import get_party_account_currency from erpnext.setup.utils import get_exchange_rate from erpnext.utilities.transaction_base import TransactionBase -from erpnext.accounts.party import get_party_account_currency -from frappe.email.inbox import link_communication_to_document + class Opportunity(TransactionBase): def after_insert(self): diff --git a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py index b8c53f077a..693a86cfcd 100644 --- a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py +++ b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from frappe import _ + def get_data(): return { diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index 52aa0b036a..347bf6366d 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -2,11 +2,13 @@ # See license.txt from __future__ import unicode_literals +import unittest + import frappe -from frappe.utils import today, random_string +from frappe.utils import random_string, today + from erpnext.crm.doctype.lead.lead import make_customer from erpnext.crm.doctype.opportunity.opportunity import make_quotation -import unittest test_records = frappe.get_test_records('Opportunity') diff --git a/erpnext/crm/doctype/opportunity_item/opportunity_item.py b/erpnext/crm/doctype/opportunity_item/opportunity_item.py index 7a5ed63f88..225cfe9d32 100644 --- a/erpnext/crm/doctype/opportunity_item/opportunity_item.py +++ b/erpnext/crm/doctype/opportunity_item/opportunity_item.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class OpportunityItem(Document): pass diff --git a/erpnext/crm/doctype/opportunity_lost_reason/opportunity_lost_reason.py b/erpnext/crm/doctype/opportunity_lost_reason/opportunity_lost_reason.py index 48b63b091e..b25f02afff 100644 --- a/erpnext/crm/doctype/opportunity_lost_reason/opportunity_lost_reason.py +++ b/erpnext/crm/doctype/opportunity_lost_reason/opportunity_lost_reason.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class OpportunityLostReason(Document): pass diff --git a/erpnext/crm/doctype/opportunity_lost_reason_detail/opportunity_lost_reason_detail.py b/erpnext/crm/doctype/opportunity_lost_reason_detail/opportunity_lost_reason_detail.py index 8723f1d045..4bb5c54b1d 100644 --- a/erpnext/crm/doctype/opportunity_lost_reason_detail/opportunity_lost_reason_detail.py +++ b/erpnext/crm/doctype/opportunity_lost_reason_detail/opportunity_lost_reason_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class OpportunityLostReasonDetail(Document): pass diff --git a/erpnext/crm/doctype/opportunity_type/opportunity_type.py b/erpnext/crm/doctype/opportunity_type/opportunity_type.py index 48abac3fe2..5b64e98096 100644 --- a/erpnext/crm/doctype/opportunity_type/opportunity_type.py +++ b/erpnext/crm/doctype/opportunity_type/opportunity_type.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class OpportunityType(Document): pass diff --git a/erpnext/crm/doctype/opportunity_type/test_opportunity_type.py b/erpnext/crm/doctype/opportunity_type/test_opportunity_type.py index 6410bbc340..f86a70e8cf 100644 --- a/erpnext/crm/doctype/opportunity_type/test_opportunity_type.py +++ b/erpnext/crm/doctype/opportunity_type/test_opportunity_type.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestOpportunityType(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/prospect/prospect.py b/erpnext/crm/doctype/prospect/prospect.py index 5f5815de5e..367aa3d312 100644 --- a/erpnext/crm/doctype/prospect/prospect.py +++ b/erpnext/crm/doctype/prospect/prospect.py @@ -2,9 +2,10 @@ # For license information, please see license.txt import frappe +from frappe.contacts.address_and_contact import load_address_and_contact from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc -from frappe.contacts.address_and_contact import load_address_and_contact + class Prospect(Document): def onload(self): @@ -15,7 +16,7 @@ class Prospect(Document): def on_update(self): self.link_with_lead_contact_and_address() - + def on_trash(self): self.unlink_dynamic_links() diff --git a/erpnext/crm/doctype/prospect/test_prospect.py b/erpnext/crm/doctype/prospect/test_prospect.py index 0fffad1939..fa44e20435 100644 --- a/erpnext/crm/doctype/prospect/test_prospect.py +++ b/erpnext/crm/doctype/prospect/test_prospect.py @@ -1,11 +1,13 @@ # Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt -import frappe import unittest + +import frappe from frappe.utils import random_string -from erpnext.crm.doctype.lead.test_lead import make_lead + from erpnext.crm.doctype.lead.lead import add_lead_to_prospect +from erpnext.crm.doctype.lead.test_lead import make_lead class TestProspect(unittest.TestCase): diff --git a/erpnext/crm/doctype/prospect_lead/prospect_lead.py b/erpnext/crm/doctype/prospect_lead/prospect_lead.py index 2be5a5f39a..40edbe0524 100644 --- a/erpnext/crm/doctype/prospect_lead/prospect_lead.py +++ b/erpnext/crm/doctype/prospect_lead/prospect_lead.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class ProspectLead(Document): pass diff --git a/erpnext/crm/doctype/sales_stage/sales_stage.py b/erpnext/crm/doctype/sales_stage/sales_stage.py index a80f4cc089..e9e176f087 100644 --- a/erpnext/crm/doctype/sales_stage/sales_stage.py +++ b/erpnext/crm/doctype/sales_stage/sales_stage.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SalesStage(Document): pass diff --git a/erpnext/crm/doctype/sales_stage/test_sales_stage.py b/erpnext/crm/doctype/sales_stage/test_sales_stage.py index 80b65130e6..83d1f269fd 100644 --- a/erpnext/crm/doctype/sales_stage/test_sales_stage.py +++ b/erpnext/crm/doctype/sales_stage/test_sales_stage.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestSalesStage(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/social_media_post/social_media_post.js b/erpnext/crm/doctype/social_media_post/social_media_post.js index a8f5deea53..6874caac71 100644 --- a/erpnext/crm/doctype/social_media_post/social_media_post.js +++ b/erpnext/crm/doctype/social_media_post/social_media_post.js @@ -80,10 +80,10 @@ frappe.ui.form.on('Social Media Post', { refresh: function(frm) { frm.trigger('text'); - + if (frm.doc.docstatus === 1) { if (!['Posted', 'Deleted'].includes(frm.doc.post_status)) { - frm.trigger('add_post_btn'); + frm.trigger('add_post_btn'); } if (frm.doc.post_status !='Deleted') { frm.add_custom_button(('Delete Post'), function() { diff --git a/erpnext/crm/doctype/social_media_post/social_media_post.py b/erpnext/crm/doctype/social_media_post/social_media_post.py index 95320bff53..14d4521e1e 100644 --- a/erpnext/crm/doctype/social_media_post/social_media_post.py +++ b/erpnext/crm/doctype/social_media_post/social_media_post.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe.model.document import Document -from frappe import _ + import datetime +import frappe +from frappe import _ +from frappe.model.document import Document + + class SocialMediaPost(Document): def validate(self): if (not self.twitter and not self.linkedin): @@ -26,7 +29,7 @@ class SocialMediaPost(Document): if self.scheduled_time: self.post_status = "Scheduled" super(SocialMediaPost, self).submit() - + def on_cancel(self): self.db_set('post_status', 'Cancelled') @@ -35,11 +38,11 @@ class SocialMediaPost(Document): if self.twitter and self.twitter_post_id: twitter = frappe.get_doc("Twitter Settings") twitter.delete_tweet(self.twitter_post_id) - + if self.linkedin and self.linkedin_post_id: linkedin = frappe.get_doc("LinkedIn Settings") linkedin.delete_post(self.linkedin_post_id) - + self.db_set('post_status', 'Deleted') @frappe.whitelist() @@ -51,7 +54,7 @@ class SocialMediaPost(Document): if self.twitter and self.twitter_post_id: twitter = frappe.get_doc("Twitter Settings") response['twitter'] = twitter.get_tweet(self.twitter_post_id) - + return response @frappe.whitelist() @@ -67,7 +70,7 @@ class SocialMediaPost(Document): self.db_set("linkedin_post_id", linkedin_post.headers['X-RestLi-Id']) self.db_set("post_status", "Posted") - except: + except Exception: self.db_set("post_status", "Error") title = _("Error while POSTING {0}").format(self.name) frappe.log_error(message=frappe.get_traceback(), title=title) diff --git a/erpnext/crm/doctype/social_media_post/test_social_media_post.py b/erpnext/crm/doctype/social_media_post/test_social_media_post.py index ec81ee5871..c2d041898a 100644 --- a/erpnext/crm/doctype/social_media_post/test_social_media_post.py +++ b/erpnext/crm/doctype/social_media_post/test_social_media_post.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestSocialMediaPost(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/twitter_settings/test_twitter_settings.py b/erpnext/crm/doctype/twitter_settings/test_twitter_settings.py index 3f999c1af4..ff3163c559 100644 --- a/erpnext/crm/doctype/twitter_settings/test_twitter_settings.py +++ b/erpnext/crm/doctype/twitter_settings/test_twitter_settings.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestTwitterSettings(unittest.TestCase): pass diff --git a/erpnext/crm/doctype/twitter_settings/twitter_settings.py b/erpnext/crm/doctype/twitter_settings/twitter_settings.py index 47756560ec..0205cca2b9 100644 --- a/erpnext/crm/doctype/twitter_settings/twitter_settings.py +++ b/erpnext/crm/doctype/twitter_settings/twitter_settings.py @@ -3,13 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, os, tweepy, json + +import json + +import frappe +import tweepy from frappe import _ from frappe.model.document import Document +from frappe.utils import get_url_to_form from frappe.utils.file_manager import get_file_path -from frappe.utils import get_url_to_form, get_link_to_form from tweepy.error import TweepError + class TwitterSettings(Document): @frappe.whitelist() def get_authorize_url(self): @@ -53,10 +58,10 @@ class TwitterSettings(Document): frappe.throw(_('Invalid Consumer Key or Consumer Secret Key')) def get_api(self): - # authentication of consumer key and secret - auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret")) - # authentication of access token and secret - auth.set_access_token(self.access_token, self.access_token_secret) + # authentication of consumer key and secret + auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret")) + # authentication of access token and secret + auth.set_access_token(self.access_token, self.access_token_secret) return tweepy.API(auth) @@ -90,20 +95,20 @@ class TwitterSettings(Document): def delete_tweet(self, tweet_id): api = self.get_api() - try: + try: api.destroy_status(tweet_id) except TweepError as e: self.api_error(e) def get_tweet(self, tweet_id): api = self.get_api() - try: + try: response = api.get_status(tweet_id, trim_user=True, include_entities=True) except TweepError as e: self.api_error(e) - + return response._json - + def api_error(self, e): content = json.loads(e.response.content) content = content["errors"][0] diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py index f244daffea..0da0e0e71a 100644 --- a/erpnext/crm/doctype/utils.py +++ b/erpnext/crm/doctype/utils.py @@ -1,6 +1,6 @@ + import frappe -from frappe import _ -import json + @frappe.whitelist() def get_last_interaction(contact=None, lead=None): diff --git a/erpnext/crm/report/campaign_efficiency/campaign_efficiency.py b/erpnext/crm/report/campaign_efficiency/campaign_efficiency.py index 238884b519..87f516b8c7 100644 --- a/erpnext/crm/report/campaign_efficiency/campaign_efficiency.py +++ b/erpnext/crm/report/campaign_efficiency/campaign_efficiency.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import flt + def execute(filters=None): columns, data = [], [] columns=get_columns("Campaign Name") diff --git a/erpnext/crm/report/first_response_time_for_opportunity/first_response_time_for_opportunity.py b/erpnext/crm/report/first_response_time_for_opportunity/first_response_time_for_opportunity.py index 2ffbc3e62a..df57893ef4 100644 --- a/erpnext/crm/report/first_response_time_for_opportunity/first_response_time_for_opportunity.py +++ b/erpnext/crm/report/first_response_time_for_opportunity/first_response_time_for_opportunity.py @@ -2,8 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe + def execute(filters=None): columns = [ { diff --git a/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py b/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py index e66bc1ec8e..71efdb96e7 100644 --- a/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py +++ b/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _, msgprint from frappe.utils import date_diff, flt + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/crm/report/lead_details/lead_details.py b/erpnext/crm/report/lead_details/lead_details.py index 072a47611b..11e8276427 100644 --- a/erpnext/crm/report/lead_details/lead_details.py +++ b/erpnext/crm/report/lead_details/lead_details.py @@ -2,8 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe import _ + import frappe +from frappe import _ + def execute(filters=None): columns, data = get_columns(), get_data(filters) diff --git a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py index 8fe16a2f4c..5406eba6d8 100644 --- a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py +++ b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe import _ + from erpnext.crm.report.campaign_efficiency.campaign_efficiency import get_lead_data + def execute(filters=None): columns, data = [], [] columns=get_columns() diff --git a/erpnext/crm/report/lost_opportunity/lost_opportunity.py b/erpnext/crm/report/lost_opportunity/lost_opportunity.py index 858dcc4da8..b308ceb272 100644 --- a/erpnext/crm/report/lost_opportunity/lost_opportunity.py +++ b/erpnext/crm/report/lost_opportunity/lost_opportunity.py @@ -2,8 +2,10 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe import _ + import frappe +from frappe import _ + def execute(filters=None): columns, data = get_columns(), get_data(filters) diff --git a/erpnext/crm/report/prospects_engaged_but_not_converted/prospects_engaged_but_not_converted.py b/erpnext/crm/report/prospects_engaged_but_not_converted/prospects_engaged_but_not_converted.py index 425b7a8fdd..4a16f3d539 100644 --- a/erpnext/crm/report/prospects_engaged_but_not_converted/prospects_engaged_but_not_converted.py +++ b/erpnext/crm/report/prospects_engaged_but_not_converted/prospects_engaged_but_not_converted.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import add_days, now + def execute(filters=None): columns, data = [], [] set_defaut_value_for_filters(filters) diff --git a/erpnext/demo/demo.py b/erpnext/demo/demo.py index e89b6895a0..5be24206ca 100644 --- a/erpnext/demo/demo.py +++ b/erpnext/demo/demo.py @@ -1,11 +1,16 @@ from __future__ import unicode_literals -import frappe, sys -import erpnext +import sys + +import frappe import frappe.utils -from erpnext.demo.user import hr, sales, purchase, manufacturing, stock, accounts, projects, fixed_asset + +import erpnext +from erpnext.demo.setup import education, healthcare, manufacture, retail, setup_data +from erpnext.demo.user import accounts from erpnext.demo.user import education as edu -from erpnext.demo.setup import education, manufacture, setup_data, healthcare, retail +from erpnext.demo.user import fixed_asset, hr, manufacturing, projects, purchase, sales, stock + """ Make a demo @@ -88,7 +93,7 @@ def simulate(domain='Manufacturing', days=100): elif domain=='Education': edu.work() - except: + except Exception: frappe.db.set_global('demo_last_date', current_date) raise finally: diff --git a/erpnext/demo/setup/education.py b/erpnext/demo/setup/education.py index cf9451d5da..304bc3d2c3 100644 --- a/erpnext/demo/setup/education.py +++ b/erpnext/demo/setup/education.py @@ -2,11 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json -from frappe.utils.make_random import get_random -from datetime import datetime -from erpnext.demo.setup.setup_data import import_json +import json import random +from datetime import datetime + +import frappe +from frappe.utils.make_random import get_random + +from erpnext.demo.setup.setup_data import import_json + def setup_data(): frappe.flags.mute_emails = True diff --git a/erpnext/demo/setup/healthcare.py b/erpnext/demo/setup/healthcare.py index aa389e56b4..5d5707f647 100644 --- a/erpnext/demo/setup/healthcare.py +++ b/erpnext/demo/setup/healthcare.py @@ -2,13 +2,17 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json -from frappe.utils.make_random import get_random import datetime -from erpnext.demo.setup.setup_data import import_json +import json + +import frappe from frappe.utils import getdate +from frappe.utils.make_random import get_random + +from erpnext.demo.setup.setup_data import import_json from erpnext.healthcare.doctype.lab_test.lab_test import create_test_from_template + def setup_data(): frappe.flags.mute_emails = True make_masters() diff --git a/erpnext/demo/setup/manufacture.py b/erpnext/demo/setup/manufacture.py index 7d6b5012ea..5db3519c2c 100644 --- a/erpnext/demo/setup/manufacture.py +++ b/erpnext/demo/setup/manufacture.py @@ -1,13 +1,16 @@ from __future__ import unicode_literals -import random, json -import frappe -from frappe.utils import nowdate, add_days -from erpnext.demo.setup.setup_data import import_json -from erpnext.demo.domains import data +import json +import random +import frappe +from frappe.utils import add_days, nowdate from six import iteritems +from erpnext.demo.domains import data +from erpnext.demo.setup.setup_data import import_json + + def setup_data(): import_json("Location") import_json("Asset Category") diff --git a/erpnext/demo/setup/retail.py b/erpnext/demo/setup/retail.py index 82d1c15ea3..d94d2d6763 100644 --- a/erpnext/demo/setup/retail.py +++ b/erpnext/demo/setup/retail.py @@ -1,12 +1,12 @@ from __future__ import unicode_literals -import random, json +import json + import frappe -from frappe.utils import nowdate, add_days -from erpnext.demo.setup.setup_data import import_json +from six import iteritems + from erpnext.demo.domains import data -from six import iteritems def setup_data(): setup_item() diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index 05ee28a24a..42f83a3b4e 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -1,13 +1,18 @@ from __future__ import print_function, unicode_literals -import random, json -import frappe, erpnext -from frappe.utils.nestedset import get_root_of -from frappe.utils import flt, now_datetime, cstr, random_string -from frappe.utils.make_random import add_random_children, get_random -from frappe.custom.doctype.custom_field.custom_field import create_custom_fields -from erpnext.demo.domains import data +import json +import random + +import frappe from frappe import _ +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields +from frappe.utils import cstr, flt, now_datetime, random_string +from frappe.utils.make_random import add_random_children, get_random +from frappe.utils.nestedset import get_root_of + +import erpnext +from erpnext.demo.domains import data + def setup(domain): frappe.flags.in_demo = 1 diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py index 7fab772235..2a24824485 100644 --- a/erpnext/demo/user/accounts.py +++ b/erpnext/demo/user/accounts.py @@ -4,19 +4,25 @@ from __future__ import unicode_literals -import erpnext -import frappe import random -from frappe.utils import random_string + +import frappe from frappe.desk import query_report +from frappe.utils import random_string +from frappe.utils.make_random import get_random + +import erpnext from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry -from frappe.utils.make_random import get_random -from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry +from erpnext.accounts.doctype.payment_request.payment_request import ( + make_payment_entry, + make_payment_request, +) from erpnext.demo.user.sales import make_sales_order from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice + def work(): frappe.set_user(frappe.db.get_global('demo_accounts_user')) diff --git a/erpnext/demo/user/education.py b/erpnext/demo/user/education.py index 883a6d88cf..adc0463a7f 100644 --- a/erpnext/demo/user/education.py +++ b/erpnext/demo/user/education.py @@ -4,13 +4,21 @@ from __future__ import unicode_literals -import frappe import random +from datetime import timedelta + +import frappe from frappe.utils import cstr from frappe.utils.make_random import get_random -from datetime import timedelta -from erpnext.education.api import get_student_group_students, make_attendance_records, enroll_student, \ - get_fee_schedule, collect_fees, get_course + +from erpnext.education.api import ( + collect_fees, + enroll_student, + get_course, + get_fee_schedule, + get_student_group_students, + make_attendance_records, +) def work(): diff --git a/erpnext/demo/user/fixed_asset.py b/erpnext/demo/user/fixed_asset.py index dc094e1c91..ec0e4c818b 100644 --- a/erpnext/demo/user/fixed_asset.py +++ b/erpnext/demo/user/fixed_asset.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe from frappe.utils.make_random import get_random + from erpnext.assets.doctype.asset.asset import make_sales_invoice from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py index 0211bc8a90..17d5829f90 100644 --- a/erpnext/demo/user/hr.py +++ b/erpnext/demo/user/hr.py @@ -1,15 +1,23 @@ from __future__ import unicode_literals -import frappe, erpnext -import random + import datetime -from frappe.utils import random_string, add_days, get_last_day, getdate +import random + +import frappe +from frappe.utils import add_days, get_last_day, getdate, random_string +from frappe.utils.make_random import get_random + +import erpnext +from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry +from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account +from erpnext.hr.doctype.leave_application.leave_application import ( + AttendanceAlreadyMarkedError, + OverlapError, + get_leave_balance_on, +) from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice -from frappe.utils.make_random import get_random -from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account -from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry -from erpnext.hr.doctype.leave_application.leave_application import (get_leave_balance_on, - OverlapError, AttendanceAlreadyMarkedError) + def work(): frappe.set_user(frappe.db.get_global('demo_hr_user')) diff --git a/erpnext/demo/user/manufacturing.py b/erpnext/demo/user/manufacturing.py index bece0798fa..6e01f0f5a6 100644 --- a/erpnext/demo/user/manufacturing.py +++ b/erpnext/demo/user/manufacturing.py @@ -3,21 +3,23 @@ from __future__ import unicode_literals -import frappe, random, erpnext +import random from datetime import timedelta -from frappe.utils.make_random import how_many + +import frappe from frappe.desk import query_report -from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError +from frappe.utils.make_random import how_many + +import erpnext from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record + def work(): if random.random() < 0.3: return frappe.set_user(frappe.db.get_global('demo_manufacturing_user')) if not frappe.get_all('Sales Order'): return - from erpnext.projects.doctype.timesheet.timesheet import OverlapError - ppt = frappe.new_doc("Production Plan") ppt.company = erpnext.get_default_company() # ppt.use_multi_level_bom = 1 #refactored @@ -68,9 +70,12 @@ def work(): def make_stock_entry_from_pro(pro_id, purpose): from erpnext.manufacturing.doctype.work_order.work_order import make_stock_entry + from erpnext.stock.doctype.stock_entry.stock_entry import ( + DuplicateEntryForWorkOrderError, + IncorrectValuationRateError, + OperationsNotCompleteError, + ) from erpnext.stock.stock_ledger import NegativeStockError - from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \ - DuplicateEntryForWorkOrderError, OperationsNotCompleteError try: st = frappe.get_doc(make_stock_entry(pro_id, purpose)) diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py index 044e2967fd..b6b99de532 100644 --- a/erpnext/demo/user/projects.py +++ b/erpnext/demo/user/projects.py @@ -3,11 +3,14 @@ from __future__ import unicode_literals -import frappe, erpnext +import frappe from frappe.utils import flt from frappe.utils.make_random import get_random -from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet + +import erpnext from erpnext.demo.user.hr import make_sales_invoice_for_timesheet +from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet + def run_projects(current_date): frappe.set_user(frappe.db.get_global('demo_projects_user')) diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py index b7aca79cf9..ec32f973da 100644 --- a/erpnext/demo/user/purchase.py +++ b/erpnext/demo/user/purchase.py @@ -3,15 +3,22 @@ from __future__ import unicode_literals -import frappe, random, json, erpnext -from frappe.utils.make_random import how_many, get_random +import json +import random + +import frappe from frappe.desk import query_report -from erpnext.setup.utils import get_exchange_rate +from frappe.utils.make_random import get_random, how_many + +import erpnext from erpnext.accounts.party import get_party_account_currency +from erpnext.buying.doctype.request_for_quotation.request_for_quotation import ( + make_supplier_quotation_from_rfq, +) from erpnext.exceptions import InvalidCurrency +from erpnext.setup.utils import get_exchange_rate from erpnext.stock.doctype.material_request.material_request import make_request_for_quotation -from erpnext.buying.doctype.request_for_quotation.request_for_quotation import \ - make_supplier_quotation_from_rfq + def work(): frappe.set_user(frappe.db.get_global('demo_purchase_user')) diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py index 8d5ba28b79..95494ee324 100644 --- a/erpnext/demo/user/sales.py +++ b/erpnext/demo/user/sales.py @@ -3,12 +3,20 @@ from __future__ import unicode_literals -import frappe, random, erpnext +import random + +import frappe from frappe.utils import flt from frappe.utils.make_random import add_random_children, get_random -from erpnext.setup.utils import get_exchange_rate + +import erpnext +from erpnext.accounts.doctype.payment_request.payment_request import ( + make_payment_entry, + make_payment_request, +) from erpnext.accounts.party import get_party_account_currency -from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry +from erpnext.setup.utils import get_exchange_rate + def work(domain="Manufacturing"): frappe.set_user(frappe.db.get_global('demo_sales_user_2')) diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py index d44da7d127..188fc13f24 100644 --- a/erpnext/demo/user/stock.py +++ b/erpnext/demo/user/stock.py @@ -3,13 +3,18 @@ from __future__ import print_function, unicode_literals -import frappe, random, erpnext +import random + +import frappe from frappe.desk import query_report -from erpnext.stock.stock_ledger import NegativeStockError -from erpnext.stock.doctype.serial_no.serial_no import SerialNoRequiredError, SerialNoQtyError + +import erpnext from erpnext.stock.doctype.batch.batch import UnableToSelectBatchError from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_return from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_return +from erpnext.stock.doctype.serial_no.serial_no import SerialNoQtyError, SerialNoRequiredError +from erpnext.stock.stock_ledger import NegativeStockError + def work(): frappe.set_user(frappe.db.get_global('demo_manufacturing_user')) @@ -66,8 +71,10 @@ def make_delivery_note(): def make_stock_reconciliation(): # random set some items as damaged - from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation \ - import OpeningEntryAccountError, EmptyStockReconciliationItemsError + from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import ( + EmptyStockReconciliationItemsError, + OpeningEntryAccountError, + ) if random.random() < 0.4: stock_reco = frappe.new_doc("Stock Reconciliation") @@ -88,8 +95,11 @@ def make_stock_reconciliation(): frappe.db.rollback() def submit_draft_stock_entries(): - from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \ - DuplicateEntryForWorkOrderError, OperationsNotCompleteError + from erpnext.stock.doctype.stock_entry.stock_entry import ( + DuplicateEntryForWorkOrderError, + IncorrectValuationRateError, + OperationsNotCompleteError, + ) # try posting older drafts (if exists) frappe.db.commit() diff --git a/erpnext/education/__init__.py b/erpnext/education/__init__.py index c0589bb489..a3164b2597 100644 --- a/erpnext/education/__init__.py +++ b/erpnext/education/__init__.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals + import frappe from frappe import _ + class StudentNotInGroupError(frappe.ValidationError): pass def validate_student_belongs_to_group(student, student_group): diff --git a/erpnext/education/api.py b/erpnext/education/api.py index 4493a3fef1..d2a8805c89 100644 --- a/erpnext/education/api.py +++ b/erpnext/education/api.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe import _ -from frappe.model.mapper import get_mapped_doc -from frappe.utils import flt, cstr, getdate from frappe.email.doctype.email_group.email_group import add_subscribers +from frappe.model.mapper import get_mapped_doc +from frappe.utils import cstr, flt, getdate + def get_course(program): '''Return list of courses for a particular program diff --git a/erpnext/education/doctype/academic_term/academic_term.py b/erpnext/education/doctype/academic_term/academic_term.py index fa7f2899dc..b8e22b68c6 100644 --- a/erpnext/education/doctype/academic_term/academic_term.py +++ b/erpnext/education/doctype/academic_term/academic_term.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import getdate from frappe.model.document import Document +from frappe.utils import getdate + class AcademicTerm(Document): def autoname(self): diff --git a/erpnext/education/doctype/academic_term/academic_term_dashboard.py b/erpnext/education/doctype/academic_term/academic_term_dashboard.py index eb2f90742c..a1087b8fc4 100644 --- a/erpnext/education/doctype/academic_term/academic_term_dashboard.py +++ b/erpnext/education/doctype/academic_term/academic_term_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'academic_term', diff --git a/erpnext/education/doctype/academic_term/test_academic_term.py b/erpnext/education/doctype/academic_term/test_academic_term.py index 0964a56454..6329103870 100644 --- a/erpnext/education/doctype/academic_term/test_academic_term.py +++ b/erpnext/education/doctype/academic_term/test_academic_term.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Academic Term') diff --git a/erpnext/education/doctype/academic_year/academic_year.py b/erpnext/education/doctype/academic_year/academic_year.py index f2858a42d4..77b67d8a5d 100644 --- a/erpnext/education/doctype/academic_year/academic_year.py +++ b/erpnext/education/doctype/academic_year/academic_year.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import msgprint, _ +from frappe import _ from frappe.model.document import Document + class AcademicYear(Document): def validate(self): #Check that start of academic year is earlier than end of academic year diff --git a/erpnext/education/doctype/academic_year/academic_year_dashboard.py b/erpnext/education/doctype/academic_year/academic_year_dashboard.py index d3734df803..49d68c3af2 100644 --- a/erpnext/education/doctype/academic_year/academic_year_dashboard.py +++ b/erpnext/education/doctype/academic_year/academic_year_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'academic_year', diff --git a/erpnext/education/doctype/academic_year/test_academic_year.py b/erpnext/education/doctype/academic_year/test_academic_year.py index 9da75a7214..31135c40f3 100644 --- a/erpnext/education/doctype/academic_year/test_academic_year.py +++ b/erpnext/education/doctype/academic_year/test_academic_year.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Academic Year') diff --git a/erpnext/education/doctype/article/article.py b/erpnext/education/doctype/article/article.py index b5cc5cbc7a..f3c77880fc 100644 --- a/erpnext/education/doctype/article/article.py +++ b/erpnext/education/doctype/article/article.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class Article(Document): def get_article(self): pass diff --git a/erpnext/education/doctype/article/test_article.py b/erpnext/education/doctype/article/test_article.py index 2fce07f82c..cda79ad457 100644 --- a/erpnext/education/doctype/article/test_article.py +++ b/erpnext/education/doctype/article/test_article.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestArticle(unittest.TestCase): pass diff --git a/erpnext/education/doctype/assessment_criteria/assessment_criteria.py b/erpnext/education/doctype/assessment_criteria/assessment_criteria.py index bfbf26cf6c..f8f04bf513 100644 --- a/erpnext/education/doctype/assessment_criteria/assessment_criteria.py +++ b/erpnext/education/doctype/assessment_criteria/assessment_criteria.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document diff --git a/erpnext/education/doctype/assessment_criteria/test_assessment_criteria.py b/erpnext/education/doctype/assessment_criteria/test_assessment_criteria.py index fc0d745110..1098d0369f 100644 --- a/erpnext/education/doctype/assessment_criteria/test_assessment_criteria.py +++ b/erpnext/education/doctype/assessment_criteria/test_assessment_criteria.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Assessment Criteria') diff --git a/erpnext/education/doctype/assessment_criteria_group/assessment_criteria_group.py b/erpnext/education/doctype/assessment_criteria_group/assessment_criteria_group.py index 75381e1d0b..e62c030552 100644 --- a/erpnext/education/doctype/assessment_criteria_group/assessment_criteria_group.py +++ b/erpnext/education/doctype/assessment_criteria_group/assessment_criteria_group.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssessmentCriteriaGroup(Document): pass diff --git a/erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.py b/erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.py index 5b293371bb..d65f1e78d1 100644 --- a/erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.py +++ b/erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Assessment Criteria Group') diff --git a/erpnext/education/doctype/assessment_group/assessment_group.py b/erpnext/education/doctype/assessment_group/assessment_group.py index 88acc124d3..3425109331 100644 --- a/erpnext/education/doctype/assessment_group/assessment_group.py +++ b/erpnext/education/doctype/assessment_group/assessment_group.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssessmentGroup(Document): pass diff --git a/erpnext/education/doctype/assessment_group/assessment_group_dashboard.py b/erpnext/education/doctype/assessment_group/assessment_group_dashboard.py index 1a23606a61..83438c0ed7 100644 --- a/erpnext/education/doctype/assessment_group/assessment_group_dashboard.py +++ b/erpnext/education/doctype/assessment_group/assessment_group_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'assessment_group', diff --git a/erpnext/education/doctype/assessment_group/test_assessment_group.py b/erpnext/education/doctype/assessment_group/test_assessment_group.py index 2fd98b6d02..822d65c9bb 100644 --- a/erpnext/education/doctype/assessment_group/test_assessment_group.py +++ b/erpnext/education/doctype/assessment_group/test_assessment_group.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Assessment Group') diff --git a/erpnext/education/doctype/assessment_plan/assessment_plan.py b/erpnext/education/doctype/assessment_plan/assessment_plan.py index 16136c19f7..2a58a313cd 100644 --- a/erpnext/education/doctype/assessment_plan/assessment_plan.py +++ b/erpnext/education/doctype/assessment_plan/assessment_plan.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document + import frappe from frappe import _ +from frappe.model.document import Document + class AssessmentPlan(Document): def validate(self): diff --git a/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py b/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py index 8ac3faf6dd..672953852e 100644 --- a/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py +++ b/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'assessment_plan', diff --git a/erpnext/education/doctype/assessment_plan/test_assessment_plan.py b/erpnext/education/doctype/assessment_plan/test_assessment_plan.py index 2de4f23f5b..9a6b886035 100644 --- a/erpnext/education/doctype/assessment_plan/test_assessment_plan.py +++ b/erpnext/education/doctype/assessment_plan/test_assessment_plan.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Assessment Plan') diff --git a/erpnext/education/doctype/assessment_plan_criteria/assessment_plan_criteria.py b/erpnext/education/doctype/assessment_plan_criteria/assessment_plan_criteria.py index 53b477f700..795462d630 100644 --- a/erpnext/education/doctype/assessment_plan_criteria/assessment_plan_criteria.py +++ b/erpnext/education/doctype/assessment_plan_criteria/assessment_plan_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssessmentPlanCriteria(Document): pass diff --git a/erpnext/education/doctype/assessment_result/assessment_result.py b/erpnext/education/doctype/assessment_result/assessment_result.py index 7dfe0cf6c2..01f483f8b0 100644 --- a/erpnext/education/doctype/assessment_result/assessment_result.py +++ b/erpnext/education/doctype/assessment_result/assessment_result.py @@ -3,14 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import flt from frappe.model.document import Document -from erpnext.education.api import get_grade -from erpnext.education.api import get_assessment_details +from frappe.utils import flt from frappe.utils.csvutils import getlink + import erpnext.education +from erpnext.education.api import get_assessment_details, get_grade + class AssessmentResult(Document): def validate(self): diff --git a/erpnext/education/doctype/assessment_result/assessment_result_dashboard.py b/erpnext/education/doctype/assessment_result/assessment_result_dashboard.py index 2526076d30..f9e2008ebc 100644 --- a/erpnext/education/doctype/assessment_result/assessment_result_dashboard.py +++ b/erpnext/education/doctype/assessment_result/assessment_result_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'reports': [ diff --git a/erpnext/education/doctype/assessment_result/test_assessment_result.py b/erpnext/education/doctype/assessment_result/test_assessment_result.py index adce57769d..fa0ad1f692 100644 --- a/erpnext/education/doctype/assessment_result/test_assessment_result.py +++ b/erpnext/education/doctype/assessment_result/test_assessment_result.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + from erpnext.education.api import get_grade # test_records = frappe.get_test_records('Assessment Result') diff --git a/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.py b/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.py index d051593159..234dff044f 100644 --- a/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.py +++ b/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssessmentResultDetail(Document): pass diff --git a/erpnext/education/doctype/assessment_result_tool/assessment_result_tool.py b/erpnext/education/doctype/assessment_result_tool/assessment_result_tool.py index a0d286ccbe..83b4f5634e 100644 --- a/erpnext/education/doctype/assessment_result_tool/assessment_result_tool.py +++ b/erpnext/education/doctype/assessment_result_tool/assessment_result_tool.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class AssessmentResultTool(Document): pass diff --git a/erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.py b/erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.py index f784ccb256..bcc57220e7 100644 --- a/erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.py +++ b/erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestAssessmentResultTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/content_activity/content_activity.py b/erpnext/education/doctype/content_activity/content_activity.py index 2ae7a5c94c..076e2d37c0 100644 --- a/erpnext/education/doctype/content_activity/content_activity.py +++ b/erpnext/education/doctype/content_activity/content_activity.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ContentActivity(Document): pass diff --git a/erpnext/education/doctype/content_question/content_question.py b/erpnext/education/doctype/content_question/content_question.py index b239d211a3..9c2491697d 100644 --- a/erpnext/education/doctype/content_question/content_question.py +++ b/erpnext/education/doctype/content_question/content_question.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ContentQuestion(Document): pass diff --git a/erpnext/education/doctype/content_question/test_content_question.py b/erpnext/education/doctype/content_question/test_content_question.py index 268b9be2e7..f6bd49bb80 100644 --- a/erpnext/education/doctype/content_question/test_content_question.py +++ b/erpnext/education/doctype/content_question/test_content_question.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestContentQuestion(unittest.TestCase): pass diff --git a/erpnext/education/doctype/course/course.py b/erpnext/education/doctype/course/course.py index 92f92ed9f3..9cc373a5fe 100644 --- a/erpnext/education/doctype/course/course.py +++ b/erpnext/education/doctype/course/course.py @@ -3,10 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json -from frappe.model.document import Document + +import frappe from frappe import _ +from frappe.model.document import Document + class Course(Document): def validate(self): diff --git a/erpnext/education/doctype/course/course_dashboard.py b/erpnext/education/doctype/course/course_dashboard.py index 8de91b1c09..8eca2a1350 100644 --- a/erpnext/education/doctype/course/course_dashboard.py +++ b/erpnext/education/doctype/course/course_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'course', diff --git a/erpnext/education/doctype/course/test_course.py b/erpnext/education/doctype/course/test_course.py index 4667ac45a2..dd43ef447c 100644 --- a/erpnext/education/doctype/course/test_course.py +++ b/erpnext/education/doctype/course/test_course.py @@ -2,11 +2,12 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # See license.txt from __future__ import unicode_literals -from erpnext.education.doctype.topic.test_topic import make_topic -from erpnext.education.doctype.topic.test_topic import make_topic_and_linked_content + +import unittest import frappe -import unittest + +from erpnext.education.doctype.topic.test_topic import make_topic, make_topic_and_linked_content # test_records = frappe.get_test_records('Course') diff --git a/erpnext/education/doctype/course_activity/course_activity.py b/erpnext/education/doctype/course_activity/course_activity.py index 3aa1ea0c5b..61b51a05a1 100644 --- a/erpnext/education/doctype/course_activity/course_activity.py +++ b/erpnext/education/doctype/course_activity/course_activity.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + class CourseActivity(Document): def validate(self): self.check_if_enrolled() diff --git a/erpnext/education/doctype/course_activity/test_course_activity.py b/erpnext/education/doctype/course_activity/test_course_activity.py index 5269a6b71a..778cefecab 100644 --- a/erpnext/education/doctype/course_activity/test_course_activity.py +++ b/erpnext/education/doctype/course_activity/test_course_activity.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestCourseActivity(unittest.TestCase): pass diff --git a/erpnext/education/doctype/course_assessment_criteria/course_assessment_criteria.py b/erpnext/education/doctype/course_assessment_criteria/course_assessment_criteria.py index ade2a390a2..df384c5314 100644 --- a/erpnext/education/doctype/course_assessment_criteria/course_assessment_criteria.py +++ b/erpnext/education/doctype/course_assessment_criteria/course_assessment_criteria.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class CourseAssessmentCriteria(Document): pass diff --git a/erpnext/education/doctype/course_content/course_content.py b/erpnext/education/doctype/course_content/course_content.py index 0d2f85ab50..1dd08adbb0 100644 --- a/erpnext/education/doctype/course_content/course_content.py +++ b/erpnext/education/doctype/course_content/course_content.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class CourseContent(Document): pass diff --git a/erpnext/education/doctype/course_content/test_course_content.py b/erpnext/education/doctype/course_content/test_course_content.py index 9be4b1f5ce..320fa111f7 100644 --- a/erpnext/education/doctype/course_content/test_course_content.py +++ b/erpnext/education/doctype/course_content/test_course_content.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestCourseContent(unittest.TestCase): pass diff --git a/erpnext/education/doctype/course_enrollment/course_enrollment.py b/erpnext/education/doctype/course_enrollment/course_enrollment.py index ce88990a70..21e74516f8 100644 --- a/erpnext/education/doctype/course_enrollment/course_enrollment.py +++ b/erpnext/education/doctype/course_enrollment/course_enrollment.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + +from functools import reduce + import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import get_link_to_form -from functools import reduce + class CourseEnrollment(Document): def validate(self): diff --git a/erpnext/education/doctype/course_enrollment/course_enrollment_dashboard.py b/erpnext/education/doctype/course_enrollment/course_enrollment_dashboard.py index 37972fe354..253325c586 100644 --- a/erpnext/education/doctype/course_enrollment/course_enrollment_dashboard.py +++ b/erpnext/education/doctype/course_enrollment/course_enrollment_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'enrollment', diff --git a/erpnext/education/doctype/course_enrollment/test_course_enrollment.py b/erpnext/education/doctype/course_enrollment/test_course_enrollment.py index 874bf121f4..e5feb1b7f7 100644 --- a/erpnext/education/doctype/course_enrollment/test_course_enrollment.py +++ b/erpnext/education/doctype/course_enrollment/test_course_enrollment.py @@ -3,14 +3,14 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe -from erpnext.education.doctype.student.test_student import create_student -from erpnext.education.doctype.student.test_student import get_student -from erpnext.education.doctype.program.test_program import setup_program from erpnext.education.doctype.course_activity.test_course_activity import make_course_activity +from erpnext.education.doctype.program.test_program import setup_program +from erpnext.education.doctype.student.test_student import create_student, get_student + class TestCourseEnrollment(unittest.TestCase): def setUp(self): diff --git a/erpnext/education/doctype/course_schedule/course_schedule.py b/erpnext/education/doctype/course_schedule/course_schedule.py index 748728d104..38379e4c77 100644 --- a/erpnext/education/doctype/course_schedule/course_schedule.py +++ b/erpnext/education/doctype/course_schedule/course_schedule.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + class CourseSchedule(Document): def validate(self): self.instructor_name = frappe.db.get_value("Instructor", self.instructor, "instructor_name") diff --git a/erpnext/education/doctype/course_schedule/course_schedule_dashboard.py b/erpnext/education/doctype/course_schedule/course_schedule_dashboard.py index 22ce7e1ec2..12a1735f4e 100644 --- a/erpnext/education/doctype/course_schedule/course_schedule_dashboard.py +++ b/erpnext/education/doctype/course_schedule/course_schedule_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'course_schedule', diff --git a/erpnext/education/doctype/course_schedule/test_course_schedule.py b/erpnext/education/doctype/course_schedule/test_course_schedule.py index 5bb4de8584..1b45ceda48 100644 --- a/erpnext/education/doctype/course_schedule/test_course_schedule.py +++ b/erpnext/education/doctype/course_schedule/test_course_schedule.py @@ -3,13 +3,13 @@ # See license.txt from __future__ import unicode_literals -import frappe +import datetime import unittest -import datetime -from frappe.utils import today, to_timedelta +import frappe +from frappe.utils import to_timedelta, today + from erpnext.education.utils import OverlapError -from frappe.utils.make_random import get_random # test_records = frappe.get_test_records('Course Schedule') diff --git a/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py b/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py index 0f2ea96a58..4f7ed36821 100644 --- a/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py +++ b/erpnext/education/doctype/course_scheduling_tool/course_scheduling_tool.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import calendar + +import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import add_days, getdate + from erpnext.education.utils import OverlapError @@ -95,7 +98,7 @@ class CourseSchedulingTool(Document): if self.day == calendar.day_name[getdate(d.schedule_date).weekday()]: frappe.delete_doc("Course Schedule", d.name) rescheduled.append(d.name) - except: + except Exception: reschedule_errors.append(d.name) return rescheduled, reschedule_errors diff --git a/erpnext/education/doctype/course_scheduling_tool/test_course_scheduling_tool.py b/erpnext/education/doctype/course_scheduling_tool/test_course_scheduling_tool.py index d921f8e0e1..27379b70e1 100644 --- a/erpnext/education/doctype/course_scheduling_tool/test_course_scheduling_tool.py +++ b/erpnext/education/doctype/course_scheduling_tool/test_course_scheduling_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestCourseSchedulingTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/course_topic/course_topic.py b/erpnext/education/doctype/course_topic/course_topic.py index 2364f17a49..11eb457b7c 100644 --- a/erpnext/education/doctype/course_topic/course_topic.py +++ b/erpnext/education/doctype/course_topic/course_topic.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class CourseTopic(Document): pass diff --git a/erpnext/education/doctype/course_topic/test_course_topic.py b/erpnext/education/doctype/course_topic/test_course_topic.py index 7ce46d28ad..0bba7f5478 100644 --- a/erpnext/education/doctype/course_topic/test_course_topic.py +++ b/erpnext/education/doctype/course_topic/test_course_topic.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestCourseTopic(unittest.TestCase): pass diff --git a/erpnext/education/doctype/education_settings/education_settings.py b/erpnext/education/doctype/education_settings/education_settings.py index 6c7e95c80d..71d13f733b 100644 --- a/erpnext/education/doctype/education_settings/education_settings.py +++ b/erpnext/education/doctype/education_settings/education_settings.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe import frappe.defaults from frappe.model.document import Document diff --git a/erpnext/education/doctype/education_settings/test_education_settings.py b/erpnext/education/doctype/education_settings/test_education_settings.py index 038fb6e57e..3611cbef21 100644 --- a/erpnext/education/doctype/education_settings/test_education_settings.py +++ b/erpnext/education/doctype/education_settings/test_education_settings.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestEducationSettings(unittest.TestCase): pass diff --git a/erpnext/education/doctype/fee_category/fee_category.py b/erpnext/education/doctype/fee_category/fee_category.py index 55234442ba..f531f8af6e 100644 --- a/erpnext/education/doctype/fee_category/fee_category.py +++ b/erpnext/education/doctype/fee_category/fee_category.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class FeeCategory(Document): pass diff --git a/erpnext/education/doctype/fee_category/test_fee_category.py b/erpnext/education/doctype/fee_category/test_fee_category.py index 48e7589a0c..875568416f 100644 --- a/erpnext/education/doctype/fee_category/test_fee_category.py +++ b/erpnext/education/doctype/fee_category/test_fee_category.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Fee Category') diff --git a/erpnext/education/doctype/fee_component/fee_component.py b/erpnext/education/doctype/fee_component/fee_component.py index 8694610927..dba39af594 100644 --- a/erpnext/education/doctype/fee_component/fee_component.py +++ b/erpnext/education/doctype/fee_component/fee_component.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class FeeComponent(Document): pass diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule.py b/erpnext/education/doctype/fee_schedule/fee_schedule.py index 0b025c7534..6bf4667179 100644 --- a/erpnext/education/doctype/fee_schedule/fee_schedule.py +++ b/erpnext/education/doctype/fee_schedule/fee_schedule.py @@ -3,13 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext + +import frappe +from frappe import _ from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc -from frappe.utils import money_in_words -from frappe.utils import cint, flt, cstr +from frappe.utils import cint, cstr, flt, money_in_words from frappe.utils.background_jobs import enqueue -from frappe import _ + +import erpnext class FeeSchedule(Document): diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule_dashboard.py b/erpnext/education/doctype/fee_schedule/fee_schedule_dashboard.py index 4d7da21ea1..34f870578f 100644 --- a/erpnext/education/doctype/fee_schedule/fee_schedule_dashboard.py +++ b/erpnext/education/doctype/fee_schedule/fee_schedule_dashboard.py @@ -2,6 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + def get_data(): return { 'fieldname': 'fee_schedule', diff --git a/erpnext/education/doctype/fee_schedule/test_fee_schedule.py b/erpnext/education/doctype/fee_schedule/test_fee_schedule.py index 44e0756d64..86b74de342 100644 --- a/erpnext/education/doctype/fee_schedule/test_fee_schedule.py +++ b/erpnext/education/doctype/fee_schedule/test_fee_schedule.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestFeeSchedule(unittest.TestCase): pass diff --git a/erpnext/education/doctype/fee_schedule_program/fee_schedule_program.py b/erpnext/education/doctype/fee_schedule_program/fee_schedule_program.py index 11d5697380..5e9ed61ba8 100644 --- a/erpnext/education/doctype/fee_schedule_program/fee_schedule_program.py +++ b/erpnext/education/doctype/fee_schedule_program/fee_schedule_program.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class FeeScheduleProgram(Document): pass diff --git a/erpnext/education/doctype/fee_schedule_student_group/fee_schedule_student_group.py b/erpnext/education/doctype/fee_schedule_student_group/fee_schedule_student_group.py index 776534d6fa..ba30a91516 100644 --- a/erpnext/education/doctype/fee_schedule_student_group/fee_schedule_student_group.py +++ b/erpnext/education/doctype/fee_schedule_student_group/fee_schedule_student_group.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class FeeScheduleStudentGroup(Document): pass diff --git a/erpnext/education/doctype/fee_structure/fee_structure.py b/erpnext/education/doctype/fee_structure/fee_structure.py index 9755717ee9..a6cc701921 100644 --- a/erpnext/education/doctype/fee_structure/fee_structure.py +++ b/erpnext/education/doctype/fee_structure/fee_structure.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc diff --git a/erpnext/education/doctype/fee_structure/fee_structure_dashboard.py b/erpnext/education/doctype/fee_structure/fee_structure_dashboard.py index fdf7df7aa2..c053b4ea4b 100644 --- a/erpnext/education/doctype/fee_structure/fee_structure_dashboard.py +++ b/erpnext/education/doctype/fee_structure/fee_structure_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'fee_structure', diff --git a/erpnext/education/doctype/fee_structure/test_fee_structure.py b/erpnext/education/doctype/fee_structure/test_fee_structure.py index 785ae4e7d3..1311f13997 100644 --- a/erpnext/education/doctype/fee_structure/test_fee_structure.py +++ b/erpnext/education/doctype/fee_structure/test_fee_structure.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Fee Structure') diff --git a/erpnext/education/doctype/fees/fees.py b/erpnext/education/doctype/fees/fees.py index 7e86704904..a5dc0dca31 100644 --- a/erpnext/education/doctype/fees/fees.py +++ b/erpnext/education/doctype/fees/fees.py @@ -3,14 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document -import frappe, erpnext + +import frappe from frappe import _ from frappe.utils import money_in_words -from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request from frappe.utils.csvutils import getlink -from erpnext.controllers.accounts_controller import AccountsController + +import erpnext +from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request from erpnext.accounts.general_ledger import make_reverse_gl_entries +from erpnext.controllers.accounts_controller import AccountsController class Fees(AccountsController): diff --git a/erpnext/education/doctype/fees/test_fees.py b/erpnext/education/doctype/fees/test_fees.py index c6bb704b41..fbf7a571fe 100644 --- a/erpnext/education/doctype/fees/test_fees.py +++ b/erpnext/education/doctype/fees/test_fees.py @@ -3,10 +3,12 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import nowdate from frappe.utils.make_random import get_random + from erpnext.education.doctype.program.test_program import make_program_and_linked_courses test_dependencies = ['Company'] diff --git a/erpnext/education/doctype/grading_scale/grading_scale.py b/erpnext/education/doctype/grading_scale/grading_scale.py index 0e73297161..ed75f31d84 100644 --- a/erpnext/education/doctype/grading_scale/grading_scale.py +++ b/erpnext/education/doctype/grading_scale/grading_scale.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils import cint from frappe.model.document import Document +from frappe.utils import cint + class GradingScale(Document): def validate(self): diff --git a/erpnext/education/doctype/grading_scale/grading_scale_dashboard.py b/erpnext/education/doctype/grading_scale/grading_scale_dashboard.py index 2a3f13b156..268871a04e 100644 --- a/erpnext/education/doctype/grading_scale/grading_scale_dashboard.py +++ b/erpnext/education/doctype/grading_scale/grading_scale_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'grading_scale', diff --git a/erpnext/education/doctype/grading_scale/test_grading_scale.py b/erpnext/education/doctype/grading_scale/test_grading_scale.py index 5364d7c887..e5d83c20c1 100644 --- a/erpnext/education/doctype/grading_scale/test_grading_scale.py +++ b/erpnext/education/doctype/grading_scale/test_grading_scale.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Grading Scale') diff --git a/erpnext/education/doctype/grading_scale_interval/grading_scale_interval.py b/erpnext/education/doctype/grading_scale_interval/grading_scale_interval.py index 41ac5ffd5c..6e55aac40b 100644 --- a/erpnext/education/doctype/grading_scale_interval/grading_scale_interval.py +++ b/erpnext/education/doctype/grading_scale_interval/grading_scale_interval.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class GradingScaleInterval(Document): pass diff --git a/erpnext/education/doctype/guardian/guardian.py b/erpnext/education/doctype/guardian/guardian.py index e82cc546af..f79e131034 100644 --- a/erpnext/education/doctype/guardian/guardian.py +++ b/erpnext/education/doctype/guardian/guardian.py @@ -3,11 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document from frappe.utils.csvutils import getlink + class Guardian(Document): def __setup__(self): self.onload() diff --git a/erpnext/education/doctype/guardian/test_guardian.py b/erpnext/education/doctype/guardian/test_guardian.py index 61420f6cec..446e261221 100644 --- a/erpnext/education/doctype/guardian/test_guardian.py +++ b/erpnext/education/doctype/guardian/test_guardian.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Guardian') diff --git a/erpnext/education/doctype/guardian_interest/guardian_interest.py b/erpnext/education/doctype/guardian_interest/guardian_interest.py index f5c4cf1d49..4a3040f060 100644 --- a/erpnext/education/doctype/guardian_interest/guardian_interest.py +++ b/erpnext/education/doctype/guardian_interest/guardian_interest.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class GuardianInterest(Document): pass diff --git a/erpnext/education/doctype/guardian_student/guardian_student.py b/erpnext/education/doctype/guardian_student/guardian_student.py index bf6f5c1373..62867d8908 100644 --- a/erpnext/education/doctype/guardian_student/guardian_student.py +++ b/erpnext/education/doctype/guardian_student/guardian_student.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class GuardianStudent(Document): pass diff --git a/erpnext/education/doctype/instructor/instructor.py b/erpnext/education/doctype/instructor/instructor.py index b1bfcbb2f1..92fb8b04b9 100644 --- a/erpnext/education/doctype/instructor/instructor.py +++ b/erpnext/education/doctype/instructor/instructor.py @@ -3,11 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document from frappe.model.naming import set_name_by_naming_series + class Instructor(Document): def autoname(self): naming_method = frappe.db.get_value("Education Settings", None, "instructor_created_by") diff --git a/erpnext/education/doctype/instructor/instructor_dashboard.py b/erpnext/education/doctype/instructor/instructor_dashboard.py index c19c85947d..bb08a54903 100644 --- a/erpnext/education/doctype/instructor/instructor_dashboard.py +++ b/erpnext/education/doctype/instructor/instructor_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'heatmap': True, diff --git a/erpnext/education/doctype/instructor/test_instructor.py b/erpnext/education/doctype/instructor/test_instructor.py index 4061422a74..b698a20e11 100644 --- a/erpnext/education/doctype/instructor/test_instructor.py +++ b/erpnext/education/doctype/instructor/test_instructor.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Instructor') diff --git a/erpnext/education/doctype/instructor_log/instructor_log.py b/erpnext/education/doctype/instructor_log/instructor_log.py index 75217b22f6..68ab7a639e 100644 --- a/erpnext/education/doctype/instructor_log/instructor_log.py +++ b/erpnext/education/doctype/instructor_log/instructor_log.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class InstructorLog(Document): pass diff --git a/erpnext/education/doctype/options/options.py b/erpnext/education/doctype/options/options.py index a11d77afb2..a064384129 100644 --- a/erpnext/education/doctype/options/options.py +++ b/erpnext/education/doctype/options/options.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class Options(Document): pass diff --git a/erpnext/education/doctype/program/program.py b/erpnext/education/doctype/program/program.py index 9d886b7b9e..7de34cf30f 100644 --- a/erpnext/education/doctype/program/program.py +++ b/erpnext/education/doctype/program/program.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class Program(Document): def get_course_list(self): diff --git a/erpnext/education/doctype/program/program_dashboard.py b/erpnext/education/doctype/program/program_dashboard.py index 6c503e1bf1..66960767f1 100644 --- a/erpnext/education/doctype/program/program_dashboard.py +++ b/erpnext/education/doctype/program/program_dashboard.py @@ -1,5 +1,6 @@ from frappe import _ + def get_data(): return { 'fieldname': 'program', diff --git a/erpnext/education/doctype/program/test_program.py b/erpnext/education/doctype/program/test_program.py index 204f2961e7..3222aa6004 100644 --- a/erpnext/education/doctype/program/test_program.py +++ b/erpnext/education/doctype/program/test_program.py @@ -2,12 +2,13 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # See license.txt from __future__ import unicode_literals -from erpnext.education.doctype.course.test_course import make_course -from erpnext.education.doctype.topic.test_topic import make_topic_and_linked_content -from erpnext.education.doctype.course.test_course import make_course_and_linked_topic + +import unittest import frappe -import unittest + +from erpnext.education.doctype.course.test_course import make_course, make_course_and_linked_topic +from erpnext.education.doctype.topic.test_topic import make_topic_and_linked_content test_data = { "program_name": "_Test Program", diff --git a/erpnext/education/doctype/program_course/program_course.py b/erpnext/education/doctype/program_course/program_course.py index 684b6fade7..d5236a109a 100644 --- a/erpnext/education/doctype/program_course/program_course.py +++ b/erpnext/education/doctype/program_course/program_course.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ProgramCourse(Document): pass diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.py b/erpnext/education/doctype/program_enrollment/program_enrollment.py index dd4aa576ac..79c5a14d8c 100644 --- a/erpnext/education/doctype/program_enrollment/program_enrollment.py +++ b/erpnext/education/doctype/program_enrollment/program_enrollment.py @@ -3,12 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe import msgprint, _ +from frappe import _, msgprint +from frappe.desk.reportview import get_match_cond from frappe.model.document import Document -from frappe.desk.reportview import get_match_cond, get_filters_cond from frappe.utils import comma_and, get_link_to_form, getdate -import erpnext.www.lms as lms + class ProgramEnrollment(Document): def validate(self): diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment_dashboard.py b/erpnext/education/doctype/program_enrollment/program_enrollment_dashboard.py index c47f866689..f829276dac 100644 --- a/erpnext/education/doctype/program_enrollment/program_enrollment_dashboard.py +++ b/erpnext/education/doctype/program_enrollment/program_enrollment_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'program_enrollment', diff --git a/erpnext/education/doctype/program_enrollment/test_program_enrollment.py b/erpnext/education/doctype/program_enrollment/test_program_enrollment.py index 497ee288aa..65de38af2d 100644 --- a/erpnext/education/doctype/program_enrollment/test_program_enrollment.py +++ b/erpnext/education/doctype/program_enrollment/test_program_enrollment.py @@ -3,13 +3,13 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from erpnext.education.doctype.student.test_student import create_student -from erpnext.education.doctype.student.test_student import get_student +import frappe + from erpnext.education.doctype.program.test_program import make_program_and_linked_courses -from erpnext.education.doctype.course_activity.test_course_activity import make_course_activity +from erpnext.education.doctype.student.test_student import create_student, get_student + class TestProgramEnrollment(unittest.TestCase): diff --git a/erpnext/education/doctype/program_enrollment_course/program_enrollment_course.py b/erpnext/education/doctype/program_enrollment_course/program_enrollment_course.py index e1f564eff0..5c0706dbce 100644 --- a/erpnext/education/doctype/program_enrollment_course/program_enrollment_course.py +++ b/erpnext/education/doctype/program_enrollment_course/program_enrollment_course.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ProgramEnrollmentCourse(Document): pass diff --git a/erpnext/education/doctype/program_enrollment_fee/program_enrollment_fee.py b/erpnext/education/doctype/program_enrollment_fee/program_enrollment_fee.py index 03a311e164..53bae7c150 100644 --- a/erpnext/education/doctype/program_enrollment_fee/program_enrollment_fee.py +++ b/erpnext/education/doctype/program_enrollment_fee/program_enrollment_fee.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ProgramEnrollmentFee(Document): pass diff --git a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py index 5833b67f9b..69fa66558d 100644 --- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py +++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from erpnext.education.api import enroll_student from frappe.utils import cint +from erpnext.education.api import enroll_student + + class ProgramEnrollmentTool(Document): def onload(self): academic_term_reqd = cint(frappe.db.get_single_value('Education Settings', 'academic_term_reqd')) diff --git a/erpnext/education/doctype/program_enrollment_tool/test_program_enrollment_tool.py b/erpnext/education/doctype/program_enrollment_tool/test_program_enrollment_tool.py index f22b3b1c8d..55734cbc94 100644 --- a/erpnext/education/doctype/program_enrollment_tool/test_program_enrollment_tool.py +++ b/erpnext/education/doctype/program_enrollment_tool/test_program_enrollment_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestProgramEnrollmentTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.py b/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.py index 38dc1c8437..67653458f5 100644 --- a/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.py +++ b/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ProgramEnrollmentToolStudent(Document): pass diff --git a/erpnext/education/doctype/program_fee/program_fee.py b/erpnext/education/doctype/program_fee/program_fee.py index cadcc4eeb8..70105ee6be 100644 --- a/erpnext/education/doctype/program_fee/program_fee.py +++ b/erpnext/education/doctype/program_fee/program_fee.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class ProgramFee(Document): pass diff --git a/erpnext/education/doctype/question/question.py b/erpnext/education/doctype/question/question.py index fb3b50478c..e74aa93ad8 100644 --- a/erpnext/education/doctype/question/question.py +++ b/erpnext/education/doctype/question/question.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + class Question(Document): def validate(self): diff --git a/erpnext/education/doctype/question/test_question.py b/erpnext/education/doctype/question/test_question.py index 552872e15f..1ce10c0cb8 100644 --- a/erpnext/education/doctype/question/test_question.py +++ b/erpnext/education/doctype/question/test_question.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestQuestion(unittest.TestCase): pass diff --git a/erpnext/education/doctype/quiz/quiz.py b/erpnext/education/doctype/quiz/quiz.py index a128e1f342..474bea111b 100644 --- a/erpnext/education/doctype/quiz/quiz.py +++ b/erpnext/education/doctype/quiz/quiz.py @@ -3,11 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -import json from frappe import _ from frappe.model.document import Document + class Quiz(Document): def validate(self): if self.passing_score > 100: diff --git a/erpnext/education/doctype/quiz/test_quiz.py b/erpnext/education/doctype/quiz/test_quiz.py index 344fd544ee..22eb23d4fd 100644 --- a/erpnext/education/doctype/quiz/test_quiz.py +++ b/erpnext/education/doctype/quiz/test_quiz.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestQuiz(unittest.TestCase): pass diff --git a/erpnext/education/doctype/quiz_activity/quiz_activity.py b/erpnext/education/doctype/quiz_activity/quiz_activity.py index 24c7175397..0fc7603228 100644 --- a/erpnext/education/doctype/quiz_activity/quiz_activity.py +++ b/erpnext/education/doctype/quiz_activity/quiz_activity.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class QuizActivity(Document): pass diff --git a/erpnext/education/doctype/quiz_activity/test_quiz_activity.py b/erpnext/education/doctype/quiz_activity/test_quiz_activity.py index fb0425d809..44e3a3f92b 100644 --- a/erpnext/education/doctype/quiz_activity/test_quiz_activity.py +++ b/erpnext/education/doctype/quiz_activity/test_quiz_activity.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestQuizActivity(unittest.TestCase): pass diff --git a/erpnext/education/doctype/quiz_question/quiz_question.py b/erpnext/education/doctype/quiz_question/quiz_question.py index 317e75b2cb..20cb9f7b38 100644 --- a/erpnext/education/doctype/quiz_question/quiz_question.py +++ b/erpnext/education/doctype/quiz_question/quiz_question.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class QuizQuestion(Document): pass diff --git a/erpnext/education/doctype/quiz_result/quiz_result.py b/erpnext/education/doctype/quiz_result/quiz_result.py index a4fd9f062f..059d294cff 100644 --- a/erpnext/education/doctype/quiz_result/quiz_result.py +++ b/erpnext/education/doctype/quiz_result/quiz_result.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class QuizResult(Document): pass diff --git a/erpnext/education/doctype/quiz_result/test_quiz_result.py b/erpnext/education/doctype/quiz_result/test_quiz_result.py index 86ee52d87d..08ac4811bc 100644 --- a/erpnext/education/doctype/quiz_result/test_quiz_result.py +++ b/erpnext/education/doctype/quiz_result/test_quiz_result.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestQuizResult(unittest.TestCase): pass diff --git a/erpnext/education/doctype/room/room.py b/erpnext/education/doctype/room/room.py index f26e9c4b45..dc68a0dd0c 100644 --- a/erpnext/education/doctype/room/room.py +++ b/erpnext/education/doctype/room/room.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class Room(Document): pass diff --git a/erpnext/education/doctype/room/room_dashboard.py b/erpnext/education/doctype/room/room_dashboard.py index 7bcb97f709..6a43b6037f 100644 --- a/erpnext/education/doctype/room/room_dashboard.py +++ b/erpnext/education/doctype/room/room_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'room', diff --git a/erpnext/education/doctype/room/test_room.py b/erpnext/education/doctype/room/test_room.py index 33ffd9173e..5718d51d65 100644 --- a/erpnext/education/doctype/room/test_room.py +++ b/erpnext/education/doctype/room/test_room.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Room') diff --git a/erpnext/education/doctype/school_house/school_house.py b/erpnext/education/doctype/school_house/school_house.py index 8751e5c646..2f9c5f46a8 100644 --- a/erpnext/education/doctype/school_house/school_house.py +++ b/erpnext/education/doctype/school_house/school_house.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class SchoolHouse(Document): pass diff --git a/erpnext/education/doctype/school_house/test_school_house.py b/erpnext/education/doctype/school_house/test_school_house.py index 5cf96d5daa..b58b7d49ce 100644 --- a/erpnext/education/doctype/school_house/test_school_house.py +++ b/erpnext/education/doctype/school_house/test_school_house.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestSchoolHouse(unittest.TestCase): pass diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py index 6be9e7104b..ae498ba57d 100644 --- a/erpnext/education/doctype/student/student.py +++ b/erpnext/education/doctype/student/student.py @@ -3,12 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document -from frappe.utils import getdate,today from frappe import _ from frappe.desk.form.linked_with import get_linked_doctypes +from frappe.model.document import Document +from frappe.utils import getdate, today + from erpnext.education.utils import check_content_completion, check_quiz_completion + + class Student(Document): def validate(self): self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name])) diff --git a/erpnext/education/doctype/student/student_dashboard.py b/erpnext/education/doctype/student/student_dashboard.py index d2614628b1..efff2e6490 100644 --- a/erpnext/education/doctype/student/student_dashboard.py +++ b/erpnext/education/doctype/student/student_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'heatmap': True, diff --git a/erpnext/education/doctype/student/test_student.py b/erpnext/education/doctype/student/test_student.py index fcb2b5fb93..ec6abb56ef 100644 --- a/erpnext/education/doctype/student/test_student.py +++ b/erpnext/education/doctype/student/test_student.py @@ -2,12 +2,12 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # See license.txt from __future__ import unicode_literals -from frappe.test_runner import make_test_records -from erpnext.education.doctype.program.test_program import make_program_and_linked_courses -from erpnext.education.doctype.course.test_course import make_course + +import unittest import frappe -import unittest + +from erpnext.education.doctype.program.test_program import make_program_and_linked_courses test_records = frappe.get_test_records('Student') class TestStudent(unittest.TestCase): diff --git a/erpnext/education/doctype/student_admission/student_admission.py b/erpnext/education/doctype/student_admission/student_admission.py index 0febb96aeb..67ef67b4aa 100644 --- a/erpnext/education/doctype/student_admission/student_admission.py +++ b/erpnext/education/doctype/student_admission/student_admission.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.utils import nowdate diff --git a/erpnext/education/doctype/student_admission/test_student_admission.py b/erpnext/education/doctype/student_admission/test_student_admission.py index 748c7ae1b3..c9cfbca14a 100644 --- a/erpnext/education/doctype/student_admission/test_student_admission.py +++ b/erpnext/education/doctype/student_admission/test_student_admission.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Admission') diff --git a/erpnext/education/doctype/student_admission_program/student_admission_program.py b/erpnext/education/doctype/student_admission_program/student_admission_program.py index 406027ca2c..2377d2648d 100644 --- a/erpnext/education/doctype/student_admission_program/student_admission_program.py +++ b/erpnext/education/doctype/student_admission_program/student_admission_program.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class StudentAdmissionProgram(Document): pass diff --git a/erpnext/education/doctype/student_applicant/student_applicant.py b/erpnext/education/doctype/student_applicant/student_applicant.py index 193b6d3297..36a0757531 100644 --- a/erpnext/education/doctype/student_applicant/student_applicant.py +++ b/erpnext/education/doctype/student_applicant/student_applicant.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import print_function, unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import getdate, add_years, nowdate, date_diff +from frappe.utils import add_years, date_diff, getdate, nowdate + class StudentApplicant(Document): def autoname(self): diff --git a/erpnext/education/doctype/student_applicant/test_student_applicant.py b/erpnext/education/doctype/student_applicant/test_student_applicant.py index 9734a88b93..b7258a4ae1 100644 --- a/erpnext/education/doctype/student_applicant/test_student_applicant.py +++ b/erpnext/education/doctype/student_applicant/test_student_applicant.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Applicant') diff --git a/erpnext/education/doctype/student_attendance/student_attendance.py b/erpnext/education/doctype/student_attendance/student_attendance.py index 2e9e6cf8d6..3826afb049 100644 --- a/erpnext/education/doctype/student_attendance/student_attendance.py +++ b/erpnext/education/doctype/student_attendance/student_attendance.py @@ -3,14 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ -from frappe.utils import get_link_to_form, getdate, formatdate +from frappe.model.document import Document +from frappe.utils import formatdate, get_link_to_form, getdate + from erpnext import get_default_company from erpnext.education.api import get_student_group_students from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday + class StudentAttendance(Document): def validate(self): self.validate_mandatory() diff --git a/erpnext/education/doctype/student_attendance/student_attendance_dashboard.py b/erpnext/education/doctype/student_attendance/student_attendance_dashboard.py index e405b8aed9..489f64d680 100644 --- a/erpnext/education/doctype/student_attendance/student_attendance_dashboard.py +++ b/erpnext/education/doctype/student_attendance/student_attendance_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'reports': [ diff --git a/erpnext/education/doctype/student_attendance/test_student_attendance.py b/erpnext/education/doctype/student_attendance/test_student_attendance.py index 9f4153845b..d453aeda1c 100644 --- a/erpnext/education/doctype/student_attendance/test_student_attendance.py +++ b/erpnext/education/doctype/student_attendance/test_student_attendance.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Attendance') diff --git a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.py b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.py index 972973fbad..96767deb6d 100644 --- a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.py +++ b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class StudentAttendanceTool(Document): pass diff --git a/erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.py b/erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.py index ffc42af474..a94a3f235d 100644 --- a/erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.py +++ b/erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestStudentAttendanceTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/student_batch_name/student_batch_name.py b/erpnext/education/doctype/student_batch_name/student_batch_name.py index e6d38ea254..ce507160e0 100644 --- a/erpnext/education/doctype/student_batch_name/student_batch_name.py +++ b/erpnext/education/doctype/student_batch_name/student_batch_name.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentBatchName(Document): pass diff --git a/erpnext/education/doctype/student_batch_name/test_student_batch_name.py b/erpnext/education/doctype/student_batch_name/test_student_batch_name.py index 09534f355c..75ebeb29b8 100644 --- a/erpnext/education/doctype/student_batch_name/test_student_batch_name.py +++ b/erpnext/education/doctype/student_batch_name/test_student_batch_name.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Batch Name') diff --git a/erpnext/education/doctype/student_category/student_category.py b/erpnext/education/doctype/student_category/student_category.py index bd3a835889..bb362d5834 100644 --- a/erpnext/education/doctype/student_category/student_category.py +++ b/erpnext/education/doctype/student_category/student_category.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentCategory(Document): pass diff --git a/erpnext/education/doctype/student_category/student_category_dashboard.py b/erpnext/education/doctype/student_category/student_category_dashboard.py index f31c34bd94..9238623788 100644 --- a/erpnext/education/doctype/student_category/student_category_dashboard.py +++ b/erpnext/education/doctype/student_category/student_category_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'student_category', diff --git a/erpnext/education/doctype/student_category/test_student_category.py b/erpnext/education/doctype/student_category/test_student_category.py index 756cab87eb..0893769045 100644 --- a/erpnext/education/doctype/student_category/test_student_category.py +++ b/erpnext/education/doctype/student_category/test_student_category.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Category') diff --git a/erpnext/education/doctype/student_group/student_group.py b/erpnext/education/doctype/student_group/student_group.py index 3d4572abf7..2347d31731 100644 --- a/erpnext/education/doctype/student_group/student_group.py +++ b/erpnext/education/doctype/student_group/student_group.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ -from erpnext.education.utils import validate_duplicate_student +from frappe.model.document import Document from frappe.utils import cint +from erpnext.education.utils import validate_duplicate_student + + class StudentGroup(Document): def validate(self): self.validate_mandatory_fields() diff --git a/erpnext/education/doctype/student_group/student_group_dashboard.py b/erpnext/education/doctype/student_group/student_group_dashboard.py index d37445f7b9..36329bd8d8 100644 --- a/erpnext/education/doctype/student_group/student_group_dashboard.py +++ b/erpnext/education/doctype/student_group/student_group_dashboard.py @@ -1,8 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'student_group', diff --git a/erpnext/education/doctype/student_group/test_student_group.py b/erpnext/education/doctype/student_group/test_student_group.py index 8b9b47d9ce..06022511e5 100644 --- a/erpnext/education/doctype/student_group/test_student_group.py +++ b/erpnext/education/doctype/student_group/test_student_group.py @@ -3,10 +3,13 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe + import erpnext.education + def get_random_group(): doc = frappe.get_doc({ "doctype": "Student Group", diff --git a/erpnext/education/doctype/student_group_creation_tool/student_group_creation_tool.py b/erpnext/education/doctype/student_group_creation_tool/student_group_creation_tool.py index 28ff7d618c..2007f8aa7c 100644 --- a/erpnext/education/doctype/student_group_creation_tool/student_group_creation_tool.py +++ b/erpnext/education/doctype/student_group_creation_tool/student_group_creation_tool.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document + from erpnext.education.doctype.student_group.student_group import get_students + class StudentGroupCreationTool(Document): @frappe.whitelist() def get_courses(self): diff --git a/erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.py b/erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.py index 9ca56588f2..432da09013 100644 --- a/erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.py +++ b/erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestStudentGroupCreationTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/student_group_creation_tool_course/student_group_creation_tool_course.py b/erpnext/education/doctype/student_group_creation_tool_course/student_group_creation_tool_course.py index b3411ea7c5..b9d1e0d7fe 100644 --- a/erpnext/education/doctype/student_group_creation_tool_course/student_group_creation_tool_course.py +++ b/erpnext/education/doctype/student_group_creation_tool_course/student_group_creation_tool_course.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentGroupCreationToolCourse(Document): pass diff --git a/erpnext/education/doctype/student_group_instructor/student_group_instructor.py b/erpnext/education/doctype/student_group_instructor/student_group_instructor.py index b6cc588b67..81a7ed25af 100644 --- a/erpnext/education/doctype/student_group_instructor/student_group_instructor.py +++ b/erpnext/education/doctype/student_group_instructor/student_group_instructor.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentGroupInstructor(Document): pass diff --git a/erpnext/education/doctype/student_group_student/student_group_student.py b/erpnext/education/doctype/student_group_student/student_group_student.py index 1fe4ea1dc3..7ee4caec5e 100644 --- a/erpnext/education/doctype/student_group_student/student_group_student.py +++ b/erpnext/education/doctype/student_group_student/student_group_student.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentGroupStudent(Document): pass diff --git a/erpnext/education/doctype/student_guardian/student_guardian.py b/erpnext/education/doctype/student_guardian/student_guardian.py index 04445bcc59..56d7df7d0a 100644 --- a/erpnext/education/doctype/student_guardian/student_guardian.py +++ b/erpnext/education/doctype/student_guardian/student_guardian.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentGuardian(Document): pass diff --git a/erpnext/education/doctype/student_language/student_language.py b/erpnext/education/doctype/student_language/student_language.py index be6d5debe4..6ec0b1fc6e 100644 --- a/erpnext/education/doctype/student_language/student_language.py +++ b/erpnext/education/doctype/student_language/student_language.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentLanguage(Document): pass diff --git a/erpnext/education/doctype/student_language/test_student_language.py b/erpnext/education/doctype/student_language/test_student_language.py index 592b94a4fc..1d7c003ae5 100644 --- a/erpnext/education/doctype/student_language/test_student_language.py +++ b/erpnext/education/doctype/student_language/test_student_language.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Language') diff --git a/erpnext/education/doctype/student_leave_application/student_leave_application.py b/erpnext/education/doctype/student_leave_application/student_leave_application.py index ef670124c3..50c14aae22 100644 --- a/erpnext/education/doctype/student_leave_application/student_leave_application.py +++ b/erpnext/education/doctype/student_leave_application/student_leave_application.py @@ -3,13 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals + +from datetime import timedelta + import frappe from frappe import _ -from datetime import timedelta -from frappe.utils import get_link_to_form, getdate, date_diff, flt -from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday -from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list from frappe.model.document import Document +from frappe.utils import date_diff, flt, get_link_to_form, getdate + +from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list +from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday + class StudentLeaveApplication(Document): def validate(self): diff --git a/erpnext/education/doctype/student_leave_application/student_leave_application_dashboard.py b/erpnext/education/doctype/student_leave_application/student_leave_application_dashboard.py index 0ff6d1a76e..2674f5415d 100644 --- a/erpnext/education/doctype/student_leave_application/student_leave_application_dashboard.py +++ b/erpnext/education/doctype/student_leave_application/student_leave_application_dashboard.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def get_data(): return { 'fieldname': 'leave_application', diff --git a/erpnext/education/doctype/student_leave_application/test_student_leave_application.py b/erpnext/education/doctype/student_leave_application/test_student_leave_application.py index 9cae257748..506dc738d8 100644 --- a/erpnext/education/doctype/student_leave_application/test_student_leave_application.py +++ b/erpnext/education/doctype/student_leave_application/test_student_leave_application.py @@ -3,12 +3,15 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import getdate, add_days, add_months + +import frappe +from frappe.utils import add_days, add_months, getdate + from erpnext import get_default_company -from erpnext.education.doctype.student_group.test_student_group import get_random_group from erpnext.education.doctype.student.test_student import create_student +from erpnext.education.doctype.student_group.test_student_group import get_random_group + class TestStudentLeaveApplication(unittest.TestCase): def setUp(self): diff --git a/erpnext/education/doctype/student_log/student_log.py b/erpnext/education/doctype/student_log/student_log.py index 8b12886863..2ca49ca12d 100644 --- a/erpnext/education/doctype/student_log/student_log.py +++ b/erpnext/education/doctype/student_log/student_log.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentLog(Document): pass diff --git a/erpnext/education/doctype/student_log/test_student_log.py b/erpnext/education/doctype/student_log/test_student_log.py index 1fe191fe95..533191f3b4 100644 --- a/erpnext/education/doctype/student_log/test_student_log.py +++ b/erpnext/education/doctype/student_log/test_student_log.py @@ -3,7 +3,6 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest # test_records = frappe.get_test_records('Student Log') diff --git a/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py b/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py index 17bc367826..1cf7921315 100644 --- a/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py +++ b/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py @@ -3,13 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json + +import json + +import frappe from frappe import _ from frappe.model.document import Document -from erpnext.education.api import get_grade from frappe.utils.pdf import get_pdf -from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_formatted_result -from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_child_assessment_groups + +from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import ( + get_child_assessment_groups, + get_formatted_result, +) class StudentReportGenerationTool(Document): diff --git a/erpnext/education/doctype/student_report_generation_tool/test_student_report_generation_tool.py b/erpnext/education/doctype/student_report_generation_tool/test_student_report_generation_tool.py index 417816642e..f6227136d9 100644 --- a/erpnext/education/doctype/student_report_generation_tool/test_student_report_generation_tool.py +++ b/erpnext/education/doctype/student_report_generation_tool/test_student_report_generation_tool.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestStudentReportGenerationTool(unittest.TestCase): pass diff --git a/erpnext/education/doctype/student_sibling/student_sibling.py b/erpnext/education/doctype/student_sibling/student_sibling.py index 4adc3f35ba..b36cf59dbb 100644 --- a/erpnext/education/doctype/student_sibling/student_sibling.py +++ b/erpnext/education/doctype/student_sibling/student_sibling.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentSibling(Document): pass diff --git a/erpnext/education/doctype/student_siblings/student_siblings.py b/erpnext/education/doctype/student_siblings/student_siblings.py index 4e20d84ae7..412cf050c1 100644 --- a/erpnext/education/doctype/student_siblings/student_siblings.py +++ b/erpnext/education/doctype/student_siblings/student_siblings.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class StudentSiblings(Document): pass diff --git a/erpnext/education/doctype/topic/test_topic.py b/erpnext/education/doctype/topic/test_topic.py index d03db1cb93..b6c6c7516f 100644 --- a/erpnext/education/doctype/topic/test_topic.py +++ b/erpnext/education/doctype/topic/test_topic.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestTopic(unittest.TestCase): def setUp(self): make_topic_and_linked_content("_Test Topic 1", [{"type":"Article", "name": "_Test Article 1"}]) diff --git a/erpnext/education/doctype/topic/topic.py b/erpnext/education/doctype/topic/topic.py index fb680d725b..1834b2e060 100644 --- a/erpnext/education/doctype/topic/topic.py +++ b/erpnext/education/doctype/topic/topic.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe import _ from frappe.model.document import Document + class Topic(Document): def get_contents(self): try: diff --git a/erpnext/education/doctype/topic_content/test_topic_content.py b/erpnext/education/doctype/topic_content/test_topic_content.py index cf304f60bc..6fdcbdae71 100644 --- a/erpnext/education/doctype/topic_content/test_topic_content.py +++ b/erpnext/education/doctype/topic_content/test_topic_content.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestTopicContent(unittest.TestCase): pass diff --git a/erpnext/education/doctype/topic_content/topic_content.py b/erpnext/education/doctype/topic_content/topic_content.py index 9b2c90bb4f..9339bbde5a 100644 --- a/erpnext/education/doctype/topic_content/topic_content.py +++ b/erpnext/education/doctype/topic_content/topic_content.py @@ -3,8 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + from frappe.model.document import Document + class TopicContent(Document): pass diff --git a/erpnext/education/report/absent_student_report/absent_student_report.py b/erpnext/education/report/absent_student_report/absent_student_report.py index c3487ccaff..d5b66757fc 100644 --- a/erpnext/education/report/absent_student_report/absent_student_report.py +++ b/erpnext/education/report/absent_student_report/absent_student_report.py @@ -2,12 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe +from frappe import _, msgprint from frappe.utils import formatdate -from frappe import msgprint, _ + from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/education/report/assessment_plan_status/assessment_plan_status.py b/erpnext/education/report/assessment_plan_status/assessment_plan_status.py index 21184a637c..64ceb42731 100644 --- a/erpnext/education/report/assessment_plan_status/assessment_plan_status.py +++ b/erpnext/education/report/assessment_plan_status/assessment_plan_status.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + +from itertools import groupby + import frappe from frappe import _ -from itertools import groupby from frappe.utils import cint DOCSTATUS = { diff --git a/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.py b/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.py index 1043e5bd45..ad07ee1949 100644 --- a/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.py +++ b/erpnext/education/report/course_wise_assessment_report/course_wise_assessment_report.py @@ -2,10 +2,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + +from collections import OrderedDict, defaultdict + import frappe from frappe import _ -from frappe.utils import flt -from collections import defaultdict, OrderedDict + from erpnext.education.api import get_grade diff --git a/erpnext/education/report/final_assessment_grades/final_assessment_grades.py b/erpnext/education/report/final_assessment_grades/final_assessment_grades.py index e6e0ba2ebc..ae7f34b5e1 100644 --- a/erpnext/education/report/final_assessment_grades/final_assessment_grades.py +++ b/erpnext/education/report/final_assessment_grades/final_assessment_grades.py @@ -2,12 +2,16 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe import _ + from collections import defaultdict -from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_formatted_result -from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import get_chart_data +import frappe +from frappe import _ + +from erpnext.education.report.course_wise_assessment_report.course_wise_assessment_report import ( + get_chart_data, + get_formatted_result, +) def execute(filters=None): diff --git a/erpnext/education/report/program_wise_fee_collection/program_wise_fee_collection.py b/erpnext/education/report/program_wise_fee_collection/program_wise_fee_collection.py index c0ec0357cc..1717ed55ae 100644 --- a/erpnext/education/report/program_wise_fee_collection/program_wise_fee_collection.py +++ b/erpnext/education/report/program_wise_fee_collection/program_wise_fee_collection.py @@ -2,9 +2,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py index 5bebd4385c..a21a93686e 100644 --- a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py +++ b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py @@ -2,6 +2,7 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ diff --git a/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.py b/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.py index e2576a0c71..b65350f1b2 100644 --- a/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.py +++ b/erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.py @@ -2,12 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe +from frappe import _, msgprint from frappe.utils import formatdate -from frappe import msgprint, _ + from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py b/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py index 04dc8c0e56..f6d9c5a012 100644 --- a/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py +++ b/erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py @@ -2,14 +2,16 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe -from frappe.utils import cstr, cint, getdate, get_first_day, get_last_day, date_diff, add_days -from frappe import msgprint, _ -from calendar import monthrange +from frappe import _ +from frappe.utils import add_days, cstr, date_diff, get_first_day, get_last_day, getdate + from erpnext.education.api import get_student_group_students from erpnext.education.doctype.student_attendance.student_attendance import get_holiday_list from erpnext.support.doctype.issue.issue import get_holidays + def execute(filters=None): if not filters: filters = {} diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 3070e6a3e8..33394e1796 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- # Copyright (c) 2015, Frappe Technologies and contributors -from __future__ import unicode_literals, division +from __future__ import division, unicode_literals + import frappe from frappe import _ + class OverlapError(frappe.ValidationError): pass def validate_overlap_for(doc, doctype, fieldname, value=None): @@ -219,7 +221,7 @@ def get_quiz(quiz_name, course): try: quiz = frappe.get_doc("Quiz", quiz_name) questions = quiz.get_questions() - except: + except Exception: frappe.throw(_("Quiz {0} does not exist").format(quiz_name), frappe.DoesNotExistError) return None diff --git a/erpnext/education/web_form/student_applicant/student_applicant.py b/erpnext/education/web_form/student_applicant/student_applicant.py index 2334f8b26d..f57de916dd 100644 --- a/erpnext/education/web_form/student_applicant/student_applicant.py +++ b/erpnext/education/web_form/student_applicant/student_applicant.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import frappe def get_context(context): # do your magic here diff --git a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py index a505ee09d2..192ec147e3 100644 --- a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py +++ b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py @@ -1,8 +1,15 @@ from __future__ import unicode_literals -import frappe, base64, hashlib, hmac, json -from frappe.utils import cstr + +import base64 +import hashlib +import hmac +import json + +import frappe from frappe import _ +from frappe.utils import cstr + def verify_request(): woocommerce_settings = frappe.get_doc("Woocommerce Settings") diff --git a/erpnext/erpnext_integrations/data_migration_mapping/issue_to_task/__init__.py b/erpnext/erpnext_integrations/data_migration_mapping/issue_to_task/__init__.py index aeb5352a22..5a4a57c2e2 100644 --- a/erpnext/erpnext_integrations/data_migration_mapping/issue_to_task/__init__.py +++ b/erpnext/erpnext_integrations/data_migration_mapping/issue_to_task/__init__.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + import frappe + def pre_process(issue): project = frappe.db.get_value('Project', filters={'project_name': issue.milestone}) diff --git a/erpnext/erpnext_integrations/data_migration_mapping/milestone_to_project/__init__.py b/erpnext/erpnext_integrations/data_migration_mapping/milestone_to_project/__init__.py index 9d3f02eaaf..bab8031e02 100644 --- a/erpnext/erpnext_integrations/data_migration_mapping/milestone_to_project/__init__.py +++ b/erpnext/erpnext_integrations/data_migration_mapping/milestone_to_project/__init__.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def pre_process(milestone): return { 'title': milestone.title, diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py index 148c1a6a16..a757a43b59 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py @@ -3,10 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, time, dateutil, math, csv -from six import StringIO -import erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_mws_api as mws + +import csv +import math +import time + +import dateutil +import frappe from frappe import _ +from six import StringIO + +import erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_mws_api as mws + #Get and Create Products def get_products_details(): diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_api.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_api.py index 7fd3b34fd5..652fa9200d 100755 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_api.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_api.py @@ -6,24 +6,24 @@ # Extended to include finances object from __future__ import unicode_literals -import urllib -from urllib.parse import quote +import base64 import hashlib import hmac -import base64 -import six -from erpnext.erpnext_integrations.doctype.amazon_mws_settings import xml_utils import re +from urllib.parse import quote + +from erpnext.erpnext_integrations.doctype.amazon_mws_settings import xml_utils + try: from xml.etree.ElementTree import ParseError as XMLError except ImportError: from xml.parsers.expat import ExpatError as XMLError -from time import strftime, gmtime + +from time import gmtime, strftime from requests import request from requests.exceptions import HTTPError - __all__ = [ 'Feeds', 'Inventory', diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_settings.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_settings.py index 9c59840149..ac59eb7925 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_settings.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_mws_settings.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe.model.document import Document + import dateutil +import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields +from frappe.model.document import Document + from erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods import get_orders + class AmazonMWSSettings(Document): def validate(self): if self.enable_amazon == 1: diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/test_amazon_mws_settings.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/test_amazon_mws_settings.py index 7b40014c52..844df59576 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/test_amazon_mws_settings.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/test_amazon_mws_settings.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestAmazonMWSSettings(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py index 99ede8f31d..88ef64d307 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/xml_utils.py @@ -8,8 +8,8 @@ Borrowed from https://github.com/timotheus/ebaysdk-python """ from __future__ import unicode_literals -import xml.etree.ElementTree as ET import re +import xml.etree.ElementTree as ET class object_dict(dict): @@ -88,7 +88,7 @@ class xml2dict(object): ns = http://cs.sfsu.edu/csc867/myscheduler name = patients """ - result = re.compile("\{(.*)\}(.*)").search(tag) + result = re.compile(r"\{(.*)\}(.*)").search(tag) if result: value.namespace, tag = result.groups() diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py index bff928c1c9..f1314fc122 100644 --- a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document -import requests + import frappe +import requests from frappe import _ +from frappe.model.document import Document + class ExotelSettings(Document): def validate(self): diff --git a/erpnext/erpnext_integrations/doctype/gocardless_mandate/gocardless_mandate.py b/erpnext/erpnext_integrations/doctype/gocardless_mandate/gocardless_mandate.py index 9c9df65314..b416ce8808 100644 --- a/erpnext/erpnext_integrations/doctype/gocardless_mandate/gocardless_mandate.py +++ b/erpnext/erpnext_integrations/doctype/gocardless_mandate/gocardless_mandate.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class GoCardlessMandate(Document): pass diff --git a/erpnext/erpnext_integrations/doctype/gocardless_mandate/test_gocardless_mandate.py b/erpnext/erpnext_integrations/doctype/gocardless_mandate/test_gocardless_mandate.py index d77a352cdb..1b76ee5afc 100644 --- a/erpnext/erpnext_integrations/doctype/gocardless_mandate/test_gocardless_mandate.py +++ b/erpnext/erpnext_integrations/doctype/gocardless_mandate/test_gocardless_mandate.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestGoCardlessMandate(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/gocardless_settings/__init__.py b/erpnext/erpnext_integrations/doctype/gocardless_settings/__init__.py index 25784a5620..d003edb9b0 100644 --- a/erpnext/erpnext_integrations/doctype/gocardless_settings/__init__.py +++ b/erpnext/erpnext_integrations/doctype/gocardless_settings/__init__.py @@ -3,10 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -import json -import hmac + import hashlib +import hmac +import json + +import frappe + @frappe.whitelist(allow_guest=True) def webhooks(): diff --git a/erpnext/erpnext_integrations/doctype/gocardless_settings/gocardless_settings.py b/erpnext/erpnext_integrations/doctype/gocardless_settings/gocardless_settings.py index c65e3cefee..6484973106 100644 --- a/erpnext/erpnext_integrations/doctype/gocardless_settings/gocardless_settings.py +++ b/erpnext/erpnext_integrations/doctype/gocardless_settings/gocardless_settings.py @@ -3,13 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document import gocardless_pro from frappe import _ +from frappe.integrations.utils import create_payment_gateway, create_request_log +from frappe.model.document import Document +from frappe.utils import call_hook_method, cint, flt, get_url from six.moves.urllib.parse import urlencode -from frappe.utils import get_url, call_hook_method, flt, cint -from frappe.integrations.utils import create_request_log, create_payment_gateway + class GoCardlessSettings(Document): supported_currencies = ["EUR", "DKK", "GBP", "SEK"] diff --git a/erpnext/erpnext_integrations/doctype/gocardless_settings/test_gocardless_settings.py b/erpnext/erpnext_integrations/doctype/gocardless_settings/test_gocardless_settings.py index e377f3482c..b17aef5098 100644 --- a/erpnext/erpnext_integrations/doctype/gocardless_settings/test_gocardless_settings.py +++ b/erpnext/erpnext_integrations/doctype/gocardless_settings/test_gocardless_settings.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestGoCardlessSettings(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py index d1adeeee07..6d46a1c884 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py @@ -1,7 +1,9 @@ import base64 +import datetime + import requests from requests.auth import HTTPBasicAuth -import datetime + class MpesaConnector(): def __init__(self, env="sandbox", app_key=None, app_secret=None, sandbox_url="https://sandbox.safaricom.co.ke", diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_custom_fields.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_custom_fields.py index 139e2fb192..368139b872 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_custom_fields.py +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_custom_fields.py @@ -1,6 +1,7 @@ import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields + def create_custom_pos_fields(): """Create custom fields corresponding to POS Settings and POS Invoice.""" pos_field = { diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py index de93357861..4ce85e58a6 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py @@ -4,17 +4,21 @@ from __future__ import unicode_literals -from json import loads, dumps + +from json import dumps, loads import frappe -from frappe.model.document import Document from frappe import _ -from frappe.utils import call_hook_method, fmt_money -from frappe.integrations.utils import create_request_log, create_payment_gateway -from frappe.utils import get_request_site_address -from erpnext.erpnext_integrations.utils import create_mode_of_payment +from frappe.integrations.utils import create_payment_gateway, create_request_log +from frappe.model.document import Document +from frappe.utils import call_hook_method, fmt_money, get_request_site_address + from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_connector import MpesaConnector -from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_custom_fields import create_custom_pos_fields +from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_custom_fields import ( + create_custom_pos_fields, +) +from erpnext.erpnext_integrations.utils import create_mode_of_payment + class MpesaSettings(Document): supported_currencies = ["KES"] @@ -39,7 +43,9 @@ class MpesaSettings(Document): for i, amount in enumerate(request_amounts): args.request_amount = amount if frappe.flags.in_test: - from erpnext.erpnext_integrations.doctype.mpesa_settings.test_mpesa_settings import get_payment_request_response_payload + from erpnext.erpnext_integrations.doctype.mpesa_settings.test_mpesa_settings import ( + get_payment_request_response_payload, + ) response = frappe._dict(get_payment_request_response_payload(amount)) else: response = frappe._dict(generate_stk_push(**args)) @@ -71,7 +77,9 @@ class MpesaSettings(Document): ) if frappe.flags.in_test: - from erpnext.erpnext_integrations.doctype.mpesa_settings.test_mpesa_settings import get_test_account_balance_response + from erpnext.erpnext_integrations.doctype.mpesa_settings.test_mpesa_settings import ( + get_test_account_balance_response, + ) response = frappe._dict(get_test_account_balance_response()) else: response = frappe._dict(get_account_balance(payload)) diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py index d4cb6b982b..de81b82132 100644 --- a/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py +++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/test_mpesa_settings.py @@ -2,13 +2,20 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals -from json import dumps -import frappe + import unittest -from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_settings import process_balance_info, verify_transaction +from json import dumps + +import frappe + from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice +from erpnext.erpnext_integrations.doctype.mpesa_settings.mpesa_settings import ( + process_balance_info, + verify_transaction, +) from erpnext.erpnext_integrations.utils import create_mode_of_payment + class TestMpesaSettings(unittest.TestCase): def setUp(self): # create payment gateway in setup diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py index 73f5927df4..d4cf56af6b 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py @@ -2,12 +2,11 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +import frappe import plaid import requests -from plaid.errors import APIError, ItemError, InvalidRequestError - -import frappe from frappe import _ +from plaid.errors import APIError, InvalidRequestError, ItemError class PlaidConnector(): diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py index eddcb3401f..d2748c2faa 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py @@ -5,15 +5,16 @@ import json import frappe -from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account -from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector import PlaidConnector from frappe import _ from frappe.desk.doctype.tag.tag import add_tag from frappe.model.document import Document from frappe.utils import add_months, formatdate, getdate, today - from plaid.errors import ItemError +from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account +from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector import PlaidConnector + + class PlaidSettings(Document): @staticmethod @frappe.whitelist() diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py index e2243eabde..32b5b8f265 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py @@ -6,11 +6,16 @@ import json import unittest import frappe +from frappe.utils.response import json_handler + from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account from erpnext.erpnext_integrations.doctype.plaid_settings.plaid_settings import ( - add_account_subtype, add_account_type, add_bank_accounts, - new_bank_transaction, get_plaid_configuration) -from frappe.utils.response import json_handler + add_account_subtype, + add_account_type, + add_bank_accounts, + get_plaid_configuration, + new_bank_transaction, +) class TestPlaidSettings(unittest.TestCase): diff --git a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py index 866ea66278..39b9bb232e 100644 --- a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py +++ b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py @@ -3,15 +3,19 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import json +import traceback + import frappe +import requests from frappe import _ from frappe.model.document import Document from requests_oauthlib import OAuth2Session -import json -import requests -import traceback + from erpnext import encode_company_abbr + # QuickBooks requires a redirect URL, User will be redirect to this URL # This will be a GET request # Request parameters will have two parameters `code` and `realmId` @@ -253,8 +257,9 @@ class QuickBooksMigrator(Document): try: # Assumes that exactly one fiscal year has been created so far # Creates fiscal years till oldest ledger entry date is covered - from frappe.utils.data import add_years, getdate from itertools import chain + + from frappe.utils.data import add_years, getdate smallest_ledger_entry_date = getdate(min(entry["date"] for entry in chain(*self.gl_entries.values()) if entry["date"])) oldest_fiscal_year = frappe.get_all("Fiscal Year", fields=["year_start_date", "year_end_date"], diff --git a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/test_quickbooks_migrator.py b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/test_quickbooks_migrator.py index 6ce7c92ae8..5604b40d14 100644 --- a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/test_quickbooks_migrator.py +++ b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/test_quickbooks_migrator.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestQuickBooksMigrator(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py index 907a22333b..e1e7f62df4 100644 --- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py +++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py @@ -11,19 +11,19 @@ import traceback import zipfile from decimal import Decimal -from bs4 import BeautifulSoup as bs - import frappe -from erpnext import encode_company_abbr -from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts -from erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer import unset_existing_data - +from bs4 import BeautifulSoup as bs from frappe import _ from frappe.custom.doctype.custom_field.custom_field import create_custom_field from frappe.model.document import Document -from frappe.model.naming import getseries, revert_series_if_last from frappe.utils.data import format_datetime +from erpnext import encode_company_abbr +from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts +from erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer import ( + unset_existing_data, +) + PRIMARY_ACCOUNT = "Primary" VOUCHER_CHUNK_SIZE = 500 @@ -266,7 +266,7 @@ class TallyMigration(Document): self.is_master_data_processed = 1 - except: + except Exception: self.publish("Process Master Data", _("Process Failed"), -1, 5) self.log() @@ -302,14 +302,14 @@ class TallyMigration(Document): try: party_doc = frappe.get_doc(party) party_doc.insert() - except: + except Exception: self.log(party_doc) addresses_file = frappe.get_doc("File", {"file_url": addresses_file_url}) for address in json.loads(addresses_file.get_content()): try: address_doc = frappe.get_doc(address) address_doc.insert(ignore_mandatory=True) - except: + except Exception: self.log(address_doc) def create_items_uoms(items_file_url, uoms_file_url): @@ -319,7 +319,7 @@ class TallyMigration(Document): try: uom_doc = frappe.get_doc(uom) uom_doc.insert() - except: + except Exception: self.log(uom_doc) items_file = frappe.get_doc("File", {"file_url": items_file_url}) @@ -327,7 +327,7 @@ class TallyMigration(Document): try: item_doc = frappe.get_doc(item) item_doc.insert() - except: + except Exception: self.log(item_doc) try: @@ -346,7 +346,7 @@ class TallyMigration(Document): self.is_master_data_imported = 1 frappe.db.commit() - except: + except Exception: self.publish("Import Master Data", _("Process Failed"), -1, 5) frappe.db.rollback() self.log() @@ -370,7 +370,7 @@ class TallyMigration(Document): if processed_voucher: vouchers.append(processed_voucher) frappe.db.commit() - except: + except Exception: frappe.db.rollback() self.log(voucher) return vouchers @@ -494,7 +494,7 @@ class TallyMigration(Document): self.is_day_book_data_processed = 1 - except: + except Exception: self.publish("Process Day Book Data", _("Process Failed"), -1, 5) self.log() @@ -564,7 +564,7 @@ class TallyMigration(Document): is_last = True frappe.enqueue_doc(self.doctype, self.name, "_import_vouchers", queue="long", timeout=3600, start=index+1, total=total, is_last=is_last) - except: + except Exception: self.log() finally: @@ -583,7 +583,7 @@ class TallyMigration(Document): voucher_doc.submit() self.publish("Importing Vouchers", _("{} of {}").format(index, total), index, total) frappe.db.commit() - except: + except Exception: frappe.db.rollback() self.log(voucher_doc) diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py index 9f67e55ca1..aae8f6d4db 100644 --- a/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py +++ b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py @@ -3,8 +3,8 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + class TestTallyMigration(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py index 7f5f0f0e7a..9dd481747e 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class TaxJarSettings(Document): pass diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/test_taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/test_taxjar_settings.py index 7cdfd00956..c871b05642 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/test_taxjar_settings.py +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/test_taxjar_settings.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestTaxJarSettings(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/woocommerce_settings/test_woocommerce_settings.py b/erpnext/erpnext_integrations/doctype/woocommerce_settings/test_woocommerce_settings.py index 458a23fae2..3d18458436 100644 --- a/erpnext/erpnext_integrations/doctype/woocommerce_settings/test_woocommerce_settings.py +++ b/erpnext/erpnext_integrations/doctype/woocommerce_settings/test_woocommerce_settings.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestWoocommerceSettings(unittest.TestCase): pass diff --git a/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py b/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py index 45f261007f..2e15fab0d3 100644 --- a/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py +++ b/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py @@ -3,12 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ -from frappe.utils.nestedset import get_root_of -from frappe.model.document import Document -from six.moves.urllib.parse import urlparse from frappe.custom.doctype.custom_field.custom_field import create_custom_field +from frappe.model.document import Document +from frappe.utils.nestedset import get_root_of +from six.moves.urllib.parse import urlparse + class WoocommerceSettings(Document): def validate(self): diff --git a/erpnext/erpnext_integrations/stripe_integration.py b/erpnext/erpnext_integrations/stripe_integration.py index 820c740532..f0315eb7ee 100644 --- a/erpnext/erpnext_integrations/stripe_integration.py +++ b/erpnext/erpnext_integrations/stripe_integration.py @@ -2,9 +2,8 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt -import stripe - import frappe +import stripe from frappe import _ from frappe.integrations.utils import create_request_log diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index f960998c3c..870a4ef54c 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -1,11 +1,12 @@ import traceback -import taxjar - import frappe -from erpnext import get_default_company +import taxjar from frappe import _ from frappe.contacts.doctype.address.address import get_company_address +from frappe.utils import cint + +from erpnext import get_default_company TAX_ACCOUNT_HEAD = frappe.db.get_single_value("TaxJar Settings", "tax_account_head") SHIP_ACCOUNT_HEAD = frappe.db.get_single_value("TaxJar Settings", "shipping_account_head") @@ -14,6 +15,10 @@ TAXJAR_CALCULATE_TAX = frappe.db.get_single_value("TaxJar Settings", "taxjar_cal SUPPORTED_COUNTRY_CODES = ["AT", "AU", "BE", "BG", "CA", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB", "GR", "HR", "HU", "IE", "IT", "LT", "LU", "LV", "MT", "NL", "PL", "PT", "RO", "SE", "SI", "SK", "US"] +SUPPORTED_STATE_CODES = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', + 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', + 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', + 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] def get_client(): @@ -27,7 +32,11 @@ def get_client(): api_url = taxjar.SANDBOX_API_URL if api_key and api_url: - return taxjar.Client(api_key=api_key, api_url=api_url) + client = taxjar.Client(api_key=api_key, api_url=api_url) + client.set_api_config('headers', { + 'x-api-version': '2020-08-07' + }) + return client def create_transaction(doc, method): @@ -57,7 +66,10 @@ def create_transaction(doc, method): tax_dict['amount'] = doc.total + tax_dict['shipping'] try: - client.create_order(tax_dict) + if doc.is_return: + client.create_refund(tax_dict) + else: + client.create_order(tax_dict) except taxjar.exceptions.TaxJarResponseError as err: frappe.throw(_(sanitize_error_response(err))) except Exception as ex: @@ -89,13 +101,15 @@ def get_tax_data(doc): to_country_code = frappe.db.get_value("Country", to_address.country, "code") to_country_code = to_country_code.upper() - if to_country_code not in SUPPORTED_COUNTRY_CODES: - return - shipping = sum([tax.tax_amount for tax in doc.taxes if tax.account_head == SHIP_ACCOUNT_HEAD]) - if to_shipping_state is not None: - to_shipping_state = get_iso_3166_2_state_code(to_address) + line_items = [get_line_item_dict(item) for item in doc.items] + + if from_shipping_state not in SUPPORTED_STATE_CODES: + from_shipping_state = get_state_code(from_address, 'Company') + + if to_shipping_state not in SUPPORTED_STATE_CODES: + to_shipping_state = get_state_code(to_address, 'Shipping') tax_dict = { 'from_country': from_country_code, @@ -109,11 +123,29 @@ def get_tax_data(doc): 'to_street': to_address.address_line1, 'to_state': to_shipping_state, 'shipping': shipping, - 'amount': doc.net_total + 'amount': doc.net_total, + 'plugin': 'erpnext', + 'line_items': line_items } - return tax_dict +def get_state_code(address, location): + if address is not None: + state_code = get_iso_3166_2_state_code(address) + if state_code not in SUPPORTED_STATE_CODES: + frappe.throw(_("Please enter a valid State in the {0} Address").format(location)) + else: + frappe.throw(_("Please enter a valid State in the {0} Address").format(location)) + + return state_code + +def get_line_item_dict(item): + return dict( + id = item.get('idx'), + quantity = item.get('qty'), + unit_price = item.get('rate'), + product_tax_code = item.get('product_tax_category') + ) def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: @@ -122,17 +154,7 @@ def set_sales_tax(doc, method): if not doc.items: return - # if the party is exempt from sales tax, then set all tax account heads to zero - sales_tax_exempted = hasattr(doc, "exempt_from_sales_tax") and doc.exempt_from_sales_tax \ - or frappe.db.has_column("Customer", "exempt_from_sales_tax") and frappe.db.get_value("Customer", doc.customer, "exempt_from_sales_tax") - - if sales_tax_exempted: - for tax in doc.taxes: - if tax.account_head == TAX_ACCOUNT_HEAD: - tax.tax_amount = 0 - break - - doc.run_method("calculate_taxes_and_totals") + if check_sales_tax_exemption(doc): return tax_dict = get_tax_data(doc) @@ -143,7 +165,6 @@ def set_sales_tax(doc, method): return tax_data = validate_tax_request(tax_dict) - if tax_data is not None: if not tax_data.amount_to_collect: setattr(doc, "taxes", [tax for tax in doc.taxes if tax.account_head != TAX_ACCOUNT_HEAD]) @@ -163,9 +184,28 @@ def set_sales_tax(doc, method): "account_head": TAX_ACCOUNT_HEAD, "tax_amount": tax_data.amount_to_collect }) + # Assigning values to tax_collectable and taxable_amount fields in sales item table + for item in tax_data.breakdown.line_items: + doc.get('items')[cint(item.id)-1].tax_collectable = item.tax_collectable + doc.get('items')[cint(item.id)-1].taxable_amount = item.taxable_amount doc.run_method("calculate_taxes_and_totals") +def check_sales_tax_exemption(doc): + # if the party is exempt from sales tax, then set all tax account heads to zero + sales_tax_exempted = hasattr(doc, "exempt_from_sales_tax") and doc.exempt_from_sales_tax \ + or frappe.db.has_column("Customer", "exempt_from_sales_tax") \ + and frappe.db.get_value("Customer", doc.customer, "exempt_from_sales_tax") + + if sales_tax_exempted: + for tax in doc.taxes: + if tax.account_head == TAX_ACCOUNT_HEAD: + tax.tax_amount = 0 + break + doc.run_method("calculate_taxes_and_totals") + return True + else: + return False def validate_tax_request(tax_dict): """Return the sales tax that should be collected for a given order.""" @@ -200,6 +240,8 @@ def get_shipping_address_details(doc): if doc.shipping_address_name: shipping_address = frappe.get_doc("Address", doc.shipping_address_name) + elif doc.customer_address: + shipping_address = frappe.get_doc("Address", doc.customer_address_name) else: shipping_address = get_company_address_details(doc) diff --git a/erpnext/erpnext_integrations/utils.py b/erpnext/erpnext_integrations/utils.py index caafc0821e..bb5c0c2dd1 100644 --- a/erpnext/erpnext_integrations/utils.py +++ b/erpnext/erpnext_integrations/utils.py @@ -1,10 +1,16 @@ from __future__ import unicode_literals + +import base64 +import hashlib +import hmac + import frappe from frappe import _ -import base64, hashlib, hmac from six.moves.urllib.parse import urlparse + from erpnext import get_default_company + def validate_webhooks_request(doctype, hmac_key, secret_key='secret'): def innerfn(fn): settings = frappe.get_doc(doctype) diff --git a/erpnext/exceptions.py b/erpnext/exceptions.py index 04291cd5bd..9c6b13f803 100644 --- a/erpnext/exceptions.py +++ b/erpnext/exceptions.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + import frappe + # accounts class PartyFrozen(frappe.ValidationError): pass class InvalidAccountCurrency(frappe.ValidationError): pass diff --git a/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json b/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json index a59f149ee5..6803528156 100644 --- a/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json +++ b/erpnext/healthcare/dashboard_chart/clinical_procedures/clinical_procedures.json @@ -12,15 +12,15 @@ "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 13:22:47.008622", - "modified": "2020-07-22 13:36:48.114479", + "last_synced_on": "2021-01-30 21:03:30.086891", + "modified": "2021-02-01 13:36:04.469863", "modified_by": "Administrator", "module": "Healthcare", "name": "Clinical Procedures", "number_of_groups": 0, "owner": "Administrator", "timeseries": 0, - "type": "Percentage", + "type": "Bar", "use_report_chart": 0, "y_axis": [] } \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json b/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json index 6d560f74bf..dae9db19b8 100644 --- a/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json +++ b/erpnext/healthcare/dashboard_chart/clinical_procedures_status/clinical_procedures_status.json @@ -12,15 +12,15 @@ "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 13:22:46.691764", - "modified": "2020-07-22 13:40:17.215775", + "last_synced_on": "2021-02-01 13:36:38.787783", + "modified": "2021-02-01 13:37:18.718275", "modified_by": "Administrator", "module": "Healthcare", "name": "Clinical Procedures Status", "number_of_groups": 0, "owner": "Administrator", "timeseries": 0, - "type": "Pie", + "type": "Bar", "use_report_chart": 0, "y_axis": [] } \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json b/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json index 0195aac8b7..82145d6024 100644 --- a/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json +++ b/erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json @@ -5,21 +5,22 @@ "docstatus": 0, "doctype": "Dashboard Chart", "document_type": "Patient Encounter Diagnosis", + "dynamic_filters_json": "", "filters_json": "[]", "group_by_based_on": "diagnosis", "group_by_type": "Count", "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 13:22:47.895521", - "modified": "2020-07-22 13:43:32.369481", + "last_synced_on": "2021-01-30 21:03:33.729487", + "modified": "2021-02-01 13:34:57.385335", "modified_by": "Administrator", "module": "Healthcare", "name": "Diagnoses", "number_of_groups": 0, "owner": "Administrator", "timeseries": 0, - "type": "Percentage", + "type": "Bar", "use_report_chart": 0, "y_axis": [] } \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json b/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json index 052483533e..70293b158e 100644 --- a/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json +++ b/erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json @@ -12,15 +12,15 @@ "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 13:22:47.344055", - "modified": "2020-07-22 13:37:34.490129", + "last_synced_on": "2021-01-30 21:03:28.272914", + "modified": "2021-02-01 13:36:08.391433", "modified_by": "Administrator", "module": "Healthcare", "name": "Lab Tests", "number_of_groups": 0, "owner": "Administrator", "timeseries": 0, - "type": "Percentage", + "type": "Bar", "use_report_chart": 0, "y_axis": [] } \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json b/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json index 8fc86a1c59..65e5472aa1 100644 --- a/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json +++ b/erpnext/healthcare/dashboard_chart/symptoms/symptoms.json @@ -12,15 +12,15 @@ "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 13:22:47.296748", - "modified": "2020-07-22 13:40:59.655129", + "last_synced_on": "2021-01-30 21:03:32.067473", + "modified": "2021-02-01 13:35:30.953718", "modified_by": "Administrator", "module": "Healthcare", "name": "Symptoms", "number_of_groups": 0, "owner": "Administrator", "timeseries": 0, - "type": "Percentage", + "type": "Bar", "use_report_chart": 0, "y_axis": [] } \ No newline at end of file diff --git a/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.py b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.py index eca7143e68..9c71ce86ac 100644 --- a/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.py +++ b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.py @@ -2,9 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals + import frappe from frappe.utils.dashboard import cache_source + @frappe.whitelist() @cache_source def get(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None, diff --git a/erpnext/healthcare/doctype/antibiotic/antibiotic.py b/erpnext/healthcare/doctype/antibiotic/antibiotic.py index 8236c8ab73..6a4b7648b9 100644 --- a/erpnext/healthcare/doctype/antibiotic/antibiotic.py +++ b/erpnext/healthcare/doctype/antibiotic/antibiotic.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class Antibiotic(Document): pass diff --git a/erpnext/healthcare/doctype/antibiotic/test_antibiotic.py b/erpnext/healthcare/doctype/antibiotic/test_antibiotic.py index 6ac4f4f9fc..b6ec79f7ff 100644 --- a/erpnext/healthcare/doctype/antibiotic/test_antibiotic.py +++ b/erpnext/healthcare/doctype/antibiotic/test_antibiotic.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestAntibiotic(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/appointment_type/appointment_type.py b/erpnext/healthcare/doctype/appointment_type/appointment_type.py index 67a24f31e0..94d023f2c3 100644 --- a/erpnext/healthcare/doctype/appointment_type/appointment_type.py +++ b/erpnext/healthcare/doctype/appointment_type/appointment_type.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document + import frappe +from frappe.model.document import Document + class AppointmentType(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py b/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py index 845e4466c1..b9c6edbb19 100644 --- a/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py +++ b/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'appointment_type', diff --git a/erpnext/healthcare/doctype/appointment_type_service_item/appointment_type_service_item.py b/erpnext/healthcare/doctype/appointment_type_service_item/appointment_type_service_item.py index b2e0e82bad..026d5d79fd 100644 --- a/erpnext/healthcare/doctype/appointment_type_service_item/appointment_type_service_item.py +++ b/erpnext/healthcare/doctype/appointment_type_service_item/appointment_type_service_item.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class AppointmentTypeServiceItem(Document): pass diff --git a/erpnext/healthcare/doctype/body_part/body_part.py b/erpnext/healthcare/doctype/body_part/body_part.py index 300493a52b..77e8dd90a0 100644 --- a/erpnext/healthcare/doctype/body_part/body_part.py +++ b/erpnext/healthcare/doctype/body_part/body_part.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class BodyPart(Document): pass diff --git a/erpnext/healthcare/doctype/body_part/test_body_part.py b/erpnext/healthcare/doctype/body_part/test_body_part.py index cb3a61150e..a81ba179bf 100644 --- a/erpnext/healthcare/doctype/body_part/test_body_part.py +++ b/erpnext/healthcare/doctype/body_part/test_body_part.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestBodyPart(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/body_part_link/body_part_link.py b/erpnext/healthcare/doctype/body_part_link/body_part_link.py index 0371529769..07488f0117 100644 --- a/erpnext/healthcare/doctype/body_part_link/body_part_link.py +++ b/erpnext/healthcare/doctype/body_part_link/body_part_link.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class BodyPartLink(Document): pass diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py index cbf89ee3bd..df4c2ef905 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py @@ -3,15 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import flt, nowdate, nowtime, cstr +from frappe.model.mapper import get_mapped_doc +from frappe.utils import flt, nowdate, nowtime + from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_account from erpnext.healthcare.doctype.lab_test.lab_test import create_sample_doc -from erpnext.stock.stock_ledger import get_previous_sle from erpnext.stock.get_item_details import get_item_details -from frappe.model.mapper import get_mapped_doc +from erpnext.stock.stock_ledger import get_previous_sle + class ClinicalProcedure(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py index 0326e5e9da..b5c3744204 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py @@ -4,8 +4,13 @@ from __future__ import unicode_literals import unittest + import frappe -from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_clinical_procedure_template + +from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import ( + create_clinical_procedure_template, + create_healthcare_docs, +) test_dependencies = ['Item'] diff --git a/erpnext/healthcare/doctype/clinical_procedure_item/clinical_procedure_item.py b/erpnext/healthcare/doctype/clinical_procedure_item/clinical_procedure_item.py index d59e517597..16c5369cfe 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_item/clinical_procedure_item.py +++ b/erpnext/healthcare/doctype/clinical_procedure_item/clinical_procedure_item.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class ClinicalProcedureItem(Document): pass diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py index 58194f10a8..16e0969ae4 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py @@ -3,11 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json + +import json + +import frappe from frappe import _ from frappe.model.document import Document from frappe.model.rename_doc import rename_doc + class ClinicalProcedureTemplate(Document): def validate(self): self.enable_disable_item() diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template_dashboard.py b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template_dashboard.py index 9aab5216e1..a69899d3ea 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template_dashboard.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'procedure_template', diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/test_clinical_procedure_template.py b/erpnext/healthcare/doctype/clinical_procedure_template/test_clinical_procedure_template.py index 62e138b8ed..f754c76341 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/test_clinical_procedure_template.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/test_clinical_procedure_template.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, earthians and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestClinicalProcedureTemplate(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/codification_table/codification_table.py b/erpnext/healthcare/doctype/codification_table/codification_table.py index ae29c03bbb..232d92ca9d 100644 --- a/erpnext/healthcare/doctype/codification_table/codification_table.py +++ b/erpnext/healthcare/doctype/codification_table/codification_table.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class CodificationTable(Document): pass diff --git a/erpnext/healthcare/doctype/complaint/complaint.py b/erpnext/healthcare/doctype/complaint/complaint.py index 717f9dbb4a..20e00f6b02 100644 --- a/erpnext/healthcare/doctype/complaint/complaint.py +++ b/erpnext/healthcare/doctype/complaint/complaint.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class Complaint(Document): pass diff --git a/erpnext/healthcare/doctype/complaint/test_complaint.py b/erpnext/healthcare/doctype/complaint/test_complaint.py index 2b9273a967..d3e10692b0 100644 --- a/erpnext/healthcare/doctype/complaint/test_complaint.py +++ b/erpnext/healthcare/doctype/complaint/test_complaint.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestComplaint(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/descriptive_test_result/descriptive_test_result.py b/erpnext/healthcare/doctype/descriptive_test_result/descriptive_test_result.py index 7ccf6b57aa..c08604694a 100644 --- a/erpnext/healthcare/doctype/descriptive_test_result/descriptive_test_result.py +++ b/erpnext/healthcare/doctype/descriptive_test_result/descriptive_test_result.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class DescriptiveTestResult(Document): pass diff --git a/erpnext/healthcare/doctype/descriptive_test_template/descriptive_test_template.py b/erpnext/healthcare/doctype/descriptive_test_template/descriptive_test_template.py index 281f32db7f..84184fbcca 100644 --- a/erpnext/healthcare/doctype/descriptive_test_template/descriptive_test_template.py +++ b/erpnext/healthcare/doctype/descriptive_test_template/descriptive_test_template.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class DescriptiveTestTemplate(Document): pass diff --git a/erpnext/healthcare/doctype/diagnosis/diagnosis.py b/erpnext/healthcare/doctype/diagnosis/diagnosis.py index f56e79062a..05add1b530 100644 --- a/erpnext/healthcare/doctype/diagnosis/diagnosis.py +++ b/erpnext/healthcare/doctype/diagnosis/diagnosis.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class Diagnosis(Document): pass diff --git a/erpnext/healthcare/doctype/dosage_form/dosage_form.py b/erpnext/healthcare/doctype/dosage_form/dosage_form.py index 046af08094..6b2d88b61b 100644 --- a/erpnext/healthcare/doctype/dosage_form/dosage_form.py +++ b/erpnext/healthcare/doctype/dosage_form/dosage_form.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class DosageForm(Document): pass diff --git a/erpnext/healthcare/doctype/dosage_form/test_dosage_form.py b/erpnext/healthcare/doctype/dosage_form/test_dosage_form.py index 81cfcf6f7d..0161b82ba3 100644 --- a/erpnext/healthcare/doctype/dosage_form/test_dosage_form.py +++ b/erpnext/healthcare/doctype/dosage_form/test_dosage_form.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestDosageForm(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/dosage_strength/dosage_strength.py b/erpnext/healthcare/doctype/dosage_strength/dosage_strength.py index e36a0160cf..9e74743a7c 100644 --- a/erpnext/healthcare/doctype/dosage_strength/dosage_strength.py +++ b/erpnext/healthcare/doctype/dosage_strength/dosage_strength.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class DosageStrength(Document): pass diff --git a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py index 68a2dc5d3c..744bdb03ef 100755 --- a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py +++ b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class DrugPrescription(Document): def get_quantity(self): quantity = 0 diff --git a/erpnext/healthcare/doctype/exercise/exercise.py b/erpnext/healthcare/doctype/exercise/exercise.py index efd89997fe..5d2b1f1a96 100644 --- a/erpnext/healthcare/doctype/exercise/exercise.py +++ b/erpnext/healthcare/doctype/exercise/exercise.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class Exercise(Document): pass diff --git a/erpnext/healthcare/doctype/exercise_difficulty_level/exercise_difficulty_level.py b/erpnext/healthcare/doctype/exercise_difficulty_level/exercise_difficulty_level.py index 17e97b8960..bbb297275f 100644 --- a/erpnext/healthcare/doctype/exercise_difficulty_level/exercise_difficulty_level.py +++ b/erpnext/healthcare/doctype/exercise_difficulty_level/exercise_difficulty_level.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class ExerciseDifficultyLevel(Document): pass diff --git a/erpnext/healthcare/doctype/exercise_difficulty_level/test_exercise_difficulty_level.py b/erpnext/healthcare/doctype/exercise_difficulty_level/test_exercise_difficulty_level.py index 80ef3a7de8..dcaea08aba 100644 --- a/erpnext/healthcare/doctype/exercise_difficulty_level/test_exercise_difficulty_level.py +++ b/erpnext/healthcare/doctype/exercise_difficulty_level/test_exercise_difficulty_level.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestExerciseDifficultyLevel(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/exercise_type/exercise_type.py b/erpnext/healthcare/doctype/exercise_type/exercise_type.py index ae44a2b77b..48eb6ba2d8 100644 --- a/erpnext/healthcare/doctype/exercise_type/exercise_type.py +++ b/erpnext/healthcare/doctype/exercise_type/exercise_type.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class ExerciseType(Document): def autoname(self): if self.difficulty_level: diff --git a/erpnext/healthcare/doctype/exercise_type/test_exercise_type.py b/erpnext/healthcare/doctype/exercise_type/test_exercise_type.py index bf217e893a..583aea911a 100644 --- a/erpnext/healthcare/doctype/exercise_type/test_exercise_type.py +++ b/erpnext/healthcare/doctype/exercise_type/test_exercise_type.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestExerciseType(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/exercise_type_step/exercise_type_step.py b/erpnext/healthcare/doctype/exercise_type_step/exercise_type_step.py index 13d7e5732f..412ef3225e 100644 --- a/erpnext/healthcare/doctype/exercise_type_step/exercise_type_step.py +++ b/erpnext/healthcare/doctype/exercise_type_step/exercise_type_step.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class ExerciseTypeStep(Document): pass diff --git a/erpnext/healthcare/doctype/fee_validity/fee_validity.py b/erpnext/healthcare/doctype/fee_validity/fee_validity.py index 59586e0c31..aa30becd33 100644 --- a/erpnext/healthcare/doctype/fee_validity/fee_validity.py +++ b/erpnext/healthcare/doctype/fee_validity/fee_validity.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -from frappe.model.document import Document -import frappe -from frappe.utils import getdate + import datetime +import frappe +from frappe.model.document import Document +from frappe.utils import getdate + + class FeeValidity(Document): def validate(self): self.update_status() diff --git a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py index 957f85211d..ce1947f5ba 100644 --- a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py +++ b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py @@ -3,11 +3,17 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import nowdate, add_days -from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_appointment, create_healthcare_service_items + +import frappe +from frappe.utils import add_days, nowdate + from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import ( + create_appointment, + create_healthcare_docs, + create_healthcare_service_items, +) test_dependencies = ["Company"] diff --git a/erpnext/healthcare/doctype/fee_validity_reference/fee_validity_reference.py b/erpnext/healthcare/doctype/fee_validity_reference/fee_validity_reference.py index c819280832..c03978aad1 100644 --- a/erpnext/healthcare/doctype/fee_validity_reference/fee_validity_reference.py +++ b/erpnext/healthcare/doctype/fee_validity_reference/fee_validity_reference.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class FeeValidityReference(Document): pass diff --git a/erpnext/healthcare/doctype/healthcare.py b/erpnext/healthcare/doctype/healthcare.py index 6fd2015fa2..f8e008e7d3 100644 --- a/erpnext/healthcare/doctype/healthcare.py +++ b/erpnext/healthcare/doctype/healthcare.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals + def get_data(): return [] diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py index 5da5a0657c..4550e7ab4c 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py @@ -3,13 +3,18 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document from frappe import _ -from erpnext.accounts.party import validate_party_accounts -from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address +from frappe.contacts.address_and_contact import ( + delete_contact_and_address, + load_address_and_contact, +) +from frappe.model.document import Document from frappe.model.naming import append_number_if_name_exists -from frappe.desk.reportview import build_match_conditions, get_filters_cond + +from erpnext.accounts.party import validate_party_accounts + class HealthcarePractitioner(Document): def onload(self): diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py index bcee44430a..8e0292e97c 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'heatmap': True, diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/test_healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/test_healthcare_practitioner.py index de8201b151..214bcd287a 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/test_healthcare_practitioner.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/test_healthcare_practitioner.py @@ -2,7 +2,9 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestHealthcarePractitioner(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/healthcare_schedule_time_slot/healthcare_schedule_time_slot.py b/erpnext/healthcare/doctype/healthcare_schedule_time_slot/healthcare_schedule_time_slot.py index e58ea53c2c..721da24adc 100644 --- a/erpnext/healthcare/doctype/healthcare_schedule_time_slot/healthcare_schedule_time_slot.py +++ b/erpnext/healthcare/doctype/healthcare_schedule_time_slot/healthcare_schedule_time_slot.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class HealthcareScheduleTimeSlot(Document): pass diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py index 989d426789..550b9fbff2 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py @@ -4,11 +4,12 @@ from __future__ import unicode_literals -from frappe.utils.nestedset import NestedSet -from frappe.utils import cint, cstr +import json + import frappe from frappe import _ -import json +from frappe.utils import cint, cstr +from frappe.utils.nestedset import NestedSet class HealthcareServiceUnit(NestedSet): @@ -30,7 +31,7 @@ class HealthcareServiceUnit(NestedSet): self.validate_one_root() def set_service_unit_properties(self): - if self.is_group: + if cint(self.is_group): self.allow_appointments = False self.overlap_appointments = False self.inpatient_occupancy = False diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/test_healthcare_service_unit.py b/erpnext/healthcare/doctype/healthcare_service_unit/test_healthcare_service_unit.py index bced2fe1f6..84197e56c5 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/test_healthcare_service_unit.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit/test_healthcare_service_unit.py @@ -5,5 +5,6 @@ from __future__ import unicode_literals import unittest + class TestHealthcareServiceUnit(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py index a318e50600..181cb529fc 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py @@ -3,11 +3,13 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document from frappe.model.rename_doc import rename_doc + class HealthcareServiceUnitType(Document): def validate(self): if self.allow_appointments and self.inpatient_occupancy: diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py index 0ac548b3ff..7421ec3b89 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'service_unit_type', diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py index 3ee3377b00..839e1d6a4d 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py @@ -2,9 +2,12 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + import frappe + class TestHealthcareServiceUnitType(unittest.TestCase): def test_item_creation(self): unit_type = get_unit_type() diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py index a16fceb74d..9ab8881766 100644 --- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py +++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import json + import frappe from frappe import _ -from frappe.model.document import Document from frappe.core.doctype.sms_settings.sms_settings import send_sms -import json +from frappe.model.document import Document + class HealthcareSettings(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/healthcare_settings/test_healthcare_settings.py b/erpnext/healthcare/doctype/healthcare_settings/test_healthcare_settings.py index 1b620d5f5d..af2f2b4c4f 100644 --- a/erpnext/healthcare/doctype/healthcare_settings/test_healthcare_settings.py +++ b/erpnext/healthcare/doctype/healthcare_settings/test_healthcare_settings.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestHealthcareSettings(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py index 3a299eda26..b28e37a9c3 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import flt, get_link_to_form, getdate, nowtime -from erpnext.stock.utils import get_latest_stock_qty +from frappe.utils import flt, get_link_to_form + from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_account +from erpnext.stock.utils import get_latest_stock_qty + class InpatientMedicationEntry(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry_dashboard.py b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry_dashboard.py index a4bec45596..ca9364d66a 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry_dashboard.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'against_imoe', diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/test_inpatient_medication_entry.py b/erpnext/healthcare/doctype/inpatient_medication_entry/test_inpatient_medication_entry.py index ff9e21252a..dde7739f7a 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/test_inpatient_medication_entry.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/test_inpatient_medication_entry.py @@ -3,14 +3,32 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import add_days, getdate, now_datetime -from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import create_patient, create_inpatient, get_healthcare_service_unit, mark_invoiced_inpatient_occupancy -from erpnext.healthcare.doctype.inpatient_record.inpatient_record import admit_patient, discharge_patient, schedule_discharge -from erpnext.healthcare.doctype.inpatient_medication_order.test_inpatient_medication_order import create_ipmo, create_ipme -from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import get_drug_shortage_map, make_difference_stock_entry + from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_account +from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import ( + get_drug_shortage_map, + make_difference_stock_entry, +) +from erpnext.healthcare.doctype.inpatient_medication_order.test_inpatient_medication_order import ( + create_ipme, + create_ipmo, +) +from erpnext.healthcare.doctype.inpatient_record.inpatient_record import ( + admit_patient, + discharge_patient, + schedule_discharge, +) +from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import ( + create_inpatient, + create_patient, + get_healthcare_service_unit, + mark_invoiced_inpatient_occupancy, +) + class TestInpatientMedicationEntry(unittest.TestCase): def setUp(self): diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry_detail/inpatient_medication_entry_detail.py b/erpnext/healthcare/doctype/inpatient_medication_entry_detail/inpatient_medication_entry_detail.py index 644898d9ed..91734312d4 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry_detail/inpatient_medication_entry_detail.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry_detail/inpatient_medication_entry_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class InpatientMedicationEntryDetail(Document): pass diff --git a/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.py b/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.py index b379e98fe1..2e6d73208f 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.py +++ b/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import cstr + from erpnext.healthcare.doctype.patient_encounter.patient_encounter import get_prescription_dates + class InpatientMedicationOrder(Document): def validate(self): self.validate_inpatient() diff --git a/erpnext/healthcare/doctype/inpatient_medication_order/test_inpatient_medication_order.py b/erpnext/healthcare/doctype/inpatient_medication_order/test_inpatient_medication_order.py index 798976283b..477f8c9761 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_order/test_inpatient_medication_order.py +++ b/erpnext/healthcare/doctype/inpatient_medication_order/test_inpatient_medication_order.py @@ -3,11 +3,23 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import add_days, getdate, now_datetime -from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import create_patient, create_inpatient, get_healthcare_service_unit, mark_invoiced_inpatient_occupancy -from erpnext.healthcare.doctype.inpatient_record.inpatient_record import admit_patient, discharge_patient, schedule_discharge + +from erpnext.healthcare.doctype.inpatient_record.inpatient_record import ( + admit_patient, + discharge_patient, + schedule_discharge, +) +from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import ( + create_inpatient, + create_patient, + get_healthcare_service_unit, + mark_invoiced_inpatient_occupancy, +) + class TestInpatientMedicationOrder(unittest.TestCase): def setUp(self): diff --git a/erpnext/healthcare/doctype/inpatient_medication_order_entry/inpatient_medication_order_entry.py b/erpnext/healthcare/doctype/inpatient_medication_order_entry/inpatient_medication_order_entry.py index ebfe366346..15800ad15f 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_order_entry/inpatient_medication_order_entry.py +++ b/erpnext/healthcare/doctype/inpatient_medication_order_entry/inpatient_medication_order_entry.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class InpatientMedicationOrderEntry(Document): pass diff --git a/erpnext/healthcare/doctype/inpatient_occupancy/inpatient_occupancy.py b/erpnext/healthcare/doctype/inpatient_occupancy/inpatient_occupancy.py index 52de25b457..c8f3296d0d 100644 --- a/erpnext/healthcare/doctype/inpatient_occupancy/inpatient_occupancy.py +++ b/erpnext/healthcare/doctype/inpatient_occupancy/inpatient_occupancy.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class InpatientOccupancy(Document): pass diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py index f4d1eaf2e3..2e26677db5 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py @@ -3,11 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json + +import json + +import frappe from frappe import _ -from frappe.utils import today, now_datetime, getdate, get_datetime, get_link_to_form -from frappe.model.document import Document from frappe.desk.reportview import get_match_cond +from frappe.model.document import Document +from frappe.utils import get_datetime, get_link_to_form, getdate, now_datetime, today + class InpatientRecord(Document): def after_insert(self): diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record_dashboard.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record_dashboard.py index 92cc6103f4..0f4adce4ed 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record_dashboard.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'inpatient_record', diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py index b4a961264f..58934e6a03 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -3,14 +3,21 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest + +import frappe from frappe.utils import now_datetime, today from frappe.utils.make_random import get_random -from erpnext.healthcare.doctype.inpatient_record.inpatient_record import admit_patient, discharge_patient, schedule_discharge + +from erpnext.healthcare.doctype.inpatient_record.inpatient_record import ( + admit_patient, + discharge_patient, + schedule_discharge, +) from erpnext.healthcare.doctype.lab_test.test_lab_test import create_patient_encounter from erpnext.healthcare.utils import get_encounters_to_invoice + class TestInpatientRecord(unittest.TestCase): def test_admit_and_discharge(self): frappe.db.sql("""delete from `tabInpatient Record`""") diff --git a/erpnext/healthcare/doctype/lab_prescription/lab_prescription.py b/erpnext/healthcare/doctype/lab_prescription/lab_prescription.py index b788a0db7e..a3f9aa24c4 100644 --- a/erpnext/healthcare/doctype/lab_prescription/lab_prescription.py +++ b/erpnext/healthcare/doctype/lab_prescription/lab_prescription.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class LabPrescription(Document): pass diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py index 4b57cd073d..7db497c24d 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.py +++ b/erpnext/healthcare/doctype/lab_test/lab_test.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import getdate, cstr, get_link_to_form +from frappe.utils import get_link_to_form, getdate + class LabTest(Document): def validate(self): @@ -34,7 +36,7 @@ class LabTest(Document): frappe.db.set_value('Lab Prescription', self.prescription, 'lab_test_created', 1) if frappe.db.get_value('Lab Prescription', self.prescription, 'invoiced'): self.invoiced = True - if not self.lab_test_name and self.template: + if self.template: self.load_test_from_template() self.reload() @@ -48,9 +50,9 @@ class LabTest(Document): if item.result_value and item.secondary_uom and item.conversion_factor: try: item.secondary_uom_result = float(item.result_value) * float(item.conversion_factor) - except: + except Exception: item.secondary_uom_result = '' - frappe.msgprint(_('Row #{0}: Result for Secondary UOM not calculated'.format(item.idx)), title = _('Warning')) + frappe.msgprint(_('Row #{0}: Result for Secondary UOM not calculated').format(item.idx), title = _('Warning')) def validate_result_values(self): if self.normal_test_items: @@ -229,9 +231,9 @@ def create_sample_doc(template, patient, invoice, company = None): sample_collection = frappe.get_doc('Sample Collection', sample_exists[0][0]) quantity = int(sample_collection.sample_qty) + int(template.sample_qty) if template.sample_details: - sample_details = sample_collection.sample_details + '\n-\n' + _('Test: ') + sample_details = sample_collection.sample_details + '\n-\n' + _('Test :') sample_details += (template.get('lab_test_name') or template.get('template')) + '\n' - sample_details += _('Collection Details: ') + '\n\t' + template.sample_details + sample_details += _('Collection Details:') + '\n\t' + template.sample_details frappe.db.set_value('Sample Collection', sample_collection.name, 'sample_details', sample_details) frappe.db.set_value('Sample Collection', sample_collection.name, 'sample_qty', quantity) diff --git a/erpnext/healthcare/doctype/lab_test/test_lab_test.py b/erpnext/healthcare/doctype/lab_test/test_lab_test.py index c9f0029ed8..da10bd86bd 100644 --- a/erpnext/healthcare/doctype/lab_test/test_lab_test.py +++ b/erpnext/healthcare/doctype/lab_test/test_lab_test.py @@ -2,13 +2,22 @@ # Copyright (c) 2015, ESS LLP and Contributors # See license.txt from __future__ import unicode_literals + import unittest + import frappe from frappe.utils import getdate, nowtime -from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_patient + +from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import ( + get_income_account, + get_receivable_account, +) from erpnext.healthcare.doctype.lab_test.lab_test import create_multiple -from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account -from erpnext.healthcare.doctype.patient_medical_record.test_patient_medical_record import create_lab_test_template as create_blood_test_template +from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_patient +from erpnext.healthcare.doctype.patient_medical_record.test_patient_medical_record import ( + create_lab_test_template as create_blood_test_template, +) + class TestLabTest(unittest.TestCase): def test_lab_test_item(self): diff --git a/erpnext/healthcare/doctype/lab_test_group_template/lab_test_group_template.py b/erpnext/healthcare/doctype/lab_test_group_template/lab_test_group_template.py index 1e2cef4e18..2e3c4093c7 100644 --- a/erpnext/healthcare/doctype/lab_test_group_template/lab_test_group_template.py +++ b/erpnext/healthcare/doctype/lab_test_group_template/lab_test_group_template.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class LabTestGroupTemplate(Document): pass diff --git a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.py b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.py index 4c66b7276b..3a765fe243 100644 --- a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.py +++ b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class LabTestSample(Document): pass diff --git a/erpnext/healthcare/doctype/lab_test_sample/test_lab_test_sample.py b/erpnext/healthcare/doctype/lab_test_sample/test_lab_test_sample.py index 2bc56bd324..8896572d78 100644 --- a/erpnext/healthcare/doctype/lab_test_sample/test_lab_test_sample.py +++ b/erpnext/healthcare/doctype/lab_test_sample/test_lab_test_sample.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestLabTestSample(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py index 543dee27eb..c052693d04 100644 --- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py +++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py @@ -3,10 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json + +import json + +import frappe +from frappe import _ from frappe.model.document import Document from frappe.model.rename_doc import rename_doc -from frappe import _ + class LabTestTemplate(Document): def after_insert(self): diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_dashboard.py b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_dashboard.py index 94dfeea7a4..a4f9d4b714 100644 --- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_dashboard.py +++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'template', diff --git a/erpnext/healthcare/doctype/lab_test_template/test_lab_test_template.py b/erpnext/healthcare/doctype/lab_test_template/test_lab_test_template.py index 4c9f55a839..8d8ac64750 100644 --- a/erpnext/healthcare/doctype/lab_test_template/test_lab_test_template.py +++ b/erpnext/healthcare/doctype/lab_test_template/test_lab_test_template.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, ESS and Contributors # See license.txt from __future__ import unicode_literals + import unittest # test_records = frappe.get_test_records('Lab Test Template') diff --git a/erpnext/healthcare/doctype/lab_test_uom/lab_test_uom.py b/erpnext/healthcare/doctype/lab_test_uom/lab_test_uom.py index 7ce8d2d1c8..ce11c0ffce 100644 --- a/erpnext/healthcare/doctype/lab_test_uom/lab_test_uom.py +++ b/erpnext/healthcare/doctype/lab_test_uom/lab_test_uom.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class LabTestUOM(Document): pass diff --git a/erpnext/healthcare/doctype/lab_test_uom/test_lab_test_uom.py b/erpnext/healthcare/doctype/lab_test_uom/test_lab_test_uom.py index 0b3f516497..9fe2de51a6 100644 --- a/erpnext/healthcare/doctype/lab_test_uom/test_lab_test_uom.py +++ b/erpnext/healthcare/doctype/lab_test_uom/test_lab_test_uom.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, ESS and Contributors # See license.txt from __future__ import unicode_literals + import unittest # test_records = frappe.get_test_records('Lab Test UOM') diff --git a/erpnext/healthcare/doctype/medical_code/medical_code.py b/erpnext/healthcare/doctype/medical_code/medical_code.py index 0deaac38ca..4ed3d31e90 100644 --- a/erpnext/healthcare/doctype/medical_code/medical_code.py +++ b/erpnext/healthcare/doctype/medical_code/medical_code.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class MedicalCode(Document): def autoname(self): self.name = self.medical_code_standard+" "+self.code diff --git a/erpnext/healthcare/doctype/medical_code/test_medical_code.py b/erpnext/healthcare/doctype/medical_code/test_medical_code.py index b1e0402790..7584b050a6 100644 --- a/erpnext/healthcare/doctype/medical_code/test_medical_code.py +++ b/erpnext/healthcare/doctype/medical_code/test_medical_code.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestMedicalCode(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/medical_code_standard/medical_code_standard.py b/erpnext/healthcare/doctype/medical_code_standard/medical_code_standard.py index 7b2731c1de..be0ea8922e 100644 --- a/erpnext/healthcare/doctype/medical_code_standard/medical_code_standard.py +++ b/erpnext/healthcare/doctype/medical_code_standard/medical_code_standard.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class MedicalCodeStandard(Document): pass diff --git a/erpnext/healthcare/doctype/medical_code_standard/test_medical_code_standard.py b/erpnext/healthcare/doctype/medical_code_standard/test_medical_code_standard.py index fde095d809..3b046e360f 100644 --- a/erpnext/healthcare/doctype/medical_code_standard/test_medical_code_standard.py +++ b/erpnext/healthcare/doctype/medical_code_standard/test_medical_code_standard.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestMedicalCodeStandard(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/medical_department/medical_department.py b/erpnext/healthcare/doctype/medical_department/medical_department.py index 0f2d4fc5f9..7be5a1ade3 100644 --- a/erpnext/healthcare/doctype/medical_department/medical_department.py +++ b/erpnext/healthcare/doctype/medical_department/medical_department.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class MedicalDepartment(Document): pass diff --git a/erpnext/healthcare/doctype/medical_department/test_medical_department.py b/erpnext/healthcare/doctype/medical_department/test_medical_department.py index 543750a7e7..6435a23e92 100644 --- a/erpnext/healthcare/doctype/medical_department/test_medical_department.py +++ b/erpnext/healthcare/doctype/medical_department/test_medical_department.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, ESS LLP and Contributors # See license.txt from __future__ import unicode_literals + import unittest # test_records = frappe.get_test_records('Medical Department') diff --git a/erpnext/healthcare/doctype/normal_test_result/normal_test_result.py b/erpnext/healthcare/doctype/normal_test_result/normal_test_result.py index 63abf0297e..e72f7269fc 100644 --- a/erpnext/healthcare/doctype/normal_test_result/normal_test_result.py +++ b/erpnext/healthcare/doctype/normal_test_result/normal_test_result.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class NormalTestResult(Document): pass diff --git a/erpnext/healthcare/doctype/normal_test_template/normal_test_template.py b/erpnext/healthcare/doctype/normal_test_template/normal_test_template.py index bc2c991484..9df48559cd 100644 --- a/erpnext/healthcare/doctype/normal_test_template/normal_test_template.py +++ b/erpnext/healthcare/doctype/normal_test_template/normal_test_template.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class NormalTestTemplate(Document): pass diff --git a/erpnext/healthcare/doctype/organism/organism.py b/erpnext/healthcare/doctype/organism/organism.py index 1ead762c2f..dfb9c0dd0d 100644 --- a/erpnext/healthcare/doctype/organism/organism.py +++ b/erpnext/healthcare/doctype/organism/organism.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class Organism(Document): pass diff --git a/erpnext/healthcare/doctype/organism/test_organism.py b/erpnext/healthcare/doctype/organism/test_organism.py index ecb96650e1..9d7ea0ba33 100644 --- a/erpnext/healthcare/doctype/organism/test_organism.py +++ b/erpnext/healthcare/doctype/organism/test_organism.py @@ -2,7 +2,9 @@ # Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestOrganism(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/organism_test_item/organism_test_item.py b/erpnext/healthcare/doctype/organism_test_item/organism_test_item.py index 019a55b396..6bb8e8f4c0 100644 --- a/erpnext/healthcare/doctype/organism_test_item/organism_test_item.py +++ b/erpnext/healthcare/doctype/organism_test_item/organism_test_item.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class OrganismTestItem(Document): pass diff --git a/erpnext/healthcare/doctype/organism_test_result/organism_test_result.py b/erpnext/healthcare/doctype/organism_test_result/organism_test_result.py index 02393c2700..3428403e3c 100644 --- a/erpnext/healthcare/doctype/organism_test_result/organism_test_result.py +++ b/erpnext/healthcare/doctype/organism_test_result/organism_test_result.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class OrganismTestResult(Document): pass diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index 9dae1f68b0..970c000d00 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -3,18 +3,25 @@ # For license information, please see license.txt from __future__ import unicode_literals + +import dateutil import frappe from frappe import _ -from frappe.model.document import Document -from frappe.utils import cint, cstr, getdate -import dateutil from frappe.contacts.address_and_contact import load_address_and_contact from frappe.contacts.doctype.contact.contact import get_default_contact +from frappe.model.document import Document from frappe.model.naming import set_name_by_naming_series +from frappe.utils import cint, cstr, getdate from frappe.utils.nestedset import get_root_of + from erpnext import get_default_currency -from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account, send_registration_sms from erpnext.accounts.party import get_dashboard_info +from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import ( + get_income_account, + get_receivable_account, + send_registration_sms, +) + class Patient(Document): def onload(self): diff --git a/erpnext/healthcare/doctype/patient/patient_dashboard.py b/erpnext/healthcare/doctype/patient/patient_dashboard.py index 7f7cfa8e5b..a388b74f61 100644 --- a/erpnext/healthcare/doctype/patient/patient_dashboard.py +++ b/erpnext/healthcare/doctype/patient/patient_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'heatmap': True, diff --git a/erpnext/healthcare/doctype/patient/test_patient.py b/erpnext/healthcare/doctype/patient/test_patient.py index 9274b6f5e8..4b8c732646 100644 --- a/erpnext/healthcare/doctype/patient/test_patient.py +++ b/erpnext/healthcare/doctype/patient/test_patient.py @@ -4,9 +4,12 @@ from __future__ import unicode_literals import unittest + import frappe + from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_patient + class TestPatient(unittest.TestCase): def test_customer_created(self): frappe.db.sql("""delete from `tabPatient`""") diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index 36047c4838..dcbcda09d8 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -3,17 +3,28 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe -from frappe.model.document import Document -import json -from frappe.utils import getdate, get_time, flt -from frappe.model.mapper import get_mapped_doc -from frappe import _ + import datetime +import json + +import frappe +from frappe import _ from frappe.core.doctype.sms_settings.sms_settings import send_sms +from frappe.model.document import Document +from frappe.model.mapper import get_mapped_doc +from frappe.utils import flt, get_link_to_form, get_time, getdate + +from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import ( + get_income_account, + get_receivable_account, +) +from erpnext.healthcare.utils import ( + check_fee_validity, + get_service_item_and_practitioner_charge, + manage_fee_validity, +) from erpnext.hr.doctype.employee.employee import is_holiday -from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account -from erpnext.healthcare.utils import check_fee_validity, get_service_item_and_practitioner_charge, manage_fee_validity + class MaximumCapacityError(frappe.ValidationError): pass @@ -100,7 +111,9 @@ class PatientAppointment(Document): def validate_service_unit(self): if self.inpatient_record and self.service_unit: - from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import get_current_healthcare_service_unit + from erpnext.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import ( + get_current_healthcare_service_unit, + ) is_inpatient_occupancy_unit = frappe.db.get_value('Healthcare Service Unit', self.service_unit, 'inpatient_occupancy') @@ -333,17 +346,13 @@ def check_employee_wise_availability(date, practitioner_doc): def get_available_slots(practitioner_doc, date): - available_slots = [] - slot_details = [] + available_slots = slot_details = [] weekday = date.strftime('%A') practitioner = practitioner_doc.name for schedule_entry in practitioner_doc.practitioner_schedules: - if schedule_entry.schedule: - practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule) - else: - frappe.throw(_('{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner').format( - frappe.bold(practitioner)), title=_('Practitioner Schedule Not Found')) + validate_practitioner_schedules(schedule_entry, practitioner) + practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule) if practitioner_schedule: available_slots = [] @@ -386,6 +395,19 @@ def get_available_slots(practitioner_doc, date): return slot_details +def validate_practitioner_schedules(schedule_entry, practitioner): + if schedule_entry.schedule: + if not schedule_entry.service_unit: + frappe.throw(_('Practitioner {0} does not have a Service Unit set against the Practitioner Schedule {1}.').format( + get_link_to_form('Healthcare Practitioner', practitioner), frappe.bold(schedule_entry.schedule)), + title=_('Service Unit Not Found')) + + else: + frappe.throw(_('Practitioner {0} does not have a Practitioner Schedule assigned.').format( + get_link_to_form('Healthcare Practitioner', practitioner)), + title=_('Practitioner Schedule Not Found')) + + @frappe.whitelist() def update_status(appointment_id, status): frappe.db.set_value('Patient Appointment', appointment_id, 'status', status) diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment_dashboard.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment_dashboard.py index 085c4f6cbf..43c63c96e6 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment_dashboard.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'appointment', diff --git a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py index f5477c096a..8ca30b8cbe 100644 --- a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py @@ -2,12 +2,19 @@ # Copyright (c) 2015, ESS LLP and Contributors # See license.txt from __future__ import unicode_literals + import unittest + import frappe -from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status, make_encounter, check_payment_fields_reqd, check_is_new_patient -from frappe.utils import nowdate, add_days, now_datetime -from frappe.utils.make_random import get_random +from frappe.utils import add_days, now_datetime, nowdate + from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.healthcare.doctype.patient_appointment.patient_appointment import ( + check_is_new_patient, + check_payment_fields_reqd, + make_encounter, + update_status, +) class TestPatientAppointment(unittest.TestCase): @@ -66,7 +73,7 @@ class TestPatientAppointment(unittest.TestCase): medical_department = create_medical_department() frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0) frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1) - appointment_type = create_appointment_type() + appointment_type = create_appointment_type({'medical_department': medical_department}) appointment = create_appointment(patient, practitioner, add_days(nowdate(), 2), invoice=1, appointment_type=appointment_type.name, department=medical_department) @@ -91,9 +98,9 @@ class TestPatientAppointment(unittest.TestCase): 'op_consulting_charge': 300 }] appointment_type = create_appointment_type(args={ - 'name': 'Generic Appointment Type charge', - 'items': items - }) + 'name': 'Generic Appointment Type charge', + 'items': items + }) appointment = create_appointment(patient, practitioner, add_days(nowdate(), 2), invoice=1, appointment_type=appointment_type.name) @@ -131,9 +138,16 @@ class TestPatientAppointment(unittest.TestCase): self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'status'), 'Cancelled') def test_appointment_booking_for_admission_service_unit(self): - from erpnext.healthcare.doctype.inpatient_record.inpatient_record import admit_patient, discharge_patient, schedule_discharge - from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import \ - create_inpatient, get_healthcare_service_unit, mark_invoiced_inpatient_occupancy + from erpnext.healthcare.doctype.inpatient_record.inpatient_record import ( + admit_patient, + discharge_patient, + schedule_discharge, + ) + from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import ( + create_inpatient, + get_healthcare_service_unit, + mark_invoiced_inpatient_occupancy, + ) frappe.db.sql("""delete from `tabInpatient Record`""") patient, practitioner = create_healthcare_docs() @@ -157,9 +171,16 @@ class TestPatientAppointment(unittest.TestCase): discharge_patient(ip_record1) def test_invalid_healthcare_service_unit_validation(self): - from erpnext.healthcare.doctype.inpatient_record.inpatient_record import admit_patient, discharge_patient, schedule_discharge - from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import \ - create_inpatient, get_healthcare_service_unit, mark_invoiced_inpatient_occupancy + from erpnext.healthcare.doctype.inpatient_record.inpatient_record import ( + admit_patient, + discharge_patient, + schedule_discharge, + ) + from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import ( + create_inpatient, + get_healthcare_service_unit, + mark_invoiced_inpatient_occupancy, + ) frappe.db.sql("""delete from `tabInpatient Record`""") patient, practitioner = create_healthcare_docs() @@ -259,7 +280,10 @@ class TestPatientAppointment(unittest.TestCase): self.assertRaises(OverlapError, appointment.save) def test_service_unit_capacity(self): - from erpnext.healthcare.doctype.patient_appointment.patient_appointment import MaximumCapacityError, OverlapError + from erpnext.healthcare.doctype.patient_appointment.patient_appointment import ( + MaximumCapacityError, + OverlapError, + ) practitioner = create_practitioner() capacity = 3 overlap_service_unit_type = create_service_unit_type(id=10, allow_appointments=1, overlap_appointments=1) @@ -408,9 +432,9 @@ def create_appointment_type(args=None): else: item = create_healthcare_service_items() items = [{ - 'medical_department': '_Test Medical Department', - 'op_consulting_charge_item': item, - 'op_consulting_charge': 200 + 'medical_department': args.get('medical_department') or '_Test Medical Department', + 'op_consulting_charge_item': item, + 'op_consulting_charge': 200 }] return frappe.get_doc({ 'doctype': 'Appointment Type', diff --git a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.py b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.py index 7bad20dffd..90cb30035d 100644 --- a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.py +++ b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc + class PatientAssessment(Document): def validate(self): self.set_total_score() diff --git a/erpnext/healthcare/doctype/patient_assessment/test_patient_assessment.py b/erpnext/healthcare/doctype/patient_assessment/test_patient_assessment.py index 3fda8550f6..0ffbd1f504 100644 --- a/erpnext/healthcare/doctype/patient_assessment/test_patient_assessment.py +++ b/erpnext/healthcare/doctype/patient_assessment/test_patient_assessment.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestPatientAssessment(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_detail/patient_assessment_detail.py b/erpnext/healthcare/doctype/patient_assessment_detail/patient_assessment_detail.py index 0519599ac0..4da679b889 100644 --- a/erpnext/healthcare/doctype/patient_assessment_detail/patient_assessment_detail.py +++ b/erpnext/healthcare/doctype/patient_assessment_detail/patient_assessment_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientAssessmentDetail(Document): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_parameter/patient_assessment_parameter.py b/erpnext/healthcare/doctype/patient_assessment_parameter/patient_assessment_parameter.py index b8e0074717..783c537848 100644 --- a/erpnext/healthcare/doctype/patient_assessment_parameter/patient_assessment_parameter.py +++ b/erpnext/healthcare/doctype/patient_assessment_parameter/patient_assessment_parameter.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientAssessmentParameter(Document): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_parameter/test_patient_assessment_parameter.py b/erpnext/healthcare/doctype/patient_assessment_parameter/test_patient_assessment_parameter.py index e722f9905e..f06fffb1ef 100644 --- a/erpnext/healthcare/doctype/patient_assessment_parameter/test_patient_assessment_parameter.py +++ b/erpnext/healthcare/doctype/patient_assessment_parameter/test_patient_assessment_parameter.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestPatientAssessmentParameter(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_sheet/patient_assessment_sheet.py b/erpnext/healthcare/doctype/patient_assessment_sheet/patient_assessment_sheet.py index 40da763013..4686e9e261 100644 --- a/erpnext/healthcare/doctype/patient_assessment_sheet/patient_assessment_sheet.py +++ b/erpnext/healthcare/doctype/patient_assessment_sheet/patient_assessment_sheet.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientAssessmentSheet(Document): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_template/patient_assessment_template.py b/erpnext/healthcare/doctype/patient_assessment_template/patient_assessment_template.py index 083cab5d01..e0d8fca37f 100644 --- a/erpnext/healthcare/doctype/patient_assessment_template/patient_assessment_template.py +++ b/erpnext/healthcare/doctype/patient_assessment_template/patient_assessment_template.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientAssessmentTemplate(Document): pass diff --git a/erpnext/healthcare/doctype/patient_assessment_template/test_patient_assessment_template.py b/erpnext/healthcare/doctype/patient_assessment_template/test_patient_assessment_template.py index 86dbd5438c..7d639cb6af 100644 --- a/erpnext/healthcare/doctype/patient_assessment_template/test_patient_assessment_template.py +++ b/erpnext/healthcare/doctype/patient_assessment_template/test_patient_assessment_template.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestPatientAssessmentTemplate(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py index 7a745ae468..2daa6c145c 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py @@ -3,12 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import cstr, getdate, add_days -from frappe import _ from frappe.model.mapper import get_mapped_doc +from frappe.utils import add_days, getdate class PatientEncounter(Document): diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter_dashboard.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter_dashboard.py index 39e54f5b35..3b64d98871 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter_dashboard.py +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'encounter', diff --git a/erpnext/healthcare/doctype/patient_encounter/test_patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/test_patient_encounter.py index 96976821a7..fa643a31d8 100644 --- a/erpnext/healthcare/doctype/patient_encounter/test_patient_encounter.py +++ b/erpnext/healthcare/doctype/patient_encounter/test_patient_encounter.py @@ -2,9 +2,11 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest import frappe + from erpnext.healthcare.doctype.patient_encounter.patient_encounter import PatientEncounter diff --git a/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py index 34b0cf8a58..e4d2069a50 100644 --- a/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py +++ b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientEncounterDiagnosis(Document): pass diff --git a/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py index bdb7bb218e..47f2a2be7e 100644 --- a/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py +++ b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientEncounterSymptom(Document): pass diff --git a/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.py b/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.py index f0a1f929f4..34e15dc46a 100644 --- a/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.py +++ b/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientHistoryCustomDocumentType(Document): pass diff --git a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py index 63b00859d7..b763591d3a 100644 --- a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py +++ b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py @@ -3,13 +3,17 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe import _ -from frappe.utils import cstr, cint from frappe.model.document import Document +from frappe.utils import cint, cstr + from erpnext.healthcare.page.patient_history.patient_history import get_patient_history_doctypes + class PatientHistorySettings(Document): def validate(self): self.validate_submittable_doctypes() @@ -18,7 +22,7 @@ class PatientHistorySettings(Document): def validate_submittable_doctypes(self): for entry in self.custom_doctypes: if not cint(frappe.db.get_value('DocType', entry.document_type, 'is_submittable')): - msg = _('Row #{0}: Document Type {1} is not submittable. ').format( + msg = _('Row #{0}: Document Type {1} is not submittable.').format( entry.idx, frappe.bold(entry.document_type)) msg += _('Patient Medical Record can only be created for submittable document types.') frappe.throw(msg) @@ -116,12 +120,12 @@ def set_subject_field(doc): fieldname = entry.get('fieldname') if entry.get('fieldtype') == 'Table' and doc.get(fieldname): formatted_value = get_formatted_value_for_table_field(doc.get(fieldname), meta.get_field(fieldname)) - subject += frappe.bold(_(entry.get('label')) + ': ') + '
' + cstr(formatted_value) + '
' + subject += frappe.bold(_(entry.get('label')) + ':') + '
' + cstr(formatted_value) + '
' else: if doc.get(fieldname): formatted_value = format_value(doc.get(fieldname), meta.get_field(fieldname), doc) - subject += frappe.bold(_(entry.get('label')) + ': ') + cstr(formatted_value) + '
' + subject += frappe.bold(_(entry.get('label')) + ':') + cstr(formatted_value) + '
' return subject diff --git a/erpnext/healthcare/doctype/patient_history_settings/test_patient_history_settings.py b/erpnext/healthcare/doctype/patient_history_settings/test_patient_history_settings.py index 33119d8185..c37a2adc36 100644 --- a/erpnext/healthcare/doctype/patient_history_settings/test_patient_history_settings.py +++ b/erpnext/healthcare/doctype/patient_history_settings/test_patient_history_settings.py @@ -3,12 +3,15 @@ # See license.txt from __future__ import unicode_literals -import frappe -import unittest import json +import unittest + +import frappe from frappe.utils import getdate, strip_html + from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_patient + class TestPatientHistorySettings(unittest.TestCase): def setUp(self): dt = create_custom_doctype() @@ -38,13 +41,12 @@ class TestPatientHistorySettings(unittest.TestCase): # tests for medical record creation of standard doctypes in test_patient_medical_record.py patient = create_patient() doc = create_doc(patient) - # check for medical record medical_rec = frappe.db.exists("Patient Medical Record", {"status": "Open", "reference_name": doc.name}) self.assertTrue(medical_rec) medical_rec = frappe.get_doc("Patient Medical Record", medical_rec) - expected_subject = "Date: {0}Rating: 3Feedback: Test Patient History Settings".format( + expected_subject = "Date:{0}Rating:3Feedback:Test Patient History Settings".format( frappe.utils.format_date(getdate())) self.assertEqual(strip_html(medical_rec.subject), expected_subject) self.assertEqual(medical_rec.patient, patient) diff --git a/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.py b/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.py index 2d94911855..b7dd09bc10 100644 --- a/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.py +++ b/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class PatientHistoryStandardDocumentType(Document): pass diff --git a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.py b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.py index 35e42bd6bd..ac2cffa3e8 100644 --- a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.py +++ b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document + class PatientMedicalRecord(Document): def after_insert(self): if self.reference_doctype == "Patient Medical Record" : diff --git a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py index 5b7d8d62c8..099146c7ee 100644 --- a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py +++ b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py @@ -2,11 +2,20 @@ # Copyright (c) 2015, ESS LLP and Contributors # See license.txt from __future__ import unicode_literals + import unittest + import frappe from frappe.utils import nowdate -from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_encounter, create_healthcare_docs, create_appointment, create_medical_department + from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile +from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import ( + create_appointment, + create_encounter, + create_healthcare_docs, + create_medical_department, +) + class TestPatientMedicalRecord(unittest.TestCase): def setUp(self): diff --git a/erpnext/healthcare/doctype/patient_relation/patient_relation.py b/erpnext/healthcare/doctype/patient_relation/patient_relation.py index 150b96200d..17bc20940d 100644 --- a/erpnext/healthcare/doctype/patient_relation/patient_relation.py +++ b/erpnext/healthcare/doctype/patient_relation/patient_relation.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class PatientRelation(Document): pass diff --git a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.py b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.py index 8bd0937948..7fa31e5fb6 100644 --- a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.py +++ b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class PractitionerSchedule(Document): def autoname(self): self.name = self.schedule_name diff --git a/erpnext/healthcare/doctype/practitioner_schedule/test_practitioner_schedule.py b/erpnext/healthcare/doctype/practitioner_schedule/test_practitioner_schedule.py index 52638cb618..1ecaa47248 100644 --- a/erpnext/healthcare/doctype/practitioner_schedule/test_practitioner_schedule.py +++ b/erpnext/healthcare/doctype/practitioner_schedule/test_practitioner_schedule.py @@ -2,7 +2,9 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestPractitionerSchedule(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/practitioner_service_unit_schedule/practitioner_service_unit_schedule.py b/erpnext/healthcare/doctype/practitioner_service_unit_schedule/practitioner_service_unit_schedule.py index c18a4406ca..4eba1fbf6b 100644 --- a/erpnext/healthcare/doctype/practitioner_service_unit_schedule/practitioner_service_unit_schedule.py +++ b/erpnext/healthcare/doctype/practitioner_service_unit_schedule/practitioner_service_unit_schedule.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class PractitionerServiceUnitSchedule(Document): pass diff --git a/erpnext/healthcare/doctype/prescription_dosage/prescription_dosage.py b/erpnext/healthcare/doctype/prescription_dosage/prescription_dosage.py index dea263dca0..19f9b70bb6 100644 --- a/erpnext/healthcare/doctype/prescription_dosage/prescription_dosage.py +++ b/erpnext/healthcare/doctype/prescription_dosage/prescription_dosage.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class PrescriptionDosage(Document): pass diff --git a/erpnext/healthcare/doctype/prescription_dosage/test_prescription_dosage.py b/erpnext/healthcare/doctype/prescription_dosage/test_prescription_dosage.py index e61a418896..cabfd35e23 100644 --- a/erpnext/healthcare/doctype/prescription_dosage/test_prescription_dosage.py +++ b/erpnext/healthcare/doctype/prescription_dosage/test_prescription_dosage.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestPrescriptionDosage(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/prescription_duration/prescription_duration.py b/erpnext/healthcare/doctype/prescription_duration/prescription_duration.py index 96ddf8dafe..988276da74 100644 --- a/erpnext/healthcare/doctype/prescription_duration/prescription_duration.py +++ b/erpnext/healthcare/doctype/prescription_duration/prescription_duration.py @@ -3,9 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document from frappe.utils import cstr + class PrescriptionDuration(Document): def autoname(self): self.name = " ".join(filter(None, diff --git a/erpnext/healthcare/doctype/prescription_duration/test_prescription_duration.py b/erpnext/healthcare/doctype/prescription_duration/test_prescription_duration.py index fe5524c5aa..197bb3e7fb 100644 --- a/erpnext/healthcare/doctype/prescription_duration/test_prescription_duration.py +++ b/erpnext/healthcare/doctype/prescription_duration/test_prescription_duration.py @@ -2,7 +2,9 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals + import unittest + class TestPrescriptionDuration(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.py b/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.py index 62ea9f1a40..f4d29fa6a3 100644 --- a/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.py +++ b/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class ProcedurePrescription(Document): pass diff --git a/erpnext/healthcare/doctype/sample_collection/sample_collection.py b/erpnext/healthcare/doctype/sample_collection/sample_collection.py index 461f809507..7de6ac08ca 100644 --- a/erpnext/healthcare/doctype/sample_collection/sample_collection.py +++ b/erpnext/healthcare/doctype/sample_collection/sample_collection.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe +from frappe import _ from frappe.model.document import Document from frappe.utils import flt -from frappe import _ + class SampleCollection(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/sensitivity/sensitivity.py b/erpnext/healthcare/doctype/sensitivity/sensitivity.py index bf7c36b9d2..f61781d3f8 100644 --- a/erpnext/healthcare/doctype/sensitivity/sensitivity.py +++ b/erpnext/healthcare/doctype/sensitivity/sensitivity.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class Sensitivity(Document): pass diff --git a/erpnext/healthcare/doctype/sensitivity/test_sensitivity.py b/erpnext/healthcare/doctype/sensitivity/test_sensitivity.py index 1616d2decb..c772c72faf 100644 --- a/erpnext/healthcare/doctype/sensitivity/test_sensitivity.py +++ b/erpnext/healthcare/doctype/sensitivity/test_sensitivity.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, ESS and Contributors # See license.txt from __future__ import unicode_literals + import unittest # test_records = frappe.get_test_records('Sensitivity') diff --git a/erpnext/healthcare/doctype/sensitivity_test_result/sensitivity_test_result.py b/erpnext/healthcare/doctype/sensitivity_test_result/sensitivity_test_result.py index 64f1e6ca25..53f7acc4af 100644 --- a/erpnext/healthcare/doctype/sensitivity_test_result/sensitivity_test_result.py +++ b/erpnext/healthcare/doctype/sensitivity_test_result/sensitivity_test_result.py @@ -3,7 +3,9 @@ # For license information, please see license.txt from __future__ import unicode_literals + from frappe.model.document import Document + class SensitivityTestResult(Document): pass diff --git a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py index 983fba9f5f..4f96f6a706 100644 --- a/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py +++ b/erpnext/healthcare/doctype/therapy_plan/test_therapy_plan.py @@ -3,13 +3,23 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest -from frappe.utils import getdate, flt, nowdate + +import frappe +from frappe.utils import flt, getdate, nowdate + +from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import ( + create_appointment, + create_healthcare_docs, + create_medical_department, + create_patient, +) +from erpnext.healthcare.doctype.therapy_plan.therapy_plan import ( + make_sales_invoice, + make_therapy_session, +) from erpnext.healthcare.doctype.therapy_type.test_therapy_type import create_therapy_type -from erpnext.healthcare.doctype.therapy_plan.therapy_plan import make_therapy_session, make_sales_invoice -from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import \ - create_healthcare_docs, create_patient, create_appointment, create_medical_department + class TestTherapyPlan(unittest.TestCase): def test_creation_on_encounter_submission(self): @@ -31,7 +41,7 @@ class TestTherapyPlan(unittest.TestCase): self.assertEqual(frappe.db.get_value('Therapy Plan', plan.name, 'status'), 'Completed') patient, practitioner = create_healthcare_docs() - appointment = create_appointment(patient, practitioner, nowdate()) + appointment = create_appointment(patient, practitioner, nowdate()) session = make_therapy_session(plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name) session = frappe.get_doc(session) diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py index e209660434..6d63f39189 100644 --- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py +++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document from frappe.utils import flt, today + class TherapyPlan(Document): def validate(self): self.set_totals() diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan_dashboard.py b/erpnext/healthcare/doctype/therapy_plan/therapy_plan_dashboard.py index 6526acda15..25c8df1d6b 100644 --- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan_dashboard.py +++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'therapy_plan', diff --git a/erpnext/healthcare/doctype/therapy_plan_detail/therapy_plan_detail.py b/erpnext/healthcare/doctype/therapy_plan_detail/therapy_plan_detail.py index 44211f32e3..1842fc2197 100644 --- a/erpnext/healthcare/doctype/therapy_plan_detail/therapy_plan_detail.py +++ b/erpnext/healthcare/doctype/therapy_plan_detail/therapy_plan_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class TherapyPlanDetail(Document): pass diff --git a/erpnext/healthcare/doctype/therapy_plan_template/test_therapy_plan_template.py b/erpnext/healthcare/doctype/therapy_plan_template/test_therapy_plan_template.py index 33ee29db7d..cd3d5686bc 100644 --- a/erpnext/healthcare/doctype/therapy_plan_template/test_therapy_plan_template.py +++ b/erpnext/healthcare/doctype/therapy_plan_template/test_therapy_plan_template.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestTherapyPlanTemplate(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template.py b/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template.py index 635d4beb8d..f5512be207 100644 --- a/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template.py +++ b/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template.py @@ -3,11 +3,14 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe from frappe.model.document import Document from frappe.utils import cint, flt + from erpnext.healthcare.doctype.therapy_type.therapy_type import make_item_price + class TherapyPlanTemplate(Document): def after_insert(self): self.create_item_from_template() diff --git a/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template_dashboard.py b/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template_dashboard.py index c748fbfcb7..def5c482d1 100644 --- a/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template_dashboard.py +++ b/erpnext/healthcare/doctype/therapy_plan_template/therapy_plan_template_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'therapy_plan_template', diff --git a/erpnext/healthcare/doctype/therapy_plan_template_detail/therapy_plan_template_detail.py b/erpnext/healthcare/doctype/therapy_plan_template_detail/therapy_plan_template_detail.py index 7b979fe9fc..104c1bf28b 100644 --- a/erpnext/healthcare/doctype/therapy_plan_template_detail/therapy_plan_template_detail.py +++ b/erpnext/healthcare/doctype/therapy_plan_template_detail/therapy_plan_template_detail.py @@ -3,8 +3,10 @@ # For license information, please see license.txt from __future__ import unicode_literals + # import frappe from frappe.model.document import Document + class TherapyPlanTemplateDetail(Document): pass diff --git a/erpnext/healthcare/doctype/therapy_session/test_therapy_session.py b/erpnext/healthcare/doctype/therapy_session/test_therapy_session.py index 75bb8df196..e4afacf3f0 100644 --- a/erpnext/healthcare/doctype/therapy_session/test_therapy_session.py +++ b/erpnext/healthcare/doctype/therapy_session/test_therapy_session.py @@ -6,5 +6,6 @@ from __future__ import unicode_literals # import frappe import unittest + class TestTherapySession(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session.py b/erpnext/healthcare/doctype/therapy_session/therapy_session.py index 51f267f949..915e6e42f4 100644 --- a/erpnext/healthcare/doctype/therapy_session/therapy_session.py +++ b/erpnext/healthcare/doctype/therapy_session/therapy_session.py @@ -3,14 +3,20 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import datetime -from frappe.model.document import Document -from frappe.utils import get_time, flt -from frappe.model.mapper import get_mapped_doc + +import frappe from frappe import _ -from frappe.utils import cstr, getdate, get_link_to_form -from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account +from frappe.model.document import Document +from frappe.model.mapper import get_mapped_doc +from frappe.utils import flt, get_link_to_form, get_time, getdate + +from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import ( + get_income_account, + get_receivable_account, +) + class TherapySession(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session_dashboard.py b/erpnext/healthcare/doctype/therapy_session/therapy_session_dashboard.py index 9de7e29323..b8a37820ba 100644 --- a/erpnext/healthcare/doctype/therapy_session/therapy_session_dashboard.py +++ b/erpnext/healthcare/doctype/therapy_session/therapy_session_dashboard.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + from frappe import _ + def get_data(): return { 'fieldname': 'therapy_session', diff --git a/erpnext/healthcare/doctype/therapy_type/test_therapy_type.py b/erpnext/healthcare/doctype/therapy_type/test_therapy_type.py index 80fc83fd6c..23d542236b 100644 --- a/erpnext/healthcare/doctype/therapy_type/test_therapy_type.py +++ b/erpnext/healthcare/doctype/therapy_type/test_therapy_type.py @@ -3,9 +3,11 @@ # See license.txt from __future__ import unicode_literals -import frappe import unittest +import frappe + + class TestTherapyType(unittest.TestCase): def test_therapy_type_item(self): therapy_type = create_therapy_type() diff --git a/erpnext/healthcare/doctype/therapy_type/therapy_type.py b/erpnext/healthcare/doctype/therapy_type/therapy_type.py index 3f6a36a968..3517ef2c5a 100644 --- a/erpnext/healthcare/doctype/therapy_type/therapy_type.py +++ b/erpnext/healthcare/doctype/therapy_type/therapy_type.py @@ -3,12 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe import _ -from frappe.utils import cint from frappe.model.document import Document from frappe.model.rename_doc import rename_doc +from frappe.utils import cint + class TherapyType(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/treatment_plan_template/test_treatment_plan_template.py b/erpnext/healthcare/doctype/treatment_plan_template/test_treatment_plan_template.py index 21ede7129f..b8a1dd7786 100644 --- a/erpnext/healthcare/doctype/treatment_plan_template/test_treatment_plan_template.py +++ b/erpnext/healthcare/doctype/treatment_plan_template/test_treatment_plan_template.py @@ -4,5 +4,6 @@ # import frappe import unittest + class TestTreatmentPlanTemplate(unittest.TestCase): pass diff --git a/erpnext/healthcare/doctype/treatment_plan_template/treatment_plan_template.py b/erpnext/healthcare/doctype/treatment_plan_template/treatment_plan_template.py index a92e2668fe..dbe0e9ae5f 100644 --- a/erpnext/healthcare/doctype/treatment_plan_template/treatment_plan_template.py +++ b/erpnext/healthcare/doctype/treatment_plan_template/treatment_plan_template.py @@ -5,6 +5,7 @@ import frappe from frappe import _ from frappe.model.document import Document + class TreatmentPlanTemplate(Document): def validate(self): self.validate_age() diff --git a/erpnext/healthcare/doctype/treatment_plan_template_item/treatment_plan_template_item.py b/erpnext/healthcare/doctype/treatment_plan_template_item/treatment_plan_template_item.py index 5f58b06af6..8b8d89f07f 100644 --- a/erpnext/healthcare/doctype/treatment_plan_template_item/treatment_plan_template_item.py +++ b/erpnext/healthcare/doctype/treatment_plan_template_item/treatment_plan_template_item.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class TreatmentPlanTemplateItem(Document): pass diff --git a/erpnext/healthcare/doctype/treatment_plan_template_practitioner/treatment_plan_template_practitioner.py b/erpnext/healthcare/doctype/treatment_plan_template_practitioner/treatment_plan_template_practitioner.py index 6d34568e15..c2d08bcc1a 100644 --- a/erpnext/healthcare/doctype/treatment_plan_template_practitioner/treatment_plan_template_practitioner.py +++ b/erpnext/healthcare/doctype/treatment_plan_template_practitioner/treatment_plan_template_practitioner.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class TreatmentPlanTemplatePractitioner(Document): pass diff --git a/erpnext/healthcare/doctype/vital_signs/test_vital_signs.py b/erpnext/healthcare/doctype/vital_signs/test_vital_signs.py index 5d3e00740f..22b52fb482 100644 --- a/erpnext/healthcare/doctype/vital_signs/test_vital_signs.py +++ b/erpnext/healthcare/doctype/vital_signs/test_vital_signs.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, ESS LLP and Contributors # See license.txt from __future__ import unicode_literals + import unittest # test_records = frappe.get_test_records('Vital Signs') diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py index 4bb3940ae0..29dbeb470d 100644 --- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py +++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py @@ -3,10 +3,11 @@ # For license information, please see license.txt from __future__ import unicode_literals + import frappe -from frappe.model.document import Document -from frappe.utils import cstr from frappe import _ +from frappe.model.document import Document + class VitalSigns(Document): def validate(self): diff --git a/erpnext/healthcare/module_onboarding/healthcare/healthcare.json b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json index 56c3c13559..0aa8f9a027 100644 --- a/erpnext/healthcare/module_onboarding/healthcare/healthcare.json +++ b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json @@ -10,7 +10,7 @@ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/healthcare", "idx": 0, "is_complete": 0, - "modified": "2020-07-08 14:06:19.512946", + "modified": "2021-01-30 19:22:20.273766", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare", diff --git a/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json b/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json index c45a347080..3f25a9d676 100644 --- a/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json +++ b/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json @@ -5,14 +5,14 @@ "doctype": "Onboarding Step", "idx": 0, "is_complete": 0, - "is_mandatory": 1, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-26 23:16:31.965521", + "modified": "2021-01-30 12:02:22.849260", "modified_by": "Administrator", "name": "Create Healthcare Practitioner", "owner": "Administrator", "reference_document": "Healthcare Practitioner", + "show_form_tour": 0, "show_full_form": 1, "title": "Create Healthcare Practitioner", "validate_action": 1 diff --git a/erpnext/healthcare/onboarding_step/create_patient/create_patient.json b/erpnext/healthcare/onboarding_step/create_patient/create_patient.json index 77bc5bd7ad..b46bb15b48 100644 --- a/erpnext/healthcare/onboarding_step/create_patient/create_patient.json +++ b/erpnext/healthcare/onboarding_step/create_patient/create_patient.json @@ -5,14 +5,14 @@ "doctype": "Onboarding Step", "idx": 0, "is_complete": 0, - "is_mandatory": 1, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-19 12:26:24.023418", - "modified_by": "Administrator", + "modified": "2021-01-30 00:09:28.786428", + "modified_by": "ruchamahabal2@gmail.com", "name": "Create Patient", "owner": "Administrator", "reference_document": "Patient", + "show_form_tour": 0, "show_full_form": 1, "title": "Create Patient", "validate_action": 1 diff --git a/erpnext/healthcare/onboarding_step/create_practitioner_schedule/create_practitioner_schedule.json b/erpnext/healthcare/onboarding_step/create_practitioner_schedule/create_practitioner_schedule.json index 65980ef668..7ce122d5c0 100644 --- a/erpnext/healthcare/onboarding_step/create_practitioner_schedule/create_practitioner_schedule.json +++ b/erpnext/healthcare/onboarding_step/create_practitioner_schedule/create_practitioner_schedule.json @@ -5,14 +5,14 @@ "doctype": "Onboarding Step", "idx": 0, "is_complete": 0, - "is_mandatory": 1, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-19 12:27:09.437825", - "modified_by": "Administrator", + "modified": "2021-01-30 00:09:28.794602", + "modified_by": "ruchamahabal2@gmail.com", "name": "Create Practitioner Schedule", "owner": "Administrator", "reference_document": "Practitioner Schedule", + "show_form_tour": 0, "show_full_form": 1, "title": "Create Practitioner Schedule", "validate_action": 1 diff --git a/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json b/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json index 697b761e52..dfe9f71a76 100644 --- a/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json +++ b/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json @@ -5,14 +5,14 @@ "doctype": "Onboarding Step", "idx": 0, "is_complete": 0, - "is_mandatory": 0, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-26 23:10:24.504030", + "modified": "2021-01-30 19:22:08.257160", "modified_by": "Administrator", "name": "Explore Clinical Procedure Templates", "owner": "Administrator", "reference_document": "Clinical Procedure Template", + "show_form_tour": 0, "show_full_form": 0, "title": "Explore Clinical Procedure Templates", "validate_action": 1 diff --git a/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json b/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json index b2d5aef431..2d952f3093 100644 --- a/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json +++ b/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json @@ -5,14 +5,14 @@ "doctype": "Onboarding Step", "idx": 0, "is_complete": 0, - "is_mandatory": 1, "is_single": 1, "is_skipped": 0, - "modified": "2020-05-26 23:10:24.507648", + "modified": "2021-01-30 19:22:07.275735", "modified_by": "Administrator", "name": "Explore Healthcare Settings", "owner": "Administrator", "reference_document": "Healthcare Settings", + "show_form_tour": 0, "show_full_form": 0, "title": "Explore Healthcare Settings", "validate_action": 1 diff --git a/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json b/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json index fa4c9036d7..baa8358c06 100644 --- a/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json +++ b/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json @@ -6,14 +6,14 @@ "field": "schedule", "idx": 0, "is_complete": 0, - "is_mandatory": 1, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-26 22:07:07.482530", - "modified_by": "Administrator", + "modified": "2021-01-30 00:09:28.807129", + "modified_by": "ruchamahabal2@gmail.com", "name": "Introduction to Healthcare Practitioner", "owner": "Administrator", "reference_document": "Healthcare Practitioner", + "show_form_tour": 0, "show_full_form": 0, "title": "Introduction to Healthcare Practitioner", "validate_action": 0 diff --git a/erpnext/healthcare/page/patient_history/patient_history.css b/erpnext/healthcare/page/patient_history/patient_history.css index 1bb589164e..74b5e7eb91 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.css +++ b/erpnext/healthcare/page/patient_history/patient_history.css @@ -9,6 +9,26 @@ cursor: pointer; } +.patient-image-container { + margin-top: 17px; + } + +.patient-image { + display: inline-block; + width: 100%; + height: 0; + padding: 50% 0px; + background-size: cover; + background-repeat: no-repeat; + background-position: center center; + border-radius: 4px; +} + +.patient-name { + font-size: 20px; + margin-top: 25px; +} + .medical_record-label { max-width: 100px; margin-bottom: -4px; @@ -19,19 +39,19 @@ } .date-indicator { - background:none; - font-size:12px; - vertical-align:middle; - font-weight:bold; - color:#6c7680; + background:none; + font-size:12px; + vertical-align:middle; + font-weight:bold; + color:#6c7680; } .date-indicator::after { - margin:0 -4px 0 12px; - content:''; - display:inline-block; - height:8px; - width:8px; - border-radius:8px; + margin:0 -4px 0 12px; + content:''; + display:inline-block; + height:8px; + width:8px; + border-radius:8px; background: #d1d8dd; } diff --git a/erpnext/healthcare/page/patient_history/patient_history.html b/erpnext/healthcare/page/patient_history/patient_history.html index f1706557f4..d16b38637c 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.html +++ b/erpnext/healthcare/page/patient_history/patient_history.html @@ -1,26 +1,18 @@ -
-
-

-
+
+
+
+
+
+
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- -
+ +
+
+
+
+
+
+
+
diff --git a/erpnext/healthcare/page/patient_history/patient_history.js b/erpnext/healthcare/page/patient_history/patient_history.js index 54343aae44..ed2dc52cb1 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.js +++ b/erpnext/healthcare/page/patient_history/patient_history.js @@ -1,403 +1,455 @@ frappe.provide('frappe.patient_history'); frappe.pages['patient_history'].on_page_load = function(wrapper) { - let me = this; - let page = frappe.ui.make_app_page({ + frappe.ui.make_app_page({ parent: wrapper, - title: 'Patient History', - single_column: true + title: __('Patient History') }); - frappe.breadcrumbs.add('Healthcare'); - let pid = ''; - page.main.html(frappe.render_template('patient_history', {})); - page.main.find('.header-separator').hide(); - - let patient = frappe.ui.form.make_control({ - parent: page.main.find('.patient'), - df: { - fieldtype: 'Link', - options: 'Patient', - fieldname: 'patient', - placeholder: __('Select Patient'), - only_select: true, - change: function() { - let patient_id = patient.get_value(); - if (pid != patient_id && patient_id) { - me.start = 0; - me.page.main.find('.patient_documents_list').html(''); - setup_filters(patient_id, me); - get_documents(patient_id, me); - show_patient_info(patient_id, me); - show_patient_vital_charts(patient_id, me, 'bp', 'mmHg', 'Blood Pressure'); - } - pid = patient_id; - } - }, - }); - patient.refresh(); - - if (frappe.route_options) { - patient.set_value(frappe.route_options.patient); - } - - this.page.main.on('click', '.btn-show-chart', function() { - let btn_show_id = $(this).attr('data-show-chart-id'), pts = $(this).attr('data-pts'); - let title = $(this).attr('data-title'); - show_patient_vital_charts(patient.get_value(), me, btn_show_id, pts, title); - }); - - this.page.main.on('click', '.btn-more', function() { - let doctype = $(this).attr('data-doctype'), docname = $(this).attr('data-docname'); - if (me.page.main.find('.'+docname).parent().find('.document-html').attr('data-fetched') == '1') { - me.page.main.find('.'+docname).hide(); - me.page.main.find('.'+docname).parent().find('.document-html').show(); - } else { - if (doctype && docname) { - let exclude = ['patient', 'patient_name', 'patient_sex', 'encounter_date']; - frappe.call({ - method: 'erpnext.healthcare.utils.render_doc_as_html', - args:{ - doctype: doctype, - docname: docname, - exclude_fields: exclude - }, - freeze: true, - callback: function(r) { - if (r.message) { - me.page.main.find('.' + docname).hide(); - - me.page.main.find('.' + docname).parent().find('.document-html').html( - `${r.message.html} -
- - -
- `); - - me.page.main.find('.' + docname).parent().find('.document-html').show(); - me.page.main.find('.' + docname).parent().find('.document-html').attr('data-fetched', '1'); - } - } - }); - } - } - }); - - this.page.main.on('click', '.btn-less', function() { - let docname = $(this).attr('data-docname'); - me.page.main.find('.' + docname).parent().find('.document-id').show(); - me.page.main.find('.' + docname).parent().find('.document-html').hide(); - }); - me.start = 0; - me.page.main.on('click', '.btn-get-records', function() { - get_documents(patient.get_value(), me); + let patient_history = new PatientHistory(wrapper); + $(wrapper).bind('show', ()=> { + patient_history.show(); }); }; -let setup_filters = function(patient, me) { - $('.doctype-filter').empty(); - frappe.xcall( - 'erpnext.healthcare.page.patient_history.patient_history.get_patient_history_doctypes' - ).then(document_types => { - let doctype_filter = frappe.ui.form.make_control({ - parent: $('.doctype-filter'), +class PatientHistory { + constructor(wrapper) { + this.wrapper = $(wrapper); + this.page = wrapper.page; + this.sidebar = this.wrapper.find('.layout-side-section'); + this.main_section = this.wrapper.find('.layout-main-section'); + this.start = 0; + } + + show() { + frappe.breadcrumbs.add('Healthcare'); + this.sidebar.empty(); + + let me = this; + let patient = frappe.ui.form.make_control({ + parent: me.sidebar, df: { - fieldtype: 'MultiSelectList', - fieldname: 'document_type', - placeholder: __('Select Document Type'), - input_class: 'input-xs', + fieldtype: 'Link', + options: 'Patient', + fieldname: 'patient', + placeholder: __('Select Patient'), + only_select: true, change: () => { - me.start = 0; - me.page.main.find('.patient_documents_list').html(''); - get_documents(patient, me, doctype_filter.get_value(), date_range_field.get_value()); - }, - get_data: () => { - return document_types.map(document_type => { - return { - description: document_type, - value: document_type - }; - }); - }, + me.patient_id = ''; + if (me.patient_id != patient.get_value() && patient.get_value()) { + me.start = 0; + me.patient_id = patient.get_value(); + me.make_patient_profile(); + } + } } }); - doctype_filter.refresh(); + patient.refresh(); - $('.date-filter').empty(); - let date_range_field = frappe.ui.form.make_control({ - df: { - fieldtype: 'DateRange', - fieldname: 'date_range', - placeholder: __('Date Range'), - input_class: 'input-xs', - change: () => { - let selected_date_range = date_range_field.get_value(); - if (selected_date_range && selected_date_range.length === 2) { + if (frappe.route_options && !this.patient_id) { + patient.set_value(frappe.route_options.patient); + this.patient_id = frappe.route_options.patient; + } + + this.sidebar.find('[data-fieldname="patient"]').append('
'); + } + + make_patient_profile() { + this.page.set_title(__('Patient History')); + this.main_section.empty().append(frappe.render_template('patient_history')); + this.setup_filters(); + this.setup_documents(); + this.show_patient_info(); + this.setup_buttons(); + this.show_patient_vital_charts('bp', 'mmHg', 'Blood Pressure'); + } + + setup_filters() { + $('.doctype-filter').empty(); + let me = this; + + frappe.xcall( + 'erpnext.healthcare.page.patient_history.patient_history.get_patient_history_doctypes' + ).then(document_types => { + let doctype_filter = frappe.ui.form.make_control({ + parent: $('.doctype-filter'), + df: { + fieldtype: 'MultiSelectList', + fieldname: 'document_type', + placeholder: __('Select Document Type'), + change: () => { me.start = 0; me.page.main.find('.patient_documents_list').html(''); - get_documents(patient, me, doctype_filter.get_value(), selected_date_range); - } + this.setup_documents(doctype_filter.get_value(), date_range_field.get_value()); + }, + get_data: () => { + return document_types.map(document_type => { + return { + description: document_type, + value: document_type + }; + }); + }, } - }, - parent: $('.date-filter') + }); + doctype_filter.refresh(); + + $('.date-filter').empty(); + let date_range_field = frappe.ui.form.make_control({ + df: { + fieldtype: 'DateRange', + fieldname: 'date_range', + placeholder: __('Date Range'), + input_class: 'input-xs', + change: () => { + let selected_date_range = date_range_field.get_value(); + if (selected_date_range && selected_date_range.length === 2) { + me.start = 0; + me.page.main.find('.patient_documents_list').html(''); + this.setup_documents(doctype_filter.get_value(), date_range_field.get_value()); + } + } + }, + parent: $('.date-filter') + }); + date_range_field.refresh(); }); - date_range_field.refresh(); - }); -}; + } -let get_documents = function(patient, me, document_types="", selected_date_range="") { - let filters = { - name: patient, - start: me.start, - page_length: 20 - }; - if (document_types) - filters['document_types'] = document_types; - if (selected_date_range) - filters['date_range'] = selected_date_range; + setup_documents(document_types="", selected_date_range="") { + let filters = { + name: this.patient_id, + start: this.start, + page_length: 20 + }; + if (document_types) + filters['document_types'] = document_types; + if (selected_date_range) + filters['date_range'] = selected_date_range; - frappe.call({ - 'method': 'erpnext.healthcare.page.patient_history.patient_history.get_feed', - args: filters, - callback: function(r) { - let data = r.message; - if (data.length) { - add_to_records(me, data); - } else { - me.page.main.find('.patient_documents_list').append(` -
-

${__('No more records..')}

-
`); - me.page.main.find('.btn-get-records').hide(); + let me = this; + frappe.call({ + 'method': 'erpnext.healthcare.page.patient_history.patient_history.get_feed', + args: filters, + callback: function(r) { + let data = r.message; + if (data.length) { + me.add_to_records(data); + } else { + me.page.main.find('.patient_documents_list').append(` +
+

${__('No more records..')}

+
`); + me.page.main.find('.btn-get-records').hide(); + } } - } - }); -}; + }); + } -let add_to_records = function(me, data) { - let details = "
`; + } + } + + this.page.main.find('.patient_documents_list').append(details); + this.start += data.length; + + if (data.length === 20) { + this.page.main.find(".btn-get-records").show(); + } else { + this.page.main.find(".btn-get-records").hide(); + this.page.main.find(".patient_documents_list").append(` +
+

${__('No more records..')}

+
`); } } - details += ''; - me.page.main.find('.patient_documents_list').append(details); - me.start += data.length; + add_date_separator(data) { + let date = frappe.datetime.str_to_obj(data.communication_date); + let pdate = ''; + let diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), + frappe.datetime.obj_to_str(date)); - if (data.length === 20) { - me.page.main.find(".btn-get-records").show(); - } else { - me.page.main.find(".btn-get-records").hide(); - me.page.main.find(".patient_documents_list").append(` -
-

${__('No more records..')}

-
`); - } -}; - -let add_date_separator = function(data) { - let date = frappe.datetime.str_to_obj(data.communication_date); - let pdate = ''; - let diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date)); - - if (diff < 1) { - pdate = __('Today'); - } else if (diff < 2) { - pdate = __('Yesterday'); - } else { - pdate = __('on ') + frappe.datetime.global_date_format(date); - } - data.date_sep = pdate; - return data; -}; - -let show_patient_info = function(patient, me) { - frappe.call({ - 'method': 'erpnext.healthcare.doctype.patient.patient.get_patient_detail', - args: { - patient: patient - }, - callback: function(r) { - let data = r.message; - let details = ''; - if (data.image) { - details += `
`; - } - - details += ` ${data.patient_name}
${data.sex}`; - if (data.email) details += `
${data.email}`; - if (data.mobile) details += `
${data.mobile}`; - if (data.occupation) details += `

${__('Occupation')} : ${data.occupation}`; - if (data.blood_group) details += `
${__('Blood Group')} : ${data.blood_group}`; - if (data.allergies) details += `

${__('Allerigies')} : ${data.allergies.replace("\n", ", ")}`; - if (data.medication) details += `
${__('Medication')} : ${data.medication.replace("\n", ", ")}`; - if (data.alcohol_current_use) details += `

${__('Alcohol use')} : ${data.alcohol_current_use}`; - if (data.alcohol_past_use) details += `
${__('Alcohol past use')} : ${data.alcohol_past_use}`; - if (data.tobacco_current_use) details += `
${__('Tobacco use')} : ${data.tobacco_current_use}`; - if (data.tobacco_past_use) details += `
${__('Tobacco past use')} : ${data.tobacco_past_use}`; - if (data.medical_history) details += `

${__('Medical history')} : ${data.medical_history.replace("\n", ", ")}`; - if (data.surgical_history) details += `
${__('Surgical history')} : ${data.surgical_history.replace("\n", ", ")}`; - if (data.surrounding_factors) details += `

${__('Occupational hazards')} : ${data.surrounding_factors.replace("\n", ", ")}`; - if (data.other_risk_factors) details += `
${__('Other risk factors')} : ${data.other_risk_factors.replace("\n", ", ")}`; - if (data.patient_details) details += `

${__('More info')} : ${data.patient_details.replace("\n", ", ")}`; - - if (details) { - details = `
` + details + `
`; - } - me.page.main.find('.patient_details').html(details); + if (diff < 1) { + pdate = __('Today'); + } else if (diff < 2) { + pdate = __('Yesterday'); + } else { + pdate = __('on {0}', [frappe.datetime.global_date_format(date)]); } - }); -}; + data.date_sep = pdate; + return data; + } -let show_patient_vital_charts = function(patient, me, btn_show_id, pts, title) { - frappe.call({ - method: 'erpnext.healthcare.utils.get_patient_vitals', - args:{ - patient: patient - }, - callback: function(r) { - if (r.message) { - let show_chart_btns_html = ` -
- - ${__('Blood Pressure')} - - - ${__('Respiratory/Pulse Rate')} - - - ${__('Temperature')} - - - ${__('BMI')} - -
`; + show_patient_info() { + this.get_patient_info().then(() => { + $('.patient-info').empty().append(frappe.render_template('patient_history_sidebar', { + patient_image: this.patient.image, + patient_name: this.patient.patient_name, + patient_gender: this.patient.sex, + patient_mobile: this.patient.mobile + })); + this.show_patient_details(); + }); + } - me.page.main.find('.show_chart_btns').html(show_chart_btns_html); + show_patient_details() { + let me = this; + frappe.call({ + 'method': 'erpnext.healthcare.doctype.patient.patient.get_patient_detail', + args: { + patient: me.patient_id + }, + callback: function(r) { let data = r.message; - let labels = [], datasets = []; - let bp_systolic = [], bp_diastolic = [], temperature = []; - let pulse = [], respiratory_rate = [], bmi = [], height = [], weight = []; + let details = ``; - for (let i=0; i
${__('Occupation')} : ${data.occupation}`; + if (data.blood_group) details += `
${__('Blood Group')} : ${data.blood_group}`; + if (data.allergies) details += `

${__('Allerigies')} : ${data.allergies.replace("\n", ", ")}`; + if (data.medication) details += `
${__('Medication')} : ${data.medication.replace("\n", ", ")}`; + if (data.alcohol_current_use) details += `

${__('Alcohol use')} : ${data.alcohol_current_use}`; + if (data.alcohol_past_use) details += `
${__('Alcohol past use')} : ${data.alcohol_past_use}`; + if (data.tobacco_current_use) details += `
${__('Tobacco use')} : ${data.tobacco_current_use}`; + if (data.tobacco_past_use) details += `
${__('Tobacco past use')} : ${data.tobacco_past_use}`; + if (data.medical_history) details += `

${__('Medical history')} : ${data.medical_history.replace("\n", ", ")}`; + if (data.surgical_history) details += `
${__('Surgical history')} : ${data.surgical_history.replace("\n", ", ")}`; + if (data.surrounding_factors) details += `

${__('Occupational hazards')} : ${data.surrounding_factors.replace("\n", ", ")}`; + if (data.other_risk_factors) details += `
${__('Other risk factors')} : ${data.other_risk_factors.replace("\n", ", ")}`; + if (data.patient_details) details += `

${__('More info')} : ${data.patient_details.replace("\n", ", ")}`; - if (btn_show_id === 'bp') { - bp_systolic.push(data[i].bp_systolic); - bp_diastolic.push(data[i].bp_diastolic); - } - if (btn_show_id === 'temperature') { - temperature.push(data[i].temperature); - } - if (btn_show_id === 'pulse_rate') { - pulse.push(data[i].pulse); - respiratory_rate.push(data[i].respiratory_rate); - } - if (btn_show_id === 'bmi') { - bmi.push(data[i].bmi); - height.push(data[i].height); - weight.push(data[i].weight); - } + if (details) { + details = `
` + details + `
`; } - if (btn_show_id === 'temperature') { - datasets.push({name: 'Temperature', values: temperature, chartType: 'line'}); - } - if (btn_show_id === 'bmi') { - datasets.push({name: 'BMI', values: bmi, chartType: 'line'}); - datasets.push({name: 'Height', values: height, chartType: 'line'}); - datasets.push({name: 'Weight', values: weight, chartType: 'line'}); - } - if (btn_show_id === 'bp') { - datasets.push({name: 'BP Systolic', values: bp_systolic, chartType: 'line'}); - datasets.push({name: 'BP Diastolic', values: bp_diastolic, chartType: 'line'}); - } - if (btn_show_id === 'pulse_rate') { - datasets.push({name: 'Heart Rate / Pulse', values: pulse, chartType: 'line'}); - datasets.push({name: 'Respiratory Rate', values: respiratory_rate, chartType: 'line'}); - } - new frappe.Chart('.patient_vital_charts', { - data: { - labels: labels, - datasets: datasets - }, - title: title, - type: 'axis-mixed', - height: 200, - colors: ['purple', '#ffa3ef', 'light-blue'], - - tooltipOptions: { - formatTooltipX: d => (d + '').toUpperCase(), - formatTooltipY: d => d + ' ' + pts, - } - }); - me.page.main.find('.header-separator').show(); - } else { - me.page.main.find('.patient_vital_charts').html(''); - me.page.main.find('.show_chart_btns').html(''); - me.page.main.find('.header-separator').hide(); + me.sidebar.find('.patient-details').html(details); } - } - }); -}; + }); + } + + get_patient_info() { + return frappe.xcall('frappe.client.get', { + doctype: 'Patient', + name: this.patient_id, + }).then((patient) => { + if (patient) { + this.patient = patient; + } + }); + } + + setup_buttons() { + let me = this; + this.page.main.on("click", ".btn-show-chart", function() { + let btn_id = $(this).attr("data-show-chart-id"), scale_unit = $(this).attr("data-pts"); + let title = $(this).attr("data-title"); + me.show_patient_vital_charts(btn_id, scale_unit, title); + }); + + this.page.main.on('click', '.btn-more', function() { + let doctype = $(this).attr('data-doctype'), docname = $(this).attr('data-docname'); + if (me.page.main.find('.'+docname).parent().find('.document-html').attr('data-fetched') == '1') { + me.page.main.find('.'+docname).hide(); + me.page.main.find('.'+docname).parent().find('.document-html').show(); + } else { + if (doctype && docname) { + let exclude = ['patient', 'patient_name', 'patient_sex', 'encounter_date', 'naming_series']; + frappe.call({ + method: 'erpnext.healthcare.utils.render_doc_as_html', + args: { + doctype: doctype, + docname: docname, + exclude_fields: exclude + }, + freeze: true, + callback: function(r) { + if (r.message) { + me.page.main.find('.' + docname).hide(); + + me.page.main.find('.' + docname).parent().find('.document-html').html( + `${r.message.html} +
+
+ + +
+ `); + + me.page.main.find('.' + docname).parent().find('.document-html').attr('hidden', false); + me.page.main.find('.' + docname).parent().find('.document-html').attr('data-fetched', '1'); + } + } + }); + } + } + }); + + this.page.main.on('click', '.btn-less', function() { + let docname = $(this).attr('data-docname'); + me.page.main.find('.' + docname).parent().find('.document-id').show(); + me.page.main.find('.' + docname).parent().find('.document-html').hide(); + }); + + me.page.main.on('click', '.btn-get-records', function() { + this.setup_documents(); + }); + } + + show_patient_vital_charts(btn_id, scale_unit, title) { + let me = this; + + frappe.call({ + method: 'erpnext.healthcare.utils.get_patient_vitals', + args: { + patient: me.patient_id + }, + callback: function(r) { + if (r.message) { + let show_chart_btns_html = ` +
+ + ${__('Blood Pressure')} + + + ${__('Respiratory/Pulse Rate')} + + + ${__('Temperature')} + + + ${__('BMI')} + +
`; + + me.page.main.find('.show_chart_btns').html(show_chart_btns_html); + let data = r.message; + let labels = [], datasets = []; + let bp_systolic = [], bp_diastolic = [], temperature = []; + let pulse = [], respiratory_rate = [], bmi = [], height = [], weight = []; + + for (let i=0; i (d + '').toUpperCase(), + formatTooltipY: d => d + ' ' + scale_unit, + } + }); + me.page.main.find('.header-separator').show(); + } else { + me.page.main.find('.patient_vital_charts').html(''); + me.page.main.find('.show_chart_btns').html(''); + me.page.main.find('.header-separator').hide(); + } + } + }); + } +} diff --git a/erpnext/healthcare/page/patient_history/patient_history.py b/erpnext/healthcare/page/patient_history/patient_history.py index 4cdfd64a69..77d8846f37 100644 --- a/erpnext/healthcare/page/patient_history/patient_history.py +++ b/erpnext/healthcare/page/patient_history/patient_history.py @@ -3,10 +3,12 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe + import json + +import frappe from frappe.utils import cint -from erpnext.healthcare.utils import render_docs_as_html + @frappe.whitelist() def get_feed(name, document_types=None, date_range=None, start=0, page_length=20): diff --git a/erpnext/healthcare/page/patient_history/patient_history_sidebar.html b/erpnext/healthcare/page/patient_history/patient_history_sidebar.html new file mode 100644 index 0000000000..fc7eab0540 --- /dev/null +++ b/erpnext/healthcare/page/patient_history/patient_history_sidebar.html @@ -0,0 +1,20 @@ +
+
+ {% if patient_image %} +
+ {% endif %} +
+
+ {% if patient_name %} +

{{patient_name}}

+ {% endif %} + {% if patient_gender %} +

{%=__("Gender: ") %} {{patient_gender}}

+ {% endif %} + {% if patient_mobile %} +

{%=__("Contact: ") %} {{patient_mobile}}

+ {% endif %} +
+
+
+
diff --git a/erpnext/healthcare/page/patient_progress/patient_progress.css b/erpnext/healthcare/page/patient_progress/patient_progress.css index 5d85a7487f..737b2e0ea2 100644 --- a/erpnext/healthcare/page/patient_progress/patient_progress.css +++ b/erpnext/healthcare/page/patient_progress/patient_progress.css @@ -29,6 +29,7 @@ .patient-name { font-size: 20px; + margin-top: 25px; } /* heatmap */ @@ -55,6 +56,7 @@ } .heatmap-container .chart-filter { + z-index: 1; position: relative; top: 5px; margin-right: 10px; @@ -111,10 +113,13 @@ text.title { } .chart-column-container { - border-bottom: 1px solid #d1d8dd; margin: 5px 0; } +.progress-graphs .progress-container { + margin-bottom: var(--margin-xl); +} + .line-chart-container .frappe-chart { margin-top: -20px; } @@ -146,6 +151,7 @@ text.title { } .percentage-chart-container .chart-filter { + z-index: 1; position: relative; top: 12px; margin-right: 10px; diff --git a/erpnext/healthcare/page/patient_progress/patient_progress.html b/erpnext/healthcare/page/patient_progress/patient_progress.html index 30064bd165..ee60065618 100644 --- a/erpnext/healthcare/page/patient_progress/patient_progress.html +++ b/erpnext/healthcare/page/patient_progress/patient_progress.html @@ -1,14 +1,15 @@
-