diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml
new file mode 100644
index 00000000000..d36b11553ce
--- /dev/null
+++ b/.github/workflows/docker-release.yml
@@ -0,0 +1,14 @@
+name: Trigger Docker build on release
+on:
+ release:
+ types: [created]
+jobs:
+ curl:
+ runs-on: ubuntu-latest
+ container:
+ image: alpine:latest
+ steps:
+ - name: curl
+ run: |
+ apk add curl bash
+ curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token ${{ secrets.TRAVIS_CI_TOKEN }}" -d '{"request":{"branch":"master"}}' https://api.travis-ci.org/repo/frappe%2Ffrappe_docker/requests
diff --git a/.travis.yml b/.travis.yml
index 213445b806e..77d427e5a50 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
-dist: trusty
-
language: python
+dist: trusty
git:
depth: 1
@@ -14,21 +13,10 @@ addons:
jobs:
include:
- - name: "Python 2.7 Server Side Test"
- python: 2.7
- script: bench --site test_site run-tests --app erpnext --coverage
-
- name: "Python 3.6 Server Side Test"
python: 3.6
script: bench --site test_site run-tests --app erpnext --coverage
- - name: "Python 2.7 Patch Test"
- python: 2.7
- before_script:
- - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
- - bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz
- script: bench --site test_site migrate
-
- name: "Python 3.6 Patch Test"
python: 3.6
before_script:
@@ -40,8 +28,7 @@ install:
- cd ~
- nvm install 10
- - git clone https://github.com/frappe/bench --depth 1
- - pip install -e ./bench
+ - pip install frappe-bench
- git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1
- bench init --skip-assets --frappe-path ~/frappe --python $(which python) frappe-bench
diff --git a/CODEOWNERS b/CODEOWNERS
index 5e1113d34f9..7cf65a7a732 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -3,17 +3,16 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
-* @nabinhait
-manufacturing/ @rohitwaghchaure
+manufacturing/ @rohitwaghchaure @marination
accounts/ @deepeshgarg007 @nextchamp-saqib
-loan_management/ @deepeshgarg007
-pos* @nextchamp-saqib
-assets/ @nextchamp-saqib
+loan_management/ @deepeshgarg007 @rohitwaghchaure
+pos* @nextchamp-saqib @rohitwaghchaure
+assets/ @nextchamp-saqib @deepeshgarg007
stock/ @marination @rohitwaghchaure
-buying/ @marination @rohitwaghchaure
-hr/ @Anurag810
-projects/ @hrwX
-support/ @hrwX
-healthcare/ @ruchamahabal
-erpnext_integrations/ @Mangesh-Khairnar
+buying/ @marination @deepeshgarg007
+hr/ @Anurag810 @rohitwaghchaure
+projects/ @hrwX @nextchamp-saqib
+support/ @hrwX @marination
+healthcare/ @ruchamahabal @marination
+erpnext_integrations/ @Mangesh-Khairnar @nextchamp-saqib
requirements.txt @gavindsouza
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 786b9cfd164..38d8a62f07f 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
-__version__ = '12.0.0-dev'
+__version__ = '13.0.0-dev'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/__init__.py b/erpnext/accounts/accounts
similarity index 100%
rename from erpnext/accounts/report/purchase_order_items_to_be_billed/__init__.py
rename to erpnext/accounts/accounts
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 c3e2f7db124..39bf4b053a7 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
@@ -6,7 +6,7 @@ import frappe, json
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.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
+from frappe.utils.dashboard import cache_source, get_from_date_from_timespan
from frappe.desk.doctype.dashboard_chart.dashboard_chart import get_period_ending
from frappe.utils.nestedset import get_descendants_of
@@ -14,7 +14,7 @@ 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,
- to_date = None, timespan = None, time_interval = None):
+ to_date = None, timespan = None, time_interval = None, heatmap_year = None):
if chart_name:
chart = frappe.get_doc('Dashboard Chart', chart_name)
else:
diff --git a/erpnext/accounts/dashboard_fixtures.py b/erpnext/accounts/dashboard_fixtures.py
new file mode 100644
index 00000000000..421c86dba01
--- /dev/null
+++ b/erpnext/accounts/dashboard_fixtures.py
@@ -0,0 +1,264 @@
+# 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
+from frappe import _
+from erpnext.accounts.utils import get_fiscal_year, get_account_name
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards()
+ })
+
+def get_dashboards():
+ return [{
+ "name": "Accounts",
+ "dashboard_name": "Accounts",
+ "doctype": "Dashboard",
+ "charts": [
+ { "chart": "Profit and Loss" , "width": "Full"},
+ { "chart": "Incoming Bills (Purchase Invoice)", "width": "Half"},
+ { "chart": "Outgoing Bills (Sales Invoice)", "width": "Half"},
+ { "chart": "Accounts Receivable Ageing", "width": "Half"},
+ { "chart": "Accounts Payable Ageing", "width": "Half"},
+ { "chart": "Budget Variance", "width": "Full"},
+ { "chart": "Bank Balance", "width": "Full"}
+ ],
+ "cards": [
+ {"card": "Total Outgoing Bills"},
+ {"card": "Total Incoming Bills"},
+ {"card": "Total Incoming Payment"},
+ {"card": "Total Outgoing Payment"}
+ ]
+ }]
+
+def get_charts():
+ company = frappe.get_doc("Company", get_company_for_dashboards())
+ bank_account = company.default_bank_account or get_account_name("Bank", company=company.name)
+ fiscal_year = get_fiscal_year(date=nowdate())
+ default_cost_center = company.cost_center
+
+ return [
+ {
+ "doctype": "Dashboard Charts",
+ "name": "Profit and Loss",
+ "owner": "Administrator",
+ "report_name": "Profit and Loss Statement",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "filter_based_on": "Fiscal Year",
+ "from_fiscal_year": fiscal_year[0],
+ "to_fiscal_year": fiscal_year[0],
+ "periodicity": "Monthly",
+ "include_default_book_entries": 1
+ }),
+ "type": "Bar",
+ 'timeseries': 0,
+ "chart_type": "Report",
+ "chart_name": _("Profit and Loss"),
+ "is_custom": 1,
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Monthly",
+ "name": "Incoming Bills (Purchase Invoice)",
+ "chart_name": _("Incoming Bills (Purchase Invoice)"),
+ "timespan": "Last Year",
+ "color": "#a83333",
+ "value_based_on": "base_net_total",
+ "filters_json": json.dumps([["Purchase Invoice", "docstatus", "=", 1]]),
+ "chart_type": "Sum",
+ "timeseries": 1,
+ "based_on": "posting_date",
+ "owner": "Administrator",
+ "document_type": "Purchase Invoice",
+ "type": "Bar",
+ "width": "Half",
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Outgoing Bills (Sales Invoice)",
+ "time_interval": "Monthly",
+ "chart_name": _("Outgoing Bills (Sales Invoice)"),
+ "timespan": "Last Year",
+ "color": "#7b933d",
+ "value_based_on": "base_net_total",
+ "filters_json": json.dumps([["Sales Invoice", "docstatus", "=", 1]]),
+ "chart_type": "Sum",
+ "timeseries": 1,
+ "based_on": "posting_date",
+ "owner": "Administrator",
+ "document_type": "Sales Invoice",
+ "type": "Bar",
+ "width": "Half",
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Charts",
+ "name": "Accounts Receivable Ageing",
+ "owner": "Administrator",
+ "report_name": "Accounts Receivable",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "report_date": nowdate(),
+ "ageing_based_on": "Due Date",
+ "range1": 30,
+ "range2": 60,
+ "range3": 90,
+ "range4": 120
+ }),
+ "type": "Donut",
+ 'timeseries': 0,
+ "chart_type": "Report",
+ "chart_name": _("Accounts Receivable Ageing"),
+ "is_custom": 1,
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Charts",
+ "name": "Accounts Payable Ageing",
+ "owner": "Administrator",
+ "report_name": "Accounts Payable",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "report_date": nowdate(),
+ "ageing_based_on": "Due Date",
+ "range1": 30,
+ "range2": 60,
+ "range3": 90,
+ "range4": 120
+ }),
+ "type": "Donut",
+ 'timeseries': 0,
+ "chart_type": "Report",
+ "chart_name": _("Accounts Payable Ageing"),
+ "is_custom": 1,
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Charts",
+ "name": "Budget Variance",
+ "owner": "Administrator",
+ "report_name": "Budget Variance Report",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "from_fiscal_year": fiscal_year[0],
+ "to_fiscal_year": fiscal_year[0],
+ "period": "Monthly",
+ "budget_against": "Cost Center"
+ }),
+ "type": "Bar",
+ "timeseries": 0,
+ "chart_type": "Report",
+ "chart_name": _("Budget Variance"),
+ "is_custom": 1,
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Charts",
+ "name": "Bank Balance",
+ "time_interval": "Quarterly",
+ "chart_name": "Bank Balance",
+ "timespan": "Last Year",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "account": bank_account
+ }),
+ "source": "Account Balance Timeline",
+ "chart_type": "Custom",
+ "timeseries": 1,
+ "owner": "Administrator",
+ "type": "Line",
+ "width": "Half",
+ "is_public": 1
+ },
+ ]
+
+def get_number_cards():
+ fiscal_year = get_fiscal_year(date=nowdate())
+ year_start_date = get_date_str(fiscal_year[1])
+ year_end_date = get_date_str(fiscal_year[2])
+ return [
+ {
+ "doctype": "Number Card",
+ "document_type": "Payment Entry",
+ "name": "Total Incoming Payment",
+ "filters_json": json.dumps([
+ ['Payment Entry', 'docstatus', '=', 1],
+ ['Payment Entry', 'posting_date', 'between', [year_start_date, year_end_date]],
+ ['Payment Entry', 'payment_type', '=', 'Receive']
+ ]),
+ "label": _("Total Incoming Payment"),
+ "function": "Sum",
+ "aggregate_function_based_on": "base_received_amount",
+ "is_public": 1,
+ "is_custom": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Payment Entry",
+ "name": "Total Outgoing Payment",
+ "filters_json": json.dumps([
+ ['Payment Entry', 'docstatus', '=', 1],
+ ['Payment Entry', 'posting_date', 'between', [year_start_date, year_end_date]],
+ ['Payment Entry', 'payment_type', '=', 'Pay']
+ ]),
+ "label": _("Total Outgoing Payment"),
+ "function": "Sum",
+ "aggregate_function_based_on": "base_paid_amount",
+ "is_public": 1,
+ "is_custom": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Sales Invoice",
+ "name": "Total Outgoing Bills",
+ "filters_json": json.dumps([
+ ['Sales Invoice', 'docstatus', '=', 1],
+ ['Sales Invoice', 'posting_date', 'between', [year_start_date, year_end_date]]
+ ]),
+ "label": _("Total Outgoing Bills"),
+ "function": "Sum",
+ "aggregate_function_based_on": "base_net_total",
+ "is_public": 1,
+ "is_custom": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Purchase Invoice",
+ "name": "Total Incoming Bills",
+ "filters_json": json.dumps([
+ ['Purchase Invoice', 'docstatus', '=', 1],
+ ['Purchase Invoice', 'posting_date', 'between', [year_start_date, year_end_date]]
+ ]),
+ "label": _("Total Incoming Bills"),
+ "function": "Sum",
+ "aggregate_function_based_on": "base_net_total",
+ "is_public": 1,
+ "is_custom": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ }
+ ]
diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py
index b0210e5fd4b..448011016e7 100644
--- a/erpnext/accounts/deferred_revenue.py
+++ b/erpnext/accounts/deferred_revenue.py
@@ -185,7 +185,7 @@ def book_deferred_income_or_expense(doc, deferred_process, posting_date=None):
total_days, total_booking_days, account_currency)
make_gl_entries(doc, credit_account, debit_account, against,
- amount, base_amount, end_date, project, account_currency, item.cost_center, item.name, deferred_process)
+ amount, base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process)
# Returned in case of any errors because it tries to submit the same record again and again in case of errors
if frappe.flags.deferred_accounting_error:
@@ -199,10 +199,13 @@ def book_deferred_income_or_expense(doc, deferred_process, posting_date=None):
if item.get(enable_check):
_book_deferred_revenue_or_expense(item)
-def process_deferred_accounting(posting_date=today()):
+def process_deferred_accounting(posting_date=None):
''' Converts deferred income/expense into income/expense
Executed via background jobs on every month end '''
+ if not posting_date:
+ posting_date = today()
+
if not cint(frappe.db.get_singles_value('Accounts Settings', 'automatically_process_deferred_accounting_entry')):
return
@@ -222,7 +225,7 @@ def process_deferred_accounting(posting_date=today()):
doc.submit()
def make_gl_entries(doc, credit_account, debit_account, against,
- amount, base_amount, posting_date, project, account_currency, cost_center, voucher_detail_no, deferred_process=None):
+ amount, base_amount, posting_date, project, account_currency, cost_center, item, deferred_process=None):
# GL Entry for crediting the amount in the deferred expense
from erpnext.accounts.general_ledger import make_gl_entries
@@ -236,12 +239,12 @@ def make_gl_entries(doc, credit_account, debit_account, against,
"credit": base_amount,
"credit_in_account_currency": amount,
"cost_center": cost_center,
- "voucher_detail_no": voucher_detail_no,
+ "voucher_detail_no": item.name,
'posting_date': posting_date,
'project': project,
'against_voucher_type': 'Process Deferred Accounting',
'against_voucher': deferred_process
- }, account_currency)
+ }, account_currency, item=item)
)
# GL Entry to debit the amount from the expense
gl_entries.append(
@@ -251,12 +254,12 @@ def make_gl_entries(doc, credit_account, debit_account, against,
"debit": base_amount,
"debit_in_account_currency": amount,
"cost_center": cost_center,
- "voucher_detail_no": voucher_detail_no,
+ "voucher_detail_no": item.name,
'posting_date': posting_date,
'project': project,
'against_voucher_type': 'Process Deferred Accounting',
'against_voucher': deferred_process
- }, account_currency)
+ }, account_currency, item=item)
)
if gl_entries:
diff --git a/erpnext/accounts/desk_page/accounting/accounting.json b/erpnext/accounts/desk_page/accounting/accounting.json
index 0d6aca65b16..42fb9f4f37d 100644
--- a/erpnext/accounts/desk_page/accounting/accounting.json
+++ b/erpnext/accounts/desk_page/accounting/accounting.json
@@ -18,7 +18,7 @@
{
"hidden": 0,
"label": "Accounts Payable",
- "links": "[\n {\n \"description\": \"Bills raised by Suppliers.\",\n \"label\": \"Purchase Invoice\",\n \"name\": \"Purchase Invoice\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Supplier database.\",\n \"label\": \"Supplier\",\n \"name\": \"Supplier\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Bank/Cash transactions against party or for internal transfer\",\n \"label\": \"Payment Entry\",\n \"name\": \"Payment Entry\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Accounts Payable\",\n \"name\": \"Accounts Payable\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Accounts Payable Summary\",\n \"name\": \"Accounts Payable Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Purchase Register\",\n \"name\": \"Purchase Register\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Item-wise Purchase Register\",\n \"name\": \"Item-wise Purchase Register\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Purchase Order Items To Be Billed\",\n \"name\": \"Purchase Order Items To Be Billed\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Received Items To Be Billed\",\n \"name\": \"Received Items To Be Billed\",\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"description\": \"Bills raised by Suppliers.\",\n \"label\": \"Purchase Invoice\",\n \"name\": \"Purchase Invoice\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Supplier database.\",\n \"label\": \"Supplier\",\n \"name\": \"Supplier\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Bank/Cash transactions against party or for internal transfer\",\n \"label\": \"Payment Entry\",\n \"name\": \"Payment Entry\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Accounts Payable\",\n \"name\": \"Accounts Payable\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Accounts Payable Summary\",\n \"name\": \"Accounts Payable Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Purchase Register\",\n \"name\": \"Purchase Register\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Item-wise Purchase Register\",\n \"name\": \"Item-wise Purchase Register\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Order\"\n ],\n \"doctype\": \"Purchase Order\",\n \"is_query_report\": true,\n \"label\": \"Purchase Order Analysis\",\n \"name\": \"Purchase Order Analysis\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Invoice\"\n ],\n \"doctype\": \"Purchase Invoice\",\n \"is_query_report\": true,\n \"label\": \"Received Items To Be Billed\",\n \"name\": \"Received Items To Be Billed\",\n \"type\": \"report\"\n }\n]"
},
{
"hidden": 0,
@@ -45,11 +45,6 @@
"label": "Bank Statement",
"links": "[\n {\n \"label\": \"Bank\",\n \"name\": \"Bank\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Bank Account\",\n \"name\": \"Bank Account\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Bank Statement Transaction Entry\",\n \"name\": \"Bank Statement Transaction Entry\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Bank Statement Settings\",\n \"name\": \"Bank Statement Settings\",\n \"type\": \"doctype\"\n }\n]"
},
- {
- "hidden": 0,
- "links": "[\n {\n \"description\": \"Match non-linked Invoices and Payments.\",\n \"label\": \"Match Payments with Invoices\",\n \"name\": \"Payment Reconciliation\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Update bank payment dates with journals.\",\n \"label\": \"Update Bank Clearance Dates\",\n \"name\": \"Bank Clearance\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Invoice Discounting\",\n \"name\": \"Invoice Discounting\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Journal Entry\"\n ],\n \"doctype\": \"Journal Entry\",\n \"is_query_report\": true,\n \"label\": \"Bank Reconciliation Statement\",\n \"name\": \"Bank Reconciliation Statement\",\n \"type\": \"report\"\n },\n {\n \"icon\": \"fa fa-bar-chart\",\n \"label\": \"Bank Reconciliation\",\n \"name\": \"bank-reconciliation\",\n \"type\": \"page\"\n },\n {\n \"dependencies\": [\n \"Journal Entry\"\n ],\n \"doctype\": \"Journal Entry\",\n \"is_query_report\": true,\n \"label\": \"Bank Clearance Summary\",\n \"name\": \"Bank Clearance Summary\",\n \"type\": \"report\"\n },\n {\n \"label\": \"Bank Guarantee\",\n \"name\": \"Bank Guarantee\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Setup cheque dimensions for printing\",\n \"label\": \"Cheque Print Template\",\n \"name\": \"Cheque Print Template\",\n \"type\": \"doctype\"\n }\n]",
- "title": "Banking and Payments"
- },
{
"hidden": 0,
"label": "Subscription Management",
@@ -89,8 +84,8 @@
"category": "Modules",
"charts": [
{
- "chart_name": "Bank Balance",
- "label": "Bank Balance"
+ "chart_name": "Profit and Loss",
+ "label": "Profit and Loss"
}
],
"creation": "2020-03-02 15:41:59.515192",
@@ -99,23 +94,39 @@
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Accounting",
- "modified": "2020-04-29 12:17:34.844397",
+ "modified": "2020-05-27 20:34:50.949772",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounting",
+ "onboarding": "Accounts",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
- "label": "Account",
+ "label": "Chart Of Accounts",
"link_to": "Account",
"type": "DocType"
},
+ {
+ "label": "Sales Invoice",
+ "link_to": "Sales Invoice",
+ "type": "DocType"
+ },
+ {
+ "label": "Purchase Invoice",
+ "link_to": "Purchase Invoice",
+ "type": "DocType"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "Accounts",
+ "type": "Dashboard"
+ },
{
"label": "Journal Entry",
"link_to": "Journal Entry",
@@ -136,11 +147,6 @@
"link_to": "General Ledger",
"type": "Report"
},
- {
- "label": "Profit and Loss Statement",
- "link_to": "Profit and Loss Statement",
- "type": "Report"
- },
{
"label": "Trial Balance",
"link_to": "Trial Balance",
diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js
index f62d07668de..28b090bdadb 100644
--- a/erpnext/accounts/doctype/account/account_tree.js
+++ b/erpnext/accounts/doctype/account/account_tree.js
@@ -14,6 +14,9 @@ frappe.treeview_settings["Account"] = {
on_change: function() {
var me = frappe.treeview_settings['Account'].treeview;
var company = me.page.fields_dict.company.get_value();
+ if (!company) {
+ frappe.throw(__("Please set a Company"));
+ }
frappe.call({
method: "erpnext.accounts.doctype.account.account.get_root_company",
args: {
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index 7a85bfb26b6..894ec5bdec5 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -162,9 +162,9 @@ def toggle_disabling(doc):
def get_doctypes_with_dimensions():
doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry", "Asset",
- "Expense Claim", "Stock Entry", "Budget", "Payroll Entry", "Delivery Note", "Sales Invoice Item", "Purchase Invoice Item",
- "Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
- "Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule",
+ "Expense Claim", "Expense Claim Detail", "Expense Taxes and Charges", "Stock Entry", "Budget", "Payroll Entry", "Delivery Note",
+ "Sales Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item",
+ "Purchase Receipt Item", "Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule",
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
"Travel Request", "Fees", "POS Profile", "Opening Invoice Creation Tool", "Opening Invoice Creation Tool Item", "Subscription",
"Subscription Plan"]
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js
index 9e2f6eed3b6..f341f782078 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.js
+++ b/erpnext/accounts/doctype/cost_center/cost_center.js
@@ -14,7 +14,18 @@ frappe.ui.form.on('Cost Center', {
is_group: 1
}
}
- })
+ });
+
+ frm.set_query("cost_center", "distributed_cost_center", function() {
+ return {
+ filters: {
+ company: frm.doc.company,
+ is_group: 0,
+ enable_distributed_cost_center: 0,
+ name: ['!=', frm.doc.name]
+ }
+ };
+ });
},
refresh: function(frm) {
if (!frm.is_new()) {
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json
index 5013c92a327..c9bbbabe798 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.json
+++ b/erpnext/accounts/doctype/cost_center/cost_center.json
@@ -16,6 +16,9 @@
"cb0",
"is_group",
"disabled",
+ "section_break_9",
+ "enable_distributed_cost_center",
+ "distributed_cost_center",
"lft",
"rgt",
"old_parent"
@@ -119,6 +122,24 @@
"fieldname": "disabled",
"fieldtype": "Check",
"label": "Disabled"
+ },
+ {
+ "default": "0",
+ "fieldname": "enable_distributed_cost_center",
+ "fieldtype": "Check",
+ "label": "Enable Distributed Cost Center"
+ },
+ {
+ "depends_on": "eval:doc.is_group==0",
+ "fieldname": "section_break_9",
+ "fieldtype": "Section Break"
+ },
+ {
+ "depends_on": "enable_distributed_cost_center",
+ "fieldname": "distributed_cost_center",
+ "fieldtype": "Table",
+ "label": "Distributed Cost Center",
+ "options": "Distributed Cost Center"
}
],
"icon": "fa fa-money",
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py
index 0294e78111c..12094d4f989 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/cost_center.py
@@ -19,6 +19,24 @@ class CostCenter(NestedSet):
def validate(self):
self.validate_mandatory()
self.validate_parent_cost_center()
+ self.validate_distributed_cost_center()
+
+ def validate_distributed_cost_center(self):
+ if cint(self.enable_distributed_cost_center):
+ if not self.distributed_cost_center:
+ frappe.throw(_("Please enter distributed cost center"))
+ if sum(x.percentage_allocation for x in self.distributed_cost_center) != 100:
+ frappe.throw(_("Total percentage allocation for distributed cost center should be equal to 100"))
+ if not self.get('__islocal'):
+ if not cint(frappe.get_cached_value("Cost Center", {"name": self.name}, "enable_distributed_cost_center")) \
+ and self.check_if_part_of_distributed_cost_center():
+ frappe.throw(_("Cannot enable Distributed Cost Center for a Cost Center already allocated in another Distributed Cost Center"))
+ if next((True for x in self.distributed_cost_center if x.cost_center == x.parent), False):
+ frappe.throw(_("Parent Cost Center cannot be added in Distributed Cost Center"))
+ if check_if_distributed_cost_center_enabled(list(x.cost_center for x in self.distributed_cost_center)):
+ frappe.throw(_("A Distributed Cost Center cannot be added in the Distributed Cost Center allocation table."))
+ else:
+ self.distributed_cost_center = []
def validate_mandatory(self):
if self.cost_center_name != self.company and not self.parent_cost_center:
@@ -43,12 +61,15 @@ class CostCenter(NestedSet):
return 1
def convert_ledger_to_group(self):
+ if cint(self.enable_distributed_cost_center):
+ frappe.throw(_("Cost Center with enabled distributed cost center can not be converted to group"))
+ if self.check_if_part_of_distributed_cost_center():
+ frappe.throw(_("Cost Center Already Allocated in a Distributed Cost Center cannot be converted to group"))
if self.check_gle_exists():
frappe.throw(_("Cost Center with existing transactions can not be converted to group"))
- else:
- self.is_group = 1
- self.save()
- return 1
+ self.is_group = 1
+ self.save()
+ return 1
def check_gle_exists(self):
return frappe.db.get_value("GL Entry", {"cost_center": self.name})
@@ -57,6 +78,9 @@ class CostCenter(NestedSet):
return frappe.db.sql("select name from `tabCost Center` where \
parent_cost_center = %s and docstatus != 2", self.name)
+ def check_if_part_of_distributed_cost_center(self):
+ return frappe.db.get_value("Distributed Cost Center", {"cost_center": self.name})
+
def before_rename(self, olddn, newdn, merge=False):
# Add company abbr if not provided
from erpnext.setup.doctype.company.company import get_name_with_abbr
@@ -100,3 +124,7 @@ def get_name_with_number(new_account, account_number):
if account_number and not new_account[0].isdigit():
new_account = account_number + " - " + new_account
return new_account
+
+def check_if_distributed_cost_center_enabled(cost_center_list):
+ value_list = frappe.get_list("Cost Center", {"name": ["in", cost_center_list]}, "enable_distributed_cost_center", as_list=1)
+ return next((True for x in value_list if x[0]), False)
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/cost_center/test_cost_center.py b/erpnext/accounts/doctype/cost_center/test_cost_center.py
index 8f23d906760..b5fc7e3b497 100644
--- a/erpnext/accounts/doctype/cost_center/test_cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/test_cost_center.py
@@ -22,6 +22,33 @@ class TestCostCenter(unittest.TestCase):
self.assertRaises(frappe.ValidationError, cost_center.save)
+ def test_validate_distributed_cost_center(self):
+
+ if not frappe.db.get_value('Cost Center', {'name': '_Test Cost Center - _TC'}):
+ frappe.get_doc(test_records[0]).insert()
+
+ if not frappe.db.get_value('Cost Center', {'name': '_Test Cost Center 2 - _TC'}):
+ frappe.get_doc(test_records[1]).insert()
+
+ invalid_distributed_cost_center = frappe.get_doc({
+ "company": "_Test Company",
+ "cost_center_name": "_Test Distributed Cost Center",
+ "doctype": "Cost Center",
+ "is_group": 0,
+ "parent_cost_center": "_Test Company - _TC",
+ "enable_distributed_cost_center": 1,
+ "distributed_cost_center": [{
+ "cost_center": "_Test Cost Center - _TC",
+ "percentage_allocation": 40
+ }, {
+ "cost_center": "_Test Cost Center 2 - _TC",
+ "percentage_allocation": 50
+ }
+ ]
+ })
+
+ self.assertRaises(frappe.ValidationError, invalid_distributed_cost_center.save)
+
def create_cost_center(**args):
args = frappe._dict(args)
if args.cost_center_name:
diff --git a/erpnext/buying/report/requested_items_to_be_ordered/__init__.py b/erpnext/accounts/doctype/distributed_cost_center/__init__.py
similarity index 100%
rename from erpnext/buying/report/requested_items_to_be_ordered/__init__.py
rename to erpnext/accounts/doctype/distributed_cost_center/__init__.py
diff --git a/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.json b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.json
new file mode 100644
index 00000000000..45b0e2df9ba
--- /dev/null
+++ b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.json
@@ -0,0 +1,40 @@
+{
+ "actions": [],
+ "creation": "2020-03-19 12:34:01.500390",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "cost_center",
+ "percentage_allocation"
+ ],
+ "fields": [
+ {
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Cost Center",
+ "options": "Cost Center",
+ "reqd": 1
+ },
+ {
+ "fieldname": "percentage_allocation",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Percentage Allocation",
+ "reqd": 1
+ }
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-03-19 12:54:43.674655",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Distributed Cost Center",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py
new file mode 100644
index 00000000000..48c589f0c0f
--- /dev/null
+++ b/erpnext/accounts/doctype/distributed_cost_center/distributed_cost_center.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+# 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/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index efab5801e8b..291aff3f5ad 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -112,8 +112,8 @@ class GLEntry(Document):
from tabAccount where name=%s""", self.account, as_dict=1)[0]
if ret.is_group==1:
- frappe.throw(_("{0} {1}: Account {2} cannot be a Group")
- .format(self.voucher_type, self.voucher_no, self.account))
+ frappe.throw(_('''{0} {1}: Account {2} is a Group Account and group accounts cannot be used in
+ transactions''').format(self.voucher_type, self.voucher_no, self.account))
if ret.docstatus==2:
frappe.throw(_("{0} {1}: Account {2} is inactive")
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
index 39fc203d53f..594b4d4a223 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
@@ -8,6 +8,7 @@ from frappe import _
from frappe.utils import flt, getdate, nowdate, add_days
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.accounts.general_ledger import make_gl_entries
+from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
class InvoiceDiscounting(AccountsController):
def validate(self):
@@ -81,10 +82,15 @@ class InvoiceDiscounting(AccountsController):
def make_gl_entries(self):
company_currency = frappe.get_cached_value('Company', self.company, "default_currency")
+
gl_entries = []
+ invoice_fields = ["debit_to", "party_account_currency", "conversion_rate", "cost_center"]
+ accounting_dimensions = get_accounting_dimensions()
+
+ invoice_fields.extend(accounting_dimensions)
+
for d in self.invoices:
- inv = frappe.db.get_value("Sales Invoice", d.sales_invoice,
- ["debit_to", "party_account_currency", "conversion_rate", "cost_center"], as_dict=1)
+ inv = frappe.db.get_value("Sales Invoice", d.sales_invoice, invoice_fields, as_dict=1)
if d.outstanding_amount:
outstanding_in_company_currency = flt(d.outstanding_amount * inv.conversion_rate,
@@ -102,7 +108,7 @@ class InvoiceDiscounting(AccountsController):
"cost_center": inv.cost_center,
"against_voucher": d.sales_invoice,
"against_voucher_type": "Sales Invoice"
- }, inv.party_account_currency))
+ }, inv.party_account_currency, item=inv))
gl_entries.append(self.get_gl_dict({
"account": self.accounts_receivable_credit,
@@ -115,7 +121,7 @@ class InvoiceDiscounting(AccountsController):
"cost_center": inv.cost_center,
"against_voucher": d.sales_invoice,
"against_voucher_type": "Sales Invoice"
- }, ar_credit_account_currency))
+ }, ar_credit_account_currency, item=inv))
make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding='No')
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json
index 9d5063929fd..af2aa65e6b2 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.json
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json
@@ -191,6 +191,7 @@
{
"fieldname": "total_debit",
"fieldtype": "Currency",
+ "in_list_view": 1,
"label": "Total Debit",
"no_copy": 1,
"oldfieldname": "total_debit",
@@ -252,7 +253,6 @@
"fieldname": "total_amount",
"fieldtype": "Currency",
"hidden": 1,
- "in_list_view": 1,
"label": "Total Amount",
"no_copy": 1,
"options": "total_amount_currency",
@@ -503,7 +503,7 @@
"idx": 176,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-29 10:55:28.240916",
+ "modified": "2020-06-02 18:15:46.955697",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Journal Entry",
diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js
index 4d8da37efe0..699eb08e178 100644
--- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js
+++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.js
@@ -11,21 +11,9 @@ frappe.ui.form.on('Opening Invoice Creation Tool', {
};
});
- frm.set_query('cost_center', 'invoices', function(doc, cdt, cdn) {
- return {
- filters: {
- 'company': doc.company
- }
- };
- });
-
- frm.set_query('cost_center', function(doc) {
- return {
- filters: {
- 'company': doc.company
- }
- };
- });
+ if (frm.doc.company) {
+ frm.trigger('setup_company_filters');
+ }
},
refresh: function(frm) {
@@ -51,19 +39,50 @@ frappe.ui.form.on('Opening Invoice Creation Tool', {
});
},
- company: function(frm) {
- frappe.call({
- method: 'erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_creation_tool.get_temporary_opening_account',
- args: {
- company: frm.doc.company
- },
- callback: (r) => {
- if (r.message) {
- frm.doc.__onload.temporary_opening_account = r.message;
- frm.trigger('update_invoice_table');
+ setup_company_filters: function(frm) {
+ frm.set_query('cost_center', 'invoices', function(doc, cdt, cdn) {
+ return {
+ filters: {
+ 'company': doc.company
+ }
+ };
+ });
+
+ frm.set_query('cost_center', function(doc) {
+ return {
+ filters: {
+ 'company': doc.company
+ }
+ };
+ });
+
+ frm.set_query('temporary_opening_account', 'invoices', function(doc, cdt, cdn) {
+ return {
+ filters: {
+ 'company': doc.company
}
}
- })
+ });
+ },
+
+ company: function(frm) {
+ if (frm.doc.company) {
+
+ frm.trigger('setup_company_filters');
+
+ frappe.call({
+ method: 'erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_creation_tool.get_temporary_opening_account',
+ args: {
+ company: frm.doc.company
+ },
+ callback: (r) => {
+ if (r.message) {
+ frm.doc.__onload.temporary_opening_account = r.message;
+ frm.trigger('update_invoice_table');
+ }
+ }
+ })
+ }
},
invoice_type: function(frm) {
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 83c670eace4..15e51bbd995 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -86,7 +86,7 @@ class PaymentEntry(AccountsController):
self.update_payment_schedule(cancel=1)
self.set_payment_req_status()
self.set_status()
-
+
def set_payment_req_status(self):
from erpnext.accounts.doctype.payment_request.payment_request import update_payment_req_status
update_payment_req_status(self, None)
@@ -280,7 +280,7 @@ class PaymentEntry(AccountsController):
outstanding_amount, is_return = frappe.get_cached_value(d.reference_doctype, d.reference_name, ["outstanding_amount", "is_return"])
if outstanding_amount <= 0 and not is_return:
no_oustanding_refs.setdefault(d.reference_doctype, []).append(d)
-
+
for k, v in no_oustanding_refs.items():
frappe.msgprint(_("{} - {} now have {} as they had no outstanding amount left before submitting the Payment Entry. \
If this is undesirable please cancel the corresponding Payment Entry.")
@@ -319,7 +319,7 @@ class PaymentEntry(AccountsController):
invoice_payment_amount_map.setdefault(key, 0.0)
invoice_payment_amount_map[key] += reference.allocated_amount
- if not invoice_paid_amount_map.get(reference.reference_name):
+ if not invoice_paid_amount_map.get(key):
payment_schedule = frappe.get_all('Payment Schedule', filters={'parent': reference.reference_name},
fields=['paid_amount', 'payment_amount', 'payment_term'])
for term in payment_schedule:
@@ -332,12 +332,14 @@ class PaymentEntry(AccountsController):
frappe.db.sql(""" UPDATE `tabPayment Schedule` SET paid_amount = `paid_amount` - %s
WHERE parent = %s and payment_term = %s""", (amount, key[1], key[0]))
else:
- outstanding = invoice_paid_amount_map.get(key)['outstanding']
+ outstanding = flt(invoice_paid_amount_map.get(key, {}).get('outstanding'))
+
if amount > outstanding:
frappe.throw(_('Cannot allocate more than {0} against payment term {1}').format(outstanding, key[0]))
- frappe.db.sql(""" UPDATE `tabPayment Schedule` SET paid_amount = `paid_amount` + %s
- WHERE parent = %s and payment_term = %s""", (amount, key[1], key[0]))
+ if amount and outstanding:
+ frappe.db.sql(""" UPDATE `tabPayment Schedule` SET paid_amount = `paid_amount` + %s
+ WHERE parent = %s and payment_term = %s""", (amount, key[1], key[0]))
def set_status(self):
if self.docstatus == 2:
@@ -451,8 +453,6 @@ class PaymentEntry(AccountsController):
frappe.throw(_("Reference No and Reference Date is mandatory for Bank transaction"))
def set_remarks(self):
- if self.remarks: return
-
if self.payment_type=="Internal Transfer":
remarks = [_("Amount {0} {1} transferred from {2} to {3}")
.format(self.paid_from_account_currency, self.paid_amount, self.paid_from, self.paid_to)]
@@ -506,7 +506,7 @@ class PaymentEntry(AccountsController):
"against": against_account,
"account_currency": self.party_account_currency,
"cost_center": self.cost_center
- })
+ }, item=self)
dr_or_cr = "credit" if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit"
@@ -550,7 +550,7 @@ class PaymentEntry(AccountsController):
"credit_in_account_currency": self.paid_amount,
"credit": self.base_paid_amount,
"cost_center": self.cost_center
- })
+ }, item=self)
)
if self.payment_type in ("Receive", "Internal Transfer"):
gl_entries.append(
@@ -561,7 +561,7 @@ class PaymentEntry(AccountsController):
"debit_in_account_currency": self.received_amount,
"debit": self.base_received_amount,
"cost_center": self.cost_center
- })
+ }, item=self)
)
def add_deductions_gl_entries(self, gl_entries):
@@ -1093,17 +1093,20 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
def get_reference_as_per_payment_terms(payment_schedule, dt, dn, doc, grand_total, outstanding_amount):
references = []
for payment_term in payment_schedule:
- references.append({
- 'reference_doctype': dt,
- 'reference_name': dn,
- 'bill_no': doc.get('bill_no'),
- 'due_date': doc.get('due_date'),
- 'total_amount': grand_total,
- 'outstanding_amount': outstanding_amount,
- 'payment_term': payment_term.payment_term,
- 'allocated_amount': flt(payment_term.payment_amount - payment_term.paid_amount,
+ payment_term_outstanding = flt(payment_term.payment_amount - payment_term.paid_amount,
payment_term.precision('payment_amount'))
- })
+
+ if payment_term_outstanding:
+ references.append({
+ 'reference_doctype': dt,
+ 'reference_name': dn,
+ 'bill_no': doc.get('bill_no'),
+ 'due_date': doc.get('due_date'),
+ 'total_amount': grand_total,
+ 'outstanding_amount': outstanding_amount,
+ 'payment_term': payment_term.payment_term,
+ 'allocated_amount': payment_term_outstanding
+ })
return references
diff --git a/erpnext/accounts/doctype/payment_order/payment_order.py b/erpnext/accounts/doctype/payment_order/payment_order.py
index 3f3174a69b6..7ecdc41d034 100644
--- a/erpnext/accounts/doctype/payment_order/payment_order.py
+++ b/erpnext/accounts/doctype/payment_order/payment_order.py
@@ -80,7 +80,7 @@ def make_journal_entry(doc, supplier, mode_of_payment=None):
paid_amt += d.amount
je.append('accounts', {
- 'account': doc.references[0].account,
+ 'account': doc.account,
'credit_in_account_currency': paid_amt
})
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index 97ae5ffde36..eef6be1a7a1 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"autoname": "naming_series:",
"creation": "2015-12-15 22:23:24.745065",
"doctype": "DocType",
@@ -210,13 +211,14 @@
"label": "IBAN"
},
{
- "fetch_from": "bank_account.branch_code",
+ "fetch_from": "bank.branch_code",
+ "fetch_if_empty": 1,
"fieldname": "branch_code",
"fieldtype": "Read Only",
"label": "Branch Code"
},
{
- "fetch_from": "bank_account.swift_number",
+ "fetch_from": "bank.swift_number",
"fieldname": "swift_number",
"fieldtype": "Read Only",
"label": "SWIFT Number"
@@ -347,8 +349,10 @@
"read_only": 1
}
],
+ "in_create": 1,
"is_submittable": 1,
- "modified": "2020-03-28 16:07:31.960798",
+ "links": [],
+ "modified": "2020-05-29 17:38:49.392713",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Request",
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 68aeb6d1d65..287e00f70fd 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -69,7 +69,7 @@ class PaymentRequest(Document):
elif self.payment_request_type == 'Inward':
self.db_set('status', 'Requested')
- send_mail = self.payment_gateway_validation()
+ send_mail = self.payment_gateway_validation() if self.payment_gateway else None
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart") \
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 19f571fb306..4d9053a55b3 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -99,7 +99,7 @@ class PricingRule(Document):
self.same_item = 1
def validate_max_discount(self):
- if self.rate_or_discount == "Discount Percentage" and self.items:
+ if self.rate_or_discount == "Discount Percentage" and self.get("items"):
for d in self.items:
max_discount = frappe.get_cached_value("Item", d.item_code, "max_discount")
if max_discount and flt(self.discount_percentage) > flt(max_discount):
diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
index 2da71dfd0e0..2bf0b725635 100644
--- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
@@ -385,6 +385,50 @@ class TestPricingRule(unittest.TestCase):
so.load_from_db()
self.assertEqual(so.items[1].is_free_item, 1)
self.assertEqual(so.items[1].item_code, "_Test Item 2")
+
+ def test_cumulative_pricing_rule(self):
+ frappe.delete_doc_if_exists('Pricing Rule', '_Test Cumulative Pricing Rule')
+ test_record = {
+ "doctype": "Pricing Rule",
+ "title": "_Test Cumulative Pricing Rule",
+ "apply_on": "Item Code",
+ "currency": "USD",
+ "items": [{
+ "item_code": "_Test Item",
+ }],
+ "is_cumulative": 1,
+ "selling": 1,
+ "applicable_for": "Customer",
+ "customer": "_Test Customer",
+ "rate_or_discount": "Discount Percentage",
+ "rate": 0,
+ "min_amt": 0,
+ "max_amt": 10000,
+ "discount_percentage": 17.5,
+ "price_or_product_discount": "Price",
+ "company": "_Test Company",
+ "valid_from": frappe.utils.nowdate(),
+ "valid_upto": frappe.utils.nowdate()
+ }
+ frappe.get_doc(test_record.copy()).insert()
+
+ args = frappe._dict({
+ "item_code": "_Test Item",
+ "company": "_Test Company",
+ "price_list": "_Test Price List",
+ "currency": "_Test Currency",
+ "doctype": "Sales Invoice",
+ "conversion_rate": 1,
+ "price_list_currency": "_Test Currency",
+ "plc_conversion_rate": 1,
+ "order_type": "Sales",
+ "customer": "_Test Customer",
+ "name": None,
+ "transaction_date": frappe.utils.nowdate()
+ })
+ details = get_item_details(args)
+
+ self.assertTrue(details)
def make_pricing_rule(**args):
args = frappe._dict(args)
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index b358f56671f..53115f92d01 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -4,13 +4,19 @@
# For license information, please see license.txt
from __future__ import unicode_literals
-import frappe, copy, json
-from frappe import throw, _
+
+import copy
+import json
+
from six import string_types
-from frappe.utils import flt, cint, get_datetime, get_link_to_form, today
+
+import frappe
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 _, throw
+from frappe.utils import cint, flt, get_datetime, get_link_to_form, getdate, today
+
class MultiplePricingRuleConflict(frappe.ValidationError): pass
@@ -360,8 +366,7 @@ def get_qty_amount_data_for_cumulative(pr_doc, doc, items=[]):
sum_qty, sum_amt = [0, 0]
doctype = doc.get('parenttype') or doc.doctype
- date_field = ('transaction_date'
- if doc.get('transaction_date') else 'posting_date')
+ date_field = 'transaction_date' if frappe.get_meta(doctype).has_field('transaction_date') else 'posting_date'
child_doctype = '{0} Item'.format(doctype)
apply_on = frappe.scrub(pr_doc.get('apply_on'))
@@ -502,18 +507,16 @@ def get_pricing_rule_items(pr_doc):
return list(set(apply_on_data))
def validate_coupon_code(coupon_name):
- from frappe.utils import today,getdate
- coupon=frappe.get_doc("Coupon Code",coupon_name)
+ coupon = frappe.get_doc("Coupon Code", coupon_name)
+
if coupon.valid_from:
- if coupon.valid_from > getdate(today()) :
- frappe.throw(_("Sorry,coupon code validity has not started"))
+ if coupon.valid_from > getdate(today()):
+ frappe.throw(_("Sorry, this coupon code's validity has not started"))
elif coupon.valid_upto:
- if coupon.valid_upto < getdate(today()) :
- frappe.throw(_("Sorry,coupon code validity has expired"))
- elif coupon.used>=coupon.maximum_use:
- frappe.throw(_("Sorry,coupon code are exhausted"))
- else:
- return
+ if coupon.valid_upto < getdate(today()):
+ frappe.throw(_("Sorry, this coupon code's validity has expired"))
+ elif coupon.used >= coupon.maximum_use:
+ frappe.throw(_("Sorry, this coupon code is no longer valid"))
def update_coupon_code_count(coupon_name,transaction_type):
coupon=frappe.get_doc("Coupon Code",coupon_name)
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 98ba5c72ae2..829c34da67c 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -42,6 +42,8 @@
"col_break_address",
"shipping_address",
"shipping_address_display",
+ "billing_address",
+ "billing_address_display",
"currency_and_price_list",
"currency",
"conversion_rate",
@@ -168,7 +170,9 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "naming_series",
@@ -180,7 +184,9 @@
"options": "ACC-PINV-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1
+ "set_only_once": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier",
@@ -192,7 +198,9 @@
"options": "Supplier",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -204,7 +212,9 @@
"label": "Supplier Name",
"oldfieldname": "supplier_name",
"oldfieldtype": "Data",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fetch_from": "supplier.tax_id",
@@ -212,21 +222,27 @@
"fieldtype": "Read Only",
"label": "Tax Id",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "due_date",
"fieldtype": "Date",
"label": "Due Date",
"oldfieldname": "due_date",
- "oldfieldtype": "Date"
+ "oldfieldtype": "Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "is_paid",
"fieldtype": "Check",
"label": "Is Paid",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -234,19 +250,25 @@
"fieldtype": "Check",
"label": "Is Return (Debit Note)",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "apply_tds",
"fieldtype": "Check",
"label": "Apply Tax Withholding Amount",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -256,13 +278,17 @@
"label": "Company",
"options": "Company",
"print_hide": 1,
- "remember_last_selected_value": 1
+ "remember_last_selected_value": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
- "options": "Cost Center"
+ "options": "Cost Center",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Today",
@@ -274,7 +300,9 @@
"oldfieldtype": "Date",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "posting_time",
@@ -283,6 +311,8 @@
"no_copy": 1,
"print_hide": 1,
"print_width": "100px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -291,7 +321,9 @@
"fieldname": "set_posting_time",
"fieldtype": "Check",
"label": "Edit Posting Date and Time",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "amended_from",
@@ -303,44 +335,58 @@
"oldfieldtype": "Link",
"options": "Purchase Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "eval:doc.on_hold",
"fieldname": "sb_14",
"fieldtype": "Section Break",
- "label": "Hold Invoice"
+ "label": "Hold Invoice",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "on_hold",
"fieldtype": "Check",
- "label": "Hold Invoice"
+ "label": "Hold Invoice",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.on_hold",
"description": "Once set, this invoice will be on hold till the set date",
"fieldname": "release_date",
"fieldtype": "Date",
- "label": "Release Date"
+ "label": "Release Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cb_17",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.on_hold",
"fieldname": "hold_comment",
"fieldtype": "Small Text",
- "label": "Reason For Putting On Hold"
+ "label": "Reason For Putting On Hold",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "bill_no",
"fieldname": "supplier_invoice_details",
"fieldtype": "Section Break",
- "label": "Supplier Invoice Details"
+ "label": "Supplier Invoice Details",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_no",
@@ -348,11 +394,15 @@
"label": "Supplier Invoice No",
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_15",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_date",
@@ -360,13 +410,17 @@
"label": "Supplier Invoice Date",
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "return_against",
"fieldname": "returns",
"fieldtype": "Section Break",
- "label": "Returns"
+ "label": "Returns",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "return_against",
@@ -376,26 +430,34 @@
"no_copy": 1,
"options": "Purchase Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact"
+ "label": "Address and Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Select Supplier Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "address_display",
"fieldtype": "Small Text",
"label": "Address",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_person",
@@ -403,51 +465,67 @@
"in_global_search": 1,
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_display",
"fieldtype": "Small Text",
"label": "Contact",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_mobile",
"fieldtype": "Small Text",
"label": "Mobile No",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_email",
"fieldtype": "Small Text",
"label": "Contact Email",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Select Shipping Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag"
+ "options": "fa fa-tag",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "currency",
@@ -456,7 +534,9 @@
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "conversion_rate",
@@ -465,18 +545,24 @@
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break2",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "price_list_currency",
@@ -484,14 +570,18 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -500,11 +590,15 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sec_warehouse",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "update_stock",
@@ -512,7 +606,9 @@
"fieldtype": "Link",
"label": "Set Accepted Warehouse",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "update_stock",
@@ -522,11 +618,15 @@
"label": "Rejected Warehouse",
"no_copy": 1,
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -534,7 +634,9 @@
"fieldtype": "Select",
"label": "Raw Materials Supplied",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.is_subcontracted==\"Yes\"",
@@ -545,25 +647,33 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "50px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50px"
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart"
+ "options": "fa fa-shopping-cart",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "update_stock",
"fieldtype": "Check",
"label": "Update Stock",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode"
+ "label": "Scan Barcode",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_bulk_edit": 1,
@@ -573,42 +683,56 @@
"oldfieldname": "entries",
"oldfieldtype": "Table",
"options": "Purchase Invoice Item",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rule_details",
"fieldtype": "Section Break",
- "label": "Pricing Rules"
+ "label": "Pricing Rules",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Pricing Rule Detail",
"options": "Pricing Rule Detail",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible_depends_on": "supplied_items",
"fieldname": "raw_materials_supplied",
"fieldtype": "Section Break",
- "label": "Raw Materials Supplied"
+ "label": "Raw Materials Supplied",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplied_items",
"fieldtype": "Table",
"label": "Supplied Items",
"options": "Purchase Receipt Item Supplied",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_26",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total",
@@ -616,7 +740,9 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_net_total",
@@ -626,18 +752,24 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_28",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "net_total",
@@ -647,42 +779,56 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_49",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
"options": "Shipping Rule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_51",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges",
@@ -691,7 +837,9 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes",
@@ -699,13 +847,17 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup"
+ "label": "Tax Breakup",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_charges_calculation",
@@ -714,13 +866,17 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_added",
@@ -730,7 +886,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_deducted",
@@ -740,7 +898,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total_taxes_and_charges",
@@ -750,11 +910,15 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_40",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_added",
@@ -764,7 +928,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_deducted",
@@ -774,7 +940,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_taxes_and_charges",
@@ -782,14 +950,18 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "discount_amount",
"fieldname": "section_break_44",
"fieldtype": "Section Break",
- "label": "Additional Discount"
+ "label": "Additional Discount",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Grand Total",
@@ -797,7 +969,9 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_discount_amount",
@@ -805,28 +979,38 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_46",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_49",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_grand_total",
@@ -836,7 +1020,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounding_adjustment",
@@ -845,7 +1031,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -855,7 +1043,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_in_words",
@@ -864,13 +1054,17 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break8",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -881,7 +1075,9 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "rounding_adjustment",
@@ -890,7 +1086,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -900,7 +1098,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "in_words",
@@ -909,7 +1109,9 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_advance",
@@ -920,7 +1122,9 @@
"oldfieldtype": "Currency",
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "outstanding_amount",
@@ -931,14 +1135,18 @@
"oldfieldtype": "Currency",
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"depends_on": "grand_total",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total"
+ "label": "Disable Rounded Total",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -946,30 +1154,40 @@
"depends_on": "eval:doc.is_paid===1||(doc.advances && doc.advances.length>0)",
"fieldname": "payments_section",
"fieldtype": "Section Break",
- "label": "Payments"
+ "label": "Payments",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "mode_of_payment",
"fieldtype": "Link",
"label": "Mode of Payment",
"options": "Mode of Payment",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cash_bank_account",
"fieldtype": "Link",
"label": "Cash/Bank Account",
- "options": "Account"
+ "options": "Account",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "clearance_date",
"fieldtype": "Date",
"hidden": 1,
- "label": "Clearance Date"
+ "label": "Clearance Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_br_payments",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "is_paid",
@@ -978,7 +1196,9 @@
"label": "Paid Amount",
"no_copy": 1,
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_paid_amount",
@@ -987,7 +1207,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -995,7 +1217,9 @@
"depends_on": "grand_total",
"fieldname": "write_off",
"fieldtype": "Section Break",
- "label": "Write Off"
+ "label": "Write Off",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "write_off_amount",
@@ -1003,7 +1227,9 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_write_off_amount",
@@ -1012,11 +1238,15 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_61",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -1024,7 +1254,9 @@
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -1032,7 +1264,9 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1042,13 +1276,17 @@
"label": "Advance Payments",
"oldfieldtype": "Section Break",
"options": "fa fa-money",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "allocate_advances_automatically",
"fieldtype": "Check",
- "label": "Set Advances and Allocate (FIFO)"
+ "label": "Set Advances and Allocate (FIFO)",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.allocate_advances_automatically",
@@ -1056,7 +1294,9 @@
"fieldtype": "Button",
"label": "Get Advances Paid",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "advances",
@@ -1066,20 +1306,26 @@
"oldfieldname": "advance_allocation_details",
"oldfieldtype": "Table",
"options": "Purchase Invoice Advance",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "eval:(!doc.is_return)",
"fieldname": "payment_schedule_section",
"fieldtype": "Section Break",
- "label": "Payment Terms"
+ "label": "Payment Terms",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"label": "Payment Terms Template",
- "options": "Payment Terms Template"
+ "options": "Payment Terms Template",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_schedule",
@@ -1087,7 +1333,9 @@
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1095,25 +1343,33 @@
"fieldname": "terms_section_break",
"fieldtype": "Section Break",
"label": "Terms and Conditions",
- "options": "fa fa-legal"
+ "options": "fa fa-legal",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
- "label": "Terms and Conditions1"
+ "label": "Terms and Conditions1",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "printing_settings",
"fieldtype": "Section Break",
- "label": "Printing Settings"
+ "label": "Printing Settings",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1121,7 +1377,9 @@
"fieldtype": "Link",
"label": "Letter Head",
"options": "Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1129,11 +1387,15 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_112",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1145,14 +1407,18 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1
+ "report_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1161,7 +1427,9 @@
"label": "More Information",
"oldfieldtype": "Section Break",
"options": "fa fa-file-text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "credit_to",
@@ -1172,7 +1440,9 @@
"options": "Account",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "party_account_currency",
@@ -1182,7 +1452,9 @@
"no_copy": 1,
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -1192,7 +1464,9 @@
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "against_expense_account",
@@ -1202,11 +1476,15 @@
"no_copy": 1,
"oldfieldname": "against_expense_account",
"oldfieldtype": "Small Text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_63",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Draft",
@@ -1215,14 +1493,18 @@
"in_standard_filter": 1,
"label": "Status",
"options": "\nDraft\nReturn\nDebit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "inter_company_invoice_reference",
"fieldtype": "Link",
"label": "Inter Company Invoice Reference",
"options": "Sales Invoice",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "remarks",
@@ -1231,14 +1513,18 @@
"no_copy": 1,
"oldfieldname": "remarks",
"oldfieldtype": "Text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "subscription_section",
"fieldtype": "Section Break",
"label": "Subscription Section",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1247,7 +1533,9 @@
"fieldtype": "Date",
"label": "From Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1256,11 +1544,15 @@
"fieldtype": "Date",
"label": "To Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_114",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "auto_repeat",
@@ -1269,24 +1561,32 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval: doc.auto_repeat",
"fieldname": "update_auto_repeat_reference",
"fieldtype": "Button",
- "label": "Update Auto Repeat Reference"
+ "label": "Update Auto Repeat Reference",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
- "label": "Accounting Dimensions "
+ "label": "Accounting Dimensions ",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "dimension_col_break",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -1294,7 +1594,9 @@
"fieldname": "is_internal_supplier",
"fieldtype": "Check",
"label": "Is Internal Supplier",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_withholding_category",
@@ -1302,14 +1604,32 @@
"hidden": 1,
"label": "Tax Withholding Category",
"options": "Tax Withholding Category",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address",
+ "fieldtype": "Link",
+ "label": "Select Billing Address",
+ "options": "Address",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address_display",
+ "fieldtype": "Small Text",
+ "label": "Billing Address",
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
}
],
"icon": "fa fa-file-text",
"idx": 204,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-18 13:05:25.199832",
+ "modified": "2020-06-13 22:26:30.800199",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 3aa24df16d3..aa1d5b526c8 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -460,7 +460,7 @@ class PurchaseInvoice(BuyingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
def make_item_gl_entries(self, gl_entries):
@@ -841,7 +841,7 @@ class PurchaseInvoice(BuyingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
gl_entries.append(
@@ -852,7 +852,7 @@ class PurchaseInvoice(BuyingController):
"credit_in_account_currency": self.base_paid_amount \
if bank_account_currency==self.company_currency else self.paid_amount,
"cost_center": self.cost_center
- }, bank_account_currency)
+ }, bank_account_currency, item=self)
)
def make_write_off_gl_entry(self, gl_entries):
@@ -873,7 +873,7 @@ class PurchaseInvoice(BuyingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
gl_entries.append(
self.get_gl_dict({
@@ -883,7 +883,7 @@ class PurchaseInvoice(BuyingController):
"credit_in_account_currency": self.base_write_off_amount \
if write_off_account_currency==self.company_currency else self.write_off_amount,
"cost_center": self.cost_center or self.write_off_cost_center
- })
+ }, item=self)
)
def make_gle_for_rounding_adjustment(self, gl_entries):
@@ -902,8 +902,7 @@ class PurchaseInvoice(BuyingController):
"debit_in_account_currency": self.rounding_adjustment,
"debit": self.base_rounding_adjustment,
"cost_center": self.cost_center or round_off_cost_center,
- }
- ))
+ }, item=self))
def on_cancel(self):
super(PurchaseInvoice, self).on_cancel()
@@ -1021,6 +1020,40 @@ class PurchaseInvoice(BuyingController):
# calculate totals again after applying TDS
self.calculate_taxes_and_totals()
+
+ def set_status(self, update=False, status=None, update_modified=True):
+ if self.is_new():
+ if self.get('amended_from'):
+ self.status = 'Draft'
+ return
+
+ precision = self.precision("outstanding_amount")
+ outstanding_amount = flt(self.outstanding_amount, precision)
+ due_date = getdate(self.due_date)
+ nowdate = getdate()
+
+ if not status:
+ if self.docstatus == 2:
+ status = "Cancelled"
+ elif self.docstatus == 1:
+ if outstanding_amount > 0 and due_date < nowdate:
+ self.status = "Overdue"
+ elif outstanding_amount > 0 and due_date >= nowdate:
+ self.status = "Unpaid"
+ #Check if outstanding amount is 0 due to debit note issued against invoice
+ elif outstanding_amount <= 0 and self.is_return == 0 and frappe.db.get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
+ self.status = "Debit Note Issued"
+ elif self.is_return == 1:
+ self.status = "Return"
+ elif outstanding_amount<=0:
+ self.status = "Paid"
+ else:
+ self.status = "Submitted"
+ else:
+ self.status = "Draft"
+
+ if update:
+ self.db_set('status', self.status, update_modified = update_modified)
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index e41ad428469..61700050614 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -86,6 +86,8 @@ class TestPurchaseInvoice(unittest.TestCase):
pe.submit()
pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
+ pi_doc.load_from_db()
+ self.assertTrue(pi_doc.status, "Paid")
self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
unlink_payment_on_cancel_of_invoice()
@@ -203,7 +205,9 @@ class TestPurchaseInvoice(unittest.TestCase):
pi.insert()
pi.submit()
+ pi.load_from_db()
+ self.assertTrue(pi.status, "Unpaid")
self.check_gle_for_pi(pi.name)
def check_gle_for_pi(self, pi):
@@ -234,6 +238,9 @@ class TestPurchaseInvoice(unittest.TestCase):
pi = frappe.copy_doc(test_records[0])
pi.insert()
+ pi.load_from_db()
+
+ self.assertTrue(pi.status, "Draft")
pi.naming_series = 'TEST-'
self.assertRaises(frappe.CannotChangeConstantError, pi.save)
@@ -248,6 +255,8 @@ class TestPurchaseInvoice(unittest.TestCase):
pi.get("taxes").pop(1)
pi.insert()
pi.submit()
+ pi.load_from_db()
+ self.assertTrue(pi.status, "Unpaid")
gl_entries = frappe.db.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
@@ -599,6 +608,11 @@ class TestPurchaseInvoice(unittest.TestCase):
# return entry
pi1 = make_purchase_invoice(is_return=1, return_against=pi.name, qty=-2, rate=50, update_stock=1)
+ pi.load_from_db()
+ self.assertTrue(pi.status, "Debit Note Issued")
+ pi1.load_from_db()
+ self.assertTrue(pi1.status, "Return")
+
actual_qty_2 = get_qty_after_transaction()
self.assertEqual(actual_qty_1 - 2, actual_qty_2)
@@ -771,6 +785,8 @@ class TestPurchaseInvoice(unittest.TestCase):
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import get_outstanding_amount
pi = make_purchase_invoice(item_code = "_Test Item", qty = (5 * -1), rate=500, is_return = 1)
+ pi.load_from_db()
+ self.assertTrue(pi.status, "Return")
outstanding_amount = get_outstanding_amount(pi.doctype,
pi.name, "Creditors - _TC", pi.supplier, "Supplier")
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index f248276e5bb..df0c3d2299b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -924,7 +924,7 @@ var get_healthcare_services_to_invoice = function(frm) {
if(patient && patient!=selected_patient){
selected_patient = patient;
var method = "erpnext.healthcare.utils.get_healthcare_services_to_invoice";
- var args = {patient: patient};
+ var args = {patient: patient, company: frm.doc.company};
var columns = (["service", "reference_name", "reference_type"]);
get_healthcare_items(frm, true, $results, $placeholder, method, args, columns);
}
@@ -1068,7 +1068,11 @@ var get_drugs_to_invoice = function(frm) {
description:'Quantity will be calculated only for items which has "Nos" as UoM. You may change as required for each invoice item.',
get_query: function(doc) {
return {
- filters: { patient: dialog.get_value("patient"), docstatus: 1 }
+ filters: {
+ patient: dialog.get_value("patient"),
+ company: frm.doc.company,
+ docstatus: 1
+ }
};
}
},
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index db205891444..63c34ed2056 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -398,7 +398,7 @@
{
"allow_on_submit": 1,
"fieldname": "po_no",
- "fieldtype": "Data",
+ "fieldtype": "Small Text",
"label": "Customer's Purchase Order",
"no_copy": 1,
"print_hide": 1
@@ -1579,7 +1579,7 @@
"idx": 181,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-29 13:37:09.355300",
+ "modified": "2020-05-19 17:00:57.208696",
"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 3b0fade0e53..5e8279bb08d 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -582,14 +582,14 @@ class SalesInvoice(SellingController):
def validate_item_code(self):
for d in self.get('items'):
- if not d.item_code:
+ if not d.item_code and self.is_opening == "No":
msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True)
def validate_warehouse(self):
super(SalesInvoice, self).validate_warehouse()
for d in self.get_item_list():
- if not d.warehouse and frappe.get_cached_value("Item", d.item_code, "is_stock_item"):
+ if not d.warehouse and d.item_code and frappe.get_cached_value("Item", d.item_code, "is_stock_item"):
frappe.throw(_("Warehouse required for stock Item {0}").format(d.item_code))
def validate_delivery_note(self):
@@ -791,7 +791,7 @@ class SalesInvoice(SellingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
def make_tax_gl_entries(self, gl_entries):
@@ -808,7 +808,7 @@ class SalesInvoice(SellingController):
tax.precision("base_tax_amount_after_discount_amount")) if account_currency==self.company_currency else
flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount_after_discount_amount"))),
"cost_center": tax.cost_center
- }, account_currency)
+ }, account_currency, item=tax)
)
def make_item_gl_entries(self, gl_entries):
@@ -828,7 +828,7 @@ class SalesInvoice(SellingController):
for gle in fixed_asset_gl_entries:
gle["against"] = self.customer
- gl_entries.append(self.get_gl_dict(gle))
+ gl_entries.append(self.get_gl_dict(gle, item=item))
asset.db_set("disposal_date", self.posting_date)
asset.set_status("Sold" if self.docstatus==1 else None)
@@ -866,7 +866,7 @@ class SalesInvoice(SellingController):
"against_voucher": self.return_against if cint(self.is_return) else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- })
+ }, item=self)
)
gl_entries.append(
self.get_gl_dict({
@@ -875,7 +875,7 @@ class SalesInvoice(SellingController):
"against": self.customer,
"debit": self.loyalty_amount,
"remark": "Loyalty Points redeemed by the customer"
- })
+ }, item=self)
)
def make_pos_gl_entries(self, gl_entries):
@@ -896,7 +896,7 @@ class SalesInvoice(SellingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
payment_mode_account_currency = get_account_currency(payment_mode.account)
@@ -909,7 +909,7 @@ class SalesInvoice(SellingController):
if payment_mode_account_currency==self.company_currency \
else payment_mode.amount,
"cost_center": self.cost_center
- }, payment_mode_account_currency)
+ }, payment_mode_account_currency, item=self)
)
def make_gle_for_change_amount(self, gl_entries):
@@ -927,7 +927,7 @@ class SalesInvoice(SellingController):
"against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
gl_entries.append(
@@ -936,7 +936,7 @@ class SalesInvoice(SellingController):
"against": self.customer,
"credit": self.base_change_amount,
"cost_center": self.cost_center
- })
+ }, item=self)
)
else:
frappe.throw(_("Select change amount account"), title="Mandatory Field")
@@ -960,7 +960,7 @@ class SalesInvoice(SellingController):
"against_voucher": self.return_against if cint(self.is_return) else self.name,
"against_voucher_type": self.doctype,
"cost_center": self.cost_center
- }, self.party_account_currency)
+ }, self.party_account_currency, item=self)
)
gl_entries.append(
self.get_gl_dict({
@@ -971,7 +971,7 @@ class SalesInvoice(SellingController):
self.precision("base_write_off_amount")) if write_off_account_currency==self.company_currency
else flt(self.write_off_amount, self.precision("write_off_amount"))),
"cost_center": self.cost_center or self.write_off_cost_center or default_cost_center
- }, write_off_account_currency)
+ }, write_off_account_currency, item=self)
)
def make_gle_for_rounding_adjustment(self, gl_entries):
@@ -988,8 +988,7 @@ class SalesInvoice(SellingController):
"credit": flt(self.base_rounding_adjustment,
self.precision("base_rounding_adjustment")),
"cost_center": self.cost_center or round_off_cost_center,
- }
- ))
+ }, item=self))
def update_billing_status_in_dn(self, update_modified=True):
updated_delivery_notes = []
@@ -1451,11 +1450,17 @@ def get_inter_company_details(doc, doctype):
parties = frappe.db.get_all("Supplier", fields=["name"], filters={"disabled": 0, "is_internal_supplier": 1, "represents_company": doc.company})
company = frappe.get_cached_value("Customer", doc.customer, "represents_company")
+ if not parties:
+ frappe.throw(_('No Supplier found for Inter Company Transactions which represents company {0}').format(frappe.bold(doc.company)))
+
party = get_internal_party(parties, "Supplier", doc)
else:
parties = frappe.db.get_all("Customer", fields=["name"], filters={"disabled": 0, "is_internal_customer": 1, "represents_company": doc.company})
company = frappe.get_cached_value("Supplier", doc.supplier, "represents_company")
+ if not parties:
+ frappe.throw(_('No Customer found for Inter Company Transactions which represents company {0}').format(frappe.bold(doc.company)))
+
party = get_internal_party(parties, "Customer", doc)
return {
@@ -1520,14 +1525,22 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
def update_details(source_doc, target_doc, source_parent):
target_doc.inter_company_invoice_reference = source_doc.name
if target_doc.doctype in ["Purchase Invoice", "Purchase Order"]:
+ currency = frappe.db.get_value('Supplier', details.get('party'), 'default_currency')
target_doc.company = details.get("company")
target_doc.supplier = details.get("party")
target_doc.buying_price_list = source_doc.selling_price_list
+
+ if currency:
+ target_doc.currency = currency
else:
+ currency = frappe.db.get_value('Customer', details.get('party'), 'default_currency')
target_doc.company = details.get("company")
target_doc.customer = details.get("party")
target_doc.selling_price_list = source_doc.buying_price_list
+ if currency:
+ target_doc.currency = currency
+
doclist = get_mapped_doc(doctype, source_name, {
doctype: {
"doctype": target_doctype,
diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
index b2638c78279..d32a348741e 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
@@ -45,7 +45,9 @@ class ShippingRule(Document):
shipping_amount = 0.0
by_value = False
- self.validate_countries(doc)
+ if doc.get_shipping_address():
+ # validate country only if there is address
+ self.validate_countries(doc)
if self.calculate_based_on == 'Net Total':
value = doc.base_net_total
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 dd6b4fdc603..83d7967f793 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
@@ -58,7 +58,7 @@ def get_tax_withholding_details(tax_withholding_category, fiscal_year, company):
"rate": tax_rate_detail.tax_withholding_rate,
"threshold": tax_rate_detail.single_threshold,
"cumulative_threshold": tax_rate_detail.cumulative_threshold,
- "description": tax_withholding.category_name
+ "description": tax_withholding.category_name if tax_withholding.category_name else tax_withholding_category
})
def get_tax_withholding_rates(tax_withholding, fiscal_year):
@@ -180,7 +180,7 @@ def get_advance_vouchers(suppliers, fiscal_year=None, company=None, from_date=No
if company:
condition += "and company =%s" % (company)
if from_date and to_date:
- condition += "and posting_date between %s and %s" % (company, from_date, to_date)
+ condition += "and posting_date between %s and %s" % (from_date, to_date)
## Appending the same supplier again if length of suppliers list is 1
## since tuple of single element list contains None, For example ('Test Supplier 1', )
diff --git a/erpnext/accounts/module_onboarding/accounts/accounts.json b/erpnext/accounts/module_onboarding/accounts/accounts.json
new file mode 100644
index 00000000000..12da4400284
--- /dev/null
+++ b/erpnext/accounts/module_onboarding/accounts/accounts.json
@@ -0,0 +1,51 @@
+{
+ "allow_roles": [
+ {
+ "role": "Accounts Manager"
+ },
+ {
+ "role": "Accounts User"
+ }
+ ],
+ "creation": "2020-05-13 19:03:32.564049",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/accounts",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-14 22:11:06.475938",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Accounts",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Chart Of Accounts"
+ },
+ {
+ "step": "Setup Taxes"
+ },
+ {
+ "step": "Create a Product"
+ },
+ {
+ "step": "Create a Supplier"
+ },
+ {
+ "step": "Create Your First Purchase Invoice"
+ },
+ {
+ "step": "Create a Customer"
+ },
+ {
+ "step": "Create Your First Sales Invoice"
+ },
+ {
+ "step": "Configure Account Settings"
+ }
+ ],
+ "subtitle": "Accounts, invoices and taxation.",
+ "success_message": "The Accounts module is now set up!",
+ "title": "Let's Setup Your Accounts and Taxes.",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/chart_of_accounts/chart_of_accounts.json b/erpnext/accounts/onboarding_step/chart_of_accounts/chart_of_accounts.json
new file mode 100644
index 00000000000..cbd022bfdbe
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/chart_of_accounts/chart_of_accounts.json
@@ -0,0 +1,20 @@
+{
+ "action": "Go to Page",
+ "creation": "2020-05-13 19:58:20.928127",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:40:28.410447",
+ "modified_by": "Administrator",
+ "name": "Chart Of Accounts",
+ "owner": "Administrator",
+ "path": "Tree/Account",
+ "reference_document": "Account",
+ "show_full_form": 0,
+ "title": "Review Chart Of Accounts",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/configure_account_settings/configure_account_settings.json b/erpnext/accounts/onboarding_step/configure_account_settings/configure_account_settings.json
new file mode 100644
index 00000000000..c8be357de0a
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/configure_account_settings/configure_account_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 17:53:00.876946",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 1,
+ "is_skipped": 0,
+ "modified": "2020-05-14 18:06:25.212923",
+ "modified_by": "Administrator",
+ "name": "Configure Account Settings",
+ "owner": "Administrator",
+ "reference_document": "Accounts Settings",
+ "show_full_form": 1,
+ "title": "Configure Account Settings",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/create_a_customer/create_a_customer.json b/erpnext/accounts/onboarding_step/create_a_customer/create_a_customer.json
new file mode 100644
index 00000000000..bb396d268ae
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/create_a_customer/create_a_customer.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 17:46:41.831517",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:46:41.831517",
+ "modified_by": "Administrator",
+ "name": "Create a Customer",
+ "owner": "Administrator",
+ "reference_document": "Customer",
+ "show_full_form": 0,
+ "title": "Create a Customer",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/create_a_product/create_a_product.json b/erpnext/accounts/onboarding_step/create_a_product/create_a_product.json
new file mode 100644
index 00000000000..450bee1f40b
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/create_a_product/create_a_product.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 17:45:28.554605",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:45:28.554605",
+ "modified_by": "Administrator",
+ "name": "Create a Product",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "show_full_form": 0,
+ "title": "Create a Product",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/create_a_supplier/create_a_supplier.json b/erpnext/accounts/onboarding_step/create_a_supplier/create_a_supplier.json
new file mode 100644
index 00000000000..7a64224bd43
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/create_a_supplier/create_a_supplier.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 22:09:10.043554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 22:09:10.043554",
+ "modified_by": "Administrator",
+ "name": "Create a Supplier",
+ "owner": "Administrator",
+ "reference_document": "Supplier",
+ "show_full_form": 0,
+ "title": "Create a Supplier",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/create_your_first_purchase_invoice/create_your_first_purchase_invoice.json b/erpnext/accounts/onboarding_step/create_your_first_purchase_invoice/create_your_first_purchase_invoice.json
new file mode 100644
index 00000000000..3a2b8d39253
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/create_your_first_purchase_invoice/create_your_first_purchase_invoice.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 22:10:07.049704",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 22:10:07.049704",
+ "modified_by": "Administrator",
+ "name": "Create Your First Purchase Invoice",
+ "owner": "Administrator",
+ "reference_document": "Purchase Invoice",
+ "show_full_form": 1,
+ "title": "Create Your First Purchase Invoice ",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/create_your_first_sales_invoice/create_your_first_sales_invoice.json b/erpnext/accounts/onboarding_step/create_your_first_sales_invoice/create_your_first_sales_invoice.json
new file mode 100644
index 00000000000..473de5079f5
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/create_your_first_sales_invoice/create_your_first_sales_invoice.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 17:48:21.019019",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:48:21.019019",
+ "modified_by": "Administrator",
+ "name": "Create Your First Sales Invoice",
+ "owner": "Administrator",
+ "reference_document": "Sales Invoice",
+ "show_full_form": 1,
+ "title": "Create Your First Sales Invoice ",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/onboarding_step/setup_taxes/setup_taxes.json b/erpnext/accounts/onboarding_step/setup_taxes/setup_taxes.json
new file mode 100644
index 00000000000..8e0006762d1
--- /dev/null
+++ b/erpnext/accounts/onboarding_step/setup_taxes/setup_taxes.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-13 19:29:43.844463",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:40:16.014413",
+ "modified_by": "Administrator",
+ "name": "Setup Taxes",
+ "owner": "Administrator",
+ "reference_document": "Sales Taxes and Charges Template",
+ "show_full_form": 1,
+ "title": "Lets create a Tax Template for Sales ",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 528fb4e113a..db91b6696eb 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -602,10 +602,14 @@ def get_party_shipping_address(doctype, name):
else:
return ''
-def get_partywise_advanced_payment_amount(party_type, posting_date = None, company=None):
+def get_partywise_advanced_payment_amount(party_type, posting_date = None, future_payment=0, company=None):
cond = "1=1"
if posting_date:
- cond = "posting_date <= '{0}'".format(posting_date)
+ if future_payment:
+ cond = "posting_date <= '{0}' OR DATE(creation) <= '{0}' """.format(posting_date)
+ else:
+ cond = "posting_date <= '{0}'".format(posting_date)
+
if company:
cond += "and company = '{0}'".format(company)
diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js
index 4e09f99ae3e..2aa9618e559 100644
--- a/erpnext/accounts/report/accounts_payable/accounts_payable.js
+++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js
@@ -135,12 +135,5 @@ frappe.query_reports["Accounts Payable"] = {
}
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Accounts Payable"].filters.splice(9, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('Accounts Payable', 9);
diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
index d5f18b09827..9c6b0639c0a 100644
--- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
+++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
@@ -104,12 +104,5 @@ frappe.query_reports["Accounts Payable Summary"] = {
}
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Accounts Payable Summary"].filters.splice(9, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('Accounts Payable Summary', 9);
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
index 6208eb6946b..8dc558a611d 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
@@ -199,12 +199,5 @@ frappe.query_reports["Accounts Receivable"] = {
}
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Accounts Receivable"].filters.splice(9, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('Accounts Receivable', 9);
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index e9c286fcf0d..66aa18058b6 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -169,9 +169,11 @@ class ReceivablePayableReport(object):
def append_subtotal_row(self, party):
sub_total_row = self.total_row_map.get(party)
- self.data.append(sub_total_row)
- self.data.append({})
- self.update_sub_total_row(sub_total_row, 'Total')
+
+ if sub_total_row:
+ self.data.append(sub_total_row)
+ self.data.append({})
+ self.update_sub_total_row(sub_total_row, 'Total')
def get_voucher_balance(self, gle):
if self.filters.get("sales_person"):
@@ -232,7 +234,8 @@ class ReceivablePayableReport(object):
if self.filters.get('group_by_party'):
self.append_subtotal_row(self.previous_party)
- self.data.append(self.total_row_map.get('Total'))
+ if self.data:
+ self.data.append(self.total_row_map.get('Total'))
def append_row(self, row):
self.allocate_future_payments(row)
@@ -534,7 +537,7 @@ class ReceivablePayableReport(object):
def get_ageing_data(self, entry_date, row):
# [0-30, 30-60, 60-90, 90-120, 120-above]
- row.range1 = row.range2 = row.range3 = row.range4 = range5 = 0.0
+ row.range1 = row.range2 = row.range3 = row.range4 = row.range5 = 0.0
if not (self.age_as_on and entry_date):
return
@@ -546,7 +549,7 @@ class ReceivablePayableReport(object):
self.filters.range1, self.filters.range2, self.filters.range3, self.filters.range4 = 30, 60, 90, 120
for i, days in enumerate([self.filters.range1, self.filters.range2, self.filters.range3, self.filters.range4]):
- if row.age <= days:
+ if cint(row.age) <= cint(days):
index = i
break
@@ -559,6 +562,14 @@ class ReceivablePayableReport(object):
conditions, values = self.prepare_conditions()
order_by = self.get_order_by_condition()
+ if self.filters.show_future_payments:
+ values.insert(2, self.filters.report_date)
+
+ date_condition = """AND (posting_date <= %s
+ OR (against_voucher IS NULL AND DATE(creation) <= %s))"""
+ else:
+ date_condition = "AND posting_date <=%s"
+
if self.filters.get(scrub(self.party_type)):
select_fields = "debit_in_account_currency as debit, credit_in_account_currency as credit"
else:
@@ -574,9 +585,8 @@ class ReceivablePayableReport(object):
docstatus < 2
and party_type=%s
and (party is not null and party != '')
- and posting_date <= %s
- {1} {2}"""
- .format(select_fields, conditions, order_by), values, as_dict=True)
+ {1} {2} {3}"""
+ .format(select_fields, date_condition, conditions, order_by), values, as_dict=True)
def get_sales_invoices_or_customers_based_on_sales_person(self):
if self.filters.get("sales_person"):
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
index b316f108d04..305cddb102a 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
@@ -111,7 +111,12 @@ frappe.query_reports["Accounts Receivable Summary"] = {
"fieldname":"based_on_payment_terms",
"label": __("Based On Payment Terms"),
"fieldtype": "Check",
- }
+ },
+ {
+ "fieldname":"show_future_payments",
+ "label": __("Show Future Payments"),
+ "fieldtype": "Check",
+ },
],
onload: function(report) {
@@ -122,11 +127,4 @@ frappe.query_reports["Accounts Receivable Summary"] = {
}
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Accounts Receivable Summary"].filters.splice(9, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('Accounts Receivable Summary', 9);
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 aa6b42e89d0..657b3e8f204 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -33,7 +33,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
self.get_party_total(args)
party_advance_amount = get_partywise_advanced_payment_amount(self.party_type,
- self.filters.report_date, self.filters.company) or {}
+ self.filters.report_date, self.filters.show_future_payments, self.filters.company) or {}
for party, party_dict in iteritems(self.party_total):
if party_dict.outstanding == 0:
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 d7efbad240d..5001ad9f12f 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
@@ -93,7 +93,7 @@ def get_assets(filters):
sum(results.depreciation_eliminated_during_the_period) as depreciation_eliminated_during_the_period,
sum(results.depreciation_amount_during_the_period) as depreciation_amount_during_the_period
from (SELECT a.asset_category,
- ifnull(sum(case when ds.schedule_date < %(from_date)s then
+ ifnull(sum(case when ds.schedule_date < %(from_date)s and (ifnull(a.disposal_date, 0) = 0 or a.disposal_date >= %(from_date)s) then
ds.depreciation_amount
else
0
@@ -111,13 +111,11 @@ def get_assets(filters):
0
end), 0) as depreciation_amount_during_the_period
from `tabAsset` a, `tabDepreciation Schedule` ds
- where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and a.name = ds.parent
+ where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and a.name = ds.parent and ifnull(ds.journal_entry, '') != ''
group by a.asset_category
union
SELECT a.asset_category,
- ifnull(sum(case when ifnull(a.disposal_date, 0) != 0
- and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s)
- then
+ ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s) then
0
else
a.opening_accumulated_depreciation
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js
index c4c24c0bab3..4a4ad4d71cb 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.js
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js
@@ -4,6 +4,8 @@
frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Balance Sheet"] = $.extend({}, erpnext.financial_statements);
+ erpnext.utils.add_dimensions('Balance Sheet', 10);
+
frappe.query_reports["Balance Sheet"]["filters"].push({
"fieldname": "accumulated_values",
"label": __("Accumulated Values"),
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 39e218bfad2..9c9ada871c8 100644
--- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py
+++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py
@@ -2,16 +2,19 @@
# 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
-from frappe.utils import formatdate
+from frappe.utils import flt, formatdate
+
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
-from six import iteritems
-from pprint import pprint
+
def execute(filters=None):
- if not filters: filters = {}
+ if not filters:
+ filters = {}
columns = get_columns(filters)
if filters.get("budget_against_filter"):
@@ -26,37 +29,77 @@ def execute(filters=None):
for dimension in dimensions:
dimension_items = cam_map.get(dimension)
if dimension_items:
- for account, monthwise_data in iteritems(dimension_items):
- row = [dimension, account]
- totals = [0, 0, 0]
- for year in get_fiscal_years(filters):
- last_total = 0
- for relevant_months in period_month_ranges:
- period_data = [0, 0, 0]
- for month in relevant_months:
- if monthwise_data.get(year[0]):
- month_data = monthwise_data.get(year[0]).get(month, {})
- for i, fieldname in enumerate(["target", "actual", "variance"]):
- value = flt(month_data.get(fieldname))
- period_data[i] += value
- totals[i] += value
+ data = get_final_data(dimension, dimension_items, filters, period_month_ranges, data, 0)
+ else:
+ DCC_allocation = frappe.db.sql('''SELECT parent, sum(percentage_allocation) as percentage_allocation
+ FROM `tabDistributed Cost Center`
+ WHERE cost_center IN %(dimension)s
+ AND parent NOT IN %(dimension)s
+ GROUP BY parent''',{'dimension':[dimension]})
+ if DCC_allocation:
+ filters['budget_against_filter'] = [DCC_allocation[0][0]]
+ cam_map = get_dimension_account_month_map(filters)
+ dimension_items = cam_map.get(DCC_allocation[0][0])
+ if dimension_items:
+ data = get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation[0][1])
- period_data[0] += last_total
+ chart = get_chart_data(filters, columns, data)
- if(filters.get("show_cumulative")):
- last_total = period_data[0] - period_data[1]
+ return columns, data, None, chart
- period_data[2] = period_data[0] - period_data[1]
- row += period_data
- totals[2] = totals[0] - totals[1]
- if filters["period"] != "Yearly" :
- row += totals
- data.append(row)
+def get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation):
+
+ for account, monthwise_data in iteritems(dimension_items):
+ row = [dimension, account]
+ totals = [0, 0, 0]
+ for year in get_fiscal_years(filters):
+ last_total = 0
+ for relevant_months in period_month_ranges:
+ period_data = [0, 0, 0]
+ for month in relevant_months:
+ if monthwise_data.get(year[0]):
+ month_data = monthwise_data.get(year[0]).get(month, {})
+ for i, fieldname in enumerate(["target", "actual", "variance"]):
+ value = flt(month_data.get(fieldname))
+ period_data[i] += value
+ totals[i] += value
+
+ period_data[0] += last_total
+
+ if DCC_allocation:
+ period_data[0] = period_data[0]*(DCC_allocation/100)
+ period_data[1] = period_data[1]*(DCC_allocation/100)
+
+ if(filters.get("show_cumulative")):
+ last_total = period_data[0] - period_data[1]
+
+ period_data[2] = period_data[0] - period_data[1]
+ row += period_data
+ totals[2] = totals[0] - totals[1]
+ if filters["period"] != "Yearly" :
+ row += totals
+ data.append(row)
+
+ return data
- return columns, data
def get_columns(filters):
- columns = [_(filters.get("budget_against")) + ":Link/%s:150"%(filters.get("budget_against")), _("Account") + ":Link/Account:150"]
+ columns = [
+ {
+ 'label': _(filters.get("budget_against")),
+ 'fieldtype': 'Link',
+ 'fieldname': 'budget_against',
+ 'options': filters.get('budget_against'),
+ 'width': 150
+ },
+ {
+ 'label': _('Account'),
+ 'fieldname': 'Account',
+ 'fieldtype': 'Link',
+ 'options': 'Account',
+ 'width': 150
+ }
+ ]
group_months = False if filters["period"] == "Monthly" else True
@@ -65,84 +108,195 @@ def get_columns(filters):
for year in fiscal_year:
for from_date, to_date in get_period_date_ranges(filters["period"], year[0]):
if filters["period"] == "Yearly":
- labels = [_("Budget") + " " + str(year[0]), _("Actual ") + " " + str(year[0]), _("Variance ") + " " + str(year[0])]
+ labels = [
+ _("Budget") + " " + str(year[0]),
+ _("Actual ") + " " + str(year[0]),
+ _("Variance ") + " " + str(year[0])
+ ]
for label in labels:
- columns.append(label+":Float:150")
+ columns.append({
+ 'label': label,
+ 'fieldtype': 'Float',
+ 'fieldname': frappe.scrub(label),
+ 'width': 150
+ })
else:
- for label in [_("Budget") + " (%s)" + " " + str(year[0]), _("Actual") + " (%s)" + " " + str(year[0]), _("Variance") + " (%s)" + " " + str(year[0])]:
+ for label in [
+ _("Budget") + " (%s)" + " " + str(year[0]),
+ _("Actual") + " (%s)" + " " + str(year[0]),
+ _("Variance") + " (%s)" + " " + str(year[0])
+ ]:
if group_months:
- label = label % (formatdate(from_date, format_string="MMM") + "-" + formatdate(to_date, format_string="MMM"))
+ label = label % (
+ formatdate(from_date, format_string="MMM")
+ + "-"
+ + formatdate(to_date, format_string="MMM")
+ )
else:
label = label % formatdate(from_date, format_string="MMM")
- columns.append(label+":Float:150")
+ columns.append({
+ 'label': label,
+ 'fieldtype': 'Float',
+ 'fieldname': frappe.scrub(label),
+ 'width': 150
+ })
- if filters["period"] != "Yearly" :
- return columns + [_("Total Budget") + ":Float:150", _("Total Actual") + ":Float:150",
- _("Total Variance") + ":Float:150"]
+ if filters["period"] != "Yearly":
+ for label in [_("Total Budget"), _("Total Actual"), _("Total Variance")]:
+ columns.append({
+ 'label': label,
+ 'fieldtype': 'Float',
+ 'fieldname': frappe.scrub(label),
+ 'width': 150
+ })
+
+ return columns
else:
return columns
+
def get_cost_centers(filters):
- cond = "and 1=1"
+ order_by = ""
if filters.get("budget_against") == "Cost Center":
- cond = "order by lft"
+ order_by = "order by lft"
if filters.get("budget_against") in ["Cost Center", "Project"]:
- return frappe.db.sql_list("""select name from `tab{tab}` where company=%s
- {cond}""".format(tab=filters.get("budget_against"), cond=cond), filters.get("company"))
+ return frappe.db.sql_list(
+ """
+ select
+ name
+ from
+ `tab{tab}`
+ where
+ company = %s
+ {order_by}
+ """.format(tab=filters.get("budget_against"), order_by=order_by),
+ filters.get("company"))
else:
- return frappe.db.sql_list("""select name from `tab{tab}`""".format(tab=filters.get("budget_against"))) #nosec
+ return frappe.db.sql_list(
+ """
+ select
+ name
+ from
+ `tab{tab}`
+ """.format(tab=filters.get("budget_against"))) # nosec
-#Get dimension & target details
+
+# Get dimension & target details
def get_dimension_target_details(filters):
+ budget_against = frappe.scrub(filters.get("budget_against"))
cond = ""
if filters.get("budget_against_filter"):
- cond += " and b.{budget_against} in (%s)".format(budget_against = \
- frappe.scrub(filters.get('budget_against'))) % ', '.join(['%s']* len(filters.get('budget_against_filter')))
+ cond += """ and b.{budget_against} in (%s)""".format(
+ budget_against=budget_against) % ", ".join(["%s"] * len(filters.get("budget_against_filter")))
- return frappe.db.sql("""
- select b.{budget_against} as budget_against, b.monthly_distribution, ba.account, ba.budget_amount,b.fiscal_year
- from `tabBudget` b, `tabBudget Account` ba
- where b.name=ba.parent and b.docstatus = 1 and b.fiscal_year between %s and %s
- and b.budget_against = %s and b.company=%s {cond} order by b.fiscal_year
- """.format(budget_against=filters.get("budget_against").replace(" ", "_").lower(), cond=cond),
- tuple([filters.from_fiscal_year,filters.to_fiscal_year,filters.budget_against, filters.company] + filters.get('budget_against_filter')),
- as_dict=True)
+ return frappe.db.sql(
+ """
+ select
+ b.{budget_against} as budget_against,
+ b.monthly_distribution,
+ ba.account,
+ ba.budget_amount,
+ b.fiscal_year
+ from
+ `tabBudget` b,
+ `tabBudget Account` ba
+ where
+ b.name = ba.parent
+ and b.docstatus = 1
+ and b.fiscal_year between %s and %s
+ and b.budget_against = %s
+ and b.company = %s
+ {cond}
+ order by
+ b.fiscal_year
+ """.format(
+ budget_against=budget_against,
+ cond=cond,
+ ),
+ tuple(
+ [
+ filters.from_fiscal_year,
+ filters.to_fiscal_year,
+ filters.budget_against,
+ filters.company,
+ ]
+ + (filters.get("budget_against_filter") or [])
+ ), as_dict=True)
-#Get target distribution details of accounts of cost center
+# Get target distribution details of accounts of cost center
def get_target_distribution_details(filters):
target_details = {}
- for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
- from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
- where mdp.parent=md.name and md.fiscal_year between %s and %s order by md.fiscal_year""",(filters.from_fiscal_year, filters.to_fiscal_year), as_dict=1):
- target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
+ for d in frappe.db.sql(
+ """
+ select
+ md.name,
+ mdp.month,
+ mdp.percentage_allocation
+ from
+ `tabMonthly Distribution Percentage` mdp,
+ `tabMonthly Distribution` md
+ where
+ mdp.parent = md.name
+ and md.fiscal_year between %s and %s
+ order by
+ md.fiscal_year
+ """,
+ (filters.from_fiscal_year, filters.to_fiscal_year), as_dict=1):
+ target_details.setdefault(d.name, {}).setdefault(
+ d.month, flt(d.percentage_allocation)
+ )
return target_details
-#Get actual details from gl entry
+# Get actual details from gl entry
def get_actual_details(name, filters):
- cond = "1=1"
- budget_against=filters.get("budget_against").replace(" ", "_").lower()
+ budget_against = frappe.scrub(filters.get("budget_against"))
+ cond = ""
if filters.get("budget_against") == "Cost Center":
cc_lft, cc_rgt = frappe.db.get_value("Cost Center", name, ["lft", "rgt"])
- cond = "lft>='{lft}' and rgt<='{rgt}'".format(lft = cc_lft, rgt=cc_rgt)
+ cond = """
+ and lft >= "{lft}"
+ and rgt <= "{rgt}"
+ """.format(lft=cc_lft, rgt=cc_rgt)
- ac_details = frappe.db.sql("""select gl.account, gl.debit, gl.credit,gl.fiscal_year,
- MONTHNAME(gl.posting_date) as month_name, b.{budget_against} as budget_against
- from `tabGL Entry` gl, `tabBudget Account` ba, `tabBudget` b
- where
- b.name = ba.parent
- and b.docstatus = 1
- and ba.account=gl.account
- and b.{budget_against} = gl.{budget_against}
- and gl.fiscal_year between %s and %s
- and b.{budget_against}=%s
- and exists(select name from `tab{tab}` where name=gl.{budget_against} and {cond}) group by gl.name order by gl.fiscal_year
- """.format(tab = filters.budget_against, budget_against = budget_against, cond = cond,from_year=filters.from_fiscal_year,to_year=filters.to_fiscal_year),
- (filters.from_fiscal_year, filters.to_fiscal_year, name), as_dict=1)
+ ac_details = frappe.db.sql(
+ """
+ select
+ gl.account,
+ gl.debit,
+ gl.credit,
+ gl.fiscal_year,
+ MONTHNAME(gl.posting_date) as month_name,
+ b.{budget_against} as budget_against
+ from
+ `tabGL Entry` gl,
+ `tabBudget Account` ba,
+ `tabBudget` b
+ where
+ b.name = ba.parent
+ and b.docstatus = 1
+ and ba.account=gl.account
+ and b.{budget_against} = gl.{budget_against}
+ and gl.fiscal_year between %s and %s
+ and b.{budget_against} = %s
+ and exists(
+ select
+ name
+ from
+ `tab{tab}`
+ where
+ name = gl.{budget_against}
+ {cond}
+ )
+ group by
+ gl.name
+ order by gl.fiscal_year
+ """.format(tab=filters.budget_against, budget_against=budget_against, cond=cond),
+ (filters.from_fiscal_year, filters.to_fiscal_year, name), as_dict=1)
cc_actual_details = {}
for d in ac_details:
@@ -151,7 +305,6 @@ def get_actual_details(name, filters):
return cc_actual_details
def get_dimension_account_month_map(filters):
- import datetime
dimension_target_details = get_dimension_target_details(filters)
tdd = get_target_distribution_details(filters)
@@ -161,28 +314,89 @@ def get_dimension_account_month_map(filters):
actual_details = get_actual_details(ccd.budget_against, filters)
for month_id in range(1, 13):
- month = datetime.date(2013, month_id, 1).strftime('%B')
- cam_map.setdefault(ccd.budget_against, {}).setdefault(ccd.account, {}).setdefault(ccd.fiscal_year,{})\
- .setdefault(month, frappe._dict({
- "target": 0.0, "actual": 0.0
- }))
+ month = datetime.date(2013, month_id, 1).strftime("%B")
+ cam_map.setdefault(ccd.budget_against, {}).setdefault(
+ ccd.account, {}
+ ).setdefault(ccd.fiscal_year, {}).setdefault(
+ month, frappe._dict({"target": 0.0, "actual": 0.0})
+ )
tav_dict = cam_map[ccd.budget_against][ccd.account][ccd.fiscal_year][month]
- month_percentage = tdd.get(ccd.monthly_distribution, {}).get(month, 0) \
- if ccd.monthly_distribution else 100.0/12
+ month_percentage = (
+ tdd.get(ccd.monthly_distribution, {}).get(month, 0)
+ if ccd.monthly_distribution
+ else 100.0 / 12
+ )
tav_dict.target = flt(ccd.budget_amount) * month_percentage / 100
for ad in actual_details.get(ccd.account, []):
- if ad.month_name == month:
- tav_dict.actual += flt(ad.debit) - flt(ad.credit)
+ if ad.month_name == month and ad.fiscal_year == ccd.fiscal_year:
+ tav_dict.actual += flt(ad.debit) - flt(ad.credit)
return cam_map
+
def get_fiscal_years(filters):
- fiscal_year = frappe.db.sql("""select name from `tabFiscal Year` where
- name between %(from_fiscal_year)s and %(to_fiscal_year)s""",
- {'from_fiscal_year': filters["from_fiscal_year"], 'to_fiscal_year': filters["to_fiscal_year"]})
+ fiscal_year = frappe.db.sql(
+ """
+ select
+ name
+ from
+ `tabFiscal Year`
+ where
+ name between %(from_fiscal_year)s and %(to_fiscal_year)s
+ """,
+ {
+ "from_fiscal_year": filters["from_fiscal_year"],
+ "to_fiscal_year": filters["to_fiscal_year"]
+ })
return fiscal_year
+
+def get_chart_data(filters, columns, data):
+
+ if not data:
+ return None
+
+ labels = []
+
+ fiscal_year = get_fiscal_years(filters)
+ group_months = False if filters["period"] == "Monthly" else True
+
+ for year in fiscal_year:
+ for from_date, to_date in get_period_date_ranges(filters["period"], year[0]):
+ if filters['period'] == 'Yearly':
+ labels.append(year[0])
+ else:
+ if group_months:
+ label = formatdate(from_date, format_string="MMM") + "-" \
+ + formatdate(to_date, format_string="MMM")
+ labels.append(label)
+ else:
+ label = formatdate(from_date, format_string="MMM")
+ labels.append(label)
+
+ no_of_columns = len(labels)
+
+ budget_values, actual_values = [0] * no_of_columns, [0] * no_of_columns
+ for d in data:
+ values = d[2:]
+ index = 0
+
+ for i in range(no_of_columns):
+ budget_values[i] += values[index]
+ actual_values[i] += values[index+1]
+ index += 3
+
+ return {
+ 'data': {
+ 'labels': labels,
+ 'datasets': [
+ {'name': 'Budget', 'chartType': 'bar', 'values': budget_values},
+ {'name': 'Actual Expense', 'chartType': 'bar', 'values': actual_values}
+ ]
+ }
+ }
+
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.js b/erpnext/accounts/report/cash_flow/cash_flow.js
index e5d0c899181..a984bf46b50 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.js
+++ b/erpnext/accounts/report/cash_flow/cash_flow.js
@@ -5,6 +5,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Cash Flow"] = $.extend({},
erpnext.financial_statements);
+ erpnext.utils.add_dimensions('Cash Flow', 10);
+
// The last item in the array is the definition for Presentation Currency
// filter. It won't be used in cash flow for now so we pop it. Please take
// of this if you are working here.
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
index 38fd5fa2787..09479221fbb 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
@@ -33,7 +33,6 @@ frappe.query_reports["Consolidated Financial Statement"] = {
"fieldname":"period_start_date",
"label": __("Start Date"),
"fieldtype": "Date",
- "default": frappe.datetime.nowdate(),
"hidden": 1,
"reqd": 1
},
@@ -41,7 +40,6 @@ frappe.query_reports["Consolidated Financial Statement"] = {
"fieldname":"period_end_date",
"label": __("End Date"),
"fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.nowdate(), 12),
"hidden": 1,
"reqd": 1
},
@@ -106,5 +104,16 @@ frappe.query_reports["Consolidated Financial Statement"] = {
value = $value.wrap("
").parent().html();
}
return value;
+ },
+ onload: function() {
+ let fiscal_year = frappe.defaults.get_user_default("fiscal_year")
+
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ period_start_date: fy.year_start_date,
+ period_end_date: fy.year_end_date
+ });
+ });
}
}
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 7fb598bd689..533685d703d 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -19,7 +19,7 @@ from six import itervalues
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
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):
+ company=None, reset_period_on_fy_change=True, ignore_fiscal_year=False):
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
Periodicity can be (Yearly, Quarterly, Monthly)"""
@@ -56,9 +56,8 @@ def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_
to_date = add_months(start_date, months_to_add)
start_date = to_date
- if to_date == get_first_day(to_date):
- # if to_date is the first day, get the last day of previous month
- to_date = add_days(to_date, -1)
+ # Subtract one day from to_date, as it may be first day in next fiscal year or month
+ to_date = add_days(to_date, -1)
if to_date <= year_end_date:
# the normal case
@@ -67,8 +66,9 @@ def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_
# if a fiscal year ends before a 12 month period
period.to_date = year_end_date
- period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
- period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]
+ if not ignore_fiscal_year:
+ period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
+ period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]
period_list.append(period)
@@ -386,11 +386,43 @@ def set_gl_entries_by_account(
key: value
})
+ distributed_cost_center_query = ""
+ if filters and filters.get('cost_center'):
+ distributed_cost_center_query = """
+ UNION ALL
+ SELECT posting_date,
+ account,
+ debit*(DCC_allocation.percentage_allocation/100) as debit,
+ credit*(DCC_allocation.percentage_allocation/100) as credit,
+ is_opening,
+ fiscal_year,
+ debit_in_account_currency*(DCC_allocation.percentage_allocation/100) as debit_in_account_currency,
+ credit_in_account_currency*(DCC_allocation.percentage_allocation/100) as credit_in_account_currency,
+ account_currency
+ FROM `tabGL Entry`,
+ (
+ SELECT parent, sum(percentage_allocation) as percentage_allocation
+ FROM `tabDistributed Cost Center`
+ WHERE cost_center IN %(cost_center)s
+ AND parent NOT IN %(cost_center)s
+ AND is_cancelled = 0
+ GROUP BY parent
+ ) as DCC_allocation
+ WHERE company=%(company)s
+ {additional_conditions}
+ AND posting_date <= %(to_date)s
+ AND cost_center = DCC_allocation.parent
+ """.format(additional_conditions=additional_conditions.replace("and cost_center in %(cost_center)s ", ''))
+
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening, fiscal_year, debit_in_account_currency, credit_in_account_currency, account_currency from `tabGL Entry`
where company=%(company)s
{additional_conditions}
and posting_date <= %(to_date)s
- order by account, posting_date""".format(additional_conditions=additional_conditions), gl_filters, as_dict=True) #nosec
+ and is_cancelled = 0
+ {distributed_cost_center_query}
+ order by account, posting_date""".format(
+ additional_conditions=additional_conditions,
+ distributed_cost_center_query=distributed_cost_center_query), gl_filters, as_dict=True) #nosec
if filters and filters.get('presentation_currency'):
convert_to_presentation_currency(gl_entries, get_currency(filters))
@@ -488,4 +520,4 @@ def get_columns(periodicity, period_list, accumulated_values=1, company=None):
"width": 150
})
- return columns
+ return columns
\ No newline at end of file
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js
index 1188beaa0f8..1fc0f794788 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.js
+++ b/erpnext/accounts/report/general_ledger/general_ledger.js
@@ -53,7 +53,7 @@ frappe.query_reports["General Ledger"] = {
"label": __("Voucher No"),
"fieldtype": "Data",
on_change: function() {
- frappe.query_report.set_filter_value('group_by', "");
+ frappe.query_report.set_filter_value('group_by', "Group by Voucher (Consolidated)");
}
},
{
@@ -164,12 +164,5 @@ frappe.query_reports["General Ledger"] = {
]
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["General Ledger"].filters.splice(15, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('General Ledger', 15)
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 6afe208b5b1..fcd36e4e6e2 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -128,18 +128,53 @@ def get_gl_entries(filters):
filters['company_fb'] = frappe.db.get_value("Company",
filters.get("company"), 'default_finance_book')
+ distributed_cost_center_query = ""
+ if filters and filters.get('cost_center'):
+ select_fields_with_percentage = """, debit*(DCC_allocation.percentage_allocation/100) as debit, credit*(DCC_allocation.percentage_allocation/100) as credit, debit_in_account_currency*(DCC_allocation.percentage_allocation/100) as debit_in_account_currency,
+ credit_in_account_currency*(DCC_allocation.percentage_allocation/100) as credit_in_account_currency """
+
+ distributed_cost_center_query = """
+ UNION ALL
+ SELECT name as gl_entry,
+ posting_date,
+ account,
+ party_type,
+ party,
+ voucher_type,
+ voucher_no,
+ cost_center, project,
+ against_voucher_type,
+ against_voucher,
+ account_currency,
+ remarks, against,
+ is_opening, `tabGL Entry`.creation {select_fields_with_percentage}
+ FROM `tabGL Entry`,
+ (
+ SELECT parent, sum(percentage_allocation) as percentage_allocation
+ FROM `tabDistributed Cost Center`
+ WHERE cost_center IN %(cost_center)s
+ AND parent NOT IN %(cost_center)s
+ GROUP BY parent
+ ) as DCC_allocation
+ WHERE company=%(company)s
+ {conditions}
+ AND posting_date <= %(to_date)s
+ AND cost_center = DCC_allocation.parent
+ """.format(select_fields_with_percentage=select_fields_with_percentage, conditions=get_conditions(filters).replace("and cost_center in %(cost_center)s ", ''))
+
gl_entries = frappe.db.sql(
"""
select
name as gl_entry, posting_date, account, party_type, party,
voucher_type, voucher_no, cost_center, project,
against_voucher_type, against_voucher, account_currency,
- remarks, against, is_opening {select_fields}
+ remarks, against, is_opening, creation {select_fields}
from `tabGL Entry`
where company=%(company)s {conditions}
+ {distributed_cost_center_query}
{order_by_statement}
""".format(
- select_fields=select_fields, conditions=get_conditions(filters),
+ select_fields=select_fields, conditions=get_conditions(filters), distributed_cost_center_query=distributed_cost_center_query,
order_by_statement=order_by_statement
),
filters, as_dict=1)
@@ -296,7 +331,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
data[key].debit_in_account_currency += flt(gle.debit_in_account_currency)
data[key].credit_in_account_currency += flt(gle.credit_in_account_currency)
- if data[key].against_voucher:
+ if data[key].against_voucher and gle.against_voucher:
data[key].against_voucher += ', ' + gle.against_voucher
from_date, to_date = getdate(filters.from_date), getdate(filters.to_date)
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 1c458107d40..714e48d279b 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
@@ -9,8 +9,8 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c
import copy
def execute(filters=None):
- period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
- filters.periodicity, filters.accumulated_values, filters.company)
+ period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.period_start_date,
+ filters.period_end_date, filters.filter_based_on, filters.periodicity, filters.accumulated_values, filters.company)
columns, data = [], []
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
index f88906a0f1f..b709ab9b57d 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
@@ -4,11 +4,18 @@
frappe.query_reports["Item-wise Purchase Register"] = {
"filters": [
{
- "fieldname":"date_range",
- "label": __("Date Range"),
- "fieldtype": "DateRange",
- "default": [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()],
- "reqd": 1
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ "reqd": 1,
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today(),
+ "reqd": 1,
},
{
"fieldname": "item_code",
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 1f78c7a006f..3445df7206f 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
@@ -14,7 +14,6 @@ def execute(filters=None):
def _execute(filters=None, additional_table_columns=None, additional_query_columns=None):
if not filters: filters = {}
- filters.update({"from_date": filters.get("date_range")[0], "to_date": filters.get("date_range")[1]})
columns = get_columns(additional_table_columns, filters)
company_currency = erpnext.get_company_currency(filters.company)
@@ -266,13 +265,6 @@ def get_columns(additional_table_columns, filters):
'fieldtype': 'Currency',
'options': 'currency',
'width': 100
- },
- {
- 'fieldname': 'currency',
- 'label': _('Currency'),
- 'fieldtype': 'Currency',
- 'width': 80,
- 'hidden': 1
}
]
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
index 8a9c76f26f8..39fb3ca5ee3 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
@@ -4,11 +4,18 @@
frappe.query_reports["Item-wise Sales Register"] = {
"filters": [
{
- "fieldname": "date_range",
- "label": __("Date Range"),
- "fieldtype": "DateRange",
- "default": [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()],
- "reqd": 1
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ "reqd": 1,
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today(),
+ "reqd": 1,
},
{
"fieldname": "customer",
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 92a22e62f14..a05dcd75ce5 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
@@ -14,7 +14,6 @@ def execute(filters=None):
def _execute(filters=None, additional_table_columns=None, additional_query_columns=None):
if not filters: filters = {}
- filters.update({"from_date": filters.get("date_range") and filters.get("date_range")[0], "to_date": filters.get("date_range") and filters.get("date_range")[1]})
columns = get_columns(additional_table_columns, filters)
company_currency = frappe.get_cached_value('Company', filters.get("company"), "default_currency")
@@ -224,7 +223,7 @@ def get_columns(additional_table_columns, filters):
}
]
- if filters.get('group_by') != 'Terriotory':
+ if filters.get('group_by') != 'Territory':
columns.extend([
{
'label': _("Territory"),
@@ -305,13 +304,6 @@ def get_columns(additional_table_columns, filters):
'fieldtype': 'Currency',
'options': 'currency',
'width': 100
- },
- {
- 'fieldname': 'currency',
- 'label': _('Currency'),
- 'fieldtype': 'Currency',
- 'width': 80,
- 'hidden': 1
}
]
@@ -537,6 +529,13 @@ def get_tax_accounts(item_list, columns, company_currency,
'fieldtype': 'Currency',
'options': 'currency',
'width': 100
+ },
+ {
+ 'fieldname': 'currency',
+ 'label': _('Currency'),
+ 'fieldtype': 'Currency',
+ 'width': 80,
+ 'hidden': 1
}
]
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
index 2b946c05401..1c461efbcd3 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
@@ -6,6 +6,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Profit and Loss Statement"] = $.extend({},
erpnext.financial_statements);
+ erpnext.utils.add_dimensions('Profit and Loss Statement', 10);
+
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
{
"fieldname": "project",
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
index 6e9b31f2f6d..60e675f2f1f 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
@@ -105,6 +105,7 @@ def accumulate_values_into_parents(accounts, accounts_by_name):
def prepare_data(accounts, filters, total_row, parent_children_map, based_on):
data = []
+ new_accounts = accounts
company_currency = frappe.get_cached_value('Company', filters.get("company"), "default_currency")
for d in accounts:
@@ -118,6 +119,19 @@ def prepare_data(accounts, filters, total_row, parent_children_map, based_on):
"currency": company_currency,
"based_on": based_on
}
+ if based_on == 'cost_center':
+ cost_center_doc = frappe.get_doc("Cost Center",d.name)
+ if not cost_center_doc.enable_distributed_cost_center:
+ DCC_allocation = frappe.db.sql("""SELECT parent, sum(percentage_allocation) as percentage_allocation
+ FROM `tabDistributed Cost Center`
+ WHERE cost_center IN %(cost_center)s
+ AND parent NOT IN %(cost_center)s
+ GROUP BY parent""",{'cost_center': [d.name]})
+ if DCC_allocation:
+ for account in new_accounts:
+ if account['name'] == DCC_allocation[0][0]:
+ for value in value_fields:
+ d[value] += account[value]*(DCC_allocation[0][1]/100)
for key in value_fields:
row[key] = flt(d.get(key, 0.0), 3)
diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json
deleted file mode 100644
index 3645ec02e1d..00000000000
--- a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "add_total_row": 1,
- "apply_user_permissions": 1,
- "creation": "2013-05-28 15:54:16",
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 3,
- "is_standard": "Yes",
- "modified": "2017-02-24 20:00:24.302988",
- "modified_by": "Administrator",
- "module": "Accounts",
- "name": "Purchase Order Items To Be Billed",
- "owner": "Administrator",
- "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order`.`supplier_name` as \"Supplier Name::150\",\n\t`tabPurchase Order Item`.`project` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t(`tabPurchase Order Item`.billed_amt * ifnull(`tabPurchase Order`.conversion_rate, 1)) as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - (`tabPurchase Order Item`.billed_amt * ifnull(`tabPurchase Order`.conversion_rate, 1))) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n\t`tabPurchase Order`.company as \"Company:Link/Company:\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Closed\"\n and `tabPurchase Order Item`.amount > 0\n\tand (`tabPurchase Order Item`.billed_amt * ifnull(`tabPurchase Order`.conversion_rate, 1)) < `tabPurchase Order Item`.base_amount\norder by `tabPurchase Order`.transaction_date asc",
- "ref_doctype": "Purchase Invoice",
- "report_name": "Purchase Order Items To Be Billed",
- "report_type": "Script Report",
- "roles": [
- {
- "role": "Accounts User"
- },
- {
- "role": "Purchase User"
- },
- {
- "role": "Auditor"
- },
- {
- "role": "Accounts Manager"
- }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.py b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.py
deleted file mode 100644
index 99d0a368139..00000000000
--- a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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 erpnext.accounts.report.non_billed_report import get_ordered_to_be_billed_data
-
-def execute(filters=None):
- columns = get_column()
- args = get_args()
- data = get_ordered_to_be_billed_data(args)
- return columns, data
-
-def get_column():
- return [
- _("Purchase Order") + ":Link/Purchase Order:120", _("Status") + "::120", _("Date") + ":Date:100",
- _("Suplier") + ":Link/Supplier:120", _("Suplier Name") + "::120",
- _("Project") + ":Link/Project:120", _("Item Code") + ":Link/Item:120",
- _("Amount") + ":Currency:100", _("Billed Amount") + ":Currency:100", _("Amount to Bill") + ":Currency:100",
- _("Item Name") + "::120", _("Description") + "::120", _("Company") + ":Link/Company:120",
- ]
-
-def get_args():
- return {'doctype': 'Purchase Order', 'party': 'supplier',
- 'date': 'transaction_date', 'order': 'transaction_date', 'order_by': 'asc'}
diff --git a/erpnext/accounts/report/purchase_register/purchase_register.js b/erpnext/accounts/report/purchase_register/purchase_register.js
index b2b95b2b81b..f34ea571639 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.js
+++ b/erpnext/accounts/report/purchase_register/purchase_register.js
@@ -56,11 +56,4 @@ frappe.query_reports["Purchase Register"] = {
]
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Purchase Register"].filters.splice(7, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
\ No newline at end of file
+erpnext.utils.add_dimensions('Purchase Register', 7);
\ No newline at end of file
diff --git a/erpnext/accounts/report/sales_register/sales_register.js b/erpnext/accounts/report/sales_register/sales_register.js
index 9dee656d4a9..85bbceab827 100644
--- a/erpnext/accounts/report/sales_register/sales_register.js
+++ b/erpnext/accounts/report/sales_register/sales_register.js
@@ -68,12 +68,5 @@ frappe.query_reports["Sales Register"] = {
]
}
-erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Sales Register"].filters.splice(7, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
-});
+erpnext.utils.add_dimensions('Sales Register', 7);
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 4ac0f656119..a9fb237a048 100644
--- a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
+++ b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
@@ -111,7 +111,7 @@ def get_gle_map(filters):
# {"purchase_invoice": list of dict of all gle created for this invoice}
gle_map = {}
gle = frappe.db.get_all('GL Entry',\
- {"voucher_no": ["in", [d.get("name") for d in filters["invoices"]]]},
+ {"voucher_no": ["in", [d.get("name") for d in filters["invoices"]]], 'is_cancelled': 0},
["fiscal_year", "credit", "debit", "account", "voucher_no", "posting_date"])
for d in gle:
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js
index 622bab6946f..9c0854c5d3a 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.js
+++ b/erpnext/accounts/report/trial_balance/trial_balance.js
@@ -46,7 +46,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"default": frappe.defaults.get_user_default("year_end_date"),
},
{
- "fieldname":"cost_center",
+ "fieldname": "cost_center",
"label": __("Cost Center"),
"fieldtype": "Link",
"options": "Cost Center",
@@ -61,7 +61,13 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
}
},
{
- "fieldname":"finance_book",
+ "fieldname": "project",
+ "label": __("Project"),
+ "fieldtype": "Link",
+ "options": "Project"
+ },
+ {
+ "fieldname": "finance_book",
"label": __("Finance Book"),
"fieldtype": "Link",
"options": "Finance Book",
@@ -96,14 +102,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"initial_depth": 3
}
- erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Trial Balance"].filters.splice(5, 0 ,{
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
- });
+ erpnext.utils.add_dimensions('Trial Balance', 6);
});
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py
index d78324157a9..5a699b6580a 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.py
+++ b/erpnext/accounts/report/trial_balance/trial_balance.py
@@ -69,6 +69,11 @@ def get_data(filters):
gl_entries_by_account = {}
opening_balances = get_opening_balances(filters)
+
+ #add filter inside list so that the query in financial_statements.py doesn't break
+ if filters.project:
+ filters.project = [filters.project]
+
set_gl_entries_by_account(filters.company, filters.from_date,
filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
@@ -102,6 +107,9 @@ def get_rootwise_opening_balances(filters, report_type):
additional_conditions += """ and cost_center in (select name from `tabCost Center`
where lft >= %s and rgt <= %s)""" % (lft, rgt)
+ if filters.project:
+ additional_conditions += " and project = %(project)s"
+
if filters.finance_book:
fb_conditions = " AND finance_book = %(finance_book)s"
if filters.include_default_book_entries:
@@ -116,6 +124,7 @@ def get_rootwise_opening_balances(filters, report_type):
"from_date": filters.from_date,
"report_type": report_type,
"year_start_date": filters.year_start_date,
+ "project": filters.project,
"finance_book": filters.finance_book,
"company_fb": frappe.db.get_value("Company", filters.company, 'default_finance_book')
}
diff --git a/erpnext/assets/dashboard_fixtures.py b/erpnext/assets/dashboard_fixtures.py
new file mode 100644
index 00000000000..9af45d16b62
--- /dev/null
+++ b/erpnext/assets/dashboard_fixtures.py
@@ -0,0 +1,185 @@
+# 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
+from frappe import _
+from erpnext.accounts.utils import get_fiscal_year
+
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_dashboards():
+ return [{
+ "name": "Asset",
+ "dashboard_name": "Asset",
+ "charts": [
+ { "chart": "Asset Value Analytics", "width": "Full" },
+ { "chart": "Category-wise Asset Value", "width": "Half" },
+ { "chart": "Location-wise Asset Value", "width": "Half" },
+ ],
+ "cards": [
+ {"card": "Total Assets"},
+ {"card": "New Assets (This Year)"},
+ {"card": "Asset Value"}
+ ]
+ }]
+
+fiscal_year = get_fiscal_year(date=nowdate())
+year_start_date = get_date_str(fiscal_year[1])
+year_end_date = get_date_str(fiscal_year[2])
+
+
+def get_charts():
+ company = get_company_for_dashboards()
+ return [
+ {
+ "name": "Asset Value Analytics",
+ "chart_name": _("Asset Value Analytics"),
+ "chart_type": "Report",
+ "report_name": "Fixed Asset Register",
+ "is_custom": 1,
+ "group_by_type": "Count",
+ "number_of_groups": 0,
+ "is_public": 0,
+ "timespan": "Last Year",
+ "time_interval": "Yearly",
+ "timeseries": 0,
+ "filters_json": json.dumps({
+ "company": company,
+ "status": "In Location",
+ "filter_based_on": "Fiscal Year",
+ "from_fiscal_year": fiscal_year[0],
+ "to_fiscal_year": fiscal_year[0],
+ "period_start_date": year_start_date,
+ "period_end_date": year_end_date,
+ "date_based_on": "Purchase Date",
+ "group_by": "--Select a group--"
+ }),
+ "type": "Bar",
+ "custom_options": json.dumps({
+ "type": "bar",
+ "barOptions": { "stacked": 1 },
+ "axisOptions": { "shortenYAxisNumbers": 1 },
+ "tooltipOptions": {}
+ }),
+ "doctype": "Dashboard Chart",
+ "y_axis": []
+ },
+ {
+ "name": "Category-wise Asset Value",
+ "chart_name": _("Category-wise Asset Value"),
+ "chart_type": "Report",
+ "report_name": "Fixed Asset Register",
+ "x_field": "asset_category",
+ "timeseries": 0,
+ "filters_json": json.dumps({
+ "company": company,
+ "status":"In Location",
+ "group_by":"Asset Category",
+ "is_existing_asset":0
+ }),
+ "type": "Donut",
+ "doctype": "Dashboard Chart",
+ "y_axis": [
+ {
+ "parent": "Category-wise Asset Value",
+ "parentfield": "y_axis",
+ "parenttype": "Dashboard Chart",
+ "y_field": "asset_value",
+ "doctype": "Dashboard Chart Field"
+ }
+ ],
+ "custom_options": json.dumps({
+ "type": "donut",
+ "height": 300,
+ "axisOptions": {"shortenYAxisNumbers": 1}
+ })
+ },
+ {
+ "name": "Location-wise Asset Value",
+ "chart_name": "Location-wise Asset Value",
+ "chart_type": "Report",
+ "report_name": "Fixed Asset Register",
+ "x_field": "location",
+ "timeseries": 0,
+ "filters_json": json.dumps({
+ "company": company,
+ "status":"In Location",
+ "group_by":"Location",
+ "is_existing_asset":0
+ }),
+ "type": "Donut",
+ "doctype": "Dashboard Chart",
+ "y_axis": [
+ {
+ "parent": "Location-wise Asset Value",
+ "parentfield": "y_axis",
+ "parenttype": "Dashboard Chart",
+ "y_field": "asset_value",
+ "doctype": "Dashboard Chart Field"
+ }
+ ],
+ "custom_options": json.dumps({
+ "type": "donut",
+ "height": 300,
+ "axisOptions": {"shortenYAxisNumbers": 1}
+ })
+ }
+ ]
+
+def get_number_cards():
+ return [
+ {
+ "name": "Total Assets",
+ "label": _("Total Assets"),
+ "function": "Count",
+ "document_type": "Asset",
+ "is_public": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly",
+ "filters_json": "[]",
+ "doctype": "Number Card",
+ },
+ {
+ "name": "New Assets (This Year)",
+ "label": _("New Assets (This Year)"),
+ "function": "Count",
+ "document_type": "Asset",
+ "is_public": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly",
+ "filters_json": json.dumps([
+ ['Asset', 'creation', 'between', [year_start_date, year_end_date]]
+ ]),
+ "doctype": "Number Card",
+ },
+ {
+ "name": "Asset Value",
+ "label": _("Asset Value"),
+ "function": "Sum",
+ "aggregate_function_based_on": "value_after_depreciation",
+ "document_type": "Asset",
+ "is_public": 1,
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly",
+ "filters_json": "[]",
+ "doctype": "Number Card"
+ }
+ ]
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
\ No newline at end of file
diff --git a/erpnext/assets/desk_page/assets/assets.json b/erpnext/assets/desk_page/assets/assets.json
index 03094160e5f..94939fdd2a2 100644
--- a/erpnext/assets/desk_page/assets/assets.json
+++ b/erpnext/assets/desk_page/assets/assets.json
@@ -17,21 +17,27 @@
}
],
"category": "Modules",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Asset Value Analytics",
+ "label": "Asset Value Analytics"
+ }
+ ],
"creation": "2020-03-02 15:43:27.634865",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Assets",
- "modified": "2020-04-01 11:28:51.072198",
+ "modified": "2020-05-20 18:05:23.994795",
"modified_by": "Administrator",
"module": "Assets",
"name": "Assets",
+ "onboarding": "Assets",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
@@ -42,14 +48,19 @@
"type": "DocType"
},
{
- "label": "Asset Movement",
- "link_to": "Asset Movement",
+ "label": "Asset Category",
+ "link_to": "Asset Category",
"type": "DocType"
},
{
"label": "Fixed Asset Register",
"link_to": "Fixed Asset Register",
"type": "Report"
+ },
+ {
+ "label": "Assets Dashboard",
+ "link_to": "Asset",
+ "type": "Dashboard"
}
]
}
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js
index a53ff881777..fba20c0c879 100644
--- a/erpnext/assets/doctype/asset/asset.js
+++ b/erpnext/assets/doctype/asset/asset.js
@@ -387,7 +387,8 @@ frappe.ui.form.on('Asset', {
}
frm.set_value('gross_purchase_amount', item.base_net_rate + item.item_tax_amount);
frm.set_value('purchase_receipt_amount', item.base_net_rate + item.item_tax_amount);
- frm.set_value('location', item.asset_location);
+ item.asset_location && frm.set_value('location', item.asset_location);
+ frm.set_value('cost_center', item.cost_center || purchase_doc.cost_center);
},
set_depreciation_rate: function(frm, row) {
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index a3200d56443..2ecabe60f03 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -125,8 +125,10 @@ class Asset(AccountsController):
if self.available_for_use_date and getdate(self.available_for_use_date) < getdate(self.purchase_date):
frappe.throw(_("Available-for-use Date should be after purchase date"))
-
+
def validate_gross_and_purchase_amount(self):
+ if self.is_existing_asset: return
+
if self.gross_purchase_amount and self.gross_purchase_amount != self.purchase_receipt_amount:
frappe.throw(_("Gross Purchase Amount should be {} to purchase amount of one single Asset. {}\
Please do not book expense of multiple assets against one single Asset.")
@@ -455,7 +457,7 @@ class Asset(AccountsController):
for d in self.get('finance_books'):
if d.finance_book == self.default_finance_book:
return cint(d.idx) - 1
-
+
def validate_make_gl_entry(self):
purchase_document = self.get_purchase_document()
asset_bought_with_invoice = purchase_document == self.purchase_invoice
@@ -487,14 +489,14 @@ class Asset(AccountsController):
purchase_document = self.purchase_invoice if asset_bought_with_invoice else self.purchase_receipt
return purchase_document
-
+
def get_asset_accounts(self):
fixed_asset_account = get_asset_category_account('fixed_asset_account', asset=self.name,
asset_category = self.asset_category, company = self.company)
cwip_account = get_asset_account("capital_work_in_progress_account",
self.name, self.asset_category, self.company)
-
+
return fixed_asset_account, cwip_account
def make_gl_entries(self):
@@ -513,7 +515,7 @@ class Asset(AccountsController):
"credit": self.purchase_receipt_amount,
"credit_in_account_currency": self.purchase_receipt_amount,
"cost_center": self.cost_center
- }))
+ }, item=self))
gl_entries.append(self.get_gl_dict({
"account": fixed_asset_account,
@@ -523,7 +525,7 @@ class Asset(AccountsController):
"debit": self.purchase_receipt_amount,
"debit_in_account_currency": self.purchase_receipt_amount,
"cost_center": self.cost_center
- }))
+ }, item=self))
if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries
diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.json b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.json
index efb2de3f266..c0c2566fe23 100644
--- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.json
+++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.json
@@ -1,559 +1,140 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "field:asset_name",
- "beta": 0,
- "creation": "2017-10-19 16:50:22.879545",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "autoname": "field:asset_name",
+ "creation": "2017-10-19 16:50:22.879545",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "asset_name",
+ "asset_category",
+ "company",
+ "column_break_3",
+ "item_code",
+ "item_name",
+ "section_break_6",
+ "maintenance_team",
+ "column_break_9",
+ "maintenance_manager",
+ "maintenance_manager_name",
+ "section_break_8",
+ "asset_maintenance_tasks"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "asset_name",
- "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": "Asset Name",
- "length": 0,
- "no_copy": 0,
- "options": "Asset",
- "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
- },
+ "fieldname": "asset_name",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Asset Name",
+ "options": "Asset",
+ "reqd": 1,
+ "unique": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "asset_name.asset_category",
- "fieldname": "asset_category",
- "fieldtype": "Read Only",
- "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": "Asset Category",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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": "asset_category",
+ "fieldtype": "Read Only",
+ "label": "Asset Category"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "asset_name.item_code",
- "fieldname": "item_code",
- "fieldtype": "Read Only",
- "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": "Item Code",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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": "item_code",
+ "fieldtype": "Read Only",
+ "label": "Item Code"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "asset_name.item_name",
- "fieldname": "item_name",
- "fieldtype": "Read Only",
- "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": "Item Name",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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": "item_name",
+ "fieldtype": "Read Only",
+ "label": "Item Name"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_3",
- "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,
- "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_3",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 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,
- "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
- },
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "label": "Company",
+ "options": "Company",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "select_serial_no",
- "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": "Select Serial No",
- "length": 0,
- "no_copy": 0,
- "options": "Serial No",
- "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": "section_break_6",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "serial_no",
- "fieldtype": "Small Text",
- "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": "Serial No",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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": "maintenance_team",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Maintenance Team",
+ "options": "Asset Maintenance Team",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_6",
- "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,
- "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_9",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "maintenance_team",
- "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": "Maintenance Team",
- "length": 0,
- "no_copy": 0,
- "options": "Asset Maintenance Team",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_9",
- "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,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "maintenance_team.maintenance_manager",
- "fieldname": "maintenance_manager",
- "fieldtype": "Data",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Maintenance Manager",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "maintenance_manager",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Maintenance Manager",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "maintenance_team.maintenance_manager_name",
- "fieldname": "maintenance_manager_name",
- "fieldtype": "Read Only",
- "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": "Maintenance Manager Name",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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": "maintenance_manager_name",
+ "fieldtype": "Read Only",
+ "label": "Maintenance Manager Name"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_8",
- "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": "Tasks",
- "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": "section_break_8",
+ "fieldtype": "Section Break",
+ "label": "Tasks"
+ },
{
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "asset_maintenance_tasks",
- "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": "Maintenance Tasks",
- "length": 0,
- "no_copy": 0,
- "options": "Asset Maintenance Task",
- "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
+ "fieldname": "asset_maintenance_tasks",
+ "fieldtype": "Table",
+ "label": "Maintenance Tasks",
+ "options": "Asset Maintenance Task",
+ "reqd": 1
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-05-22 17:20:54.711885",
- "modified_by": "Administrator",
- "module": "Assets",
- "name": "Asset Maintenance",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "links": [],
+ "modified": "2020-05-28 20:28:32.993823",
+ "modified_by": "Administrator",
+ "module": "Assets",
+ "name": "Asset Maintenance",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Quality Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Quality Manager",
+ "share": 1,
"write": 1
- },
+ },
{
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Manufacturing User",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Manufacturing 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
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
index 3f046113a0f..d6adde6a371 100644
--- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
+++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
@@ -38,7 +38,7 @@ class AssetMaintenance(Document):
@frappe.whitelist()
def assign_tasks(asset_maintenance_name, assign_to_member, maintenance_task, next_due_date):
- team_member = frappe.get_doc('User', assign_to_member).email
+ team_member = frappe.db.get_value('User', assign_to_member, "email")
args = {
'doctype' : 'Asset Maintenance',
'assign_to' : team_member,
@@ -77,7 +77,7 @@ def calculate_next_due_date(periodicity, start_date = None, end_date = None, las
def update_maintenance_log(asset_maintenance, item_code, item_name, task):
asset_maintenance_log = frappe.get_value("Asset Maintenance Log", {"asset_maintenance": asset_maintenance,
- "task": task.maintenance_task, "maintenance_status": ('in',['Planned','Overdue'])})
+ "task": task.name, "maintenance_status": ('in',['Planned','Overdue'])})
if not asset_maintenance_log:
asset_maintenance_log = frappe.get_doc({
@@ -86,7 +86,7 @@ def update_maintenance_log(asset_maintenance, item_code, item_name, task):
"asset_name": asset_maintenance,
"item_code": item_code,
"item_name": item_name,
- "task": task.maintenance_task,
+ "task": task.name,
"has_certificate": task.certificate_required,
"description": task.description,
"assign_to_name": task.assign_to_name,
diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
index 42aecdf44ac..7395bec1e62 100644
--- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
+++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
@@ -1,819 +1,210 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "naming_series:",
- "beta": 0,
- "creation": "2017-10-23 16:58:44.424309",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Document",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "autoname": "naming_series:",
+ "creation": "2017-10-23 16:58:44.424309",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "asset_maintenance",
+ "naming_series",
+ "asset_name",
+ "column_break_2",
+ "item_code",
+ "item_name",
+ "section_break_5",
+ "task",
+ "task_name",
+ "maintenance_type",
+ "periodicity",
+ "assign_to_name",
+ "column_break_6",
+ "due_date",
+ "completion_date",
+ "maintenance_status",
+ "section_break_12",
+ "has_certificate",
+ "certificate_attachement",
+ "section_break_6",
+ "description",
+ "column_break_9",
+ "actions_performed",
+ "amended_from"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "asset_maintenance",
- "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": "Asset Maintenance",
- "length": 0,
- "no_copy": 0,
- "options": "Asset Maintenance",
- "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": "asset_maintenance",
+ "fieldtype": "Link",
+ "label": "Asset Maintenance",
+ "options": "Asset Maintenance"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "",
- "fieldname": "naming_series",
- "fieldtype": "Select",
- "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": "Series",
- "length": 0,
- "no_copy": 0,
- "options": "ACC-AML-.YYYY.-",
- "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
- },
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Series",
+ "options": "ACC-AML-.YYYY.-",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "asset_maintenance.asset_name",
- "fieldname": "asset_name",
- "fieldtype": "Read Only",
- "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": "Asset Name",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "fetch_from": "asset_maintenance.asset_name",
+ "fieldname": "asset_name",
+ "fieldtype": "Read Only",
+ "label": "Asset Name"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_2",
- "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,
- "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_2",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "asset_maintenance.item_code",
- "fieldname": "item_code",
- "fieldtype": "Read Only",
- "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": "Item Code",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "fetch_from": "asset_maintenance.item_code",
+ "fieldname": "item_code",
+ "fieldtype": "Read Only",
+ "label": "Item Code"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "asset_maintenance.item_name",
- "fieldname": "item_name",
- "fieldtype": "Read Only",
- "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": "Item Name",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "fetch_from": "asset_maintenance.item_name",
+ "fieldname": "item_name",
+ "fieldtype": "Read Only",
+ "label": "Item Name"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_5",
- "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,
- "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": "section_break_5",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "task",
- "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": "Task",
- "length": 0,
- "no_copy": 0,
- "options": "Asset Maintenance Task",
- "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": "task",
+ "fieldtype": "Link",
+ "label": "Task",
+ "options": "Asset Maintenance Task"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.maintenance_type",
- "fieldname": "maintenance_type",
- "fieldtype": "Read Only",
- "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": "Maintenance Type",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "fetch_from": "task.maintenance_type",
+ "fieldname": "maintenance_type",
+ "fieldtype": "Read Only",
+ "label": "Maintenance Type"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.periodicity",
- "fieldname": "periodicity",
- "fieldtype": "Data",
- "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": "Periodicity",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fetch_from": "task.periodicity",
+ "fieldname": "periodicity",
+ "fieldtype": "Data",
+ "label": "Periodicity",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.assign_to_name",
- "fieldname": "assign_to_name",
- "fieldtype": "Read Only",
- "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": "Assign To",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "fetch_from": "task.assign_to_name",
+ "fieldname": "assign_to_name",
+ "fieldtype": "Read Only",
+ "label": "Assign To"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_6",
- "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,
- "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_6",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.next_due_date",
- "fieldname": "due_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": "Due Date",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fetch_from": "task.next_due_date",
+ "fieldname": "due_date",
+ "fieldtype": "Date",
+ "in_list_view": 1,
+ "label": "Due Date",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "completion_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": "Completion Date",
- "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": "completion_date",
+ "fieldtype": "Date",
+ "in_list_view": 1,
+ "label": "Completion Date"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "maintenance_status",
- "fieldtype": "Select",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 1,
- "label": "Maintenance Status",
- "length": 0,
- "no_copy": 0,
- "options": "Planned\nCompleted\nCancelled\nOverdue",
- "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
- },
+ "fieldname": "maintenance_status",
+ "fieldtype": "Select",
+ "in_standard_filter": 1,
+ "label": "Maintenance Status",
+ "options": "Planned\nCompleted\nCancelled\nOverdue",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_12",
- "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,
- "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": "section_break_12",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.certificate_required",
- "fieldname": "has_certificate",
- "fieldtype": "Check",
- "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": "Has Certificate ",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "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
- },
+ "default": "0",
+ "fetch_from": "task.certificate_required",
+ "fieldname": "has_certificate",
+ "fieldtype": "Check",
+ "label": "Has Certificate "
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.has_certificate",
- "fieldname": "certificate_attachement",
- "fieldtype": "Attach",
- "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": "Certificate",
- "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
- },
+ "depends_on": "eval:doc.has_certificate",
+ "fieldname": "certificate_attachement",
+ "fieldtype": "Attach",
+ "label": "Certificate"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_6",
- "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,
- "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": "section_break_6",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "task.description",
- "fieldname": "description",
- "fieldtype": "Read Only",
- "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": "Description",
- "length": 0,
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fetch_from": "task.description",
+ "fieldname": "description",
+ "fieldtype": "Read Only",
+ "label": "Description",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_9",
- "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,
- "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_9",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "actions_performed",
- "fieldtype": "Text Editor",
- "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": "Actions performed",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "allow_on_submit": 1,
+ "fieldname": "actions_performed",
+ "fieldtype": "Text Editor",
+ "label": "Actions performed"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "amended_from",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Amended From",
- "length": 0,
- "no_copy": 1,
- "options": "Asset Maintenance Log",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldname": "amended_from",
+ "fieldtype": "Link",
+ "label": "Amended From",
+ "no_copy": 1,
+ "options": "Asset Maintenance Log",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fetch_from": "task.maintenance_task",
+ "fieldname": "task_name",
+ "fieldtype": "Data",
+ "in_preview": 1,
+ "label": "Task Name",
+ "read_only": 1
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 1,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-08-21 14:44:51.457835",
- "modified_by": "Administrator",
- "module": "Assets",
- "name": "Asset Maintenance Log",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "is_submittable": 1,
+ "links": [],
+ "modified": "2020-05-28 20:51:48.238397",
+ "modified_by": "Administrator",
+ "module": "Assets",
+ "name": "Asset Maintenance Log",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 1,
- "cancel": 1,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Manufacturing User",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 1,
+ "amend": 1,
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Manufacturing User",
+ "share": 1,
+ "submit": 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",
- "title_field": "",
- "track_changes": 1,
- "track_seen": 1,
- "track_views": 0
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 1
}
\ No newline at end of file
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 d98cc310b3b..2a5666d5064 100644
--- a/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py
+++ b/erpnext/assets/doctype/asset_maintenance_task/asset_maintenance_task.py
@@ -7,5 +7,4 @@ import frappe
from frappe.model.document import Document
class AssetMaintenanceTask(Document):
- def autoname(self):
- self.name = self.maintenance_task
+ pass
diff --git a/erpnext/assets/doctype/location/location.json b/erpnext/assets/doctype/location/location.json
index 6a35130f30a..f56fd05d98c 100644
--- a/erpnext/assets/doctype/location/location.json
+++ b/erpnext/assets/doctype/location/location.json
@@ -141,7 +141,7 @@
],
"is_tree": 1,
"links": [],
- "modified": "2020-03-18 18:00:08.885805",
+ "modified": "2020-05-08 16:11:11.375701",
"modified_by": "Administrator",
"module": "Assets",
"name": "Location",
@@ -221,7 +221,6 @@
}
],
"quick_entry": 1,
- "restrict_to_domain": "Agriculture",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
diff --git a/erpnext/assets/module_onboarding/assets/assets.json b/erpnext/assets/module_onboarding/assets/assets.json
new file mode 100644
index 00000000000..66dd60ae81f
--- /dev/null
+++ b/erpnext/assets/module_onboarding/assets/assets.json
@@ -0,0 +1,42 @@
+{
+ "allow_roles": [
+ {
+ "role": "Accounts User"
+ },
+ {
+ "role": "Maintenance User"
+ }
+ ],
+ "creation": "2020-05-08 15:10:45.571457",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/asset",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-08 16:17:31.685943",
+ "modified_by": "Administrator",
+ "module": "Assets",
+ "name": "Assets",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Introduction to Assets"
+ },
+ {
+ "step": "Create a Fixed Asset Item"
+ },
+ {
+ "step": "Create an Asset Category"
+ },
+ {
+ "step": "Purchase an Asset Item"
+ },
+ {
+ "step": "Create an Asset"
+ }
+ ],
+ "subtitle": "Assets, Depreciations, Repairs and more",
+ "success_message": "The Asset Module is all set up!",
+ "title": "Let's Setup Asset Management",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/assets/onboarding_step/create_a_fixed_asset_item/create_a_fixed_asset_item.json b/erpnext/assets/onboarding_step/create_a_fixed_asset_item/create_a_fixed_asset_item.json
new file mode 100644
index 00000000000..f5818c091f1
--- /dev/null
+++ b/erpnext/assets/onboarding_step/create_a_fixed_asset_item/create_a_fixed_asset_item.json
@@ -0,0 +1,16 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-08 13:20:00.259985",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-08 13:20:00.259985",
+ "modified_by": "Administrator",
+ "name": "Create a Fixed Asset Item",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "title": "Create a Fixed Asset Item"
+}
\ No newline at end of file
diff --git a/erpnext/assets/onboarding_step/create_an_asset/create_an_asset.json b/erpnext/assets/onboarding_step/create_an_asset/create_an_asset.json
new file mode 100644
index 00000000000..5488b1d7b4e
--- /dev/null
+++ b/erpnext/assets/onboarding_step/create_an_asset/create_an_asset.json
@@ -0,0 +1,16 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-08 13:21:53.332538",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-08 13:21:53.332538",
+ "modified_by": "Administrator",
+ "name": "Create an Asset",
+ "owner": "Administrator",
+ "reference_document": "Asset",
+ "title": "Create an Asset"
+}
\ No newline at end of file
diff --git a/erpnext/assets/onboarding_step/create_an_asset_category/create_an_asset_category.json b/erpnext/assets/onboarding_step/create_an_asset_category/create_an_asset_category.json
new file mode 100644
index 00000000000..3bf54af348a
--- /dev/null
+++ b/erpnext/assets/onboarding_step/create_an_asset_category/create_an_asset_category.json
@@ -0,0 +1,16 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-08 13:21:53.332538",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-08 13:21:53.332538",
+ "modified_by": "Administrator",
+ "name": "Create an Asset Category",
+ "owner": "Administrator",
+ "reference_document": "Asset Category",
+ "title": "Create an Asset Category"
+ }
\ No newline at end of file
diff --git a/erpnext/assets/onboarding_step/introduction_to_assets/introduction_to_assets.json b/erpnext/assets/onboarding_step/introduction_to_assets/introduction_to_assets.json
new file mode 100644
index 00000000000..d48dd1cd3d2
--- /dev/null
+++ b/erpnext/assets/onboarding_step/introduction_to_assets/introduction_to_assets.json
@@ -0,0 +1,16 @@
+{
+ "action": "Watch Video",
+ "creation": "2020-05-08 13:18:25.424715",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-08 16:06:16.625646",
+ "modified_by": "Administrator",
+ "name": "Introduction to Assets",
+ "owner": "Administrator",
+ "title": "Introduction to Assets",
+ "video_url": "https://www.youtube.com/watch?v=I-K8pLRmvSo"
+}
\ No newline at end of file
diff --git a/erpnext/assets/onboarding_step/purchase_an_asset_item/purchase_an_asset_item.json b/erpnext/assets/onboarding_step/purchase_an_asset_item/purchase_an_asset_item.json
new file mode 100644
index 00000000000..732ff7f733b
--- /dev/null
+++ b/erpnext/assets/onboarding_step/purchase_an_asset_item/purchase_an_asset_item.json
@@ -0,0 +1,16 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-08 13:21:28.208059",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-08 13:21:28.208059",
+ "modified_by": "Administrator",
+ "name": "Purchase an Asset Item",
+ "owner": "Administrator",
+ "reference_document": "Purchase Receipt",
+ "title": "Purchase an Asset Item"
+}
\ No newline at end of file
diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
index 91ce9ce7fe9..1a6ef54a830 100644
--- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
+++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.js
@@ -21,20 +21,54 @@ frappe.query_reports["Fixed Asset Register"] = {
reqd: 1
},
{
- fieldname:"purchase_date",
- label: __("Purchase Date"),
- fieldtype: "Date"
+ "fieldname":"filter_based_on",
+ "label": __("Period Based On"),
+ "fieldtype": "Select",
+ "options": ["Fiscal Year", "Date Range"],
+ "default": ["Fiscal Year"],
+ "reqd": 1
},
{
- fieldname:"available_for_use_date",
- label: __("Available For Use Date"),
- fieldtype: "Date"
+ "fieldname":"from_date",
+ "label": __("Start Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.add_months(frappe.datetime.nowdate(), -12),
+ "depends_on": "eval: doc.filter_based_on == 'Date Range'",
+ "reqd": 1
},
{
- fieldname:"finance_book",
- label: __("Finance Book"),
- fieldtype: "Link",
- options: "Finance Book"
+ "fieldname":"to_date",
+ "label": __("End Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.nowdate(),
+ "depends_on": "eval: doc.filter_based_on == 'Date Range'",
+ "reqd": 1
+ },
+ {
+ "fieldname":"from_fiscal_year",
+ "label": __("Start Year"),
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": frappe.defaults.get_user_default("fiscal_year"),
+ "depends_on": "eval: doc.filter_based_on == 'Fiscal Year'",
+ "reqd": 1
+ },
+ {
+ "fieldname":"to_fiscal_year",
+ "label": __("End Year"),
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": frappe.defaults.get_user_default("fiscal_year"),
+ "depends_on": "eval: doc.filter_based_on == 'Fiscal Year'",
+ "reqd": 1
+ },
+ {
+ "fieldname":"date_based_on",
+ "label": __("Date Based On"),
+ "fieldtype": "Select",
+ "options": ["Purchase Date", "Available For Use Date"],
+ "default": "Purchase Date",
+ "reqd": 1
},
{
fieldname:"asset_category",
@@ -42,6 +76,26 @@ frappe.query_reports["Fixed Asset Register"] = {
fieldtype: "Link",
options: "Asset Category"
},
+ {
+ fieldname:"finance_book",
+ label: __("Finance Book"),
+ fieldtype: "Link",
+ options: "Finance Book"
+ },
+ {
+ fieldname:"cost_center",
+ label: __("Cost Center"),
+ fieldtype: "Link",
+ options: "Cost Center"
+ },
+ {
+ fieldname:"group_by",
+ label: __("Group By"),
+ fieldtype: "Select",
+ options: ["--Select a group--", "Asset Category", "Location"],
+ default: "--Select a group--",
+ reqd: 1
+ },
{
fieldname:"is_existing_asset",
label: __("Is Existing Asset"),
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 fa2fe7b4a3c..af08a2a601e 100644
--- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
+++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
@@ -4,122 +4,39 @@
from __future__ import unicode_literals
import frappe
from frappe import _
-from frappe.utils import cstr, today, flt
+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
def execute(filters=None):
filters = frappe._dict(filters or {})
columns = get_columns(filters)
data = get_data(filters)
- return columns, data
+ chart = prepare_chart_data(data, filters) if filters.get("group_by") not in ("Asset Category", "Location") else {}
-def get_columns(filters):
- return [
- {
- "label": _("Asset Id"),
- "fieldtype": "Link",
- "fieldname": "asset_id",
- "options": "Asset",
- "width": 100
- },
- {
- "label": _("Asset Name"),
- "fieldtype": "Data",
- "fieldname": "asset_name",
- "width": 140
- },
- {
- "label": _("Asset Category"),
- "fieldtype": "Link",
- "fieldname": "asset_category",
- "options": "Asset Category",
- "width": 100
- },
- {
- "label": _("Status"),
- "fieldtype": "Data",
- "fieldname": "status",
- "width": 90
- },
- {
- "label": _("Purchase Date"),
- "fieldtype": "Date",
- "fieldname": "purchase_date",
- "width": 90
- },
- {
- "label": _("Available For Use Date"),
- "fieldtype": "Date",
- "fieldname": "available_for_use_date",
- "width": 90
- },
- {
- "label": _("Gross Purchase Amount"),
- "fieldname": "gross_purchase_amount",
- "options": "Currency",
- "width": 90
- },
- {
- "label": _("Asset Value"),
- "fieldname": "asset_value",
- "options": "Currency",
- "width": 90
- },
- {
- "label": _("Opening Accumulated Depreciation"),
- "fieldname": "opening_accumulated_depreciation",
- "options": "Currency",
- "width": 90
- },
- {
- "label": _("Depreciated Amount"),
- "fieldname": "depreciated_amount",
- "options": "Currency",
- "width": 90
- },
- {
- "label": _("Cost Center"),
- "fieldtype": "Link",
- "fieldname": "cost_center",
- "options": "Cost Center",
- "width": 100
- },
- {
- "label": _("Department"),
- "fieldtype": "Link",
- "fieldname": "department",
- "options": "Department",
- "width": 100
- },
- {
- "label": _("Vendor Name"),
- "fieldtype": "Data",
- "fieldname": "vendor_name",
- "width": 100
- },
- {
- "label": _("Location"),
- "fieldtype": "Link",
- "fieldname": "location",
- "options": "Location",
- "width": 100
- },
- ]
+ return columns, data, None, chart
def get_conditions(filters):
conditions = { 'docstatus': 1 }
status = filters.status
- date = filters.date
+ date_field = frappe.scrub(filters.date_based_on or "Purchase Date")
if filters.get('company'):
conditions["company"] = filters.company
- if filters.get('purchase_date'):
- conditions["purchase_date"] = ('<=', filters.get('purchase_date'))
- if filters.get('available_for_use_date'):
- conditions["available_for_use_date"] = ('<=', filters.get('available_for_use_date'))
+ if filters.filter_based_on == "Date Range":
+ conditions[date_field] = ["between", [filters.from_date, filters.to_date]]
+ if filters.filter_based_on == "Fiscal Year":
+ fiscal_year = get_fiscal_year_data(filters.from_fiscal_year, filters.to_fiscal_year)
+ validate_fiscal_year(fiscal_year, filters.from_fiscal_year, filters.to_fiscal_year)
+ filters.year_start_date = getdate(fiscal_year.year_start_date)
+ filters.year_end_date = getdate(fiscal_year.year_end_date)
+
+ conditions[date_field] = ["between", [filters.year_start_date, filters.year_end_date]]
if filters.get('is_existing_asset'):
conditions["is_existing_asset"] = filters.get('is_existing_asset')
if filters.get('asset_category'):
conditions["asset_category"] = filters.get('asset_category')
+ if filters.get('cost_center'):
+ conditions["cost_center"] = filters.get('cost_center')
# In Store assets are those that are not sold or scrapped
operand = 'not in'
@@ -139,18 +56,28 @@ def get_data(filters):
pr_supplier_map = get_purchase_receipt_supplier_map()
pi_supplier_map = get_purchase_invoice_supplier_map()
- assets_record = frappe.db.get_all("Asset",
- filters=conditions,
- fields=["name", "asset_name", "department", "cost_center", "purchase_receipt",
+ group_by = frappe.scrub(filters.get("group_by"))
+
+ if group_by == "asset_category":
+ fields = ["asset_category", "gross_purchase_amount", "opening_accumulated_depreciation"]
+ assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields, group_by=group_by)
+
+ elif group_by == "location":
+ fields = ["location", "gross_purchase_amount", "opening_accumulated_depreciation"]
+ assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields, group_by=group_by)
+
+ else:
+ fields = ["name as asset_id", "asset_name", "status", "department", "cost_center", "purchase_receipt",
"asset_category", "purchase_date", "gross_purchase_amount", "location",
- "available_for_use_date", "status", "purchase_invoice", "opening_accumulated_depreciation"])
+ "available_for_use_date", "purchase_invoice", "opening_accumulated_depreciation"]
+ assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)
for asset in assets_record:
asset_value = asset.gross_purchase_amount - flt(asset.opening_accumulated_depreciation) \
- flt(depreciation_amount_map.get(asset.name))
if asset_value:
row = {
- "asset_id": asset.name,
+ "asset_id": asset.asset_id,
"asset_name": asset.asset_name,
"status": asset.status,
"department": asset.department,
@@ -158,7 +85,7 @@ def get_data(filters):
"vendor_name": pr_supplier_map.get(asset.purchase_receipt) or pi_supplier_map.get(asset.purchase_invoice),
"gross_purchase_amount": asset.gross_purchase_amount,
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
- "depreciated_amount": depreciation_amount_map.get(asset.name) or 0.0,
+ "depreciated_amount": depreciation_amount_map.get(asset.asset_id) or 0.0,
"available_for_use_date": asset.available_for_use_date,
"location": asset.location,
"asset_category": asset.asset_category,
@@ -169,8 +96,39 @@ def get_data(filters):
return data
+def prepare_chart_data(data, filters):
+ labels_values_map = {}
+ date_field = frappe.scrub(filters.date_based_on)
+
+ period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
+ filters.from_date, filters.to_date, filters.filter_based_on, "Monthly", company=filters.company)
+
+ for d in period_list:
+ labels_values_map.setdefault(d.get('label'), frappe._dict({'asset_value': 0, 'depreciated_amount': 0}))
+
+ for d in data:
+ date = d.get(date_field)
+ belongs_to_month = formatdate(date, "MMM YYYY")
+
+ labels_values_map[belongs_to_month].asset_value += d.get("asset_value")
+ labels_values_map[belongs_to_month].depreciated_amount += d.get("depreciated_amount")
+
+ return {
+ "data" : {
+ "labels": labels_values_map.keys(),
+ "datasets": [
+ { 'name': _('Asset Value'), 'values': [d.get("asset_value") for d in labels_values_map.values()] },
+ { 'name': _('Depreciatied Amount'), 'values': [d.get("depreciated_amount") for d in labels_values_map.values()] }
+ ]
+ },
+ "type": "bar",
+ "barOptions": {
+ "stacked": 1
+ },
+ }
+
def get_finance_book_value_map(filters):
- date = filters.get('purchase_date') or filters.get('available_for_use_date') or today()
+ date = filters.to_date if filters.filter_based_on == "Date Range" else filters.year_end_date
return frappe._dict(frappe.db.sql(''' Select
parent, SUM(depreciation_amount)
@@ -201,3 +159,139 @@ def get_purchase_invoice_supplier_map():
AND pii.is_fixed_asset=1
AND pi.docstatus=1
AND pi.is_return=0'''))
+
+def get_columns(filters):
+ if filters.get("group_by") in ["Asset Category", "Location"]:
+ return [
+ {
+ "label": _("{}").format(filters.get("group_by")),
+ "fieldtype": "Link",
+ "fieldname": frappe.scrub(filters.get("group_by")),
+ "options": filters.get("group_by"),
+ "width": 120
+ },
+ {
+ "label": _("Gross Purchase Amount"),
+ "fieldname": "gross_purchase_amount",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ },
+ {
+ "label": _("Opening Accumulated Depreciation"),
+ "fieldname": "opening_accumulated_depreciation",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 90
+ },
+ {
+ "label": _("Depreciated Amount"),
+ "fieldname": "depreciated_amount",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ },
+ {
+ "label": _("Asset Value"),
+ "fieldname": "asset_value",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ }
+ ]
+
+ return [
+ {
+ "label": _("Asset Id"),
+ "fieldtype": "Link",
+ "fieldname": "asset_id",
+ "options": "Asset",
+ "width": 60
+ },
+ {
+ "label": _("Asset Name"),
+ "fieldtype": "Data",
+ "fieldname": "asset_name",
+ "width": 140
+ },
+ {
+ "label": _("Asset Category"),
+ "fieldtype": "Link",
+ "fieldname": "asset_category",
+ "options": "Asset Category",
+ "width": 100
+ },
+ {
+ "label": _("Status"),
+ "fieldtype": "Data",
+ "fieldname": "status",
+ "width": 80
+ },
+ {
+ "label": _("Purchase Date"),
+ "fieldtype": "Date",
+ "fieldname": "purchase_date",
+ "width": 90
+ },
+ {
+ "label": _("Available For Use Date"),
+ "fieldtype": "Date",
+ "fieldname": "available_for_use_date",
+ "width": 90
+ },
+ {
+ "label": _("Gross Purchase Amount"),
+ "fieldname": "gross_purchase_amount",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ },
+ {
+ "label": _("Asset Value"),
+ "fieldname": "asset_value",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ },
+ {
+ "label": _("Opening Accumulated Depreciation"),
+ "fieldname": "opening_accumulated_depreciation",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 90
+ },
+ {
+ "label": _("Depreciated Amount"),
+ "fieldname": "depreciated_amount",
+ "fieldtype": "Currency",
+ "options": "company:currency",
+ "width": 100
+ },
+ {
+ "label": _("Cost Center"),
+ "fieldtype": "Link",
+ "fieldname": "cost_center",
+ "options": "Cost Center",
+ "width": 100
+ },
+ {
+ "label": _("Department"),
+ "fieldtype": "Link",
+ "fieldname": "department",
+ "options": "Department",
+ "width": 100
+ },
+ {
+ "label": _("Vendor Name"),
+ "fieldtype": "Data",
+ "fieldname": "vendor_name",
+ "width": 100
+ },
+ {
+ "label": _("Location"),
+ "fieldtype": "Link",
+ "fieldname": "location",
+ "options": "Location",
+ "width": 100
+ },
+ ]
\ No newline at end of file
diff --git a/erpnext/buying/dashboard_fixtures.py b/erpnext/buying/dashboard_fixtures.py
new file mode 100644
index 00000000000..186bfb23af9
--- /dev/null
+++ b/erpnext/buying/dashboard_fixtures.py
@@ -0,0 +1,207 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+import json
+from frappe import _
+from frappe.utils import nowdate
+from erpnext.accounts.utils import get_fiscal_year
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
+
+company = frappe.get_doc("Company", get_company_for_dashboards())
+fiscal_year = get_fiscal_year(nowdate(), as_dict=1)
+fiscal_year_name = fiscal_year.get("name")
+start_date = str(fiscal_year.get("year_start_date"))
+end_date = str(fiscal_year.get("year_end_date"))
+
+def get_dashboards():
+ return [{
+ "name": "Buying",
+ "dashboard_name": "Buying",
+ "charts": [
+ { "chart": "Purchase Order Trends", "width": "Full"},
+ { "chart": "Material Request Analysis", "width": "Half"},
+ { "chart": "Purchase Order Analysis", "width": "Half"},
+ { "chart": "Top Suppliers", "width": "Full"}
+ ],
+ "cards": [
+ { "card": "Annual Purchase"},
+ { "card": "Purchase Orders to Receive"},
+ { "card": "Purchase Orders to Bill"},
+ { "card": "Active Suppliers"}
+ ]
+ }]
+
+def get_charts():
+ return [
+ {
+ "name": "Purchase Order Analysis",
+ "chart_name": _("Purchase Order Analysis"),
+ "chart_type": "Report",
+ "custom_options": json.dumps({
+ "type": "donut",
+ "height": 300,
+ "axisOptions": {"shortenYAxisNumbers": 1}
+ }),
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "from_date": start_date,
+ "to_date": end_date
+ }),
+ "is_custom": 1,
+ "is_public": 1,
+ "owner": "Administrator",
+ "report_name": "Purchase Order Analysis",
+ "type": "Donut"
+ },
+ {
+ "name": "Material Request Analysis",
+ "chart_name": _("Material Request Analysis"),
+ "chart_type": "Group By",
+ "custom_options": json.dumps({"height": 300}),
+ "doctype": "Dashboard Chart",
+ "document_type": "Material Request",
+ "filters_json": json.dumps(
+ [["Material Request", "status", "not in", ["Draft", "Cancelled", "Stopped", None], False],
+ ["Material Request", "material_request_type", "=", "Purchase", False],
+ ["Material Request", "company", "=", company.name, False],
+ ["Material Request", "docstatus", "=", 1, False],
+ ["Material Request", "transaction_date", "Between", [start_date, end_date], False]]
+ ),
+ "group_by_based_on": "status",
+ "group_by_type": "Count",
+ "is_custom": 0,
+ "is_public": 1,
+ "number_of_groups": 0,
+ "owner": "Administrator",
+ "type": "Donut"
+ },
+ {
+ "name": "Purchase Order Trends",
+ "chart_name": _("Purchase Order Trends"),
+ "chart_type": "Report",
+ "custom_options": json.dumps({
+ "type": "line",
+ "axisOptions": {"shortenYAxisNumbers": 1},
+ "tooltipOptions": {},
+ "lineOptions": {
+ "regionFill": 1
+ }
+ }),
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "period": "Monthly",
+ "fiscal_year": fiscal_year_name,
+ "period_based_on": "posting_date",
+ "based_on": "Item"
+ }),
+ "is_custom": 1,
+ "is_public": 1,
+ "owner": "Administrator",
+ "report_name": "Purchase Order Trends",
+ "type": "Line"
+ },
+ {
+ "name": "Top Suppliers",
+ "chart_name": _("Top Suppliers"),
+ "chart_type": "Report",
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "period": "Monthly",
+ "fiscal_year": fiscal_year_name,
+ "period_based_on": "posting_date",
+ "based_on": "Supplier"
+ }),
+ "is_custom": 1,
+ "is_public": 1,
+ "owner": "Administrator",
+ "report_name": "Purchase Receipt Trends",
+ "type": "Bar"
+ }
+ ]
+
+def get_number_cards():
+ return [
+ {
+ "name": "Annual Purchase",
+ "aggregate_function_based_on": "base_net_total",
+ "doctype": "Number Card",
+ "document_type": "Purchase Order",
+ "filters_json": json.dumps([
+ ["Purchase Order", "transaction_date", "Between", [start_date, end_date], False],
+ ["Purchase Order", "status", "not in", ["Draft", "Cancelled", "Closed", None], False],
+ ["Purchase Order", "docstatus", "=", 1, False],
+ ["Purchase Order", "company", "=", company.name, False],
+ ["Purchase Order", "transaction_date", "Between", [start_date,end_date], False]
+ ]),
+ "function": "Sum",
+ "is_public": 1,
+ "label": _("Annual Purchase"),
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "name": "Purchase Orders to Receive",
+ "doctype": "Number Card",
+ "document_type": "Purchase Order",
+ "filters_json": json.dumps([
+ ["Purchase Order", "status", "in", ["To Receive and Bill", "To Receive", None], False],
+ ["Purchase Order", "docstatus", "=", 1, False],
+ ["Purchase Order", "company", "=", company.name, False]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Purchase Orders to Receive"),
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ },
+ {
+ "name": "Purchase Orders to Bill",
+ "doctype": "Number Card",
+ "document_type": "Purchase Order",
+ "filters_json": json.dumps([
+ ["Purchase Order", "status", "in", ["To Receive and Bill", "To Bill", None], False],
+ ["Purchase Order", "docstatus", "=", 1, False],
+ ["Purchase Order", "company", "=", company.name, False]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Purchase Orders to Bill"),
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ },
+ {
+ "name": "Active Suppliers",
+ "doctype": "Number Card",
+ "document_type": "Supplier",
+ "filters_json": json.dumps([["Supplier", "disabled", "=", "0"]]),
+ "function": "Count",
+ "is_public": 1,
+ "label": "Active Suppliers",
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/buying/desk_page/buying/buying.json b/erpnext/buying/desk_page/buying/buying.json
index 5e764cf8bbe..bddb9573ad5 100644
--- a/erpnext/buying/desk_page/buying/buying.json
+++ b/erpnext/buying/desk_page/buying/buying.json
@@ -2,24 +2,24 @@
"cards": [
{
"hidden": 0,
- "label": "Supplier",
- "links": "[\n {\n \"description\": \"Supplier database.\",\n \"label\": \"Supplier\",\n \"name\": \"Supplier\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Supplier Group master.\",\n \"label\": \"Supplier Group\",\n \"name\": \"Supplier Group\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"All Contacts.\",\n \"label\": \"Contact\",\n \"name\": \"Contact\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"All Addresses.\",\n \"label\": \"Address\",\n \"name\": \"Address\",\n \"type\": \"doctype\"\n }\n]"
+ "label": "Buying",
+ "links": "[ \n {\n \"dependencies\": [\n \"Item\"\n ],\n \"description\": \"Request for purchase.\",\n \"label\": \"Material Request\",\n \"name\": \"Material Request\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Purchase Orders given to Suppliers.\",\n \"label\": \"Purchase Order\",\n \"name\": \"Purchase Order\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"label\": \"Purchase Invoice\",\n \"name\": \"Purchase Invoice\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Request for quotation.\",\n \"label\": \"Request for Quotation\",\n \"name\": \"Request for Quotation\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Quotations received from Suppliers.\",\n \"label\": \"Supplier Quotation\",\n \"name\": \"Supplier Quotation\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
- "label": "Purchasing",
- "links": "[\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Purchase Orders given to Suppliers.\",\n \"label\": \"Purchase Order\",\n \"name\": \"Purchase Order\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"label\": \"Purchase Invoice\",\n \"name\": \"Purchase Invoice\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"description\": \"Request for purchase.\",\n \"label\": \"Material Request\",\n \"name\": \"Material Request\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Request for quotation.\",\n \"label\": \"Request for Quotation\",\n \"name\": \"Request for Quotation\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"description\": \"Quotations received from Suppliers.\",\n \"label\": \"Supplier Quotation\",\n \"name\": \"Supplier Quotation\",\n \"type\": \"doctype\"\n }\n]"
- },
- {
- "hidden": 0,
- "label": "Items and Pricing",
- "links": "[\n {\n \"description\": \"All Products or Services.\",\n \"label\": \"Item\",\n \"name\": \"Item\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Multiple Item prices.\",\n \"label\": \"Item Price\",\n \"name\": \"Item Price\",\n \"onboard\": 1,\n \"route\": \"#Report/Item Price\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Price List master.\",\n \"label\": \"Price List\",\n \"name\": \"Price List\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Bundle items at time of sale.\",\n \"label\": \"Product Bundle\",\n \"name\": \"Product Bundle\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Tree of Item Groups.\",\n \"icon\": \"fa fa-sitemap\",\n \"label\": \"Item Group\",\n \"link\": \"Tree/Item Group\",\n \"name\": \"Item Group\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Rules for applying different promotional schemes.\",\n \"label\": \"Promotional Scheme\",\n \"name\": \"Promotional Scheme\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Rules for applying pricing and discount.\",\n \"label\": \"Pricing Rule\",\n \"name\": \"Pricing Rule\",\n \"type\": \"doctype\"\n }\n]"
+ "label": "Items & Pricing",
+ "links": "[\n {\n \"description\": \"All Products or Services.\",\n \"label\": \"Item\",\n \"name\": \"Item\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Multiple Item prices.\",\n \"label\": \"Item Price\",\n \"name\": \"Item Price\",\n \"onboard\": 1,\n \"route\": \"#Report/Item Price\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Price List master.\",\n \"label\": \"Price List\",\n \"name\": \"Price List\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Bundle items at time of sale.\",\n \"label\": \"Product Bundle\",\n \"name\": \"Product Bundle\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Tree of Item Groups.\",\n \"icon\": \"fa fa-sitemap\",\n \"label\": \"Item Group\",\n \"link\": \"Tree/Item Group\",\n \"name\": \"Item Group\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Rules for applying different promotional schemes.\",\n \"label\": \"Promotional Scheme\",\n \"name\": \"Promotional Scheme\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Rules for applying pricing and discount.\",\n \"label\": \"Pricing Rule\",\n \"name\": \"Pricing Rule\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
"label": "Settings",
"links": "[\n {\n \"description\": \"Default settings for buying transactions.\",\n \"label\": \"Buying Settings\",\n \"name\": \"Buying Settings\",\n \"settings\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Tax template for buying transactions.\",\n \"label\": \"Purchase Taxes and Charges Template\",\n \"name\": \"Purchase Taxes and Charges Template\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Template of terms or contract.\",\n \"label\": \"Terms and Conditions Template\",\n \"name\": \"Terms and Conditions\",\n \"type\": \"doctype\"\n }\n]"
},
+ {
+ "hidden": 0,
+ "label": "Supplier",
+ "links": "[\n {\n \"description\": \"Supplier database.\",\n \"label\": \"Supplier\",\n \"name\": \"Supplier\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Supplier Group master.\",\n \"label\": \"Supplier Group\",\n \"name\": \"Supplier Group\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"All Contacts.\",\n \"label\": \"Contact\",\n \"name\": \"Contact\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"All Addresses.\",\n \"label\": \"Address\",\n \"name\": \"Address\",\n \"type\": \"doctype\"\n }\n]"
+ },
{
"hidden": 0,
"label": "Supplier Scorecard",
@@ -28,67 +28,86 @@
{
"hidden": 0,
"label": "Key Reports",
- "links": "[\n {\n \"is_query_report\": true,\n \"label\": \"Purchase Analytics\",\n \"name\": \"Purchase Analytics\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Supplier-Wise Sales Analytics\",\n \"name\": \"Supplier-Wise Sales Analytics\",\n \"onboard\": 1,\n \"reference_doctype\": \"Stock Ledger Entry\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Purchase Order Trends\",\n \"name\": \"Purchase Order Trends\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Procurement Tracker\",\n \"name\": \"Procurement Tracker\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Requested Items To Be Ordered\",\n \"name\": \"Requested Items To Be Ordered\",\n \"onboard\": 1,\n \"reference_doctype\": \"Material Request\",\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"is_query_report\": true,\n \"label\": \"Purchase Analytics\",\n \"name\": \"Purchase Analytics\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Purchase Order Analysis\",\n \"name\": \"Purchase Order Analysis\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Supplier-Wise Sales Analytics\",\n \"name\": \"Supplier-Wise Sales Analytics\",\n \"onboard\": 1,\n \"reference_doctype\": \"Stock Ledger Entry\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Requested Items to Order\",\n \"name\": \"Requested Items to Order\",\n \"onboard\": 1,\n \"reference_doctype\": \"Material Request\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Purchase Order Trends\",\n \"name\": \"Purchase Order Trends\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Procurement Tracker\",\n \"name\": \"Procurement Tracker\",\n \"onboard\": 1,\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n }\n]"
},
{
"hidden": 0,
"label": "Other Reports",
- "links": "[\n {\n \"is_query_report\": true,\n \"label\": \"Items To Be Requested\",\n \"name\": \"Items To Be Requested\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Item-wise Purchase History\",\n \"name\": \"Item-wise Purchase History\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Material Requests for which Supplier Quotations are not created\",\n \"name\": \"Material Requests for which Supplier Quotations are not created\",\n \"reference_doctype\": \"Material Request\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Supplier Addresses And Contacts\",\n \"name\": \"Address And Contacts\",\n \"reference_doctype\": \"Address\",\n \"route_options\": {\n \"party_type\": \"Supplier\"\n },\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"is_query_report\": true,\n \"label\": \"Items To Be Requested\",\n \"name\": \"Items To Be Requested\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Item-wise Purchase History\",\n \"name\": \"Item-wise Purchase History\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Subcontracted Raw Materials To Be Transferred\",\n \"name\": \"Subcontracted Raw Materials To Be Transferred\",\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Subcontracted Item To Be Received\",\n \"name\": \"Subcontracted Item To Be Received\",\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Quoted Item Comparison\",\n \"name\": \"Quoted Item Comparison\",\n \"onboard\": 1,\n \"reference_doctype\": \"Supplier Quotation\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Material Requests for which Supplier Quotations are not created\",\n \"name\": \"Material Requests for which Supplier Quotations are not created\",\n \"reference_doctype\": \"Material Request\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Supplier Addresses And Contacts\",\n \"name\": \"Address And Contacts\",\n \"reference_doctype\": \"Address\",\n \"route_options\": {\n \"party_type\": \"Supplier\"\n },\n \"type\": \"report\"\n }\n]"
+ },
+ {
+ "hidden": 0,
+ "label": "Regional",
+ "links": "[\n {\n \"description\": \"Import Italian Purchase Invoices\",\n \"label\": \"Import Supplier Invoice\",\n \"name\": \"Import Supplier Invoice\",\n \"type\": \"doctype\"\n } \n]"
}
],
+ "cards_label": "",
"category": "Modules",
"charts": [
{
- "chart_name": "Expenses",
- "label": "Expenses"
+ "chart_name": "Purchase Order Trends",
+ "label": "Purchase Order Trends"
}
],
+ "charts_label": "",
"creation": "2020-01-28 11:50:26.195467",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Buying",
- "modified": "2020-04-01 11:28:51.192097",
+ "modified": "2020-05-28 13:32:49.960574",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying",
+ "onboarding": "Buying",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
- "format": "{} Unpaid",
- "label": "Purchase Invoice",
- "link_to": "Purchase Invoice",
- "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"Unpaid\"\n}",
+ "color": "#cef6d1",
+ "format": "{} Available",
+ "label": "Item",
+ "link_to": "Item",
+ "stats_filter": "{\n \"disabled\": 0\n}",
"type": "DocType"
},
{
- "format": "{} to receive",
+ "color": "#ffe8cd",
+ "format": "{} Pending",
+ "label": "Material Request",
+ "link_to": "Material Request",
+ "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"Pending\"\n}",
+ "type": "DocType"
+ },
+ {
+ "color": "#ffe8cd",
+ "format": "{} To Receive",
"label": "Purchase Order",
"link_to": "Purchase Order",
- "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"To Receive\"\n}",
+ "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\":[\"in\", [\"To Receive\", \"To Receive and Bill\"]]\n}",
"type": "DocType"
},
{
- "label": "Supplier Quotation",
- "link_to": "Supplier Quotation",
- "type": "DocType"
- },
- {
- "label": "Accounts Payable",
- "link_to": "Accounts Payable",
+ "label": "Purchase Analytics",
+ "link_to": "Purchase Analytics",
"type": "Report"
},
{
- "label": "Purchase Register",
- "link_to": "Purchase Register",
+ "label": "Purchase Order Analysis",
+ "link_to": "Purchase Order Analysis",
"type": "Report"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "Buying",
+ "type": "Dashboard"
}
- ]
+ ],
+ "shortcuts_label": ""
}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.js b/erpnext/buying/doctype/buying_settings/buying_settings.js
index 403b1c95e74..01b40cd26fe 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.js
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.js
@@ -6,3 +6,26 @@ frappe.ui.form.on('Buying Settings', {
// }
});
+
+frappe.tour['Buying Settings'] = [
+ {
+ fieldname: "supp_master_name",
+ title: "Supplier Naming By",
+ description: __("By default, the Item Name is set as per the Item Code entered. If you want Items to be named by a set ") + "Naming Series " + __(" choose the 'Naming Series' option."),
+ },
+ {
+ fieldname: "buying_price_list",
+ title: "Default Buying Price List",
+ description: __("Configure the default Price List when creating a new Buying transaction, the default is set as 'Standard Buying'. Item prices will be fetched from this Price List.")
+ },
+ {
+ fieldname: "po_required",
+ title: "Purchase Order Required for Purchase Invoice & Receipt Creation",
+ description: __("If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice or Receipt without creating a Purchase Order first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Order' checkbox in supplier master.")
+ },
+ {
+ fieldname: "pr_required",
+ title: "Purchase Receipt Required for Purchase Invoice Creation",
+ description: __("If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice without creating a Purchase Receipt first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Receipt' checkbox in supplier master.")
+ }
+];
\ No newline at end of file
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json
index a492519591b..a0ab2a00f99 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.json
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.json
@@ -1,8 +1,10 @@
{
+ "actions": [],
"creation": "2013-06-25 11:04:03",
"description": "Settings for Buying Module",
"doctype": "DocType",
"document_type": "Other",
+ "engine": "InnoDB",
"field_order": [
"supp_master_name",
"supplier_group",
@@ -44,13 +46,13 @@
{
"fieldname": "po_required",
"fieldtype": "Select",
- "label": "Purchase Order Required",
+ "label": "Purchase Order Required for Purchase Invoice & Receipt Creation",
"options": "No\nYes"
},
{
"fieldname": "pr_required",
"fieldtype": "Select",
- "label": "Purchase Receipt Required",
+ "label": "Purchase Receipt Required for Purchase Invoice Creation",
"options": "No\nYes"
},
{
@@ -92,7 +94,8 @@
"icon": "fa fa-cog",
"idx": 1,
"issingle": 1,
- "modified": "2019-08-20 13:13:09.055189",
+ "links": [],
+ "modified": "2020-05-15 14:49:32.513611",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",
@@ -107,5 +110,7 @@
"share": 1,
"write": 1
}
- ]
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC"
}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index a4f60fbba5c..7145fea5c5c 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -38,6 +38,8 @@
"col_break_address",
"shipping_address",
"shipping_address_display",
+ "billing_address",
+ "billing_address_display",
"currency_and_price_list",
"currency",
"conversion_rate",
@@ -135,7 +137,9 @@
{
"fieldname": "supplier_section",
"fieldtype": "Section Break",
- "options": "fa fa-user"
+ "options": "fa fa-user",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -145,7 +149,9 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "naming_series",
@@ -157,7 +163,9 @@
"options": "PUR-ORD-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1
+ "set_only_once": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -170,14 +178,18 @@
"options": "Supplier",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 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"
+ "label": "Get Items from Open Material Requests",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -186,7 +198,9 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Supplier Name",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "company",
@@ -198,13 +212,17 @@
"options": "Company",
"print_hide": 1,
"remember_last_selected_value": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -216,27 +234,35 @@
"oldfieldname": "transaction_date",
"oldfieldtype": "Date",
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"fieldname": "schedule_date",
"fieldtype": "Date",
- "label": "Required By"
+ "label": "Required By",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval:doc.docstatus===1",
"fieldname": "order_confirmation_no",
"fieldtype": "Data",
- "label": "Order Confirmation No"
+ "label": "Order Confirmation No",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval:doc.order_confirmation_no",
"fieldname": "order_confirmation_date",
"fieldtype": "Date",
- "label": "Order Confirmation Date"
+ "label": "Order Confirmation Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "amended_from",
@@ -248,19 +274,25 @@
"oldfieldtype": "Data",
"options": "Purchase Order",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "drop_ship",
"fieldtype": "Section Break",
- "label": "Drop Ship"
+ "label": "Drop Ship",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer",
"fieldtype": "Link",
"label": "Customer",
"options": "Customer",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -268,31 +300,41 @@
"fieldtype": "Data",
"label": "Customer Name",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_19",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_person",
"fieldtype": "Link",
"label": "Customer Contact",
- "options": "Contact"
+ "options": "Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Customer Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_mobile",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Customer Mobile No",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_email",
@@ -300,46 +342,60 @@
"hidden": 1,
"label": "Customer Contact Email",
"options": "Email",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact"
+ "label": "Address and Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Select Supplier Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_person",
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "address_display",
"fieldtype": "Small Text",
"label": "Address",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_display",
"fieldtype": "Small Text",
"in_global_search": 1,
"label": "Contact",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_mobile",
"fieldtype": "Small Text",
"label": "Mobile No",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_email",
@@ -347,32 +403,42 @@
"label": "Contact Email",
"options": "Email",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Select Shipping Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag"
+ "options": "fa fa-tag",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "currency",
@@ -382,7 +448,9 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "conversion_rate",
@@ -392,18 +460,24 @@
"oldfieldtype": "Currency",
"precision": "9",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cb_price_list",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "price_list_currency",
@@ -411,14 +485,18 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -427,11 +505,15 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sec_warehouse",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "Sets 'Warehouse' in each row of the Items table.",
@@ -439,11 +521,15 @@
"fieldtype": "Link",
"label": "Set Target Warehouse",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -452,25 +538,33 @@
"in_standard_filter": 1,
"label": "Supply Raw Materials",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.is_subcontracted==\"Yes\"",
"fieldname": "supplier_warehouse",
"fieldtype": "Link",
"label": "Supplier Warehouse",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart"
+ "options": "fa fa-shopping-cart",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode"
+ "label": "Scan Barcode",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_bulk_edit": 1,
@@ -480,26 +574,34 @@
"oldfieldname": "po_details",
"oldfieldtype": "Table",
"options": "Purchase Order Item",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_break_48",
"fieldtype": "Section Break",
- "label": "Pricing Rules"
+ "label": "Pricing Rules",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Purchase Order Pricing Rule",
"options": "Pricing Rule Detail",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible_depends_on": "supplied_items",
"fieldname": "raw_material_details",
"fieldtype": "Section Break",
- "label": "Raw Materials Supplied"
+ "label": "Raw Materials Supplied",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplied_items",
@@ -509,17 +611,23 @@
"oldfieldtype": "Table",
"options": "Purchase Order Item Supplied",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sb_last_purchase",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total",
@@ -527,7 +635,9 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_net_total",
@@ -538,18 +648,24 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_26",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "net_total",
@@ -559,20 +675,26 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges",
@@ -581,22 +703,30 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_50",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
"options": "Shipping Rule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_52",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes",
@@ -604,13 +734,17 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup"
+ "label": "Tax Breakup",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_charges_calculation",
@@ -619,13 +753,17 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_added",
@@ -635,7 +773,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_deducted",
@@ -645,7 +785,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total_taxes_and_charges",
@@ -656,11 +798,15 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_39",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_added",
@@ -670,7 +816,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_deducted",
@@ -680,7 +828,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_taxes_and_charges",
@@ -688,14 +838,18 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "discount_amount",
"fieldname": "discount_section",
"fieldtype": "Section Break",
- "label": "Additional Discount"
+ "label": "Additional Discount",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Grand Total",
@@ -703,7 +857,9 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_discount_amount",
@@ -711,28 +867,38 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_45",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals_section",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_grand_total",
@@ -743,7 +909,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounding_adjustment",
@@ -752,7 +920,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "In Words will be visible once you save the Purchase Order.",
@@ -762,7 +932,9 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounded_total",
@@ -772,12 +944,16 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break4",
"fieldtype": "Column Break",
- "oldfieldtype": "Column Break"
+ "oldfieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "grand_total",
@@ -787,7 +963,9 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "rounding_adjustment",
@@ -796,20 +974,26 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "rounded_total",
"fieldtype": "Currency",
"label": "Rounded Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total"
+ "label": "Disable Rounded Total",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "in_words",
@@ -818,7 +1002,9 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "advance_paid",
@@ -827,19 +1013,25 @@
"no_copy": 1,
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "payment_schedule_section",
"fieldtype": "Section Break",
- "label": "Payment Terms"
+ "label": "Payment Terms",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"label": "Payment Terms Template",
- "options": "Payment Terms Template"
+ "options": "Payment Terms Template",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_schedule",
@@ -847,7 +1039,9 @@
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -856,7 +1050,9 @@
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break",
- "options": "fa fa-legal"
+ "options": "fa fa-legal",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tc_name",
@@ -865,21 +1061,27 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
"label": "Terms and Conditions",
"oldfieldname": "terms",
- "oldfieldtype": "Text Editor"
+ "oldfieldtype": "Text Editor",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Information",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Draft",
@@ -894,7 +1096,9 @@
"print_hide": 1,
"read_only": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "ref_sq",
@@ -905,7 +1109,9 @@
"oldfieldname": "ref_sq",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "party_account_currency",
@@ -915,18 +1121,24 @@
"no_copy": 1,
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "inter_company_order_reference",
"fieldtype": "Link",
"label": "Inter Company Order Reference",
"options": "Sales Order",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_74",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.__islocal",
@@ -936,7 +1148,9 @@
"label": "% Received",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.__islocal",
@@ -946,7 +1160,9 @@
"label": "% Billed",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -956,6 +1172,8 @@
"oldfieldtype": "Column Break",
"print_hide": 1,
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -966,7 +1184,9 @@
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -978,11 +1198,15 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1
+ "report_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_86",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -990,19 +1214,25 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "subscription_section",
"fieldtype": "Section Break",
- "label": "Subscription Section"
+ "label": "Subscription Section",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1010,7 +1240,9 @@
"fieldtype": "Date",
"label": "From Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1018,11 +1250,15 @@
"fieldtype": "Date",
"label": "To Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_97",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "auto_repeat",
@@ -1031,44 +1267,72 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval: doc.auto_repeat",
"fieldname": "update_auto_repeat_reference",
"fieldtype": "Button",
- "label": "Update Auto Repeat Reference"
+ "label": "Update Auto Repeat Reference",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
- "options": "Tax Category"
+ "options": "Tax Category",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "supplied_items",
"fieldname": "set_reserve_warehouse",
"fieldtype": "Link",
"label": "Set Reserve Warehouse",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "tracking_section",
"fieldtype": "Section Break",
- "label": "Tracking"
+ "label": "Tracking",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_75",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address",
+ "fieldtype": "Link",
+ "label": "Select Billing Address",
+ "options": "Address",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address_display",
+ "fieldtype": "Small Text",
+ "label": "Billing Address",
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
}
],
"icon": "fa fa-file-text",
"idx": 105,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-24 12:13:14.186280",
+ "modified": "2020-06-13 22:25:47.333850",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index 16061c61ba0..1b8b40459f6 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -18,6 +18,10 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
refresh: function() {
var me = this;
this._super();
+
+ if (this.frm.doc.__islocal && !this.frm.doc.valid_till) {
+ this.frm.set_value('valid_till', frappe.datetime.add_months(this.frm.doc.transaction_date, 1));
+ }
if (this.frm.doc.docstatus === 1) {
cur_frm.add_custom_button(__("Purchase Order"), this.make_purchase_order,
__('Create'));
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
index 82fc6285bcf..7db1516ce1b 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
@@ -13,9 +13,10 @@
"supplier",
"supplier_name",
"column_break1",
- "transaction_date",
- "amended_from",
"company",
+ "transaction_date",
+ "valid_till",
+ "amended_from",
"address_section",
"supplier_address",
"contact_person",
@@ -760,7 +761,7 @@
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
- "options": "\nDraft\nSubmitted\nStopped\nCancelled",
+ "options": "\nDraft\nSubmitted\nStopped\nCancelled\nExpired",
"print_hide": 1,
"read_only": 1,
"reqd": 1,
@@ -791,13 +792,18 @@
"options": "Opportunity",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fieldname": "valid_till",
+ "fieldtype": "Date",
+ "label": "Valid Till"
}
],
"icon": "fa fa-shopping-cart",
"idx": 29,
"is_submittable": 1,
"links": [],
- "modified": "2019-12-30 19:17:28.208693",
+ "modified": "2020-05-15 21:24:12.639482",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation",
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index 5b4356a7471..baf245735a4 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
-from frappe.utils import flt, nowdate, add_days
+from frappe.utils import flt, nowdate, add_days, getdate
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController
@@ -28,6 +28,7 @@ class SupplierQuotation(BuyingController):
validate_for_items(self)
self.validate_with_previous_doc()
self.validate_uom_is_integer("uom", "qty")
+ self.validate_valid_till()
def on_submit(self):
frappe.db.set(self, "status", "Submitted")
@@ -52,6 +53,11 @@ class SupplierQuotation(BuyingController):
"is_child_table": True
}
})
+
+ def validate_valid_till(self):
+ if self.valid_till and getdate(self.valid_till) < getdate(self.transaction_date):
+ frappe.throw(_("Valid till Date cannot be before Transaction Date"))
+
def update_rfq_supplier_status(self, include_me):
rfq_list = set([])
for item in self.items:
@@ -158,3 +164,11 @@ def make_quotation(source_name, target_doc=None):
}, target_doc)
return doclist
+
+def set_expired_status():
+ frappe.db.sql("""
+ UPDATE
+ `tabSupplier Quotation` SET `status` = 'Expired'
+ WHERE
+ `status` not in ('Cancelled', 'Stopped') AND `valid_till` < %s
+ """, (nowdate()))
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js
index 95554397bb7..9f4fecea86b 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js
@@ -5,6 +5,8 @@ frappe.listview_settings['Supplier Quotation'] = {
return [__("Ordered"), "green", "status,=,Ordered"];
} else if(doc.status==="Rejected") {
return [__("Lost"), "darkgrey", "status,=,Lost"];
+ } else if(doc.status==="Expired") {
+ return [__("Expired"), "darkgrey", "status,=,Expired"];
}
}
};
diff --git a/erpnext/buying/module_onboarding/buying/buying.json b/erpnext/buying/module_onboarding/buying/buying.json
new file mode 100644
index 00000000000..8fe2f388b0c
--- /dev/null
+++ b/erpnext/buying/module_onboarding/buying/buying.json
@@ -0,0 +1,54 @@
+{
+ "allow_roles": [
+ {
+ "role": "Purchase Manager"
+ },
+ {
+ "role": "Purchase User"
+ },
+ {
+ "role": "Stock Manager"
+ },
+ {
+ "role": "Stock User"
+ }
+ ],
+ "creation": "2020-05-06 15:56:35.049205",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/buying",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-27 17:17:52.075947",
+ "modified_by": "Administrator",
+ "module": "Buying",
+ "name": "Buying",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Introduction to Buying"
+ },
+ {
+ "step": "Create a Supplier"
+ },
+ {
+ "step": "Setup your Warehouse"
+ },
+ {
+ "step": "Create a Product"
+ },
+ {
+ "step": "Create a Material Request"
+ },
+ {
+ "step": "Create your first Purchase Order"
+ },
+ {
+ "step": "Buying Settings"
+ }
+ ],
+ "subtitle": "Products, Purchases, Analysis and more.",
+ "success_message": "The Buying Module is all set up!",
+ "title": "Let's Set Up the Buying Module.",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/buying_settings/buying_settings.json b/erpnext/buying/onboarding_step/buying_settings/buying_settings.json
new file mode 100644
index 00000000000..a788ccd4cc9
--- /dev/null
+++ b/erpnext/buying/onboarding_step/buying_settings/buying_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Update Settings",
+ "creation": "2020-05-06 15:53:44.667414",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:30:06.323797",
+ "modified_by": "Administrator",
+ "name": "Buying Settings",
+ "owner": "Administrator",
+ "reference_document": "Buying Settings",
+ "show_full_form": 0,
+ "title": "Configure Buying Settings.",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/create_a_material_request/create_a_material_request.json b/erpnext/buying/onboarding_step/create_a_material_request/create_a_material_request.json
new file mode 100644
index 00000000000..9dc493dd499
--- /dev/null
+++ b/erpnext/buying/onboarding_step/create_a_material_request/create_a_material_request.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-15 14:39:09.818764",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-15 14:39:09.818764",
+ "modified_by": "Administrator",
+ "name": "Create a Material Request",
+ "owner": "Administrator",
+ "reference_document": "Material Request",
+ "show_full_form": 1,
+ "title": "Create a Material Request",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/create_a_product/create_a_product.json b/erpnext/buying/onboarding_step/create_a_product/create_a_product.json
new file mode 100644
index 00000000000..d2068e167b7
--- /dev/null
+++ b/erpnext/buying/onboarding_step/create_a_product/create_a_product.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 18:16:06.624554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:30:02.489949",
+ "modified_by": "Administrator",
+ "name": "Create a Product",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "show_full_form": 0,
+ "title": "Create a Product",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/create_a_supplier/create_a_supplier.json b/erpnext/buying/onboarding_step/create_a_supplier/create_a_supplier.json
new file mode 100644
index 00000000000..7a64224bd43
--- /dev/null
+++ b/erpnext/buying/onboarding_step/create_a_supplier/create_a_supplier.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 22:09:10.043554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 22:09:10.043554",
+ "modified_by": "Administrator",
+ "name": "Create a Supplier",
+ "owner": "Administrator",
+ "reference_document": "Supplier",
+ "show_full_form": 0,
+ "title": "Create a Supplier",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/create_your_first_purchase_order/create_your_first_purchase_order.json b/erpnext/buying/onboarding_step/create_your_first_purchase_order/create_your_first_purchase_order.json
new file mode 100644
index 00000000000..9dbed239789
--- /dev/null
+++ b/erpnext/buying/onboarding_step/create_your_first_purchase_order/create_your_first_purchase_order.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 18:17:49.976035",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:31:56.856112",
+ "modified_by": "Administrator",
+ "name": "Create your first Purchase Order",
+ "owner": "Administrator",
+ "reference_document": "Purchase Order",
+ "show_full_form": 0,
+ "title": "Create your first Purchase Order",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/introduction_to_buying/introduction_to_buying.json b/erpnext/buying/onboarding_step/introduction_to_buying/introduction_to_buying.json
new file mode 100644
index 00000000000..fd98fddafae
--- /dev/null
+++ b/erpnext/buying/onboarding_step/introduction_to_buying/introduction_to_buying.json
@@ -0,0 +1,19 @@
+{
+ "action": "Watch Video",
+ "creation": "2020-05-06 15:37:09.477765",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:25:08.509900",
+ "modified_by": "Administrator",
+ "name": "Introduction to Buying",
+ "owner": "Administrator",
+ "show_full_form": 0,
+ "title": "Introduction to Buying",
+ "validate_action": 1,
+ "video_url": "https://youtu.be/efFajTTQBa8"
+}
\ No newline at end of file
diff --git a/erpnext/buying/onboarding_step/setup_your_warehouse/setup_your_warehouse.json b/erpnext/buying/onboarding_step/setup_your_warehouse/setup_your_warehouse.json
new file mode 100644
index 00000000000..557c905bd6c
--- /dev/null
+++ b/erpnext/buying/onboarding_step/setup_your_warehouse/setup_your_warehouse.json
@@ -0,0 +1,20 @@
+{
+ "action": "Go to Page",
+ "creation": "2020-05-19 18:54:19.383397",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 18:54:19.383397",
+ "modified_by": "Administrator",
+ "name": "Setup your Warehouse",
+ "owner": "Administrator",
+ "path": "Tree/Warehouse",
+ "reference_document": "Warehouse",
+ "show_full_form": 0,
+ "title": "Setup your Warehouse",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
index 39668795cba..88a865f0f85 100644
--- a/erpnext/buying/report/procurement_tracker/procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
@@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
+from frappe.utils import flt
def execute(filters=None):
columns = get_columns(filters)
@@ -54,15 +55,16 @@ def get_columns(filters):
"width": 140
},
{
- "label": _("Description"),
- "fieldname": "description",
- "fieldtype": "Data",
- "width": 200
+ "label": _("Item"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 150
},
{
"label": _("Quantity"),
"fieldname": "quantity",
- "fieldtype": "Int",
+ "fieldtype": "Float",
"width": 140
},
{
@@ -118,7 +120,7 @@ def get_columns(filters):
},
{
"label": _("Purchase Order Amount(Company Currency)"),
- "fieldname": "purchase_order_amt_usd",
+ "fieldname": "purchase_order_amt_in_company_currency",
"fieldtype": "Float",
"width": 140
},
@@ -175,17 +177,17 @@ def get_data(filters):
"requesting_site": po.warehouse,
"requestor": po.owner,
"material_request_no": po.material_request,
- "description": po.description,
- "quantity": po.qty,
+ "item_code": po.item_code,
+ "quantity": flt(po.qty),
"unit_of_measurement": po.stock_uom,
"status": po.status,
"purchase_order_date": po.transaction_date,
"purchase_order": po.parent,
"supplier": po.supplier,
- "estimated_cost": mr_record.get('amount'),
- "actual_cost": pi_records.get(po.name),
- "purchase_order_amt": po.amount,
- "purchase_order_amt_in_company_currency": po.base_amount,
+ "estimated_cost": flt(mr_record.get('amount')),
+ "actual_cost": flt(pi_records.get(po.name)),
+ "purchase_order_amt": flt(po.amount),
+ "purchase_order_amt_in_company_currency": flt(po.base_amount),
"expected_delivery_date": po.schedule_date,
"actual_delivery_date": pr_records.get(po.name)
}
@@ -198,9 +200,14 @@ def get_mapped_mr_details(conditions):
SELECT
par.transaction_date,
par.per_ordered,
+ par.owner,
child.name,
child.parent,
- child.amount
+ child.amount,
+ child.qty,
+ child.item_code,
+ child.uom,
+ par.status
FROM `tabMaterial Request` par, `tabMaterial Request Item` child
WHERE
par.per_ordered>=0
@@ -217,7 +224,15 @@ def get_mapped_mr_details(conditions):
procurement_record_details = dict(
material_request_date=record.transaction_date,
material_request_no=record.parent,
- estimated_cost=record.amount
+ requestor=record.owner,
+ item_code=record.item_code,
+ estimated_cost=flt(record.amount),
+ quantity=flt(record.qty),
+ unit_of_measurement=record.uom,
+ status=record.status,
+ actual_cost=0,
+ purchase_order_amt=0,
+ purchase_order_amt_in_company_currency=0
)
procurement_record_against_mr.append(procurement_record_details)
return mr_records, procurement_record_against_mr
@@ -259,7 +274,7 @@ def get_po_entries(conditions):
child.warehouse,
child.material_request,
child.material_request_item,
- child.description,
+ child.item_code,
child.stock_uom,
child.qty,
child.amount,
diff --git a/erpnext/hr/report/department_analytics/__init__.py b/erpnext/buying/report/purchase_order_analysis/__init__.py
similarity index 100%
rename from erpnext/hr/report/department_analytics/__init__.py
rename to erpnext/buying/report/purchase_order_analysis/__init__.py
diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js
new file mode 100644
index 00000000000..701da4380aa
--- /dev/null
+++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.js
@@ -0,0 +1,78 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Purchase Order Analysis"] = {
+ "filters": [
+ {
+ "fieldname": "company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Company",
+ "reqd": 1,
+ "default": frappe.defaults.get_default("company")
+ },
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "width": "80",
+ "reqd": 1,
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "width": "80",
+ "reqd": 1,
+ "default": frappe.datetime.get_today()
+ },
+ {
+ "fieldname": "purchase_order",
+ "label": __("Purchase Order"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Purchase Order",
+ "get_query": () =>{
+ return {
+ filters: { "docstatus": 1 }
+ }
+ }
+ },
+ {
+ "fieldname": "status",
+ "label": __("Status"),
+ "fieldtype": "MultiSelectList",
+ "width": "80",
+ get_data: function(txt) {
+ let status = ["To Bill", "To Receive", "To Receive and Bill", "Completed"]
+ let options = []
+ for (let option of status){
+ options.push({
+ "value": option,
+ "description": ""
+ })
+ }
+ return options
+ }
+ },
+ {
+ "fieldname": "group_by_po",
+ "label": __("Group by Purchase Order"),
+ "fieldtype": "Check",
+ "default": 0
+ }
+ ],
+
+ "formatter": function (value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+ let format_fields = ["received_qty", "billed_amount"];
+
+ if (in_list(format_fields, column.fieldname) && data && data[column.fieldname] > 0) {
+ value = "" + value + " ";
+ }
+ return value;
+ }
+};
diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.json b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.json
new file mode 100644
index 00000000000..5ba3101ec51
--- /dev/null
+++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.json
@@ -0,0 +1,33 @@
+{
+ "add_total_row": 1,
+ "creation": "2020-05-04 18:41:28.625119",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-05-15 20:57:52.623455",
+ "modified_by": "Administrator",
+ "module": "Buying",
+ "name": "Purchase Order Analysis",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Purchase Order",
+ "report_name": "Purchase Order Analysis",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Purchase Manager"
+ },
+ {
+ "role": "Purchase User"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Supplier"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py
new file mode 100644
index 00000000000..89be62231b9
--- /dev/null
+++ b/erpnext/buying/report/purchase_order_analysis/purchase_order_analysis.py
@@ -0,0 +1,271 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+import copy
+from frappe import _
+from frappe.utils import flt, date_diff, getdate
+
+def execute(filters=None):
+ if not filters:
+ return [], []
+
+ validate_filters(filters)
+
+ columns = get_columns(filters)
+ conditions = get_conditions(filters)
+
+ data = get_data(conditions, filters)
+
+ if not data:
+ return [], [], None, []
+
+ data, chart_data = prepare_data(data, filters)
+
+ return columns, data, None, chart_data
+
+def validate_filters(filters):
+ from_date, to_date = filters.get("from_date"), filters.get("to_date")
+
+ if not from_date and to_date:
+ frappe.throw(_("From and To Dates are required."))
+ elif date_diff(to_date, from_date) < 0:
+ frappe.throw(_("To Date cannot be before From Date."))
+
+def get_conditions(filters):
+ conditions = ""
+ if filters.get("from_date") and filters.get("to_date"):
+ conditions += " and po.transaction_date between %(from_date)s and %(to_date)s"
+
+ if filters.get("company"):
+ conditions += " and po.company = %(company)s"
+
+ if filters.get("purchase_order"):
+ conditions += " and po.name = %(purchase_order)s"
+
+ if filters.get("status"):
+ conditions += " and po.status in %(status)s"
+
+ return conditions
+
+def get_data(conditions, filters):
+ data = frappe.db.sql("""
+ SELECT
+ po.transaction_date as date,
+ poi.schedule_date as required_date,
+ po.name as purchase_order,
+ po.status, po.supplier, poi.item_code,
+ poi.qty, poi.received_qty,
+ (poi.qty - poi.received_qty) AS pending_qty,
+ IFNULL(pii.qty, 0) as billed_qty,
+ poi.base_amount as amount,
+ (poi.received_qty * poi.base_rate) as received_qty_amount,
+ (poi.billed_amt * IFNULL(po.conversion_rate, 1)) as billed_amount,
+ (poi.base_amount - (poi.billed_amt * IFNULL(po.conversion_rate, 1))) as pending_amount,
+ po.set_warehouse as warehouse,
+ po.company, poi.name
+ FROM
+ `tabPurchase Order` po,
+ `tabPurchase Order Item` poi
+ LEFT JOIN `tabPurchase Invoice Item` pii
+ ON pii.po_detail = poi.name
+ WHERE
+ poi.parent = po.name
+ and po.status not in ('Stopped', 'Closed')
+ and po.docstatus = 1
+ {0}
+ GROUP BY poi.name
+ ORDER BY po.transaction_date ASC
+ """.format(conditions), filters, as_dict=1)
+
+ return data
+
+def prepare_data(data, filters):
+ completed, pending = 0, 0
+ pending_field = "pending_amount"
+ completed_field = "billed_amount"
+
+ if filters.get("group_by_po"):
+ purchase_order_map = {}
+
+ for row in data:
+ # sum data for chart
+ completed += row[completed_field]
+ pending += row[pending_field]
+
+ # prepare data for report view
+ row["qty_to_bill"] = flt(row["qty"]) - flt(row["billed_qty"])
+
+ if filters.get("group_by_po"):
+ po_name = row["purchase_order"]
+
+ if not po_name in purchase_order_map:
+ # create an entry
+ row_copy = copy.deepcopy(row)
+ purchase_order_map[po_name] = row_copy
+ else:
+ # update existing entry
+ po_row = purchase_order_map[po_name]
+ po_row["required_date"] = min(getdate(po_row["required_date"]), getdate(row["required_date"]))
+
+ # sum numeric columns
+ fields = ["qty", "received_qty", "pending_qty", "billed_qty", "qty_to_bill", "amount",
+ "received_qty_amount", "billed_amount", "pending_amount"]
+ for field in fields:
+ po_row[field] = flt(row[field]) + flt(po_row[field])
+
+ chart_data = prepare_chart_data(pending, completed)
+
+ if filters.get("group_by_po"):
+ data = []
+ for po in purchase_order_map:
+ data.append(purchase_order_map[po])
+ return data, chart_data
+
+ return data, chart_data
+
+def prepare_chart_data(pending, completed):
+ labels = ["Amount to Bill", "Billed Amount"]
+
+ return {
+ "data" : {
+ "labels": labels,
+ "datasets": [
+ {"values": [pending, completed]}
+ ]
+ },
+ "type": 'donut',
+ "height": 300
+ }
+
+def get_columns(filters):
+ columns = [
+ {
+ "label":_("Date"),
+ "fieldname": "date",
+ "fieldtype": "Date",
+ "width": 90
+ },
+ {
+ "label":_("Required By"),
+ "fieldname": "required_date",
+ "fieldtype": "Date",
+ "width": 90
+ },
+ {
+ "label": _("Purchase Order"),
+ "fieldname": "purchase_order",
+ "fieldtype": "Link",
+ "options": "Purchase Order",
+ "width": 160
+ },
+ {
+ "label":_("Status"),
+ "fieldname": "status",
+ "fieldtype": "Data",
+ "width": 130
+ },
+ {
+ "label": _("Supplier"),
+ "fieldname": "supplier",
+ "fieldtype": "Link",
+ "options": "Supplier",
+ "width": 130
+ }]
+
+ if not filters.get("group_by_po"):
+ columns.append({
+ "label":_("Item Code"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 100
+ })
+
+ columns.extend([
+ {
+ "label": _("Qty"),
+ "fieldname": "qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Received Qty"),
+ "fieldname": "received_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Pending Qty"),
+ "fieldname": "pending_qty",
+ "fieldtype": "Float",
+ "width": 80,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Billed Qty"),
+ "fieldname": "billed_qty",
+ "fieldtype": "Float",
+ "width": 80,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Qty to Bill"),
+ "fieldname": "qty_to_bill",
+ "fieldtype": "Float",
+ "width": 80,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Amount"),
+ "fieldname": "amount",
+ "fieldtype": "Currency",
+ "width": 110,
+ "options": "Company:company:default_currency",
+ "convertible": "rate"
+ },
+ {
+ "label": _("Billed Amount"),
+ "fieldname": "billed_amount",
+ "fieldtype": "Currency",
+ "width": 110,
+ "options": "Company:company:default_currency",
+ "convertible": "rate"
+ },
+ {
+ "label": _("Pending Amount"),
+ "fieldname": "pending_amount",
+ "fieldtype": "Currency",
+ "width": 130,
+ "options": "Company:company:default_currency",
+ "convertible": "rate"
+ },
+ {
+ "label": _("Received Qty Amount"),
+ "fieldname": "received_qty_amount",
+ "fieldtype": "Currency",
+ "width": 130,
+ "options": "Company:company:default_currency",
+ "convertible": "rate"
+ },
+ {
+ "label": _("Warehouse"),
+ "fieldname": "warehouse",
+ "fieldtype": "Link",
+ "options": "Warehouse",
+ "width": 100
+ },
+ {
+ "label": _("Company"),
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "width": 100
+ }
+ ])
+
+ return columns
+
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 888676cf64f..1ed6cad6b46 100644
--- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py
+++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+from frappe import _
from erpnext.controllers.trends import get_columns,get_data
def execute(filters=None):
@@ -10,5 +11,48 @@ def execute(filters=None):
data = []
conditions = get_columns(filters, "Purchase Order")
data = get_data(filters, conditions)
+ chart_data = get_chart_data(data, conditions, filters)
- return conditions["columns"], data
\ No newline at end of file
+ return conditions["columns"], data, None, chart_data
+
+def get_chart_data(data, conditions, filters):
+ if not (data and conditions):
+ return []
+
+ datapoints = []
+
+ start = 2 if filters.get("based_on") in ["Item", "Supplier"] else 1
+ if filters.get("group_by"):
+ start += 1
+
+ # fetch only periodic columns as labels
+ columns = conditions.get("columns")[start:-2][1::2]
+ labels = [column.split(':')[0] for column in columns]
+ datapoints = [0] * len(labels)
+
+ for row in data:
+ # If group by filter, don't add first row of group (it's already summed)
+ if not row[start-1]:
+ continue
+ # Remove None values and compute only periodic data
+ row = [x if x else 0 for x in row[start:-2]]
+ row = row[1::2]
+
+ for i in range(len(row)):
+ datapoints[i] += row[i]
+
+ return {
+ "data" : {
+ "labels" : labels,
+ "datasets" : [
+ {
+ "name" : _("{0}").format(filters.get("period")) + _(" Purchase Value"),
+ "values" : datapoints
+ }
+ ]
+ },
+ "type" : "line",
+ "lineOptions": {
+ "regionFill": 1
+ }
+ }
\ No newline at end of file
diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
index 3d05612c9ed..a76ffeec2ec 100644
--- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
+++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
@@ -5,20 +5,18 @@ frappe.query_reports["Quoted Item Comparison"] = {
filters: [
{
fieldtype: "Link",
- label: __("Supplier Quotation"),
- options: "Supplier Quotation",
- fieldname: "supplier_quotation",
- default: "",
- get_query: () => {
- return { filters: { "docstatus": ["<", 2] } }
- }
+ label: __("Company"),
+ options: "Company",
+ fieldname: "company",
+ default: frappe.defaults.get_user_default("Company"),
+ "reqd": 1
},
{
reqd: 1,
default: "",
options: "Item",
label: __("Item"),
- fieldname: "item",
+ fieldname: "item_code",
fieldtype: "Link",
get_query: () => {
let quote = frappe.query_report.get_filter_value('supplier_quotation');
@@ -37,8 +35,37 @@ frappe.query_reports["Quoted Item Comparison"] = {
}
}
}
+ },
+ {
+ fieldname: "supplier",
+ label: __("Supplier"),
+ fieldtype: "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Supplier', txt);
+ }
+ },
+ {
+ fieldtype: "Link",
+ label: __("Supplier Quotation"),
+ options: "Supplier Quotation",
+ fieldname: "supplier_quotation",
+ default: "",
+ get_query: () => {
+ return { filters: { "docstatus": ["<", 2] } }
+ }
+ },
+ {
+ fieldtype: "Link",
+ label: __("Request for Quotation"),
+ options: "Request for Quotation",
+ fieldname: "request_for_quotation",
+ default: "",
+ get_query: () => {
+ return { filters: { "docstatus": ["<", 2] } }
+ }
}
],
+
onload: (report) => {
// Create a button for setting the default supplier
report.page.add_inner_button(__("Select Default Supplier"), () => {
@@ -102,6 +129,4 @@ frappe.query_reports["Quoted Item Comparison"] = {
});
dialog.show();
}
-}
-
-
+}
\ No newline at end of file
diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
index 5aff6bacaea..a33867a525e 100644
--- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
+++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
@@ -2,103 +2,180 @@
# For license information, please see license.txt
from __future__ import unicode_literals
-from erpnext.setup.utils import get_exchange_rate
-from frappe.utils import flt, cint
import frappe
+from frappe.utils import flt, cint
+from frappe import _
+from collections import defaultdict
+from erpnext.setup.utils import get_exchange_rate
def execute(filters=None):
- qty_list = get_quantity_list(filters.item)
- data = get_quote_list(filters.item, qty_list)
- columns = get_columns(qty_list)
- return columns, data
-
-def get_quote_list(item, qty_list):
- out = []
- if not item:
+ if not filters:
+ return [], []
+
+ conditions = get_conditions(filters)
+ supplier_quotation_data = get_data(filters, conditions)
+ columns = get_columns()
+
+ data, chart_data = prepare_data(supplier_quotation_data)
+
+ return columns, data, None, chart_data
+
+def get_conditions(filters):
+ conditions = ""
+ if filters.get("supplier_quotation"):
+ conditions += " AND sqi.parent = %(supplier_quotation)s"
+
+ if filters.get("request_for_quotation"):
+ conditions += " AND sqi.request_for_quotation = %(request_for_quotation)s"
+
+ if filters.get("supplier"):
+ conditions += " AND sq.supplier in %(supplier)s"
+ return conditions
+
+def get_data(filters, conditions):
+ if not filters.get("item_code"):
return []
- suppliers = []
- price_data = []
- company_currency = frappe.db.get_default("currency")
- float_precision = cint(frappe.db.get_default("float_precision")) or 2
- # Get the list of suppliers
- for root in frappe.db.sql("""select parent, qty, rate from `tabSupplier Quotation Item`
- where item_code=%s and docstatus < 2""", item, as_dict=1):
- for splr in frappe.db.sql("""select supplier from `tabSupplier Quotation`
- where name =%s and docstatus < 2""", root.parent, as_dict=1):
- ip = frappe._dict({
- "supplier": splr.supplier,
- "qty": root.qty,
- "parent": root.parent,
- "rate": root.rate
- })
- price_data.append(ip)
- suppliers.append(splr.supplier)
+ supplier_quotation_data = frappe.db.sql("""SELECT
+ sqi.parent, sqi.qty, sqi.rate, sqi.uom, sqi.request_for_quotation,
+ sq.supplier
+ FROM
+ `tabSupplier Quotation Item` sqi,
+ `tabSupplier Quotation` sq
+ WHERE
+ sqi.item_code = %(item_code)s
+ AND sqi.parent = sq.name
+ AND sqi.docstatus < 2
+ AND sq.company = %(company)s
+ AND sq.status != 'Expired'
+ {0}""".format(conditions), filters, as_dict=1)
+
+ return supplier_quotation_data
+
+def prepare_data(supplier_quotation_data):
+ out, suppliers, qty_list = [], [], []
+ supplier_wise_map = defaultdict(list)
+ supplier_qty_price_map = {}
+
+ company_currency = frappe.db.get_default("currency")
+ float_precision = cint(frappe.db.get_default("float_precision")) or 2
+
+ for data in supplier_quotation_data:
+ supplier = data.get("supplier")
+ supplier_currency = frappe.db.get_value("Supplier", data.get("supplier"), "default_currency")
- #Add a row for each supplier
- for root in set(suppliers):
- supplier_currency = frappe.db.get_value("Supplier", root, "default_currency")
if supplier_currency:
exchange_rate = get_exchange_rate(supplier_currency, company_currency)
else:
exchange_rate = 1
- row = frappe._dict({
- "supplier_name": root
- })
- for col in qty_list:
- # Get the quantity for this row
- for item_price in price_data:
- if str(item_price.qty) == col.key and item_price.supplier == root:
- row[col.key] = flt(item_price.rate * exchange_rate, float_precision)
- row[col.key + "QUOTE"] = item_price.parent
- break
- else:
- row[col.key] = ""
- row[col.key + "QUOTE"] = ""
- out.append(row)
-
- return out
-
-def get_quantity_list(item):
- out = []
-
- if item:
- qty_list = frappe.db.sql("""select distinct qty from `tabSupplier Quotation Item`
- where ifnull(item_code,'')=%s and docstatus < 2 order by qty""", item, as_dict=1)
+ row = {
+ "quotation": data.get("parent"),
+ "qty": data.get("qty"),
+ "price": flt(data.get("rate") * exchange_rate, float_precision),
+ "uom": data.get("uom"),
+ "request_for_quotation": data.get("request_for_quotation"),
+ }
- for qt in qty_list:
- col = frappe._dict({
- "key": str(qt.qty),
- "label": "Qty: " + str(int(qt.qty))
- })
- out.append(col)
+ # map for report view of form {'supplier1':[{},{},...]}
+ supplier_wise_map[supplier].append(row)
- return out
-
-def get_columns(qty_list):
+ # map for chart preparation of the form {'supplier1': {'qty': 'price'}}
+ if not supplier in supplier_qty_price_map:
+ supplier_qty_price_map[supplier] = {}
+ supplier_qty_price_map[supplier][row["qty"]] = row["price"]
+
+ suppliers.append(supplier)
+ qty_list.append(data.get("qty"))
+
+ suppliers = list(set(suppliers))
+ qty_list = list(set(qty_list))
+
+ # final data format for report view
+ for supplier in suppliers:
+ supplier_wise_map[supplier][0].update({"supplier_name": supplier})
+ for entry in supplier_wise_map[supplier]:
+ out.append(entry)
+
+ chart_data = prepare_chart_data(suppliers, qty_list, supplier_qty_price_map)
+
+ return out, chart_data
+
+def prepare_chart_data(suppliers, qty_list, supplier_qty_price_map):
+ data_points_map = {}
+ qty_list.sort()
+
+ # create qty wise values map of the form {'qty1':[value1, value2]}
+ for supplier in suppliers:
+ entry = supplier_qty_price_map[supplier]
+ for qty in qty_list:
+ if not qty in data_points_map:
+ data_points_map[qty] = []
+ if qty in entry:
+ data_points_map[qty].append(entry[qty])
+ else:
+ data_points_map[qty].append(None)
+
+ dataset = []
+ for qty in qty_list:
+ datapoints = {
+ "name": _("Price for Qty ") + str(qty),
+ "values": data_points_map[qty]
+ }
+ dataset.append(datapoints)
+
+ chart_data = {
+ "data": {
+ "labels": suppliers,
+ "datasets": dataset
+ },
+ "type": "bar"
+ }
+
+ return chart_data
+
+def get_columns():
columns = [{
"fieldname": "supplier_name",
- "label": "Supplier",
+ "label": _("Supplier"),
"fieldtype": "Link",
"options": "Supplier",
"width": 200
- }]
-
- for qty in qty_list:
- columns.append({
- "fieldname": qty.key,
- "label": qty.label,
- "fieldtype": "Currency",
- "options": "currency",
- "width": 80
- })
- columns.append({
- "fieldname": qty.key + "QUOTE",
- "label": "Quotation",
- "fieldtype": "Link",
- "options": "Supplier Quotation",
- "width": 90
- })
+ },
+ {
+ "fieldname": "quotation",
+ "label": _("Supplier Quotation"),
+ "fieldtype": "Link",
+ "options": "Supplier Quotation",
+ "width": 200
+ },
+ {
+ "fieldname": "qty",
+ "label": _("Quantity"),
+ "fieldtype": "Float",
+ "width": 80
+ },
+ {
+ "fieldname": "price",
+ "label": _("Price"),
+ "fieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "width": 110
+ },
+ {
+ "fieldname": "uom",
+ "label": _("UOM"),
+ "fieldtype": "Link",
+ "options": "UOM",
+ "width": 90
+ },
+ {
+ "fieldname": "request_for_quotation",
+ "label": _("Request for Quotation"),
+ "fieldtype": "Link",
+ "options": "Request for Quotation",
+ "width": 200
+ }
+ ]
return columns
\ No newline at end of file
diff --git a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json
deleted file mode 100644
index bb112698d32..00000000000
--- a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "add_total_row": 1,
- "creation": "2013-05-13 16:10:02",
- "disable_prepared_report": 0,
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 3,
- "is_standard": "Yes",
- "modified": "2019-04-18 19:02:03.099422",
- "modified_by": "Administrator",
- "module": "Buying",
- "name": "Requested Items To Be Ordered",
- "owner": "Administrator",
- "prepared_report": 0,
- "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.stock_qty, 0)) as \"Qty:Float:100\",\n\tifnull(mr_item.stock_uom, '') as \"UOM:Link/UOM:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.stock_qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\",\n\tmr.company as \"Company:Link/Company:\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.stock_qty, 0))\norder by mr.transaction_date asc",
- "ref_doctype": "Purchase Order",
- "report_name": "Requested Items To Be Ordered",
- "report_type": "Query Report",
- "roles": [
- {
- "role": "Stock User"
- },
- {
- "role": "Purchase Manager"
- },
- {
- "role": "Purchase User"
- }
- ]
- }
\ No newline at end of file
diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/__init__.py b/erpnext/buying/report/requested_items_to_order/__init__.py
similarity index 100%
rename from erpnext/stock/report/purchase_order_items_to_be_received/__init__.py
rename to erpnext/buying/report/requested_items_to_order/__init__.py
diff --git a/erpnext/buying/report/requested_items_to_order/requested_items_to_order.js b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.js
new file mode 100644
index 00000000000..9555e8252a3
--- /dev/null
+++ b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.js
@@ -0,0 +1,76 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Requested Items to Order"] = {
+ "filters": [
+ {
+ "fieldname": "company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Company",
+ "reqd": 1,
+ "default": frappe.defaults.get_default("company")
+ },
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "width": "80",
+ "reqd": 1,
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "width": "80",
+ "reqd": 1,
+ "default": frappe.datetime.get_today()
+ },
+ {
+ "fieldname": "material_request",
+ "label": __("Material Request"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Material Request",
+ "get_query": () => {
+ return {
+ filters: {
+ "docstatus": 1,
+ "material_request_type": "Purchase",
+ "per_received": ["<", 100]
+ }
+ }
+ }
+ },
+ {
+ "fieldname": "item_code",
+ "label": __("Item"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Item",
+ "get_query": () => {
+ return {
+ query: "erpnext.controllers.queries.item_query"
+ }
+ }
+ },
+ {
+ "fieldname": "group_by_mr",
+ "label": __("Group by Material Request"),
+ "fieldtype": "Check",
+ "default": 0
+ }
+ ],
+
+ "formatter": function (value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+
+ if (column.fieldname == "ordered_qty" && data && data.ordered_qty > 0) {
+ value = "" + value + " ";
+ }
+ return value;
+ }
+};
diff --git a/erpnext/buying/report/requested_items_to_order/requested_items_to_order.json b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.json
new file mode 100644
index 00000000000..4a0578be4bf
--- /dev/null
+++ b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.json
@@ -0,0 +1,34 @@
+{
+ "add_total_row": 1,
+ "creation": "2020-05-04 20:23:57.750719",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-05-05 13:05:51.723951",
+ "modified_by": "Administrator",
+ "module": "Buying",
+ "name": "Requested Items to Order",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "query": "",
+ "ref_doctype": "Material Request",
+ "report_name": "Requested Items to Order",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Purchase Manager"
+ },
+ {
+ "role": "Stock Manager"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Purchase User"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/buying/report/requested_items_to_order/requested_items_to_order.py b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.py
new file mode 100644
index 00000000000..cca01b104ae
--- /dev/null
+++ b/erpnext/buying/report/requested_items_to_order/requested_items_to_order.py
@@ -0,0 +1,233 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+import copy
+from frappe import _
+from frappe.utils import flt, date_diff, getdate
+
+def execute(filters=None):
+ if not filters:
+ return [],[]
+
+ validate_filters(filters)
+
+ columns = get_columns(filters)
+ conditions = get_conditions(filters)
+
+ #get queried data
+ data = get_data(filters, conditions)
+
+ #prepare data for report and chart views
+ data, chart_data = prepare_data(data, filters)
+
+ return columns, data, None, chart_data
+
+def validate_filters(filters):
+ from_date, to_date = filters.get("from_date"), filters.get("to_date")
+
+ if not from_date and to_date:
+ frappe.throw(_("From and To Dates are required."))
+ elif date_diff(to_date, from_date) < 0:
+ frappe.throw(_("To Date cannot be before From Date."))
+
+def get_conditions(filters):
+ conditions = ''
+
+ if filters.get("from_date") and filters.get("to_date"):
+ conditions += " and mr.transaction_date between '{0}' and '{1}'".format(filters.get("from_date"),filters.get("to_date"))
+
+ if filters.get("company"):
+ conditions += " and mr.company = '{0}'".format(filters.get("company"))
+
+ if filters.get("material_request"):
+ conditions += " and mr.name = '{0}'".format(filters.get("material_request"))
+
+ if filters.get("item_code"):
+ conditions += " and mr_item.item_code = '{0}'".format(filters.get("item_code"))
+
+ return conditions
+
+def get_data(filters, conditions):
+ data = frappe.db.sql("""
+ select
+ mr.name as material_request,
+ mr.transaction_date as date,
+ mr_item.schedule_date as required_date,
+ mr_item.item_code as item_code,
+ sum(ifnull(mr_item.stock_qty, 0)) as qty,
+ ifnull(mr_item.stock_uom, '') as uom,
+ sum(ifnull(mr_item.ordered_qty, 0)) as ordered_qty,
+ (sum(mr_item.stock_qty) - sum(ifnull(mr_item.ordered_qty, 0))) as qty_to_order,
+ mr_item.item_name as item_name,
+ mr.company as company
+ from
+ `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
+ where
+ mr_item.parent = mr.name
+ and mr.material_request_type = "Purchase"
+ and mr.docstatus = 1
+ and mr.status != "Stopped"
+ {conditions}
+ group by mr.name, mr_item.item_code
+ having
+ sum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.stock_qty, 0))
+ order by mr.transaction_date, mr.schedule_date""".format(conditions=conditions), as_dict=1)
+
+ return data
+
+def update_qty_columns(row_to_update, data_row):
+ fields = ["qty", "ordered_qty", "qty_to_order"]
+ for field in fields:
+ row_to_update[field] += flt(data_row[field])
+
+def prepare_data(data, filters):
+ """Prepare consolidated Report data and Chart data"""
+ material_request_map, item_qty_map = {}, {}
+
+ for row in data:
+ # item wise map for charts
+ if not row["item_code"] in item_qty_map:
+ item_qty_map[row["item_code"]] = {
+ "qty" : row["qty"],
+ "ordered_qty" : row["ordered_qty"],
+ "qty_to_order" : row["qty_to_order"]
+ }
+ else:
+ item_entry = item_qty_map[row["item_code"]]
+ update_qty_columns(item_entry, row)
+
+ if filters.get("group_by_mr"):
+ # consolidated material request map for group by filter
+ if not row["material_request"] in material_request_map:
+ # create an entry with mr as key
+ row_copy = copy.deepcopy(row)
+ material_request_map[row["material_request"]] = row_copy
+ else:
+ mr_row = material_request_map[row["material_request"]]
+ mr_row["required_date"] = min(getdate(mr_row["required_date"]), getdate(row["required_date"]))
+
+ #sum numeric columns
+ update_qty_columns(mr_row, row)
+
+ chart_data = prepare_chart_data(item_qty_map)
+
+ if filters.get("group_by_mr"):
+ data =[]
+ for mr in material_request_map:
+ data.append(material_request_map[mr])
+ return data, chart_data
+
+ return data, chart_data
+
+def prepare_chart_data(item_data):
+ labels, qty_to_order, ordered_qty = [], [], []
+
+ if len(item_data) > 30:
+ item_data = dict(list(item_data.items())[:30])
+
+ for row in item_data:
+ mr_row = item_data[row]
+ labels.append(row)
+ qty_to_order.append(mr_row["qty_to_order"])
+ ordered_qty.append(mr_row["ordered_qty"])
+
+ chart_data = {
+ "data" : {
+ "labels": labels,
+ "datasets": [
+ {
+ 'name': _('Qty to Order'),
+ 'values': qty_to_order
+ },
+ {
+ 'name': _('Ordered Qty'),
+ 'values': ordered_qty
+ }
+ ]
+ },
+ "type": "bar",
+ "barOptions": {
+ "stacked": 1
+ },
+ }
+
+ return chart_data
+
+def get_columns(filters):
+ columns = [
+ {
+ "label": _("Material Request"),
+ "fieldname": "material_request",
+ "fieldtype": "Link",
+ "options": "Material Request",
+ "width": 150
+ },
+ {
+ "label":_("Date"),
+ "fieldname": "date",
+ "fieldtype": "Date",
+ "width": 90
+ },
+ {
+ "label":_("Required By"),
+ "fieldname": "required_date",
+ "fieldtype": "Date",
+ "width": 100
+ }
+ ]
+
+ if not filters.get("group_by_mr"):
+ columns.extend([{
+ "label":_("Item Code"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 100
+ },
+ {
+ "label":_("Item Name"),
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "width": 100
+ },
+ {
+ "label": _("UOM"),
+ "fieldname": "uom",
+ "fieldtype": "Data",
+ "width": 100,
+ }])
+
+ columns.extend([
+ {
+ "label": _("Qty"),
+ "fieldname": "qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Ordered Qty"),
+ "fieldname": "ordered_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Qty to Order"),
+ "fieldname": "qty_to_order",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Company"),
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "width": 100
+ }
+ ])
+
+ return columns
diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py
index 1d4054786e6..b06bb76ca82 100644
--- a/erpnext/config/buying.py
+++ b/erpnext/config/buying.py
@@ -1,8 +1,9 @@
from __future__ import unicode_literals
+import frappe
from frappe import _
def get_data():
- return [
+ config = [
{
"label": _("Purchasing"),
"icon": "fa fa-star",
@@ -166,7 +167,7 @@ def get_data():
{
"type": "report",
"is_query_report": True,
- "name": "Requested Items To Be Ordered",
+ "name": "Requested Items To Order",
"reference_doctype": "Material Request",
"onboard": 1,
},
@@ -243,3 +244,21 @@ def get_data():
},
]
+
+ regional = {
+ "label": _("Regional"),
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Import Supplier Invoice",
+ "description": _("Import Italian Supplier Invoice."),
+ "onboard": 1,
+ }
+ ]
+ }
+
+ countries = frappe.get_all("Company", fields="country")
+ countries = [country["country"] for country in countries]
+ if "Italy" in countries:
+ config.append(regional)
+ return config
\ No newline at end of file
diff --git a/erpnext/config/manufacturing.py b/erpnext/config/manufacturing.py
index 2c18eeb83a1..012f1cad0ad 100644
--- a/erpnext/config/manufacturing.py
+++ b/erpnext/config/manufacturing.py
@@ -120,13 +120,7 @@ def get_data():
{
"type": "report",
"is_query_report": True,
- "name": "Open Work Orders",
- "doctype": "Work Order"
- },
- {
- "type": "report",
- "is_query_report": True,
- "name": "Work Orders in Progress",
+ "name": "Work Order Summary",
"doctype": "Work Order"
},
{
@@ -135,12 +129,6 @@ def get_data():
"name": "Issued Items Against Work Order",
"doctype": "Work Order"
},
- {
- "type": "report",
- "is_query_report": True,
- "name": "Completed Work Orders",
- "doctype": "Work Order"
- },
{
"type": "report",
"is_query_report": True,
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index 29f8dd57026..50b17abbe6d 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -70,7 +70,7 @@ def validate_item_variant_attributes(item, args=None):
else:
attributes_list = attribute_values.get(attribute.lower(), [])
- validate_item_attribute_value(attributes_list, attribute, value, item.name)
+ validate_item_attribute_value(attributes_list, attribute, value, item.name, from_variant=True)
def validate_is_incremental(numeric_attribute, attribute, value, item):
from_range = numeric_attribute.from_range
@@ -93,13 +93,20 @@ def validate_is_incremental(numeric_attribute, attribute, value, item):
.format(attribute, from_range, to_range, increment, item),
InvalidItemAttributeValueError, title=_('Invalid Attribute'))
-def validate_item_attribute_value(attributes_list, attribute, attribute_value, item):
+def validate_item_attribute_value(attributes_list, attribute, attribute_value, item, from_variant=True):
allow_rename_attribute_value = frappe.db.get_single_value('Item Variant Settings', 'allow_rename_attribute_value')
if allow_rename_attribute_value:
pass
elif attribute_value not in attributes_list:
- frappe.throw(_("The value {0} is already assigned to an exisiting Item {2}.").format(
- attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Rename Not Allowed'))
+ if from_variant:
+ frappe.throw(_("{0} is not a valid Value for Attribute {1} of Item {2}.").format(
+ frappe.bold(attribute_value), frappe.bold(attribute), frappe.bold(item)), InvalidItemAttributeValueError, title=_("Invalid Value"))
+ else:
+ msg = _("The value {0} is already assigned to an exisiting Item {1}.").format(
+ frappe.bold(attribute_value), frappe.bold(item))
+ msg += " " + _("To still proceed with editing this Attribute Value, enable {0} in Item Variant Settings.").format(frappe.bold("Allow Rename Attribute Value"))
+
+ frappe.throw(msg, InvalidItemAttributeValueError, title=_('Edit Not Allowed'))
def get_attribute_values(item):
if not frappe.flags.attribute_values:
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 5febfd6bf28..f6a8d27d440 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -8,11 +8,14 @@ from frappe.desk.reportview import get_match_cond, get_filters_cond
from frappe.utils import nowdate, getdate
from collections import defaultdict
from erpnext.stock.get_item_details import _get_item_tax_template
+from frappe.utils import unique
# searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters):
conditions = []
- return frappe.db.sql("""select name, employee_name from `tabEmployee`
+ fields = get_fields("Employee", ["name", "employee_name"])
+
+ return frappe.db.sql("""select {fields} from `tabEmployee`
where status = 'Active'
and docstatus < 2
and ({key} like %(txt)s
@@ -24,6 +27,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters):
idx desc,
name, employee_name
limit %(start)s, %(page_len)s""".format(**{
+ 'fields': ", ".join(fields),
'key': searchfield,
'fcond': get_filters_cond(doctype, filters, conditions),
'mcond': get_match_cond(doctype)
@@ -34,9 +38,12 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len
})
- # searches for leads which are not converted
+
+# searches for leads which are not converted
def lead_query(doctype, txt, searchfield, start, page_len, filters):
- return frappe.db.sql("""select name, lead_name, company_name from `tabLead`
+ fields = get_fields("Lead", ["name", "lead_name", "company_name"])
+
+ return frappe.db.sql("""select {fields} from `tabLead`
where docstatus < 2
and ifnull(status, '') != 'Converted'
and ({key} like %(txt)s
@@ -50,6 +57,7 @@ def lead_query(doctype, txt, searchfield, start, page_len, filters):
idx desc,
name, lead_name
limit %(start)s, %(page_len)s""".format(**{
+ 'fields': ", ".join(fields),
'key': searchfield,
'mcond':get_match_cond(doctype)
}), {
@@ -59,6 +67,7 @@ def lead_query(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len
})
+
# searches for customer
def customer_query(doctype, txt, searchfield, start, page_len, filters):
conditions = []
@@ -69,13 +78,9 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
else:
fields = ["name", "customer_name", "customer_group", "territory"]
- meta = frappe.get_meta("Customer")
- searchfields = meta.get_search_fields()
- searchfields = searchfields + [f for f in [searchfield or "name", "customer_name"] \
- if not f in searchfields]
- fields = fields + [f for f in searchfields if not f in fields]
+ fields = get_fields("Customer", fields)
- fields = ", ".join(fields)
+ searchfields = frappe.get_meta("Customer").get_search_fields()
searchfields = " or ".join([field + " like %(txt)s" for field in searchfields])
return frappe.db.sql("""select {fields} from `tabCustomer`
@@ -88,7 +93,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
idx desc,
name, customer_name
limit %(start)s, %(page_len)s""".format(**{
- "fields": fields,
+ "fields": ", ".join(fields),
"scond": searchfields,
"mcond": get_match_cond(doctype),
"fcond": get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
@@ -99,6 +104,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len
})
+
# searches for supplier
def supplier_query(doctype, txt, searchfield, start, page_len, filters):
supp_master_name = frappe.defaults.get_user_default("supp_master_name")
@@ -106,7 +112,8 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
fields = ["name", "supplier_group"]
else:
fields = ["name", "supplier_name", "supplier_group"]
- fields = ", ".join(fields)
+
+ fields = get_fields("Supplier", fields)
return frappe.db.sql("""select {field} from `tabSupplier`
where docstatus < 2
@@ -119,7 +126,7 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
idx desc,
name, supplier_name
limit %(start)s, %(page_len)s """.format(**{
- 'field': fields,
+ 'field': ', '.join(fields),
'key': searchfield,
'mcond':get_match_cond(doctype)
}), {
@@ -129,6 +136,7 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len
})
+
def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
company_currency = erpnext.get_company_currency(filters.get('company'))
@@ -153,6 +161,7 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
return tax_accounts
+
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
conditions = []
@@ -179,12 +188,6 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
# scan description only if items are less than 50000
description_cond = 'or tabItem.description LIKE %(txt)s'
- extra_cond = " and tabItem.has_variants=0"
- if (filters and isinstance(filters, dict)
- and filters.get("doctype") == "BOM"):
- extra_cond = ""
- del filters["doctype"]
-
return frappe.db.sql("""select tabItem.name,
if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
@@ -195,10 +198,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
from tabItem
where tabItem.docstatus < 2
and tabItem.disabled=0
+ and tabItem.has_variants=0
and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00')
and ({scond} or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s)
{description_cond})
- {extra_cond}
{fcond} {mcond}
order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
@@ -209,7 +212,6 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
key=searchfield,
columns=columns,
scond=searchfields,
- extra_cond=extra_cond,
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
mcond=get_match_cond(doctype).replace('%', '%%'),
description_cond = description_cond),
@@ -221,10 +223,12 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
"page_len": page_len
}, as_dict=as_dict)
+
def bom(doctype, txt, searchfield, start, page_len, filters):
conditions = []
+ fields = get_fields("BOM", ["name", "item"])
- return frappe.db.sql("""select tabBOM.name, tabBOM.item
+ return frappe.db.sql("""select {fields}
from tabBOM
where tabBOM.docstatus=1
and tabBOM.is_active=1
@@ -234,6 +238,7 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
idx desc, name
limit %(start)s, %(page_len)s """.format(
+ fields=", ".join(fields),
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
mcond=get_match_cond(doctype).replace('%', '%%'),
key=searchfield),
@@ -244,13 +249,16 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len or 20
})
+
def get_project_name(doctype, txt, searchfield, start, page_len, filters):
cond = ''
if filters.get('customer'):
cond = """(`tabProject`.customer = %s or
ifnull(`tabProject`.customer,"")="") and""" %(frappe.db.escape(filters.get("customer")))
- return frappe.db.sql("""select `tabProject`.name from `tabProject`
+ fields = get_fields("Project", ["name"])
+
+ return frappe.db.sql("""select {fields} from `tabProject`
where `tabProject`.status not in ("Completed", "Cancelled")
and {cond} `tabProject`.name like %(txt)s {match_cond}
order by
@@ -258,6 +266,7 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
idx desc,
`tabProject`.name asc
limit {start}, {page_len}""".format(
+ fields=", ".join(['`tabProject`.{0}'.format(f) for f in fields]),
cond=cond,
match_cond=get_match_cond(doctype),
start=start,
@@ -268,8 +277,10 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters, as_dict):
+ fields = get_fields("Delivery Note", ["name", "customer", "posting_date"])
+
return frappe.db.sql("""
- select `tabDelivery Note`.name, `tabDelivery Note`.customer, `tabDelivery Note`.posting_date
+ select %(fields)s
from `tabDelivery Note`
where `tabDelivery Note`.`%(key)s` like %(txt)s and
`tabDelivery Note`.docstatus = 1
@@ -284,6 +295,7 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
)
%(mcond)s order by `tabDelivery Note`.`%(key)s` asc limit %(start)s, %(page_len)s
""" % {
+ "fields": ", ".join(["`tabDelivery Note`.{0}".format(f) for f in fields]),
"key": searchfield,
"fcond": get_filters_cond(doctype, filters, []),
"mcond": get_match_cond(doctype),
@@ -349,6 +361,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
order by expiry_date, name desc
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
+
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
filter_list = []
@@ -371,6 +384,7 @@ def get_account_list(doctype, txt, searchfield, start, page_len, filters):
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)
+
def get_blanket_orders(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select distinct bo.name, bo.blanket_order_type, bo.to_date
from `tabBlanket Order` bo, `tabBlanket Order Item` boi
@@ -385,6 +399,7 @@ def get_blanket_orders(doctype, txt, searchfield, start, page_len, filters):
company = frappe.db.escape(filters.get("company"))
))
+
@frappe.whitelist()
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond
@@ -490,6 +505,7 @@ def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(query, filters)
+
@frappe.whitelist()
def item_manufacturer_query(doctype, txt, searchfield, start, page_len, filters):
item_filters = [
@@ -507,6 +523,7 @@ def item_manufacturer_query(doctype, txt, searchfield, start, page_len, filters)
)
return item_manufacturers
+
@frappe.whitelist()
def get_purchase_receipts(doctype, txt, searchfield, start, page_len, filters):
query = """
@@ -520,6 +537,7 @@ def get_purchase_receipts(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(query, filters)
+
@frappe.whitelist()
def get_purchase_invoices(doctype, txt, searchfield, start, page_len, filters):
query = """
@@ -533,6 +551,7 @@ def get_purchase_invoices(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(query, filters)
+
@frappe.whitelist()
def get_tax_template(doctype, txt, searchfield, start, page_len, filters):
@@ -556,3 +575,13 @@ def get_tax_template(doctype, txt, searchfield, start, page_len, filters):
taxes = _get_item_tax_template(args, taxes, for_validate=True)
return [(d,) for d in set(taxes)]
+
+
+def get_fields(doctype, fields=[]):
+ meta = frappe.get_meta(doctype)
+ fields.extend(meta.get_search_fields())
+
+ if meta.title_field and not meta.title_field.strip() in fields:
+ fields.insert(1, meta.title_field.strip())
+
+ return unique(fields)
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 1e0a48c134b..b696ac39f69 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -361,7 +361,7 @@ class SellingController(StockController):
self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no])))
def set_gross_profit(self):
- if self.doctype == "Sales Order":
+ if self.doctype in ["Sales Order", "Quotation"]:
for item in self.items:
item.gross_profit = flt(((item.base_rate - item.valuation_rate) * item.stock_qty), self.precision("amount", item))
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index de76e45cd11..b465a106f0e 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -69,17 +69,6 @@ status_map = {
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],
- "Purchase Invoice": [
- ["Draft", None],
- ["Submitted", "eval:self.docstatus==1"],
- ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],
- ["Return", "eval:self.is_return==1 and self.docstatus==1"],
- ["Debit Note Issued",
- "eval:self.outstanding_amount <= 0 and self.docstatus==1 and self.is_return==0 and get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"],
- ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],
- ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],
- ["Cancelled", "eval:self.docstatus==2"],
- ],
"Material Request": [
["Draft", None],
["Stopped", "eval:self.status == 'Stopped'"],
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 86de80815db..2888c764ef7 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -19,7 +19,8 @@ class QualityInspectionNotSubmittedError(frappe.ValidationError): pass
class StockController(AccountsController):
def validate(self):
super(StockController, self).validate()
- self.validate_inspection()
+ if not self.get('is_return'):
+ self.validate_inspection()
self.validate_serialized_batch()
self.validate_customer_provided_item()
@@ -226,7 +227,7 @@ class StockController(AccountsController):
def check_expense_account(self, item):
if not item.get("expense_account"):
- frappe.throw(_("Expense or Difference account is mandatory for Item {0} as it impacts overall stock value").format(item.item_code))
+ frappe.throw(_("Expense Account not set for Item {0}. Please set an Expense Account for the item in the Items table").format(item.item_code))
else:
is_expense_account = frappe.db.get_value("Account",
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index ed379389d7e..ecf041efd17 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -155,7 +155,7 @@ def has_website_permission(doc, ptype, user, verbose=False):
return frappe.db.exists(doctype, get_customer_filter(doc, customers))
elif suppliers:
fieldname = 'suppliers' if doctype == 'Request for Quotation' else 'supplier'
- return frappe.db.exists(doctype, filters={
+ return frappe.db.exists(doctype, {
'name': doc.name,
fieldname: ["in", suppliers]
})
diff --git a/erpnext/crm/dashboard_fixtures.py b/erpnext/crm/dashboard_fixtures.py
new file mode 100644
index 00000000000..0535cbbcc95
--- /dev/null
+++ b/erpnext/crm/dashboard_fixtures.py
@@ -0,0 +1,214 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe, erpnext, json
+from frappe import _
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards()
+ })
+
+def get_dashboards():
+ return [{
+ "doctype": "Dashboard",
+ "name": "CRM",
+ "dashboard_name": "CRM",
+ "charts": [
+ { "chart": "Incoming Leads", "width": "Full" },
+ { "chart": "Opportunity Trends", "width": "Full"},
+ { "chart": "Won Opportunities", "width": "Full" },
+ { "chart": "Territory Wise Opportunity Count", "width": "Half"},
+ { "chart": "Opportunities via Campaigns", "width": "Half" },
+ { "chart": "Territory Wise Sales", "width": "Full"},
+ { "chart": "Lead Source", "width": "Half"}
+ ],
+ "cards": [
+ { "card": "New Lead (Last 1 Month)" },
+ { "card": "New Opportunity (Last 1 Month)" },
+ { "card": "Won Opportunity (Last 1 Month)" },
+ { "card": "Open Opportunity"},
+ ]
+ }]
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
+
+def get_charts():
+ company = get_company_for_dashboards()
+
+ return [{
+ "name": "Incoming Leads",
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Count",
+ "chart_name": _("Incoming Leads"),
+ "timespan": "Last Quarter",
+ "time_interval": "Weekly",
+ "document_type": "Lead",
+ "based_on": "creation",
+ 'is_public': 1,
+ 'timeseries': 1,
+ "owner": "Administrator",
+ "filters_json": json.dumps([]),
+ "type": "Bar"
+ },
+ {
+ "name": "Opportunity Trends",
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Count",
+ "chart_name": _("Opportunity Trends"),
+ "timespan": "Last Quarter",
+ "time_interval": "Weekly",
+ "document_type": "Opportunity",
+ "based_on": "creation",
+ 'is_public': 1,
+ 'timeseries': 1,
+ "owner": "Administrator",
+ "filters_json": json.dumps([["Opportunity", "company", "=", company, False]]),
+ "type": "Bar"
+ },
+ {
+ "name": "Opportunities via Campaigns",
+ "chart_name": _("Opportunities via Campaigns"),
+ "doctype": "Dashboard Chart",
+ "chart_type": "Group By",
+ "group_by_type": "Count",
+ "group_by_based_on": "campaign",
+ "document_type": "Opportunity",
+ 'is_public': 1,
+ 'timeseries': 1,
+ "owner": "Administrator",
+ "filters_json": json.dumps([["Opportunity", "company", "=", company, False]]),
+ "type": "Pie",
+ "custom_options": json.dumps({
+ "truncateLegends": 1,
+ "maxSlices": 8
+ })
+ },
+ {
+ "name": "Won Opportunities",
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Count",
+ "chart_name": _("Won Opportunities"),
+ "timespan": "Last Year",
+ "time_interval": "Monthly",
+ "document_type": "Opportunity",
+ "based_on": "modified",
+ 'is_public': 1,
+ 'timeseries': 1,
+ "owner": "Administrator",
+ "filters_json": json.dumps([
+ ["Opportunity", "company", "=", company, False],
+ ["Opportunity", "status", "=", "Converted", False]]),
+ "type": "Bar"
+ },
+ {
+ "name": "Territory Wise Opportunity Count",
+ "doctype": "Dashboard Chart",
+ "chart_type": "Group By",
+ "group_by_type": "Count",
+ "group_by_based_on": "territory",
+ "chart_name": _("Territory Wise Opportunity Count"),
+ "document_type": "Opportunity",
+ 'is_public': 1,
+ "filters_json": json.dumps([
+ ["Opportunity", "company", "=", company, False]
+ ]),
+ "owner": "Administrator",
+ "type": "Donut",
+ "custom_options": json.dumps({
+ "truncateLegends": 1,
+ "maxSlices": 8
+ })
+ },
+ {
+ "name": "Territory Wise Sales",
+ "doctype": "Dashboard Chart",
+ "chart_type": "Group By",
+ "group_by_type": "Sum",
+ "group_by_based_on": "territory",
+ "chart_name": _("Territory Wise Sales"),
+ "aggregate_function_based_on": "opportunity_amount",
+ "document_type": "Opportunity",
+ 'is_public': 1,
+ "owner": "Administrator",
+ "filters_json": json.dumps([
+ ["Opportunity", "company", "=", company, False],
+ ["Opportunity", "status", "=", "Converted", False]
+ ]),
+ "type": "Bar"
+ },
+ {
+ "name": "Lead Source",
+ "doctype": "Dashboard Chart",
+ "chart_type": "Group By",
+ "group_by_type": "Count",
+ "group_by_based_on": "source",
+ "chart_name": _("Lead Source"),
+ "document_type": "Lead",
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Pie",
+ "custom_options": json.dumps({
+ "truncateLegends": 1,
+ "maxSlices": 8
+ })
+ }]
+
+def get_number_cards():
+ return [{
+ "doctype": "Number Card",
+ "document_type": "Lead",
+ "name": "New Lead (Last 1 Month)",
+ "filters_json": json.dumps([["Lead","creation","Previous","1 month",False]]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("New Lead (Last 1 Month)"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Opportunity",
+ "name": "New Opportunity (Last 1 Month)",
+ "filters_json": json.dumps([["Opportunity","creation","Previous","1 month",False]]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("New Opportunity (Last 1 Month)"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Opportunity",
+ "name": "Won Opportunity (Last 1 Month)",
+ "filters_json": json.dumps([["Opportunity","creation","Previous","1 month",False]]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Won Opportunity (Last 1 Month)"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Opportunity",
+ "name": "Open Opportunity",
+ "filters_json": json.dumps([["Opportunity","status","=","Open",False]]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Open Opportunity"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ }]
\ No newline at end of file
diff --git a/erpnext/crm/desk_page/crm/crm.json b/erpnext/crm/desk_page/crm/crm.json
index ca13d6abb66..eb69dc06b65 100644
--- a/erpnext/crm/desk_page/crm/crm.json
+++ b/erpnext/crm/desk_page/crm/crm.json
@@ -27,26 +27,32 @@
}
],
"category": "Modules",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Territory Wise Sales"
+ }
+ ],
"creation": "2020-01-23 14:48:30.183272",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "CRM",
- "modified": "2020-04-27 22:32:26.682911",
+ "modified": "2020-05-28 13:33:52.906750",
"modified_by": "Administrator",
"module": "CRM",
"name": "CRM",
+ "onboarding": "CRM",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#ffe8cd",
"format": "{} Open",
"label": "Lead",
"link_to": "Lead",
@@ -54,6 +60,7 @@
"type": "DocType"
},
{
+ "color": "#cef6d1",
"format": "{} Assigned",
"label": "Opportunity",
"link_to": "Opportunity",
@@ -69,6 +76,11 @@
"label": "Sales Analytics",
"link_to": "Sales Analytics",
"type": "Report"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "CRM",
+ "type": "Dashboard"
}
]
}
\ No newline at end of file
diff --git a/erpnext/crm/doctype/lead/lead.json b/erpnext/crm/doctype/lead/lead.json
index 20ab51d44bc..6fef0c46437 100644
--- a/erpnext/crm/doctype/lead/lead.json
+++ b/erpnext/crm/doctype/lead/lead.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_events_in_timeline": 1,
"allow_import": 1,
"autoname": "naming_series:",
@@ -447,7 +448,7 @@
"idx": 5,
"image_field": "image",
"links": [],
- "modified": "2020-04-08 22:26:11.687110",
+ "modified": "2020-05-11 20:27:45.868960",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
@@ -504,15 +505,6 @@
"read": 1,
"report": 1,
"role": "Sales User"
- },
- {
- "email": 1,
- "export": 1,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Guest",
- "share": 1
}
],
"search_fields": "lead_name,lead_owner,status",
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index 74b358219dc..ec7d14d6ae3 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -153,7 +153,7 @@ class Lead(SellingController):
if not self.lead_name:
self.set_lead_name()
- names = self.lead_name.split(" ")
+ names = self.lead_name.strip().split(" ")
if len(names) > 1:
first_name, last_name = names[0], " ".join(names[1:])
else:
diff --git a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.js b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.js
index 50b98e9ce12..263005ef6c5 100644
--- a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.js
+++ b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.js
@@ -62,6 +62,8 @@ frappe.ui.form.on('LinkedIn Settings', {
callback : function(r) {
window.location.href = r.message;
}
+ }).fail(function() {
+ frappe.dom.unfreeze();
});
}
},
diff --git a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py
index 5df35df3ddf..377e061fdf4 100644
--- a/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py
+++ b/erpnext/crm/doctype/linkedin_settings/linkedin_settings.py
@@ -15,7 +15,7 @@ class LinkedInSettings(Document):
params = urlencode({
"response_type":"code",
"client_id": self.consumer_key,
- "redirect_uri": get_site_url(frappe.local.site) + "/?cmd=erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback",
+ "redirect_uri": "{0}/api/method/erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback?".format(frappe.utils.get_url()),
"scope": "r_emailaddress w_organization_social r_basicprofile r_liteprofile r_organization_social rw_organization_admin w_member_social"
})
@@ -30,7 +30,7 @@ class LinkedInSettings(Document):
"code": code,
"client_id": self.consumer_key,
"client_secret": self.get_password(fieldname="consumer_secret"),
- "redirect_uri": get_site_url(frappe.local.site) + "/?cmd=erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback",
+ "redirect_uri": "{0}/api/method/erpnext.crm.doctype.linkedin_settings.linkedin_settings.callback?".format(frappe.utils.get_url()),
}
headers = {
"Content-Type": "application/x-www-form-urlencoded"
@@ -154,7 +154,7 @@ class LinkedInSettings(Document):
return response
-@frappe.whitelist()
+@frappe.whitelist(allow_guest=True)
def callback(code=None, error=None, error_description=None):
if not error:
linkedin_settings = frappe.get_doc("LinkedIn Settings")
diff --git a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
index 9ed616afd23..68f0104fd6c 100644
--- a/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
+++ b/erpnext/crm/doctype/opportunity/opportunity_dashboard.py
@@ -3,11 +3,7 @@ from frappe import _
def get_data():
return {
- 'fieldname': 'prevdoc_docname',
- 'non_standard_fieldnames': {
- 'Supplier Quotation': 'opportunity',
- 'Quotation': 'opportunity'
- },
+ 'fieldname': 'opportunity',
'transactions': [
{
'items': ['Quotation', 'Supplier Quotation']
diff --git a/erpnext/crm/doctype/sales_stage/sales_stage.json b/erpnext/crm/doctype/sales_stage/sales_stage.json
index 4374bb58314..77aa559b771 100644
--- a/erpnext/crm/doctype/sales_stage/sales_stage.json
+++ b/erpnext/crm/doctype/sales_stage/sales_stage.json
@@ -1,96 +1,44 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "field:stage_name",
- "beta": 0,
- "creation": "2018-10-01 09:28:16.399518",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "allow_rename": 1,
+ "autoname": "field:stage_name",
+ "creation": "2018-10-01 09:28:16.399518",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "stage_name"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "stage_name",
- "fieldtype": "Data",
- "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": "Stage Name",
- "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,
+ "fieldname": "stage_name",
+ "fieldtype": "Data",
+ "label": "Stage Name",
"unique": 1
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-10-01 09:29:43.230378",
- "modified_by": "Administrator",
- "module": "CRM",
- "name": "Sales Stage",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "links": [],
+ "modified": "2020-05-20 12:22:01.866472",
+ "modified_by": "Administrator",
+ "module": "CRM",
+ "name": "Sales Stage",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Sales Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales Manager",
+ "share": 1,
"write": 1
}
- ],
- "quick_entry": 1,
- "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
+ ],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/crm/doctype/social_media_post/social_media_post.json b/erpnext/crm/doctype/social_media_post/social_media_post.json
index 2601c14b4d6..0a00dca2808 100644
--- a/erpnext/crm/doctype/social_media_post/social_media_post.json
+++ b/erpnext/crm/doctype/social_media_post/social_media_post.json
@@ -30,24 +30,32 @@
"fieldname": "text",
"fieldtype": "Small Text",
"label": "Tweet",
- "mandatory_depends_on": "eval:doc.twitter ==1"
+ "mandatory_depends_on": "eval:doc.twitter ==1",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "image",
"fieldtype": "Attach Image",
- "label": "Image"
+ "label": "Image",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "twitter",
"fieldtype": "Check",
- "label": "Twitter"
+ "label": "Twitter",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "linkedin",
"fieldtype": "Check",
- "label": "LinkedIn"
+ "label": "LinkedIn",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "amended_from",
@@ -56,13 +64,17 @@
"no_copy": 1,
"options": "Social Media Post",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.twitter ==1",
"fieldname": "content",
"fieldtype": "Section Break",
- "label": "Twitter"
+ "label": "Twitter",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -70,7 +82,9 @@
"fieldtype": "Select",
"label": "Post Status",
"options": "\nScheduled\nPosted\nError",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -78,7 +92,9 @@
"fieldtype": "Data",
"hidden": 1,
"label": "Twitter Post Id",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -86,68 +102,89 @@
"fieldtype": "Data",
"hidden": 1,
"label": "LinkedIn Post Id",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "campaign_name",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Campaign",
- "options": "Campaign"
+ "options": "Campaign",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_6",
"fieldtype": "Column Break",
- "label": "Share On"
+ "label": "Share On",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_14",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tweet_preview",
- "fieldtype": "HTML"
+ "fieldtype": "HTML",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"depends_on": "eval:doc.linkedin==1",
"fieldname": "linkedin_section",
"fieldtype": "Section Break",
- "label": "LinkedIn"
+ "label": "LinkedIn",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "attachments_section",
"fieldtype": "Section Break",
- "label": "Attachments"
+ "label": "Attachments",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "linkedin_post",
"fieldtype": "Text",
"label": "Post",
- "mandatory_depends_on": "eval:doc.linkedin ==1"
+ "mandatory_depends_on": "eval:doc.linkedin ==1",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_15",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"fieldname": "scheduled_time",
"fieldtype": "Datetime",
"label": "Scheduled Time",
- "read_only_depends_on": "eval:doc.post_status == \"Posted\""
+ "read_only_depends_on": "eval:doc.post_status == \"Posted\"",
+ "show_days": 1,
+ "show_seconds": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-21 15:10:04.953713",
+ "modified": "2020-06-14 10:31:33.961381",
"modified_by": "Administrator",
"module": "CRM",
"name": "Social Media Post",
"owner": "Administrator",
"permissions": [
{
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -157,6 +194,35 @@
"report": 1,
"role": "System Manager",
"share": 1,
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales User",
+ "share": 1,
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales Manager",
+ "share": 1,
+ "submit": 1,
"write": 1
}
],
diff --git a/erpnext/crm/doctype/twitter_settings/twitter_settings.js b/erpnext/crm/doctype/twitter_settings/twitter_settings.js
index b55946a8bd8..f6f431ca5c9 100644
--- a/erpnext/crm/doctype/twitter_settings/twitter_settings.js
+++ b/erpnext/crm/doctype/twitter_settings/twitter_settings.js
@@ -47,6 +47,8 @@ frappe.ui.form.on('Twitter Settings', {
callback : function(r) {
window.location.href = r.message;
}
+ }).fail(function() {
+ frappe.dom.unfreeze();
});
}
},
diff --git a/erpnext/crm/doctype/twitter_settings/twitter_settings.json b/erpnext/crm/doctype/twitter_settings/twitter_settings.json
index f92e7f04955..36776e5c202 100644
--- a/erpnext/crm/doctype/twitter_settings/twitter_settings.json
+++ b/erpnext/crm/doctype/twitter_settings/twitter_settings.json
@@ -11,8 +11,8 @@
"consumer_key",
"column_break_5",
"consumer_secret",
- "oauth_token",
- "oauth_secret",
+ "access_token",
+ "access_token_secret",
"session_status"
],
"fields": [
@@ -41,20 +41,6 @@
"label": "API Secret Key",
"reqd": 1
},
- {
- "fieldname": "oauth_token",
- "fieldtype": "Data",
- "hidden": 1,
- "label": "OAuth Token",
- "read_only": 1
- },
- {
- "fieldname": "oauth_secret",
- "fieldtype": "Password",
- "hidden": 1,
- "label": "OAuth Token Secret",
- "read_only": 1
- },
{
"fieldname": "column_break_5",
"fieldtype": "Column Break"
@@ -72,12 +58,26 @@
"label": "Session Status",
"options": "Expired\nActive",
"read_only": 1
+ },
+ {
+ "fieldname": "access_token",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Access Token",
+ "read_only": 1
+ },
+ {
+ "fieldname": "access_token_secret",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Access Token Secret",
+ "read_only": 1
}
],
"image_field": "profile_pic",
"issingle": 1,
"links": [],
- "modified": "2020-04-21 22:06:43.726798",
+ "modified": "2020-05-13 17:50:47.934776",
"modified_by": "Administrator",
"module": "CRM",
"name": "Twitter Settings",
diff --git a/erpnext/crm/doctype/twitter_settings/twitter_settings.py b/erpnext/crm/doctype/twitter_settings/twitter_settings.py
index 64f53b5eb05..976a23dfc7d 100644
--- a/erpnext/crm/doctype/twitter_settings/twitter_settings.py
+++ b/erpnext/crm/doctype/twitter_settings/twitter_settings.py
@@ -12,13 +12,12 @@ from tweepy.error import TweepError
class TwitterSettings(Document):
def get_authorize_url(self):
- callback_url = "{0}/?cmd=erpnext.crm.doctype.twitter_settings.twitter_settings.callback".format(frappe.utils.get_url())
+ callback_url = "{0}/api/method/erpnext.crm.doctype.twitter_settings.twitter_settings.callback?".format(frappe.utils.get_url())
auth = tweepy.OAuthHandler(self.consumer_key, self.get_password(fieldname="consumer_secret"), callback_url)
-
try:
redirect_url = auth.get_authorization_url()
return redirect_url
- except:
+ except tweepy.TweepError as e:
frappe.msgprint(_("Error! Failed to get request token."))
frappe.throw(_('Invalid {0} or {1}').format(frappe.bold("Consumer Key"), frappe.bold("Consumer Secret Key")))
@@ -32,13 +31,13 @@ class TwitterSettings(Document):
try:
auth.get_access_token(oauth_verifier)
- api = self.get_api()
+ api = self.get_api(auth.access_token, auth.access_token_secret)
user = api.me()
profile_pic = (user._json["profile_image_url"]).replace("_normal","")
frappe.db.set_value(self.doctype, self.name, {
- "oauth_token" : auth.access_token,
- "oauth_secret" : auth.access_token_secret,
+ "access_token" : auth.access_token,
+ "access_token_secret" : auth.access_token_secret,
"account_name" : user._json["screen_name"],
"profile_pic" : profile_pic,
"session_status" : "Active"
@@ -50,11 +49,11 @@ class TwitterSettings(Document):
frappe.msgprint(_("Error! Failed to get access token."))
frappe.throw(_('Invalid Consumer Key or Consumer Secret Key'))
- def get_api(self):
+ def get_api(self, access_token, 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.oauth_token, self.get_password(fieldname="oauth_secret"))
+ auth.set_access_token(access_token, access_token_secret)
return tweepy.API(auth)
@@ -68,13 +67,13 @@ class TwitterSettings(Document):
def upload_image(self, media):
media = get_file_path(media)
- api = self.get_api()
+ api = self.get_api(self.access_token, self.access_token_secret)
media = api.media_upload(media)
return media.media_id
def send_tweet(self, text, media_id=None):
- api = self.get_api()
+ api = self.get_api(self.access_token, self.access_token_secret)
try:
if media_id:
response = api.update_status(status = text, media_ids = [media_id])
@@ -91,8 +90,12 @@ class TwitterSettings(Document):
frappe.db.commit()
frappe.throw(content["message"],title="Twitter Error {0} {1}".format(e.response.status_code, e.response.reason))
-@frappe.whitelist()
-def callback(oauth_token, oauth_verifier):
- twitter_settings = frappe.get_single("Twitter Settings")
- twitter_settings.get_access_token(oauth_token,oauth_verifier)
- frappe.db.commit()
+@frappe.whitelist(allow_guest=True)
+def callback(oauth_token = None, oauth_verifier = None):
+ if oauth_token and oauth_verifier:
+ twitter_settings = frappe.get_single("Twitter Settings")
+ twitter_settings.get_access_token(oauth_token,oauth_verifier)
+ frappe.db.commit()
+ else:
+ frappe.local.response["type"] = "redirect"
+ frappe.local.response["location"] = get_url_to_form("Twitter Settings","Twitter Settings")
diff --git a/erpnext/crm/module_onboarding/crm/crm.json b/erpnext/crm/module_onboarding/crm/crm.json
new file mode 100644
index 00000000000..44d672a7b59
--- /dev/null
+++ b/erpnext/crm/module_onboarding/crm/crm.json
@@ -0,0 +1,42 @@
+{
+ "allow_roles": [
+ {
+ "role": "Sales Master Manager"
+ },
+ {
+ "role": "Sales Manager"
+ },
+ {
+ "role": "Sales User"
+ }
+ ],
+ "creation": "2020-05-09 23:42:50.901548",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/CRM",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-28 21:07:41.278784",
+ "modified_by": "Administrator",
+ "module": "CRM",
+ "name": "CRM",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Introduction to CRM"
+ },
+ {
+ "step": "Create Lead"
+ },
+ {
+ "step": "Create Opportunity"
+ },
+ {
+ "step": "Create and Send Quotation"
+ }
+ ],
+ "subtitle": "Lead, Opportunity, Customer and more.",
+ "success_message": "CRM Module is all Set Up!",
+ "title": "Let's Set Up Your CRM.",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/crm/onboarding/crm/crm.json b/erpnext/crm/onboarding/crm/crm.json
new file mode 100644
index 00000000000..016a8307dd7
--- /dev/null
+++ b/erpnext/crm/onboarding/crm/crm.json
@@ -0,0 +1,45 @@
+{
+ "allow_roles": [
+ {
+ "role": "Sales Master Manager"
+ },
+ {
+ "role": "Administrator"
+ },
+ {
+ "role": "Sales Manager"
+ }
+ ],
+ "creation": "2020-05-09 23:42:50.901548",
+ "docstatus": 0,
+ "doctype": "Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/CRM",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-09 23:42:50.901548",
+ "modified_by": "Administrator",
+ "module": "CRM",
+ "name": "CRM",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Introduction to CRM"
+ },
+ {
+ "step": "Start Campaign"
+ },
+ {
+ "step": "Create Lead"
+ },
+ {
+ "step": "Convert Lead to Customer"
+ },
+ {
+ "step": "Create and Send Quotation"
+ }
+ ],
+ "subtitle": "Campaign, Lead, Opportunity, Customer and more",
+ "success_message": "CRM Module is all setup!",
+ "title": "Let's Setup Your CRM",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/crm/onboarding_step/create_and_send_quotation/create_and_send_quotation.json b/erpnext/crm/onboarding_step/create_and_send_quotation/create_and_send_quotation.json
new file mode 100644
index 00000000000..78f7e4de9c7
--- /dev/null
+++ b/erpnext/crm/onboarding_step/create_and_send_quotation/create_and_send_quotation.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-09 23:42:46.592075",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-28 21:07:11.461172",
+ "modified_by": "Administrator",
+ "name": "Create and Send Quotation",
+ "owner": "Administrator",
+ "reference_document": "Quotation",
+ "show_full_form": 1,
+ "title": "Create and Send Quotation",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/crm/onboarding_step/create_lead/create_lead.json b/erpnext/crm/onboarding_step/create_lead/create_lead.json
new file mode 100644
index 00000000000..c45e8b036c5
--- /dev/null
+++ b/erpnext/crm/onboarding_step/create_lead/create_lead.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-09 23:40:25.192503",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-28 21:07:01.373403",
+ "modified_by": "Administrator",
+ "name": "Create Lead",
+ "owner": "Administrator",
+ "reference_document": "Lead",
+ "show_full_form": 1,
+ "title": "Create Lead",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/crm/onboarding_step/create_opportunity/create_opportunity.json b/erpnext/crm/onboarding_step/create_opportunity/create_opportunity.json
new file mode 100644
index 00000000000..9f996d9e2be
--- /dev/null
+++ b/erpnext/crm/onboarding_step/create_opportunity/create_opportunity.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 17:38:27.496696",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:38:27.496696",
+ "modified_by": "Administrator",
+ "name": "Create Opportunity",
+ "owner": "Administrator",
+ "reference_document": "Opportunity",
+ "show_full_form": 0,
+ "title": "Create Opportunity",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/crm/onboarding_step/introduction_to_crm/introduction_to_crm.json b/erpnext/crm/onboarding_step/introduction_to_crm/introduction_to_crm.json
new file mode 100644
index 00000000000..fa26921ae2c
--- /dev/null
+++ b/erpnext/crm/onboarding_step/introduction_to_crm/introduction_to_crm.json
@@ -0,0 +1,19 @@
+{
+ "action": "Watch Video",
+ "creation": "2020-05-09 23:37:08.926812",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 17:28:16.448676",
+ "modified_by": "Administrator",
+ "name": "Introduction to CRM",
+ "owner": "Administrator",
+ "show_full_form": 0,
+ "title": "Introduction to CRM",
+ "validate_action": 1,
+ "video_url": "https://www.youtube.com/watch?v=o9XCSZHJfpA"
+}
\ No newline at end of file
diff --git a/erpnext/crm/utils.py b/erpnext/crm/utils.py
index 38bf79e5fcb..95b19ec21ec 100644
--- a/erpnext/crm/utils.py
+++ b/erpnext/crm/utils.py
@@ -19,6 +19,5 @@ def update_lead_phone_numbers(contact, method):
mobile_no = primary_mobile_nos[0]
lead = frappe.get_doc("Lead", contact_lead)
- lead.phone = phone
- lead.mobile_no = mobile_no
- lead.save()
+ lead.db_set("phone", phone)
+ lead.db_set("mobile_no", mobile_no)
diff --git a/erpnext/education/desk_page/education/education.json b/erpnext/education/desk_page/education/education.json
index fc2697f0d75..b341ec4b99b 100644
--- a/erpnext/education/desk_page/education/education.json
+++ b/erpnext/education/desk_page/education/education.json
@@ -64,6 +64,11 @@
"hidden": 0,
"label": "Assessment Reports",
"links": "[\n {\n \"dependencies\": [\n \"Assessment Result\"\n ],\n \"doctype\": \"Assessment Result\",\n \"is_query_report\": true,\n \"label\": \"Course wise Assessment Report\",\n \"name\": \"Course wise Assessment Report\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Assessment Result\"\n ],\n \"doctype\": \"Assessment Result\",\n \"is_query_report\": true,\n \"label\": \"Final Assessment Grades\",\n \"name\": \"Final Assessment Grades\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Assessment Plan\"\n ],\n \"doctype\": \"Assessment Plan\",\n \"is_query_report\": true,\n \"label\": \"Assessment Plan Status\",\n \"name\": \"Assessment Plan Status\",\n \"type\": \"report\"\n },\n {\n \"label\": \"Student Report Generation Tool\",\n \"name\": \"Student Report Generation Tool\",\n \"type\": \"doctype\"\n }\n]"
+ },
+ {
+ "hidden": 0,
+ "label": "Reports",
+ "links": "[\n {\n \"dependencies\": [\n \"Fees\"\n ],\n \"doctype\": \"Fees\",\n \"is_query_report\": true,\n \"label\": \"Student Fee Collection\",\n \"name\": \"Student Fee Collection\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Student Attendance\"\n ],\n \"doctype\": \"Student Attendance\",\n \"is_query_report\": true,\n \"label\": \"Student Monthly Attendance Sheet\",\n \"name\": \"Student Monthly Attendance Sheet\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Student Attendance\"\n ],\n \"doctype\": \"Student Attendance\",\n \"is_query_report\": true,\n \"label\": \"Absent Student Report\",\n \"name\": \"Absent Student Report\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Program Enrollment\"\n ],\n \"doctype\": \"Program Enrollment\",\n \"is_query_report\": true,\n \"label\": \"Student and Guardian Contact Details\",\n \"name\": \"Student and Guardian Contact Details\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Student Attendance\"\n ],\n \"doctype\": \"Student Attendance\",\n \"is_query_report\": true,\n \"label\": \"Student Batch-Wise Attendance\",\n \"name\": \"Student Batch-Wise Attendance\",\n \"type\": \"report\"\n }\n]"
}
],
"category": "Domains",
@@ -77,7 +82,7 @@
"idx": 0,
"is_standard": 1,
"label": "Education",
- "modified": "2020-04-01 11:28:51.011309",
+ "modified": "2020-05-22 01:09:13.058482",
"modified_by": "Administrator",
"module": "Education",
"name": "Education",
diff --git a/erpnext/education/doctype/assessment_plan/assessment_plan.json b/erpnext/education/doctype/assessment_plan/assessment_plan.json
index bc3946440c3..95ed853c219 100644
--- a/erpnext/education/doctype/assessment_plan/assessment_plan.json
+++ b/erpnext/education/doctype/assessment_plan/assessment_plan.json
@@ -1,790 +1,207 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
+ "actions": [],
"allow_import": 1,
- "allow_rename": 0,
"autoname": "EDU-ASP-.YYYY.-.#####",
- "beta": 0,
"creation": "2015-11-12 16:34:34.658092",
- "custom": 0,
- "docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
- "editable_grid": 0,
"engine": "InnoDB",
+ "field_order": [
+ "student_group",
+ "assessment_name",
+ "assessment_group",
+ "grading_scale",
+ "column_break_2",
+ "course",
+ "program",
+ "academic_year",
+ "academic_term",
+ "section_break_5",
+ "schedule_date",
+ "room",
+ "examiner",
+ "examiner_name",
+ "column_break_4",
+ "from_time",
+ "to_time",
+ "supervisor",
+ "supervisor_name",
+ "section_break_20",
+ "maximum_assessment_score",
+ "assessment_criteria",
+ "amended_from"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "student_group",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
"in_global_search": 1,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Student Group",
- "length": 0,
- "no_copy": 0,
"options": "Student Group",
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "assessment_name",
"fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
"in_global_search": 1,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Assessment Name",
- "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
+ "label": "Assessment Name"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "assessment_group",
"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": 1,
"label": "Assessment Group",
- "length": 0,
- "no_copy": 0,
"options": "Assessment Group",
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "course.default_grading_scale",
+ "fetch_if_empty": 1,
"fieldname": "grading_scale",
"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": 1,
"label": "Grading Scale",
- "length": 0,
- "no_copy": 0,
"options": "Grading Scale",
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "column_break_2",
- "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,
- "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
+ "fieldtype": "Column Break"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "student_group.course",
+ "fetch_if_empty": 1,
"fieldname": "course",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
"in_global_search": 1,
- "in_list_view": 0,
"in_standard_filter": 1,
"label": "Course",
- "length": 0,
- "no_copy": 0,
"options": "Course",
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "student_group.program",
"fieldname": "program",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
"in_global_search": 1,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Program",
- "length": 0,
- "no_copy": 0,
- "options": "Program",
- "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
+ "options": "Program"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "student_group.academic_year",
"fieldname": "academic_year",
"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": "Academic Year",
- "length": 0,
- "no_copy": 0,
- "options": "Academic Year",
- "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
+ "options": "Academic Year"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "student_group.academic_term",
"fieldname": "academic_term",
"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": "Academic Term",
- "length": 0,
- "no_copy": 0,
- "options": "Academic Term",
- "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
+ "options": "Academic Term"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": "",
- "columns": 0,
- "depends_on": "",
"fieldname": "section_break_5",
"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": "Schedule",
- "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
+ "label": "Schedule"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"default": "Today",
"fieldname": "schedule_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": "Schedule Date",
- "length": 0,
"no_copy": 1,
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "room",
"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": "Room",
- "length": 0,
- "no_copy": 0,
- "options": "Room",
- "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
+ "options": "Room"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "examiner",
"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": "Examiner",
- "length": 0,
- "no_copy": 0,
- "options": "Instructor",
- "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
+ "options": "Instructor"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "examiner.instructor_name",
"fieldname": "examiner_name",
"fieldtype": "Data",
- "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": "Examiner Name",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "read_only": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "column_break_4",
- "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,
- "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
+ "fieldtype": "Column Break"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "from_time",
"fieldtype": "Time",
- "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": "From Time",
- "length": 0,
"no_copy": 1,
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "to_time",
"fieldtype": "Time",
- "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": "To Time",
- "length": 0,
"no_copy": 1,
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "supervisor",
"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": "Supervisor",
- "length": 0,
- "no_copy": 0,
- "options": "Instructor",
- "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
+ "options": "Instructor"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "supervisor.instructor_name",
"fieldname": "supervisor_name",
"fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
"in_global_search": 1,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Supervisor Name",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "read_only": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "section_break_20",
"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": "Evaluate",
- "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
+ "label": "Evaluate"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "maximum_assessment_score",
"fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Maximum Assessment Score",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "assessment_criteria",
"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": "Assessment Criteria",
- "length": 0,
- "no_copy": 0,
"options": "Assessment Plan Criteria",
- "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
+ "reqd": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Amended From",
- "length": 0,
"no_copy": 1,
"options": "Assessment Plan",
- "permlevel": 0,
"print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "read_only": 1
}
],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
"is_submittable": 1,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "menu_index": 0,
- "modified": "2018-08-30 00:48:03.475522",
+ "links": [],
+ "modified": "2020-05-09 14:56:26.746988",
"modified_by": "Administrator",
"module": "Education",
"name": "Assessment Plan",
- "name_case": "",
"owner": "Administrator",
"permissions": [
{
@@ -794,28 +211,17 @@
"delete": 1,
"email": 1,
"export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Academics User",
- "set_user_permissions": 0,
"share": 1,
"submit": 1,
"write": 1
}
],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
"restrict_to_domain": "Education",
- "show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
- "title_field": "assessment_name",
- "track_changes": 0,
- "track_seen": 0,
- "track_views": 0
+ "title_field": "assessment_name"
}
\ No newline at end of file
diff --git a/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py b/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py
new file mode 100644
index 00000000000..c36dfb11b54
--- /dev/null
+++ b/erpnext/education/doctype/assessment_plan/assessment_plan_dashboard.py
@@ -0,0 +1,17 @@
+# 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',
+ 'non_standard_fieldnames': {
+ },
+ 'transactions': [
+ {
+ 'label': _('Assessment'),
+ 'items': ['Assessment Result']
+ }
+ ]
+ }
\ No newline at end of file
diff --git a/erpnext/education/doctype/course/course_dashboard.py b/erpnext/education/doctype/course/course_dashboard.py
new file mode 100644
index 00000000000..752af29a9db
--- /dev/null
+++ b/erpnext/education/doctype/course/course_dashboard.py
@@ -0,0 +1,25 @@
+# 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',
+ 'non_standard_fieldnames': {
+ },
+ 'transactions': [
+ {
+ 'label': _('Course'),
+ 'items': ['Course Enrollment', 'Course Schedule']
+ },
+ {
+ 'label': _('Student'),
+ 'items': ['Student Group']
+ },
+ {
+ 'label': _('Assessment'),
+ 'items': ['Assessment Plan']
+ },
+ ]
+ }
\ No newline at end of file
diff --git a/erpnext/education/doctype/education_settings/education_settings.json b/erpnext/education/doctype/education_settings/education_settings.json
index 967a030fd2a..0e548dbf774 100644
--- a/erpnext/education/doctype/education_settings/education_settings.json
+++ b/erpnext/education/doctype/education_settings/education_settings.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"creation": "2017-04-05 13:33:04.519313",
"doctype": "DocType",
"editable_grid": 1,
@@ -42,12 +43,14 @@
"fieldtype": "Column Break"
},
{
+ "default": "0",
"description": "For Batch based Student Group, the Student Batch will be validated for every Student from the Program Enrollment.",
"fieldname": "validate_batch",
"fieldtype": "Check",
"label": "Validate Batch for Students in Student Group"
},
{
+ "default": "0",
"description": "For Course based Student Group, the Course will be validated for every Student from the enrolled Courses in Program Enrollment.",
"fieldname": "validate_course",
"fieldtype": "Check",
@@ -74,13 +77,13 @@
{
"fieldname": "web_academy_settings_section",
"fieldtype": "Section Break",
- "label": "LMS Settings"
+ "label": "Learning Management System Settings"
},
{
"depends_on": "eval: doc.enable_lms",
"fieldname": "portal_title",
"fieldtype": "Data",
- "label": "LMS Title"
+ "label": "Learning Management System Title"
},
{
"depends_on": "eval: doc.enable_lms",
@@ -89,9 +92,10 @@
"label": "Description"
},
{
+ "default": "0",
"fieldname": "enable_lms",
"fieldtype": "Check",
- "label": "Enable LMS"
+ "label": "Enable Learning Management System"
},
{
"default": "0",
@@ -102,7 +106,8 @@
}
],
"issingle": 1,
- "modified": "2019-05-13 18:36:13.127563",
+ "links": [],
+ "modified": "2020-05-07 19:18:10.639356",
"modified_by": "Administrator",
"module": "Education",
"name": "Education Settings",
@@ -141,4 +146,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule.json b/erpnext/education/doctype/fee_schedule/fee_schedule.json
index 1e98709b2b9..791831810ae 100644
--- a/erpnext/education/doctype/fee_schedule/fee_schedule.json
+++ b/erpnext/education/doctype/fee_schedule/fee_schedule.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2017-07-18 15:21:21.527136",
@@ -7,6 +8,7 @@
"engine": "InnoDB",
"field_order": [
"fee_structure",
+ "posting_date",
"due_date",
"naming_series",
"fee_creation_status",
@@ -259,10 +261,18 @@
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
+ },
+ {
+ "default": "Today",
+ "fieldname": "posting_date",
+ "fieldtype": "Date",
+ "label": "Posting Date",
+ "reqd": 1
}
],
"is_submittable": 1,
- "modified": "2019-05-26 09:10:34.522409",
+ "links": [],
+ "modified": "2020-05-15 08:39:20.682837",
"modified_by": "Administrator",
"module": "Education",
"name": "Fee Schedule",
diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule.py b/erpnext/education/doctype/fee_schedule/fee_schedule.py
index a42800a80d5..1543acdca98 100644
--- a/erpnext/education/doctype/fee_schedule/fee_schedule.py
+++ b/erpnext/education/doctype/fee_schedule/fee_schedule.py
@@ -87,6 +87,7 @@ def generate_fee(fee_schedule):
}
}
})
+ fees_doc.posting_date = doc.posting_date
fees_doc.student = student.student
fees_doc.student_name = student.student_name
fees_doc.program = student.program
diff --git a/erpnext/education/doctype/fees/fees.py b/erpnext/education/doctype/fees/fees.py
index f0d60faed6f..25d67d2d5f6 100644
--- a/erpnext/education/doctype/fees/fees.py
+++ b/erpnext/education/doctype/fees/fees.py
@@ -98,14 +98,16 @@ class Fees(AccountsController):
"debit_in_account_currency": self.grand_total,
"against_voucher": self.name,
"against_voucher_type": self.doctype
- })
+ }, item=self)
+
fee_gl_entry = self.get_gl_dict({
"account": self.income_account,
"against": self.student,
"credit": self.grand_total,
"credit_in_account_currency": self.grand_total,
"cost_center": self.cost_center
- })
+ }, item=self)
+
from erpnext.accounts.general_ledger import make_gl_entries
make_gl_entries([student_gl_entries, fee_gl_entry], cancel=(self.docstatus == 2),
update_outstanding="Yes", merge_entries=False)
diff --git a/erpnext/education/doctype/program_course/program_course.json b/erpnext/education/doctype/program_course/program_course.json
index a24e88a8611..940358e4e9b 100644
--- a/erpnext/education/doctype/program_course/program_course.json
+++ b/erpnext/education/doctype/program_course/program_course.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"creation": "2015-09-07 14:37:01.886859",
"doctype": "DocType",
"editable_grid": 1,
@@ -16,26 +17,33 @@
"in_list_view": 1,
"label": "Course",
"options": "Course",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
- {
+ {
+ "fetch_from": "course.course_name",
"fieldname": "course_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Course Name",
- "fetch_from": "course.course_name",
- "read_only":1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "required",
"fieldtype": "Check",
"in_list_view": 1,
- "label": "Mandatory"
+ "label": "Mandatory",
+ "show_days": 1,
+ "show_seconds": 1
}
],
"istable": 1,
- "modified": "2019-06-12 12:42:12.845972",
+ "links": [],
+ "modified": "2020-06-09 18:56:10.213241",
"modified_by": "Administrator",
"module": "Education",
"name": "Program Course",
@@ -45,4 +53,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/erpnext_integrations/connectors/shopify_connection.py b/erpnext/erpnext_integrations/connectors/shopify_connection.py
index ca0e1609cb0..d59f9092983 100644
--- a/erpnext/erpnext_integrations/connectors/shopify_connection.py
+++ b/erpnext/erpnext_integrations/connectors/shopify_connection.py
@@ -95,10 +95,10 @@ def create_sales_order(shopify_order, shopify_settings, company=None):
items = get_order_items(shopify_order.get("line_items"), shopify_settings)
if not items:
- message = 'Following items are exists in order but relevant record not found in Product master'
+ message = 'Following items exists in the shopify order but relevant records were not found in the shopify Product master'
message += "\n" + ", ".join(product_not_exists)
- make_shopify_log(status="Error", exception=e, rollback=True)
+ make_shopify_log(status="Error", exception=message, rollback=True)
return ''
@@ -241,14 +241,17 @@ def get_order_taxes(shopify_order, shopify_settings):
return taxes
def update_taxes_with_shipping_lines(taxes, shipping_lines, shopify_settings):
+ """Shipping lines represents the shipping details,
+ each such shipping detail consists of a list of tax_lines"""
for shipping_charge in shipping_lines:
- taxes.append({
- "charge_type": _("Actual"),
- "account_head": get_tax_account_head(shipping_charge),
- "description": shipping_charge["title"],
- "tax_amount": shipping_charge["price"],
- "cost_center": shopify_settings.cost_center
- })
+ for tax in shipping_charge.get("tax_lines"):
+ taxes.append({
+ "charge_type": _("Actual"),
+ "account_head": get_tax_account_head(tax),
+ "description": tax["title"],
+ "tax_amount": tax["price"],
+ "cost_center": shopify_settings.cost_center
+ })
return taxes
diff --git a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
index 618865200cf..1b0c9f60b6e 100644
--- a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
+++ b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py
@@ -49,12 +49,13 @@ def _order(*args, **kwargs):
if event == "created":
sys_lang = frappe.get_single("System Settings").language or 'en'
raw_billing_data = order.get("billing")
+ raw_shipping_data = order.get("shipping")
customer_name = raw_billing_data.get("first_name") + " " + raw_billing_data.get("last_name")
- link_customer_and_address(raw_billing_data, customer_name)
+ link_customer_and_address(raw_billing_data, raw_shipping_data, customer_name)
link_items(order.get("line_items"), woocommerce_settings, sys_lang)
create_sales_order(order, woocommerce_settings, customer_name, sys_lang)
-def link_customer_and_address(raw_billing_data, customer_name):
+def link_customer_and_address(raw_billing_data, raw_shipping_data, customer_name):
customer_woo_com_email = raw_billing_data.get("email")
customer_exists = frappe.get_value("Customer", {"woocommerce_email": customer_woo_com_email})
if not customer_exists:
@@ -68,38 +69,74 @@ def link_customer_and_address(raw_billing_data, customer_name):
customer.customer_name = customer_name
customer.woocommerce_email = customer_woo_com_email
customer.flags.ignore_mandatory = True
- customer.save()
+ customer.save()
if customer_exists:
frappe.rename_doc("Customer", old_name, customer_name)
- address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email})
+ billing_address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email, "address_type": "Billing"})
+ shipping_address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email, "address_type": "Shipping"})
+ rename_address(billing_address, customer)
+ rename_address(shipping_address, customer)
else:
- address = frappe.new_doc("Address")
+ create_address(raw_billing_data, customer, "Billing")
+ create_address(raw_shipping_data, customer, "Shipping")
+ create_contact(raw_billing_data, customer)
- address.address_line1 = raw_billing_data.get("address_1", "Not Provided")
- address.address_line2 = raw_billing_data.get("address_2", "Not Provided")
- address.city = raw_billing_data.get("city", "Not Provided")
- address.woocommerce_email = customer_woo_com_email
- address.address_type = "Billing"
- address.country = frappe.get_value("Country", {"code": raw_billing_data.get("country", "IN").lower()})
- address.state = raw_billing_data.get("state")
- address.pincode = raw_billing_data.get("postcode")
- address.phone = raw_billing_data.get("phone")
- address.email_id = customer_woo_com_email
+def create_contact(data, customer):
+ email = data.get("email", None)
+ phone = data.get("phone", None)
+
+ if not email and not phone:
+ return
+
+ contact = frappe.new_doc("Contact")
+ contact.first_name = data.get("first_name")
+ contact.last_name = data.get("last_name")
+ contact.is_primary_contact = 1
+ contact.is_billing_contact = 1
+
+ if phone:
+ contact.add_phone(phone, is_primary_mobile_no=1, is_primary_phone=1)
+
+ if email:
+ contact.add_email(email, is_primary=1)
+
+ contact.append("links", {
+ "link_doctype": "Customer",
+ "link_name": customer.name
+ })
+
+ contact.flags.ignore_mandatory = True
+ contact.save()
+
+def create_address(raw_data, customer, address_type):
+ address = frappe.new_doc("Address")
+
+ address.address_line1 = raw_data.get("address_1", "Not Provided")
+ address.address_line2 = raw_data.get("address_2", "Not Provided")
+ address.city = raw_data.get("city", "Not Provided")
+ address.woocommerce_email = customer.woocommerce_email
+ address.address_type = address_type
+ address.country = frappe.get_value("Country", {"code": raw_data.get("country", "IN").lower()})
+ address.state = raw_data.get("state")
+ address.pincode = raw_data.get("postcode")
+ address.phone = raw_data.get("phone")
+ address.email_id = customer.woocommerce_email
address.append("links", {
"link_doctype": "Customer",
- "link_name": customer.customer_name
+ "link_name": customer.name
})
+
address.flags.ignore_mandatory = True
- address = address.save()
+ address.save()
- if customer_exists:
- old_address_title = address.name
- new_address_title = customer.customer_name + "-billing"
- address.address_title = customer.customer_name
- address.save()
+def rename_address(address, customer):
+ old_address_title = address.name
+ new_address_title = customer.name + "-" + address.address_type
+ address.address_title = customer.customer_name
+ address.save()
- frappe.rename_doc("Address", old_address_title, new_address_title)
+ frappe.rename_doc("Address", old_address_title, new_address_title)
def link_items(items_list, woocommerce_settings, sys_lang):
for item_data in items_list:
@@ -111,7 +148,7 @@ def link_items(items_list, woocommerce_settings, sys_lang):
else:
#Create Item
item = frappe.new_doc("Item")
-
+
item.item_name = item_data.get("name")
item.item_code = _("woocommerce - {0}", sys_lang).format(item_data.get("product_id"))
item.woocommerce_id = item_data.get("product_id")
@@ -145,7 +182,8 @@ def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_l
company_abbr = frappe.db.get_value('Company', woocommerce_settings.company, 'abbr')
default_warehouse = _("Stores - {0}", sys_lang).format(company_abbr)
- if not frappe.db.exists("Warehouse", default_warehouse):
+ if not frappe.db.exists("Warehouse", default_warehouse) \
+ and not woocommerce_settings.warehouse:
frappe.throw(_("Please set Warehouse in Woocommerce Settings"))
for item in order.get("line_items"):
@@ -171,7 +209,7 @@ def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_l
add_tax_details(new_sales_order, order.get("shipping_tax"), "Shipping Tax", woocommerce_settings.f_n_f_account)
add_tax_details(new_sales_order, order.get("shipping_total"), "Shipping Total", woocommerce_settings.f_n_f_account)
-
+
def add_tax_details(sales_order, price, desc, tax_account_head):
sales_order.append("taxes", {
"charge_type":"Actual",
diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py
index b4a5bd11a04..c3371ed5dfb 100644
--- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py
+++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py
@@ -124,10 +124,11 @@ def add_account_subtype(account_subtype):
@frappe.whitelist()
def sync_transactions(bank, bank_account):
-
- last_sync_date = frappe.db.get_value("Bank Account", bank_account, "last_integration_date")
- if last_sync_date:
- start_date = formatdate(last_sync_date, "YYYY-MM-dd")
+ '''Sync transactions based on the last integration date as the start date, after the sync is completed
+ add the transaction date of the oldest transaction as the last integration date'''
+ last_transaction_date = frappe.db.get_value("Bank Account", bank_account, "last_integration_date")
+ if last_transaction_date:
+ start_date = formatdate(last_transaction_date, "YYYY-MM-dd")
else:
start_date = formatdate(add_months(today(), -12), "YYYY-MM-dd")
end_date = formatdate(today(), "YYYY-MM-dd")
@@ -139,12 +140,14 @@ def sync_transactions(bank, bank_account):
for transaction in reversed(transactions):
result += new_bank_transaction(transaction)
- frappe.logger().info("Plaid added {} new Bank Transactions from '{}' between {} and {}".format(
- len(result), bank_account, start_date, end_date))
+ if result:
+ last_transaction_date = frappe.db.get_value('Bank Transaction', result.pop(), 'date')
- frappe.db.set_value("Bank Account", bank_account, "last_integration_date", getdate(end_date))
+ frappe.logger().info("Plaid added {} new Bank Transactions from '{}' between {} and {}".format(
+ len(result), bank_account, start_date, end_date))
+
+ frappe.db.set_value("Bank Account", bank_account, "last_integration_date", last_transaction_date)
- return result
except Exception:
frappe.log_error(frappe.get_traceback(), _("Plaid transactions sync error"))
@@ -209,7 +212,7 @@ def new_bank_transaction(transaction):
result.append(new_transaction.name)
except Exception:
- frappe.throw(frappe.get_traceback())
+ frappe.throw(title=_('Bank transaction creation error'))
return result
diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json
index 8f1b746e5b6..5339c99155b 100644
--- a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json
+++ b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json
@@ -133,7 +133,7 @@
"label": "Customer Settings"
},
{
- "description": "If Shopify not contains a customer in Order, then while syncing Orders, the system will consider default customer for order",
+ "description": "If Shopify does not have a customer in the order, then while syncing the orders, the system will consider the default customer for the order",
"fieldname": "default_customer",
"fieldtype": "Link",
"label": "Default Customer",
@@ -258,7 +258,7 @@
}
],
"issingle": 1,
- "modified": "2019-09-13 12:32:11.384757",
+ "modified": "2020-05-28 12:32:11.384757",
"modified_by": "umair@erpnext.com",
"module": "ERPNext Integrations",
"name": "Shopify Settings",
@@ -277,4 +277,4 @@
],
"sort_field": "modified",
"sort_order": "DESC"
-}
\ No newline at end of file
+}
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
index d84c8234efa..fd16d1e84aa 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
@@ -1,7 +1,9 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Tally Migration', {
+frappe.provide("erpnext.tally_migration");
+
+frappe.ui.form.on("Tally Migration", {
onload: function (frm) {
let reload_status = true;
frappe.realtime.on("tally_migration_progress_update", function (data) {
@@ -35,7 +37,17 @@ frappe.ui.form.on('Tally Migration', {
}
});
},
+
refresh: function (frm) {
+ frm.trigger("show_logs_preview");
+ erpnext.tally_migration.failed_import_log = JSON.parse(frm.doc.failed_import_log);
+ erpnext.tally_migration.fixed_errors_log = JSON.parse(frm.doc.fixed_errors_log);
+
+ ["default_round_off_account", "default_warehouse", "default_cost_center"].forEach(account => {
+ frm.toggle_reqd(account, frm.doc.is_master_data_imported === 1)
+ frm.toggle_enable(account, frm.doc.is_day_book_data_processed != 1)
+ })
+
if (frm.doc.master_data && !frm.doc.is_master_data_imported) {
if (frm.doc.is_master_data_processed) {
if (frm.doc.status != "Importing Master Data") {
@@ -47,6 +59,7 @@ frappe.ui.form.on('Tally Migration', {
}
}
}
+
if (frm.doc.day_book_data && !frm.doc.is_day_book_data_imported) {
if (frm.doc.is_day_book_data_processed) {
if (frm.doc.status != "Importing Day Book Data") {
@@ -59,6 +72,17 @@ frappe.ui.form.on('Tally Migration', {
}
}
},
+
+ erpnext_company: function (frm) {
+ frappe.db.exists("Company", frm.doc.erpnext_company).then(exists => {
+ if (exists) {
+ frappe.msgprint(
+ __("Company {0} already exists. Continuing will overwrite the Company and Chart of Accounts", [frm.doc.erpnext_company]),
+ );
+ }
+ });
+ },
+
add_button: function (frm, label, method) {
frm.add_custom_button(
label,
@@ -71,5 +95,255 @@ frappe.ui.form.on('Tally Migration', {
frm.reload_doc();
}
);
+ },
+
+ render_html_table(frm, shown_logs, hidden_logs, field) {
+ if (shown_logs && shown_logs.length > 0) {
+ frm.toggle_display(field, true);
+ } else {
+ frm.toggle_display(field, false);
+ return
+ }
+ let rows = erpnext.tally_migration.get_html_rows(shown_logs, field);
+ let rows_head, table_caption;
+
+ let table_footer = (hidden_logs && (hidden_logs.length > 0)) ? `
+ And ${hidden_logs.length} more others
+ `: "";
+
+ if (field === "fixed_error_log_preview") {
+ rows_head = `${__("Meta Data")}
+ ${__("Unresolve")} `
+ table_caption = "Resolved Issues"
+ } else {
+ rows_head = `${__("Error Message")}
+ ${__("Create")} `
+ table_caption = "Error Log"
+ }
+
+ frm.get_field(field).$wrapper.html(`
+
+ ${table_caption}
+
+ ${__("#")}
+ ${__("DocType")}
+ ${rows_head}
+
+ ${rows}
+ ${table_footer}
+
+ `);
+ },
+
+ show_error_summary(frm) {
+ let summary = erpnext.tally_migration.failed_import_log.reduce((summary, row) => {
+ if (row.doc) {
+ if (summary[row.doc.doctype]) {
+ summary[row.doc.doctype] += 1;
+ } else {
+ summary[row.doc.doctype] = 1;
+ }
+ }
+ return summary
+ }, {});
+ console.table(summary);
+ },
+
+ show_logs_preview(frm) {
+ let empty = "[]";
+ let import_log = frm.doc.failed_import_log || empty;
+ let completed_log = frm.doc.fixed_errors_log || empty;
+ let render_section = !(import_log === completed_log && import_log === empty);
+
+ frm.toggle_display("import_log_section", render_section);
+ if (render_section) {
+ frm.trigger("show_error_summary");
+ frm.trigger("show_errored_import_log");
+ frm.trigger("show_fixed_errors_log");
+ }
+ },
+
+ show_errored_import_log(frm) {
+ let import_log = erpnext.tally_migration.failed_import_log;
+ let logs = import_log.slice(0, 20);
+ let hidden_logs = import_log.slice(20);
+
+ frm.events.render_html_table(frm, logs, hidden_logs, "failed_import_preview");
+ },
+
+ show_fixed_errors_log(frm) {
+ let completed_log = erpnext.tally_migration.fixed_errors_log;
+ let logs = completed_log.slice(0, 20);
+ let hidden_logs = completed_log.slice(20);
+
+ frm.events.render_html_table(frm, logs, hidden_logs, "fixed_error_log_preview");
}
});
+
+erpnext.tally_migration.getError = (traceback) => {
+ /* Extracts the Error Message from the Python Traceback or Solved error */
+ let is_multiline = traceback.trim().indexOf("\n") != -1;
+ let message;
+
+ if (is_multiline) {
+ let exc_error_idx = traceback.trim().lastIndexOf("\n") + 1
+ let error_line = traceback.substr(exc_error_idx)
+ let split_str_idx = (error_line.indexOf(':') > 0) ? error_line.indexOf(':') + 1 : 0;
+ message = error_line.slice(split_str_idx).trim();
+ } else {
+ message = traceback;
+ }
+
+ return message
+}
+
+erpnext.tally_migration.cleanDoc = (obj) => {
+ /* Strips all null and empty values of your JSON object */
+ let temp = obj;
+ $.each(temp, function(key, value){
+ if (value === "" || value === null){
+ delete obj[key];
+ } else if (Object.prototype.toString.call(value) === '[object Object]') {
+ erpnext.tally_migration.cleanDoc(value);
+ } else if ($.isArray(value)) {
+ $.each(value, function (k,v) { erpnext.tally_migration.cleanDoc(v); });
+ }
+ });
+ return temp;
+}
+
+erpnext.tally_migration.unresolve = (document) => {
+ /* Mark document migration as unresolved ie. move to failed error log */
+ let frm = cur_frm;
+ let failed_log = erpnext.tally_migration.failed_import_log;
+ let fixed_log = erpnext.tally_migration.fixed_errors_log;
+
+ let modified_fixed_log = fixed_log.filter(row => {
+ if (!frappe.utils.deep_equal(erpnext.tally_migration.cleanDoc(row.doc), document)) {
+ return row
+ }
+ });
+
+ failed_log.push({ doc: document, exc: `Marked unresolved on ${Date()}` });
+
+ frm.doc.failed_import_log = JSON.stringify(failed_log);
+ frm.doc.fixed_errors_log = JSON.stringify(modified_fixed_log);
+
+ frm.dirty();
+ frm.save();
+}
+
+erpnext.tally_migration.resolve = (document) => {
+ /* Mark document migration as resolved ie. move to fixed error log */
+ let frm = cur_frm;
+ let failed_log = erpnext.tally_migration.failed_import_log;
+ let fixed_log = erpnext.tally_migration.fixed_errors_log;
+
+ let modified_failed_log = failed_log.filter(row => {
+ if (!frappe.utils.deep_equal(erpnext.tally_migration.cleanDoc(row.doc), document)) {
+ return row
+ }
+ });
+ fixed_log.push({ doc: document, exc: `Solved on ${Date()}` });
+
+ frm.doc.failed_import_log = JSON.stringify(modified_failed_log);
+ frm.doc.fixed_errors_log = JSON.stringify(fixed_log);
+
+ frm.dirty();
+ frm.save();
+}
+
+erpnext.tally_migration.create_new_doc = (document) => {
+ /* Mark as resolved and create new document */
+ erpnext.tally_migration.resolve(document);
+ return frappe.call({
+ type: "POST",
+ method: 'erpnext.erpnext_integrations.doctype.tally_migration.tally_migration.new_doc',
+ args: {
+ document
+ },
+ freeze: true,
+ callback: function(r) {
+ if(!r.exc) {
+ frappe.model.sync(r.message);
+ frappe.get_doc(r.message.doctype, r.message.name).__run_link_triggers = true;
+ frappe.set_route("Form", r.message.doctype, r.message.name);
+ }
+ }
+ });
+}
+
+erpnext.tally_migration.get_html_rows = (logs, field) => {
+ let index = 0;
+ let rows = logs
+ .map(({ doc, exc }) => {
+ let id = frappe.dom.get_unique_id();
+ let traceback = exc;
+
+ let error_message = erpnext.tally_migration.getError(traceback);
+ index++;
+
+ let show_traceback = `
+
+ ${__("Show Traceback")}
+
+ `;
+
+ let show_doc = `
+
+ ${__("Show Document")}
+
+
+
+
${JSON.stringify(erpnext.tally_migration.cleanDoc(doc), null, 1)}
+
+
`;
+
+ let create_button = `
+
+ ${__("Create Document")}
+ `
+
+ let mark_as_unresolved = `
+
+ ${__("Mark as unresolved")}
+ `
+
+ if (field === "fixed_error_log_preview") {
+ return `
+ ${index}
+
+ ${doc.doctype}
+
+
+ ${error_message}
+ ${show_doc}
+
+
+ ${mark_as_unresolved}
+
+ `;
+ } else {
+ return `
+ ${index}
+
+ ${doc.doctype}
+
+
+ ${error_message}
+ ${show_traceback}
+ ${show_doc}
+
+
+ ${create_button}
+
+ `;
+ }
+ }).join("");
+
+ return rows
+}
\ No newline at end of file
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
index dc6f093ac9d..417d9437926 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
@@ -28,14 +28,19 @@
"vouchers",
"accounts_section",
"default_warehouse",
- "round_off_account",
+ "default_round_off_account",
"column_break_21",
"default_cost_center",
"day_book_section",
"day_book_data",
"column_break_27",
"is_day_book_data_processed",
- "is_day_book_data_imported"
+ "is_day_book_data_imported",
+ "import_log_section",
+ "failed_import_log",
+ "fixed_errors_log",
+ "failed_import_preview",
+ "fixed_error_log_preview"
],
"fields": [
{
@@ -57,6 +62,7 @@
"fieldname": "tally_creditors_account",
"fieldtype": "Data",
"label": "Tally Creditors Account",
+ "read_only_depends_on": "eval:doc.is_master_data_processed==1",
"reqd": 1
},
{
@@ -69,6 +75,7 @@
"fieldname": "tally_debtors_account",
"fieldtype": "Data",
"label": "Tally Debtors Account",
+ "read_only_depends_on": "eval:doc.is_master_data_processed==1",
"reqd": 1
},
{
@@ -92,7 +99,7 @@
"fieldname": "erpnext_company",
"fieldtype": "Data",
"label": "ERPNext Company",
- "read_only_depends_on": "eval:doc.is_master_data_processed == 1"
+ "read_only_depends_on": "eval:doc.is_master_data_processed==1"
},
{
"fieldname": "processed_files_section",
@@ -136,6 +143,7 @@
},
{
"depends_on": "is_master_data_imported",
+ "description": "The accounts are set by the system automatically but do confirm these defaults",
"fieldname": "accounts_section",
"fieldtype": "Section Break",
"label": "Accounts"
@@ -146,12 +154,6 @@
"label": "Default Warehouse",
"options": "Warehouse"
},
- {
- "fieldname": "round_off_account",
- "fieldtype": "Link",
- "label": "Round Off Account",
- "options": "Account"
- },
{
"fieldname": "column_break_21",
"fieldtype": "Column Break"
@@ -212,11 +214,47 @@
"fieldname": "default_uom",
"fieldtype": "Link",
"label": "Default UOM",
- "options": "UOM"
+ "options": "UOM",
+ "read_only_depends_on": "eval:doc.is_master_data_imported==1"
+ },
+ {
+ "default": "[]",
+ "fieldname": "failed_import_log",
+ "fieldtype": "Code",
+ "hidden": 1,
+ "options": "JSON"
+ },
+ {
+ "fieldname": "failed_import_preview",
+ "fieldtype": "HTML",
+ "label": "Failed Import Log"
+ },
+ {
+ "fieldname": "import_log_section",
+ "fieldtype": "Section Break",
+ "label": "Import Log"
+ },
+ {
+ "fieldname": "default_round_off_account",
+ "fieldtype": "Link",
+ "label": "Default Round Off Account",
+ "options": "Account"
+ },
+ {
+ "default": "[]",
+ "fieldname": "fixed_errors_log",
+ "fieldtype": "Code",
+ "hidden": 1,
+ "options": "JSON"
+ },
+ {
+ "fieldname": "fixed_error_log_preview",
+ "fieldtype": "HTML",
+ "label": "Fixed Error Log"
}
],
"links": [],
- "modified": "2020-04-16 13:03:28.894919",
+ "modified": "2020-04-28 00:29:18.039826",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "Tally Migration",
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
index 13474e19ee1..462685f5e71 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import json
import re
+import sys
import traceback
import zipfile
from decimal import Decimal
@@ -15,18 +16,34 @@ 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 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
-
PRIMARY_ACCOUNT = "Primary"
VOUCHER_CHUNK_SIZE = 500
+@frappe.whitelist()
+def new_doc(document):
+ document = json.loads(document)
+ doctype = document.pop("doctype")
+ document.pop("name", None)
+ doc = frappe.new_doc(doctype)
+ doc.update(document)
+
+ return doc
+
class TallyMigration(Document):
+ def validate(self):
+ failed_import_log = json.loads(self.failed_import_log)
+ sorted_failed_import_log = sorted(failed_import_log, key=lambda row: row["doc"]["creation"])
+ self.failed_import_log = json.dumps(sorted_failed_import_log)
+
def autoname(self):
if not self.name:
self.name = "Tally Migration on " + format_datetime(self.creation)
@@ -65,9 +82,17 @@ class TallyMigration(Document):
"attached_to_name": self.name,
"content": json.dumps(value),
"is_private": True
- }).insert()
+ })
+ try:
+ f.insert()
+ except frappe.DuplicateEntryError:
+ pass
setattr(self, key, f.file_url)
+ def set_account_defaults(self):
+ self.default_cost_center, self.default_round_off_account = frappe.db.get_value("Company", self.erpnext_company, ["cost_center", "round_off_account"])
+ self.default_warehouse = frappe.db.get_value("Stock Settings", "Stock Settings", "default_warehouse")
+
def _process_master_data(self):
def get_company_name(collection):
return collection.find_all("REMOTECMPINFO.LIST")[0].REMOTECMPNAME.string.strip()
@@ -84,7 +109,11 @@ class TallyMigration(Document):
children, parents = get_children_and_parent_dict(accounts)
group_set = [acc[1] for acc in accounts if acc[2]]
children, customers, suppliers = remove_parties(parents, children, group_set)
- coa = traverse({}, children, roots, roots, group_set)
+
+ try:
+ coa = traverse({}, children, roots, roots, group_set)
+ except RecursionError:
+ self.log(_("Error occured while parsing Chart of Accounts: Please make sure that no two accounts have the same name"))
for account in coa:
coa[account]["root_type"] = root_type_map[account]
@@ -126,14 +155,18 @@ class TallyMigration(Document):
def remove_parties(parents, children, group_set):
customers, suppliers = set(), set()
for account in parents:
+ found = False
if self.tally_creditors_account in parents[account]:
- children.pop(account, None)
+ found = True
if account not in group_set:
suppliers.add(account)
- elif self.tally_debtors_account in parents[account]:
- children.pop(account, None)
+ if self.tally_debtors_account in parents[account]:
+ found = True
if account not in group_set:
customers.add(account)
+ if found:
+ children.pop(account, None)
+
return children, customers, suppliers
def traverse(tree, children, accounts, roots, group_set):
@@ -151,6 +184,7 @@ class TallyMigration(Document):
parties, addresses = [], []
for account in collection.find_all("LEDGER"):
party_type = None
+ links = []
if account.NAME.string.strip() in customers:
party_type = "Customer"
parties.append({
@@ -161,7 +195,9 @@ class TallyMigration(Document):
"territory": "All Territories",
"customer_type": "Individual",
})
- elif account.NAME.string.strip() in suppliers:
+ links.append({"link_doctype": party_type, "link_name": account["NAME"]})
+
+ if account.NAME.string.strip() in suppliers:
party_type = "Supplier"
parties.append({
"doctype": party_type,
@@ -170,6 +206,8 @@ class TallyMigration(Document):
"supplier_group": "All Supplier Groups",
"supplier_type": "Individual",
})
+ links.append({"link_doctype": party_type, "link_name": account["NAME"]})
+
if party_type:
address = "\n".join([a.string.strip() for a in account.find_all("ADDRESS")])
addresses.append({
@@ -183,7 +221,7 @@ class TallyMigration(Document):
"mobile": account.LEDGERPHONE.string.strip() if account.LEDGERPHONE else None,
"phone": account.LEDGERPHONE.string.strip() if account.LEDGERPHONE else None,
"gstin": account.PARTYGSTIN.string.strip() if account.PARTYGSTIN else None,
- "links": [{"link_doctype": party_type, "link_name": account["NAME"]}],
+ "links": links
})
return parties, addresses
@@ -242,12 +280,18 @@ class TallyMigration(Document):
def create_company_and_coa(coa_file_url):
coa_file = frappe.get_doc("File", {"file_url": coa_file_url})
frappe.local.flags.ignore_chart_of_accounts = True
- company = frappe.get_doc({
- "doctype": "Company",
- "company_name": self.erpnext_company,
- "default_currency": "INR",
- "enable_perpetual_inventory": 0,
- }).insert()
+
+ try:
+ company = frappe.get_doc({
+ "doctype": "Company",
+ "company_name": self.erpnext_company,
+ "default_currency": "INR",
+ "enable_perpetual_inventory": 0,
+ }).insert()
+ except frappe.DuplicateEntryError:
+ company = frappe.get_doc("Company", self.erpnext_company)
+ unset_existing_data(self.erpnext_company)
+
frappe.local.flags.ignore_chart_of_accounts = False
create_charts(company.name, custom_chart=json.loads(coa_file.get_content()))
company.create_default_warehouses()
@@ -256,36 +300,35 @@ class TallyMigration(Document):
parties_file = frappe.get_doc("File", {"file_url": parties_file_url})
for party in json.loads(parties_file.get_content()):
try:
- frappe.get_doc(party).insert()
+ party_doc = frappe.get_doc(party)
+ party_doc.insert()
except:
- self.log(party)
+ 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:
- frappe.get_doc(address).insert(ignore_mandatory=True)
+ address_doc = frappe.get_doc(address)
+ address_doc.insert(ignore_mandatory=True)
except:
- try:
- gstin = address.pop("gstin", None)
- frappe.get_doc(address).insert(ignore_mandatory=True)
- self.log({"address": address, "message": "Invalid GSTIN: {}. Address was created without GSTIN".format(gstin)})
- except:
- self.log(address)
+ self.log(address_doc)
def create_items_uoms(items_file_url, uoms_file_url):
uoms_file = frappe.get_doc("File", {"file_url": uoms_file_url})
for uom in json.loads(uoms_file.get_content()):
if not frappe.db.exists(uom):
try:
- frappe.get_doc(uom).insert()
+ uom_doc = frappe.get_doc(uom)
+ uom_doc.insert()
except:
- self.log(uom)
+ self.log(uom_doc)
items_file = frappe.get_doc("File", {"file_url": items_file_url})
for item in json.loads(items_file.get_content()):
try:
- frappe.get_doc(item).insert()
+ item_doc = frappe.get_doc(item)
+ item_doc.insert()
except:
- self.log(item)
+ self.log(item_doc)
try:
self.publish("Import Master Data", _("Creating Company and Importing Chart of Accounts"), 1, 4)
@@ -299,10 +342,13 @@ class TallyMigration(Document):
self.publish("Import Master Data", _("Done"), 4, 4)
+ self.set_account_defaults()
self.is_master_data_imported = 1
+ frappe.db.commit()
except:
self.publish("Import Master Data", _("Process Failed"), -1, 5)
+ frappe.db.rollback()
self.log()
finally:
@@ -323,7 +369,9 @@ class TallyMigration(Document):
processed_voucher = function(voucher)
if processed_voucher:
vouchers.append(processed_voucher)
+ frappe.db.commit()
except:
+ frappe.db.rollback()
self.log(voucher)
return vouchers
@@ -349,6 +397,7 @@ class TallyMigration(Document):
journal_entry = {
"doctype": "Journal Entry",
"tally_guid": voucher.GUID.string.strip(),
+ "tally_voucher_no": voucher.VOUCHERNUMBER.string.strip() if voucher.VOUCHERNUMBER else "",
"posting_date": voucher.DATE.string.strip(),
"company": self.erpnext_company,
"accounts": accounts,
@@ -377,6 +426,7 @@ class TallyMigration(Document):
"doctype": doctype,
party_field: voucher.PARTYNAME.string.strip(),
"tally_guid": voucher.GUID.string.strip(),
+ "tally_voucher_no": voucher.VOUCHERNUMBER.string.strip() if voucher.VOUCHERNUMBER else "",
"posting_date": voucher.DATE.string.strip(),
"due_date": voucher.DATE.string.strip(),
"items": get_voucher_items(voucher, doctype),
@@ -468,14 +518,21 @@ class TallyMigration(Document):
oldest_year = new_year
def create_custom_fields(doctypes):
- for doctype in doctypes:
- df = {
- "fieldtype": "Data",
- "fieldname": "tally_guid",
- "read_only": 1,
- "label": "Tally GUID"
- }
- create_custom_field(doctype, df)
+ tally_guid_df = {
+ "fieldtype": "Data",
+ "fieldname": "tally_guid",
+ "read_only": 1,
+ "label": "Tally GUID"
+ }
+ tally_voucher_no_df = {
+ "fieldtype": "Data",
+ "fieldname": "tally_voucher_no",
+ "read_only": 1,
+ "label": "Tally Voucher Number"
+ }
+ for df in [tally_guid_df, tally_voucher_no_df]:
+ for doctype in doctypes:
+ create_custom_field(doctype, df)
def create_price_list():
frappe.get_doc({
@@ -490,7 +547,7 @@ class TallyMigration(Document):
try:
frappe.db.set_value("Account", encode_company_abbr(self.tally_creditors_account, self.erpnext_company), "account_type", "Payable")
frappe.db.set_value("Account", encode_company_abbr(self.tally_debtors_account, self.erpnext_company), "account_type", "Receivable")
- frappe.db.set_value("Company", self.erpnext_company, "round_off_account", self.round_off_account)
+ frappe.db.set_value("Company", self.erpnext_company, "round_off_account", self.default_round_off_account)
vouchers_file = frappe.get_doc("File", {"file_url": self.vouchers})
vouchers = json.loads(vouchers_file.get_content())
@@ -521,11 +578,14 @@ class TallyMigration(Document):
for index, voucher in enumerate(chunk, start=start):
try:
- doc = frappe.get_doc(voucher).insert()
- doc.submit()
+ voucher_doc = frappe.get_doc(voucher)
+ voucher_doc.insert()
+ voucher_doc.submit()
self.publish("Importing Vouchers", _("{} of {}").format(index, total), index, total)
+ frappe.db.commit()
except:
- self.log(voucher)
+ frappe.db.rollback()
+ self.log(voucher_doc)
if is_last:
self.status = ""
@@ -551,9 +611,22 @@ class TallyMigration(Document):
frappe.enqueue_doc(self.doctype, self.name, "_import_day_book_data", queue="long", timeout=3600)
def log(self, data=None):
- data = data or self.status
- message = "\n".join(["Data:", json.dumps(data, default=str, indent=4), "--" * 50, "\nException:", traceback.format_exc()])
- return frappe.log_error(title="Tally Migration Error", message=message)
+ if isinstance(data, frappe.model.document.Document):
+ if sys.exc_info()[1].__class__ != frappe.DuplicateEntryError:
+ failed_import_log = json.loads(self.failed_import_log)
+ doc = data.as_dict()
+ failed_import_log.append({
+ "doc": doc,
+ "exc": traceback.format_exc()
+ })
+ self.failed_import_log = json.dumps(failed_import_log, separators=(',', ':'))
+ self.save()
+ frappe.db.commit()
+
+ else:
+ data = data or self.status
+ message = "\n".join(["Data:", json.dumps(data, default=str, indent=4), "--" * 50, "\nException:", traceback.format_exc()])
+ return frappe.log_error(title="Tally Migration Error", message=message)
def set_status(self, status=""):
self.status = status
diff --git a/erpnext/stock/report/purchase_order_items_to_be_received_or_billed/__init__.py b/erpnext/healthcare/dashboard_chart_source/__init__.py
similarity index 100%
rename from erpnext/stock/report/purchase_order_items_to_be_received_or_billed/__init__.py
rename to erpnext/healthcare/dashboard_chart_source/__init__.py
diff --git a/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/__init__.py b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.js b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.js
new file mode 100644
index 00000000000..dd6dc666d23
--- /dev/null
+++ b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.js
@@ -0,0 +1,14 @@
+frappe.provide('frappe.dashboards.chart_sources');
+
+frappe.dashboards.chart_sources["Department wise Patient Appointments"] = {
+ method: "erpnext.healthcare.dashboard_chart_source.department_wise_patient_appointments.department_wise_patient_appointments.get",
+ filters: [
+ {
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company")
+ }
+ ]
+};
\ No newline at end of file
diff --git a/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.json b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.json
new file mode 100644
index 00000000000..00301ef2c36
--- /dev/null
+++ b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.json
@@ -0,0 +1,13 @@
+{
+ "creation": "2020-05-18 19:18:42.571045",
+ "docstatus": 0,
+ "doctype": "Dashboard Chart Source",
+ "idx": 0,
+ "modified": "2020-05-18 19:18:42.571045",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Department wise Patient Appointments",
+ "owner": "Administrator",
+ "source_name": "Department wise Patient Appointments",
+ "timeseries": 0
+}
\ 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
new file mode 100644
index 00000000000..062da6e4654
--- /dev/null
+++ b/erpnext/healthcare/dashboard_chart_source/department_wise_patient_appointments/department_wise_patient_appointments.py
@@ -0,0 +1,72 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# 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,
+ to_date = None, timespan = None, time_interval = None, heatmap_year = None):
+ if chart_name:
+ chart = frappe.get_doc('Dashboard Chart', chart_name)
+ else:
+ chart = frappe._dict(frappe.parse_json(chart))
+
+ filters = frappe.parse_json(filters)
+
+ data = frappe.db.get_list('Medical Department', fields=['name'])
+ if not filters:
+ filters = {}
+
+ status = ['Open', 'Scheduled', 'Closed', 'Cancelled']
+ for department in data:
+ filters['department'] = department.name
+ department['total_appointments'] = frappe.db.count('Patient Appointment', filters=filters)
+
+ for entry in status:
+ filters['status'] = entry
+ department[frappe.scrub(entry)] = frappe.db.count('Patient Appointment', filters=filters)
+ filters.pop('status')
+
+ sorted_department_map = sorted(data, key = lambda i: i['total_appointments'], reverse=True)
+
+ if len(sorted_department_map) > 10:
+ sorted_department_map = sorted_department_map[:10]
+
+ labels = []
+ open_appointments = []
+ scheduled = []
+ closed = []
+ cancelled = []
+
+ for department in sorted_department_map:
+ labels.append(department.name)
+ open_appointments.append(department.open)
+ scheduled.append(department.scheduled)
+ closed.append(department.closed)
+ cancelled.append(department.cancelled)
+
+ return {
+ 'labels': labels,
+ 'datasets': [
+ {
+ 'name': 'Open',
+ 'values': open_appointments
+ },
+ {
+ 'name': 'Scheduled',
+ 'values': scheduled
+ },
+ {
+ 'name': 'Closed',
+ 'values': closed
+ },
+ {
+ 'name': 'Cancelled',
+ 'values': cancelled
+ }
+ ],
+ 'type': 'bar'
+ }
\ No newline at end of file
diff --git a/erpnext/healthcare/dashboard_fixtures.py b/erpnext/healthcare/dashboard_fixtures.py
new file mode 100644
index 00000000000..94668a16d91
--- /dev/null
+++ b/erpnext/healthcare/dashboard_fixtures.py
@@ -0,0 +1,245 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+import json
+from frappe import _
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_company():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company = frappe.get_list("Company", limit=1)
+ if company:
+ return company[0].name
+ return None
+
+def get_dashboards():
+ return [{
+ "name": "Healthcare",
+ "dashboard_name": "Healthcare",
+ "charts": [
+ { "chart": "Patient Appointments", "width": "Full"},
+ { "chart": "In-Patient Status", "width": "Half"},
+ { "chart": "Clinical Procedures Status", "width": "Half"},
+ { "chart": "Lab Tests", "width": "Half"},
+ { "chart": "Clinical Procedures", "width": "Half"},
+ { "chart": "Symptoms", "width": "Half"},
+ { "chart": "Diagnoses", "width": "Half"},
+ { "chart": "Department wise Patient Appointments", "width": "Full"}
+ ],
+ "cards": [
+ { "card": "Total Patients" },
+ { "card": "Total Patient Admitted" },
+ { "card": "Open Appointments" },
+ { "card": "Appointments to Bill" }
+ ]
+ }]
+
+def get_charts():
+ company = get_company()
+ return [
+ {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Daily",
+ "name": "Patient Appointments",
+ "chart_name": _("Patient Appointments"),
+ "timespan": "Last Month",
+ "filters_json": json.dumps([
+ ["Patient Appointment", "company", "=", company, False],
+ ["Patient Appointment", "status", "!=", "Cancelled"]
+ ]),
+ "chart_type": "Count",
+ "timeseries": 1,
+ "based_on": "appointment_datetime",
+ "owner": "Administrator",
+ "document_type": "Patient Appointment",
+ "type": "Line",
+ "width": "Half"
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Department wise Patient Appointments",
+ "chart_name": _("Department wise Patient Appointments"),
+ "chart_type": "Custom",
+ "source": "Department wise Patient Appointments",
+ "filters_json": json.dumps([]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Bar",
+ "width": "Full",
+ "custom_options": json.dumps({
+ "colors": ["#7CD5FA", "#5F62F6", "#7544E2", "#EE5555"],
+ "barOptions":{
+ "stacked":1
+ },
+ "height": 300
+ })
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Lab Tests",
+ "chart_name": _("Lab Tests"),
+ "chart_type": "Group By",
+ "document_type": "Lab Test",
+ "group_by_type": "Count",
+ "group_by_based_on": "template",
+ "filters_json": json.dumps([
+ ["Lab Test", "company", "=", company, False],
+ ["Lab Test", "docstatus", "=", 1]
+ ]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Percentage",
+ "width": "Half",
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Clinical Procedures",
+ "chart_name": _("Clinical Procedures"),
+ "chart_type": "Group By",
+ "document_type": "Clinical Procedure",
+ "group_by_type": "Count",
+ "group_by_based_on": "procedure_template",
+ "filters_json": json.dumps([
+ ["Clinical Procedure", "company", "=", company, False],
+ ["Clinical Procedure", "docstatus", "=", 1]
+ ]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Percentage",
+ "width": "Half",
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "In-Patient Status",
+ "chart_name": _("In-Patient Status"),
+ "chart_type": "Group By",
+ "document_type": "Inpatient Record",
+ "group_by_type": "Count",
+ "group_by_based_on": "status",
+ "filters_json": json.dumps([
+ ["Inpatient Record", "company", "=", company, False]
+ ]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Bar",
+ "width": "Half",
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Clinical Procedures Status",
+ "chart_name": _("Clinical Procedure Status"),
+ "chart_type": "Group By",
+ "document_type": "Clinical Procedure",
+ "group_by_type": "Count",
+ "group_by_based_on": "status",
+ "filters_json": json.dumps([
+ ["Clinical Procedure", "company", "=", company, False],
+ ["Clinical Procedure", "docstatus", "=", 1]
+ ]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Pie",
+ "width": "Half",
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Symptoms",
+ "chart_name": _("Symptoms"),
+ "chart_type": "Group By",
+ "document_type": "Patient Encounter Symptom",
+ "group_by_type": "Count",
+ "group_by_based_on": "complaint",
+ "filters_json": json.dumps([]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Percentage",
+ "width": "Half",
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Diagnoses",
+ "chart_name": _("Diagnoses"),
+ "chart_type": "Group By",
+ "document_type": "Patient Encounter Diagnosis",
+ "group_by_type": "Count",
+ "group_by_based_on": "diagnosis",
+ "filters_json": json.dumps([]),
+ 'is_public': 1,
+ "owner": "Administrator",
+ "type": "Percentage",
+ "width": "Half",
+ }
+ ]
+
+def get_number_cards():
+ company = get_company()
+ return [
+ {
+ "name": "Total Patients",
+ "label": _("Total Patients"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Patient",
+ "filters_json": json.dumps(
+ [["Patient","status","=","Active",False]]
+ ),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "name": "Total Patients Admitted",
+ "label": _("Total Patients Admitted"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Patient",
+ "filters_json": json.dumps(
+ [["Patient","inpatient_status","=","Admitted",False]]
+ ),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "name": "Open Appointments",
+ "label": _("Open Appointments"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Patient Appointment",
+ "filters_json": json.dumps(
+ [["Patient Appointment","company","=",company,False],
+ ["Patient Appointment","status","=","Open",False]]
+ ),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ },
+ {
+ "name": "Appointments to Bill",
+ "label": _("Appointments To Bill"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Patient Appointment",
+ "filters_json": json.dumps(
+ [["Patient Appointment","company","=",company,False],
+ ["Patient Appointment","invoiced","=",0,False]]
+ ),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/healthcare/desk_page/healthcare/healthcare.json b/erpnext/healthcare/desk_page/healthcare/healthcare.json
index 5cf09b34b24..334b65563bc 100644
--- a/erpnext/healthcare/desk_page/healthcare/healthcare.json
+++ b/erpnext/healthcare/desk_page/healthcare/healthcare.json
@@ -60,26 +60,30 @@
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Healthcare",
- "modified": "2020-04-25 22:31:36.576444",
+ "modified": "2020-05-28 19:02:28.824995",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare",
+ "onboarding": "Healthcare",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"restrict_to_domain": "Healthcare",
"shortcuts": [
{
+ "color": "#ffe8cd",
"format": "{} Open",
"label": "Patient Appointment",
"link_to": "Patient Appointment",
- "stats_filter": "{\n \"status\": \"Open\"\n}",
+ "stats_filter": "{\n \"status\": \"Open\",\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%']\n}",
"type": "DocType"
},
{
+ "color": "#ffe8cd",
"format": "{} Active",
"label": "Patient",
"link_to": "Patient",
@@ -87,10 +91,11 @@
"type": "DocType"
},
{
+ "color": "#cef6d1",
"format": "{} Vacant",
"label": "Healthcare Service Unit",
"link_to": "Healthcare Service Unit",
- "stats_filter": "{\n \"occupancy_status\": \"Vacant\",\n \"is_group\": 0\n}",
+ "stats_filter": "{\n \"occupancy_status\": \"Vacant\",\n \"is_group\": 0,\n \"company\": [\"like\", \"%\" + frappe.defaults.get_global_default(\"company\") + \"%\"]\n}",
"type": "DocType"
},
{
@@ -102,6 +107,11 @@
"label": "Patient History",
"link_to": "patient_history",
"type": "Page"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "Healthcare",
+ "type": "Dashboard"
}
]
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
index 87c22ccf6f3..eb7d4bdebad 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
@@ -43,7 +43,8 @@ frappe.ui.form.on('Clinical Procedure', {
return {
filters: {
'is_group': false,
- 'allow_appointments': true
+ 'allow_appointments': true,
+ 'company': frm.doc.company
}
};
});
@@ -158,11 +159,13 @@ frappe.ui.form.on('Clinical Procedure', {
age = __('{0} as on {1}', [age, data.message.age_as_on]);
}
}
+ frm.set_value('patient_name', data.message.patient_name);
frm.set_value('patient_age', age);
frm.set_value('patient_sex', data.message.sex);
}
});
} else {
+ frm.set_value('patient_name', '');
frm.set_value('patient_age', '');
frm.set_value('patient_sex', '');
}
@@ -177,15 +180,35 @@ frappe.ui.form.on('Clinical Procedure', {
name: frm.doc.appointment
},
callback: function(data) {
- frm.set_value('patient', data.message.patient);
- frm.set_value('procedure_template', data.message.procedure_template);
- frm.set_value('medical_department', data.message.department);
- frm.set_value('start_date', data.message.appointment_date);
- frm.set_value('start_time', data.message.appointment_time);
- frm.set_value('notes', data.message.notes);
- frm.set_value('service_unit', data.message.service_unit);
+ let values = {
+ 'patient':data.message.patient,
+ 'procedure_template': data.message.procedure_template,
+ 'medical_department': data.message.department,
+ 'practitioner': data.message.practitioner,
+ 'start_date': data.message.appointment_date,
+ 'start_time': data.message.appointment_time,
+ 'notes': data.message.notes,
+ 'service_unit': data.message.service_unit,
+ 'company': data.message.company
+ };
+ frm.set_value(values);
}
});
+ } else {
+ let values = {
+ 'patient': '',
+ 'patient_name': '',
+ 'patient_sex': '',
+ 'patient_age': '',
+ 'medical_department': '',
+ 'procedure_template': '',
+ 'start_date': '',
+ 'start_time': '',
+ 'notes': '',
+ 'service_unit': '',
+ 'inpatient_record': ''
+ };
+ frm.set_value(values);
}
},
@@ -234,9 +257,11 @@ frappe.ui.form.on('Clinical Procedure', {
name: frm.doc.practitioner
},
callback: function (data) {
- frappe.model.set_value(frm.doctype,frm.docname, 'medical_department',data.message.department);
+ frappe.model.set_value(frm.doctype,frm.docname, 'practitioner_name', data.message.practitioner_name);
}
});
+ } else {
+ frappe.model.set_value(frm.doctype,frm.docname, 'practitioner_name', '');
}
},
@@ -284,14 +309,6 @@ frappe.ui.form.on('Clinical Procedure', {
});
-cur_frm.set_query('procedure_template', function(doc) {
- return {
- filters: {
- 'medical_department': doc.medical_department
- }
- };
-});
-
frappe.ui.form.on('Clinical Procedure Item', {
qty: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
index 3c936bbf277..eaf8d80ba8c 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
@@ -7,28 +7,32 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
- "inpatient_record",
"naming_series",
- "procedure_template",
+ "title",
"appointment",
+ "procedure_template",
+ "column_break_30",
+ "company",
+ "invoiced",
+ "section_break_6",
"patient",
+ "patient_name",
"patient_sex",
"patient_age",
- "prescription",
- "medical_department",
- "practitioner",
+ "inpatient_record",
+ "notes",
"column_break_7",
"status",
+ "practitioner",
+ "practitioner_name",
+ "medical_department",
"service_unit",
- "warehouse",
"start_date",
"start_time",
"sample",
- "invoiced",
- "notes",
- "company",
"consumables_section",
"consume_stock",
+ "warehouse",
"items",
"section_break_24",
"invoice_separately_as_consumables",
@@ -36,6 +40,9 @@
"consumable_total_amount",
"column_break_27",
"consumption_details",
+ "sb_refs",
+ "column_break_34",
+ "prescription",
"amended_from"
],
"fields": [
@@ -56,15 +63,15 @@
{
"fieldname": "appointment",
"fieldtype": "Link",
- "in_list_view": 1,
+ "in_standard_filter": 1,
"label": "Appointment",
- "options": "Patient Appointment"
+ "options": "Patient Appointment",
+ "set_only_once": 1
},
{
- "fetch_from": "inpatient_record.patient",
"fieldname": "patient",
"fieldtype": "Link",
- "in_list_view": 1,
+ "in_standard_filter": 1,
"label": "Patient",
"options": "Patient",
"reqd": 1
@@ -88,17 +95,20 @@
"fieldtype": "Link",
"hidden": 1,
"label": "Procedure Prescription",
- "options": "Procedure Prescription"
+ "options": "Procedure Prescription",
+ "read_only": 1
},
{
"fieldname": "medical_department",
"fieldtype": "Link",
+ "in_standard_filter": 1,
"label": "Medical Department",
"options": "Medical Department"
},
{
"fieldname": "practitioner",
"fieldtype": "Link",
+ "in_standard_filter": 1,
"label": "Healthcare Practitioner",
"options": "Healthcare Practitioner"
},
@@ -208,6 +218,7 @@
"read_only": 1
},
{
+ "depends_on": "eval:!doc.__islocal",
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
@@ -226,6 +237,8 @@
"read_only": 1
},
{
+ "collapsible": 1,
+ "collapsible_depends_on": "consume_stock",
"fieldname": "consumables_section",
"fieldtype": "Section Break",
"label": "Consumables"
@@ -237,11 +250,51 @@
{
"fieldname": "section_break_24",
"fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "column_break_30",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "section_break_6",
+ "fieldtype": "Section Break"
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "sb_refs",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "patient_name",
+ "fieldtype": "Data",
+ "label": "Patient Name",
+ "read_only": 1
+ },
+ {
+ "fieldname": "practitioner_name",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Practitioner Name",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_34",
+ "fieldtype": "Column Break"
+ },
+ {
+ "allow_on_submit": 1,
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Title",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-02 11:44:27.970651",
+ "modified": "2020-04-27 21:36:23.796924",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Clinical Procedure",
@@ -257,11 +310,27 @@
"report": 1,
"role": "Nursing User",
"share": 1,
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Physician",
+ "share": 1,
+ "submit": 1,
"write": 1
}
],
"restrict_to_domain": "Healthcare",
"sort_field": "modified",
"sort_order": "DESC",
+ "title_field": "title",
"track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
index b7d7a62a950..e55a1433a51 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
@@ -16,6 +16,7 @@ from frappe.model.mapper import get_mapped_doc
class ClinicalProcedure(Document):
def validate(self):
self.set_status()
+ self.set_title()
if self.consume_stock:
self.set_actual_qty()
@@ -37,7 +38,7 @@ class ClinicalProcedure(Document):
template = frappe.get_doc('Clinical Procedure Template', self.procedure_template)
if template.sample:
patient = frappe.get_doc('Patient', self.patient)
- sample_collection = create_sample_doc(template, patient, None)
+ sample_collection = create_sample_doc(template, patient, None, self.company)
frappe.db.set_value('Clinical Procedure', self.name, 'sample', sample_collection.name)
self.reload()
@@ -50,6 +51,9 @@ class ClinicalProcedure(Document):
elif self.docstatus == 2:
self.status = 'Cancelled'
+ def set_title(self):
+ self.title = _('{0} - {1}').format(self.patient_name or self.patient, self.procedure_template)[:100]
+
def complete_procedure(self):
if self.consume_stock and self.items:
stock_entry = make_stock_entry(self)
diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.js b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.js
index 57f4cdf3b2f..16d4540c7c5 100644
--- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.js
+++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.js
@@ -144,3 +144,38 @@ cur_frm.set_query('item_code', 'items', function() {
}
};
});
+
+frappe.tour['Clinical Procedure Template'] = [
+ {
+ fieldname: 'template',
+ title: __('Template Name'),
+ description: __('Enter a name for the Clinical Procedure Template')
+ },
+ {
+ fieldname: 'item_code',
+ title: __('Item Code'),
+ description: __('Set the Item Code which will be used for billing the Clinical Procedure.')
+ },
+ {
+ fieldname: 'item_group',
+ title: __('Item Group'),
+ description: __('Select an Item Group for the Clinical Procedure Item.')
+ },
+ {
+ fieldname: 'is_billable',
+ title: __('Clinical Procedure Rate'),
+ description: __('Check this if the Clinical Procedure is billable and also set the rate.')
+ },
+ {
+ fieldname: 'consume_stock',
+ title: __('Allow Stock Consumption'),
+ description: __('Check this if the Clinical Procedure utilises consumables. Click ') + "here " + __(' to know more')
+
+ },
+ {
+ fieldname: 'medical_department',
+ title: __('Medical Department'),
+ description: __('You can also set the Medical Department for the template. After saving the document, an Item will automatically be created for billing this Clinical Procedure. You can then use this template while creating Clinical Procedures for Patients. Templates save you from filling up redundant data every single time. You can also create templates for other operations like Lab Tests, Therapy Sessions, etc.')
+ }
+];
+
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
index 4ab3b6e9c1b..fc0b24122ae 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
@@ -108,3 +108,38 @@ frappe.ui.form.on('Healthcare Practitioner', 'employee', function(frm) {
});
}
});
+
+frappe.tour['Healthcare Practitioner'] = [
+ {
+ fieldname: 'employee',
+ title: __('Employee'),
+ description: __('If you want to track Payroll and other HRMS operations for a Practitoner, create an Employee and link it here.')
+ },
+ {
+ fieldname: 'practitioner_schedules',
+ title: __('Practitioner Schedules'),
+ description: __('Set the Practitioner Schedule you just created. This will be used while booking appointments.')
+ },
+ {
+ fieldname: 'op_consulting_charge_item',
+ title: __('Out Patient Consulting Charge Item'),
+ description: __('Create a service item for Out Patient Consulting.')
+ },
+ {
+ fieldname: 'inpatient_visit_charge_item',
+ title: __('Inpatient Visit Charge Item'),
+ description: __('If this Healthcare Practitioner works for the In-Patient Department, create a service item for Inpatient Visits.')
+ },
+ {
+ fieldname: 'op_consulting_charge',
+ title: __('Out Patient Consulting Charge'),
+ description: __('Set the Out Patient Consulting Charge for this Practitioner.')
+
+ },
+ {
+ fieldname: 'inpatient_visit_charge',
+ title: __('Inpatient Visit Charge'),
+ description: __('If this Healthcare Practitioner also works for the In-Patient Department, set the inpatient visit charge for this Practitioner.')
+ }
+];
+
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
index fd5b6e12f66..cb747f95ef8 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
@@ -1,6 +1,5 @@
{
"actions": [],
- "allow_copy": 1,
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
@@ -51,17 +50,20 @@
"fieldname": "first_name",
"fieldtype": "Data",
"label": "First Name",
+ "no_copy": 1,
"reqd": 1
},
{
"fieldname": "middle_name",
"fieldtype": "Data",
- "label": "Middle Name (Optional)"
+ "label": "Middle Name (Optional)",
+ "no_copy": 1
},
{
"fieldname": "last_name",
"fieldtype": "Data",
- "label": "Last Name"
+ "label": "Last Name",
+ "no_copy": 1
},
{
"fieldname": "image",
@@ -226,6 +228,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Full Name",
+ "no_copy": 1,
"read_only": 1,
"search_index": 1
},
@@ -233,6 +236,7 @@
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
+ "no_copy": 1,
"options": "HLC-PRAC-.YYYY.-",
"report_hide": 1,
"set_only_once": 1
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
index ea4ae846f7d..9ee865a62a4 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
@@ -12,7 +12,6 @@
"engine": "InnoDB",
"field_order": [
"healthcare_service_unit_name",
- "parent_healthcare_service_unit",
"is_group",
"service_unit_type",
"allow_appointments",
@@ -20,8 +19,10 @@
"inpatient_occupancy",
"occupancy_status",
"column_break_9",
- "warehouse",
"company",
+ "warehouse",
+ "tree_details_section",
+ "parent_healthcare_service_unit",
"lft",
"rgt",
"old_parent"
@@ -51,7 +52,6 @@
"depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
"fieldname": "is_group",
"fieldtype": "Check",
- "in_list_view": 1,
"label": "Is Group"
},
{
@@ -63,12 +63,12 @@
"options": "Healthcare Service Unit Type"
},
{
- "bold": 1,
"default": "0",
"depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1",
"fetch_from": "service_unit_type.allow_appointments",
"fieldname": "allow_appointments",
"fieldtype": "Check",
+ "in_list_view": 1,
"label": "Allow Appointments",
"no_copy": 1,
"read_only": 1
@@ -90,6 +90,7 @@
"fetch_from": "service_unit_type.inpatient_occupancy",
"fieldname": "inpatient_occupancy",
"fieldtype": "Check",
+ "in_list_view": 1,
"label": "Inpatient Occupancy",
"no_copy": 1,
"read_only": 1,
@@ -101,7 +102,7 @@
"fieldtype": "Select",
"label": "Occupancy Status",
"no_copy": 1,
- "options": "\nVacant\nOccupied",
+ "options": "Vacant\nOccupied",
"read_only": 1
},
{
@@ -157,10 +158,16 @@
"options": "Healthcare Service Unit",
"print_hide": 1,
"report_hide": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "tree_details_section",
+ "fieldtype": "Section Break",
+ "label": "Tree Details"
}
],
"links": [],
- "modified": "2020-03-26 16:13:08.675952",
+ "modified": "2020-05-20 18:26:56.065543",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Service Unit",
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 13cc43d2be4..9e0417a2bef 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
@@ -22,10 +22,16 @@ class HealthcareServiceUnit(NestedSet):
super(HealthcareServiceUnit, self).on_update()
self.validate_one_root()
- def validate(self):
+ def after_insert(self):
if self.is_group:
self.allow_appointments = 0
self.overlap_appointments = 0
self.inpatient_occupancy = 0
- elif not self.allow_appointments:
- self.overlap_appointments = 0
+ elif self.service_unit_type:
+ service_unit_type = frappe.get_doc('Healthcare Service Unit Type', self.service_unit_type)
+ self.allow_appointments = service_unit_type.allow_appointments
+ self.overlap_appointments = service_unit_type.overlap_appointments
+ self.inpatient_occupancy = service_unit_type.inpatient_occupancy
+ if self.inpatient_occupancy:
+ self.occupancy_status = 'Vacant'
+ self.overlap_appointments = 0
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
index 5fa47d91bc2..4b8503d0286 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
+++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
@@ -31,6 +31,7 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Service Unit Type",
+ "no_copy": 1,
"reqd": 1,
"unique": 1
},
@@ -40,8 +41,7 @@
"depends_on": "eval:doc.inpatient_occupancy != 1",
"fieldname": "allow_appointments",
"fieldtype": "Check",
- "label": "Allow Appointments",
- "no_copy": 1
+ "label": "Allow Appointments"
},
{
"bold": 1,
@@ -49,8 +49,7 @@
"depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
"fieldname": "overlap_appointments",
"fieldtype": "Check",
- "label": "Allow Overlap",
- "no_copy": 1
+ "label": "Allow Overlap"
},
{
"bold": 1,
@@ -58,8 +57,7 @@
"depends_on": "eval:doc.allow_appointments != 1",
"fieldname": "inpatient_occupancy",
"fieldtype": "Check",
- "label": "Inpatient Occupancy",
- "no_copy": 1
+ "label": "Inpatient Occupancy"
},
{
"bold": 1,
@@ -79,6 +77,7 @@
"fieldname": "item",
"fieldtype": "Link",
"label": "Item",
+ "no_copy": 1,
"options": "Item",
"read_only": 1
},
@@ -86,7 +85,8 @@
"fieldname": "item_code",
"fieldtype": "Data",
"label": "Item Code",
- "mandatory_depends_on": "eval: doc.is_billable == 1"
+ "mandatory_depends_on": "eval: doc.is_billable == 1",
+ "no_copy": 1
},
{
"fieldname": "item_group",
@@ -138,7 +138,7 @@
}
],
"links": [],
- "modified": "2020-01-30 16:06:00.624496",
+ "modified": "2020-05-20 15:31:09.627516",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Service Unit Type",
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 286ecc0ff8e..bb86eaacc40 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
@@ -10,6 +10,22 @@ from frappe.model.rename_doc import rename_doc
class HealthcareServiceUnitType(Document):
def validate(self):
+ if self.allow_appointments and self.inpatient_occupancy:
+ frappe.msgprint(
+ _('Healthcare Service Unit Type cannot have both {0} and {1}').format(
+ frappe.bold('Allow Appointments'), frappe.bold('Inpatient Occupancy')),
+ raise_exception=1, title=_('Validation Error'), indicator='red'
+ )
+ elif not self.allow_appointments and not self.inpatient_occupancy:
+ frappe.msgprint(
+ _('Healthcare Service Unit Type must allow atleast one among {0} and {1}').format(
+ frappe.bold('Allow Appointments'), frappe.bold('Inpatient Occupancy')),
+ raise_exception=1, title=_('Validation Error'), indicator='red'
+ )
+
+ if not self.allow_appointments:
+ self.overlap_appointments = 0
+
if self.is_billable:
if self.disabled:
frappe.db.set_value('Item', self.item, 'disabled', 1)
diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
index 22fbf5019a6..cf2276fc07c 100644
--- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
+++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js
@@ -39,3 +39,37 @@ var set_query_service_item = function(frm, service_item_field) {
};
});
};
+
+frappe.tour['Healthcare Settings'] = [
+ {
+ fieldname: 'link_customer_to_patient',
+ title: __('Link Customer to Patient'),
+ description: __('If checked, a customer will be created for every Patient. Patient Invoices will be created against this Customer. You can also select existing Customer while creating a Patient. This field is checked by default.')
+ },
+ {
+ fieldname: 'collect_registration_fee',
+ title: __('Collect Registration Fee'),
+ description: __('If your Healthcare facility bills registrations of Patients, you can check this and set the Registration Fee in the field below. Checking this will create new Patients with a Disabled status by default and will only be enabled after invoicing the Registration Fee.')
+ },
+ {
+ fieldname: 'automate_appointment_invoicing',
+ title: __('Automate Appointment Invoicing'),
+ description: __('Checking this will automatically create a Sales Invoice whenever an appointment is booked for a Patient.')
+ },
+ {
+ fieldname: 'inpatient_visit_charge_item',
+ title: __('Healthcare Service Items'),
+ description: __('You can create a service item for Inpatient Visit Charge and set it here. Similarly, you can set up other Healthcare Service Items for billing in this section. Click ') + "here " + __(' to know more')
+ },
+ {
+ fieldname: 'income_account',
+ title: __('Set up default Accounts for the Healthcare Facility'),
+ description: __('If you wish to override default accounts settings and configure the Income and Receivable accounts for Healthcare, you can do so here.')
+
+ },
+ {
+ fieldname: 'send_registration_msg',
+ title: __('Out Patient SMS alerts'),
+ description: __('If you want to send SMS alert on Patient Registration, you can enable this option. Similary, you can set up Out Patient SMS alerts for other functionalities in this section. Click ') + "here " + __(' to know more')
+ }
+];
diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
index de086201795..2f0115c36a7 100644
--- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
+++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
@@ -240,7 +240,7 @@
"label": "Patient Registration"
},
{
- "default": "Hello {{doc.patient}}, Thank you for registering with {{doc.company}}. Your ID is {{doc.id}} . Please note this ID for future reference. \nThank You, Get well soon!",
+ "default": "Hello {{doc.patient}}, Thank you for registering with {{doc.company}}. Your ID is {{doc.name}} . Please note this ID for future reference. \nThank You!",
"depends_on": "send_registration_msg",
"fieldname": "registration_msg",
"fieldtype": "Small Text",
@@ -254,7 +254,7 @@
"label": "Appointment Confirmation"
},
{
- "default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.practitioner}} by {{doc.start_dt}} at {{doc.company}}.\nThank you, Good day!",
+ "default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.practitioner}} on {{doc.appointment_datetime}} at {{doc.company}}.\nThank you, Good day!",
"depends_on": "send_appointment_confirmation",
"fieldname": "appointment_confirmation_msg",
"fieldtype": "Small Text",
@@ -276,7 +276,7 @@
"label": "Appointment Reminder"
},
{
- "default": "Hello {{doc.patient}}, You have an appointment with {{doc.practitioner}} by {{doc.appointment_time}} at {{doc.company}}.\nThank you, Good day!\n",
+ "default": "Hello {{doc.patient}}, You have an appointment with {{doc.practitioner}} by {{doc.appointment_datetime}} at {{doc.company}}.\nThank you, Good day!\n",
"depends_on": "send_appointment_reminder",
"fieldname": "appointment_reminder_msg",
"fieldtype": "Small Text",
diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.js b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.js
index 67c12f6c14d..971e166067e 100644
--- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.js
+++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.js
@@ -2,22 +2,37 @@
// For license information, please see license.txt
frappe.ui.form.on('Inpatient Record', {
+ setup: function(frm) {
+ frm.get_field('drug_prescription').grid.editable_fields = [
+ {fieldname: 'drug_code', columns: 2},
+ {fieldname: 'drug_name', columns: 2},
+ {fieldname: 'dosage', columns: 2},
+ {fieldname: 'period', columns: 2}
+ ];
+ },
refresh: function(frm) {
- if(!frm.doc.__islocal && frm.doc.status == "Admission Scheduled"){
+ if (!frm.doc.__islocal && (frm.doc.status == 'Admission Scheduled' || frm.doc.status == 'Admitted')) {
+ frm.enable_save();
+ } else {
+ frm.disable_save();
+ }
+
+ if (!frm.doc.__islocal && frm.doc.status == 'Admission Scheduled') {
frm.add_custom_button(__('Admit'), function() {
admit_patient_dialog(frm);
} );
- frm.set_df_property("btn_transfer", "hidden", 1);
}
- if(!frm.doc.__islocal && frm.doc.status == "Discharge Scheduled"){
+
+ if (!frm.doc.__islocal && frm.doc.status == 'Discharge Scheduled') {
frm.add_custom_button(__('Discharge'), function() {
discharge_patient(frm);
} );
- frm.set_df_property("btn_transfer", "hidden", 0);
}
- if(!frm.doc.__islocal && (frm.doc.status == "Discharged" || frm.doc.status == "Discharge Scheduled")){
+ if (!frm.doc.__islocal && frm.doc.status != 'Admitted') {
frm.disable_save();
- frm.set_df_property("btn_transfer", "hidden", 1);
+ frm.set_df_property('btn_transfer', 'hidden', 1);
+ } else {
+ frm.set_df_property('btn_transfer', 'hidden', 0);
}
},
btn_transfer: function(frm) {
@@ -25,39 +40,47 @@ frappe.ui.form.on('Inpatient Record', {
}
});
-var discharge_patient = function(frm) {
+let discharge_patient = function(frm) {
frappe.call({
doc: frm.doc,
- method: "discharge",
+ method: 'discharge',
callback: function(data) {
- if(!data.exc){
+ if (!data.exc) {
frm.reload_doc();
}
},
freeze: true,
- freeze_message: "Process Discharge"
+ freeze_message: __('Processing Inpatient Discharge')
});
};
-var admit_patient_dialog = function(frm){
- var dialog = new frappe.ui.Dialog({
+let admit_patient_dialog = function(frm) {
+ let dialog = new frappe.ui.Dialog({
title: 'Admit Patient',
width: 100,
fields: [
- {fieldtype: "Link", label: "Service Unit Type", fieldname: "service_unit_type", options: "Healthcare Service Unit Type"},
- {fieldtype: "Link", label: "Service Unit", fieldname: "service_unit", options: "Healthcare Service Unit", reqd: 1},
- {fieldtype: "Datetime", label: "Admission Datetime", fieldname: "check_in", reqd: 1},
- {fieldtype: "Date", label: "Expected Discharge", fieldname: "expected_discharge"}
+ {fieldtype: 'Link', label: 'Service Unit Type', fieldname: 'service_unit_type',
+ options: 'Healthcare Service Unit Type', default: frm.doc.admission_service_unit_type
+ },
+ {fieldtype: 'Link', label: 'Service Unit', fieldname: 'service_unit',
+ options: 'Healthcare Service Unit', reqd: 1
+ },
+ {fieldtype: 'Datetime', label: 'Admission Datetime', fieldname: 'check_in',
+ reqd: 1, default: frappe.datetime.now_datetime()
+ },
+ {fieldtype: 'Date', label: 'Expected Discharge', fieldname: 'expected_discharge',
+ default: frm.doc.expected_length_of_stay ? frappe.datetime.add_days(frappe.datetime.now_datetime(), frm.doc.expected_length_of_stay) : ''
+ }
],
- primary_action_label: __("Admit"),
+ primary_action_label: __('Admit'),
primary_action : function(){
- var service_unit = dialog.get_value('service_unit');
- var check_in = dialog.get_value('check_in');
- var expected_discharge = null;
- if(dialog.get_value('expected_discharge')){
+ let service_unit = dialog.get_value('service_unit');
+ let check_in = dialog.get_value('check_in');
+ let expected_discharge = null;
+ if (dialog.get_value('expected_discharge')) {
expected_discharge = dialog.get_value('expected_discharge');
}
- if(!service_unit && !check_in){
+ if (!service_unit && !check_in) {
return;
}
frappe.call({
@@ -69,32 +92,33 @@ var admit_patient_dialog = function(frm){
'expected_discharge': expected_discharge
},
callback: function(data) {
- if(!data.exc){
+ if (!data.exc) {
frm.reload_doc();
}
},
freeze: true,
- freeze_message: "Process Admission"
+ freeze_message: __('Processing Patient Admission')
});
frm.refresh_fields();
dialog.hide();
}
});
- dialog.fields_dict["service_unit_type"].get_query = function(){
+ dialog.fields_dict['service_unit_type'].get_query = function() {
return {
filters: {
- "inpatient_occupancy": 1,
- "allow_appointments": 0
+ 'inpatient_occupancy': 1,
+ 'allow_appointments': 0
}
};
};
- dialog.fields_dict["service_unit"].get_query = function(){
+ dialog.fields_dict['service_unit'].get_query = function() {
return {
filters: {
- "is_group": 0,
- "service_unit_type": dialog.get_value("service_unit_type"),
- "occupancy_status" : "Vacant"
+ 'is_group': 0,
+ 'company': frm.doc.company,
+ 'service_unit_type': dialog.get_value('service_unit_type'),
+ 'occupancy_status' : 'Vacant'
}
};
};
@@ -102,21 +126,21 @@ var admit_patient_dialog = function(frm){
dialog.show();
};
-var transfer_patient_dialog = function(frm){
- var dialog = new frappe.ui.Dialog({
+let transfer_patient_dialog = function(frm) {
+ let dialog = new frappe.ui.Dialog({
title: 'Transfer Patient',
width: 100,
fields: [
- {fieldtype: "Link", label: "Leave From", fieldname: "leave_from", options: "Healthcare Service Unit", reqd: 1, read_only:1},
- {fieldtype: "Link", label: "Service Unit Type", fieldname: "service_unit_type", options: "Healthcare Service Unit Type"},
- {fieldtype: "Link", label: "Transfer To", fieldname: "service_unit", options: "Healthcare Service Unit", reqd: 1},
- {fieldtype: "Datetime", label: "Check In", fieldname: "check_in", reqd: 1}
+ {fieldtype: 'Link', label: 'Leave From', fieldname: 'leave_from', options: 'Healthcare Service Unit', reqd: 1, read_only:1},
+ {fieldtype: 'Link', label: 'Service Unit Type', fieldname: 'service_unit_type', options: 'Healthcare Service Unit Type'},
+ {fieldtype: 'Link', label: 'Transfer To', fieldname: 'service_unit', options: 'Healthcare Service Unit', reqd: 1},
+ {fieldtype: 'Datetime', label: 'Check In', fieldname: 'check_in', reqd: 1}
],
- primary_action_label: __("Transfer"),
- primary_action : function(){
- var service_unit = null;
- var check_in = dialog.get_value('check_in');
- var leave_from = null;
+ primary_action_label: __('Transfer'),
+ primary_action : function() {
+ let service_unit = null;
+ let check_in = dialog.get_value('check_in');
+ let leave_from = null;
if(dialog.get_value('leave_from')){
leave_from = dialog.get_value('leave_from');
}
@@ -135,47 +159,47 @@ var transfer_patient_dialog = function(frm){
'leave_from': leave_from
},
callback: function(data) {
- if(!data.exc){
+ if (!data.exc) {
frm.reload_doc();
}
},
freeze: true,
- freeze_message: "Process Transfer"
+ freeze_message: __('Process Transfer')
});
frm.refresh_fields();
dialog.hide();
}
});
- dialog.fields_dict["leave_from"].get_query = function(){
+ dialog.fields_dict['leave_from'].get_query = function(){
return {
- query : "erpnext.healthcare.doctype.inpatient_record.inpatient_record.get_leave_from",
+ query : 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.get_leave_from',
filters: {docname:frm.doc.name}
};
};
- dialog.fields_dict["service_unit_type"].get_query = function(){
+ dialog.fields_dict['service_unit_type'].get_query = function(){
return {
filters: {
- "inpatient_occupancy": 1,
- "allow_appointments": 0
+ 'inpatient_occupancy': 1,
+ 'allow_appointments': 0
}
};
};
- dialog.fields_dict["service_unit"].get_query = function(){
+ dialog.fields_dict['service_unit'].get_query = function(){
return {
filters: {
- "is_group": 0,
- "service_unit_type": dialog.get_value("service_unit_type"),
- "occupancy_status" : "Vacant"
+ 'is_group': 0,
+ 'service_unit_type': dialog.get_value('service_unit_type'),
+ 'occupancy_status' : 'Vacant'
}
};
};
dialog.show();
- var not_left_service_unit = null;
- for(let inpatient_occupancy in frm.doc.inpatient_occupancies){
- if(frm.doc.inpatient_occupancies[inpatient_occupancy].left != 1){
+ let not_left_service_unit = null;
+ for (let inpatient_occupancy in frm.doc.inpatient_occupancies) {
+ if (frm.doc.inpatient_occupancies[inpatient_occupancy].left != 1) {
not_left_service_unit = frm.doc.inpatient_occupancies[inpatient_occupancy].service_unit;
}
}
diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.json b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.json
index 92c11fbb4da..5ced845c1b0 100644
--- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.json
+++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.json
@@ -1,980 +1,475 @@
{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "naming_series:",
- "beta": 0,
- "creation": "2018-07-11 17:48:51.404139",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "autoname": "naming_series:",
+ "creation": "2018-07-11 17:48:51.404139",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "section_break_1",
+ "naming_series",
+ "patient",
+ "patient_name",
+ "gender",
+ "blood_group",
+ "dob",
+ "mobile",
+ "email",
+ "phone",
+ "column_break_8",
+ "company",
+ "status",
+ "scheduled_date",
+ "admitted_datetime",
+ "expected_discharge",
+ "references",
+ "admission_encounter",
+ "admission_practitioner",
+ "medical_department",
+ "admission_ordered_for",
+ "expected_length_of_stay",
+ "admission_service_unit_type",
+ "cb_admission",
+ "primary_practitioner",
+ "secondary_practitioner",
+ "admission_instruction",
+ "encounter_details_section",
+ "chief_complaint",
+ "column_break_29",
+ "diagnosis",
+ "medication_section",
+ "drug_prescription",
+ "investigations_section",
+ "lab_test_prescription",
+ "procedures_section",
+ "procedure_prescription",
+ "rehabilitation_section",
+ "therapy_plan",
+ "therapies",
+ "sb_inpatient_occupancy",
+ "inpatient_occupancies",
+ "btn_transfer",
+ "sb_discharge_details",
+ "discharge_ordered_date",
+ "discharge_practitioner",
+ "discharge_encounter",
+ "discharge_date",
+ "cb_discharge",
+ "discharge_instructions",
+ "followup_date",
+ "sb_discharge_note",
+ "discharge_note"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_1",
- "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,
- "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": "section_break_1",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "",
- "fieldname": "naming_series",
- "fieldtype": "Select",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Series",
- "length": 0,
- "no_copy": 0,
- "options": "HLC-INP-.YYYY.-",
- "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": "naming_series",
+ "fieldtype": "Select",
+ "hidden": 1,
+ "label": "Series",
+ "options": "HLC-INP-.YYYY.-"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "patient",
- "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": "Patient",
- "length": 0,
- "no_copy": 0,
- "options": "Patient",
- "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
- },
+ "fieldname": "patient",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Patient",
+ "options": "Patient",
+ "reqd": 1,
+ "set_only_once": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.patient_name",
- "fieldname": "patient_name",
- "fieldtype": "Data",
- "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": "Patient Name",
- "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
- },
+ "fetch_from": "patient.patient_name",
+ "fieldname": "patient_name",
+ "fieldtype": "Data",
+ "label": "Patient Name",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.sex",
- "fieldname": "gender",
- "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": "Gender",
- "length": 0,
- "no_copy": 0,
- "options": "Gender",
- "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
- },
+ "fetch_from": "patient.sex",
+ "fieldname": "gender",
+ "fieldtype": "Link",
+ "label": "Gender",
+ "options": "Gender",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.blood_group",
- "fieldname": "blood_group",
- "fieldtype": "Select",
- "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": "Blood Group",
- "length": 0,
- "no_copy": 0,
- "options": "\nA Positive\nA Negative\nAB Positive\nAB Negative\nB Positive\nB Negative\nO Positive\nO Negative",
- "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
- },
+ "fetch_from": "patient.blood_group",
+ "fieldname": "blood_group",
+ "fieldtype": "Select",
+ "label": "Blood Group",
+ "options": "\nA Positive\nA Negative\nAB Positive\nAB Negative\nB Positive\nB Negative\nO Positive\nO Negative",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "dob",
- "fieldtype": "Date",
- "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": "Date of birth",
- "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
- },
+ "fetch_from": "patient.dob",
+ "fieldname": "dob",
+ "fieldtype": "Date",
+ "label": "Date of birth",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.mobile",
- "fieldname": "mobile",
- "fieldtype": "Data",
- "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": "Mobile",
- "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
- },
+ "fetch_from": "patient.mobile",
+ "fieldname": "mobile",
+ "fieldtype": "Data",
+ "label": "Mobile",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.email",
- "fieldname": "email",
- "fieldtype": "Data",
- "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": "Email",
- "length": 0,
- "no_copy": 0,
- "options": "Email",
- "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
- },
+ "fetch_from": "patient.email",
+ "fieldname": "email",
+ "fieldtype": "Data",
+ "label": "Email",
+ "options": "Email",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "patient.phone",
- "fieldname": "phone",
- "fieldtype": "Data",
- "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": "Phone",
- "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
- },
+ "fetch_from": "patient.phone",
+ "fieldname": "phone",
+ "fieldtype": "Data",
+ "label": "Phone",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_8",
- "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,
- "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": "medical_department",
+ "fieldtype": "Link",
+ "label": "Medical Department",
+ "options": "Medical Department",
+ "set_only_once": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "status",
- "fieldtype": "Select",
- "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": "Status",
- "length": 0,
- "no_copy": 0,
- "options": "Admission Scheduled\nAdmitted\nDischarge Scheduled\nDischarged",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "primary_practitioner",
+ "fieldtype": "Link",
+ "label": "Healthcare Practitioner (Primary)",
+ "options": "Healthcare Practitioner"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "Today",
- "fieldname": "scheduled_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": "Admission Schedule Date",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "secondary_practitioner",
+ "fieldtype": "Link",
+ "label": "Healthcare Practitioner (Secondary)",
+ "options": "Healthcare Practitioner"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "Today",
- "fieldname": "admitted_datetime",
- "fieldtype": "Datetime",
- "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": "Admitted Datetime",
- "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_8",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "expected_discharge",
- "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": "Expected Discharge",
- "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
- },
+ "default": "Admission Scheduled",
+ "fieldname": "status",
+ "fieldtype": "Select",
+ "in_list_view": 1,
+ "label": "Status",
+ "options": "Admission Scheduled\nAdmitted\nDischarge Scheduled\nDischarged",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "discharge_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": "Discharge Date",
- "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
- },
+ "default": "Today",
+ "fieldname": "scheduled_date",
+ "fieldtype": "Date",
+ "in_list_view": 1,
+ "label": "Admission Schedule Date",
+ "read_only": 1,
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 1,
- "columns": 0,
- "fieldname": "references",
- "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": "References",
- "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": "admission_ordered_for",
+ "fieldtype": "Date",
+ "label": "Admission Ordered For",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "cb_admission",
- "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": "Admission",
- "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": "admitted_datetime",
+ "fieldtype": "Datetime",
+ "in_list_view": 1,
+ "label": "Admitted Datetime",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "admission_practitioner",
- "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": "Healthcare Practitioner",
- "length": 0,
- "no_copy": 0,
- "options": "Healthcare Practitioner",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "depends_on": "eval:(doc.expected_length_of_stay > 0)",
+ "fieldname": "expected_length_of_stay",
+ "fieldtype": "Int",
+ "label": "Expected Length of Stay",
+ "set_only_once": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "admission_encounter",
- "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": "Patient Encounter",
- "length": 0,
- "no_copy": 0,
- "options": "Patient Encounter",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "expected_discharge",
+ "fieldtype": "Date",
+ "in_list_view": 1,
+ "label": "Expected Discharge",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "cb_discharge",
- "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": "Discharge",
- "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
- },
+ "collapsible": 1,
+ "fieldname": "references",
+ "fieldtype": "Section Break",
+ "label": "Admission Order Details"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "discharge_practitioner",
- "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": "Healthcare Practitioner",
- "length": 0,
- "no_copy": 0,
- "options": "Healthcare Practitioner",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "cb_admission",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "discharge_encounter",
- "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": "Patient Encounter",
- "length": 0,
- "no_copy": 0,
- "options": "Patient Encounter",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "admission_practitioner",
+ "fieldtype": "Link",
+ "label": "Healthcare Practitioner",
+ "options": "Healthcare Practitioner",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "sb_inpatient_occupancy",
- "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": "Inpatient Occupancy",
- "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": "admission_encounter",
+ "fieldtype": "Link",
+ "label": "Patient Encounter",
+ "options": "Patient Encounter",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "inpatient_occupancies",
- "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,
- "length": 0,
- "no_copy": 0,
- "options": "Inpatient Occupancy",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "chief_complaint",
+ "fieldtype": "Table MultiSelect",
+ "label": "Chief Complaint",
+ "options": "Patient Encounter Symptom",
+ "permlevel": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "btn_transfer",
- "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": "Transfer",
- "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": "admission_instruction",
+ "fieldtype": "Small Text",
+ "label": "Admission Instruction",
+ "set_only_once": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.status != \"Admission Scheduled\"",
- "fieldname": "sb_discharge_note",
- "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": "Discharge Note",
- "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": "cb_discharge",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "discharge_note",
- "fieldtype": "Text Editor",
- "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,
- "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": "discharge_practitioner",
+ "fieldtype": "Link",
+ "label": "Healthcare Practitioner",
+ "options": "Healthcare Practitioner",
+ "read_only": 1
+ },
+ {
+ "fieldname": "discharge_encounter",
+ "fieldtype": "Link",
+ "label": "Patient Encounter",
+ "options": "Patient Encounter",
+ "read_only": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "medication_section",
+ "fieldtype": "Section Break",
+ "label": "Medications",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "drug_prescription",
+ "fieldtype": "Table",
+ "options": "Drug Prescription",
+ "permlevel": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "investigations_section",
+ "fieldtype": "Section Break",
+ "label": "Investigations",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "lab_test_prescription",
+ "fieldtype": "Table",
+ "options": "Lab Prescription",
+ "permlevel": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "procedures_section",
+ "fieldtype": "Section Break",
+ "label": "Procedures",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "procedure_prescription",
+ "fieldtype": "Table",
+ "options": "Procedure Prescription",
+ "permlevel": 1
+ },
+ {
+ "depends_on": "eval:(doc.status != \"Admission Scheduled\")",
+ "fieldname": "sb_inpatient_occupancy",
+ "fieldtype": "Section Break",
+ "label": "Inpatient Occupancy"
+ },
+ {
+ "fieldname": "admission_service_unit_type",
+ "fieldtype": "Link",
+ "label": "Admission Service Unit Type",
+ "options": "Healthcare Service Unit Type",
+ "read_only": 1
+ },
+ {
+ "fieldname": "inpatient_occupancies",
+ "fieldtype": "Table",
+ "options": "Inpatient Occupancy",
+ "read_only": 1
+ },
+ {
+ "fieldname": "btn_transfer",
+ "fieldtype": "Button",
+ "label": "Transfer"
+ },
+ {
+ "depends_on": "eval:(doc.status == \"Discharge Scheduled\" || doc.status == \"Discharged\")",
+ "fieldname": "sb_discharge_note",
+ "fieldtype": "Section Break",
+ "label": "Discharge Notes"
+ },
+ {
+ "fieldname": "discharge_note",
+ "fieldtype": "Text Editor",
+ "permlevel": 1
+ },
+ {
+ "fetch_from": "admission_encounter.company",
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "in_standard_filter": 1,
+ "label": "Company",
+ "options": "Company"
+ },
+ {
+ "collapsible": 1,
+ "collapsible_depends_on": "eval:(doc.status == \"Admitted\")",
+ "fieldname": "encounter_details_section",
+ "fieldtype": "Section Break",
+ "label": "Encounter Impression",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "column_break_29",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "diagnosis",
+ "fieldtype": "Table MultiSelect",
+ "label": "Diagnosis",
+ "options": "Patient Encounter Diagnosis",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "followup_date",
+ "fieldtype": "Date",
+ "label": "Follow Up Date"
+ },
+ {
+ "collapsible": 1,
+ "depends_on": "eval:(doc.status == \"Discharge Scheduled\" || doc.status == \"Discharged\")",
+ "fieldname": "sb_discharge_details",
+ "fieldtype": "Section Break",
+ "label": "Discharge Detials"
+ },
+ {
+ "fieldname": "discharge_instructions",
+ "fieldtype": "Small Text",
+ "label": "Discharge Instructions"
+ },
+ {
+ "fieldname": "discharge_ordered_date",
+ "fieldtype": "Date",
+ "in_list_view": 1,
+ "label": "Discharge Ordered Date",
+ "read_only": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "rehabilitation_section",
+ "fieldtype": "Section Break",
+ "label": "Rehabilitation",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "therapy_plan",
+ "fieldtype": "Link",
+ "hidden": 1,
+ "label": "Therapy Plan",
+ "options": "Therapy Plan",
+ "permlevel": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "therapies",
+ "fieldtype": "Table",
+ "options": "Therapy Plan Detail",
+ "permlevel": 1
+ },
+ {
+ "fieldname": "discharge_date",
+ "fieldtype": "Date",
+ "label": "Discharge Date",
+ "read_only": 1
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-08-21 14:44:43.168245",
- "modified_by": "Administrator",
- "module": "Healthcare",
- "name": "Inpatient Record",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "links": [],
+ "modified": "2020-05-21 02:26:22.144575",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Inpatient Record",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Healthcare Administrator",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Healthcare Administrator",
+ "share": 1,
"write": 1
+ },
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Physician",
+ "share": 1,
+ "write": 1
+ },
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Nursing User",
+ "share": 1,
+ "write": 1
+ },
+ {
+ "permlevel": 1,
+ "read": 1,
+ "role": "Physician",
+ "write": 1
+ },
+ {
+ "permlevel": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Nursing User"
}
- ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "restrict_to_domain": "Healthcare",
- "search_fields": "patient",
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "title_field": "patient",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
-}
+ ],
+ "restrict_to_domain": "Healthcare",
+ "search_fields": "patient",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "patient",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py
index 835b38bedf8..cf63b65f4d6 100644
--- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py
+++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py
@@ -3,7 +3,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
-import frappe
+import frappe, json
from frappe import _
from frappe.utils import today, now_datetime, getdate
from frappe.model.document import Document
@@ -11,8 +11,12 @@ from frappe.desk.reportview import get_match_cond
class InpatientRecord(Document):
def after_insert(self):
- frappe.db.set_value("Patient", self.patient, "inpatient_status", "Admission Scheduled")
- frappe.db.set_value("Patient", self.patient, "inpatient_record", self.name)
+ frappe.db.set_value('Patient', self.patient, 'inpatient_record', self.name)
+ frappe.db.set_value('Patient', self.patient, 'inpatient_status', self.status)
+
+ if self.admission_encounter: # Update encounter
+ frappe.db.set_value('Patient Encounter', self.admission_encounter, 'inpatient_record', self.name)
+ frappe.db.set_value('Patient Encounter', self.admission_encounter, 'inpatient_status', self.status)
def validate(self):
self.validate_dates()
@@ -22,13 +26,10 @@ class InpatientRecord(Document):
frappe.db.set_value("Patient", self.patient, "inpatient_record", None)
def validate_dates(self):
- if (getdate(self.scheduled_date) < getdate(today())) or \
- (getdate(self.admitted_datetime) < getdate(today())):
- frappe.throw(_("Scheduled and Admitted dates can not be less than today"))
if (getdate(self.expected_discharge) < getdate(self.scheduled_date)) or \
- (getdate(self.discharge_date) < getdate(self.scheduled_date)):
- frappe.throw(_("Expected and Discharge dates cannot be less than Admission Schedule date"))
-
+ (getdate(self.discharge_ordered_date) < getdate(self.scheduled_date)):
+ frappe.throw(_('Expected and Discharge dates cannot be less than Admission Schedule date'))
+
def validate_already_scheduled_or_admitted(self):
query = """
select name, status
@@ -59,37 +60,76 @@ class InpatientRecord(Document):
if service_unit:
transfer_patient(self, service_unit, check_in)
+
@frappe.whitelist()
-def schedule_inpatient(patient, encounter_id, practitioner):
- patient_obj = frappe.get_doc('Patient', patient)
+def schedule_inpatient(args):
+ admission_order = json.loads(args) # admission order via Encounter
+ if not admission_order or not admission_order['patient'] or not admission_order['admission_encounter']:
+ frappe.throw(_('Missing required details, did not create Inpatient Record'))
+
inpatient_record = frappe.new_doc('Inpatient Record')
- inpatient_record.patient = patient
- inpatient_record.patient_name = patient_obj.patient_name
- inpatient_record.gender = patient_obj.sex
- inpatient_record.blood_group = patient_obj.blood_group
- inpatient_record.dob = patient_obj.dob
- inpatient_record.mobile = patient_obj.mobile
- inpatient_record.email = patient_obj.email
- inpatient_record.phone = patient_obj.phone
- inpatient_record.status = "Admission Scheduled"
+
+ # Admission order details
+ set_details_from_ip_order(inpatient_record, admission_order)
+
+ # Patient details
+ patient = frappe.get_doc('Patient', admission_order['patient'])
+ inpatient_record.patient = patient.name
+ inpatient_record.patient_name = patient.patient_name
+ inpatient_record.gender = patient.sex
+ inpatient_record.blood_group = patient.blood_group
+ inpatient_record.dob = patient.dob
+ inpatient_record.mobile = patient.mobile
+ inpatient_record.email = patient.email
+ inpatient_record.phone = patient.phone
inpatient_record.scheduled_date = today()
- inpatient_record.admission_practitioner = practitioner
- inpatient_record.admission_encounter = encounter_id
+
+ # Set encounter detials
+ encounter = frappe.get_doc('Patient Encounter', admission_order['admission_encounter'])
+ if encounter and encounter.symptoms: # Symptoms
+ set_ip_child_records(inpatient_record, 'chief_complaint', encounter.symptoms)
+
+ if encounter and encounter.diagnosis: # Diagnosis
+ set_ip_child_records(inpatient_record, 'diagnosis', encounter.diagnosis)
+
+ if encounter and encounter.drug_prescription: # Medication
+ set_ip_child_records(inpatient_record, 'drug_prescription', encounter.drug_prescription)
+
+ if encounter and encounter.lab_test_prescription: # Lab Tests
+ set_ip_child_records(inpatient_record, 'lab_test_prescription', encounter.lab_test_prescription)
+
+ if encounter and encounter.procedure_prescription: # Procedure Prescription
+ set_ip_child_records(inpatient_record, 'procedure_prescription', encounter.procedure_prescription)
+
+ if encounter and encounter.therapies: # Therapies
+ inpatient_record.therapy_plan = encounter.therapy_plan
+ set_ip_child_records(inpatient_record, 'therapies', encounter.therapies)
+
+ inpatient_record.status = 'Admission Scheduled'
inpatient_record.save(ignore_permissions = True)
@frappe.whitelist()
-def schedule_discharge(patient, encounter_id=None, practitioner=None):
- inpatient_record_id = frappe.db.get_value('Patient', patient, 'inpatient_record')
+def schedule_discharge(args):
+ discharge_order = json.loads(args)
+ inpatient_record_id = frappe.db.get_value('Patient', discharge_order['patient'], 'inpatient_record')
if inpatient_record_id:
- inpatient_record = frappe.get_doc("Inpatient Record", inpatient_record_id)
- inpatient_record.discharge_practitioner = practitioner
- inpatient_record.discharge_encounter = encounter_id
- inpatient_record.status = "Discharge Scheduled"
-
+ inpatient_record = frappe.get_doc('Inpatient Record', inpatient_record_id)
check_out_inpatient(inpatient_record)
-
+ set_details_from_ip_order(inpatient_record, discharge_order)
+ inpatient_record.status = 'Discharge Scheduled'
inpatient_record.save(ignore_permissions = True)
- frappe.db.set_value("Patient", patient, "inpatient_status", "Discharge Scheduled")
+ frappe.db.set_value('Patient', discharge_order['patient'], 'inpatient_status', inpatient_record.status)
+ frappe.db.set_value('Patient Encounter', inpatient_record.discharge_encounter, 'inpatient_status', inpatient_record.status)
+
+def set_details_from_ip_order(inpatient_record, ip_order):
+ for key in ip_order:
+ inpatient_record.set(key, ip_order[key])
+
+def set_ip_child_records(inpatient_record, inpatient_record_child, encounter_child):
+ for item in encounter_child:
+ table = inpatient_record.append(inpatient_record_child)
+ for df in table.meta.get('fields'):
+ table.set(df.fieldname, item.get(df.fieldname))
def check_out_inpatient(inpatient_record):
if inpatient_record.inpatient_occupancies:
@@ -128,7 +168,7 @@ def validate_invoiced_inpatient(inpatient_record):
if pending_invoices:
frappe.throw(_("Can not mark Inpatient Record Discharged, there are Unbilled Invoices {0}").format(", "
- .join(pending_invoices)))
+ .join(pending_invoices)), title=_('Unbilled Invoices'))
def get_pending_doc(doc, doc_name_list, pending_invoices):
if doc_name_list:
@@ -144,19 +184,19 @@ def get_pending_doc(doc, doc_name_list, pending_invoices):
return pending_invoices
def get_inpatient_docs_not_invoiced(doc, inpatient_record):
- return frappe.db.get_list(doc, filters = {"patient": inpatient_record.patient,
- "inpatient_record": inpatient_record.name, "invoiced": 0})
+ return frappe.db.get_list(doc, filters = {'patient': inpatient_record.patient,
+ 'inpatient_record': inpatient_record.name, 'docstatus': 1, 'invoiced': 0})
def admit_patient(inpatient_record, service_unit, check_in, expected_discharge=None):
inpatient_record.admitted_datetime = check_in
- inpatient_record.status = "Admitted"
+ inpatient_record.status = 'Admitted'
inpatient_record.expected_discharge = expected_discharge
inpatient_record.set('inpatient_occupancies', [])
transfer_patient(inpatient_record, service_unit, check_in)
- frappe.db.set_value("Patient", inpatient_record.patient, "inpatient_status", "Admitted")
- frappe.db.set_value("Patient", inpatient_record.patient, "inpatient_record", inpatient_record.name)
+ frappe.db.set_value('Patient', inpatient_record.patient, 'inpatient_status', 'Admitted')
+ frappe.db.set_value('Patient', inpatient_record.patient, 'inpatient_record', inpatient_record.name)
def transfer_patient(inpatient_record, service_unit, check_in):
item_line = inpatient_record.append('inpatient_occupancies', {})
diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
index e15324c55bf..4c2d3f692a2 100644
--- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
+++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
@@ -8,7 +8,6 @@ import unittest
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.patient_appointment.test_patient_appointment import create_patient
class TestInpatientRecord(unittest.TestCase):
def test_admit_and_discharge(self):
@@ -112,3 +111,13 @@ def get_service_unit_type():
service_unit_type.save(ignore_permissions = True)
return service_unit_type.name
return service_unit_type
+
+def create_patient():
+ patient = frappe.db.exists('Patient', '_Test IPD Patient')
+ if not patient:
+ patient = frappe.new_doc('Patient')
+ patient.first_name = '_Test IPD Patient'
+ patient.sex = 'Female'
+ patient.save(ignore_permissions=True)
+ patient = patient.name
+ return patient
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.js b/erpnext/healthcare/doctype/lab_test/lab_test.js
index 5b3f4c705ad..bf1ecc87e4c 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.js
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.js
@@ -137,13 +137,13 @@ var get_lab_test_prescribed = function(frm){
});
}
else{
- frappe.msgprint(__("Please select Patient to get Lab Tests"));
+ frappe.msgprint(__("Please select a Patient to get Lab Tests"));
}
};
var show_lab_tests = function(frm, result){
var d = new frappe.ui.Dialog({
- title: __("Lab Test Prescriptions"),
+ title: __("Lab Tests"),
fields: [
{
fieldtype: "HTML", fieldname: "lab_test"
@@ -161,7 +161,7 @@ var show_lab_tests = function(frm, result){
', {name:y[0], lab_test: y[1], encounter:y[2], invoiced:y[3], practitioner:y[4], date:y[5]})).appendTo(html_field);
row.find("a").click(function() {
frm.doc.template = $(this).attr("data-lab-test");
@@ -180,9 +180,10 @@ var show_lab_tests = function(frm, result){
return false;
});
});
- if(!result){
- var msg = "There are no Lab Test prescribed for "+frm.doc.patient;
- $(repl('%(msg)s
', {msg: msg})).appendTo(html_field);
+ if(!result.length){
+ var msg = __("No Lab Tests found for the Patient {0}", [frm.doc.patient_name.bold()]);
+ html_field.empty();
+ $(repl('%(msg)s
', {msg: msg})).appendTo(html_field);
}
d.show();
};
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.json b/erpnext/healthcare/doctype/lab_test/lab_test.json
index ccbc24b3fb6..17dc1edd8c1 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.json
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.json
@@ -9,18 +9,18 @@
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
- "inpatient_record",
"naming_series",
- "invoiced",
"patient",
"patient_name",
"patient_age",
"patient_sex",
- "practitioner",
+ "report_preference",
"email",
"mobile",
- "company",
+ "practitioner",
"c_b",
+ "inpatient_record",
+ "company",
"department",
"status",
"submitted_date",
@@ -31,7 +31,7 @@
"employee_name",
"employee_designation",
"user",
- "report_preference",
+ "invoiced",
"sb_first",
"lab_test_name",
"column_break_26",
@@ -153,7 +153,7 @@
{
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 1,
+ "in_standard_filter": 1,
"label": "Company",
"options": "Company",
"print_hide": 1,
@@ -168,6 +168,7 @@
"fieldname": "department",
"fieldtype": "Link",
"ignore_user_permissions": 1,
+ "in_standard_filter": 1,
"label": "Department",
"options": "Medical Department",
"search_index": 1
@@ -427,7 +428,7 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-23 19:37:06.617764",
+ "modified": "2020-04-04 19:16:29.131168",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test",
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index ea8ce25c975..b2c5e6bf437 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -69,9 +69,9 @@ def create_multiple(doctype, docname):
lab_test_created = create_lab_test_from_encounter(docname)
if lab_test_created:
- frappe.msgprint(_("Lab Test(s) "+lab_test_created+" created."))
+ frappe.msgprint(_("Lab Test(s) {0} created".format(lab_test_created)))
else:
- frappe.msgprint(_("No Lab Test created"))
+ frappe.msgprint(_("No Lab Tests created"))
def create_lab_test_from_encounter(encounter_id):
lab_test_created = False
@@ -87,7 +87,7 @@ def create_lab_test_from_encounter(encounter_id):
for lab_test_id in lab_test_ids:
template = get_lab_test_template(lab_test_id[1])
if template:
- lab_test = create_lab_test_doc(lab_test_id[2], encounter.practitioner, patient, template)
+ lab_test = create_lab_test_doc(lab_test_id[2], encounter.practitioner, patient, template, encounter.company)
lab_test.save(ignore_permissions = True)
frappe.db.set_value("Lab Prescription", lab_test_id[0], "lab_test_created", 1)
if not lab_test_created:
@@ -111,7 +111,7 @@ def create_lab_test_from_invoice(invoice_name):
if lab_test_created != 1:
template = get_lab_test_template(item.item_code)
if template:
- lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template)
+ lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template, invoice.company)
if item.reference_dt == "Lab Prescription":
lab_test.prescription = item.reference_dn
lab_test.save(ignore_permissions = True)
@@ -121,7 +121,7 @@ def create_lab_test_from_invoice(invoice_name):
if not lab_tests_created:
lab_tests_created = lab_test.name
else:
- lab_tests_created += ", "+lab_test.name
+ lab_tests_created += ", " + lab_test.name
return lab_tests_created
def get_lab_test_template(item):
@@ -141,7 +141,7 @@ def check_template_exists(item):
return template_exists
return False
-def create_lab_test_doc(invoiced, practitioner, patient, template):
+def create_lab_test_doc(invoiced, practitioner, patient, template, company):
lab_test = frappe.new_doc("Lab Test")
lab_test.invoiced = invoiced
lab_test.practitioner = practitioner
@@ -150,11 +150,12 @@ def create_lab_test_doc(invoiced, practitioner, patient, template):
lab_test.patient_sex = patient.sex
lab_test.email = patient.email
lab_test.mobile = patient.mobile
+ lab_test.report_preference = patient.report_preference
lab_test.department = template.department
lab_test.template = template.name
lab_test.lab_test_group = template.lab_test_group
lab_test.result_date = getdate()
- lab_test.report_preference = patient.report_preference
+ lab_test.company = company
return lab_test
def create_normals(template, lab_test):
@@ -190,7 +191,7 @@ def create_specials(template, lab_test):
special.require_result_value = 1
special.template = template.name
-def create_sample_doc(template, patient, invoice):
+def create_sample_doc(template, patient, invoice, company = None):
if template.sample:
sample_exists = frappe.db.exists({
"doctype": "Sample Collection",
@@ -221,6 +222,8 @@ def create_sample_doc(template, patient, invoice):
sample_collection.sample = template.sample
sample_collection.sample_uom = template.sample_uom
sample_collection.sample_qty = template.sample_qty
+ sample_collection.company = company
+
if(template.sample_details):
sample_collection.sample_details = "Test :" + (template.get("lab_test_name") or template.get("template")) +"\n"+"Collection Detials:\n\t"+template.sample_details
sample_collection.save(ignore_permissions=True)
@@ -229,7 +232,7 @@ def create_sample_doc(template, patient, invoice):
def create_sample_collection(lab_test, template, patient, invoice):
if(frappe.db.get_value("Healthcare Settings", None, "create_sample_collection_for_lab_test") == "1"):
- sample_collection = create_sample_doc(template, patient, invoice)
+ sample_collection = create_sample_doc(template, patient, invoice, lab_test.company)
if(sample_collection):
lab_test.sample = sample_collection.name
return lab_test
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 e2b47b45593..3521561f34a 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
@@ -115,7 +115,7 @@ def make_item_price(item, price_list_name, item_price):
"price_list": price_list_name,
"item_code": item,
"price_list_rate": item_price
- }).insert(ignore_permissions=True)
+ }).insert(ignore_permissions=True, ignore_mandatory=True)
@frappe.whitelist()
def change_test_code_from_template(lab_test_code, doc):
diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js
index d5df9567ec5..490f2475001 100644
--- a/erpnext/healthcare/doctype/patient/patient.js
+++ b/erpnext/healthcare/doctype/patient/patient.js
@@ -10,6 +10,8 @@ frappe.ui.form.on('Patient', {
]
};
});
+ frm.set_query('customer_group', {'is_group': 0});
+ frm.set_query('default_price_list', { 'selling': 1});
if (frappe.defaults.get_default('patient_name_by') != 'Naming Series') {
frm.toggle_display('naming_series', false);
@@ -40,6 +42,7 @@ frappe.ui.form.on('Patient', {
frm.add_custom_button(__('Patient Encounter'), function () {
create_encounter(frm);
}, 'Create');
+ frm.toggle_enable(['customer'], 0); // ToDo, allow change only if no transactions booked or better, add merge option
}
},
onload: function (frm) {
diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json
index 4258e4011de..8af1a9ccd75 100644
--- a/erpnext/healthcare/doctype/patient/patient.json
+++ b/erpnext/healthcare/doctype/patient/patient.json
@@ -24,13 +24,20 @@
"image",
"column_break_14",
"status",
- "inpatient_status",
"inpatient_record",
- "customer",
+ "inpatient_status",
+ "report_preference",
"mobile",
"email",
"phone",
- "report_preference",
+ "customer_details_section",
+ "customer",
+ "customer_group",
+ "territory",
+ "column_break_24",
+ "default_currency",
+ "default_price_list",
+ "language",
"personal_and_social_history",
"occupation",
"column_break_25",
@@ -52,9 +59,7 @@
"surrounding_factors",
"other_risk_factors",
"more_info",
- "patient_details",
- "ac_sb",
- "default_currency"
+ "patient_details"
],
"fields": [
{
@@ -67,6 +72,7 @@
{
"fieldname": "inpatient_status",
"fieldtype": "Select",
+ "in_preview": 1,
"label": "Inpatient Status",
"options": "\nAdmission Scheduled\nAdmitted\nDischarge Scheduled",
"read_only": 1
@@ -101,6 +107,7 @@
{
"fieldname": "sex",
"fieldtype": "Link",
+ "in_preview": 1,
"label": "Gender",
"options": "Gender",
"reqd": 1
@@ -109,6 +116,7 @@
"bold": 1,
"fieldname": "blood_group",
"fieldtype": "Select",
+ "in_preview": 1,
"label": "Blood Group",
"options": "\nA Positive\nA Negative\nAB Positive\nAB Negative\nB Positive\nB Negative\nO Positive\nO Negative"
},
@@ -116,6 +124,7 @@
"bold": 1,
"fieldname": "dob",
"fieldtype": "Date",
+ "in_preview": 1,
"label": "Date of birth"
},
{
@@ -142,6 +151,7 @@
"fieldname": "image",
"fieldtype": "Attach Image",
"hidden": 1,
+ "in_preview": 1,
"label": "Image",
"no_copy": 1,
"print_hide": 1,
@@ -157,7 +167,8 @@
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Customer",
- "options": "Customer"
+ "options": "Customer",
+ "set_only_once": 1
},
{
"fieldname": "report_preference",
@@ -171,7 +182,8 @@
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
- "label": "Mobile"
+ "label": "Mobile",
+ "options": "Phone"
},
{
"bold": 1,
@@ -186,7 +198,8 @@
"fieldname": "phone",
"fieldtype": "Data",
"in_filter": 1,
- "label": "Phone"
+ "label": "Phone",
+ "options": "Phone"
},
{
"collapsible": 1,
@@ -268,25 +281,25 @@
"fieldname": "tobacco_past_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Tobacco Consumption Habbits (Past)"
+ "label": "Tobacco Consumption (Past)"
},
{
"fieldname": "tobacco_current_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Tobacco Consumption Habbits (Present)"
+ "label": "Tobacco Consumption (Present)"
},
{
"fieldname": "alcohol_past_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Alcohol Consumption Habbits (Past)"
+ "label": "Alcohol Consumption (Past)"
},
{
"fieldname": "alcohol_current_use",
"fieldtype": "Data",
"ignore_user_permissions": 1,
- "label": "Alcohol Consumption Habbits (Present)"
+ "label": "Alcohol Consumption (Present)"
},
{
"fieldname": "column_break_32",
@@ -320,20 +333,11 @@
"ignore_xss_filter": 1,
"label": "Patient Details"
},
- {
- "collapsible": 1,
- "fieldname": "ac_sb",
- "fieldtype": "Section Break",
- "label": "Account Details"
- },
{
"fieldname": "default_currency",
"fieldtype": "Link",
- "hidden": 1,
- "ignore_xss_filter": 1,
- "label": "Default Currency",
- "options": "Currency",
- "print_hide": 1
+ "label": "Billing Currency",
+ "options": "Currency"
},
{
"fieldname": "last_name",
@@ -351,13 +355,47 @@
"fieldname": "middle_name",
"fieldtype": "Data",
"label": "Middle Name (optional)"
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "customer_details_section",
+ "fieldtype": "Section Break",
+ "label": "Customer Details"
+ },
+ {
+ "fieldname": "customer_group",
+ "fieldtype": "Link",
+ "label": "Customer Group",
+ "options": "Customer Group"
+ },
+ {
+ "fieldname": "territory",
+ "fieldtype": "Link",
+ "label": "Territory",
+ "options": "Territory"
+ },
+ {
+ "fieldname": "column_break_24",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "default_price_list",
+ "fieldtype": "Link",
+ "label": "Default Price List",
+ "options": "Price List"
+ },
+ {
+ "fieldname": "language",
+ "fieldtype": "Link",
+ "label": "Print Language",
+ "options": "Language"
}
],
"icon": "fa fa-user",
"image_field": "image",
"links": [],
"max_attachments": 50,
- "modified": "2020-04-06 12:55:30.807744",
+ "modified": "2020-04-25 17:24:32.146415",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient",
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index e304a0bbc36..30a1e45f0ee 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -10,6 +10,7 @@ from frappe.utils import cint, cstr, getdate
import dateutil
from frappe.model.naming import set_name_by_naming_series
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
class Patient(Document):
@@ -17,6 +18,9 @@ class Patient(Document):
self.set_full_name()
self.add_as_website_user()
+ def before_insert(self):
+ self.set_missing_customer_details()
+
def after_insert(self):
self.add_as_website_user()
self.reload()
@@ -26,6 +30,25 @@ class Patient(Document):
frappe.db.set_value('Patient', self.name, 'status', 'Disabled')
else:
send_registration_sms(self)
+ self.reload() # self.notify_update()
+
+ def on_update(self):
+ if self.customer:
+ customer = frappe.get_doc('Customer', self.customer)
+ if self.customer_group:
+ customer.customer_group = self.customer_group
+ if self.territory:
+ customer.territory = self.territory
+
+ customer.customer_name = self.patient_name
+ customer.default_price_list = self.default_price_list
+ customer.default_currency = self.default_currency
+ customer.language = self.language
+ customer.ignore_mandatory = True
+ customer.save(ignore_permissions=True)
+ else:
+ if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+ create_customer(self)
def set_full_name(self):
if self.last_name:
@@ -33,6 +56,22 @@ class Patient(Document):
else:
self.patient_name = self.first_name
+ def set_missing_customer_details(self):
+ if not self.customer_group:
+ self.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') or get_root_of('Customer Group')
+ if not self.territory:
+ self.territory = frappe.db.get_single_value('Selling Settings', 'territory') or get_root_of('Territory')
+ if not self.default_price_list:
+ self.default_price_list = frappe.db.get_single_value('Selling Settings', 'selling_price_list')
+
+ if not self.customer_group or not self.territory or not self.default_price_list:
+ frappe.msgprint(_('Please set defaults for Customer Group, Territory and Selling Price List in Selling Settings'), alert=True)
+
+ if not self.default_currency:
+ self.default_currency = get_default_currency()
+ if not self.language:
+ self.language = frappe.db.get_single_value('System Settings', 'language')
+
def add_as_website_user(self):
if self.email:
if not frappe.db.exists ('User', self.email):
@@ -86,19 +125,15 @@ class Patient(Document):
return {'invoice': sales_invoice.name}
def create_customer(doc):
- customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group')
- territory = frappe.db.get_single_value('Selling Settings', 'territory')
- if not (customer_group and territory):
- customer_group = get_root_of('Customer Group')
- territory = get_root_of('Territory')
- frappe.msgprint(_('Please set default customer group and territory in Selling Settings'), alert=True)
-
customer = frappe.get_doc({
'doctype': 'Customer',
'customer_name': doc.patient_name,
- 'customer_group': customer_group,
- 'territory' : territory,
- 'customer_type': 'Individual'
+ 'customer_group': doc.customer_group or frappe.db.get_single_value('Selling Settings', 'customer_group'),
+ 'territory' : doc.territory or frappe.db.get_single_value('Selling Settings', 'territory'),
+ 'customer_type': 'Individual',
+ 'default_currency': doc.default_currency,
+ 'default_price_list': doc.default_price_list,
+ 'language': doc.language
}).insert(ignore_permissions=True, ignore_mandatory=True)
frappe.db.set_value('Patient', doc.name, 'customer', customer.name)
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index fa589347ffa..f7ed31bfeab 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -32,8 +32,9 @@ frappe.ui.form.on('Patient Appointment', {
frm.set_query('service_unit', function(){
return {
filters: {
- 'is_group': 0,
- 'allow_appointments': 1
+ 'is_group': false,
+ 'allow_appointments': true,
+ 'company': frm.doc.company
}
};
});
@@ -127,6 +128,11 @@ frappe.ui.form.on('Patient Appointment', {
patient: function(frm) {
if (frm.doc.patient) {
frm.trigger('toggle_payment_fields');
+ } else {
+ frm.set_value('patient_name', '');
+ frm.set_value('patient_sex', '');
+ frm.set_value('patient_age', '');
+ frm.set_value('inpatient_record', '');
}
},
@@ -230,7 +236,6 @@ let check_and_set_availability = function(frm) {
d.hide();
frm.enable_save();
frm.save();
- frm.enable_save();
d.get_primary_btn().attr('disabled', true);
}
});
@@ -481,6 +486,7 @@ let create_vital_signs = function(frm) {
frappe.route_options = {
'patient': frm.doc.patient,
'appointment': frm.doc.name,
+ 'company': frm.doc.company
};
frappe.new_doc('Vital Signs');
};
@@ -513,6 +519,7 @@ frappe.ui.form.on('Patient Appointment', 'practitioner', function(frm) {
callback: function (data) {
frappe.model.set_value(frm.doctype, frm.docname, 'department', data.message.department);
frappe.model.set_value(frm.doctype, frm.docname, 'paid_amount', data.message.op_consulting_charge);
+ frappe.model.set_value(frm.doctype, frm.docname, 'billing_item', data.message.op_consulting_charge_item);
}
});
}
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
index 57e6c479d1e..ac35acc21ac 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
@@ -10,40 +10,44 @@
"engine": "InnoDB",
"field_order": [
"naming_series",
+ "title",
+ "status",
"patient",
"patient_name",
"patient_sex",
"patient_age",
"inpatient_record",
"column_break_1",
- "status",
+ "company",
+ "service_unit",
"procedure_template",
"get_procedure_from_encounter",
"procedure_prescription",
"therapy_type",
"get_prescribed_therapies",
"therapy_plan",
- "service_unit",
- "section_break_12",
"practitioner",
+ "practitioner_name",
"department",
+ "section_break_12",
"appointment_type",
+ "duration",
"column_break_17",
"appointment_date",
"appointment_time",
"appointment_datetime",
- "duration",
"section_break_16",
"mode_of_payment",
- "paid_amount",
- "company",
- "column_break_2",
+ "billing_item",
"invoiced",
+ "column_break_2",
+ "paid_amount",
"ref_sales_invoice",
"section_break_3",
- "notes",
"referring_practitioner",
- "reminded"
+ "reminded",
+ "column_break_36",
+ "notes"
],
"fields": [
{
@@ -55,7 +59,6 @@
"read_only": 1
},
{
- "fetch_from": "inpatient_record.patient",
"fieldname": "patient",
"fieldtype": "Link",
"ignore_user_permissions": 1,
@@ -79,7 +82,8 @@
"fieldname": "duration",
"fieldtype": "Int",
"in_filter": 1,
- "label": "Duration (In Minutes)"
+ "label": "Duration (In Minutes)",
+ "set_only_once": 1
},
{
"fieldname": "column_break_1",
@@ -98,6 +102,7 @@
"search_index": 1
},
{
+ "depends_on": "eval:doc.patient;",
"fieldname": "procedure_template",
"fieldtype": "Link",
"label": "Clinical Procedure Template",
@@ -117,7 +122,8 @@
"label": "Procedure Prescription",
"no_copy": 1,
"options": "Procedure Prescription",
- "print_hide": 1
+ "print_hide": 1,
+ "read_only": 1
},
{
"fieldname": "service_unit",
@@ -128,7 +134,8 @@
},
{
"fieldname": "section_break_12",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Appointment Details"
},
{
"fieldname": "practitioner",
@@ -143,6 +150,7 @@
"set_only_once": 1
},
{
+ "fetch_from": "practitioner.department",
"fieldname": "department",
"fieldtype": "Link",
"ignore_user_permissions": 1,
@@ -173,11 +181,13 @@
"fieldtype": "Time",
"in_list_view": 1,
"label": "Time",
- "read_only": 1
+ "read_only": 1,
+ "reqd": 1
},
{
"fieldname": "section_break_16",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Payments"
},
{
"fetch_from": "patient.patient_name",
@@ -206,6 +216,7 @@
{
"fieldname": "appointment_datetime",
"fieldtype": "Datetime",
+ "hidden": 1,
"label": "Appointment Datetime",
"print_hide": 1,
"read_only": 1,
@@ -237,12 +248,12 @@
{
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 1,
+ "in_standard_filter": 1,
"label": "Company",
"no_copy": 1,
"options": "Company",
- "print_hide": 1,
- "report_hide": 1
+ "reqd": 1,
+ "set_only_once": 1
},
{
"collapsible": 1,
@@ -307,10 +318,37 @@
"label": "Series",
"options": "HLC-APP-.YYYY.-",
"set_only_once": 1
+ },
+ {
+ "fieldname": "billing_item",
+ "fieldtype": "Link",
+ "label": "Billing Item",
+ "options": "Item",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_36",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Title",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fetch_from": "practitioner.practitioner_name",
+ "fieldname": "practitioner_name",
+ "fieldtype": "Data",
+ "label": "Practitioner Name",
+ "read_only": 1
}
],
"links": [],
- "modified": "2020-03-31 16:16:32.116865",
+ "modified": "2020-05-21 03:04:21.400893",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Appointment",
@@ -358,7 +396,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
- "title_field": "patient",
+ "title_field": "title",
"track_changes": 1,
"track_seen": 1
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index c4ec30f0469..512fb48360f 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -21,6 +21,7 @@ class PatientAppointment(Document):
self.set_appointment_datetime()
self.validate_customer_created()
self.set_status()
+ self.set_title()
def after_insert(self):
self.update_prescription_details()
@@ -28,6 +29,10 @@ class PatientAppointment(Document):
self.update_fee_validity()
send_confirmation_msg(self)
+ def set_title(self):
+ self.title = _('{0} with {1}').format(self.patient_name or self.patient,
+ self.practitioner_name or self.practitioner)
+
def set_status(self):
today = getdate()
appointment_date = getdate(self.appointment_date)
@@ -119,25 +124,28 @@ def invoice_appointment(appointment_doc):
if automate_invoicing and not appointment_invoiced and not fee_validity:
sales_invoice = frappe.new_doc('Sales Invoice')
+ sales_invoice.patient = appointment_doc.patient
sales_invoice.customer = frappe.get_value('Patient', appointment_doc.patient, 'customer')
sales_invoice.appointment = appointment_doc.name
sales_invoice.due_date = getdate()
- sales_invoice.is_pos = 1
sales_invoice.company = appointment_doc.company
sales_invoice.debit_to = get_receivable_account(appointment_doc.company)
item = sales_invoice.append('items', {})
item = get_appointment_item(appointment_doc, item)
- payment = sales_invoice.append('payments', {})
- payment.mode_of_payment = appointment_doc.mode_of_payment
- payment.amount = appointment_doc.paid_amount
+ # Add payments if payment details are supplied else proceed to create invoice as Unpaid
+ if appointment_doc.mode_of_payment and appointment_doc.paid_amount:
+ sales_invoice.is_pos = 1
+ payment = sales_invoice.append('payments', {})
+ payment.mode_of_payment = appointment_doc.mode_of_payment
+ payment.amount = appointment_doc.paid_amount
sales_invoice.set_missing_values(for_validate=True)
sales_invoice.flags.ignore_mandatory = True
sales_invoice.save(ignore_permissions=True)
sales_invoice.submit()
- frappe.msgprint(_('Sales Invoice {0} created as paid'.format(sales_invoice.name)), alert=True)
+ frappe.msgprint(_('Sales Invoice {0} created'.format(sales_invoice.name)), alert=True)
frappe.db.set_value('Patient Appointment', appointment_doc.name, 'invoiced', 1)
frappe.db.set_value('Patient Appointment', appointment_doc.name, 'ref_sales_invoice', sales_invoice.name)
@@ -343,8 +351,8 @@ def make_encounter(source_name, target_doc=None):
['practitioner', 'practitioner'],
['medical_department', 'department'],
['patient_sex', 'patient_sex'],
- ['encounter_date', 'appointment_date'],
- ['invoiced', 'invoiced']
+ ['invoiced', 'invoiced'],
+ ['company', 'company']
]
}
}, target_doc)
@@ -370,17 +378,19 @@ def send_appointment_reminder():
frappe.db.set_value('Patient Appointment', doc.name, 'reminded', 1)
def send_message(doc, message):
- patient = frappe.get_doc('Patient', doc.patient)
- if patient.mobile:
+ patient_mobile = frappe.db.get_value('Patient', doc.patient, 'mobile')
+ if patient_mobile:
context = {'doc': doc, 'alert': doc, 'comments': None}
if doc.get('_comments'):
context['comments'] = json.loads(doc.get('_comments'))
# jinja to string convertion happens here
message = frappe.render_template(message, context)
- number = [patient.mobile]
- send_sms(number, message)
-
+ number = [patient_mobile]
+ try:
+ send_sms(number, message)
+ except Exception as e:
+ frappe.msgprint(_('SMS not sent, please check SMS Settings'), alert=True)
@frappe.whitelist()
def get_events(start, end, filters=None):
@@ -437,7 +447,7 @@ def get_prescribed_therapies(patient):
"""
SELECT
t.therapy_type, t.name, t.parent, e.practitioner,
- e.encounter_date, e.therapy_plan, e.visit_department
+ e.encounter_date, e.therapy_plan, e.medical_department
FROM
`tabPatient Encounter` e, `tabTherapy Plan Detail` t
WHERE
diff --git a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
index 7075af5d00c..eeed157291e 100644
--- a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
@@ -4,14 +4,15 @@
from __future__ import unicode_literals
import unittest
import frappe
-from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status
+from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status, make_encounter
from frappe.utils import nowdate, add_days
from frappe.utils.make_random import get_random
class TestPatientAppointment(unittest.TestCase):
def setUp(self):
frappe.db.sql("""delete from `tabPatient Appointment`""")
- frappe.db.sql("""delete from `tabFee Validity""")
+ frappe.db.sql("""delete from `tabFee Validity`""")
+ frappe.db.sql("""delete from `tabPatient Encounter`""")
def test_status(self):
patient, medical_department, practitioner = create_healthcare_docs()
@@ -23,6 +24,19 @@ class TestPatientAppointment(unittest.TestCase):
create_encounter(appointment)
self.assertEquals(frappe.db.get_value('Patient Appointment', appointment.name, 'status'), 'Closed')
+ def test_start_encounter(self):
+ patient, medical_department, practitioner = create_healthcare_docs()
+ frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1)
+ appointment = create_appointment(patient, practitioner, add_days(nowdate(), 4), invoice = 1)
+ self.assertEqual(frappe.db.get_value('Patient Appointment', appointment.name, 'invoiced'), 1)
+ encounter = make_encounter(appointment.name)
+ self.assertTrue(encounter)
+ self.assertEqual(encounter.company, appointment.company)
+ self.assertEqual(encounter.practitioner, appointment.practitioner)
+ self.assertEqual(encounter.patient, appointment.patient)
+ # invoiced flag mapped from appointment
+ self.assertEqual(encounter.invoiced, frappe.db.get_value('Patient Appointment', appointment.name, 'invoiced'))
+
def test_invoicing(self):
patient, medical_department, practitioner = create_healthcare_docs()
frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0)
@@ -33,7 +47,11 @@ class TestPatientAppointment(unittest.TestCase):
frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1)
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 2), invoice=1)
self.assertEqual(frappe.db.get_value('Patient Appointment', appointment.name, 'invoiced'), 1)
- self.assertTrue(frappe.db.get_value('Patient Appointment', appointment.name, 'ref_sales_invoice'))
+ sales_invoice_name = frappe.db.get_value('Sales Invoice Item', {'reference_dn': appointment.name}, 'parent')
+ self.assertTrue(sales_invoice_name)
+ self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'company'), appointment.company)
+ self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'patient'), appointment.patient)
+ self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'paid_amount'), appointment.paid_amount)
def test_appointment_cancel(self):
patient, medical_department, practitioner = create_healthcare_docs()
@@ -53,8 +71,8 @@ class TestPatientAppointment(unittest.TestCase):
appointment = create_appointment(patient, practitioner, nowdate(), invoice=1)
update_status(appointment.name, 'Cancelled')
# check invoice cancelled
- sales_invoice = frappe.db.get_value('Patient Appointment', appointment.name, 'ref_sales_invoice')
- self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice, 'status'), 'Cancelled')
+ sales_invoice_name = frappe.db.get_value('Sales Invoice Item', {'reference_dn': appointment.name}, 'parent')
+ self.assertEqual(frappe.db.get_value('Sales Invoice', sales_invoice_name, 'status'), 'Cancelled')
def create_healthcare_docs():
@@ -90,14 +108,15 @@ def create_patient():
patient = patient.name
return patient
-def create_encounter(appointment=None):
- encounter = frappe.new_doc('Patient Encounter')
+def create_encounter(appointment):
if appointment:
+ encounter = frappe.new_doc('Patient Encounter')
encounter.appointment = appointment.name
encounter.patient = appointment.patient
encounter.practitioner = appointment.practitioner
encounter.encounter_date = appointment.appointment_date
encounter.encounter_time = appointment.appointment_time
+ encounter.company = appointment.company
encounter.save()
encounter.submit()
return encounter
diff --git a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
index 3952a8153f7..15c94344e9b 100644
--- a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
+++ b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.json
@@ -11,6 +11,7 @@
"patient",
"assessment_template",
"column_break_4",
+ "company",
"healthcare_practitioner",
"assessment_datetime",
"assessment_description",
@@ -127,11 +128,18 @@
"fieldname": "assessment_description",
"fieldtype": "Small Text",
"label": "Assessment Description"
+ },
+ {
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "in_standard_filter": 1,
+ "label": "Company",
+ "options": "Company"
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-21 13:23:09.815007",
+ "modified": "2020-05-25 14:38:38.302399",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Assessment",
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
index 78e789d3594..edcee99d4bc 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
@@ -25,15 +25,16 @@ frappe.ui.form.on('Patient Encounter', {
refresh_field('lab_test_prescription');
if (!frm.doc.__islocal) {
-
- if (frm.doc.inpatient_status == 'Admission Scheduled' || frm.doc.inpatient_status == 'Admitted') {
- frm.add_custom_button(__('Schedule Discharge'), function() {
- schedule_discharge(frm);
- });
- } else if (frm.doc.inpatient_status != 'Discharge Scheduled') {
- frm.add_custom_button(__('Schedule Admission'), function() {
- schedule_inpatient(frm);
- });
+ if (frm.doc.docstatus === 1) {
+ if (frm.doc.inpatient_status == 'Admission Scheduled' || frm.doc.inpatient_status == 'Admitted') {
+ frm.add_custom_button(__('Schedule Discharge'), function() {
+ schedule_discharge(frm);
+ });
+ } else if (frm.doc.inpatient_status != 'Discharge Scheduled') {
+ frm.add_custom_button(__('Schedule Admission'), function() {
+ schedule_inpatient(frm);
+ });
+ }
}
frm.add_custom_button(__('Patient History'), function() {
@@ -101,6 +102,11 @@ frappe.ui.form.on('Patient Encounter', {
frm.events.set_patient_info(frm);
},
+ practitioner: function(frm) {
+ if (!frm.doc.practitioner) {
+ frm.set_value('practitioner_name', '');
+ }
+ },
set_appointment_fields: function(frm) {
if (frm.doc.appointment) {
frappe.call({
@@ -114,9 +120,11 @@ frappe.ui.form.on('Patient Encounter', {
'patient':data.message.patient,
'type': data.message.appointment_type,
'practitioner': data.message.practitioner,
- 'invoiced': data.message.invoiced
+ 'invoiced': data.message.invoiced,
+ 'company': data.message.company
};
frm.set_value(values);
+ frm.set_df_property('patient', 'read_only', 1);
}
});
}
@@ -133,6 +141,7 @@ frappe.ui.form.on('Patient Encounter', {
'inpatient_status': ''
};
frm.set_value(values);
+ frm.set_df_property('patient', 'read_only', 0);
}
},
@@ -148,52 +157,137 @@ frappe.ui.form.on('Patient Encounter', {
if (data.message.dob) {
age = calculate_age(data.message.dob);
}
- frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', age);
- frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', data.message.sex);
- if (data.message.inpatient_record) {
- frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', data.message.inpatient_record);
- frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', data.message.inpatient_status);
- }
+ let values = {
+ 'patient_age': age,
+ 'patient_name':data.message.patient_name,
+ 'patient_sex': data.message.sex,
+ 'inpatient_record': data.message.inpatient_record,
+ 'inpatient_status': data.message.inpatient_status
+ };
+ frm.set_value(values);
}
});
} else {
- frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', '');
- frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', '');
- frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', '');
- frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
+ let values = {
+ 'patient_age': '',
+ 'patient_name':'',
+ 'patient_sex': '',
+ 'inpatient_record': '',
+ 'inpatient_status': ''
+ };
+ frm.set_value(values);
}
}
});
-let schedule_inpatient = function(frm) {
- frappe.call({
- method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_inpatient',
- args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
- callback: function(data) {
- if (!data.exc) {
- frm.reload_doc();
+var schedule_inpatient = function(frm) {
+ var dialog = new frappe.ui.Dialog({
+ title: 'Patient Admission',
+ fields: [
+ {fieldtype: 'Link', label: 'Medical Department', fieldname: 'medical_department', options: 'Medical Department', reqd: 1},
+ {fieldtype: 'Link', label: 'Healthcare Practitioner (Primary)', fieldname: 'primary_practitioner', options: 'Healthcare Practitioner', reqd: 1},
+ {fieldtype: 'Link', label: 'Healthcare Practitioner (Secondary)', fieldname: 'secondary_practitioner', options: 'Healthcare Practitioner'},
+ {fieldtype: 'Column Break'},
+ {fieldtype: 'Date', label: 'Admission Ordered For', fieldname: 'admission_ordered_for', default: 'Today'},
+ {fieldtype: 'Link', label: 'Service Unit Type', fieldname: 'service_unit_type', options: 'Healthcare Service Unit Type'},
+ {fieldtype: 'Int', label: 'Expected Length of Stay', fieldname: 'expected_length_of_stay'},
+ {fieldtype: 'Section Break'},
+ {fieldtype: 'Long Text', label: 'Admission Instructions', fieldname: 'admission_instruction'}
+ ],
+ primary_action_label: __('Order Admission'),
+ primary_action : function() {
+ var args = {
+ patient: frm.doc.patient,
+ admission_encounter: frm.doc.name,
+ referring_practitioner: frm.doc.practitioner,
+ company: frm.doc.company,
+ medical_department: dialog.get_value('medical_department'),
+ primary_practitioner: dialog.get_value('primary_practitioner'),
+ secondary_practitioner: dialog.get_value('secondary_practitioner'),
+ admission_ordered_for: dialog.get_value('admission_ordered_for'),
+ admission_service_unit_type: dialog.get_value('service_unit_type'),
+ expected_length_of_stay: dialog.get_value('expected_length_of_stay'),
+ admission_instruction: dialog.get_value('admission_instruction')
}
- },
- freeze: true,
- freeze_message: __('Process Inpatient Scheduling')
+ frappe.call({
+ method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_inpatient',
+ args: {
+ args: args
+ },
+ callback: function(data) {
+ if (!data.exc) {
+ frm.reload_doc();
+ }
+ },
+ freeze: true,
+ freeze_message: 'Scheduling Patient Admission'
+ });
+ frm.refresh_fields();
+ dialog.hide();
+ }
});
+
+ dialog.set_values({
+ 'medical_department': frm.doc.medical_department,
+ 'primary_practitioner': frm.doc.practitioner,
+ });
+
+ dialog.fields_dict['service_unit_type'].get_query = function() {
+ return {
+ filters: {
+ 'inpatient_occupancy': 1,
+ 'allow_appointments': 0
+ }
+ };
+ };
+
+ dialog.show();
+ dialog.$wrapper.find('.modal-dialog').css('width', '800px');
};
-let schedule_discharge = function(frm) {
- frappe.call({
- method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_discharge',
- args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
- callback: function(data) {
- if (!data.exc) {
- frm.reload_doc();
+var schedule_discharge = function(frm) {
+ var dialog = new frappe.ui.Dialog ({
+ title: 'Inpatient Discharge',
+ fields: [
+ {fieldtype: 'Date', label: 'Discharge Ordered Date', fieldname: 'discharge_ordered_date', default: 'Today', read_only: 1},
+ {fieldtype: 'Date', label: 'Followup Date', fieldname: 'followup_date'},
+ {fieldtype: 'Column Break'},
+ {fieldtype: 'Small Text', label: 'Discharge Instructions', fieldname: 'discharge_instructions'},
+ {fieldtype: 'Section Break', label:'Discharge Summary'},
+ {fieldtype: 'Long Text', label: 'Discharge Note', fieldname: 'discharge_note'}
+ ],
+ primary_action_label: __('Order Discharge'),
+ primary_action : function() {
+ var args = {
+ patient: frm.doc.patient,
+ discharge_encounter: frm.doc.name,
+ discharge_practitioner: frm.doc.practitioner,
+ discharge_ordered_date: dialog.get_value('discharge_ordered_date'),
+ followup_date: dialog.get_value('followup_date'),
+ discharge_instructions: dialog.get_value('discharge_instructions'),
+ discharge_note: dialog.get_value('discharge_note')
}
- },
- freeze: true,
- freeze_message: 'Process Discharge'
+ frappe.call ({
+ method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_discharge',
+ args: {args},
+ callback: function(data) {
+ if(!data.exc){
+ frm.reload_doc();
+ }
+ },
+ freeze: true,
+ freeze_message: 'Scheduling Inpatient Discharge'
+ });
+ frm.refresh_fields();
+ dialog.hide();
+ }
});
+
+ dialog.show();
+ dialog.$wrapper.find('.modal-dialog').css('width', '800px');
};
-let create_medical_record = function (frm) {
+let create_medical_record = function(frm) {
if (!frm.doc.patient) {
frappe.throw(__('Please select patient'));
}
@@ -206,25 +300,26 @@ let create_medical_record = function (frm) {
frappe.new_doc('Patient Medical Record');
};
-let create_vital_signs = function (frm) {
+let create_vital_signs = function(frm) {
if (!frm.doc.patient) {
frappe.throw(__('Please select patient'));
}
frappe.route_options = {
'patient': frm.doc.patient,
- 'appointment': frm.doc.appointment,
- 'encounter': frm.doc.name
+ 'encounter': frm.doc.name,
+ 'company': frm.doc.company
};
frappe.new_doc('Vital Signs');
};
-let create_procedure = function (frm) {
+let create_procedure = function(frm) {
if (!frm.doc.patient) {
frappe.throw(__('Please select patient'));
}
frappe.route_options = {
'patient': frm.doc.patient,
- 'medical_department': frm.doc.medical_department
+ 'medical_department': frm.doc.medical_department,
+ 'company': frm.doc.company
};
frappe.new_doc('Clinical Procedure');
};
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
index 5f11039e19b..15675f4673f 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
@@ -11,23 +11,23 @@
"engine": "InnoDB",
"field_order": [
"naming_series",
+ "title",
"appointment",
"appointment_type",
"patient",
"patient_name",
"patient_sex",
"patient_age",
- "company",
+ "inpatient_record",
+ "inpatient_status",
"column_break_6",
- "practitioner",
- "medical_department",
+ "company",
"encounter_date",
"encounter_time",
+ "practitioner",
+ "practitioner_name",
+ "medical_department",
"invoiced",
- "section_break_1",
- "inpatient_record",
- "column_break_17",
- "inpatient_status",
"sb_symptoms",
"symptoms",
"symptoms_in_print",
@@ -47,22 +47,18 @@
"therapies",
"section_break_33",
"encounter_comment",
+ "sb_refs",
"amended_from"
],
"fields": [
{
+ "allow_on_submit": 1,
"fieldname": "inpatient_record",
"fieldtype": "Link",
"label": "Inpatient Record",
"options": "Inpatient Record",
"read_only": 1
},
- {
- "collapsible": 1,
- "fieldname": "section_break_1",
- "fieldtype": "Section Break",
- "label": "Inpatient Details"
- },
{
"fieldname": "naming_series",
"fieldtype": "Select",
@@ -77,14 +73,13 @@
"ignore_user_permissions": 1,
"label": "Appointment",
"options": "Patient Appointment",
- "search_index": 1
+ "search_index": 1,
+ "set_only_once": 1
},
{
- "fetch_from": "inpatient_record.patient",
"fieldname": "patient",
"fieldtype": "Link",
"ignore_user_permissions": 1,
- "in_list_view": 1,
"in_standard_filter": 1,
"label": "Patient",
"options": "Patient",
@@ -92,7 +87,6 @@
"search_index": 1
},
{
- "fetch_from": "patient.patient_name",
"fieldname": "patient_name",
"fieldtype": "Data",
"label": "Patient Name",
@@ -114,7 +108,6 @@
{
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 1,
"label": "Company",
"options": "Company"
},
@@ -125,7 +118,6 @@
{
"fieldname": "practitioner",
"fieldtype": "Link",
- "in_list_view": 1,
"in_standard_filter": 1,
"label": "Healthcare Practitioner",
"options": "Healthcare Practitioner",
@@ -207,29 +199,29 @@
{
"fieldname": "codification_table",
"fieldtype": "Table",
- "label": "Medical Coding",
+ "label": "Medical Codes",
"options": "Codification Table"
},
{
"fieldname": "sb_drug_prescription",
"fieldtype": "Section Break",
- "label": "Medication"
+ "label": "Medications"
},
{
"fieldname": "drug_prescription",
"fieldtype": "Table",
- "label": "Drug Prescription",
+ "label": "Items",
"options": "Drug Prescription"
},
{
"fieldname": "sb_test_prescription",
"fieldtype": "Section Break",
- "label": "Investigation"
+ "label": "Investigations"
},
{
"fieldname": "lab_test_prescription",
"fieldtype": "Table",
- "label": "Lab Prescription",
+ "label": "Lab Tests",
"options": "Lab Prescription"
},
{
@@ -240,7 +232,7 @@
{
"fieldname": "procedure_prescription",
"fieldtype": "Table",
- "label": "Procedure Prescription",
+ "label": "Clinical Procedures",
"no_copy": 1,
"options": "Procedure Prescription"
},
@@ -299,26 +291,44 @@
"fieldname": "medical_department",
"fieldtype": "Link",
"ignore_user_permissions": 1,
- "in_list_view": 1,
"in_standard_filter": 1,
"label": "Department",
"options": "Medical Department",
"read_only": 1
},
{
+ "allow_on_submit": 1,
"fieldname": "inpatient_status",
"fieldtype": "Data",
"label": "Inpatient Status",
"read_only": 1
},
{
- "fieldname": "column_break_17",
- "fieldtype": "Column Break"
+ "fieldname": "sb_refs",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fetch_from": "practitioner.practitioner_name",
+ "fieldname": "practitioner_name",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Practitioner Name",
+ "read_only": 1
+ },
+ {
+ "allow_on_submit": 1,
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Title",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-14 16:18:08.180457",
+ "modified": "2020-05-16 21:00:08.644531",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Encounter",
@@ -345,7 +355,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
- "title_field": "patient",
+ "title_field": "title",
"track_changes": 1,
"track_seen": 1
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
index 1734c28e52b..56401a3e742 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
@@ -10,6 +10,9 @@ from frappe.utils import cstr
from frappe import _
class PatientEncounter(Document):
+ def validate(self):
+ self.set_title()
+
def on_update(self):
if self.appointment:
frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Closed')
@@ -29,6 +32,10 @@ class PatientEncounter(Document):
def on_submit(self):
create_therapy_plan(self)
+ def set_title(self):
+ self.title = _('{0} with {1}').format(self.patient_name or self.patient,
+ self.practitioner_name or self.practitioner)[:100]
+
def create_therapy_plan(encounter):
if len(encounter.therapies):
doc = frappe.new_doc('Therapy Plan')
diff --git a/erpnext/healthcare/doctype/sample_collection/sample_collection.json b/erpnext/healthcare/doctype/sample_collection/sample_collection.json
index 39cead88621..016cfbc3ae2 100644
--- a/erpnext/healthcare/doctype/sample_collection/sample_collection.json
+++ b/erpnext/healthcare/doctype/sample_collection/sample_collection.json
@@ -9,14 +9,14 @@
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
- "inpatient_record",
"naming_series",
- "invoiced",
"patient",
- "column_break_4",
"patient_age",
"patient_sex",
+ "column_break_4",
+ "inpatient_record",
"company",
+ "invoiced",
"section_break_6",
"sample",
"sample_uom",
@@ -85,11 +85,9 @@
{
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 1,
+ "in_standard_filter": 1,
"label": "Company",
- "options": "Company",
- "print_hide": 1,
- "report_hide": 1
+ "options": "Company"
},
{
"fieldname": "section_break_6",
@@ -167,7 +165,7 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-25 16:55:52.376834",
+ "modified": "2020-05-25 14:36:46.990469",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Sample Collection",
diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
index ca78b6618ec..9edfeb2faa1 100644
--- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
+++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.json
@@ -10,6 +10,7 @@
"patient",
"patient_name",
"column_break_4",
+ "company",
"status",
"start_date",
"section_break_3",
@@ -98,10 +99,17 @@
"label": "Status",
"options": "Not Started\nIn Progress\nCompleted\nCancelled",
"read_only": 1
+ },
+ {
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "in_standard_filter": 1,
+ "label": "Company",
+ "options": "Company"
}
],
"links": [],
- "modified": "2020-04-21 13:13:43.956014",
+ "modified": "2020-05-25 14:38:53.649315",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Therapy Plan",
diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session.js b/erpnext/healthcare/doctype/therapy_session/therapy_session.js
index abe4defaf93..e66e66751aa 100644
--- a/erpnext/healthcare/doctype/therapy_session/therapy_session.js
+++ b/erpnext/healthcare/doctype/therapy_session/therapy_session.js
@@ -9,6 +9,16 @@ frappe.ui.form.on('Therapy Session', {
{fieldname: 'counts_completed', columns: 1},
{fieldname: 'assistance_level', columns: 1}
];
+
+ frm.set_query('service_unit', function() {
+ return {
+ filters: {
+ 'is_group': false,
+ 'allow_appointments': true,
+ 'company': frm.doc.company
+ }
+ };
+ });
},
refresh: function(frm) {
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.json b/erpnext/healthcare/doctype/vital_signs/vital_signs.json
index 75726dbe070..15ab5047bc4 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.json
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.json
@@ -2,18 +2,22 @@
"actions": [],
"allow_copy": 1,
"allow_import": 1,
+ "autoname": "naming_series:",
"beta": 1,
"creation": "2017-02-02 11:00:24.853005",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
- "inpatient_record",
+ "naming_series",
+ "title",
"patient",
"patient_name",
+ "inpatient_record",
"appointment",
"encounter",
"column_break_2",
+ "company",
"signs_date",
"signs_time",
"sb_vs",
@@ -34,7 +38,7 @@
"bmi",
"column_break_14",
"nutrition_note",
- "company",
+ "sb_references",
"amended_from"
],
"fields": [
@@ -68,7 +72,8 @@
"fieldname": "appointment",
"fieldtype": "Link",
"in_filter": 1,
- "label": "Appointment",
+ "label": "Patient Appointment",
+ "no_copy": 1,
"options": "Patient Appointment",
"print_hide": 1,
"read_only": 1
@@ -81,8 +86,7 @@
"no_copy": 1,
"options": "Patient Encounter",
"print_hide": 1,
- "read_only": 1,
- "report_hide": 1
+ "read_only": 1
},
{
"fieldname": "column_break_2",
@@ -217,7 +221,6 @@
{
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 1,
"label": "Company",
"options": "Company"
},
@@ -229,11 +232,34 @@
"options": "Vital Signs",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "sb_references",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Series",
+ "options": "HLC-VTS-.YYYY.-",
+ "reqd": 1
+ },
+ {
+ "allow_on_submit": 1,
+ "columns": 5,
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Title",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-04 17:19:29.549889",
+ "modified": "2020-05-17 22:23:24.632286",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Vital Signs",
@@ -273,7 +299,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
- "title_field": "patient",
+ "title_field": "title",
"track_changes": 1,
"track_seen": 1
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
index b0e78e8eb94..69d81ff4b08 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
@@ -9,12 +9,19 @@ from frappe.utils import cstr
from frappe import _
class VitalSigns(Document):
+ def validate(self):
+ self.set_title()
+
def on_submit(self):
insert_vital_signs_to_medical_record(self)
def on_cancel(self):
delete_vital_signs_from_medical_record(self)
+ def set_title(self):
+ self.title = _('{0} on {1}').format(self.patient_name or self.patient,
+ frappe.utils.format_date(self.signs_date))[:100]
+
def insert_vital_signs_to_medical_record(doc):
subject = set_subject_field(doc)
medical_record = frappe.new_doc('Patient Medical Record')
diff --git a/erpnext/healthcare/module_onboarding/healthcare/healthcare.json b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json
new file mode 100644
index 00000000000..3e50726060a
--- /dev/null
+++ b/erpnext/healthcare/module_onboarding/healthcare/healthcare.json
@@ -0,0 +1,42 @@
+{
+ "allow_roles": [
+ {
+ "role": "Healthcare Administrator"
+ }
+ ],
+ "creation": "2020-05-19 10:32:43.025852",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/healthcare",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-26 23:16:37.603361",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Healthcare",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Create Patient"
+ },
+ {
+ "step": "Create Practitioner Schedule"
+ },
+ {
+ "step": "Introduction to Healthcare Practitioner"
+ },
+ {
+ "step": "Create Healthcare Practitioner"
+ },
+ {
+ "step": "Explore Healthcare Settings"
+ },
+ {
+ "step": "Explore Clinical Procedure Templates"
+ }
+ ],
+ "subtitle": "Patients, Practitioner Schedules, Settings and more.",
+ "success_message": "Yayy! The Healthcare Module is all set up!",
+ "title": "Let's Setup the Healthcare Module",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
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
new file mode 100644
index 00000000000..c45a347080c
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/create_healthcare_practitioner/create_healthcare_practitioner.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-19 10:39:55.728058",
+ "docstatus": 0,
+ "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_by": "Administrator",
+ "name": "Create Healthcare Practitioner",
+ "owner": "Administrator",
+ "reference_document": "Healthcare Practitioner",
+ "show_full_form": 1,
+ "title": "Create Healthcare Practitioner",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/onboarding_step/create_patient/create_patient.json b/erpnext/healthcare/onboarding_step/create_patient/create_patient.json
new file mode 100644
index 00000000000..77bc5bd7adf
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/create_patient/create_patient.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-19 10:32:27.648902",
+ "docstatus": 0,
+ "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",
+ "name": "Create Patient",
+ "owner": "Administrator",
+ "reference_document": "Patient",
+ "show_full_form": 1,
+ "title": "Create Patient",
+ "validate_action": 1
+}
\ No newline at end of file
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
new file mode 100644
index 00000000000..65980ef6687
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/create_practitioner_schedule/create_practitioner_schedule.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-19 10:41:19.065753",
+ "docstatus": 0,
+ "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",
+ "name": "Create Practitioner Schedule",
+ "owner": "Administrator",
+ "reference_document": "Practitioner Schedule",
+ "show_full_form": 1,
+ "title": "Create Practitioner Schedule",
+ "validate_action": 1
+}
\ No newline at end of file
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
new file mode 100644
index 00000000000..697b761e528
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/explore_clinical_procedure_templates/explore_clinical_procedure_templates.json
@@ -0,0 +1,19 @@
+{
+ "action": "Show Form Tour",
+ "creation": "2020-05-19 11:40:51.963741",
+ "docstatus": 0,
+ "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_by": "Administrator",
+ "name": "Explore Clinical Procedure Templates",
+ "owner": "Administrator",
+ "reference_document": "Clinical Procedure Template",
+ "show_full_form": 0,
+ "title": "Explore Clinical Procedure Templates",
+ "validate_action": 1
+}
\ No newline at end of file
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
new file mode 100644
index 00000000000..b2d5aef4312
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/explore_healthcare_settings/explore_healthcare_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Show Form Tour",
+ "creation": "2020-05-19 11:14:33.044989",
+ "docstatus": 0,
+ "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_by": "Administrator",
+ "name": "Explore Healthcare Settings",
+ "owner": "Administrator",
+ "reference_document": "Healthcare Settings",
+ "show_full_form": 0,
+ "title": "Explore Healthcare Settings",
+ "validate_action": 1
+}
\ No newline at end of file
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
new file mode 100644
index 00000000000..fa4c9036d7e
--- /dev/null
+++ b/erpnext/healthcare/onboarding_step/introduction_to_healthcare_practitioner/introduction_to_healthcare_practitioner.json
@@ -0,0 +1,20 @@
+{
+ "action": "Show Form Tour",
+ "creation": "2020-05-19 10:43:56.231679",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "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",
+ "name": "Introduction to Healthcare Practitioner",
+ "owner": "Administrator",
+ "reference_document": "Healthcare Practitioner",
+ "show_full_form": 0,
+ "title": "Introduction to Healthcare Practitioner",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/setup.py b/erpnext/healthcare/setup.py
index 2087f49f32f..06840801d37 100644
--- a/erpnext/healthcare/setup.py
+++ b/erpnext/healthcare/setup.py
@@ -195,10 +195,21 @@ def create_sensitivity():
def add_healthcare_service_unit_tree_root():
record = [
- {
- "doctype": "Healthcare Service Unit",
- "healthcare_service_unit_name": "All Healthcare Service Units",
- "is_group": 1
- }
+ {
+ "doctype": "Healthcare Service Unit",
+ "healthcare_service_unit_name": "All Healthcare Service Units",
+ "is_group": 1,
+ "company": get_company()
+ }
]
insert_record(record)
+
+def get_company():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company = frappe.get_list("Company", limit=1)
+ if company:
+ return company[0].name
+ return None
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index a7565323585..9abaa0784a7 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -3,83 +3,84 @@
# For license information, please see license.txt
from __future__ import unicode_literals
+import math
import frappe
from frappe import _
-import math
from frappe.utils import time_diff_in_hours, rounded
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_income_account
from erpnext.healthcare.doctype.fee_validity.fee_validity import create_fee_validity
from erpnext.healthcare.doctype.lab_test.lab_test import create_multiple
@frappe.whitelist()
-def get_healthcare_services_to_invoice(patient):
+def get_healthcare_services_to_invoice(patient, company):
patient = frappe.get_doc('Patient', patient)
+ items_to_invoice = []
if patient:
validate_customer_created(patient)
- items_to_invoice = []
- patient_appointments = frappe.get_list(
- 'Patient Appointment',
- fields='*',
- filters={'patient': patient.name, 'invoiced': 0},
- order_by='appointment_date'
- )
- if patient_appointments:
- items_to_invoice = get_fee_validity(patient_appointments)
+ # Customer validated, build a list of billable services
+ items_to_invoice += get_appointments_to_invoice(patient, company)
+ items_to_invoice += get_encounters_to_invoice(patient, company)
+ items_to_invoice += get_lab_tests_to_invoice(patient, company)
+ items_to_invoice += get_clinical_procedures_to_invoice(patient, company)
+ items_to_invoice += get_inpatient_services_to_invoice(patient, company)
+ items_to_invoice += get_therapy_sessions_to_invoice(patient, company)
- encounters = get_encounters_to_invoice(patient)
- lab_tests = get_lab_tests_to_invoice(patient)
- clinical_procedures = get_clinical_procedures_to_invoice(patient)
- inpatient_services = get_inpatient_services_to_invoice(patient)
- therapy_sessions = get_therapy_sessions_to_invoice(patient)
- items_to_invoice += encounters + lab_tests + clinical_procedures + inpatient_services + therapy_sessions
return items_to_invoice
+
def validate_customer_created(patient):
if not frappe.db.get_value('Patient', patient.name, 'customer'):
msg = _("Please set a Customer linked to the Patient")
msg += " {0} ".format(patient.name)
frappe.throw(msg, title=_('Customer Not Found'))
-def get_fee_validity(patient_appointments):
- if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'):
- return []
+def get_appointments_to_invoice(patient, company):
+ appointments_to_invoice = []
+ patient_appointments = frappe.get_list(
+ 'Patient Appointment',
+ fields = '*',
+ filters = {'patient': patient.name, 'company': company, 'invoiced': 0},
+ order_by = 'appointment_date'
+ )
- items_to_invoice = []
for appointment in patient_appointments:
+ # Procedure Appointments
if appointment.procedure_template:
if frappe.db.get_value('Clinical Procedure Template', appointment.procedure_template, 'is_billable'):
- items_to_invoice.append({
+ appointments_to_invoice.append({
'reference_type': 'Patient Appointment',
'reference_name': appointment.name,
'service': appointment.procedure_template
})
+ # Consultation Appointments, should check fee validity
else:
- fee_validity = frappe.db.exists('Fee Validity Reference', {'appointment': appointment.name})
- if not fee_validity:
- practitioner_charge = 0
- income_account = None
- service_item = None
- if appointment.practitioner:
- service_item, practitioner_charge = get_service_item_and_practitioner_charge(appointment)
- income_account = get_income_account(appointment.practitioner, appointment.company)
- items_to_invoice.append({
- 'reference_type': 'Patient Appointment',
- 'reference_name': appointment.name,
- 'service': service_item,
- 'rate': practitioner_charge,
- 'income_account': income_account
- })
+ if frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups') and \
+ frappe.db.exists('Fee Validity Reference', {'appointment': appointment.name}):
+ continue # Skip invoicing, fee validty present
+ practitioner_charge = 0
+ income_account = None
+ service_item = None
+ if appointment.practitioner:
+ service_item, practitioner_charge = get_service_item_and_practitioner_charge(appointment)
+ income_account = get_income_account(appointment.practitioner, appointment.company)
+ appointments_to_invoice.append({
+ 'reference_type': 'Patient Appointment',
+ 'reference_name': appointment.name,
+ 'service': service_item,
+ 'rate': practitioner_charge,
+ 'income_account': income_account
+ })
- return items_to_invoice
+ return appointments_to_invoice
-def get_encounters_to_invoice(patient):
+def get_encounters_to_invoice(patient, company):
encounters_to_invoice = []
encounters = frappe.get_list(
'Patient Encounter',
fields=['*'],
- filters={'patient': patient.name, 'invoiced': False, 'docstatus': 1}
+ filters={'patient': patient.name, 'company': company, 'invoiced': False, 'docstatus': 1}
)
if encounters:
for encounter in encounters:
@@ -102,12 +103,12 @@ def get_encounters_to_invoice(patient):
return encounters_to_invoice
-def get_lab_tests_to_invoice(patient):
+def get_lab_tests_to_invoice(patient, company):
lab_tests_to_invoice = []
lab_tests = frappe.get_list(
'Lab Test',
fields=['name', 'template'],
- filters={'patient': patient.name, 'invoiced': False, 'docstatus': 1}
+ filters={'patient': patient.name, 'company': company, 'invoiced': False, 'docstatus': 1}
)
for lab_test in lab_tests:
item, is_billable = frappe.get_cached_value('Lab Test Template', lab_test.template, ['item', 'is_billable'])
@@ -143,12 +144,12 @@ def get_lab_tests_to_invoice(patient):
return lab_tests_to_invoice
-def get_clinical_procedures_to_invoice(patient):
+def get_clinical_procedures_to_invoice(patient, company):
clinical_procedures_to_invoice = []
procedures = frappe.get_list(
'Clinical Procedure',
fields='*',
- filters={'patient': patient.name, 'invoiced': False}
+ filters={'patient': patient.name, 'company': company, 'invoiced': False}
)
for procedure in procedures:
if not procedure.appointment:
@@ -204,7 +205,7 @@ def get_clinical_procedures_to_invoice(patient):
return clinical_procedures_to_invoice
-def get_inpatient_services_to_invoice(patient):
+def get_inpatient_services_to_invoice(patient, company):
services_to_invoice = []
inpatient_services = frappe.db.sql(
'''
@@ -214,10 +215,11 @@ def get_inpatient_services_to_invoice(patient):
`tabInpatient Record` ip, `tabInpatient Occupancy` io
WHERE
ip.patient=%s
+ and ip.company=%s
and io.parent=ip.name
and io.left=1
and io.invoiced=0
- ''', (patient.name), as_dict=1)
+ ''', (patient.name, company), as_dict=1)
for inpatient_occupancy in inpatient_services:
service_unit_type = frappe.db.get_value('Healthcare Service Unit', inpatient_occupancy.service_unit, 'service_unit_type')
@@ -244,12 +246,12 @@ def get_inpatient_services_to_invoice(patient):
return services_to_invoice
-def get_therapy_sessions_to_invoice(patient):
+def get_therapy_sessions_to_invoice(patient, company):
therapy_sessions_to_invoice = []
therapy_sessions = frappe.get_list(
'Therapy Session',
fields='*',
- filters={'patient': patient.name, 'invoiced': False}
+ filters={'patient': patient.name, 'invoiced': 0, 'company': company}
)
for therapy in therapy_sessions:
if not therapy.appointment:
@@ -396,6 +398,7 @@ def check_fee_validity(appointment):
def manage_fee_validity(appointment):
fee_validity = check_fee_validity(appointment)
+
if fee_validity:
if appointment.status == 'Cancelled' and fee_validity.visited > 0:
fee_validity.visited -= 1
@@ -509,10 +512,10 @@ def get_children(doctype, parent, company, is_root=False):
def get_patient_vitals(patient, from_date=None, to_date=None):
if not patient: return
- vitals = frappe.db.get_all('Vital Signs', {
+ vitals = frappe.db.get_all('Vital Signs', filters={
'docstatus': 1,
'patient': patient
- }, order_by='signs_date, signs_time')
+ }, order_by='signs_date, signs_time', fields=['*'])
if len(vitals):
return vitals
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 6b198e744cc..9d7cdc2a3b9 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -308,7 +308,8 @@ scheduler_events = {
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
- "erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status"
+ "erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status",
+ "erpnext.buying.doctype.supplier_quotation.supplier_quotation.set_expired_status"
],
"daily_long": [
"erpnext.setup.doctype.email_digest.email_digest.send",
@@ -319,8 +320,7 @@ scheduler_events = {
"erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual.process_loan_interest_accrual_for_term_loans"
],
"monthly_long": [
- "erpnext.accounts.deferred_revenue.convert_deferred_revenue_to_income",
- "erpnext.accounts.deferred_revenue.convert_deferred_expense_to_expense",
+ "erpnext.accounts.deferred_revenue.process_deferred_accounting",
"erpnext.hr.utils.allocate_earned_leaves",
"erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual.process_loan_interest_accrual_for_demand_loans"
]
diff --git a/erpnext/hr/dashboard_fixtures.py b/erpnext/hr/dashboard_fixtures.py
new file mode 100644
index 00000000000..6e042ac78d3
--- /dev/null
+++ b/erpnext/hr/dashboard_fixtures.py
@@ -0,0 +1,228 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+import erpnext
+import json
+from frappe import _
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_dashboards():
+ dashboards = []
+ dashboards.append(get_human_resource_dashboard())
+ return dashboards
+
+def get_human_resource_dashboard():
+ return {
+ "name": "Human Resource",
+ "dashboard_name": "Human Resource",
+ "is_default": 1,
+ "charts": [
+ { "chart": "Outgoing Salary", "width": "Full"},
+ { "chart": "Gender Diversity Ratio", "width": "Half"},
+ { "chart": "Job Application Status", "width": "Half"},
+ { "chart": 'Designation Wise Employee Count', "width": "Half"},
+ { "chart": 'Department Wise Employee Count', "width": "Half"},
+ { "chart": 'Designation Wise Openings', "width": "Half"},
+ { "chart": 'Department Wise Openings', "width": "Half"},
+ { "chart": "Attendance Count", "width": "Full"}
+ ],
+ "cards": [
+ {"card": "Total Employees"},
+ {"card": "New Joinees (Last year)"},
+ {'card': "Employees Left (Last year)"},
+ {'card': "Total Job Openings (Last month)"},
+ {'card': "Total Applicants (Last month)"},
+ {'card': "Shortlisted Candidates (Last month)"},
+ {'card': "Rejected Candidates (Last month)"},
+ {'card': "Total Job Offered (Last month)"},
+ ]
+ }
+
+def get_recruitment_dashboard():
+ pass
+
+
+def get_charts():
+ company = erpnext.get_default_company()
+ date = frappe.utils.get_datetime()
+
+ month_map = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"]
+
+
+ if not company:
+ company = frappe.db.get_value("Company", {"is_group": 0}, "name")
+
+ dashboard_charts = [
+ get_dashboards_chart_doc('Gender Diversity Ratio', "Group By", "Pie",
+ document_type = "Employee", group_by_type="Count", group_by_based_on="gender",
+ filters_json = json.dumps([["Employee", "status", "=", "Active"]]))
+ ]
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Job Application Status', "Group By", "Pie",
+ document_type = "Job Applicant", group_by_type="Count", group_by_based_on="status",
+ filters_json = json.dumps([["Job Applicant", "creation", "Previous", "1 month"]]))
+ )
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Outgoing Salary', "Sum", "Line",
+ document_type = "Salary Slip", based_on="end_date",
+ value_based_on = "rounded_total", time_interval = "Monthly", timeseries = 1,
+ filters_json = json.dumps([["Salary Slip", "docstatus", "=", 1]]))
+ )
+
+ custom_options = '''{
+ "type": "line",
+ "axisOptions": {
+ "shortenYAxisNumbers": 1
+ },
+ "tooltipOptions": {}
+ }'''
+
+ filters_json = json.dumps({
+ "month": month_map[date.month - 1],
+ "year": str(date.year),
+ "company":company
+ })
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Attendance Count', "Report", "Line",
+ report_name = "Monthly Attendance Sheet", is_custom =1, group_by_type="Count",
+ filters_json = filters_json, custom_options=custom_options)
+ )
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Department Wise Employee Count', "Group By", "Donut",
+ document_type = "Employee", group_by_type="Count", group_by_based_on="department",
+ filters_json = json.dumps([["Employee", "status", "=", "Active"]]))
+ )
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Designation Wise Employee Count', "Group By", "Donut",
+ document_type = "Employee", group_by_type="Count", group_by_based_on="designation",
+ filters_json = json.dumps([["Employee", "status", "=", "Active"]]))
+ )
+
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Designation Wise Openings', "Group By", "Bar",
+ document_type = "Job Opening", group_by_type="Sum", group_by_based_on="designation",
+ time_interval = "Monthly", aggregate_function_based_on = "planned_vacancies")
+ )
+ dashboard_charts.append(
+ get_dashboards_chart_doc('Department Wise Openings', "Group By", "Bar",
+ document_type = "Job Opening", group_by_type="Sum", group_by_based_on="department",
+ time_interval = "Monthly", aggregate_function_based_on = "planned_vacancies")
+ )
+ return dashboard_charts
+
+
+def get_number_cards():
+ number_cards = []
+
+ number_cards = [
+ get_number_cards_doc("Employee", "Total Employees", filters_json = json.dumps([
+ ["Employee","status","=","Active"]
+ ])
+ )
+ ]
+
+ number_cards.append(
+ get_number_cards_doc("Employee", "New Joinees (Last year)", filters_json = json.dumps([
+ ["Employee","date_of_joining","Previous","1 year"],
+ ["Employee","status","=","Active"]
+ ])
+ )
+ )
+
+ number_cards.append(
+ get_number_cards_doc("Employee", "Employees Left (Last year)", filters_json = json.dumps([
+ ["Employee", "relieving_date", "Previous", "1 year"],
+ ["Employee", "status", "=", "Left"]
+ ])
+ )
+ )
+
+ number_cards.append(
+ get_number_cards_doc("Job Applicant", "Total Applicants (Last month)", filters_json = json.dumps([
+ ["Job Applicant", "creation", "Previous", "1 month"]
+ ])
+ )
+ )
+
+ number_cards.append(
+ get_number_cards_doc("Job Opening", "Total Job Openings (Last month)", func = "Sum",
+ aggregate_function_based_on = "planned_vacancies",
+ filters_json = json.dumps([["Job Opening", "creation", "Previous", "1 month"]])
+ )
+ )
+ number_cards.append(
+ get_number_cards_doc("Job Applicant", "Shortlisted Candidates (Last month)", filters_json = json.dumps([
+ ["Job Applicant", "status", "=", "Accepted"],
+ ["Job Applicant", "creation", "Previous", "1 month"]
+ ])
+ )
+ )
+ number_cards.append(
+ get_number_cards_doc("Job Applicant", "Rejected Candidates (Last month)", filters_json = json.dumps([
+ ["Job Applicant", "status", "=", "Rejected"],
+ ["Job Applicant", "creation", "Previous", "1 month"]
+ ])
+ )
+ )
+ number_cards.append(
+ get_number_cards_doc("Job Offer", "Total Job Offered (Last month)",
+ filters_json = json.dumps([["Job Offer", "creation", "Previous", "1 month"]])
+ )
+ )
+
+ return number_cards
+
+
+def get_number_cards_doc(document_type, label, **args):
+ args = frappe._dict(args)
+
+ return {
+ "doctype": "Number Card",
+ "document_type": document_type,
+ "function": args.func or "Count",
+ "is_public": args.is_public or 1,
+ "label": _(label),
+ "name": args.name or label,
+ "show_percentage_stats": args.show_percentage_stats or 1,
+ "stats_time_interval": args.stats_time_interval or 'Monthly',
+ "filters_json": args.filters_json or '[]',
+ "aggregate_function_based_on": args.aggregate_function_based_on or None
+ }
+
+def get_dashboards_chart_doc(name, chart_type, graph_type, **args):
+ args = frappe._dict(args)
+
+ return {
+ "name": name,
+ "chart_name": _(args.chart_name or name),
+ "chart_type": chart_type,
+ "document_type": args.document_type or None,
+ "report_name": args.report_name or None,
+ "is_custom": args.is_custom or 0,
+ "group_by_type": args.group_by_type or None,
+ "group_by_based_on": args.group_by_based_on or None,
+ "based_on": args.based_on or None,
+ "value_based_on": args.value_based_on or None,
+ "number_of_groups": args.number_of_groups or 0,
+ "is_public": args.is_public or 1,
+ "timespan": args.timespan or "Last Year",
+ "time_interval": args.time_interval or "Yearly",
+ "timeseries": args.timeseries or 0,
+ "filters_json": args.filters_json or '[]',
+ "type": graph_type,
+ "custom_options": args.custom_options or '',
+ "doctype": "Dashboard Chart",
+ "aggregate_function_based_on": args.aggregate_function_based_on or None
+ }
\ No newline at end of file
diff --git a/erpnext/hr/desk_page/hr/hr.json b/erpnext/hr/desk_page/hr/hr.json
index 22aa170744c..1c24444fdd2 100644
--- a/erpnext/hr/desk_page/hr/hr.json
+++ b/erpnext/hr/desk_page/hr/hr.json
@@ -18,7 +18,7 @@
{
"hidden": 0,
"label": "Leaves",
- "links": "[\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Application\",\n \"name\": \"Leave Application\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Allocation\",\n \"name\": \"Leave Allocation\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Leave Type\"\n ],\n \"label\": \"Leave Policy\",\n \"name\": \"Leave Policy\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Period\",\n \"name\": \"Leave Period\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Leave Type\",\n \"name\": \"Leave Type\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Holiday List\",\n \"name\": \"Holiday List\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Compensatory Leave Request\",\n \"name\": \"Compensatory Leave Request\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Encashment\",\n \"name\": \"Leave Encashment\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Leave Block List\",\n \"name\": \"Leave Block List\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Leave Application\"\n ],\n \"doctype\": \"Leave Application\",\n \"is_query_report\": true,\n \"label\": \"Employee Leave Balance\",\n \"name\": \"Employee Leave Balance\",\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Application\",\n \"name\": \"Leave Application\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Allocation\",\n \"name\": \"Leave Allocation\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Leave Type\"\n ],\n \"label\": \"Leave Policy\",\n \"name\": \"Leave Policy\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Leave Period\",\n \"name\": \"Leave Period\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Leave Type\",\n \"name\": \"Leave Type\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Holiday List\",\n \"name\": \"Holiday List\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Compensatory Leave Request\",\n \"name\": \"Compensatory Leave Request\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Employee\"\n ],\n \"label\": \"Leave Encashment\",\n \"name\": \"Leave Encashment\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Leave Block List\",\n \"name\": \"Leave Block List\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Leave Application\"\n ],\n \"doctype\": \"Leave Application\",\n \"is_query_report\": true,\n \"label\": \"Employee Leave Balance\",\n \"name\": \"Employee Leave Balance\",\n \"type\": \"report\"\n }\n]"
},
{
"hidden": 0,
@@ -77,26 +77,33 @@
}
],
"category": "Modules",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Outgoing Salary",
+ "label": "Outgoing Salary"
+ }
+ ],
"creation": "2020-03-02 15:48:58.322521",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "HR",
- "modified": "2020-04-29 20:29:22.114309",
+ "modified": "2020-06-10 12:41:41.695669",
"modified_by": "Administrator",
"module": "HR",
"name": "HR",
+ "onboarding": "Human Resource",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#cef6d1",
"format": "{} Active",
"label": "Employee",
"link_to": "Employee",
@@ -104,33 +111,35 @@
"type": "DocType"
},
{
- "format": "{} Unpaid",
- "label": "Expense Claim",
- "link_to": "Expense Claim",
- "stats_filter": "{\"approval_status\":\"Draft\"}",
+ "color": "#ffe8cd",
+ "format": "{} Open",
+ "label": "Leave Application",
+ "link_to": "Leave Application",
+ "stats_filter": "{\"status\":\"Open\"}",
"type": "DocType"
},
{
- "format": "{} Open",
- "label": "Job Applicant",
- "link_to": "Job Applicant",
- "stats_filter": "{\n \"status\": \"Open\"\n}",
+ "label": "Attendance",
+ "link_to": "Attendance",
+ "stats_filter": "",
"type": "DocType"
},
{
"label": "Salary Structure",
- "link_to": "Salary Structure",
+ "link_to": "Payroll Entry",
"type": "DocType"
},
{
- "label": "Leave Application",
- "link_to": "Leave Application",
- "type": "DocType"
- },
- {
- "label": "Salary Register",
- "link_to": "Salary Register",
+ "label": "Monthly Attendance Sheet",
+ "link_to": "Monthly Attendance Sheet",
"type": "Report"
+ },
+ {
+ "format": "{} Open",
+ "label": "Dashboard",
+ "link_to": "Human Resource",
+ "stats_filter": "{\n \"status\": \"Open\"\n}",
+ "type": "Dashboard"
}
]
}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
index bab6fb545f8..e369ba7cef6 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -37,7 +37,7 @@ class AdditionalSalary(Document):
frappe.throw(_("Payroll date can not be less than employee's joining date."))
elif getdate(self.from_date) < getdate(date_of_joining):
frappe.throw(_("From date can not be less than employee's joining date."))
- elif getdate(self.to_date) > getdate(relieving_date):
+ elif relieving_date and getdate(self.to_date) > getdate(relieving_date):
frappe.throw(_("To date can not be greater than employee's relieving date."))
def get_amount(self, sal_start_date, sal_end_date):
diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.py b/erpnext/hr/doctype/appraisal_template/appraisal_template.py
index e5d3c42e1bd..d0dfad4be31 100644
--- a/erpnext/hr/doctype/appraisal_template/appraisal_template.py
+++ b/erpnext/hr/doctype/appraisal_template/appraisal_template.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import cint
+from frappe.utils import cint, flt
from frappe import _
from frappe.model.document import Document
@@ -11,11 +11,11 @@ from frappe.model.document import Document
class AppraisalTemplate(Document):
def validate(self):
self.check_total_points()
-
- def check_total_points(self):
+
+ def check_total_points(self):
total_points = 0
for d in self.get("goals"):
- total_points += int(d.per_weightage or 0)
+ total_points += flt(d.per_weightage)
if cint(total_points) != 100:
frappe.throw(_("Sum of points for all goals should be 100. It is {0}").format(total_points))
diff --git a/erpnext/hr/doctype/attendance/attendance.json b/erpnext/hr/doctype/attendance/attendance.json
index 906f6f77f21..a656a7ea5f7 100644
--- a/erpnext/hr/doctype/attendance/attendance.json
+++ b/erpnext/hr/doctype/attendance/attendance.json
@@ -19,11 +19,15 @@
"attendance_date",
"company",
"department",
- "shift",
"attendance_request",
- "amended_from",
+ "details_section",
+ "shift",
+ "in_time",
+ "out_time",
+ "column_break_18",
"late_entry",
- "early_exit"
+ "early_exit",
+ "amended_from"
],
"fields": [
{
@@ -172,13 +176,36 @@
"fieldname": "early_exit",
"fieldtype": "Check",
"label": "Early Exit"
+ },
+ {
+ "fieldname": "details_section",
+ "fieldtype": "Section Break",
+ "label": "Details"
+ },
+ {
+ "depends_on": "shift",
+ "fieldname": "in_time",
+ "fieldtype": "Datetime",
+ "label": "In Time",
+ "read_only": 1
+ },
+ {
+ "depends_on": "shift",
+ "fieldname": "out_time",
+ "fieldtype": "Datetime",
+ "label": "Out Time",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_18",
+ "fieldtype": "Column Break"
}
],
"icon": "fa fa-ok",
"idx": 1,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-11 11:40:14.319496",
+ "modified": "2020-05-29 13:51:37.177231",
"modified_by": "Administrator",
"module": "HR",
"name": "Attendance",
diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py
index b6c80655c2e..45b7060610d 100644
--- a/erpnext/hr/doctype/attendance/attendance.py
+++ b/erpnext/hr/doctype/attendance/attendance.py
@@ -21,7 +21,7 @@ class Attendance(Document):
date_of_joining = frappe.db.get_value("Employee", self.employee, "date_of_joining")
# leaves can be marked for future dates
- if self.status not in ('On Leave', 'Half Day') and getdate(self.attendance_date) > getdate(nowdate()):
+ if self.status != 'On Leave' and not self.leave_application and getdate(self.attendance_date) > getdate(nowdate()):
frappe.throw(_("Attendance can not be marked for future dates"))
elif date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
frappe.throw(_("Attendance date can not be less than employee's joining date"))
@@ -41,7 +41,7 @@ class Attendance(Document):
leave_record = frappe.db.sql("""
select leave_type, half_day, half_day_date
from `tabLeave Application`
- where employee = %s
+ where employee = %s
and %s between from_date and to_date
and status = 'Approved'
and docstatus = 1
@@ -172,8 +172,8 @@ def get_unmarked_days(employee, month):
records = frappe.get_all("Attendance", fields = ['attendance_date', 'employee'] , filters = [
- ["attendance_date", ">", month_start],
- ["attendance_date", "<", month_end],
+ ["attendance_date", ">=", month_start],
+ ["attendance_date", "<=", month_end],
["employee", "=", employee],
["docstatus", "!=", 2]
])
diff --git a/erpnext/hr/doctype/department/department.json b/erpnext/hr/doctype/department/department.json
index 6469f4cbed2..a54c1d18e7c 100644
--- a/erpnext/hr/doctype/department/department.json
+++ b/erpnext/hr/doctype/department/department.json
@@ -14,6 +14,8 @@
"is_group",
"disabled",
"section_break_4",
+ "payroll_cost_center",
+ "column_break_9",
"leave_block_list",
"leave_section",
"leave_approvers",
@@ -125,13 +127,23 @@
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "payroll_cost_center",
+ "fieldtype": "Link",
+ "label": "Payroll Cost Center",
+ "options": "Cost Center"
+ },
+ {
+ "fieldname": "column_break_9",
+ "fieldtype": "Column Break"
}
],
"icon": "fa fa-sitemap",
"idx": 1,
"is_tree": 1,
"links": [],
- "modified": "2020-03-18 18:03:27.784362",
+ "modified": "2020-05-05 18:49:28.503931",
"modified_by": "Administrator",
"module": "HR",
"name": "Department",
diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json
index 13c202c7759..f575765f69b 100644
--- a/erpnext/hr/doctype/employee/employee.json
+++ b/erpnext/hr/doctype/employee/employee.json
@@ -60,6 +60,8 @@
"default_shift",
"salary_information",
"salary_mode",
+ "payroll_cost_center",
+ "column_break_52",
"bank_name",
"bank_ac_no",
"health_insurance_section",
@@ -783,13 +785,25 @@
{
"fieldname": "column_break_19",
"fieldtype": "Column Break"
+ },
+ {
+ "fetch_from": "department.payroll_cost_center",
+ "fetch_if_empty": 1,
+ "fieldname": "payroll_cost_center",
+ "fieldtype": "Link",
+ "label": "Payroll Cost Center",
+ "options": "Cost Center"
+ },
+ {
+ "fieldname": "column_break_52",
+ "fieldtype": "Column Break"
}
],
"icon": "fa fa-user",
"idx": 24,
"image_field": "image",
"links": [],
- "modified": "2020-04-08 12:25:34.306695",
+ "modified": "2020-05-05 18:51:03.152503",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py
index d3410de2eb7..f4b214adc3c 100644
--- a/erpnext/hr/doctype/employee/test_employee.py
+++ b/erpnext/hr/doctype/employee/test_employee.py
@@ -45,7 +45,7 @@ class TestEmployee(unittest.TestCase):
employee1_doc.status = 'Left'
self.assertRaises(EmployeeLeftValidationError, employee1_doc.save)
-def make_employee(user, company=None):
+def make_employee(user, company=None, **kwargs):
if not frappe.db.get_value("User", user):
frappe.get_doc({
"doctype": "User",
@@ -55,7 +55,7 @@ def make_employee(user, company=None):
"roles": [{"doctype": "Has Role", "role": "Employee"}]
}).insert()
- if not frappe.db.get_value("Employee", { "user_id": user, "company": company or erpnext.get_default_company() }):
+ if not frappe.db.get_value("Employee", {"user_id": user}):
employee = frappe.get_doc({
"doctype": "Employee",
"naming_series": "EMP-",
@@ -71,7 +71,10 @@ def make_employee(user, company=None):
"prefered_email": user,
"status": "Active",
"employment_type": "Intern"
- }).insert()
+ })
+ if kwargs:
+ employee.update(kwargs)
+ employee.insert()
return employee.name
else:
return frappe.get_value("Employee", {"employee_name":user}, "name")
diff --git a/erpnext/hr/doctype/employee_advance/employee_advance.js b/erpnext/hr/doctype/employee_advance/employee_advance.js
index 6cc49cfff23..cba8ee9a404 100644
--- a/erpnext/hr/doctype/employee_advance/employee_advance.js
+++ b/erpnext/hr/doctype/employee_advance/employee_advance.js
@@ -139,13 +139,13 @@ frappe.ui.form.on('Employee Advance', {
employee: function (frm) {
if (frm.doc.employee) {
return frappe.call({
- method: "erpnext.hr.doctype.employee_advance.employee_advance.get_due_advance_amount",
+ method: "erpnext.hr.doctype.employee_advance.employee_advance.get_pending_amount",
args: {
"employee": frm.doc.employee,
"posting_date": frm.doc.posting_date
},
callback: function(r) {
- frm.set_value("due_advance_amount",r.message);
+ frm.set_value("pending_amount",r.message);
}
});
}
diff --git a/erpnext/hr/doctype/employee_advance/employee_advance.json b/erpnext/hr/doctype/employee_advance/employee_advance.json
index 8c5ce42d870..0d909138719 100644
--- a/erpnext/hr/doctype/employee_advance/employee_advance.json
+++ b/erpnext/hr/doctype/employee_advance/employee_advance.json
@@ -19,7 +19,7 @@
"column_break_11",
"advance_amount",
"paid_amount",
- "due_advance_amount",
+ "pending_amount",
"claimed_amount",
"return_amount",
"section_break_7",
@@ -102,14 +102,6 @@
"options": "Company:company:default_currency",
"read_only": 1
},
- {
- "depends_on": "eval:cur_frm.doc.employee",
- "fieldname": "due_advance_amount",
- "fieldtype": "Currency",
- "label": "Due Advance Amount",
- "options": "Company:company:default_currency",
- "read_only": 1
- },
{
"fieldname": "claimed_amount",
"fieldtype": "Currency",
@@ -177,11 +169,19 @@
"fieldname": "repay_unclaimed_amount_from_salary",
"fieldtype": "Check",
"label": "Repay unclaimed amount from salary"
+ },
+ {
+ "depends_on": "eval:cur_frm.doc.employee",
+ "fieldname": "pending_amount",
+ "fieldtype": "Currency",
+ "label": "Pending Amount",
+ "options": "Company:company:default_currency",
+ "read_only": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-06 15:11:33.747535",
+ "modified": "2020-06-12 12:42:39.833818",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Advance",
diff --git a/erpnext/hr/doctype/employee_advance/employee_advance.py b/erpnext/hr/doctype/employee_advance/employee_advance.py
index 23e4992066b..a49dfcfc2a2 100644
--- a/erpnext/hr/doctype/employee_advance/employee_advance.py
+++ b/erpnext/hr/doctype/employee_advance/employee_advance.py
@@ -95,7 +95,7 @@ class EmployeeAdvance(Document):
frappe.db.set_value("Employee Advance", self.name, "status", self.status)
@frappe.whitelist()
-def get_due_advance_amount(employee, posting_date):
+def get_pending_amount(employee, posting_date):
employee_due_amount = frappe.get_all("Employee Advance", \
filters = {"employee":employee, "docstatus":1, "posting_date":("<=", posting_date)}, \
fields = ["advance_amount", "paid_amount"])
@@ -146,7 +146,7 @@ def create_return_through_additional_salary(doc):
return additional_salary
@frappe.whitelist()
-def make_return_entry(employee_name, company, employee_advance_name, return_amount, mode_of_payment, advance_account):
+def make_return_entry(employee, company, employee_advance_name, return_amount, advance_account, mode_of_payment=None):
return_account = get_default_bank_cash_account(company, account_type='Cash', mode_of_payment = mode_of_payment)
mode_of_payment_type = ''
diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.py b/erpnext/hr/doctype/employee_checkin/employee_checkin.py
index 86705121ac5..15fbd4e0153 100644
--- a/erpnext/hr/doctype/employee_checkin/employee_checkin.py
+++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.py
@@ -72,7 +72,7 @@ def add_log_based_on_employee_field(employee_field_value, timestamp, device_id=N
return doc
-def mark_attendance_and_link_log(logs, attendance_status, attendance_date, working_hours=None, late_entry=False, early_exit=False, shift=None):
+def mark_attendance_and_link_log(logs, attendance_status, attendance_date, working_hours=None, late_entry=False, early_exit=False, in_time=None, out_time=None, shift=None):
"""Creates an attendance and links the attendance to the Employee Checkin.
Note: If attendance is already present for the given date, the logs are marked as skipped and no exception is thrown.
@@ -100,7 +100,9 @@ def mark_attendance_and_link_log(logs, attendance_status, attendance_date, worki
'company': employee_doc.company,
'shift': shift,
'late_entry': late_entry,
- 'early_exit': early_exit
+ 'early_exit': early_exit,
+ 'in_time': in_time,
+ 'out_time': out_time
}
attendance = frappe.get_doc(doc_dict).insert()
attendance.submit()
diff --git a/erpnext/hr/doctype/employee_other_income/employee_other_income.json b/erpnext/hr/doctype/employee_other_income/employee_other_income.json
index 2dd6c10988d..8abfe1e93a8 100644
--- a/erpnext/hr/doctype/employee_other_income/employee_other_income.json
+++ b/erpnext/hr/doctype/employee_other_income/employee_other_income.json
@@ -76,25 +76,15 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-19 18:06:45.361830",
+ "modified": "2020-05-14 17:17:38.883126",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Other Income",
"owner": "Administrator",
"permissions": [
{
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "System Manager",
- "share": 1,
- "write": 1
- },
- {
+ "amend": 1,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -104,9 +94,12 @@
"report": 1,
"role": "HR Manager",
"share": 1,
+ "submit": 1,
"write": 1
},
{
+ "amend": 1,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -116,9 +109,12 @@
"report": 1,
"role": "HR User",
"share": 1,
+ "submit": 1,
"write": 1
},
{
+ "amend": 1,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -128,6 +124,7 @@
"report": 1,
"role": "Employee",
"share": 1,
+ "submit": 1,
"write": 1
}
],
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index fb2310396b7..6bb9af98263 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -243,7 +243,6 @@ frappe.ui.form.on("Expense Claim", {
},
update_employee_advance_claimed_amount: function(frm) {
- console.log("update_employee_advance_claimed_amount")
let amount_to_be_allocated = frm.doc.grand_total;
$.each(frm.doc.advances || [], function(i, advance){
if (amount_to_be_allocated >= advance.unclaimed_amount){
@@ -295,6 +294,16 @@ frappe.ui.form.on("Expense Claim", {
frm.events.get_advances(frm);
},
+ cost_center: function(frm) {
+ frm.events.set_child_cost_center(frm);
+ },
+ set_child_cost_center: function(frm){
+ (frm.doc.expenses || []).forEach(function(d) {
+ if (!d.cost_center){
+ d.cost_center = frm.doc.cost_center;
+ }
+ });
+ },
get_taxes: function(frm) {
if(frm.doc.taxes) {
frappe.call({
@@ -338,8 +347,7 @@ frappe.ui.form.on("Expense Claim", {
frappe.ui.form.on("Expense Claim Detail", {
expenses_add: function(frm, cdt, cdn) {
- var row = frappe.get_doc(cdt, cdn);
- frm.script_manager.copy_from_first_row("expenses", row, ["cost_center"]);
+ frm.events.set_child_cost_center(frm);
},
amount: function(frm, cdt, cdn) {
var child = locals[cdt][cdn];
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index ac1bfa1a391..ea469b82c98 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -116,8 +116,9 @@ class ExpenseClaim(AccountsController):
"party_type": "Employee",
"party": self.employee,
"against_voucher_type": self.doctype,
- "against_voucher": self.name
- })
+ "against_voucher": self.name,
+ "cost_center": self.cost_center
+ }, item=self)
)
# expense entries
@@ -129,7 +130,7 @@ class ExpenseClaim(AccountsController):
"debit_in_account_currency": data.sanctioned_amount,
"against": self.employee,
"cost_center": data.cost_center
- })
+ }, item=data)
)
for data in self.advances:
@@ -157,7 +158,7 @@ class ExpenseClaim(AccountsController):
"credit": self.grand_total,
"credit_in_account_currency": self.grand_total,
"against": self.employee
- })
+ }, item=self)
)
gl_entry.append(
@@ -170,7 +171,7 @@ class ExpenseClaim(AccountsController):
"debit_in_account_currency": self.grand_total,
"against_voucher": self.name,
"against_voucher_type": self.doctype,
- })
+ }, item=self)
)
return gl_entry
@@ -187,7 +188,7 @@ class ExpenseClaim(AccountsController):
"cost_center": self.cost_center,
"against_voucher_type": self.doctype,
"against_voucher": self.name
- })
+ }, item=tax)
)
def validate_account_details(self):
diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json
index 16e9eef9174..3cce50e0905 100644
--- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json
+++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json
@@ -13,9 +13,11 @@
"description",
"section_break_6",
"amount",
- "cost_center",
"column_break_8",
- "sanctioned_amount"
+ "sanctioned_amount",
+ "accounting_dimensions_section",
+ "cost_center",
+ "dimension_col_break"
],
"fields": [
{
@@ -104,12 +106,21 @@
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center"
+ },
+ {
+ "fieldname": "accounting_dimensions_section",
+ "fieldtype": "Section Break",
+ "label": "Accounting Dimensions"
+ },
+ {
+ "fieldname": "dimension_col_break",
+ "fieldtype": "Column Break"
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2019-12-11 13:42:33.233432",
+ "modified": "2020-05-11 18:54:35.601592",
"modified_by": "Administrator",
"module": "HR",
"name": "Expense Claim Detail",
diff --git a/erpnext/hr/doctype/expense_taxes_and_charges/expense_taxes_and_charges.json b/erpnext/hr/doctype/expense_taxes_and_charges/expense_taxes_and_charges.json
index d68caf1cc1b..885e3eed976 100644
--- a/erpnext/hr/doctype/expense_taxes_and_charges/expense_taxes_and_charges.json
+++ b/erpnext/hr/doctype/expense_taxes_and_charges/expense_taxes_and_charges.json
@@ -8,14 +8,16 @@
"engine": "InnoDB",
"field_order": [
"account_head",
- "cost_center",
"rate",
"col_break1",
"description",
"section_break_6",
"tax_amount",
"column_break_8",
- "total"
+ "total",
+ "accounting_dimensions_section",
+ "cost_center",
+ "dimension_col_break"
],
"fields": [
{
@@ -91,11 +93,20 @@
{
"fieldname": "column_break_8",
"fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "accounting_dimensions_section",
+ "fieldtype": "Section Break",
+ "label": "Accounting Dimensions"
+ },
+ {
+ "fieldname": "dimension_col_break",
+ "fieldtype": "Column Break"
}
],
"istable": 1,
"links": [],
- "modified": "2020-03-11 13:25:06.721917",
+ "modified": "2020-05-11 19:01:26.611758",
"modified_by": "Administrator",
"module": "HR",
"name": "Expense Taxes and Charges",
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.json b/erpnext/hr/doctype/hr_settings/hr_settings.json
index 9161ed822ac..ebf8723be65 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.json
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.json
@@ -13,12 +13,12 @@
"stop_birthday_reminders",
"expense_approver_mandatory_in_expense_claim",
"payroll_settings",
- "payroll_based_on",
- "max_working_hours_against_timesheet",
+ "payroll_based_on",
+ "max_working_hours_against_timesheet",
"include_holidays_in_total_working_days",
"disable_rounded_total",
"column_break_11",
- "daily_wages_fraction_for_half_day",
+ "daily_wages_fraction_for_half_day",
"email_salary_slip_to_employee",
"encrypt_salary_slips_in_emails",
"password_policy",
@@ -191,7 +191,7 @@
"default": "Leave",
"fieldname": "payroll_based_on",
"fieldtype": "Select",
- "label": "Calculate Working Days in Payroll based on",
+ "label": "Calculate Payroll Working Days Based On",
"options": "Leave\nAttendance"
},
{
@@ -206,7 +206,7 @@
"idx": 1,
"issingle": 1,
"links": [],
- "modified": "2020-04-13 21:20:59.382394",
+ "modified": "2020-05-11 13:02:51.274347",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 1f50e27098c..fb1f2c00b13 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -38,11 +38,15 @@ frappe.ui.form.on("Leave Application", {
},
validate: function(frm) {
+ if (frm.doc.from_date == frm.doc.to_date && frm.doc.half_day == 1){
+ frm.doc.half_day_date = frm.doc.from_date;
+ }
frm.toggle_reqd("half_day_date", frm.doc.half_day == 1);
},
make_dashboard: function(frm) {
var leave_details;
+ let lwps;
if (frm.doc.employee) {
frappe.call({
method: "erpnext.hr.doctype.leave_application.leave_application.get_leave_details",
@@ -58,6 +62,7 @@ frappe.ui.form.on("Leave Application", {
if (!r.exc && r.message['leave_approver']) {
frm.set_value('leave_approver', r.message['leave_approver']);
}
+ lwps = r.message["lwps"];
}
});
$("div").remove(".form-dashboard-section.custom");
@@ -67,6 +72,18 @@ frappe.ui.form.on("Leave Application", {
})
);
frm.dashboard.show();
+ let allowed_leave_types = Object.keys(leave_details);
+
+ // lwps should be allowed, lwps don't have any allocation
+ allowed_leave_types = allowed_leave_types.concat(lwps);
+
+ frm.set_query('leave_type', function(){
+ return {
+ filters : [
+ ['leave_type_name', 'in', allowed_leave_types]
+ ]
+ };
+ });
}
},
diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json
index 74707a24b86..7f50ace7663 100644
--- a/erpnext/hr/doctype/leave_application/leave_application.json
+++ b/erpnext/hr/doctype/leave_application/leave_application.json
@@ -174,7 +174,8 @@
"label": "Status",
"no_copy": 1,
"options": "Open\nApproved\nRejected\nCancelled",
- "permlevel": 1
+ "permlevel": 1,
+ "reqd": 1
},
{
"fieldname": "sb10",
@@ -189,14 +190,14 @@
"reqd": 1
},
{
+ "fetch_from": "employee.company",
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"read_only": 1,
"remember_last_selected_value": 1,
- "reqd": 1,
- "fetch_from": "employee.company"
+ "reqd": 1
},
{
"allow_on_submit": 1,
@@ -249,7 +250,7 @@
"is_submittable": 1,
"links": [],
"max_attachments": 3,
- "modified": "2020-03-10 22:40:43.487721",
+ "modified": "2020-05-18 13:00:41.577327",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Application",
@@ -334,4 +335,4 @@
"sort_order": "DESC",
"timeline_field": "employee",
"title_field": "employee_name"
-}
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 47b1bb7684e..0423824c0e9 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -19,7 +19,6 @@ class NotAnOptionalHoliday(frappe.ValidationError): pass
from frappe.model.document import Document
class LeaveApplication(Document):
-
def get_feed(self):
return _("{0}: From {0} of type {1}").format(self.employee_name, self.leave_type)
@@ -33,6 +32,7 @@ class LeaveApplication(Document):
self.validate_block_days()
self.validate_salary_processed_days()
self.validate_attendance()
+ self.set_half_day_date()
if frappe.db.get_value("Leave Type", self.leave_type, 'is_optional_leave'):
self.validate_optional_leave()
self.validate_applicable_after()
@@ -290,6 +290,10 @@ class LeaveApplication(Document):
frappe.throw(_("{0} is not in Optional Holiday List").format(formatdate(day)), NotAnOptionalHoliday)
day = add_days(day, 1)
+ def set_half_day_date(self):
+ if self.from_date == self.to_date and self.half_day == 1:
+ self.half_day_date = self.from_date
+
def notify_employee(self):
employee = frappe.get_doc("Employee", self.employee)
if not employee.user_id:
@@ -436,21 +440,36 @@ def get_leave_details(employee, date):
leave_allocation = {}
for d in allocation_records:
allocation = allocation_records.get(d, frappe._dict())
+
+ total_allocated_leaves = frappe.db.get_value('Leave Allocation', {
+ 'from_date': ('<=', date),
+ 'to_date': ('>=', date),
+ 'employee': employee,
+ 'leave_type': allocation.leave_type,
+ }, 'SUM(total_leaves_allocated)') or 0
+
remaining_leaves = get_leave_balance_on(employee, d, date, to_date = allocation.to_date,
consider_all_leaves_in_the_allocation_period=True)
+
end_date = allocation.to_date
leaves_taken = get_leaves_for_period(employee, d, allocation.from_date, end_date) * -1
leaves_pending = get_pending_leaves_for_period(employee, d, allocation.from_date, end_date)
leave_allocation[d] = {
- "total_leaves": allocation.total_leaves_allocated,
+ "total_leaves": total_allocated_leaves,
+ "expired_leaves": total_allocated_leaves - (remaining_leaves + leaves_taken),
"leaves_taken": leaves_taken,
"pending_leaves": leaves_pending,
"remaining_leaves": remaining_leaves}
+ #is used in set query
+ lwps = frappe.get_list("Leave Type", filters = {"is_lwp": 1})
+ lwps = [lwp.name for lwp in lwps]
+
ret = {
'leave_allocation': leave_allocation,
- 'leave_approver': get_leave_approver(employee)
+ 'leave_approver': get_leave_approver(employee),
+ 'lwps': lwps
}
return ret
@@ -549,7 +568,7 @@ def get_remaining_leaves(allocation, leaves_taken, date, expiry):
return _get_remaining_leaves(total_leaves, allocation.to_date)
-def get_leaves_for_period(employee, leave_type, from_date, to_date):
+def get_leaves_for_period(employee, leave_type, from_date, to_date, do_not_skip_expired_leaves=False):
leave_entries = get_leave_entries(employee, leave_type, from_date, to_date)
leave_days = 0
@@ -559,8 +578,8 @@ def get_leaves_for_period(employee, leave_type, from_date, to_date):
if inclusive_period and leave_entry.transaction_type == 'Leave Encashment':
leave_days += leave_entry.leaves
- elif inclusive_period and leave_entry.transaction_type == 'Leave Allocation' \
- and leave_entry.is_expired and not skip_expiry_leaves(leave_entry, to_date):
+ elif inclusive_period and leave_entry.transaction_type == 'Leave Allocation' and leave_entry.is_expired \
+ and (do_not_skip_expired_leaves or not skip_expiry_leaves(leave_entry, to_date)):
leave_days += leave_entry.leaves
elif leave_entry.transaction_type == 'Leave Application':
@@ -596,7 +615,7 @@ def get_leave_entries(employee, leave_type, from_date, to_date):
is_carry_forward, is_expired
FROM `tabLeave Ledger Entry`
WHERE employee=%(employee)s AND leave_type=%(leave_type)s
- AND docstatus=1
+ AND docstatus=1
AND (leaves<0
OR is_expired=1)
AND (from_date between %(from_date)s AND %(to_date)s
diff --git a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
index 2385b6ac1c4..d30e3b9f9c6 100644
--- a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
+++ b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
@@ -1,22 +1,23 @@
-{% if data %}
+{% if not jQuery.isEmptyObject(data) %}
{{ __("Allocated Leaves") }}
- {{ __("Leave Type") }}
- {{ __("Total Allocated Leaves") }}
- {{ __("Used Leaves") }}
- {{ __("Pending Leaves") }}
- {{ __("Available Leaves") }}
+ {{ __("Leave Type") }}
+ {{ __("Total Allocated Leaves") }}
+ {{ __("Expired Leaves") }}
+ {{ __("Used Leaves") }}
+ {{ __("Pending Leaves") }}
+ {{ __("Available Leaves") }}
-
{% for(const [key, value] of Object.entries(data)) { %}
{%= key %}
{%= value["total_leaves"] %}
+ {%= value["expired_leaves"] %}
{%= value["leaves_taken"] %}
{%= value["pending_leaves"] %}
{%= value["remaining_leaves"] %}
@@ -24,6 +25,6 @@
{% } %}
-{% } else { %}
+{% else %}
No Leaves have been allocated.
-{% } %}
\ No newline at end of file
+{% endif %}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
index 9ed58c9e59b..63559c4f5ae 100644
--- a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
+++ b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
@@ -88,32 +88,40 @@ def get_previous_expiry_ledger_entry(ledger):
}, fieldname=['name'])
def process_expired_allocation():
- ''' Check if a carry forwarded allocation has expired and create a expiry ledger entry '''
+ ''' Check if a carry forwarded allocation has expired and create a expiry ledger entry
+ Case 1: carry forwarded expiry period is set for the leave type,
+ create a separate leave expiry entry against each entry of carry forwarded and non carry forwarded leaves
+ Case 2: leave type has no specific expiry period for carry forwarded leaves
+ and there is no carry forwarded leave allocation, create a single expiry against the remaining leaves.
+ '''
# fetch leave type records that has carry forwarded leaves expiry
leave_type_records = frappe.db.get_values("Leave Type", filters={
'expire_carry_forwarded_leaves_after_days': (">", 0)
}, fieldname=['name'])
- leave_type = [record[0] for record in leave_type_records]
+ leave_type = [record[0] for record in leave_type_records] or ['']
- expired_allocation = frappe.db.sql_list("""SELECT name
- FROM `tabLeave Ledger Entry`
- WHERE
- `transaction_type`='Leave Allocation'
- AND `is_expired`=1""")
-
- expire_allocation = frappe.get_all("Leave Ledger Entry",
- fields=['leaves', 'to_date', 'employee', 'leave_type', 'is_carry_forward', 'transaction_name as name', 'transaction_type'],
- filters={
- 'to_date': ("<", today()),
- 'transaction_type': 'Leave Allocation',
- 'transaction_name': ('not in', expired_allocation)
- },
- or_filters={
- 'is_carry_forward': 0,
- 'leave_type': ('in', leave_type)
- })
+ # fetch non expired leave ledger entry of transaction_type allocation
+ expire_allocation = frappe.db.sql("""
+ SELECT
+ leaves, to_date, employee, leave_type,
+ is_carry_forward, transaction_name as name, transaction_type
+ FROM `tabLeave Ledger Entry` l
+ WHERE (NOT EXISTS
+ (SELECT name
+ FROM `tabLeave Ledger Entry`
+ WHERE
+ transaction_name = l.transaction_name
+ AND transaction_type = 'Leave Allocation'
+ AND name<>l.name
+ AND docstatus = 1
+ AND (
+ is_carry_forward=l.is_carry_forward
+ OR (is_carry_forward = 0 AND leave_type not in %s)
+ )))
+ AND transaction_type = 'Leave Allocation'
+ AND to_date < %s""", (leave_type, today()), as_dict=1)
if expire_allocation:
create_expiry_ledger_entry(expire_allocation)
@@ -133,6 +141,7 @@ def get_remaining_leaves(allocation):
'employee': allocation.employee,
'leave_type': allocation.leave_type,
'to_date': ('<=', allocation.to_date),
+ 'docstatus': 1
}, fieldname=['SUM(leaves)'])
@frappe.whitelist()
@@ -159,7 +168,8 @@ def expire_allocation(allocation, expiry_date=None):
def expire_carried_forward_allocation(allocation):
''' Expires remaining leaves in the on carried forward allocation '''
from erpnext.hr.doctype.leave_application.leave_application import get_leaves_for_period
- leaves_taken = get_leaves_for_period(allocation.employee, allocation.leave_type, allocation.from_date, allocation.to_date)
+ leaves_taken = get_leaves_for_period(allocation.employee, allocation.leave_type,
+ allocation.from_date, allocation.to_date, do_not_skip_expired_leaves=True)
leaves = flt(allocation.leaves) + flt(leaves_taken)
# allow expired leaves entry to be created
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
index 9ef3a99930b..656de0170dd 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
@@ -55,6 +55,7 @@ class PayrollEntry(Document):
ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s
{condition}""".format(condition=condition),
{"company": self.company, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet})
+
if sal_struct:
cond += "and t2.salary_structure IN %(sal_struct)s "
cond += "and %(from_date)s >= t2.from_date"
@@ -138,7 +139,7 @@ class PayrollEntry(Document):
cond = self.get_filter_condition()
ss_list = frappe.db.sql("""
- select t1.name, t1.salary_structure from `tabSalary Slip` t1
+ select t1.name, t1.salary_structure, t1.payroll_cost_center from `tabSalary Slip` t1
where t1.docstatus = %s and t1.start_date >= %s and t1.end_date <= %s
and (t1.journal_entry is null or t1.journal_entry = "") and ifnull(salary_slip_based_on_timesheet,0) = %s %s
""" % ('%s', '%s', '%s','%s', cond), (ss_status, self.start_date, self.end_date, self.salary_slip_based_on_timesheet), as_dict=as_dict)
@@ -169,10 +170,14 @@ class PayrollEntry(Document):
def get_salary_components(self, component_type):
salary_slips = self.get_sal_slip_list(ss_status = 1, as_dict = True)
- if salary_slips:
- salary_components = frappe.db.sql("""select salary_component, amount, parentfield
- from `tabSalary Detail` where parentfield = '%s' and parent in (%s)""" %
- (component_type, ', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=True)
+ if salary_slips:
+ salary_components = frappe.db.sql("""
+ select ssd.salary_component, ssd.amount, ssd.parentfield, ss.payroll_cost_center
+ from `tabSalary Slip` ss, `tabSalary Detail` ssd
+ where ss.name = ssd.parent and ssd.parentfield = '%s' and ss.name in (%s)
+ """ % (component_type, ', '.join(['%s']*len(salary_slips))),
+ tuple([d.name for d in salary_slips]), as_dict=True)
+
return salary_components
def get_salary_component_total(self, component_type = None):
@@ -186,15 +191,16 @@ class PayrollEntry(Document):
if is_flexible_benefit == 1 and only_tax_impact ==1:
add_component_to_accrual_jv_entry = False
if add_component_to_accrual_jv_entry:
- component_dict[item['salary_component']] = component_dict.get(item['salary_component'], 0) + item['amount']
+ component_dict[(item.salary_component, item.payroll_cost_center)] \
+ = component_dict.get((item.salary_component, item.payroll_cost_center), 0) + flt(item.amount)
account_details = self.get_account(component_dict = component_dict)
return account_details
def get_account(self, component_dict = None):
- account_dict = {}
- for s, a in component_dict.items():
- account = self.get_salary_component_account(s)
- account_dict[account] = account_dict.get(account, 0) + a
+ account_dict = {}
+ for key, amount in component_dict.items():
+ account = self.get_salary_component_account(key[0])
+ account_dict[(account, key[1])] = account_dict.get((account, key[1]), 0) + amount
return account_dict
def get_default_payroll_payable_account(self):
@@ -227,23 +233,23 @@ class PayrollEntry(Document):
payable_amount = 0
# Earnings
- for acc, amount in earnings.items():
+ for acc_cc, amount in earnings.items():
payable_amount += flt(amount, precision)
accounts.append({
- "account": acc,
+ "account": acc_cc[0],
"debit_in_account_currency": flt(amount, precision),
"party_type": '',
- "cost_center": self.cost_center,
+ "cost_center": acc_cc[1] or self.cost_center,
"project": self.project
})
# Deductions
- for acc, amount in deductions.items():
+ for acc_cc, amount in deductions.items():
payable_amount -= flt(amount, precision)
accounts.append({
- "account": acc,
+ "account": acc_cc[0],
"credit_in_account_currency": flt(amount, precision),
- "cost_center": self.cost_center,
+ "cost_center": acc_cc[1] or self.cost_center,
"party_type": '',
"project": self.project
})
@@ -253,6 +259,7 @@ class PayrollEntry(Document):
"account": default_payroll_payable_account,
"credit_in_account_currency": flt(payable_amount, precision),
"party_type": '',
+ "cost_center": self.cost_center
})
journal_entry.set("accounts", accounts)
diff --git a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
index e43f744bd43..3c318e78a24 100644
--- a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
+++ b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
@@ -10,15 +10,16 @@ from frappe.utils import add_months
from erpnext.hr.doctype.payroll_entry.payroll_entry import get_start_end_dates, get_end_date
from erpnext.hr.doctype.employee.test_employee import make_employee
from erpnext.hr.doctype.salary_slip.test_salary_slip import get_salary_component_account, \
- make_earning_salary_component, make_deduction_salary_component
+ make_earning_salary_component, make_deduction_salary_component, create_account
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
from erpnext.loan_management.doctype.loan.test_loan import create_loan, make_loan_disbursement_entry
from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import process_loan_interest_accrual_for_term_loans
class TestPayrollEntry(unittest.TestCase):
def setUp(self):
- for dt in ["Salary Slip", "Salary Component", "Salary Component Account", "Payroll Entry", "Salary Structure"]:
- frappe.db.sql("delete from `tab%s`" % dt)
+ for dt in ["Salary Slip", "Salary Component", "Salary Component Account",
+ "Payroll Entry", "Salary Structure", "Salary Structure Assignment", "Payroll Employee Detail", "Additional Salary"]:
+ frappe.db.sql("delete from `tab%s`" % dt)
make_earning_salary_component(setup=True, company_list=["_Test Company"])
make_deduction_salary_component(setup=True, company_list=["_Test Company"])
@@ -33,11 +34,59 @@ class TestPayrollEntry(unittest.TestCase):
get_salary_component_account(data.name)
employee = frappe.db.get_value("Employee", {'company': company})
- make_salary_structure("_Test Salary Structure", "Monthly", employee)
+ make_salary_structure("_Test Salary Structure", "Monthly", employee, company=company)
dates = get_start_end_dates('Monthly', nowdate())
if not frappe.db.get_value("Salary Slip", {"start_date": dates.start_date, "end_date": dates.end_date}):
make_payroll_entry(start_date=dates.start_date, end_date=dates.end_date)
+ def test_payroll_entry_with_employee_cost_center(self): # pylint: disable=no-self-use
+ for data in frappe.get_all('Salary Component', fields = ["name"]):
+ if not frappe.db.get_value('Salary Component Account',
+ {'parent': data.name, 'company': "_Test Company"}, 'name'):
+ get_salary_component_account(data.name)
+
+ if not frappe.db.exists('Department', "cc - _TC"):
+ frappe.get_doc({
+ 'doctype': 'Department',
+ 'department_name': "cc",
+ "company": "_Test Company"
+ }).insert()
+
+ employee1 = make_employee("test_employee1@example.com", payroll_cost_center="_Test Cost Center - _TC",
+ department="cc - _TC", company="_Test Company")
+ employee2 = make_employee("test_employee2@example.com", payroll_cost_center="_Test Cost Center 2 - _TC",
+ department="cc - _TC", company="_Test Company")
+
+ make_salary_structure("_Test Salary Structure 1", "Monthly", employee1, company="_Test Company")
+ make_salary_structure("_Test Salary Structure 2", "Monthly", employee2, company="_Test Company")
+
+ if not frappe.db.exists("Account", "_Test Payroll Payable - _TC"):
+ create_account(account_name="_Test Payroll Payable",
+ company="_Test Company", parent_account="Current Liabilities - _TC")
+ frappe.db.set_value("Company", "_Test Company", "default_payroll_payable_account",
+ "_Test Payroll Payable - _TC")
+
+ dates = get_start_end_dates('Monthly', nowdate())
+ if not frappe.db.get_value("Salary Slip", {"start_date": dates.start_date, "end_date": dates.end_date}):
+ pe = make_payroll_entry(start_date=dates.start_date, end_date=dates.end_date,
+ department="cc - _TC", company="_Test Company", payment_account="Cash - _TC", cost_center="Main - _TC")
+ je = frappe.db.get_value("Salary Slip", {"payroll_entry": pe.name}, "journal_entry")
+ je_entries = frappe.db.sql("""
+ select account, cost_center, debit, credit
+ from `tabJournal Entry Account`
+ where parent=%s
+ order by account, cost_center
+ """, je)
+ expected_je = (
+ ('_Test Payroll Payable - _TC', 'Main - _TC', 0.0, 155600.0),
+ ('Salary - _TC', '_Test Cost Center - _TC', 78000.0, 0.0),
+ ('Salary - _TC', '_Test Cost Center 2 - _TC', 78000.0, 0.0),
+ ('Salary Deductions - _TC', '_Test Cost Center - _TC', 0.0, 200.0),
+ ('Salary Deductions - _TC', '_Test Cost Center 2 - _TC', 0.0, 200.0)
+ )
+
+ self.assertEqual(je_entries, expected_je)
+
def test_get_end_date(self):
self.assertEqual(get_end_date('2017-01-01', 'monthly'), {'end_date': '2017-01-31'})
self.assertEqual(get_end_date('2017-02-01', 'monthly'), {'end_date': '2017-02-28'})
@@ -49,7 +98,6 @@ class TestPayrollEntry(unittest.TestCase):
self.assertEqual(get_end_date('2017-02-15', 'daily'), {'end_date': '2017-02-15'})
def test_loan(self):
-
branch = "Test Employee Branch"
applicant = make_employee("test_employee@loan.com", company="_Test Company")
company = "_Test Company"
@@ -116,6 +164,7 @@ def make_payroll_entry(**args):
payroll_entry.posting_date = nowdate()
payroll_entry.payroll_frequency = "Monthly"
payroll_entry.branch = args.branch or None
+ payroll_entry.department = args.department or None
if args.cost_center:
payroll_entry.cost_center = args.cost_center
@@ -123,6 +172,7 @@ def make_payroll_entry(**args):
if args.payment_account:
payroll_entry.payment_account = args.payment_account
+ payroll_entry.fill_employee_details()
payroll_entry.save()
payroll_entry.create_salary_slips()
payroll_entry.submit_salary_slips()
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index 54a8164587e..cfd4d897314 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -12,6 +12,7 @@
"department",
"designation",
"branch",
+ "payroll_cost_center",
"column_break1",
"status",
"journal_entry",
@@ -459,13 +460,22 @@
"options": "Salary Slip",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fetch_from": "employee.payroll_cost_center",
+ "fetch_if_empty": 1,
+ "fieldname": "payroll_cost_center",
+ "fieldtype": "Link",
+ "label": "Payroll Cost Center",
+ "options": "Cost Center",
+ "read_only": 1
}
],
"icon": "fa fa-file-text",
"idx": 9,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-14 20:02:53.159827",
+ "modified": "2020-05-05 18:55:26.173629",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Slip",
diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
index a7dcb941677..3eff738ec8d 100644
--- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
@@ -422,22 +422,32 @@ def get_salary_component_account(sal_comp, company_list=None):
sal_comp = frappe.get_doc("Salary Component", sal_comp)
if not sal_comp.get("accounts"):
for d in company_list:
+ company_abbr = frappe.get_cached_value('Company', d, 'abbr')
+
+ if sal_comp.type == "Earning":
+ account_name = "Salary"
+ parent_account = "Indirect Expenses - " + company_abbr
+ else:
+ account_name = "Salary Deductions"
+ parent_account = "Current Liabilities - " + company_abbr
+
sal_comp.append("accounts", {
"company": d,
- "default_account": create_account(d)
+ "default_account": create_account(account_name, d, parent_account)
})
sal_comp.save()
-def create_account(company):
- salary_account = frappe.db.get_value("Account", "Salary - " + frappe.get_cached_value('Company', company, 'abbr'))
- if not salary_account:
+def create_account(account_name, company, parent_account):
+ company_abbr = frappe.get_cached_value('Company', company, 'abbr')
+ account = frappe.db.get_value("Account", account_name + " - " + company_abbr)
+ if not account:
frappe.get_doc({
"doctype": "Account",
- "account_name": "Salary",
- "parent_account": "Indirect Expenses - " + frappe.get_cached_value('Company', company, 'abbr'),
+ "account_name": account_name,
+ "parent_account": parent_account,
"company": company
}).insert()
- return salary_account
+ return account
def make_earning_salary_component(setup=False, test_tax=False, company_list=None):
data = [
@@ -683,7 +693,7 @@ def setup_test():
make_earning_salary_component(setup=True, company_list=["_Test Company"])
make_deduction_salary_component(setup=True, company_list=["_Test Company"])
- for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Attendance"]:
+ for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Attendance", "Additional Salary"]:
frappe.db.sql("delete from `tab%s`" % dt)
make_holiday_list()
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 5ba7f1c4327..ffc16d73c25 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -153,12 +153,16 @@ def make_salary_slip(source_name, target_doc = None, employee = None, as_print =
def postprocess(source, target):
if employee:
employee_details = frappe.db.get_value("Employee", employee,
- ["employee_name", "branch", "designation", "department"], as_dict=1)
+ ["employee_name", "branch", "designation", "department", "payroll_cost_center"], as_dict=1)
target.employee = employee
target.employee_name = employee_details.employee_name
target.branch = employee_details.branch
target.designation = employee_details.designation
target.department = employee_details.department
+ target.payroll_cost_center = employee_details.payroll_cost_center
+ if not target.payroll_cost_center and target.department:
+ target.payroll_cost_center = frappe.db.get_value("Department", target.department, "payroll_cost_center")
+
target.run_method('process_salary_structure', for_preview=for_preview)
doc = get_mapped_doc("Salary Structure", source_name, {
diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
index c1869f05d7d..eb5311e3b81 100644
--- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
@@ -128,6 +128,7 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do
salary_structure_doc.insert()
if not dont_submit:
salary_structure_doc.submit()
+
else:
salary_structure_doc = frappe.get_doc("Salary Structure", salary_structure)
diff --git a/erpnext/hr/doctype/shift_type/shift_type.py b/erpnext/hr/doctype/shift_type/shift_type.py
index d56080eecd4..19735648aa9 100644
--- a/erpnext/hr/doctype/shift_type/shift_type.py
+++ b/erpnext/hr/doctype/shift_type/shift_type.py
@@ -28,13 +28,14 @@ class ShiftType(Document):
logs = frappe.db.get_list('Employee Checkin', fields="*", filters=filters, order_by="employee,time")
for key, group in itertools.groupby(logs, key=lambda x: (x['employee'], x['shift_actual_start'])):
single_shift_logs = list(group)
- attendance_status, working_hours, late_entry, early_exit = self.get_attendance(single_shift_logs)
- mark_attendance_and_link_log(single_shift_logs, attendance_status, key[1].date(), working_hours, late_entry, early_exit, self.name)
+ attendance_status, working_hours, late_entry, early_exit, in_time, out_time = self.get_attendance(single_shift_logs)
+ mark_attendance_and_link_log(single_shift_logs, attendance_status, key[1].date(), working_hours, late_entry, early_exit, in_time, out_time, self.name)
for employee in self.get_assigned_employee(self.process_attendance_after, True):
self.mark_absent_for_dates_with_no_attendance(employee)
def get_attendance(self, logs):
- """Return attendance_status, working_hours for a set of logs belonging to a single shift.
+ """Return attendance_status, working_hours, late_entry, early_exit, in_time, out_time
+ for a set of logs belonging to a single shift.
Assumtion:
1. These logs belongs to an single shift, single employee and is not in a holiday date.
2. Logs are in chronological order
@@ -48,10 +49,10 @@ class ShiftType(Document):
early_exit = True
if self.working_hours_threshold_for_absent and total_working_hours < self.working_hours_threshold_for_absent:
- return 'Absent', total_working_hours, late_entry, early_exit
+ return 'Absent', total_working_hours, late_entry, early_exit, in_time, out_time
if self.working_hours_threshold_for_half_day and total_working_hours < self.working_hours_threshold_for_half_day:
- return 'Half Day', total_working_hours, late_entry, early_exit
- return 'Present', total_working_hours, late_entry, early_exit
+ return 'Half Day', total_working_hours, late_entry, early_exit, in_time, out_time
+ return 'Present', total_working_hours, late_entry, early_exit, in_time, out_time
def mark_absent_for_dates_with_no_attendance(self, employee):
"""Marks Absents for the given employee on working days in this shift which have no attendance marked.
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
index 61faea18713..edf05e827b9 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
@@ -22,6 +22,9 @@ def get_template():
args = frappe.local.form_dict
+ if getdate(args.from_date) > getdate(args.to_date):
+ frappe.throw(_("To Date should be greater than From Date"))
+
w = UnicodeWriter()
w = add_header(w)
diff --git a/erpnext/hr/module_onboarding/human_resource/human_resource.json b/erpnext/hr/module_onboarding/human_resource/human_resource.json
new file mode 100644
index 00000000000..e64582b407c
--- /dev/null
+++ b/erpnext/hr/module_onboarding/human_resource/human_resource.json
@@ -0,0 +1,51 @@
+{
+ "allow_roles": [
+ {
+ "role": "HR Manager"
+ },
+ {
+ "role": "HR User"
+ }
+ ],
+ "creation": "2020-05-14 11:51:45.050242",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/human-resources",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-20 11:20:07.992597",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Human Resource",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Create Department"
+ },
+ {
+ "step": "Create Designation"
+ },
+ {
+ "step": "Create Holiday list"
+ },
+ {
+ "step": "Create Employee"
+ },
+ {
+ "step": "Create Leave Type"
+ },
+ {
+ "step": "Create Leave Allocation"
+ },
+ {
+ "step": "Create Leave Application"
+ },
+ {
+ "step": "HR Settings"
+ }
+ ],
+ "subtitle": "Employee, Leaves and more.",
+ "success_message": "The HR Module is all set up!",
+ "title": "Let's Setup the Human Resource Module. ",
+ "user_can_dismiss": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_department/create_department.json b/erpnext/hr/onboarding_step/create_department/create_department.json
new file mode 100644
index 00000000000..66a54cfc268
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_department/create_department.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 11:44:34.682115",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 12:22:26.448420",
+ "modified_by": "Administrator",
+ "name": "Create Department",
+ "owner": "Administrator",
+ "reference_document": "Department",
+ "show_full_form": 0,
+ "title": "Create Department",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_designation/create_designation.json b/erpnext/hr/onboarding_step/create_designation/create_designation.json
new file mode 100644
index 00000000000..c4e9cc77986
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_designation/create_designation.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 11:45:07.514193",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 12:22:41.500795",
+ "modified_by": "Administrator",
+ "name": "Create Designation",
+ "owner": "Administrator",
+ "reference_document": "Designation",
+ "show_full_form": 0,
+ "title": "Create Designation",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_employee/create_employee.json b/erpnext/hr/onboarding_step/create_employee/create_employee.json
new file mode 100644
index 00000000000..3aa33c6d862
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_employee/create_employee.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 11:43:25.561152",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 12:26:28.629074",
+ "modified_by": "Administrator",
+ "name": "Create Employee",
+ "owner": "Administrator",
+ "reference_document": "Employee",
+ "show_full_form": 0,
+ "title": "Create Employee",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_holiday_list/create_holiday_list.json b/erpnext/hr/onboarding_step/create_holiday_list/create_holiday_list.json
new file mode 100644
index 00000000000..32472b4b3fa
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_holiday_list/create_holiday_list.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-28 11:47:34.700174",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 12:25:38.068582",
+ "modified_by": "Administrator",
+ "name": "Create Holiday list",
+ "owner": "Administrator",
+ "reference_document": "Holiday List",
+ "show_full_form": 1,
+ "title": "Create Holiday List",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_leave_allocation/create_leave_allocation.json b/erpnext/hr/onboarding_step/create_leave_allocation/create_leave_allocation.json
new file mode 100644
index 00000000000..fa9941e6b97
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_leave_allocation/create_leave_allocation.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 11:48:56.123718",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 11:48:56.123718",
+ "modified_by": "Administrator",
+ "name": "Create Leave Allocation",
+ "owner": "Administrator",
+ "reference_document": "Leave Allocation",
+ "show_full_form": 0,
+ "title": "Create Leave Allocation",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_leave_application/create_leave_application.json b/erpnext/hr/onboarding_step/create_leave_application/create_leave_application.json
new file mode 100644
index 00000000000..1ed074e9a1d
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_leave_application/create_leave_application.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 11:49:45.400764",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 11:49:45.400764",
+ "modified_by": "Administrator",
+ "name": "Create Leave Application",
+ "owner": "Administrator",
+ "reference_document": "Leave Application",
+ "show_full_form": 0,
+ "title": "Create Leave Application",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/create_leave_type/create_leave_type.json b/erpnext/hr/onboarding_step/create_leave_type/create_leave_type.json
new file mode 100644
index 00000000000..8cbfc5c81f9
--- /dev/null
+++ b/erpnext/hr/onboarding_step/create_leave_type/create_leave_type.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-27 11:17:31.119312",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-20 11:17:31.119312",
+ "modified_by": "Administrator",
+ "name": "Create Leave Type",
+ "owner": "Administrator",
+ "reference_document": "Leave Type",
+ "show_full_form": 1,
+ "title": "Create Leave Type",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/onboarding_step/hr_settings/hr_settings.json b/erpnext/hr/onboarding_step/hr_settings/hr_settings.json
new file mode 100644
index 00000000000..0a1d0baf8aa
--- /dev/null
+++ b/erpnext/hr/onboarding_step/hr_settings/hr_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Update Settings",
+ "creation": "2020-05-28 13:13:52.427711",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 1,
+ "is_skipped": 0,
+ "modified": "2020-05-20 11:16:42.430974",
+ "modified_by": "Administrator",
+ "name": "HR Settings",
+ "owner": "Administrator",
+ "reference_document": "HR Settings",
+ "show_full_form": 0,
+ "title": "HR Settings",
+ "validate_action": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/report/department_analytics/department_analytics.json b/erpnext/hr/report/department_analytics/department_analytics.json
deleted file mode 100644
index 1e26b33c530..00000000000
--- a/erpnext/hr/report/department_analytics/department_analytics.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "add_total_row": 0,
- "creation": "2018-05-15 15:37:20.883263",
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 0,
- "is_standard": "Yes",
- "modified": "2018-05-15 17:19:32.934321",
- "modified_by": "Administrator",
- "module": "HR",
- "name": "Department Analytics",
- "owner": "Administrator",
- "ref_doctype": "Employee",
- "report_name": "Department Analytics",
- "report_type": "Script Report",
- "roles": [
- {
- "role": "Employee"
- },
- {
- "role": "HR User"
- },
- {
- "role": "HR Manager"
- }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/hr/report/department_analytics/department_analytics.py b/erpnext/hr/report/department_analytics/department_analytics.py
deleted file mode 100644
index b28eac43f8b..00000000000
--- a/erpnext/hr/report/department_analytics/department_analytics.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# 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 _
-
-def execute(filters=None):
- if not filters: filters = {}
-
- if not filters["company"]:
- frappe.throw(_('{0} is mandatory').format(_('Company')))
-
- columns = get_columns()
- employees = get_employees(filters)
- departments_result = get_department(filters)
- departments = []
- if departments_result:
- for department in departments_result:
- departments.append(department)
- chart = get_chart_data(departments,employees)
- return columns, employees, None, chart
-
-def get_columns():
- return [
- _("Employee") + ":Link/Employee:120", _("Name") + ":Data:200", _("Date of Birth")+ ":Date:100",
- _("Branch") + ":Link/Branch:120", _("Department") + ":Link/Department:120",
- _("Designation") + ":Link/Designation:120", _("Gender") + "::60", _("Company") + ":Link/Company:120"
- ]
-
-def get_conditions(filters):
- conditions = ""
- if filters.get("department"): conditions += " and department = '%s'" % \
- filters["department"].replace("'", "\\'")
-
- if filters.get("company"): conditions += " and company = '%s'" % \
- filters["company"].replace("'", "\\'")
- return conditions
-
-def get_employees(filters):
- conditions = get_conditions(filters)
- return frappe.db.sql("""select name, employee_name, date_of_birth,
- branch, department, designation,
- gender, company from `tabEmployee` where status = 'Active' %s""" % conditions, as_list=1)
-
-def get_department(filters):
- return frappe.db.sql("""select name from `tabDepartment` where company = %s""", (filters["company"]), as_list=1)
-
-def get_chart_data(departments,employees):
- if not departments:
- departments = []
- datasets = []
- for department in departments:
- if department:
- total_employee = frappe.db.sql("""select count(*) from \
- `tabEmployee` where \
- department = %s""" ,(department[0]), as_list=1)
- datasets.append(total_employee[0][0])
- chart = {
- "data": {
- 'labels': departments,
- 'datasets': [{'name': 'Employees','values': datasets}]
- }
- }
- chart["type"] = "bar"
- return chart
-
diff --git a/erpnext/hr/report/employee_analytics/__init__.py b/erpnext/hr/report/employee_analytics/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/hr/report/department_analytics/department_analytics.js b/erpnext/hr/report/employee_analytics/employee_analytics.js
similarity index 55%
rename from erpnext/hr/report/department_analytics/department_analytics.js
rename to erpnext/hr/report/employee_analytics/employee_analytics.js
index 29fedcd7350..8620a65a909 100644
--- a/erpnext/hr/report/department_analytics/department_analytics.js
+++ b/erpnext/hr/report/employee_analytics/employee_analytics.js
@@ -1,7 +1,8 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
+/* eslint-disable */
-frappe.query_reports["Department Analytics"] = {
+frappe.query_reports["Employee Analytics"] = {
"filters": [
{
"fieldname":"company",
@@ -11,5 +12,12 @@ frappe.query_reports["Department Analytics"] = {
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1
},
+ {
+ "fieldname":"parameter",
+ "label": __("Parameter"),
+ "fieldtype": "Select",
+ "options": ["Branch","Grade","Department","Designation", "Employment Type"],
+ "reqd": 1
+ }
]
-};
\ No newline at end of file
+};
diff --git a/erpnext/hr/report/employee_analytics/employee_analytics.json b/erpnext/hr/report/employee_analytics/employee_analytics.json
new file mode 100644
index 00000000000..5a7ab9a251e
--- /dev/null
+++ b/erpnext/hr/report/employee_analytics/employee_analytics.json
@@ -0,0 +1,30 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-05-12 13:52:50.631086",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-05-12 13:52:50.631086",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Employee Analytics",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Employee",
+ "report_name": "Employee Analytics",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Employee"
+ },
+ {
+ "role": "HR User"
+ },
+ {
+ "role": "HR Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/hr/report/employee_analytics/employee_analytics.py b/erpnext/hr/report/employee_analytics/employee_analytics.py
new file mode 100644
index 00000000000..8f393889269
--- /dev/null
+++ b/erpnext/hr/report/employee_analytics/employee_analytics.py
@@ -0,0 +1,84 @@
+# 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 _
+
+def execute(filters=None):
+ if not filters: filters = {}
+
+ if not filters["company"]:
+ frappe.throw(_('{0} is mandatory').format(_('Company')))
+
+ columns = get_columns()
+ employees = get_employees(filters)
+ parameters_result = get_parameters(filters)
+ parameters = []
+ if parameters_result:
+ for department in parameters_result:
+ parameters.append(department)
+
+ chart = get_chart_data(parameters,employees, filters)
+ return columns, employees, None, chart
+
+def get_columns():
+ return [
+ _("Employee") + ":Link/Employee:120", _("Name") + ":Data:200", _("Date of Birth")+ ":Date:100",
+ _("Branch") + ":Link/Branch:120", _("Department") + ":Link/Department:120",
+ _("Designation") + ":Link/Designation:120", _("Gender") + "::100", _("Company") + ":Link/Company:120"
+ ]
+
+def get_conditions(filters):
+ conditions = " and "+filters.get("parameter").lower().replace(" ","_")+" IS NOT NULL "
+
+ if filters.get("company"): conditions += " and company = '%s'" % \
+ filters["company"].replace("'", "\\'")
+ return conditions
+
+def get_employees(filters):
+ conditions = get_conditions(filters)
+ return frappe.db.sql("""select name, employee_name, date_of_birth,
+ branch, department, designation,
+ gender, company from `tabEmployee` where status = 'Active' %s""" % conditions, as_list=1)
+
+def get_parameters(filters):
+ if filters.get("parameter") == "Grade":
+ parameter = "Employee Grade"
+ else:
+ parameter = filters.get("parameter")
+
+ return frappe.db.sql("""select name from `tab"""+ parameter +"""` """, as_list=1)
+
+def get_chart_data(parameters,employees, filters):
+ if not parameters:
+ parameters = []
+ datasets = []
+ parameter_field_name = filters.get("parameter").lower().replace(" ","_")
+ label = []
+ for parameter in parameters:
+ if parameter:
+ total_employee = frappe.db.sql("""select count(*) from
+ `tabEmployee` where """+
+ parameter_field_name + """ = %s and company = %s""" ,( parameter[0], filters.get("company")), as_list=1)
+ if total_employee[0][0]:
+ label.append(parameter)
+ datasets.append(total_employee[0][0])
+
+ values = [ value for value in datasets if value !=0]
+
+ total_employee = frappe.db.count('Employee', {'status':'Active'})
+ others = total_employee - sum(values)
+
+ label.append(["Not Set"])
+ values.append(others)
+
+ chart = {
+ "data": {
+ 'labels': label,
+ 'datasets': [{'name': 'Employees','values': values}]
+ }
+ }
+ chart["type"] = "donut"
+ return chart
+
diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
index 97be5cd813c..db1d191758f 100644
--- a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
+++ b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
@@ -3,13 +3,13 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import flt
+from frappe.utils import flt, add_days
from frappe import _
-from erpnext.hr.doctype.leave_application.leave_application import get_leaves_for_period, get_leave_balance_on, get_leave_allocation_records
+from erpnext.hr.doctype.leave_application.leave_application import get_leaves_for_period, get_leave_balance_on
def execute(filters=None):
if filters.to_date <= filters.from_date:
- frappe.throw(_('From date can not be greater than than To date'))
+ frappe.throw(_('"From date" can not be greater than or equal to "To date"'))
columns = get_columns()
data = get_data(filters)
@@ -104,14 +104,17 @@ def get_data(filters):
new_allocation, expired_leaves = get_allocated_and_expired_leaves(filters.from_date, filters.to_date, employee.name, leave_type)
- opening = get_leave_balance_on(employee.name, leave_type, filters.from_date)
- closing = get_leave_balance_on(employee.name, leave_type, filters.to_date)
+ opening = get_leave_balance_on(employee.name, leave_type, add_days(filters.from_date, -1)) #allocation boundary condition
row.leaves_allocated = new_allocation
row.leaves_expired = expired_leaves - leaves_taken if expired_leaves - leaves_taken > 0 else 0
row.opening_balance = opening
row.leaves_taken = leaves_taken
- row.closing_balance = closing
+
+ # not be shown on the basis of days left it create in user mind for carry_forward leave
+ row.closing_balance = (new_allocation + opening - (row.leaves_expired + leaves_taken))
+
+
row.indent = 1
data.append(row)
new_leaves_allocated = 0
@@ -177,7 +180,7 @@ def get_allocated_and_expired_leaves(from_date, to_date, employee, leave_type):
}, as_dict=1)
for record in records:
- if record.to_date <= getdate(to_date):
+ if record.to_date < getdate(to_date):
expired_leaves += record.leaves
if record.from_date >= getdate(from_date):
diff --git a/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py b/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py
index a5cdecf36a7..92715d34453 100644
--- a/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py
+++ b/erpnext/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py
@@ -6,7 +6,7 @@ import frappe
from frappe import _
from frappe.utils import flt
from erpnext.hr.doctype.leave_application.leave_application \
- import get_leave_balance_on, get_leaves_for_period
+ import get_leave_details
from erpnext.hr.report.employee_leave_balance.employee_leave_balance \
import get_department_leave_approver_map
@@ -61,14 +61,14 @@ def get_data(filters, leave_types):
if (len(leave_approvers) and user in leave_approvers) or (user in ["Administrator", employee.user_id]) or ("HR Manager" in frappe.get_roles(user)):
row = [employee.name, employee.employee_name, employee.department]
-
+ available_leave = get_leave_details(employee.name, filters.date)
for leave_type in leave_types:
-
+ remaining = 0
+ if leave_type in available_leave["leave_allocation"]:
# opening balance
- opening = get_leave_balance_on(employee.name, leave_type, filters.date)
+ remaining = available_leave["leave_allocation"][leave_type]['remaining_leaves']
-
- row += [opening]
+ row += [remaining]
data.append(row)
diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
index 82ed27715f7..47daab19017 100644
--- a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
+++ b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
@@ -30,8 +30,11 @@ day_abbr = [
def execute(filters=None):
if not filters: filters = {}
+ if filters.hide_year_field == 1:
+ filters.year = 2020
+
conditions, filters = get_conditions(filters)
- columns = get_columns(filters)
+ columns, days = get_columns(filters)
att_map = get_attendance_list(conditions, filters)
if filters.group_by:
@@ -60,20 +63,67 @@ def execute(filters=None):
columns.extend([_("Total Late Entries") + ":Float:120", _("Total Early Exits") + ":Float:120"])
if filters.group_by:
+ emp_att_map = {}
for parameter in group_by_parameters:
data.append([ ""+ parameter + " "])
- record = add_data(emp_map[parameter], att_map, filters, holiday_map, conditions, leave_list=leave_list)
+ record, aaa = add_data(emp_map[parameter], att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
+ emp_att_map.update(aaa)
data += record
else:
- record = add_data(emp_map, att_map, filters, holiday_map, conditions, leave_list=leave_list)
+ record, emp_att_map = add_data(emp_map, att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
data += record
- return columns, data
+ chart_data = get_chart_data(emp_att_map, days)
+
+ return columns, data, None, chart_data
+
+def get_chart_data(emp_att_map, days):
+ labels = []
+ datasets = [
+ {"name": "Absent", "values": []},
+ {"name": "Present", "values": []},
+ {"name": "Leave", "values": []},
+ ]
+ for idx, day in enumerate(days, start=0):
+ p = day.replace("::65", "")
+ labels.append(day.replace("::65", ""))
+ total_absent_on_day = 0
+ total_leave_on_day = 0
+ total_present_on_day = 0
+ total_holiday = 0
+ for emp in emp_att_map.keys():
+ if emp_att_map[emp][idx]:
+ if emp_att_map[emp][idx] == "A":
+ total_absent_on_day += 1
+ if emp_att_map[emp][idx] in ["P", "WFH"]:
+ total_present_on_day += 1
+ if emp_att_map[emp][idx] == "HD":
+ total_present_on_day += 0.5
+ total_leave_on_day += 0.5
+ if emp_att_map[emp][idx] == "L":
+ total_leave_on_day += 1
-def add_data(employee_map, att_map, filters, holiday_map, conditions, leave_list=None):
+ datasets[0]["values"].append(total_absent_on_day)
+ datasets[1]["values"].append(total_present_on_day)
+ datasets[2]["values"].append(total_leave_on_day)
+
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': datasets
+ }
+ }
+
+ chart["type"] = "line"
+
+ return chart
+
+def add_data(employee_map, att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=None):
record = []
+ emp_att_map = {}
for emp in employee_map:
emp_det = employee_map.get(emp)
if not emp_det or emp not in att_map:
@@ -85,6 +135,7 @@ def add_data(employee_map, att_map, filters, holiday_map, conditions, leave_list
row += [emp, emp_det.employee_name]
total_p = total_a = total_l = total_h = total_um= 0.0
+ emp_status_map = []
for day in range(filters["total_days_in_month"]):
status = None
status = att_map.get(emp).get(day + 1)
@@ -101,19 +152,11 @@ def add_data(employee_map, att_map, filters, holiday_map, conditions, leave_list
status = "Holiday"
total_h += 1
+ abbr = status_map.get(status, "")
+ emp_status_map.append(abbr)
- # if emp_holiday_list in holiday_map and (day+1) in holiday_map[emp_holiday_list][0]:
- # if holiday_map[emp_holiday_list][1]:
- # status= "Weekly Off"
- # else:
- # status = "Holiday"
-
- # += 1
-
- if not filters.summarized_view:
- row.append(status_map.get(status, ""))
- else:
- if status == "Present":
+ if filters.summarized_view:
+ if status == "Present" or status == "Work From Home":
total_p += 1
elif status == "Absent":
total_a += 1
@@ -126,6 +169,9 @@ def add_data(employee_map, att_map, filters, holiday_map, conditions, leave_list
elif not status:
total_um += 1
+ if not filters.summarized_view:
+ row += emp_status_map
+
if filters.summarized_view:
row += [total_p, total_l, total_a, total_h, total_um]
@@ -159,10 +205,10 @@ def add_data(employee_map, att_map, filters, holiday_map, conditions, leave_list
row.append("0.0")
row.extend([time_default_counts[0][0],time_default_counts[0][1]])
+ emp_att_map[emp] = emp_status_map
record.append(row)
-
- return record
+ return record, emp_att_map
def get_columns(filters):
@@ -172,17 +218,19 @@ def get_columns(filters):
columns = [_(filters.group_by)+ ":Link/Branch:120"]
columns += [
- _("Employee") + ":Link/Employee:120", _("Employee Name") + ":Link/Employee:120"
+ _("Employee") + ":Link/Employee:120", _("Employee Name") + ":Data/:120"
]
-
+ days = []
+ for day in range(filters["total_days_in_month"]):
+ date = str(filters.year) + "-" + str(filters.month)+ "-" + str(day+1)
+ day_name = day_abbr[getdate(date).weekday()]
+ days.append(cstr(day+1)+ " " +day_name +"::65")
if not filters.summarized_view:
- for day in range(filters["total_days_in_month"]):
- date = str(filters.year) + "-" + str(filters.month)+ "-" + str(day+1)
- day_name = day_abbr[getdate(date).weekday()]
- columns.append(cstr(day+1)+ " " +day_name +"::65")
- else:
+ columns += days
+
+ if filters.summarized_view:
columns += [_("Total Present") + ":Float:120", _("Total Leaves") + ":Float:120", _("Total Absent") + ":Float:120", _("Total Holidays") + ":Float:120", _("Unmarked Days")+ ":Float:120"]
- return columns
+ return columns, days
def get_attendance_list(conditions, filters):
attendance_list = frappe.db.sql("""select employee, day(attendance_date) as day_of_month,
diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py
index cd125108c61..8d95924681a 100644
--- a/erpnext/hr/utils.py
+++ b/erpnext/hr/utils.py
@@ -73,11 +73,11 @@ class EmployeeBoardingController(Document):
def assign_task_to_users(self, task, users):
for user in users:
args = {
- 'assign_to' : user,
- 'doctype' : task.doctype,
- 'name' : task.name,
- 'description' : task.description or task.subject,
- 'notify': self.notify_users_by_email
+ 'assign_to': [user],
+ 'doctype': task.doctype,
+ 'name': task.name,
+ 'description': task.description or task.subject,
+ 'notify': self.notify_users_by_email
}
assign_to.add(args)
diff --git a/erpnext/loan_management/desk_page/loan_management/loan_management.json b/erpnext/loan_management/desk_page/loan/loan.json
similarity index 74%
rename from erpnext/loan_management/desk_page/loan_management/loan_management.json
rename to erpnext/loan_management/desk_page/loan/loan.json
index f9ea978ed6e..48193b0a0d8 100644
--- a/erpnext/loan_management/desk_page/loan_management/loan_management.json
+++ b/erpnext/loan_management/desk_page/loan/loan.json
@@ -23,7 +23,7 @@
{
"hidden": 0,
"label": "Reports",
- "links": "[\n {\n \"dependencies\": [\n \"Loan Repayment\"\n ],\n \"doctype\": \"Loan Repayment\",\n \"incomplete_dependencies\": [\n \"Loan Repayment\"\n ],\n \"is_query_report\": true,\n \"label\": \"Loan Repayment and Closure\",\n \"name\": \"Loan Repayment and Closure\",\n \"route\": \"#query-report/Loan Repayment and Closure\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Loan Security Pledge\"\n ],\n \"doctype\": \"Loan Security Pledge\",\n \"incomplete_dependencies\": [\n \"Loan Security Pledge\"\n ],\n \"is_query_report\": true,\n \"label\": \"Loan Security Status\",\n \"name\": \"Loan Security Status\",\n \"route\": \"#query-report/Loan Security Status\",\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"doctype\": \"Loan Repayment\",\n \"is_query_report\": true,\n \"label\": \"Loan Repayment and Closure\",\n \"name\": \"Loan Repayment and Closure\",\n \"route\": \"#query-report/Loan Repayment and Closure\",\n \"type\": \"report\"\n },\n {\n \"doctype\": \"Loan Security Pledge\",\n \"is_query_report\": true,\n \"label\": \"Loan Security Status\",\n \"name\": \"Loan Security Status\",\n \"route\": \"#query-report/Loan Security Status\",\n \"type\": \"report\"\n }\n]"
}
],
"category": "Modules",
@@ -36,18 +36,21 @@
"extends_another_page": 0,
"idx": 0,
"is_standard": 1,
- "label": "Loan Management",
- "modified": "2020-04-02 11:28:51.380509",
+ "label": "Loan",
+ "modified": "2020-06-07 19:42:14.947902",
"modified_by": "Administrator",
"module": "Loan Management",
- "name": "Loan Management",
+ "name": "Loan",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#ffe8cd",
+ "format": "{} Open",
"label": "Loan Application",
"link_to": "Loan Application",
+ "stats_filter": "{ \"status\": \"Open\" }",
"type": "DocType"
},
{
diff --git a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
index c9e36a84ddb..d44088bee74 100644
--- a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
+++ b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
@@ -27,6 +27,7 @@ class LoanDisbursement(AccountsController):
def on_cancel(self):
self.make_gl_entries(cancel=1)
+ self.ignore_linked_doctypes = ['GL Entry']
def set_missing_values(self):
if not self.disbursement_date:
diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py
index 094b9c698c7..e6ceb551850 100644
--- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py
+++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py
@@ -31,6 +31,7 @@ class LoanInterestAccrual(AccountsController):
self.update_is_accrued()
self.make_gl_entries(cancel=1)
+ self.ignore_linked_doctypes = ['GL Entry']
def update_is_accrued(self):
frappe.db.set_value('Repayment Schedule', self.repayment_schedule_name, 'is_accrued', 0)
@@ -176,21 +177,23 @@ def get_term_loans(date, term_loan=None, loan_type=None):
return term_loans
def make_loan_interest_accrual_entry(args):
- loan_interest_accrual = frappe.new_doc("Loan Interest Accrual")
- loan_interest_accrual.loan = args.loan
- loan_interest_accrual.applicant_type = args.applicant_type
- loan_interest_accrual.applicant = args.applicant
- loan_interest_accrual.interest_income_account = args.interest_income_account
- loan_interest_accrual.loan_account = args.loan_account
- loan_interest_accrual.pending_principal_amount = flt(args.pending_principal_amount, 2)
- loan_interest_accrual.interest_amount = flt(args.interest_amount, 2)
- loan_interest_accrual.posting_date = args.posting_date or nowdate()
- loan_interest_accrual.process_loan_interest_accrual = args.process_loan_interest
- loan_interest_accrual.repayment_schedule_name = args.repayment_schedule_name
- loan_interest_accrual.payable_principal_amount = args.payable_principal
+ precision = cint(frappe.db.get_default("currency_precision")) or 2
- loan_interest_accrual.save()
- loan_interest_accrual.submit()
+ loan_interest_accrual = frappe.new_doc("Loan Interest Accrual")
+ loan_interest_accrual.loan = args.loan
+ loan_interest_accrual.applicant_type = args.applicant_type
+ loan_interest_accrual.applicant = args.applicant
+ loan_interest_accrual.interest_income_account = args.interest_income_account
+ loan_interest_accrual.loan_account = args.loan_account
+ loan_interest_accrual.pending_principal_amount = flt(args.pending_principal_amount, precision)
+ loan_interest_accrual.interest_amount = flt(args.interest_amount, precision)
+ loan_interest_accrual.posting_date = args.posting_date or nowdate()
+ loan_interest_accrual.process_loan_interest_accrual = args.process_loan_interest
+ loan_interest_accrual.repayment_schedule_name = args.repayment_schedule_name
+ loan_interest_accrual.payable_principal_amount = args.payable_principal
+
+ loan_interest_accrual.save()
+ loan_interest_accrual.submit()
def get_no_of_days_for_interest_accural(loan, posting_date):
diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
index 2ab668a0e11..c28994e280b 100644
--- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
+++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py
@@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe, erpnext
import json
from frappe import _
-from frappe.utils import flt, getdate
+from frappe.utils import flt, getdate, cint
from six import iteritems
from frappe.model.document import Document
from frappe.utils import date_diff, add_days, getdate, add_months, get_first_day, get_datetime
@@ -29,8 +29,11 @@ class LoanRepayment(AccountsController):
def on_cancel(self):
self.mark_as_unpaid()
self.make_gl_entries(cancel=1)
+ self.ignore_linked_doctypes = ['GL Entry']
def set_missing_values(self, amounts):
+ precision = cint(frappe.db.get_default("currency_precision")) or 2
+
if not self.posting_date:
self.posting_date = get_datetime()
@@ -38,24 +41,26 @@ class LoanRepayment(AccountsController):
self.cost_center = erpnext.get_default_cost_center(self.company)
if not self.interest_payable:
- self.interest_payable = flt(amounts['interest_amount'], 2)
+ self.interest_payable = flt(amounts['interest_amount'], precision)
if not self.penalty_amount:
- self.penalty_amount = flt(amounts['penalty_amount'], 2)
+ self.penalty_amount = flt(amounts['penalty_amount'], precision)
if not self.pending_principal_amount:
- self.pending_principal_amount = flt(amounts['pending_principal_amount'], 2)
+ self.pending_principal_amount = flt(amounts['pending_principal_amount'], precision)
if not self.payable_principal_amount and self.is_term_loan:
- self.payable_principal_amount = flt(amounts['payable_principal_amount'], 2)
+ self.payable_principal_amount = flt(amounts['payable_principal_amount'], precision)
if not self.payable_amount:
- self.payable_amount = flt(amounts['payable_amount'], 2)
+ self.payable_amount = flt(amounts['payable_amount'], precision)
if amounts.get('due_date'):
self.due_date = amounts.get('due_date')
def validate_amount(self):
+ precision = cint(frappe.db.get_default("currency_precision")) or 2
+
if not self.amount_paid:
frappe.throw(_("Amount paid cannot be zero"))
@@ -63,11 +68,13 @@ class LoanRepayment(AccountsController):
msg = _("Paid amount cannot be less than {0}").format(self.penalty_amount)
frappe.throw(msg)
- if self.payment_type == "Loan Closure" and flt(self.amount_paid, 2) < flt(self.payable_amount, 2):
+ if self.payment_type == "Loan Closure" and flt(self.amount_paid, precision) < flt(self.payable_amount, precision):
msg = _("Amount of {0} is required for Loan closure").format(self.payable_amount)
frappe.throw(msg)
def update_paid_amount(self):
+ precision = cint(frappe.db.get_default("currency_precision")) or 2
+
loan = frappe.get_doc("Loan", self.against_loan)
for payment in self.repayment_details:
@@ -75,9 +82,9 @@ class LoanRepayment(AccountsController):
SET paid_principal_amount = `paid_principal_amount` + %s,
paid_interest_amount = `paid_interest_amount` + %s
WHERE name = %s""",
- (flt(payment.paid_principal_amount), flt(payment.paid_interest_amount), payment.loan_interest_accrual))
+ (flt(payment.paid_principal_amount, precision), flt(payment.paid_interest_amount, precision), payment.loan_interest_accrual))
- if flt(loan.total_principal_paid + self.principal_amount_paid, 2) >= flt(loan.total_payment, 2):
+ if flt(loan.total_principal_paid + self.principal_amount_paid, precision) >= flt(loan.total_payment, precision):
if loan.is_secured_loan:
frappe.db.set_value("Loan", self.against_loan, "status", "Loan Closure Requested")
else:
@@ -253,6 +260,7 @@ def get_accrued_interest_entries(against_loan):
# So it pulls all the unpaid Loan Interest Accrual Entries and calculates the penalty if applicable
def get_amounts(amounts, against_loan, posting_date, payment_type):
+ precision = cint(frappe.db.get_default("currency_precision")) or 2
against_loan_doc = frappe.get_doc("Loan", against_loan)
loan_type_details = frappe.get_doc("Loan Type", against_loan_doc.loan_type)
@@ -282,8 +290,8 @@ def get_amounts(amounts, against_loan, posting_date, payment_type):
payable_principal_amount += entry.payable_principal_amount
pending_accrual_entries.setdefault(entry.name, {
- 'interest_amount': flt(entry.interest_amount),
- 'payable_principal_amount': flt(entry.payable_principal_amount)
+ 'interest_amount': flt(entry.interest_amount, precision),
+ 'payable_principal_amount': flt(entry.payable_principal_amount, precision)
})
if not final_due_date:
@@ -301,11 +309,11 @@ def get_amounts(amounts, against_loan, posting_date, payment_type):
per_day_interest = (payable_principal_amount * (loan_type_details.rate_of_interest / 100))/365
total_pending_interest += (pending_days * per_day_interest)
- amounts["pending_principal_amount"] = pending_principal_amount
- amounts["payable_principal_amount"] = payable_principal_amount
- amounts["interest_amount"] = total_pending_interest
- amounts["penalty_amount"] = penalty_amount
- amounts["payable_amount"] = payable_principal_amount + total_pending_interest + penalty_amount
+ amounts["pending_principal_amount"] = flt(pending_principal_amount, precision)
+ amounts["payable_principal_amount"] = flt(payable_principal_amount, precision)
+ amounts["interest_amount"] = flt(total_pending_interest, precision)
+ amounts["penalty_amount"] = flt(penalty_amount, precision)
+ amounts["payable_amount"] = flt(payable_principal_amount + total_pending_interest + penalty_amount, precision)
amounts["pending_accrual_entries"] = pending_accrual_entries
if final_due_date:
diff --git a/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py b/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py
index f97e5965a5f..961c05c9c1d 100644
--- a/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py
+++ b/erpnext/loan_management/doctype/loan_security_pledge/loan_security_pledge.py
@@ -38,7 +38,7 @@ class LoanSecurityPledge(Document):
for pledge in self.securities:
if not pledge.qty and not pledge.amount:
- frappe.throw(_("Qty or Amount is mandatroy for loan security"))
+ frappe.throw(_("Qty or Amount is mandatory for loan security!"))
if not (self.loan_application and pledge.loan_security_price):
pledge.loan_security_price = get_loan_security_price(pledge.loan_security)
diff --git a/erpnext/loan_management/doctype/loan_type/loan_type.json b/erpnext/loan_management/doctype/loan_type/loan_type.json
index 51c5cb98a63..1dd3710cd2a 100644
--- a/erpnext/loan_management/doctype/loan_type/loan_type.json
+++ b/erpnext/loan_management/doctype/loan_type/loan_type.json
@@ -41,6 +41,7 @@
"options": "Company:company:default_currency"
},
{
+ "default": "0",
"fieldname": "rate_of_interest",
"fieldtype": "Percent",
"label": "Rate of Interest (%) Yearly",
@@ -143,7 +144,7 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-15 00:24:43.259963",
+ "modified": "2020-06-07 18:55:59.346292",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Type",
diff --git a/erpnext/loan_management/report/loan_security_status/loan_security_status.py b/erpnext/loan_management/report/loan_security_status/loan_security_status.py
index ea6a2ee6452..19518554759 100644
--- a/erpnext/loan_management/report/loan_security_status/loan_security_status.py
+++ b/erpnext/loan_management/report/loan_security_status/loan_security_status.py
@@ -76,7 +76,8 @@ def get_columns(filters):
"fieldtype": "Link",
"fieldname": "currency",
"options": "Currency",
- "width": 50
+ "width": 50,
+ "hidden": 1
}
]
@@ -84,17 +85,13 @@ def get_columns(filters):
def get_data(filters):
- loan_security_price_map = frappe._dict(frappe.get_all("Loan Security",
- fields=["name", "loan_security_price"], as_list=1
- ))
-
data = []
conditions = get_conditions(filters)
loan_security_pledges = frappe.db.sql("""
SELECT
p.name, p.applicant, p.loan, p.status, p.pledge_time,
- c.loan_security, c.qty
+ c.loan_security, c.qty, c.loan_security_price, c.amount
FROM
`tabLoan Security Pledge` p, `tabPledge` c
WHERE
@@ -115,8 +112,8 @@ def get_data(filters):
row["pledge_time"] = pledge.pledge_time
row["loan_security"] = pledge.loan_security
row["qty"] = pledge.qty
- row["loan_security_price"] = loan_security_price_map.get(pledge.loan_security)
- row["loan_security_value"] = row["loan_security_price"] * pledge.qty
+ row["loan_security_price"] = pledge.loan_security_price
+ row["loan_security_value"] = pledge.amount
row["currency"] = default_currency
data.append(row)
diff --git a/erpnext/manufacturing/dashboard_fixtures.py b/erpnext/manufacturing/dashboard_fixtures.py
new file mode 100644
index 00000000000..4a17fd07fbb
--- /dev/null
+++ b/erpnext/manufacturing/dashboard_fixtures.py
@@ -0,0 +1,242 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe, erpnext, json
+from frappe import _
+from frappe.utils import nowdate, get_first_day, get_last_day, add_months
+from erpnext.accounts.utils import get_fiscal_year
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_dashboards():
+ return [{
+ "name": "Manufacturing",
+ "dashboard_name": "Manufacturing",
+ "charts": [
+ { "chart": "Produced Quantity", "width": "Half" },
+ { "chart": "Completed Operation", "width": "Half" },
+ { "chart": "Work Order Analysis", "width": "Half" },
+ { "chart": "Quality Inspection Analysis", "width": "Half" },
+ { "chart": "Pending Work Order", "width": "Half" },
+ { "chart": "Last Month Downtime Analysis", "width": "Half" },
+ { "chart": "Work Order Qty Analysis", "width": "Full" },
+ { "chart": "Job Card Analysis", "width": "Full" }
+ ],
+ "cards": [
+ { "card": "Monthly Total Work Order" },
+ { "card": "Monthly Completed Work Order" },
+ { "card": "Ongoing Job Card" },
+ { "card": "Monthly Quality Inspection"}
+ ]
+ }]
+
+def get_charts():
+ company = erpnext.get_default_company()
+
+ if not company:
+ company = frappe.db.get_value("Company", {"is_group": 0}, "name")
+
+ return [{
+ "doctype": "Dashboard Chart",
+ "based_on": "modified",
+ "time_interval": "Yearly",
+ "chart_type": "Sum",
+ "chart_name": _("Produced Quantity"),
+ "name": "Produced Quantity",
+ "document_type": "Work Order",
+ "filters_json": json.dumps([['Work Order', 'docstatus', '=', 1, False]]),
+ "group_by_type": "Count",
+ "time_interval": "Monthly",
+ "timespan": "Last Year",
+ "owner": "Administrator",
+ "type": "Line",
+ "value_based_on": "produced_qty",
+ "is_public": 1,
+ "timeseries": 1
+ }, {
+ "doctype": "Dashboard Chart",
+ "based_on": "creation",
+ "time_interval": "Yearly",
+ "chart_type": "Sum",
+ "chart_name": _("Completed Operation"),
+ "name": "Completed Operation",
+ "document_type": "Work Order Operation",
+ "filters_json": json.dumps([['Work Order Operation', 'docstatus', '=', 1, False]]),
+ "group_by_type": "Count",
+ "time_interval": "Quarterly",
+ "timespan": "Last Year",
+ "owner": "Administrator",
+ "type": "Line",
+ "value_based_on": "completed_qty",
+ "is_public": 1,
+ "timeseries": 1
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Work Order Analysis"),
+ "name": "Work Order Analysis",
+ "timespan": "Last Year",
+ "report_name": "Work Order Summary",
+ "owner": "Administrator",
+ "filters_json": json.dumps({"company": company, "charts_based_on": "Status"}),
+ "type": "Donut",
+ "is_public": 1,
+ "is_custom": 1,
+ "custom_options": json.dumps({
+ "axisOptions": {
+ "shortenYAxisNumbers": 1
+ },
+ "height": 300
+ }),
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Quality Inspection Analysis"),
+ "name": "Quality Inspection Analysis",
+ "timespan": "Last Year",
+ "report_name": "Quality Inspection Summary",
+ "owner": "Administrator",
+ "filters_json": json.dumps({}),
+ "type": "Donut",
+ "is_public": 1,
+ "is_custom": 1,
+ "custom_options": json.dumps({
+ "axisOptions": {
+ "shortenYAxisNumbers": 1
+ },
+ "height": 300
+ }),
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Pending Work Order"),
+ "name": "Pending Work Order",
+ "timespan": "Last Year",
+ "report_name": "Work Order Summary",
+ "filters_json": json.dumps({"company": company, "charts_based_on": "Age"}),
+ "owner": "Administrator",
+ "type": "Donut",
+ "is_public": 1,
+ "is_custom": 1,
+ "custom_options": json.dumps({
+ "axisOptions": {
+ "shortenYAxisNumbers": 1
+ },
+ "height": 300
+ }),
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Last Month Downtime Analysis"),
+ "name": "Last Month Downtime Analysis",
+ "timespan": "Last Year",
+ "filters_json": json.dumps({}),
+ "report_name": "Downtime Analysis",
+ "owner": "Administrator",
+ "is_public": 1,
+ "is_custom": 1,
+ "type": "Bar"
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Work Order Qty Analysis"),
+ "name": "Work Order Qty Analysis",
+ "timespan": "Last Year",
+ "report_name": "Work Order Summary",
+ "filters_json": json.dumps({"company": company, "charts_based_on": "Quantity"}),
+ "owner": "Administrator",
+ "type": "Bar",
+ "is_public": 1,
+ "is_custom": 1,
+ "custom_options": json.dumps({
+ "barOptions": { "stacked": 1 }
+ }),
+ }, {
+ "doctype": "Dashboard Chart",
+ "time_interval": "Yearly",
+ "chart_type": "Report",
+ "chart_name": _("Job Card Analysis"),
+ "name": "Job Card Analysis",
+ "timespan": "Last Year",
+ "report_name": "Job Card Summary",
+ "owner": "Administrator",
+ "is_public": 1,
+ "is_custom": 1,
+ "filters_json": json.dumps({"company": company, "docstatus": 1, "range":"Monthly"}),
+ "custom_options": json.dumps({
+ "barOptions": { "stacked": 1 }
+ }),
+ "type": "Bar"
+ }]
+
+def get_number_cards():
+ start_date = add_months(nowdate(), -1)
+ end_date = nowdate()
+
+ return [{
+ "doctype": "Number Card",
+ "document_type": "Work Order",
+ "name": "Monthly Total Work Order",
+ "filters_json": json.dumps([
+ ['Work Order', 'docstatus', '=', 1],
+ ['Work Order', 'creation', 'between', [start_date, end_date]]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Monthly Total Work Order"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Work Order",
+ "name": "Monthly Completed Work Order",
+ "filters_json": json.dumps([
+ ['Work Order', 'status', '=', 'Completed'],
+ ['Work Order', 'docstatus', '=', 1],
+ ['Work Order', 'creation', 'between', [start_date, end_date]]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Monthly Completed Work Order"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Job Card",
+ "name": "Ongoing Job Card",
+ "filters_json": json.dumps([
+ ['Job Card', 'status','!=','Completed'],
+ ['Job Card', 'docstatus', '=', 1]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Ongoing Job Card"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ },
+ {
+ "doctype": "Number Card",
+ "document_type": "Quality Inspection",
+ "name": "Monthly Quality Inspection",
+ "filters_json": json.dumps([
+ ['Quality Inspection', 'docstatus', '=', 1],
+ ['Quality Inspection', 'creation', 'between', [start_date, end_date]]
+ ]),
+ "function": "Count",
+ "is_public": 1,
+ "label": _("Monthly Quality Inspection"),
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Weekly"
+ }]
\ No newline at end of file
diff --git a/erpnext/manufacturing/desk_page/manufacturing/manufacturing.json b/erpnext/manufacturing/desk_page/manufacturing/manufacturing.json
index 18604e283ab..763f533a94b 100644
--- a/erpnext/manufacturing/desk_page/manufacturing/manufacturing.json
+++ b/erpnext/manufacturing/desk_page/manufacturing/manufacturing.json
@@ -3,7 +3,7 @@
{
"hidden": 0,
"label": "Production",
- "links": "[\n {\n \"dependencies\": [\n \"Item\",\n \"BOM\"\n ],\n \"description\": \"Orders released for production.\",\n \"label\": \"Work Order\",\n \"name\": \"Work Order\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"BOM\"\n ],\n \"description\": \"Generate Material Requests (MRP) and Work Orders.\",\n \"label\": \"Production Plan\",\n \"name\": \"Production Plan\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Stock Entry\",\n \"name\": \"Stock Entry\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Activity Type\"\n ],\n \"description\": \"Time Sheet for manufacturing.\",\n \"label\": \"Timesheet\",\n \"name\": \"Timesheet\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Job Card\",\n \"name\": \"Job Card\",\n \"type\": \"doctype\"\n }\n]"
+ "links": "[\n {\n \"dependencies\": [\n \"Item\",\n \"BOM\"\n ],\n \"description\": \"Orders released for production.\",\n \"label\": \"Work Order\",\n \"name\": \"Work Order\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"BOM\"\n ],\n \"description\": \"Generate Material Requests (MRP) and Work Orders.\",\n \"label\": \"Production Plan\",\n \"name\": \"Production Plan\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Stock Entry\",\n \"name\": \"Stock Entry\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Job Card\",\n \"name\": \"Job Card\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Downtime Entry\",\n \"name\": \"Downtime Entry\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
@@ -13,7 +13,7 @@
{
"hidden": 0,
"label": "Reports",
- "links": "[\n {\n \"dependencies\": [\n \"Work Order\"\n ],\n \"doctype\": \"Work Order\",\n \"is_query_report\": true,\n \"label\": \"Open Work Orders\",\n \"name\": \"Open Work Orders\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Work Order\"\n ],\n \"doctype\": \"Work Order\",\n \"is_query_report\": true,\n \"label\": \"Work Orders in Progress\",\n \"name\": \"Work Orders in Progress\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Work Order\"\n ],\n \"doctype\": \"Work Order\",\n \"is_query_report\": true,\n \"label\": \"Issued Items Against Work Order\",\n \"name\": \"Issued Items Against Work Order\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Work Order\"\n ],\n \"doctype\": \"Work Order\",\n \"is_query_report\": true,\n \"label\": \"Completed Work Orders\",\n \"name\": \"Completed Work Orders\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Work Order\"\n ],\n \"doctype\": \"Work Order\",\n \"is_query_report\": true,\n \"label\": \"Production Analytics\",\n \"name\": \"Production Analytics\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"BOM\"\n ],\n \"doctype\": \"BOM\",\n \"is_query_report\": true,\n \"label\": \"BOM Search\",\n \"name\": \"BOM Search\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"BOM\"\n ],\n \"doctype\": \"BOM\",\n \"is_query_report\": true,\n \"label\": \"BOM Stock Report\",\n \"name\": \"BOM Stock Report\",\n \"type\": \"report\"\n }\n]"
+ "links": "[{\n\t\"dependencies\": [\"Work Order\"],\n\t\"name\": \"Production Planning Report\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Work Order\",\n\t\"label\": \"Production Planning Report\"\n}, {\n\t\"dependencies\": [\"Work Order\"],\n\t\"name\": \"Work Order Summary\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Work Order\",\n\t\"label\": \"Work Order Summary\"\n}, {\n\t\"dependencies\": [\"Quality Inspection\"],\n\t\"name\": \"Quality Inspection Summary\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Quality Inspection\",\n\t\"label\": \"Quality Inspection Summary\"\n}, {\n\t\"dependencies\": [\"Downtime Entry\"],\n\t\"name\": \"Downtime Analysis\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Downtime Entry\",\n\t\"label\": \"Downtime Analysis\"\n}, {\n\t\"dependencies\": [\"Job Card\"],\n\t\"name\": \"Job Card Summary\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Job Card\",\n\t\"label\": \"Job Card Summary\"\n}, {\n\t\"dependencies\": [\"BOM\"],\n\t\"name\": \"BOM Search\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"BOM\",\n\t\"label\": \"BOM Search\"\n}, {\n\t\"dependencies\": [\"BOM\"],\n\t\"name\": \"BOM Stock Report\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"BOM\",\n\t\"label\": \"BOM Stock Report\"\n}, {\n\t\"dependencies\": [\"Work Order\"],\n\t\"name\": \"Production Analytics\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"Work Order\",\n\t\"label\": \"Production Analytics\"\n}, {\n\t\"dependencies\": [\"BOM\"],\n\t\"name\": \"BOM Operations Time\",\n\t\"is_query_report\": true,\n\t\"type\": \"report\",\n\t\"doctype\": \"BOM\",\n\t\"label\": \"BOM Operations Time\"\n}]"
},
{
"hidden": 0,
@@ -32,23 +32,93 @@
}
],
"category": "Domains",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Produced Quantity"
+ }
+ ],
"creation": "2020-03-02 17:11:37.032604",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Manufacturing",
- "modified": "2020-04-01 11:28:50.979358",
+ "modified": "2020-05-28 13:54:02.048419",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Manufacturing",
+ "onboarding": "Manufacturing",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"restrict_to_domain": "Manufacturing",
- "shortcuts": []
+ "shortcuts": [
+ {
+ "color": "#cef6d1",
+ "format": "{} Active",
+ "label": "Item",
+ "link_to": "Item",
+ "restrict_to_domain": "Manufacturing",
+ "stats_filter": "{\n \"disabled\": 0\n}",
+ "type": "DocType"
+ },
+ {
+ "color": "#cef6d1",
+ "format": "{} Active",
+ "label": "BOM",
+ "link_to": "BOM",
+ "restrict_to_domain": "Manufacturing",
+ "stats_filter": "{\n \"is_active\": 1\n}",
+ "type": "DocType"
+ },
+ {
+ "color": "#ffe8cd",
+ "format": "{} Open",
+ "label": "Work Order",
+ "link_to": "Work Order",
+ "restrict_to_domain": "Manufacturing",
+ "stats_filter": "{ \n \"status\": [\"in\", \n [\"Draft\", \"Not Started\", \"In Process\"]\n ]\n}",
+ "type": "DocType"
+ },
+ {
+ "color": "#ffe8cd",
+ "format": "{} Open",
+ "label": "Production Plan",
+ "link_to": "Production Plan",
+ "restrict_to_domain": "Manufacturing",
+ "stats_filter": "{ \n \"status\": [\"not in\", [\"Completed\"]]\n}",
+ "type": "DocType"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "Manufacturing",
+ "restrict_to_domain": "Manufacturing",
+ "type": "Dashboard"
+ },
+ {
+ "label": "Forecasting",
+ "link_to": "Exponential Smoothing Forecasting",
+ "type": "Report"
+ },
+ {
+ "label": "Work Order Summary",
+ "link_to": "Work Order Summary",
+ "restrict_to_domain": "Manufacturing",
+ "type": "Report"
+ },
+ {
+ "label": "BOM Stock Report",
+ "link_to": "BOM Stock Report",
+ "type": "Report"
+ },
+ {
+ "label": "Production Planning Report",
+ "link_to": "Production Planning Report",
+ "type": "Report"
+ }
+ ]
}
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index ebfb7626407..47b42072412 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -29,10 +29,7 @@ frappe.ui.form.on("BOM", {
frm.set_query("item", function() {
return {
- query: "erpnext.controllers.queries.item_query",
- filters: {
- "doctype": "BOM"
- }
+ query: "erpnext.manufacturing.doctype.bom.bom.item_query"
};
});
@@ -44,9 +41,12 @@ frappe.ui.form.on("BOM", {
};
});
- frm.set_query("item_code", "items", function() {
+ frm.set_query("item_code", "items", function(doc) {
return {
- query: "erpnext.controllers.queries.item_query"
+ query: "erpnext.manufacturing.doctype.bom.bom.item_query",
+ filters: {
+ "item_code": doc.item
+ }
};
});
@@ -96,6 +96,12 @@ frappe.ui.form.on("BOM", {
frm.trigger("make_work_order");
}, __("Create"));
+ if (frm.doc.has_variants) {
+ frm.add_custom_button(__("Variant BOM"), function() {
+ frm.trigger("make_variant_bom");
+ }, __("Create"));
+ }
+
if (frm.doc.inspection_required) {
frm.add_custom_button(__("Quality Inspection"), function() {
frm.trigger("make_quality_inspection");
@@ -124,7 +130,7 @@ frappe.ui.form.on("BOM", {
}
- if (frm.doc.__onload && frm.doc.__onload["has_variants"]) {
+ if (frm.doc.has_variants) {
frm.set_intro(__('This is a Template BOM and will be used to make the work order for {0} of the item {1}',
[
`variants `,
@@ -138,9 +144,52 @@ frappe.ui.form.on("BOM", {
},
make_work_order: function(frm) {
+ frm.events.setup_variant_prompt(frm, "Work Order", (frm, item, data, variant_items) => {
+ frappe.call({
+ method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
+ args: {
+ bom_no: frm.doc.name,
+ item: item,
+ qty: data.qty || 0.0,
+ project: frm.doc.project,
+ variant_items: variant_items
+ },
+ freeze: true,
+ callback: function(r) {
+ if(r.message) {
+ let doc = frappe.model.sync(r.message)[0];
+ frappe.set_route("Form", doc.doctype, doc.name);
+ }
+ }
+ });
+ });
+ },
+
+ make_variant_bom: function(frm) {
+ frm.events.setup_variant_prompt(frm, "Variant BOM", (frm, item, data, variant_items) => {
+ frappe.call({
+ method: "erpnext.manufacturing.doctype.bom.bom.make_variant_bom",
+ args: {
+ source_name: frm.doc.name,
+ bom_no: frm.doc.name,
+ item: item,
+ variant_items: variant_items
+ },
+ freeze: true,
+ callback: function(r) {
+ if(r.message) {
+ let doc = frappe.model.sync(r.message)[0];
+ frappe.set_route("Form", doc.doctype, doc.name);
+ }
+ }
+ });
+ }, true);
+ },
+
+ setup_variant_prompt: function(frm, title, callback, skip_qty_field) {
const fields = [];
- if (frm.doc.__onload && frm.doc.__onload["has_variants"]) {
+ if (frm.doc.has_variants) {
fields.push({
fieldtype: 'Link',
label: __('Variant Item'),
@@ -158,34 +207,106 @@ frappe.ui.form.on("BOM", {
});
}
- fields.push({
- fieldtype: 'Float',
- label: __('Qty To Manufacture'),
- fieldname: 'qty',
- reqd: 1,
- default: 1
+ if (!skip_qty_field) {
+ fields.push({
+ fieldtype: 'Float',
+ label: __('Qty To Manufacture'),
+ fieldname: 'qty',
+ reqd: 1,
+ default: 1
+ });
+ }
+
+ var has_template_rm = frm.doc.items.filter(d => d.has_variants === 1) || [];
+ if (has_template_rm && has_template_rm.length > 0) {
+ fields.push({
+ fieldname: "items",
+ fieldtype: "Table",
+ label: __("Raw Materials"),
+ fields: [
+ {
+ fieldname: "item_code",
+ options: "Item",
+ label: __("Template Item"),
+ fieldtype: "Link",
+ in_list_view: 1,
+ reqd: 1,
+ },
+ {
+ fieldname: "varint_item_code",
+ options: "Item",
+ label: __("Variant Item"),
+ fieldtype: "Link",
+ in_list_view: 1,
+ reqd: 1,
+ get_query: function(data) {
+ if (!data.item_code) {
+ frappe.throw(__("Select template item"));
+ }
+
+ return {
+ query: "erpnext.controllers.queries.item_query",
+ filters: {
+ "variant_of": data.item_code
+ }
+ };
+ }
+ },
+ {
+ fieldname: "qty",
+ label: __("Quantity"),
+ fieldtype: "Float",
+ in_list_view: 1,
+ reqd: 1,
+ },
+ {
+ fieldname: "source_warehouse",
+ label: __("Source Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse"
+ },
+ {
+ fieldname: "operation",
+ label: __("Operation"),
+ fieldtype: "Data",
+ hidden: 1,
+ }
+ ],
+ in_place_edit: true,
+ data: [],
+ get_data: function () {
+ return [];
+ },
+ });
+ }
+
+ let dialog = frappe.prompt(fields, data => {
+ let item = data.item || frm.doc.item;
+ let variant_items = data.items || [];
+
+ variant_items.forEach(d => {
+ if (!d.varint_item_code) {
+ frappe.throw(__("Select variant item code for the template item {0}", [d.item_code]));
+ }
+ })
+
+ callback(frm, item, data, variant_items);
+
+ }, __(title), __("Create"));
+
+ has_template_rm.forEach(d => {
+ dialog.fields_dict.items.df.data.push({
+ "item_code": d.item_code,
+ "varint_item_code": "",
+ "qty": d.qty,
+ "source_warehouse": d.source_warehouse,
+ "operation": d.operation
+ });
});
- frappe.prompt(fields, data => {
- let item = data.item || frm.doc.item;
-
- frappe.call({
- method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
- args: {
- bom_no: frm.doc.name,
- item: item,
- qty: data.qty || 0.0,
- project: frm.doc.project
- },
- freeze: true,
- callback: function(r) {
- if(r.message) {
- var doc = frappe.model.sync(r.message)[0];
- frappe.set_route("Form", doc.doctype, doc.name);
- }
- }
- });
- }, __("Enter Value"), __("Create"));
+ if (has_template_rm) {
+ dialog.fields_dict.items.grid.refresh();
+ }
},
make_quality_inspection: function(frm) {
@@ -212,6 +333,12 @@ frappe.ui.form.on("BOM", {
});
},
+ rm_cost_as_per: function(frm) {
+ if (in_list(["Valuation Rate", "Last Purchase Rate"], frm.doc.rm_cost_as_per)) {
+ frm.set_value("plc_conversion_rate", 1.0);
+ }
+ },
+
routing: function(frm) {
if (frm.doc.routing) {
frappe.call({
@@ -242,7 +369,7 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({
item_code: function(doc, cdt, cdn){
var scrap_items = false;
var child = locals[cdt][cdn];
- if(child.doctype == 'BOM Scrap Item') {
+ if (child.doctype == 'BOM Scrap Item') {
scrap_items = true;
}
@@ -252,8 +379,19 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({
get_bom_material_detail(doc, cdt, cdn, scrap_items);
},
+
+ buying_price_list: function(doc) {
+ this.apply_price_list();
+ },
+
+ plc_conversion_rate: function(doc) {
+ if (!this.in_apply_price_list) {
+ this.apply_price_list(null, true);
+ }
+ },
+
conversion_factor: function(doc, cdt, cdn) {
- if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
+ if (frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "conversion_factor"]);
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index 63f4f977c59..f551b91597f 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_import": 1,
"creation": "2013-01-22 15:11:38",
"doctype": "DocType",
@@ -6,23 +7,25 @@
"engine": "InnoDB",
"field_order": [
"item",
- "quantity",
- "set_rate_of_sub_assembly_item_based_on_bom",
+ "company",
+ "item_name",
+ "uom",
"cb0",
"is_active",
"is_default",
"allow_alternative_item",
- "image",
- "item_name",
- "uom",
- "currency_detail",
- "company",
+ "set_rate_of_sub_assembly_item_based_on_bom",
"project",
+ "quantity",
+ "image",
+ "currency_detail",
+ "currency",
"conversion_rate",
"column_break_12",
- "currency",
"rm_cost_as_per",
"buying_price_list",
+ "price_list_currency",
+ "plc_conversion_rate",
"section_break_21",
"with_operations",
"column_break_23",
@@ -50,6 +53,7 @@
"section_break_25",
"description",
"column_break_27",
+ "has_variants",
"section_break0",
"exploded_items",
"website_section",
@@ -176,7 +180,8 @@
},
{
"fieldname": "currency_detail",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Currency and Price List"
},
{
"fieldname": "company",
@@ -324,7 +329,7 @@
},
{
"fieldname": "base_scrap_material_cost",
- "fieldtype": "Data",
+ "fieldtype": "Currency",
"label": "Scrap Material Cost(Company Currency)",
"no_copy": 1,
"options": "Company:company:default_currency",
@@ -477,13 +482,42 @@
{
"fieldname": "column_break_52",
"fieldtype": "Column Break"
+ },
+ {
+ "allow_on_submit": 1,
+ "depends_on": "eval:doc.rm_cost_as_per=='Price List'",
+ "fieldname": "plc_conversion_rate",
+ "fieldtype": "Float",
+ "label": "Price List Exchange Rate"
+ },
+ {
+ "allow_on_submit": 1,
+ "depends_on": "eval:doc.rm_cost_as_per=='Price List'",
+ "fieldname": "price_list_currency",
+ "fieldtype": "Link",
+ "label": "Price List Currency",
+ "options": "Currency",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "default": "0",
+ "fetch_from": "item.has_variants",
+ "fieldname": "has_variants",
+ "fieldtype": "Check",
+ "in_list_view": 1,
+ "label": "Has Variants",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
}
],
"icon": "fa fa-sitemap",
"idx": 1,
"image_field": "image",
"is_submittable": 1,
- "modified": "2019-11-22 14:35:12.142150",
+ "links": [],
+ "modified": "2020-05-21 12:29:32.634952",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM",
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index b1fc4deae91..2543eec53e4 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -3,13 +3,16 @@
from __future__ import unicode_literals
import frappe, erpnext
-from frappe.utils import cint, cstr, flt
+from frappe.utils import cint, cstr, flt, today
from frappe import _
from erpnext.setup.utils import get_exchange_rate
from frappe.website.website_generator import WebsiteGenerator
from erpnext.stock.get_item_details import get_conversion_factor
from erpnext.stock.get_item_details import get_price_list_rate
from frappe.core.doctype.version.version import get_diff
+from erpnext.controllers.queries import get_match_cond
+from erpnext.stock.doctype.item.item import get_item_details
+from frappe.model.mapper import get_mapped_doc
import functools
@@ -59,22 +62,19 @@ class BOM(WebsiteGenerator):
self.name = name
- def onload(self):
- super(BOM, self).onload()
- if self.get("item") and cint(frappe.db.get_value("Item", self.item, "has_variants")):
- self.set_onload("has_variants", True)
-
def validate(self):
self.route = frappe.scrub(self.name).replace('_', '-')
self.clear_operations()
self.validate_main_item()
self.validate_currency()
self.set_conversion_rate()
+ self.set_plc_conversion_rate()
self.validate_uom_is_interger()
self.set_bom_material_details()
self.validate_materials()
self.validate_operations()
self.calculate_cost()
+ self.update_cost(update_parent=False, from_child_bom=True, save=False)
def get_context(self, context):
context.parents = [{'name': 'boms', 'title': _('All BOMs') }]
@@ -101,9 +101,7 @@ class BOM(WebsiteGenerator):
self.manage_default_bom()
def get_item_det(self, item_code):
- item = frappe.db.sql("""select name, item_name, docstatus, description, image,
- is_sub_contracted_item, stock_uom, default_bom, last_purchase_rate, include_item_in_manufacturing
- from `tabItem` where name=%s""", item_code, as_dict = 1)
+ item = get_item_details(item_code)
if not item:
frappe.throw(_("Item: {0} does not exist in the system").format(item_code))
@@ -114,8 +112,15 @@ class BOM(WebsiteGenerator):
if self.routing:
self.set("operations", [])
for d in frappe.get_all("BOM Operation", fields = ["*"],
- filters = {'parenttype': 'Routing', 'parent': self.routing}):
- child = self.append('operations', d)
+ filters = {'parenttype': 'Routing', 'parent': self.routing}, order_by="idx"):
+ child = self.append('operations', {
+ "operation": d.operation,
+ "workstation": d.workstation,
+ "description": d.description,
+ "time_in_mins": d.time_in_mins,
+ "batch_size": d.batch_size,
+ "idx": d.idx
+ })
child.hour_rate = flt(d.hour_rate / self.conversion_rate, 2)
def set_bom_material_details(self):
@@ -148,10 +153,10 @@ class BOM(WebsiteGenerator):
item = self.get_item_det(args['item_code'])
- args['bom_no'] = args['bom_no'] or item and cstr(item[0]['default_bom']) or ''
+ args['bom_no'] = args['bom_no'] or item and cstr(item['default_bom']) or ''
args['transfer_for_manufacture'] = (cstr(args.get('include_item_in_manufacturing', '')) or
- item and item[0].include_item_in_manufacturing or 0)
- args.update(item[0])
+ item and item.include_item_in_manufacturing or 0)
+ args.update(item)
rate = self.get_rm_rate(args)
ret_item = {
@@ -165,7 +170,7 @@ class BOM(WebsiteGenerator):
'rate' : rate,
'qty' : args.get("qty") or args.get("stock_qty") or 1,
'stock_qty' : args.get("qty") or args.get("stock_qty") or 1,
- 'base_rate' : rate,
+ 'base_rate' : flt(rate) * (flt(self.conversion_rate) or 1),
'include_item_in_manufacturing': cint(args['transfer_for_manufacture']) or 0
}
@@ -183,40 +188,14 @@ class BOM(WebsiteGenerator):
self.rm_cost_as_per = "Valuation Rate"
if arg.get('scrap_items'):
- rate = self.get_valuation_rate(arg)
+ rate = get_valuation_rate(arg)
elif arg:
#Customer Provided parts will have zero rate
if not frappe.db.get_value('Item', arg["item_code"], 'is_customer_provided_item'):
if arg.get('bom_no') and self.set_rate_of_sub_assembly_item_based_on_bom:
rate = flt(self.get_bom_unitcost(arg['bom_no'])) * (arg.get("conversion_factor") or 1)
else:
- if self.rm_cost_as_per == 'Valuation Rate':
- rate = self.get_valuation_rate(arg) * (arg.get("conversion_factor") or 1)
- elif self.rm_cost_as_per == 'Last Purchase Rate':
- rate = flt(arg.get('last_purchase_rate') \
- or frappe.db.get_value("Item", arg['item_code'], "last_purchase_rate")) \
- * (arg.get("conversion_factor") or 1)
- elif self.rm_cost_as_per == "Price List":
- if not self.buying_price_list:
- frappe.throw(_("Please select Price List"))
- args = frappe._dict({
- "doctype": "BOM",
- "price_list": self.buying_price_list,
- "qty": arg.get("qty") or 1,
- "uom": arg.get("uom") or arg.get("stock_uom"),
- "stock_uom": arg.get("stock_uom"),
- "transaction_type": "buying",
- "company": self.company,
- "currency": self.currency,
- "conversion_rate": 1, # Passed conversion rate as 1 purposefully, as conversion rate is applied at the end of the function
- "conversion_factor": arg.get("conversion_factor") or 1,
- "plc_conversion_rate": 1,
- "ignore_party": True
- })
- item_doc = frappe.get_doc("Item", arg.get("item_code"))
- out = frappe._dict()
- get_price_list_rate(args, item_doc, out)
- rate = out.price_list_rate
+ rate = get_bom_item_rate(arg, self)
if not rate:
if self.rm_cost_as_per == "Price List":
@@ -226,7 +205,7 @@ class BOM(WebsiteGenerator):
frappe.msgprint(_("{0} not found for item {1}")
.format(self.rm_cost_as_per, arg["item_code"]), alert=True)
- return flt(rate) / (self.conversion_rate or 1)
+ return flt(rate) * flt(self.plc_conversion_rate or 1) / (self.conversion_rate or 1)
def update_cost(self, update_parent=True, from_child_bom=False, save=True):
if self.docstatus == 2:
@@ -243,10 +222,15 @@ class BOM(WebsiteGenerator):
"stock_uom": d.stock_uom,
"conversion_factor": d.conversion_factor
})
+
if rate:
d.rate = rate
d.amount = flt(d.rate) * flt(d.qty)
- d.db_update()
+ d.base_rate = flt(d.rate) * flt(self.conversion_rate)
+ d.base_amount = flt(d.amount) * flt(self.conversion_rate)
+
+ if save:
+ d.db_update()
if self.docstatus == 1:
self.flags.ignore_validate_update_after_submit = True
@@ -279,31 +263,6 @@ class BOM(WebsiteGenerator):
where is_active = 1 and name = %s""", bom_no, as_dict=1)
return bom and bom[0]['unit_cost'] or 0
- def get_valuation_rate(self, args):
- """ Get weighted average of valuation rate from all warehouses """
-
- total_qty, total_value, valuation_rate = 0.0, 0.0, 0.0
- for d in frappe.db.sql("""select actual_qty, stock_value from `tabBin`
- where item_code=%s""", args['item_code'], as_dict=1):
- total_qty += flt(d.actual_qty)
- total_value += flt(d.stock_value)
-
- if total_qty:
- valuation_rate = total_value / total_qty
-
- if valuation_rate <= 0:
- last_valuation_rate = frappe.db.sql("""select valuation_rate
- from `tabStock Ledger Entry`
- where item_code = %s and valuation_rate > 0
- order by posting_date desc, posting_time desc, creation desc limit 1""", args['item_code'])
-
- valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0
-
- if not valuation_rate:
- valuation_rate = frappe.db.get_value("Item", args['item_code'], "valuation_rate")
-
- return flt(valuation_rate)
-
def manage_default_bom(self):
""" Uncheck others if current one is selected as default or
check the current one as default if it the only bom for the selected item,
@@ -372,6 +331,13 @@ class BOM(WebsiteGenerator):
elif self.conversion_rate == 1 or flt(self.conversion_rate) <= 0:
self.conversion_rate = get_exchange_rate(self.currency, self.company_currency(), args="for_buying")
+ def set_plc_conversion_rate(self):
+ if self.rm_cost_as_per in ["Valuation Rate", "Last Purchase Rate"]:
+ self.plc_conversion_rate = 1
+ elif not self.plc_conversion_rate and self.price_list_currency:
+ self.plc_conversion_rate = get_exchange_rate(self.price_list_currency,
+ self.company_currency(), args="for_buying")
+
def validate_materials(self):
""" Validate raw material entries """
@@ -610,6 +576,62 @@ class BOM(WebsiteGenerator):
if not d.batch_size or d.batch_size <= 0:
d.batch_size = 1
+def get_bom_item_rate(args, bom_doc):
+ if bom_doc.rm_cost_as_per == 'Valuation Rate':
+ rate = get_valuation_rate(args) * (args.get("conversion_factor") or 1)
+ elif bom_doc.rm_cost_as_per == 'Last Purchase Rate':
+ rate = ( flt(args.get('last_purchase_rate')) \
+ or frappe.db.get_value("Item", args['item_code'], "last_purchase_rate")) \
+ * (args.get("conversion_factor") or 1)
+ elif bom_doc.rm_cost_as_per == "Price List":
+ if not bom_doc.buying_price_list:
+ frappe.throw(_("Please select Price List"))
+ bom_args = frappe._dict({
+ "doctype": "BOM",
+ "price_list": bom_doc.buying_price_list,
+ "qty": args.get("qty") or 1,
+ "uom": args.get("uom") or args.get("stock_uom"),
+ "stock_uom": args.get("stock_uom"),
+ "transaction_type": "buying",
+ "company": bom_doc.company,
+ "currency": bom_doc.currency,
+ "conversion_rate": 1, # Passed conversion rate as 1 purposefully, as conversion rate is applied at the end of the function
+ "conversion_factor": args.get("conversion_factor") or 1,
+ "plc_conversion_rate": 1,
+ "ignore_party": True
+ })
+ item_doc = frappe.get_cached_doc("Item", args.get("item_code"))
+ out = frappe._dict()
+ get_price_list_rate(bom_args, item_doc, out)
+ rate = out.price_list_rate
+
+ return rate
+
+def get_valuation_rate(args):
+ """ Get weighted average of valuation rate from all warehouses """
+
+ total_qty, total_value, valuation_rate = 0.0, 0.0, 0.0
+ for d in frappe.db.sql("""select actual_qty, stock_value from `tabBin`
+ where item_code=%s""", args['item_code'], as_dict=1):
+ total_qty += flt(d.actual_qty)
+ total_value += flt(d.stock_value)
+
+ if total_qty:
+ valuation_rate = total_value / total_qty
+
+ if valuation_rate <= 0:
+ last_valuation_rate = frappe.db.sql("""select valuation_rate
+ from `tabStock Ledger Entry`
+ where item_code = %s and valuation_rate > 0
+ order by posting_date desc, posting_time desc, creation desc limit 1""", args['item_code'])
+
+ valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0
+
+ if not valuation_rate:
+ valuation_rate = frappe.db.get_value("Item", args['item_code'], "valuation_rate")
+
+ return flt(valuation_rate)
+
def get_list_context(context):
context.title = _("Bill of Materials")
# context.introduction = _('Boms')
@@ -625,6 +647,8 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
sum(bom_item.{qty_field}/ifnull(bom.quantity, 1)) * %(qty)s as qty,
item.image,
bom.project,
+ bom_item.rate,
+ bom_item.amount,
item.stock_uom,
item.item_group,
item.allow_alternative_item,
@@ -641,6 +665,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
where
bom_item.docstatus < 2
and bom.name = %(bom)s
+ and ifnull(item.has_variants, 0) = 0
and item.is_stock_item in (1, {is_stock_item})
{where_conditions}
group by item_code, stock_uom
@@ -883,3 +908,84 @@ def get_bom_diff(bom1, bom2):
out.removed.append([df.fieldname, d.as_dict()])
return out
+
+def item_query(doctype, txt, searchfield, start, page_len, filters):
+ meta = frappe.get_meta("Item", cached=True)
+ searchfields = meta.get_search_fields()
+
+ order_by = "idx desc, name, item_name"
+
+ fields = ["name", "item_group", "item_name", "description"]
+ fields.extend([field for field in searchfields
+ if not field in ["name", "item_group", "description"]])
+
+ searchfields = searchfields + [field for field in [searchfield or "name", "item_code", "item_group", "item_name"]
+ if not field in searchfields]
+
+ query_filters = {
+ "disabled": 0,
+ "ifnull(end_of_life, '5050-50-50')": (">", today())
+ }
+
+ or_cond_filters = {}
+ if txt:
+ for s_field in searchfields:
+ or_cond_filters[s_field] = ("like", "%{0}%".format(txt))
+
+ barcodes = frappe.get_all("Item Barcode",
+ fields=["distinct parent as item_code"],
+ filters = {"barcode": ("like", "%{0}%".format(txt))})
+
+ barcodes = [d.item_code for d in barcodes]
+ if barcodes:
+ or_cond_filters["name"] = ("in", barcodes)
+
+ for cond in get_match_cond(doctype, as_condition=False):
+ for key, value in cond.items():
+ if key == doctype:
+ key = "name"
+
+ query_filters[key] = ("in", value)
+
+ if filters and filters.get("item_code"):
+ has_variants = frappe.get_cached_value("Item", filters.get("item_code"), "has_variants")
+ if not has_variants:
+ query_filters["has_variants"] = 0
+
+ return frappe.get_all("Item",
+ fields = fields, filters=query_filters,
+ or_filters = or_cond_filters, order_by=order_by,
+ limit_start=start, limit_page_length=page_len, as_list=1)
+
+@frappe.whitelist()
+def make_variant_bom(source_name, bom_no, item, variant_items, target_doc=None):
+ from erpnext.manufacturing.doctype.work_order.work_order import add_variant_item
+
+ def postprocess(source, doc):
+ doc.item = item
+ doc.quantity = 1
+
+ item_data = get_item_details(item)
+ doc.update({
+ "item_name": item_data.item_name,
+ "description": item_data.description,
+ "uom": item_data.stock_uom,
+ "allow_alternative_item": item_data.allow_alternative_item
+ })
+
+ add_variant_item(variant_items, doc, source_name)
+
+ doc = get_mapped_doc('BOM', source_name, {
+ 'BOM': {
+ 'doctype': 'BOM',
+ 'validation': {
+ 'docstatus': ['=', 1]
+ }
+ },
+ 'BOM Item': {
+ 'doctype': 'BOM Item',
+ 'condition': lambda doc: doc.has_variants == 0
+ },
+ }, target_doc, postprocess)
+
+ return doc
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom_list.js b/erpnext/manufacturing/doctype/bom/bom_list.js
index 2b06ed72eda..94cb466bd8a 100644
--- a/erpnext/manufacturing/doctype/bom/bom_list.js
+++ b/erpnext/manufacturing/doctype/bom/bom_list.js
@@ -1,7 +1,9 @@
frappe.listview_settings['BOM'] = {
- add_fields: ["is_active", "is_default", "total_cost"],
+ add_fields: ["is_active", "is_default", "total_cost", "has_variants"],
get_indicator: function(doc) {
- if(doc.is_default) {
+ if(doc.is_active && doc.has_variants) {
+ return [__("Template"), "orange", "has_variants,=,Yes"];
+ } else if(doc.is_default) {
return [__("Default"), "green", "is_default,=,Yes"];
} else if(doc.is_active) {
return [__("Active"), "blue", "is_active,=,Yes"];
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index 45a7b935d38..3dfd03b1395 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -81,13 +81,13 @@ class TestBOM(unittest.TestCase):
# test amounts in selected currency
self.assertEqual(bom.operating_cost, 100)
- self.assertEqual(bom.raw_material_cost, 8000)
- self.assertEqual(bom.total_cost, 8100)
+ self.assertEqual(bom.raw_material_cost, 351.68)
+ self.assertEqual(bom.total_cost, 451.68)
# test amounts in selected currency
self.assertEqual(bom.base_operating_cost, 6000)
- self.assertEqual(bom.base_raw_material_cost, 480000)
- self.assertEqual(bom.base_total_cost, 486000)
+ self.assertEqual(bom.base_raw_material_cost, 21100.80)
+ self.assertEqual(bom.base_total_cost, 27100.80)
def test_bom_cost_multi_uom_multi_currency_based_on_price_list(self):
frappe.db.set_value("Price List", "_Test Price List", "price_not_uom_dependent", 1)
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json
index f094be4c647..e34be61bc75 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.json
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json
@@ -1,8 +1,10 @@
{
+ "actions": [],
"creation": "2013-02-22 01:27:49",
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 1,
+ "engine": "InnoDB",
"field_order": [
"item_code",
"item_name",
@@ -33,6 +35,7 @@
"scrap",
"qty_consumed_per_unit",
"section_break_27",
+ "has_variants",
"include_item_in_manufacturing",
"original_item"
],
@@ -57,6 +60,7 @@
"label": "Item Name"
},
{
+ "depends_on": "eval:parent.with_operations == 1",
"fieldname": "operation",
"fieldtype": "Link",
"label": "Item operation",
@@ -258,11 +262,22 @@
"label": "Original Item",
"options": "Item",
"read_only": 1
+ },
+ {
+ "default": "0",
+ "fetch_from": "item_code.has_variants",
+ "fieldname": "has_variants",
+ "fieldtype": "Check",
+ "label": "Has Variants",
+ "no_copy": 1,
+ "print_hide": 1,
+ "read_only": 1
}
],
"idx": 1,
"istable": 1,
- "modified": "2019-11-22 11:38:52.087303",
+ "links": [],
+ "modified": "2020-04-09 14:30:26.535546",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Item",
diff --git a/erpnext/manufacturing/doctype/downtime_entry/__init__.py b/erpnext/manufacturing/doctype/downtime_entry/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.js b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.js
new file mode 100644
index 00000000000..3b7f5ba8d7f
--- /dev/null
+++ b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Downtime Entry', {
+ // refresh: function(frm) {
+
+ // }
+});
diff --git a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
new file mode 100644
index 00000000000..b301a9ec054
--- /dev/null
+++ b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.json
@@ -0,0 +1,141 @@
+{
+ "actions": [],
+ "allow_import": 1,
+ "autoname": "naming_series:",
+ "creation": "2020-04-18 04:50:46.187638",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "naming_series",
+ "workstation",
+ "operator",
+ "column_break_4",
+ "from_time",
+ "to_time",
+ "downtime",
+ "downtime_reason_section",
+ "stop_reason",
+ "column_break_9",
+ "remarks"
+ ],
+ "fields": [
+ {
+ "fieldname": "workstation",
+ "fieldtype": "Link",
+ "label": "Workstation / Machine",
+ "options": "Workstation",
+ "reqd": 1
+ },
+ {
+ "fieldname": "from_time",
+ "fieldtype": "Datetime",
+ "in_list_view": 1,
+ "label": "From Time",
+ "reqd": 1
+ },
+ {
+ "fieldname": "to_time",
+ "fieldtype": "Datetime",
+ "in_list_view": 1,
+ "label": "To Time",
+ "reqd": 1
+ },
+ {
+ "fieldname": "column_break_4",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "operator",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Operator",
+ "options": "Employee",
+ "reqd": 1
+ },
+ {
+ "fieldname": "downtime_reason_section",
+ "fieldtype": "Section Break",
+ "label": "Downtime Reason"
+ },
+ {
+ "description": "In Mins",
+ "fieldname": "downtime",
+ "fieldtype": "Float",
+ "label": "Downtime",
+ "read_only": 1
+ },
+ {
+ "fieldname": "stop_reason",
+ "fieldtype": "Select",
+ "label": "Stop Reason",
+ "options": "\nExcessive machine set up time\nUnplanned machine maintenance\nOn-machine press checks\nMachine operator errors\nMachine malfunction\nElectricity down\nOther",
+ "reqd": 1
+ },
+ {
+ "fieldname": "column_break_9",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "remarks",
+ "fieldtype": "Text",
+ "label": "Remarks"
+ },
+ {
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Naming Series",
+ "options": "DT-",
+ "reqd": 1
+ }
+ ],
+ "links": [],
+ "modified": "2020-05-26 22:14:54.479831",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Downtime Entry",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "share": 1,
+ "write": 1
+ },
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Manufacturing User",
+ "share": 1,
+ "write": 1
+ },
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Manufacturing Manager",
+ "share": 1,
+ "write": 1
+ }
+ ],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "workstation",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.py b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.py
new file mode 100644
index 00000000000..56ec4356af4
--- /dev/null
+++ b/erpnext/manufacturing/doctype/downtime_entry/downtime_entry.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import time_diff_in_hours
+from frappe.model.document import Document
+
+class DowntimeEntry(Document):
+ def validate(self):
+ if self.from_time and self.to_time:
+ self.downtime = time_diff_in_hours(self.to_time, self.from_time) * 60
diff --git a/erpnext/manufacturing/doctype/downtime_entry/test_downtime_entry.py b/erpnext/manufacturing/doctype/downtime_entry/test_downtime_entry.py
new file mode 100644
index 00000000000..8b2a8d36c12
--- /dev/null
+++ b/erpnext/manufacturing/doctype/downtime_entry/test_downtime_entry.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+# import frappe
+import unittest
+
+class TestDowntimeEntry(unittest.TestCase):
+ pass
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json
index 7661fffa864..fba670c1c15 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.json
+++ b/erpnext/manufacturing/doctype/job_card/job_card.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"autoname": "naming_series:",
"creation": "2018-07-09 17:23:29.518745",
"doctype": "DocType",
@@ -264,8 +265,10 @@
{
"fetch_from": "work_order.production_item",
"fieldname": "production_item",
- "fieldtype": "Read Only",
- "label": "Production Item"
+ "fieldtype": "Link",
+ "label": "Production Item",
+ "options": "Item",
+ "read_only": 1
},
{
"fieldname": "barcode",
@@ -274,7 +277,8 @@
"read_only": 1
},
{
- "fetch_from": "work_order.item_name",
+ "fetch_from": "production_item.item_name",
+ "fetch_if_empty": 1,
"fieldname": "item_name",
"fieldtype": "Read Only",
"label": "Item Name"
@@ -290,7 +294,8 @@
}
],
"is_submittable": 1,
- "modified": "2020-03-27 13:36:35.417502",
+ "links": [],
+ "modified": "2020-04-20 15:14:00.273441",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Job Card",
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index e9627a55145..c29d4ba3d5c 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -102,8 +102,11 @@ class JobCard(Document):
workstation_doc = frappe.get_cached_doc("Workstation", self.workstation)
if (not workstation_doc.working_hours or
cint(frappe.db.get_single_value("Manufacturing Settings", "allow_overtime"))):
- row.remaining_time_in_mins -= time_diff_in_minutes(row.planned_end_time,
- row.planned_start_time)
+ if get_datetime(row.planned_end_time) < get_datetime(row.planned_start_time):
+ row.planned_end_time = add_to_date(row.planned_start_time, minutes=row.time_in_mins)
+ row.remaining_time_in_mins = 0.0
+ else:
+ row.remaining_time_in_mins -= time_diff_in_minutes(row.planned_end_time, row.planned_start_time)
self.update_time_logs(row)
return
@@ -206,30 +209,31 @@ class JobCard(Document):
for_quantity, time_in_mins = 0, 0
from_time_list, to_time_list = [], []
-
+ field = "operation_id" if self.operation_id else "operation"
data = frappe.get_all('Job Card',
fields = ["sum(total_time_in_mins) as time_in_mins", "sum(total_completed_qty) as completed_qty"],
filters = {"docstatus": 1, "work_order": self.work_order,
- "workstation": self.workstation, "operation": self.operation})
+ "workstation": self.workstation, field: self.get(field)})
if data and len(data) > 0:
for_quantity = data[0].completed_qty
time_in_mins = data[0].time_in_mins
- if for_quantity:
+ if self.get(field):
time_data = frappe.db.sql("""
SELECT
min(from_time) as start_time, max(to_time) as end_time
FROM `tabJob Card` jc, `tabJob Card Time Log` jctl
WHERE
jctl.parent = jc.name and jc.work_order = %s
- and jc.workstation = %s and jc.operation = %s and jc.docstatus = 1
- """, (self.work_order, self.workstation, self.operation), as_dict=1)
+ and jc.workstation = %s and jc.{0} = %s and jc.docstatus = 1
+ """.format(field), (self.work_order, self.workstation, self.get(field)), as_dict=1)
wo = frappe.get_doc('Work Order', self.work_order)
+ work_order_field = "name" if field == "operation_id" else field
for data in wo.operations:
- if data.workstation == self.workstation and data.operation == self.operation:
+ if data.get(work_order_field) == self.get(field) and data.workstation == self.workstation:
data.completed_qty = for_quantity
data.actual_operation_time = time_in_mins
data.actual_start_time = time_data[0].start_time if time_data else None
diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
index ac144e24b10..668e981d188 100644
--- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
+++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.js
@@ -3,3 +3,31 @@
frappe.ui.form.on('Manufacturing Settings', {
});
+
+frappe.tour["Manufacturing Settings"] = [
+ {
+ fieldname: "material_consumption",
+ title: __("Allow Multiple Material Consumption"),
+ description: __("If ticked, multiple materials can be used for a single Work Order. This is useful if one or more time consuming products are being manufactured.")
+ },
+ {
+ fieldname: "backflush_raw_materials_based_on",
+ title: __("Backflush Raw Materials"),
+ description: __("The Stock Entry of type 'Manufacture' is known as backflush. Raw materials being consumed to manufacture finished goods is known as backflushing. When creating Manufacture Entry, raw-material items are backflushed based on BOM of production item. If you want raw-material items to be backflushed based on Material Transfer entry made against that Work Order instead, then you can set it under this field.")
+ },
+ {
+ fieldname: "default_wip_warehouse",
+ title: __("Work In Progress Warehouse"),
+ description: __("This Warehouse will be auto-updated in the Work In Progress Warehouse field of Work Orders.")
+ },
+ {
+ fieldname: "default_fg_warehouse",
+ title: __("Finished Goods Warehouse"),
+ description: __("This Warehouse will be auto-updated in the Target Warehouse field of Work Order.")
+ },
+ {
+ fieldname: "update_bom_costs_automatically",
+ title: __("Update BOM Cost Automatically"),
+ description: __("If ticked, the BOM cost will be automatically updated based on Valuation Rate / Price List Rate / last purchase rate of raw materials.")
+ }
+];
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js
index 64c952b67be..1a64bc5e248 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.js
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js
@@ -201,9 +201,9 @@ frappe.ui.form.on('Production Plan', {
title: title,
fields: [
{
- "fieldtype": "Table MultiSelect", "label": __("Source Warehouses"),
+ "fieldtype": "Table MultiSelect", "label": __("Source Warehouses (Optional)"),
"fieldname": "warehouses", "options": "Production Plan Material Request Warehouse",
- "description": "System will pickup the materials from the selected warehouses",
+ "description": __("System will pickup the materials from the selected warehouses. If not specified, system will create material request for purchase."),
get_query: function () {
return {
filters: {
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index c1255719606..a244f582c42 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -449,6 +449,32 @@ frappe.ui.form.on("Work Order Item", {
}
});
}
+ },
+
+ item_code: function(frm, cdt, cdn) {
+ let row = locals[cdt][cdn];
+
+ if (row.item_code) {
+ frappe.call({
+ method: "erpnext.stock.doctype.item.item.get_item_details",
+ args: {
+ item_code: row.item_code,
+ company: frm.doc.company
+ },
+ callback: function(r) {
+ if (r.message) {
+ frappe.model.set_value(cdt, cdn, {
+ "required_qty": 1,
+ "item_name": r.message.item_name,
+ "description": r.message.description,
+ "source_warehouse": r.message.default_warehouse,
+ "allow_alternative_item": r.message.allow_alternative_item,
+ "include_item_in_manufacturing": r.message.include_item_in_manufacturing
+ });
+ }
+ }
+ });
+ }
}
});
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.json b/erpnext/manufacturing/doctype/work_order/work_order.json
index 00a67a03d67..585a09db2bf 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.json
+++ b/erpnext/manufacturing/doctype/work_order/work_order.json
@@ -38,11 +38,12 @@
"required_items",
"time",
"planned_start_date",
- "actual_start_date",
- "column_break_13",
"planned_end_date",
- "actual_end_date",
"expected_delivery_date",
+ "column_break_13",
+ "actual_start_date",
+ "actual_end_date",
+ "lead_time",
"operations_section",
"transfer_material_against",
"operations",
@@ -108,6 +109,8 @@
},
{
"depends_on": "eval:doc.production_item",
+ "fetch_from": "production_item.item_name",
+ "fetch_if_empty": 1,
"fieldname": "item_name",
"fieldtype": "Data",
"label": "Item Name",
@@ -281,27 +284,30 @@
"reqd": 1
},
{
+ "allow_on_submit": 1,
"fieldname": "actual_start_date",
"fieldtype": "Datetime",
"label": "Actual Start Date",
- "read_only": 1
+ "read_only_depends_on": "eval:doc.operations && doc.operations.length > 0"
},
{
"fieldname": "column_break_13",
"fieldtype": "Column Break"
},
{
+ "allow_on_submit": 1,
"fieldname": "planned_end_date",
"fieldtype": "Datetime",
"label": "Planned End Date",
"no_copy": 1,
- "read_only": 1
+ "read_only_depends_on": "eval:doc.operations && doc.operations.length > 0"
},
{
+ "allow_on_submit": 1,
"fieldname": "actual_end_date",
"fieldtype": "Datetime",
"label": "Actual End Date",
- "read_only": 1
+ "read_only_depends_on": "eval:doc.operations && doc.operations.length > 0"
},
{
"allow_on_submit": 1,
@@ -476,6 +482,13 @@
"fieldtype": "Link",
"label": "Source Warehouse",
"options": "Warehouse"
+ },
+ {
+ "description": "In Mins",
+ "fieldname": "lead_time",
+ "fieldtype": "Float",
+ "label": "Lead Time",
+ "read_only": 1
}
],
"icon": "fa fa-cogs",
@@ -483,7 +496,7 @@
"image_field": "image",
"is_submittable": 1,
"links": [],
- "modified": "2020-04-24 19:32:43.323054",
+ "modified": "2020-05-05 19:32:43.323054",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Work Order",
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 84bfab2f1d9..e2233a3e2f6 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -6,11 +6,11 @@ import frappe
import json
import math
from frappe import _
-from frappe.utils import flt, get_datetime, getdate, date_diff, cint, nowdate, get_link_to_form
+from frappe.utils import flt, get_datetime, getdate, date_diff, cint, nowdate, get_link_to_form, time_diff_in_hours
from frappe.model.document import Document
-from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, get_bom_items_as_dict
+from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, get_bom_items_as_dict, get_bom_item_rate
from dateutil.relativedelta import relativedelta
-from erpnext.stock.doctype.item.item import validate_end_of_life
+from erpnext.stock.doctype.item.item import validate_end_of_life, get_item_defaults
from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError
from erpnext.projects.doctype.timesheet.timesheet import OverlapError
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
@@ -279,7 +279,7 @@ class WorkOrder(Document):
if enable_capacity_planning and job_card_doc:
row.planned_start_time = job_card_doc.time_logs[-1].from_time
row.planned_end_time = job_card_doc.time_logs[-1].to_time
- print(row.planned_start_time, original_start_time, plan_days)
+
if date_diff(row.planned_start_time, original_start_time) > plan_days:
frappe.message_log.pop()
frappe.throw(_("Unable to find the time slot in the next {0} days for the operation {1}.")
@@ -421,6 +421,9 @@ class WorkOrder(Document):
return holidays[holiday_list]
def update_operation_status(self):
+ allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings", "overproduction_percentage_for_work_order"))
+ max_allowed_qty_for_wo = flt(self.qty) + (allowance_percentage/100 * flt(self.qty))
+
for d in self.get("operations"):
if not d.completed_qty:
d.status = "Pending"
@@ -428,12 +431,12 @@ class WorkOrder(Document):
d.status = "Work in Progress"
elif flt(d.completed_qty) == flt(self.qty):
d.status = "Completed"
+ elif flt(d.completed_qty) <= max_allowed_qty_for_wo:
+ d.status = "Completed"
else:
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
def set_actual_dates(self):
- self.actual_start_date = None
- self.actual_end_date = None
if self.get("operations"):
actual_start_dates = [d.actual_start_time for d in self.get("operations") if d.actual_start_time]
if actual_start_dates:
@@ -442,6 +445,27 @@ class WorkOrder(Document):
actual_end_dates = [d.actual_end_time for d in self.get("operations") if d.actual_end_time]
if actual_end_dates:
self.actual_end_date = max(actual_end_dates)
+ else:
+ data = frappe.get_all("Stock Entry",
+ fields = ["timestamp(posting_date, posting_time) as posting_datetime"],
+ filters = {
+ "work_order": self.name,
+ "purpose": ("in", ["Material Transfer for Manufacture", "Manufacture"])
+ }
+ )
+
+ if data and len(data):
+ dates = [d.posting_datetime for d in data]
+ self.actual_start_date = min(dates)
+
+ if self.status == "Completed":
+ self.actual_end_date = max(dates)
+
+ self.set_lead_time()
+
+ def set_lead_time(self):
+ if self.actual_start_date and self.actual_end_date:
+ self.lead_time = flt(time_diff_in_hours(self.actual_end_date, self.actual_start_date) * 60)
def delete_job_card(self):
for d in frappe.get_all("Job Card", ["name"], {"work_order": self.name}):
@@ -517,6 +541,8 @@ class WorkOrder(Document):
# For instance in BOM Explosion Item child table, the items coming from sub assembly items
for item in sorted(item_dict.values(), key=lambda d: d['idx'] or 9999):
self.append('required_items', {
+ 'rate': item.rate,
+ 'amount': item.amount,
'operation': item.operation,
'item_code': item.item_code,
'item_name': item.item_name,
@@ -613,9 +639,10 @@ def get_bom_operations(doctype, txt, searchfield, start, page_len, filters):
filters = filters, fields = ['operation'], as_list=1)
@frappe.whitelist()
-def get_item_details(item, project = None):
+def get_item_details(item, project = None, skip_bom_info=False):
res = frappe.db.sql("""
- select stock_uom, description
+ select stock_uom, description, item_name, allow_alternative_item,
+ include_item_in_manufacturing
from `tabItem`
where disabled=0
and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %s)
@@ -626,6 +653,7 @@ def get_item_details(item, project = None):
return {}
res = res[0]
+ if skip_bom_info: return res
filters = {"item": item, "is_default": 1}
@@ -657,7 +685,7 @@ def get_item_details(item, project = None):
return res
@frappe.whitelist()
-def make_work_order(bom_no, item, qty=0, project=None):
+def make_work_order(bom_no, item, qty=0, project=None, variant_items=None):
if not frappe.has_permission("Work Order", "write"):
frappe.throw(_("Not permitted"), frappe.PermissionError)
@@ -672,8 +700,44 @@ def make_work_order(bom_no, item, qty=0, project=None):
wo_doc.qty = flt(qty)
wo_doc.get_items_and_operations_from_bom()
+ if variant_items:
+ add_variant_item(variant_items, wo_doc, bom_no, "required_items")
+
return wo_doc
+def add_variant_item(variant_items, wo_doc, bom_no, table_name="items"):
+ if isinstance(variant_items, string_types):
+ variant_items = json.loads(variant_items)
+
+ for item in variant_items:
+ args = frappe._dict({
+ "item_code": item.get("varint_item_code"),
+ "required_qty": item.get("qty"),
+ "qty": item.get("qty"), # for bom
+ "source_warehouse": item.get("source_warehouse"),
+ "operation": item.get("operation")
+ })
+
+ bom_doc = frappe.get_cached_doc("BOM", bom_no)
+ item_data = get_item_details(args.item_code, skip_bom_info=True)
+ args.update(item_data)
+
+ args["rate"] = get_bom_item_rate({
+ "item_code": args.get("item_code"),
+ "qty": args.get("required_qty"),
+ "uom": args.get("stock_uom"),
+ "stock_uom": args.get("stock_uom"),
+ "conversion_factor": 1
+ }, bom_doc)
+
+ if not args.source_warehouse:
+ args["source_warehouse"] = get_item_defaults(item.get("varint_item_code"),
+ wo_doc.company).default_warehouse
+
+ args["amount"] = flt(args.get("required_qty")) * flt(args.get("rate"))
+ args["uom"] = item_data.stock_uom
+ wo_doc.append(table_name, args)
+
@frappe.whitelist()
def check_if_scrap_warehouse_mandatory(bom_no):
res = {"set_scrap_wh_mandatory": False }
diff --git a/erpnext/manufacturing/doctype/work_order_item/work_order_item.json b/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
index 44421626361..3acf5727d19 100644
--- a/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
+++ b/erpnext/manufacturing/doctype/work_order_item/work_order_item.json
@@ -1,526 +1,144 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2016-04-18 07:38:26.314642",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "creation": "2016-04-18 07:38:26.314642",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "operation",
+ "item_code",
+ "source_warehouse",
+ "column_break_3",
+ "item_name",
+ "description",
+ "allow_alternative_item",
+ "include_item_in_manufacturing",
+ "qty_section",
+ "required_qty",
+ "rate",
+ "amount",
+ "column_break_11",
+ "transferred_qty",
+ "consumed_qty",
+ "available_qty_at_source_warehouse",
+ "available_qty_at_wip_warehouse"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "operation",
- "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": "Operation",
- "length": 0,
- "no_copy": 0,
- "options": "Operation",
- "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": "operation",
+ "fieldtype": "Link",
+ "label": "Operation",
+ "options": "Operation"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "item_code",
- "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": "Item Code",
- "length": 0,
- "no_copy": 0,
- "options": "Item",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Item Code",
+ "options": "Item"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "source_warehouse",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 1,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Source Warehouse",
- "length": 0,
- "no_copy": 0,
- "options": "Warehouse",
- "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": "source_warehouse",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "in_list_view": 1,
+ "label": "Source Warehouse",
+ "options": "Warehouse"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_3",
- "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,
- "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_3",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "item_name",
- "fieldtype": "Data",
- "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": "Item Name",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "label": "Item Name",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "description",
- "fieldtype": "Text",
- "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": "Description",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "description",
+ "fieldtype": "Text",
+ "label": "Description",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "qty_section",
- "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": "Qty",
- "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": "qty_section",
+ "fieldtype": "Section Break",
+ "label": "Qty"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "required_qty",
- "fieldtype": "Float",
- "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": "Required Qty",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "required_qty",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Required Qty"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:!parent.skip_transfer",
- "fieldname": "transferred_qty",
- "fieldtype": "Float",
- "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": "Transferred Qty",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "depends_on": "eval:!parent.skip_transfer",
+ "fieldname": "transferred_qty",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Transferred Qty",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "allow_alternative_item",
- "fieldtype": "Check",
- "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": "Allow Alternative Item",
- "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
- },
+ "default": "0",
+ "fieldname": "allow_alternative_item",
+ "fieldtype": "Check",
+ "label": "Allow Alternative Item"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "include_item_in_manufacturing",
- "fieldtype": "Check",
- "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": "Include Item In Manufacturing",
- "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
- },
+ "default": "0",
+ "fieldname": "include_item_in_manufacturing",
+ "fieldtype": "Check",
+ "label": "Include Item In Manufacturing"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_11",
- "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,
- "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_11",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:!parent.skip_transfer",
- "fieldname": "consumed_qty",
- "fieldtype": "Float",
- "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": "Consumed Qty",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "depends_on": "eval:!parent.skip_transfer",
+ "fieldname": "consumed_qty",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Consumed Qty",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "available_qty_at_source_warehouse",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Available Qty at Source Warehouse",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "available_qty_at_source_warehouse",
+ "fieldtype": "Float",
+ "label": "Available Qty at Source Warehouse",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "available_qty_at_wip_warehouse",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Available Qty at WIP Warehouse",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldname": "available_qty_at_wip_warehouse",
+ "fieldtype": "Float",
+ "label": "Available Qty at WIP Warehouse",
+ "read_only": 1
+ },
+ {
+ "fieldname": "rate",
+ "fieldtype": "Currency",
+ "label": "Rate",
+ "read_only": 1
+ },
+ {
+ "fieldname": "amount",
+ "fieldtype": "Currency",
+ "label": "Amount",
+ "read_only": 1
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "max_attachments": 0,
- "modified": "2018-11-20 19:04:38.508839",
- "modified_by": "Administrator",
- "module": "Manufacturing",
- "name": "Work Order Item",
- "name_case": "",
- "owner": "Administrator",
- "permissions": [],
- "quick_entry": 1,
- "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
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-04-13 18:46:32.966416",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Work Order Item",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/manufacturing/module_onboarding/manufacturing/manufacturing.json b/erpnext/manufacturing/module_onboarding/manufacturing/manufacturing.json
new file mode 100644
index 00000000000..952d1f0e071
--- /dev/null
+++ b/erpnext/manufacturing/module_onboarding/manufacturing/manufacturing.json
@@ -0,0 +1,57 @@
+{
+ "allow_roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Item Manager"
+ },
+ {
+ "role": "Stock User"
+ }
+ ],
+ "creation": "2020-05-05 16:37:08.238935",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/manufacturing",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-19 12:51:42.744570",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Manufacturing",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Warehouse"
+ },
+ {
+ "step": "Workstation"
+ },
+ {
+ "step": "Operation"
+ },
+ {
+ "step": "Create Product"
+ },
+ {
+ "step": "Create Raw Materials"
+ },
+ {
+ "step": "Create BOM"
+ },
+ {
+ "step": "Work Order"
+ },
+ {
+ "step": "Explore Manufacturing Settings"
+ }
+ ],
+ "subtitle": "Products, Raw Materials, BOM, Work Order and more.",
+ "success_message": "Manufacturing module is all setup!",
+ "title": "Let's Setup Manufacturing Module",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding/manufacturing/manufacturing.json b/erpnext/manufacturing/onboarding/manufacturing/manufacturing.json
new file mode 100644
index 00000000000..50584e19cac
--- /dev/null
+++ b/erpnext/manufacturing/onboarding/manufacturing/manufacturing.json
@@ -0,0 +1,54 @@
+{
+ "allow_roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Item Manager"
+ },
+ {
+ "role": "Stock User"
+ }
+ ],
+ "creation": "2020-05-05 16:37:08.238935",
+ "docstatus": 0,
+ "doctype": "Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/manufacturing",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-12 16:22:07.050224",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Manufacturing",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Introduction to Manufacturing"
+ },
+ {
+ "step": "Warehouse"
+ },
+ {
+ "step": "Workstation"
+ },
+ {
+ "step": "Operation"
+ },
+ {
+ "step": "Create Product"
+ },
+ {
+ "step": "Create BOM"
+ },
+ {
+ "step": "Work Order"
+ }
+ ],
+ "subtitle": "Products, Raw Materials, BOM, Work Order and more.",
+ "success_message": "Manufacturing module is all setup!",
+ "title": "Let's Setup Manufacturing Module",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/create_bom/create_bom.json b/erpnext/manufacturing/onboarding_step/create_bom/create_bom.json
new file mode 100644
index 00000000000..84b4088f233
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/create_bom/create_bom.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-05 16:41:20.239696",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:51:31.315686",
+ "modified_by": "Administrator",
+ "name": "Create BOM",
+ "owner": "Administrator",
+ "reference_document": "BOM",
+ "show_full_form": 1,
+ "title": "Create a BOM (Bill of Material)",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/create_product/create_product.json b/erpnext/manufacturing/onboarding_step/create_product/create_product.json
new file mode 100644
index 00000000000..0ffa30158b0
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/create_product/create_product.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-05 16:42:31.476275",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 1,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:50:59.010439",
+ "modified_by": "Administrator",
+ "name": "Create Product",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "show_full_form": 0,
+ "title": "Create a Finished Good",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/create_raw_materials/create_raw_materials.json b/erpnext/manufacturing/onboarding_step/create_raw_materials/create_raw_materials.json
new file mode 100644
index 00000000000..0764f2e44a8
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/create_raw_materials/create_raw_materials.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-19 11:53:17.295372",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 11:53:25.147837",
+ "modified_by": "Administrator",
+ "name": "Create Raw Materials",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "show_full_form": 0,
+ "title": "Create Raw Materials",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json b/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json
new file mode 100644
index 00000000000..7ef202ee4e7
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/explore_manufacturing_settings/explore_manufacturing_settings.json
@@ -0,0 +1,20 @@
+{
+ "action": "Show Form Tour",
+ "creation": "2020-05-19 11:55:11.378374",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 1,
+ "is_skipped": 0,
+ "modified": "2020-05-26 20:28:03.558199",
+ "modified_by": "Administrator",
+ "name": "Explore Manufacturing Settings",
+ "owner": "Administrator",
+ "reference_document": "Manufacturing Settings",
+ "show_full_form": 0,
+ "title": "Explore Manufacturing Settings",
+ "validate_action": 0,
+ "video_url": "https://www.youtube.com/watch?v=UVGfzwOOZC4"
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/introduction_to_manufacturing/introduction_to_manufacturing.json b/erpnext/manufacturing/onboarding_step/introduction_to_manufacturing/introduction_to_manufacturing.json
new file mode 100644
index 00000000000..eb7ab3a175c
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/introduction_to_manufacturing/introduction_to_manufacturing.json
@@ -0,0 +1,20 @@
+{
+ "action": "Update Settings",
+ "creation": "2020-05-05 16:40:23.676406",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 19:11:57.152883",
+ "modified_by": "Administrator",
+ "name": "Introduction to Manufacturing",
+ "owner": "Administrator",
+ "reference_document": "Manufacturing Settings",
+ "show_full_form": 0,
+ "title": "Manufacturing Settings",
+ "validate_action": 1,
+ "video_url": "https://www.youtube.com/watch?v=UVGfzwOOZC4"
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/operation/operation.json b/erpnext/manufacturing/onboarding_step/operation/operation.json
new file mode 100644
index 00000000000..b532e6778c4
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/operation/operation.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 16:15:31.706756",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:50:41.642754",
+ "modified_by": "Administrator",
+ "name": "Operation",
+ "owner": "Administrator",
+ "reference_document": "Operation",
+ "show_full_form": 0,
+ "title": "Create a Operation",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/warehouse/warehouse.json b/erpnext/manufacturing/onboarding_step/warehouse/warehouse.json
new file mode 100644
index 00000000000..e23bd33b787
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/warehouse/warehouse.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 16:13:34.014554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:50:13.766712",
+ "modified_by": "Administrator",
+ "name": "Warehouse",
+ "owner": "Administrator",
+ "reference_document": "Warehouse",
+ "show_full_form": 0,
+ "title": "Create a Warehouse",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/work_order/work_order.json b/erpnext/manufacturing/onboarding_step/work_order/work_order.json
new file mode 100644
index 00000000000..c63363e7cb2
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/work_order/work_order.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 16:15:56.084682",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:51:38.133150",
+ "modified_by": "Administrator",
+ "name": "Work Order",
+ "owner": "Administrator",
+ "reference_document": "Work Order",
+ "show_full_form": 1,
+ "title": "Create a Work Order",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/onboarding_step/workstation/workstation.json b/erpnext/manufacturing/onboarding_step/workstation/workstation.json
new file mode 100644
index 00000000000..df244bb494a
--- /dev/null
+++ b/erpnext/manufacturing/onboarding_step/workstation/workstation.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 16:14:14.930214",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 12:50:33.938176",
+ "modified_by": "Administrator",
+ "name": "Workstation",
+ "owner": "Administrator",
+ "reference_document": "Workstation",
+ "show_full_form": 0,
+ "title": "Create a Workstation / Machine",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/bom_operations_time/__init__.py b/erpnext/manufacturing/report/bom_operations_time/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.js b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.js
similarity index 66%
rename from erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.js
rename to erpnext/manufacturing/report/bom_operations_time/bom_operations_time.js
index 24c9592c241..7468e34020c 100644
--- a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.js
+++ b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.js
@@ -1,8 +1,9 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
+/* eslint-disable */
-frappe.query_reports["Purchase Order Items To Be Billed"] = {
+frappe.query_reports["BOM Operations Time"] = {
"filters": [
]
-}
+};
diff --git a/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.json b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.json
new file mode 100644
index 00000000000..665c5b9f79e
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.json
@@ -0,0 +1,28 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-03-03 01:41:20.862521",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "",
+ "modified": "2020-03-03 01:41:20.862521",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "BOM Operations Time",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "BOM",
+ "report_name": "BOM Operations Time",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Manufacturing User"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.py b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.py
new file mode 100644
index 00000000000..e7d92658f7d
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_operations_time/bom_operations_time.py
@@ -0,0 +1,112 @@
+# 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 _
+
+def execute(filters=None):
+ data = get_data(filters)
+ columns = get_columns(filters)
+ return columns, data
+
+def get_data(filters):
+ data = []
+
+ bom_data = []
+ for d in frappe.db.sql("""
+ SELECT
+ bom.name, bom.item, bom.item_name, bom.uom,
+ bomps.operation, bomps.workstation, bomps.time_in_mins
+ FROM `tabBOM` bom, `tabBOM Operation` bomps
+ WHERE
+ bom.docstatus = 1 and bom.is_active = 1 and bom.name = bomps.parent
+ """, as_dict=1):
+ row = get_args()
+ if d.name not in bom_data:
+ bom_data.append(d.name)
+ row.update(d)
+ else:
+ row.update({
+ "operation": d.operation,
+ "workstation": d.workstation,
+ "time_in_mins": d.time_in_mins
+ })
+
+ data.append(row)
+
+ used_as_subassembly_items = get_bom_count(bom_data)
+
+ for d in data:
+ d.used_as_subassembly_items = used_as_subassembly_items.get(d.name, 0)
+
+ return data
+
+def get_bom_count(bom_data):
+ data = frappe.get_all("BOM Item",
+ fields=["count(name) as count", "bom_no"],
+ filters= {"bom_no": ("in", bom_data)}, group_by = "bom_no")
+
+ bom_count = {}
+ for d in data:
+ bom_count.setdefault(d.bom_no, d.count)
+
+ return bom_count
+
+def get_args():
+ return frappe._dict({
+ "name": "",
+ "item": "",
+ "item_name": "",
+ "uom": ""
+ })
+
+def get_columns(filters):
+ return [{
+ "label": _("BOM ID"),
+ "options": "BOM",
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "width": 140
+ }, {
+ "label": _("BOM Item Code"),
+ "options": "Item",
+ "fieldname": "item",
+ "fieldtype": "Link",
+ "width": 140
+ }, {
+ "label": _("Item Name"),
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "width": 110
+ }, {
+ "label": _("UOM"),
+ "options": "UOM",
+ "fieldname": "uom",
+ "fieldtype": "Link",
+ "width": 140
+ }, {
+ "label": _("Operation"),
+ "options": "Operation",
+ "fieldname": "operation",
+ "fieldtype": "Link",
+ "width": 120
+ }, {
+ "label": _("Workstation"),
+ "options": "Workstation",
+ "fieldname": "workstation",
+ "fieldtype": "Link",
+ "width": 110
+ }, {
+ "label": _("Time (In Mins)"),
+ "fieldname": "time_in_mins",
+ "fieldtype": "Int",
+ "width": 140
+ }, {
+ "label": _("Sub-assembly BOM Count"),
+ "fieldname": "used_as_subassembly_items",
+ "fieldtype": "Int",
+ "width": 180
+ }]
+
+
diff --git a/erpnext/manufacturing/report/downtime_analysis/__init__.py b/erpnext/manufacturing/report/downtime_analysis/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.js b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.js
new file mode 100644
index 00000000000..ff32dbed98a
--- /dev/null
+++ b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Downtime Analysis"] = {
+ "filters": [
+ {
+ label: __("From Date"),
+ fieldname:"from_date",
+ fieldtype: "Datetime",
+ default: frappe.datetime.add_months(frappe.datetime.now_datetime(), -1),
+ reqd: 1
+ },
+ {
+ label: __("To Date"),
+ fieldname:"to_date",
+ fieldtype: "Datetime",
+ default: frappe.datetime.now_datetime(),
+ reqd: 1,
+ },
+ {
+ label: __("Machine"),
+ fieldname: "workstation",
+ fieldtype: "Link",
+ options: "Workstation"
+ }
+ ]
+};
diff --git a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.json b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.json
new file mode 100644
index 00000000000..5edc7781a2e
--- /dev/null
+++ b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.json
@@ -0,0 +1,31 @@
+{
+ "add_total_row": 1,
+ "creation": "2020-04-20 18:26:04.345289",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "Gadgets International",
+ "modified": "2020-04-20 18:26:04.345289",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Downtime Analysis",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Downtime Entry",
+ "report_name": "Downtime Analysis",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "System Manager"
+ },
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
new file mode 100644
index 00000000000..093309a005b
--- /dev/null
+++ b/erpnext/manufacturing/report/downtime_analysis/downtime_analysis.py
@@ -0,0 +1,113 @@
+# 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.utils import flt
+from frappe import _
+
+def execute(filters=None):
+ columns, data = [], []
+ data = get_data(filters)
+ columns = get_columns(filters)
+ chart_data = get_chart_data(data, filters)
+ return columns, data, None, chart_data
+
+def get_data(filters):
+ query_filters = {}
+
+ fields = ["name", "workstation", "operator", "from_time", "to_time", "downtime", "stop_reason", "remarks"]
+
+ query_filters["from_time"] = (">=", filters.get("from_date"))
+ query_filters["to_time"] = ("<=", filters.get("to_date"))
+
+ if filters.get("workstation"):
+ query_filters["workstation"] = filters.get("workstation")
+
+ data = frappe.get_all("Downtime Entry", fields= fields, filters=query_filters) or []
+ for d in data:
+ if d.downtime:
+ d.downtime = d.downtime / 60
+
+ return data
+
+def get_chart_data(data, columns):
+ labels = sorted(list(set([d.workstation for d in data])))
+
+ workstation_wise_data = {}
+ for d in data:
+ if d.workstation not in workstation_wise_data:
+ workstation_wise_data[d.workstation] = 0
+
+ workstation_wise_data[d.workstation] += flt(d.downtime, 2)
+
+ datasets = []
+ for label in labels:
+ datasets.append(workstation_wise_data.get(label, 0))
+
+ chart = {
+ "data": {
+ "labels": labels,
+ "datasets": [
+ {"name": "Machine Downtime", "values": datasets}
+ ]
+ },
+ "type": "bar"
+ }
+
+ return chart
+
+def get_columns(filters):
+ return [
+ {
+ "label": _("ID"),
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "options": "Downtime Entry",
+ "width": 100
+ },
+ {
+ "label": _("Machine"),
+ "fieldname": "workstation",
+ "fieldtype": "Link",
+ "options": "Workstation",
+ "width": 100
+ },
+ {
+ "label": _("Operator"),
+ "fieldname": "operator",
+ "fieldtype": "Link",
+ "options": "Employee",
+ "width": 130
+ },
+ {
+ "label": _("From Time"),
+ "fieldname": "from_time",
+ "fieldtype": "Datetime",
+ "width": 160
+ },
+ {
+ "label": _("To Time"),
+ "fieldname": "to_time",
+ "fieldtype": "Datetime",
+ "width": 160
+ },
+ {
+ "label": _("Downtime (In Hours)"),
+ "fieldname": "downtime",
+ "fieldtype": "Float",
+ "width": 150
+ },
+ {
+ "label": _("Stop Reason"),
+ "fieldname": "stop_reason",
+ "fieldtype": "Data",
+ "width": 220
+ },
+ {
+ "label": _("Remarks"),
+ "fieldname": "remarks",
+ "fieldtype": "Text",
+ "width": 100
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/exponential_smoothing_forecasting/__init__.py b/erpnext/manufacturing/report/exponential_smoothing_forecasting/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.js b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.js
new file mode 100644
index 00000000000..123a82a3882
--- /dev/null
+++ b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.js
@@ -0,0 +1,97 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Exponential Smoothing Forecasting"] = {
+ "filters": [
+ {
+ "fieldname":"company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "reqd": 1,
+ "default": frappe.defaults.get_user_default("Company")
+ },
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today(),
+ "reqd": 1
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), 12),
+ "reqd": 1
+ },
+ {
+ "fieldname":"based_on_document",
+ "label": __("Based On Document"),
+ "fieldtype": "Select",
+ "options": ["Sales Order", "Delivery Note", "Quotation"],
+ "default": "Sales Order",
+ "reqd": 1
+ },
+ {
+ "fieldname":"based_on_field",
+ "label": __("Based On"),
+ "fieldtype": "Select",
+ "options": ["Qty", "Amount"],
+ "default": "Qty",
+ "reqd": 1
+ },
+ {
+ "fieldname":"no_of_years",
+ "label": __("Based On Data ( in years )"),
+ "fieldtype": "Select",
+ "options": [3, 6, 9],
+ "default": 3,
+ "reqd": 1
+ },
+ {
+ "fieldname": "periodicity",
+ "label": __("Periodicity"),
+ "fieldtype": "Select",
+ "options": [
+ { "value": "Monthly", "label": __("Monthly") },
+ { "value": "Quarterly", "label": __("Quarterly") },
+ { "value": "Half-Yearly", "label": __("Half-Yearly") },
+ { "value": "Yearly", "label": __("Yearly") }
+ ],
+ "default": "Yearly",
+ "reqd": 1
+ },
+ {
+ "fieldname":"smoothing_constant",
+ "label": __("Smoothing Constant"),
+ "fieldtype": "Select",
+ "options": [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
+ "reqd": 1,
+ "default": 0.3
+ },
+ {
+ "fieldname":"item_code",
+ "label": __("Item Code"),
+ "fieldtype": "Link",
+ "options": "Item"
+ },
+ {
+ "fieldname":"warehouse",
+ "label": __("Warehouse"),
+ "fieldtype": "Link",
+ "options": "Warehouse",
+ get_query: () => {
+ var company = frappe.query_report.get_filter_value('company');
+ if (company) {
+ return {
+ filters: {
+ 'company': company
+ }
+ };
+ }
+ }
+ }
+ ]
+};
diff --git a/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.json b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.json
new file mode 100644
index 00000000000..5092ef4e7a5
--- /dev/null
+++ b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.json
@@ -0,0 +1,40 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-05-15 05:18:55.838030",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "",
+ "modified": "2020-05-15 05:18:55.838030",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Exponential Smoothing Forecasting",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Sales Order",
+ "report_name": "Exponential Smoothing Forecasting",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Stock Manager"
+ },
+ {
+ "role": "Sales Manager"
+ },
+ {
+ "role": "Sales User"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.py b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.py
new file mode 100644
index 00000000000..2ca9f1694b3
--- /dev/null
+++ b/erpnext/manufacturing/report/exponential_smoothing_forecasting/exponential_smoothing_forecasting.py
@@ -0,0 +1,242 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe, erpnext
+from frappe import _
+from frappe.utils import flt, nowdate, add_years, cint, getdate
+from erpnext.accounts.report.financial_statements import get_period_list
+from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
+
+def execute(filters=None):
+ return ForecastingReport(filters).execute_report()
+
+class ExponentialSmoothingForecast(object):
+ def forecast_future_data(self):
+ for key, value in self.period_wise_data.items():
+ forecast_data = []
+ for period in self.period_list:
+ forecast_key = "forecast_" + period.key
+
+ if value.get(period.key) and not forecast_data:
+ value[forecast_key] = flt(value.get("avg", 0)) or flt(value.get(period.key))
+
+ elif forecast_data:
+ previous_period_data = forecast_data[-1]
+ value[forecast_key] = (previous_period_data[1] +
+ flt(self.filters.smoothing_constant) * (
+ flt(previous_period_data[0]) - flt(previous_period_data[1])
+ )
+ )
+
+ if value.get(forecast_key):
+ # will be use to forecaset next period
+ forecast_data.append([value.get(period.key), value.get(forecast_key)])
+
+class ForecastingReport(ExponentialSmoothingForecast):
+ def __init__(self, filters=None):
+ self.filters = frappe._dict(filters or {})
+ self.data = []
+ self.doctype = self.filters.based_on_document
+ self.child_doctype = self.doctype + " Item"
+ self.based_on_field = ("qty"
+ if self.filters.based_on_field == "Qty" else "amount")
+ self.fieldtype = "Float" if self.based_on_field == "qty" else "Currency"
+ self.company_currency = erpnext.get_company_currency(self.filters.company)
+
+ def execute_report(self):
+ self.prepare_periodical_data()
+ self.forecast_future_data()
+ self.prepare_final_data()
+ self.add_total()
+
+ columns = self.get_columns()
+ charts = self.get_chart_data()
+ summary_data = self.get_summary_data()
+
+ return columns, self.data, None, charts, summary_data
+
+ def prepare_periodical_data(self):
+ self.period_wise_data = {}
+
+ from_date = add_years(self.filters.from_date, cint(self.filters.no_of_years) * -1)
+ self.period_list = get_period_list(from_date, self.filters.to_date,
+ from_date, self.filters.to_date, None, self.filters.periodicity, ignore_fiscal_year=True)
+
+ order_data = self.get_data_for_forecast() or []
+
+ for entry in order_data:
+ key = (entry.item_code, entry.warehouse)
+ if key not in self.period_wise_data:
+ self.period_wise_data[key] = entry
+
+ period_data = self.period_wise_data[key]
+ for period in self.period_list:
+ # check if posting date is within the period
+ if (entry.posting_date >= period.from_date and entry.posting_date <= period.to_date):
+ period_data[period.key] = period_data.get(period.key, 0.0) + flt(entry.get(self.based_on_field))
+
+ for key, value in self.period_wise_data.items():
+ list_of_period_value = [value.get(p.key, 0) for p in self.period_list]
+
+ if list_of_period_value:
+ total_qty = [1 for d in list_of_period_value if d]
+ if total_qty:
+ value["avg"] = flt(sum(list_of_period_value)) / flt(sum(total_qty))
+
+ def get_data_for_forecast(self):
+ cond = ""
+ if self.filters.item_code:
+ cond = " AND soi.item_code = %s" %(frappe.db.escape(self.filters.item_code))
+
+ warehouses = []
+ if self.filters.warehouse:
+ warehouses = get_child_warehouses(self.filters.warehouse)
+ cond += " AND soi.warehouse in ({})".format(','.join(['%s'] * len(warehouses)))
+
+ input_data = [self.filters.from_date, self.filters.company]
+ if warehouses:
+ input_data.extend(warehouses)
+
+ date_field = "posting_date" if self.doctype == "Delivery Note" else "transaction_date"
+
+ return frappe.db.sql("""
+ SELECT
+ so.{date_field} as posting_date, soi.item_code, soi.warehouse,
+ soi.item_name, soi.stock_qty as qty, soi.base_amount as amount
+ FROM
+ `tab{doc}` so, `tab{child_doc}` soi
+ WHERE
+ so.docstatus = 1 AND so.name = soi.parent AND
+ so.{date_field} < %s AND so.company = %s {cond}
+ """.format(doc=self.doctype, child_doc=self.child_doctype, date_field=date_field, cond=cond),
+ tuple(input_data), as_dict=1)
+
+ def prepare_final_data(self):
+ self.data = []
+
+ if not self.period_wise_data: return
+
+ for key in self.period_wise_data:
+ self.data.append(self.period_wise_data.get(key))
+
+ def add_total(self):
+ if not self.data: return
+
+ total_row = {
+ "item_code": _(frappe.bold("Total Quantity"))
+ }
+
+ for value in self.data:
+ for period in self.period_list:
+ forecast_key = "forecast_" + period.key
+ if forecast_key not in total_row:
+ total_row.setdefault(forecast_key, 0.0)
+
+ if period.key not in total_row:
+ total_row.setdefault(period.key, 0.0)
+
+ total_row[forecast_key] += value.get(forecast_key, 0.0)
+ total_row[period.key] += value.get(period.key, 0.0)
+
+ self.data.append(total_row)
+
+ def get_columns(self):
+ columns = [{
+ "label": _("Item Code"),
+ "options": "Item",
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "width": 130
+ }, {
+ "label": _("Warehouse"),
+ "options": "Warehouse",
+ "fieldname": "warehouse",
+ "fieldtype": "Link",
+ "width": 130
+ }]
+
+ width = 180 if self.filters.periodicity in ['Yearly', "Half-Yearly", "Quarterly"] else 100
+ for period in self.period_list:
+ if (self.filters.periodicity in ['Yearly', "Half-Yearly", "Quarterly"]
+ or period.from_date >= getdate(self.filters.from_date)):
+
+ forecast_key = period.key
+ label = _(period.label)
+ if period.from_date >= getdate(self.filters.from_date):
+ forecast_key = 'forecast_' + period.key
+ label = _(period.label) + " " + _("(Forecast)")
+
+ columns.append({
+ "label": label,
+ "fieldname": forecast_key,
+ "fieldtype": self.fieldtype,
+ "width": width,
+ "default": 0.0
+ })
+
+ return columns
+
+ def get_chart_data(self):
+ if not self.data: return
+
+ labels = []
+ self.total_demand = []
+ self.total_forecast = []
+ self.total_history_forecast = []
+ self.total_future_forecast = []
+
+ for period in self.period_list:
+ forecast_key = "forecast_" + period.key
+
+ labels.append(_(period.label))
+
+ if period.from_date < getdate(self.filters.from_date):
+ self.total_demand.append(self.data[-1].get(period.key, 0))
+ self.total_history_forecast.append(self.data[-1].get(forecast_key, 0))
+ else:
+ self.total_future_forecast.append(self.data[-1].get(forecast_key, 0))
+
+ self.total_forecast.append(self.data[-1].get(forecast_key, 0))
+
+ return {
+ "data": {
+ "labels": labels,
+ "datasets": [
+ {
+ "name": "Demand",
+ "values": self.total_demand
+ },
+ {
+ "name": "Forecast",
+ "values": self.total_forecast
+ }
+ ]
+ },
+ "type": "line"
+ }
+
+ def get_summary_data(self):
+ if not self.data: return
+
+ return [
+ {
+ "value": sum(self.total_demand),
+ "label": _("Total Demand (Past Data)"),
+ "currency": self.company_currency,
+ "datatype": self.fieldtype
+ },
+ {
+ "value": sum(self.total_history_forecast),
+ "label": _("Total Forecast (Past Data)"),
+ "currency": self.company_currency,
+ "datatype": self.fieldtype
+ },
+ {
+ "value": sum(self.total_future_forecast),
+ "indicator": "Green",
+ "label": _("Total Forecast (Future Data)"),
+ "currency": self.company_currency,
+ "datatype": self.fieldtype
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/job_card_summary/__init__.py b/erpnext/manufacturing/report/job_card_summary/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/job_card_summary/job_card_summary.js b/erpnext/manufacturing/report/job_card_summary/job_card_summary.js
new file mode 100644
index 00000000000..bd68db190e7
--- /dev/null
+++ b/erpnext/manufacturing/report/job_card_summary/job_card_summary.js
@@ -0,0 +1,73 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Job Card Summary"] = {
+ "filters": [
+ {
+ label: __("Company"),
+ fieldname: "company",
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1
+ },
+ {
+ fieldname: "fiscal_year",
+ label: __("Fiscal Year"),
+ fieldtype: "Link",
+ options: "Fiscal Year",
+ default: frappe.defaults.get_user_default("fiscal_year"),
+ reqd: 1,
+ on_change: function(query_report) {
+ var fiscal_year = query_report.get_values().fiscal_year;
+ if (!fiscal_year) {
+ return;
+ }
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ from_date: fy.year_start_date,
+ to_date: fy.year_end_date
+ });
+ });
+ }
+ },
+ {
+ label: __("From Posting Date"),
+ fieldname:"from_date",
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_start_date"),
+ reqd: 1
+ },
+ {
+ label: __("To Posting Date"),
+ fieldname:"to_date",
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_end_date"),
+ reqd: 1,
+ },
+ {
+ label: __("Status"),
+ fieldname: "status",
+ fieldtype: "Select",
+ options: ["", "Open", "Work In Progress", "Completed", "On Hold"]
+ },
+ {
+ label: __("Sales Orders"),
+ fieldname: "sales_order",
+ fieldtype: "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Sales Order', txt);
+ }
+ },
+ {
+ label: __("Production Item"),
+ fieldname: "production_item",
+ fieldtype: "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Item', txt);
+ }
+ }
+ ]
+};
diff --git a/erpnext/manufacturing/report/job_card_summary/job_card_summary.json b/erpnext/manufacturing/report/job_card_summary/job_card_summary.json
new file mode 100644
index 00000000000..9f08fc34cb8
--- /dev/null
+++ b/erpnext/manufacturing/report/job_card_summary/job_card_summary.json
@@ -0,0 +1,34 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-04-20 12:00:21.436619",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "Gadgets International",
+ "modified": "2020-04-20 12:00:21.436619",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Job Card Summary",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Job Card",
+ "report_name": "Job Card Summary",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Stock Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/job_card_summary/job_card_summary.py b/erpnext/manufacturing/report/job_card_summary/job_card_summary.py
new file mode 100644
index 00000000000..b1bff3500c6
--- /dev/null
+++ b/erpnext/manufacturing/report/job_card_summary/job_card_summary.py
@@ -0,0 +1,204 @@
+# 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 getdate, flt
+from erpnext.stock.report.stock_analytics.stock_analytics import (get_period_date_ranges, get_period)
+
+def execute(filters=None):
+ columns, data = [], []
+ data = get_data(filters)
+ columns = get_columns(filters)
+ chart_data = get_chart_data(data, filters)
+ return columns, data, None, chart_data
+
+def get_data(filters):
+ query_filters = {
+ "docstatus": ("<", 2),
+ "posting_date": ("between", [filters.from_date, filters.to_date])
+ }
+
+ fields = ["name", "status", "work_order", "production_item", "item_name", "posting_date",
+ "total_completed_qty", "workstation", "operation", "employee_name", "total_time_in_mins"]
+
+ for field in ["work_order", "workstation", "operation", "company"]:
+ if filters.get(field):
+ query_filters[field] = ("in", filters.get(field))
+
+ data = frappe.get_all("Job Card",
+ fields= fields, filters=query_filters)
+
+ if not data: return []
+
+ job_cards = [d.name for d in data]
+
+ job_card_time_filter = {
+ "docstatus": ("<", 2),
+ "parent": ("in", job_cards),
+ }
+
+ job_card_time_details = {}
+ for job_card_data in frappe.get_all("Job Card Time Log",
+ fields=["min(from_time) as from_time", "max(to_time) as to_time", "parent"],
+ filters=job_card_time_filter, group_by="parent", debug=1):
+ job_card_time_details[job_card_data.parent] = job_card_data
+
+ res = []
+ for d in data:
+ if d.status != "Completed":
+ d.status = "Open"
+
+ if job_card_time_details.get(d.name):
+ d.from_time = job_card_time_details.get(d.name).from_time
+ d.to_time = job_card_time_details.get(d.name).to_time
+
+ res.append(d)
+
+ return res
+
+def get_chart_data(job_card_details, filters):
+ labels, periodic_data = prepare_chart_data(job_card_details, filters)
+
+ open_job_cards, completed = [], []
+ datasets = []
+
+ for d in labels:
+ open_job_cards.append(periodic_data.get("Open").get(d))
+ completed.append(periodic_data.get("Completed").get(d))
+
+ datasets.append({"name": "Open", "values": open_job_cards})
+ datasets.append({"name": "Completed", "values": completed})
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': datasets
+ },
+ "type": "bar"
+ }
+
+ return chart
+
+def prepare_chart_data(job_card_details, filters):
+ labels = []
+
+ periodic_data = {
+ "Open": {},
+ "Completed": {}
+ }
+
+ filters.range = "Monthly"
+
+ ranges = get_period_date_ranges(filters)
+ for from_date, end_date in ranges:
+ period = get_period(end_date, filters)
+ if period not in labels:
+ labels.append(period)
+
+ for d in job_card_details:
+ if getdate(d.posting_date) > from_date and getdate(d.posting_date) <= end_date:
+ status = "Completed" if d.status == "Completed" else "Open"
+
+ if periodic_data.get(status).get(period):
+ periodic_data[status][period] += 1
+ else:
+ periodic_data[status][period] = 1
+
+ return labels, periodic_data
+
+def get_columns(filters):
+ columns = [
+ {
+ "label": _("Id"),
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "options": "Job Card",
+ "width": 100
+ },
+ {
+ "label": _("Posting Date"),
+ "fieldname": "posting_date",
+ "fieldtype": "Date",
+ "width": 100
+ },
+ ]
+
+ if not filters.get("status"):
+ columns.append(
+ {
+ "label": _("Status"),
+ "fieldname": "status",
+ "width": 100
+ },
+ )
+
+ columns.extend([
+ {
+ "label": _("Work Order"),
+ "fieldname": "work_order",
+ "fieldtype": "Link",
+ "options": "Work Order",
+ "width": 100
+ },
+ {
+ "label": _("Production Item"),
+ "fieldname": "production_item",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 110
+ },
+ {
+ "label": _("Item Name"),
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "width": 100
+ },
+ {
+ "label": _("Workstation"),
+ "fieldname": "workstation",
+ "fieldtype": "Link",
+ "options": "Workstation",
+ "width": 110
+ },
+ {
+ "label": _("Operation"),
+ "fieldname": "operation",
+ "fieldtype": "Link",
+ "options": "Operation",
+ "width": 110
+ },
+ {
+ "label": _("Employee Name"),
+ "fieldname": "employee_name",
+ "fieldtype": "Data",
+ "width": 110
+ },
+ {
+ "label": _("Total Completed Qty"),
+ "fieldname": "total_completed_qty",
+ "fieldtype": "Float",
+ "width": 120
+ },
+ {
+ "label": _("From Time"),
+ "fieldname": "from_time",
+ "fieldtype": "Datetime",
+ "width": 120
+ },
+ {
+ "label": _("To Time"),
+ "fieldname": "to_time",
+ "fieldtype": "Datetime",
+ "width": 120
+ },
+ {
+ "label": _("Time Required (In Mins)"),
+ "fieldname": "total_time_in_mins",
+ "fieldtype": "Float",
+ "width": 100
+ }
+ ])
+
+ return columns
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/production_analytics/production_analytics.py b/erpnext/manufacturing/report/production_analytics/production_analytics.py
index 7447a1f6705..79af8a1e39b 100644
--- a/erpnext/manufacturing/report/production_analytics/production_analytics.py
+++ b/erpnext/manufacturing/report/production_analytics/production_analytics.py
@@ -55,32 +55,27 @@ def get_periodic_data(filters, entry):
if d.status == 'Completed':
if getdate(d.actual_end_date) < getdate(from_date) or getdate(d.modified) < getdate(from_date):
periodic_data = update_periodic_data(periodic_data, "Completed", period)
-
elif getdate(d.actual_start_date) < getdate(from_date) :
periodic_data = update_periodic_data(periodic_data, "Pending", period)
-
elif getdate(d.planned_start_date) < getdate(from_date) :
periodic_data = update_periodic_data(periodic_data, "Overdue", period)
-
else:
periodic_data = update_periodic_data(periodic_data, "Not Started", period)
elif d.status == 'In Process':
if getdate(d.actual_start_date) < getdate(from_date) :
periodic_data = update_periodic_data(periodic_data, "Pending", period)
-
elif getdate(d.planned_start_date) < getdate(from_date) :
periodic_data = update_periodic_data(periodic_data, "Overdue", period)
-
else:
periodic_data = update_periodic_data(periodic_data, "Not Started", period)
elif d.status == 'Not Started':
if getdate(d.planned_start_date) < getdate(from_date) :
periodic_data = update_periodic_data(periodic_data, "Overdue", period)
-
else:
periodic_data = update_periodic_data(periodic_data, "Not Started", period)
+
return periodic_data
def update_periodic_data(periodic_data, status, period):
@@ -148,4 +143,3 @@ def get_chart_data(periodic_data, columns):
-
diff --git a/erpnext/manufacturing/report/production_planning_report/__init__.py b/erpnext/manufacturing/report/production_planning_report/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/production_planning_report/production_planning_report.js b/erpnext/manufacturing/report/production_planning_report/production_planning_report.js
new file mode 100644
index 00000000000..675b8a11008
--- /dev/null
+++ b/erpnext/manufacturing/report/production_planning_report/production_planning_report.js
@@ -0,0 +1,111 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Production Planning Report"] = {
+ "filters": [
+ {
+ "fieldname":"company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "reqd": 1,
+ "default": frappe.defaults.get_user_default("Company")
+ },
+ {
+ "fieldname":"based_on",
+ "label": __("Based On"),
+ "fieldtype": "Select",
+ "options": ["Sales Order", "Material Request", "Work Order"],
+ "default": "Sales Order",
+ "reqd": 1,
+ on_change: function() {
+ let filters = frappe.query_report.filters;
+ let based_on = frappe.query_report.get_filter_value('based_on');
+ let options = {
+ "Sales Order": ["Delivery Date", "Total Amount"],
+ "Material Request": ["Required Date"],
+ "Work Order": ["Planned Start Date"]
+ }
+
+ filters.forEach(d => {
+ if (d.fieldname == "order_by") {
+ d.df.options = options[based_on];
+ d.set_input(d.df.options)
+ }
+ });
+
+ frappe.query_report.refresh();
+ }
+ },
+ {
+ "fieldname":"docnames",
+ "label": __("Document Name"),
+ "fieldtype": "MultiSelectList",
+ "options": "Sales Order",
+ "get_data": function(txt) {
+ if (!frappe.query_report.filters) return;
+
+ let based_on = frappe.query_report.get_filter_value('based_on');
+ if (!based_on) return;
+
+ return frappe.db.get_link_options(based_on, txt);
+ },
+ "get_query": function() {
+ var company = frappe.query_report.get_filter_value('company');
+ return {
+ filters: {
+ "docstatus": 1,
+ "company": company
+ }
+ };
+ }
+ },
+ {
+ "fieldname":"raw_material_warehouse",
+ "label": __("Raw Material Warehouse"),
+ "fieldtype": "Link",
+ "options": "Warehouse",
+ "depends_on": "eval: doc.based_on != 'Work Order'",
+ "get_query": function() {
+ var company = frappe.query_report.get_filter_value('company');
+ return {
+ filters: {
+ "company": company
+ }
+ };
+ }
+ },
+ {
+ "fieldname":"order_by",
+ "label": __("Order By"),
+ "fieldtype": "Select",
+ "options": ["Delivery Date", "Total Amount"],
+ "default": "Delivery Date"
+ },
+ {
+ "fieldname":"include_subassembly_raw_materials",
+ "label": __("Include Sub-assembly Raw Materials"),
+ "fieldtype": "Check",
+ "depends_on": "eval: doc.based_on != 'Work Order'",
+ "default": 0
+ },
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+
+ if (column.fieldname == "production_item_name" && data && data.qty_to_manufacture > data.available_qty ) {
+ value = `${value}
`;
+ }
+
+ if (column.fieldname == "production_item" && !data.name ) {
+ value = "";
+ }
+
+ if (column.fieldname == "raw_material_name" && data && data.required_qty > data.allotted_qty ) {
+ value = `${value}
`;
+ }
+
+ return value;
+ },
+};
diff --git a/erpnext/manufacturing/report/production_planning_report/production_planning_report.json b/erpnext/manufacturing/report/production_planning_report/production_planning_report.json
new file mode 100644
index 00000000000..f37dad39a43
--- /dev/null
+++ b/erpnext/manufacturing/report/production_planning_report/production_planning_report.json
@@ -0,0 +1,31 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-03-06 11:37:43.180095",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "",
+ "modified": "2020-03-06 11:38:05.789851",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Production Planning Report",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Work Order",
+ "report_name": "Production Planning Report",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/production_planning_report/production_planning_report.py b/erpnext/manufacturing/report/production_planning_report/production_planning_report.py
new file mode 100644
index 00000000000..5ac3923187a
--- /dev/null
+++ b/erpnext/manufacturing/report/production_planning_report/production_planning_report.py
@@ -0,0 +1,374 @@
+# 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 erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
+
+# and bom_no is not null and bom_no !=''
+
+mapper = {
+ "Sales Order": {
+ "fields": """ item_code as production_item, item_name as production_item_name, stock_uom,
+ stock_qty as qty_to_manufacture, `tabSales Order Item`.parent as name, bom_no, warehouse,
+ `tabSales Order Item`.delivery_date, `tabSales Order`.base_grand_total """,
+ "filters": """`tabSales Order Item`.docstatus = 1 and stock_qty > produced_qty
+ and `tabSales Order`.per_delivered < 100.0"""
+ },
+ "Material Request": {
+ "fields": """ item_code as production_item, item_name as production_item_name, stock_uom,
+ stock_qty as qty_to_manufacture, `tabMaterial Request Item`.parent as name, bom_no, warehouse,
+ `tabMaterial Request Item`.schedule_date """,
+ "filters": """`tabMaterial Request`.docstatus = 1 and `tabMaterial Request`.per_ordered < 100
+ and `tabMaterial Request`.material_request_type = 'Manufacture' """
+ },
+ "Work Order": {
+ "fields": """ production_item, item_name as production_item_name, planned_start_date,
+ stock_uom, qty as qty_to_manufacture, name, bom_no, fg_warehouse as warehouse """,
+ "filters": "docstatus = 1 and status not in ('Completed', 'Stopped')"
+ },
+}
+
+order_mapper = {
+ "Sales Order": {
+ "Delivery Date": "`tabSales Order Item`.delivery_date asc",
+ "Total Amount": "`tabSales Order`.base_grand_total desc"
+ },
+ "Material Request": {
+ "Required Date": "`tabMaterial Request Item`.schedule_date asc"
+ },
+ "Work Order": {
+ "Planned Start Date": "planned_start_date asc"
+ }
+}
+
+def execute(filters=None):
+ return ProductionPlanReport(filters).execute_report()
+
+class ProductionPlanReport(object):
+ def __init__(self, filters=None):
+ self.filters = frappe._dict(filters or {})
+ self.raw_materials_dict = {}
+ self.data = []
+
+ def execute_report(self):
+ self.get_open_orders()
+ self.get_raw_materials()
+ self.get_item_details()
+ self.get_bin_details()
+ self.get_purchase_details()
+ self.prepare_data()
+ self.get_columns()
+
+ return self.columns, self.data
+
+ def get_open_orders(self):
+ doctype = ("`tabWork Order`" if self.filters.based_on == "Work Order"
+ else "`tab{doc}`, `tab{doc} Item`".format(doc=self.filters.based_on))
+
+ filters = mapper.get(self.filters.based_on)["filters"]
+ filters = self.prepare_other_conditions(filters, self.filters.based_on)
+ order_by = " ORDER BY %s" % (order_mapper[self.filters.based_on][self.filters.order_by])
+
+ self.orders = frappe.db.sql(""" SELECT {fields} from {doctype}
+ WHERE {filters} {order_by}""".format(
+ doctype = doctype,
+ filters = filters,
+ order_by = order_by,
+ fields = mapper.get(self.filters.based_on)["fields"]
+ ), tuple(self.filters.docnames), as_dict=1)
+
+ def prepare_other_conditions(self, filters, doctype):
+ if self.filters.docnames:
+ field = "name" if doctype == "Work Order" else "`tab{} Item`.parent".format(doctype)
+ filters += " and %s in (%s)" % (field, ','.join(['%s'] * len(self.filters.docnames)))
+
+ if doctype != "Work Order":
+ filters += " and `tab{doc}`.name = `tab{doc} Item`.parent".format(doc=doctype)
+
+ if self.filters.company:
+ filters += " and `tab%s`.company = %s" %(doctype, frappe.db.escape(self.filters.company))
+
+ return filters
+
+ def get_raw_materials(self):
+ if not self.orders: return
+ self.warehouses = [d.warehouse for d in self.orders]
+ self.item_codes = [d.production_item for d in self.orders]
+
+ if self.filters.based_on == "Work Order":
+ work_orders = [d.name for d in self.orders]
+
+ raw_materials = frappe.get_all("Work Order Item",
+ fields=["parent", "item_code", "item_name as raw_material_name",
+ "source_warehouse as warehouse", "required_qty"],
+ filters = {"docstatus": 1, "parent": ("in", work_orders), "source_warehouse": ("!=", "")}) or []
+ self.warehouses.extend([d.source_warehouse for d in raw_materials])
+
+ else:
+ bom_nos = []
+
+ for d in self.orders:
+ bom_no = d.bom_no or frappe.get_cached_value("Item", d.production_item, "default_bom")
+
+ if not d.bom_no:
+ d.bom_no = bom_no
+
+ bom_nos.append(bom_no)
+
+ bom_doctype = ("BOM Explosion Item"
+ if self.filters.include_subassembly_raw_materials else "BOM Item")
+
+ qty_field = ("qty_consumed_per_unit"
+ if self.filters.include_subassembly_raw_materials else "(bom_item.qty / bom.quantity)")
+
+ raw_materials = frappe.db.sql(""" SELECT bom_item.parent, bom_item.item_code,
+ bom_item.item_name as raw_material_name, {0} as required_qty
+ FROM
+ `tabBOM` as bom, `tab{1}` as bom_item
+ WHERE
+ bom_item.parent in ({2}) and bom_item.parent = bom.name and bom.docstatus = 1
+ """.format(qty_field, bom_doctype, ','.join(["%s"] * len(bom_nos))), tuple(bom_nos), as_dict=1)
+
+ if not raw_materials: return
+
+ self.item_codes.extend([d.item_code for d in raw_materials])
+
+ for d in raw_materials:
+ if d.parent not in self.raw_materials_dict:
+ self.raw_materials_dict.setdefault(d.parent, [])
+
+ rows = self.raw_materials_dict[d.parent]
+ rows.append(d)
+
+ def get_item_details(self):
+ if not (self.orders and self.item_codes): return
+
+ self.item_details = {}
+ for d in frappe.get_all("Item Default", fields = ["parent", "default_warehouse"],
+ filters = {"company": self.filters.company, "parent": ("in", self.item_codes)}):
+ self.item_details[d.parent] = d
+
+ def get_bin_details(self):
+ if not (self.orders and self.raw_materials_dict): return
+
+ self.bin_details = {}
+ self.mrp_warehouses = []
+ if self.filters.raw_material_warehouse:
+ self.mrp_warehouses.extend(get_child_warehouses(self.filters.raw_material_warehouse))
+ self.warehouses.extend(self.mrp_warehouses)
+
+ for d in frappe.get_all("Bin",
+ fields=["warehouse", "item_code", "actual_qty", "ordered_qty", "projected_qty"],
+ filters = {"item_code": ("in", self.item_codes), "warehouse": ("in", self.warehouses)}):
+ key = (d.item_code, d.warehouse)
+ if key not in self.bin_details:
+ self.bin_details.setdefault(key, d)
+
+ def get_purchase_details(self):
+ if not (self.orders and self.raw_materials_dict): return
+
+ self.purchase_details = {}
+
+ for d in frappe.get_all("Purchase Order Item",
+ fields=["item_code", "min(schedule_date) as arrival_date", "qty as arrival_qty", "warehouse"],
+ filters = {"item_code": ("in", self.item_codes), "warehouse": ("in", self.warehouses)},
+ group_by = "item_code, warehouse"):
+ key = (d.item_code, d.warehouse)
+ if key not in self.purchase_details:
+ self.purchase_details.setdefault(key, d)
+
+ def prepare_data(self):
+ if not self.orders: return
+
+ for d in self.orders:
+ key = d.name if self.filters.based_on == "Work Order" else d.bom_no
+
+ if not self.raw_materials_dict.get(key): continue
+
+ bin_data = self.bin_details.get((d.production_item, d.warehouse)) or {}
+ d.update({
+ "for_warehouse": d.warehouse,
+ "available_qty": 0
+ })
+
+ if bin_data and bin_data.get("actual_qty") > 0 and d.qty_to_manufacture:
+ d.available_qty = (bin_data.get("actual_qty")
+ if (d.qty_to_manufacture > bin_data.get("actual_qty")) else d.qty_to_manufacture)
+
+ bin_data["actual_qty"] -= d.available_qty
+
+ self.update_raw_materials(d, key)
+
+ def update_raw_materials(self, data, key):
+ self.index = 0
+ self.raw_materials_dict.get(key)
+
+ warehouses = self.mrp_warehouses or []
+ for d in self.raw_materials_dict.get(key):
+ if self.filters.based_on != "Work Order":
+ d.required_qty = d.required_qty * data.qty_to_manufacture
+
+ if not warehouses:
+ warehouses = [data.warehouse]
+
+ if self.filters.based_on == "Work Order" and d.warehouse:
+ warehouses = [d.warehouse]
+ else:
+ item_details = self.item_details.get(d.item_code)
+ if item_details:
+ warehouses = [item_details["default_warehouse"]]
+
+ if self.filters.raw_material_warehouse:
+ warehouses = get_child_warehouses(self.filters.raw_material_warehouse)
+
+ d.remaining_qty = d.required_qty
+ self.pick_materials_from_warehouses(d, data, warehouses)
+
+ if (d.remaining_qty and self.filters.raw_material_warehouse
+ and d.remaining_qty != d.required_qty):
+ row = self.get_args()
+ d.warehouse = self.filters.raw_material_warehouse
+ d.required_qty = d.remaining_qty
+ d.allotted_qty = 0
+ row.update(d)
+ self.data.append(row)
+
+ def pick_materials_from_warehouses(self, args, order_data, warehouses):
+ for index, warehouse in enumerate(warehouses):
+ if not args.remaining_qty: return
+
+ row = self.get_args()
+
+ key = (args.item_code, warehouse)
+ bin_data = self.bin_details.get(key)
+
+ if bin_data:
+ row.update(bin_data)
+
+ args.allotted_qty = 0
+ if bin_data and bin_data.get("actual_qty") > 0:
+ args.allotted_qty = (bin_data.get("actual_qty")
+ if (args.required_qty > bin_data.get("actual_qty")) else args.required_qty)
+
+ args.remaining_qty -= args.allotted_qty
+ bin_data["actual_qty"] -= args.allotted_qty
+
+ if ((self.mrp_warehouses and (args.allotted_qty or index == len(warehouses) - 1))
+ or not self.mrp_warehouses):
+ if not self.index:
+ row.update(order_data)
+ self.index += 1
+
+ args.warehouse = warehouse
+ row.update(args)
+ if self.purchase_details.get(key):
+ row.update(self.purchase_details.get(key))
+
+ self.data.append(row)
+
+ def get_args(self):
+ return frappe._dict({
+ "work_order": "",
+ "sales_order": "",
+ "production_item": "",
+ "production_item_name": "",
+ "qty_to_manufacture": "",
+ "produced_qty": ""
+ })
+
+ def get_columns(self):
+ based_on = self.filters.based_on
+
+ self.columns = [{
+ "label": _("ID"),
+ "options": based_on,
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "width": 100
+ }, {
+ "label": _("Item Code"),
+ "fieldname": "production_item",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 120
+ }, {
+ "label": _("Item Name"),
+ "fieldname": "production_item_name",
+ "fieldtype": "Data",
+ "width": 130
+ }, {
+ "label": _("Warehouse"),
+ "options": "Warehouse",
+ "fieldname": "for_warehouse",
+ "fieldtype": "Link",
+ "width": 100
+ }, {
+ "label": _("Order Qty"),
+ "fieldname": "qty_to_manufacture",
+ "fieldtype": "Float",
+ "width": 80
+ }, {
+ "label": _("Available"),
+ "fieldname": "available_qty",
+ "fieldtype": "Float",
+ "width": 80
+ }]
+
+ fieldname, fieldtype = "delivery_date", "Date"
+ if self.filters.based_on == "Sales Order" and self.filters.order_by == "Total Amount":
+ fieldname, fieldtype = "base_grand_total", "Currency"
+ elif self.filters.based_on == "Material Request":
+ fieldname = "schedule_date"
+ elif self.filters.based_on == "Work Order":
+ fieldname = "planned_start_date"
+
+ self.columns.append({
+ "label": _(self.filters.order_by),
+ "fieldname": fieldname,
+ "fieldtype": fieldtype,
+ "width": 100
+ })
+
+ self.columns.extend([{
+ "label": _("Raw Material Code"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 120
+ }, {
+ "label": _("Raw Material Name"),
+ "fieldname": "raw_material_name",
+ "fieldtype": "Data",
+ "width": 130
+ }, {
+ "label": _("Warehouse"),
+ "options": "Warehouse",
+ "fieldname": "warehouse",
+ "fieldtype": "Link",
+ "width": 110
+ }, {
+ "label": _("Required Qty"),
+ "fieldname": "required_qty",
+ "fieldtype": "Float",
+ "width": 100
+ }, {
+ "label": _("Allotted Qty"),
+ "fieldname": "allotted_qty",
+ "fieldtype": "Float",
+ "width": 100
+ }, {
+ "label": _("Expected Arrival Date"),
+ "fieldname": "arrival_date",
+ "fieldtype": "Date",
+ "width": 160
+ }, {
+ "label": _("Arrival Quantity"),
+ "fieldname": "arrival_qty",
+ "fieldtype": "Float",
+ "width": 140
+ }])
+
+def document_query(doctype, txt, searchfield, start, page_len, filters):
+ pass
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/quality_inspection_summary/__init__.py b/erpnext/manufacturing/report/quality_inspection_summary/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.js b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.js
new file mode 100644
index 00000000000..d4587aa6619
--- /dev/null
+++ b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Quality Inspection Summary"] = {
+ "filters": [
+ {
+ label: __("From Date"),
+ fieldname:"from_date",
+ fieldtype: "Date",
+ default: frappe.datetime.add_months(frappe.datetime.get_today(), -12),
+ reqd: 1
+ },
+ {
+ label: __("To Date"),
+ fieldname:"to_date",
+ fieldtype: "Date",
+ default: frappe.datetime.get_today(),
+ reqd: 1,
+ },
+ {
+ label: __("Status"),
+ fieldname: "status",
+ fieldtype: "Select",
+ options: ["", "Accepted", "Rejected"]
+ },
+ {
+ label: __("Item Code"),
+ fieldname: "item_code",
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ label: __("Inspected By"),
+ fieldname: "inspected_by",
+ fieldtype: "Link",
+ options: "User"
+ }
+ ]
+};
diff --git a/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.json b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.json
new file mode 100644
index 00000000000..48226e6b21d
--- /dev/null
+++ b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.json
@@ -0,0 +1,32 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-04-26 18:23:53.475110",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "json": "{}",
+ "letter_head": "Gadgets International",
+ "modified": "2020-04-26 18:24:50.529940",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Quality Inspection Summary",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Quality Inspection",
+ "report_name": "Quality Inspection Summary",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Quality Manager"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Stock Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.py b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.py
new file mode 100644
index 00000000000..6192632bda6
--- /dev/null
+++ b/erpnext/manufacturing/report/quality_inspection_summary/quality_inspection_summary.py
@@ -0,0 +1,132 @@
+# 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 _
+
+def execute(filters=None):
+ columns, data = [], []
+ data = get_data(filters)
+ columns = get_columns(filters)
+ chart_data = get_chart_data(data, filters)
+ return columns, data , None, chart_data
+
+def get_data(filters):
+ query_filters = {"docstatus": ("<", 2)}
+
+ fields = ["name", "status", "report_date", "item_code", "item_name", "sample_size",
+ "inspection_type", "reference_type", "reference_name", "inspected_by"]
+
+ for field in ["status", "item_code", "status", "inspected_by"]:
+ if filters.get(field):
+ query_filters[field] = ("in", filters.get(field))
+
+ query_filters["report_date"] = (">=", filters.get("from_date"))
+ query_filters["report_date"] = ("<=", filters.get("to_date"))
+
+ return frappe.get_all("Quality Inspection",
+ fields= fields, filters=query_filters, order_by="report_date asc")
+
+def get_chart_data(periodic_data, columns):
+ labels = ["Rejected", "Accepted"]
+
+ status_wise_data = {
+ "Accepted": 0,
+ "Rejected": 0
+ }
+
+ datasets = []
+
+ for d in periodic_data:
+ status_wise_data[d.status] += 1
+
+ datasets.append({'name':'Qty Wise Chart',
+ 'values': [status_wise_data.get("Rejected"), status_wise_data.get("Accepted")]})
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': datasets
+ },
+ "type": "donut",
+ "height": 300
+ }
+
+ return chart
+
+def get_columns(filters):
+ columns = [
+ {
+ "label": _("Id"),
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "options": "Work Order",
+ "width": 100
+ },
+ {
+ "label": _("Report Date"),
+ "fieldname": "report_date",
+ "fieldtype": "Date",
+ "width": 150
+ }
+ ]
+
+ if not filters.get("status"):
+ columns.append(
+ {
+ "label": _("Status"),
+ "fieldname": "status",
+ "width": 100
+ },
+ )
+
+ columns.extend([
+ {
+ "label": _("Item Code"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 130
+ },
+ {
+ "label": _("Item Name"),
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "width": 130
+ },
+ {
+ "label": _("Sample Size"),
+ "fieldname": "sample_size",
+ "fieldtype": "Float",
+ "width": 110
+ },
+ {
+ "label": _("Inspection Type"),
+ "fieldname": "inspection_type",
+ "fieldtype": "Data",
+ "width": 110
+ },
+ {
+ "label": _("Document Type"),
+ "fieldname": "reference_type",
+ "fieldtype": "Data",
+ "width": 90
+ },
+ {
+ "label": _("Document Name"),
+ "fieldname": "reference_name",
+ "fieldtype": "Dynamic Link",
+ "options": "reference_type",
+ "width": 150
+ },
+ {
+ "label": _("Inspected By"),
+ "fieldname": "inspected_by",
+ "fieldtype": "Link",
+ "options": "User",
+ "width": 150
+ }
+ ])
+
+ return columns
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/work_order_summary/__init__.py b/erpnext/manufacturing/report/work_order_summary/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.js b/erpnext/manufacturing/report/work_order_summary/work_order_summary.js
new file mode 100644
index 00000000000..eb23f17c477
--- /dev/null
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.js
@@ -0,0 +1,86 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Work Order Summary"] = {
+ "filters": [
+ {
+ label: __("Company"),
+ fieldname: "company",
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company"),
+ reqd: 1
+ },
+ {
+ fieldname: "fiscal_year",
+ label: __("Fiscal Year"),
+ fieldtype: "Link",
+ options: "Fiscal Year",
+ default: frappe.defaults.get_user_default("fiscal_year"),
+ reqd: 1,
+ on_change: function(query_report) {
+ var fiscal_year = query_report.get_values().fiscal_year;
+ if (!fiscal_year) {
+ return;
+ }
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ from_date: fy.year_start_date,
+ to_date: fy.year_end_date
+ });
+ });
+ }
+ },
+ {
+ label: __("From Posting Date"),
+ fieldname:"from_date",
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_start_date"),
+ reqd: 1
+ },
+ {
+ label: __("To Posting Date"),
+ fieldname:"to_date",
+ fieldtype: "Date",
+ default: frappe.defaults.get_user_default("year_end_date"),
+ reqd: 1,
+ },
+ {
+ label: __("Status"),
+ fieldname: "status",
+ fieldtype: "Select",
+ options: ["", "Not Started", "In Process", "Completed", "Stopped"]
+ },
+ {
+ label: __("Sales Orders"),
+ fieldname: "sales_order",
+ fieldtype: "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Sales Order', txt);
+ }
+ },
+ {
+ label: __("Production Item"),
+ fieldname: "production_item",
+ fieldtype: "MultiSelectList",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Item', txt);
+ }
+ },
+ {
+ label: __("Age"),
+ fieldname:"age",
+ fieldtype: "Int",
+ default: "0"
+ },
+ {
+ label: __("Charts Based On"),
+ fieldname:"charts_based_on",
+ fieldtype: "Select",
+ options: ["Status", "Age", "Quantity"],
+ default: "Status"
+ },
+ ]
+};
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.json b/erpnext/manufacturing/report/work_order_summary/work_order_summary.json
new file mode 100644
index 00000000000..0d093e22e94
--- /dev/null
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.json
@@ -0,0 +1,31 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-04-17 17:07:56.830358",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "letter_head": "Gadgets International",
+ "modified": "2020-04-19 16:59:47.979278",
+ "modified_by": "Administrator",
+ "module": "Manufacturing",
+ "name": "Work Order Summary",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Work Order",
+ "report_name": "Work Order Summary",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Stock User"
+ },
+ {
+ "role": "Manufacturing Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/report/work_order_summary/work_order_summary.py b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
new file mode 100644
index 00000000000..fb047b230ce
--- /dev/null
+++ b/erpnext/manufacturing/report/work_order_summary/work_order_summary.py
@@ -0,0 +1,267 @@
+# 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.utils import date_diff, today, getdate, flt
+from frappe import _
+from erpnext.stock.report.stock_analytics.stock_analytics import (get_period_date_ranges, get_period)
+
+def execute(filters=None):
+ columns, data = [], []
+
+ if not filters.get("age"):
+ filters["age"] = 0
+
+ data = get_data(filters)
+ columns = get_columns(filters)
+ chart_data = get_chart_data(data, filters)
+ return columns, data, None, chart_data
+
+def get_data(filters):
+ query_filters = {"docstatus": 1}
+
+ fields = ["name", "status", "sales_order", "production_item", "qty", "produced_qty",
+ "planned_start_date", "planned_end_date", "actual_start_date", "actual_end_date", "lead_time"]
+
+ for field in ["sales_order", "production_item", "status", "company"]:
+ if filters.get(field):
+ query_filters[field] = ("in", filters.get(field))
+
+ query_filters["planned_start_date"] = (">=", filters.get("from_date"))
+ query_filters["planned_end_date"] = ("<=", filters.get("to_date"))
+
+ data = frappe.get_all("Work Order",
+ fields= fields, filters=query_filters, order_by="planned_start_date asc")
+
+ res = []
+ for d in data:
+ start_date = d.actual_start_date or d.planned_start_date
+ d.age = 0
+
+ if d.status != 'Completed':
+ d.age = date_diff(today(), start_date)
+
+ if filters.get("age") <= d.age:
+ res.append(d)
+
+ return res
+
+def get_chart_data(data, filters):
+ if filters.get("charts_based_on") == "Status":
+ return get_chart_based_on_status(data)
+ elif filters.get("charts_based_on") == "Age":
+ return get_chart_based_on_age(data)
+ else:
+ return get_chart_based_on_qty(data, filters)
+
+def get_chart_based_on_status(data):
+ labels = ["Completed", "In Process", "Stopped", "Not Started"]
+
+ status_wise_data = {
+ "Not Started": 0,
+ "In Process": 0,
+ "Stopped": 0,
+ "Completed": 0
+ }
+
+ for d in data:
+ status_wise_data[d.status] += 1
+
+ values = [status_wise_data["Completed"], status_wise_data["In Process"],
+ status_wise_data["Stopped"], status_wise_data["Not Started"]]
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': [{'name':'Qty Wise Chart', 'values': values}]
+ },
+ "type": "donut",
+ "height": 300
+ }
+
+ return chart
+
+def get_chart_based_on_age(data):
+ labels = ["0-30 Days", "30-60 Days", "60-90 Days", "90 Above"]
+
+ age_wise_data = {
+ "0-30 Days": 0,
+ "30-60 Days": 0,
+ "60-90 Days": 0,
+ "90 Above": 0
+ }
+
+ for d in data:
+ if d.age > 0 and d.age <= 30:
+ age_wise_data["0-30 Days"] += 1
+ elif d.age > 30 and d.age <= 60:
+ age_wise_data["30-60 Days"] += 1
+ elif d.age > 60 and d.age <= 90:
+ age_wise_data["60-90 Days"] += 1
+ else:
+ age_wise_data["90 Above"] += 1
+
+ values = [age_wise_data["0-30 Days"], age_wise_data["30-60 Days"],
+ age_wise_data["60-90 Days"], age_wise_data["90 Above"]]
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': [{'name':'Qty Wise Chart', 'values': values}]
+ },
+ "type": "donut",
+ "height": 300
+ }
+
+ return chart
+
+def get_chart_based_on_qty(data, filters):
+ labels, periodic_data = prepare_chart_data(data, filters)
+
+ pending, completed = [], []
+ datasets = []
+
+ for d in labels:
+ pending.append(periodic_data.get("Pending").get(d))
+ completed.append(periodic_data.get("Completed").get(d))
+
+ datasets.append({"name": "Pending", "values": pending})
+ datasets.append({"name": "Completed", "values": completed})
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': datasets
+ },
+ "type": "bar",
+ "barOptions": {
+ "stacked": 1
+ }
+ }
+
+ return chart
+
+def prepare_chart_data(data, filters):
+ labels = []
+
+ periodic_data = {
+ "Pending": {},
+ "Completed": {}
+ }
+
+ filters.range = "Monthly"
+
+ ranges = get_period_date_ranges(filters)
+ for from_date, end_date in ranges:
+ period = get_period(end_date, filters)
+ if period not in labels:
+ labels.append(period)
+
+ if period not in periodic_data["Pending"]:
+ periodic_data["Pending"][period] = 0
+
+ if period not in periodic_data["Completed"]:
+ periodic_data["Completed"][period] = 0
+
+ for d in data:
+ if getdate(d.planned_start_date) >= from_date and getdate(d.planned_start_date) <= end_date:
+ periodic_data["Pending"][period] += (flt(d.qty) - flt(d.produced_qty))
+ periodic_data["Completed"][period] += flt(d.produced_qty)
+
+ return labels, periodic_data
+
+def get_columns(filters):
+ columns = [
+ {
+ "label": _("Id"),
+ "fieldname": "name",
+ "fieldtype": "Link",
+ "options": "Work Order",
+ "width": 100
+ },
+ ]
+
+ if not filters.get("status"):
+ columns.append(
+ {
+ "label": _("Status"),
+ "fieldname": "status",
+ "width": 100
+ },
+ )
+
+ columns.extend([
+ {
+ "label": _("Production Item"),
+ "fieldname": "production_item",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 130
+ },
+ {
+ "label": _("Produce Qty"),
+ "fieldname": "qty",
+ "fieldtype": "Float",
+ "width": 110
+ },
+ {
+ "label": _("Produced Qty"),
+ "fieldname": "produced_qty",
+ "fieldtype": "Float",
+ "width": 110
+ },
+ {
+ "label": _("Sales Order"),
+ "fieldname": "sales_order",
+ "fieldtype": "Link",
+ "options": "Sales Order",
+ "width": 90
+ },
+ {
+ "label": _("Planned Start Date"),
+ "fieldname": "planned_start_date",
+ "fieldtype": "Date",
+ "width": 150
+ },
+ {
+ "label": _("Planned End Date"),
+ "fieldname": "planned_end_date",
+ "fieldtype": "Date",
+ "width": 150
+ }
+ ])
+
+ if filters.get("status") != 'Not Started':
+ columns.extend([
+ {
+ "label": _("Actual Start Date"),
+ "fieldname": "actual_start_date",
+ "fieldtype": "Date",
+ "width": 100
+ },
+ {
+ "label": _("Actual End Date"),
+ "fieldname": "actual_end_date",
+ "fieldtype": "Date",
+ "width": 100
+ },
+ {
+ "label": _("Age"),
+ "fieldname": "age",
+ "fieldtype": "Float",
+ "width": 110
+ },
+ ])
+
+ if filters.get("status") == 'Completed':
+ columns.extend([
+ {
+ "label": _("Lead Time (in mins)"),
+ "fieldname": "lead_time",
+ "fieldtype": "Float",
+ "width": 110
+ },
+ ])
+
+ return columns
\ No newline at end of file
diff --git a/erpnext/non_profit/doctype/member/member.py b/erpnext/non_profit/doctype/member/member.py
index 571f87af874..d1294ccc08b 100644
--- a/erpnext/non_profit/doctype/member/member.py
+++ b/erpnext/non_profit/doctype/member/member.py
@@ -77,6 +77,7 @@ def create_customer(user_details):
customer = frappe.new_doc("Customer")
customer.customer_name = user_details.fullname
customer.customer_type = "Individual"
+ customer.flags.ignore_mandatory = True
customer.insert(ignore_permissions=True)
try:
@@ -91,7 +92,11 @@ def create_customer(user_details):
"link_name": customer.name
})
- contact.insert()
+ contact.save()
+
+ except frappe.DuplicateEntryError:
+ return customer.name
+
except Exception as e:
frappe.log_error(frappe.get_traceback(), _("Contact Creation Failed"))
pass
diff --git a/erpnext/non_profit/doctype/membership/membership.py b/erpnext/non_profit/doctype/membership/membership.py
index 5a69cdb6ab0..7a0caed621e 100644
--- a/erpnext/non_profit/doctype/membership/membership.py
+++ b/erpnext/non_profit/doctype/membership/membership.py
@@ -62,10 +62,27 @@ def get_member_based_on_subscription(subscription_id, email):
'subscription_id': subscription_id,
'email_id': email
}, order_by="creation desc")
- return frappe.get_doc("Member", members[0]['name'])
+ try:
+ return frappe.get_doc("Member", members[0]['name'])
+ except:
+ return None
+
+def verify_signature(data):
+ signature = frappe.request.headers.get('X-Razorpay-Signature')
+
+ settings = frappe.get_doc("Membership Settings")
+ key = settings.get_webhook_secret()
+
+ controller = frappe.get_doc("Razorpay Settings")
+
+ controller.verify_signature(data, signature, key)
+
@frappe.whitelist(allow_guest=True)
-def trigger_razorpay_subscription(data):
+def trigger_razorpay_subscription(*args, **kwargs):
+ data = frappe.request.get_data(as_text=True)
+ verify_signature(data)
+
if isinstance(data, six.string_types):
data = json.loads(data)
data = frappe._dict(data)
@@ -82,7 +99,10 @@ def trigger_razorpay_subscription(data):
except Exception as e:
error_log = frappe.log_error(frappe.get_traceback() + '\n' + data_json , _("Membership Webhook Failed"))
notify_failure(error_log)
- raise e
+ return False
+
+ if not member:
+ return False
if data.event == "subscription.activated":
member.customer_id = payment.customer_id
@@ -111,7 +131,6 @@ def trigger_razorpay_subscription(data):
return True
-
def notify_failure(log):
try:
content = """Dear System Manager,
diff --git a/erpnext/non_profit/doctype/membership_settings/membership_settings.js b/erpnext/non_profit/doctype/membership_settings/membership_settings.js
index c01a0b23d5d..8c0e3a4fa76 100644
--- a/erpnext/non_profit/doctype/membership_settings/membership_settings.js
+++ b/erpnext/non_profit/doctype/membership_settings/membership_settings.js
@@ -1,8 +1,30 @@
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Membership Settings', {
+frappe.ui.form.on("Membership Settings", {
refresh: function(frm) {
+ if (frm.doc.webhook_secret) {
+ frm.add_custom_button(__("Revoke "), () => {
+ frm.call("revoke_key").then(() => {
+ frm.refresh();
+ })
+ });
+ }
+ frm.trigger("add_generate_button");
+ },
- }
+ add_generate_button: function(frm) {
+ let label;
+
+ if (frm.doc.webhook_secret) {
+ label = __("Regenerate Webhook Secret");
+ } else {
+ label = __("Generate Webhook Secret");
+ }
+ frm.add_custom_button(label, () => {
+ frm.call("generate_webhook_key").then(() => {
+ frm.refresh();
+ });
+ });
+ },
});
diff --git a/erpnext/non_profit/doctype/membership_settings/membership_settings.json b/erpnext/non_profit/doctype/membership_settings/membership_settings.json
index 56b8eac4b12..52b9d01088b 100644
--- a/erpnext/non_profit/doctype/membership_settings/membership_settings.json
+++ b/erpnext/non_profit/doctype/membership_settings/membership_settings.json
@@ -8,7 +8,8 @@
"enable_razorpay",
"razorpay_settings_section",
"billing_cycle",
- "billing_frequency"
+ "billing_frequency",
+ "webhook_secret"
],
"fields": [
{
@@ -34,11 +35,17 @@
"fieldname": "billing_frequency",
"fieldtype": "Int",
"label": "Billing Frequency"
+ },
+ {
+ "fieldname": "webhook_secret",
+ "fieldtype": "Password",
+ "label": "Webhook Secret",
+ "read_only": 1
}
],
"issingle": 1,
"links": [],
- "modified": "2020-04-07 18:42:51.496807",
+ "modified": "2020-05-22 12:38:27.103759",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Membership Settings",
diff --git a/erpnext/non_profit/doctype/membership_settings/membership_settings.py b/erpnext/non_profit/doctype/membership_settings/membership_settings.py
index 2b8e37f2a65..f3b2eee6f97 100644
--- a/erpnext/non_profit/doctype/membership_settings/membership_settings.py
+++ b/erpnext/non_profit/doctype/membership_settings/membership_settings.py
@@ -4,11 +4,27 @@
from __future__ import unicode_literals
import frappe
+from frappe import _
from frappe.integrations.utils import get_payment_gateway_controller
from frappe.model.document import Document
class MembershipSettings(Document):
- pass
+ def generate_webhook_key(self):
+ key = frappe.generate_hash(length=20)
+ self.webhook_secret = key
+ self.save()
+
+ frappe.msgprint(
+ _("Here is your webhook secret, this will be shown to you only once.") + " " + key,
+ _("Webhook Secret")
+ );
+
+ def revoke_key(self):
+ self.webhook_secret = None;
+ self.save()
+
+ def get_webhook_secret(self):
+ return self.get_password(fieldname="webhook_secret", raise_exception=False)
@frappe.whitelist()
def get_plans_for_membership(*args, **kwargs):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ce0e4ac4711..a0707b77ca7 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -623,7 +623,7 @@ erpnext.patches.v11_1.update_default_supplier_in_item_defaults
erpnext.patches.v12_0.update_due_date_in_gle
erpnext.patches.v12_0.add_default_buying_selling_terms_in_company
erpnext.patches.v12_0.update_ewaybill_field_position
-erpnext.patches.v12_0.create_accounting_dimensions_in_missing_doctypes
+erpnext.patches.v12_0.create_accounting_dimensions_in_missing_doctypes #2020-05-11
erpnext.patches.v11_1.set_status_for_material_request_type_manufacture
erpnext.patches.v12_0.move_plaid_settings_to_doctype
execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_link')
@@ -631,7 +631,6 @@ execute:frappe.reload_doc('desk', 'doctype', 'dashboard')
execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_source')
execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart')
execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_field')
-erpnext.patches.v12_0.add_default_dashboards # 2020-04-05
erpnext.patches.v12_0.remove_bank_remittance_custom_fields
erpnext.patches.v12_0.generate_leave_ledger_entries
execute:frappe.delete_doc_if_exists("Report", "Loan Repayment")
@@ -679,4 +678,22 @@ erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123
erpnext.patches.v12_0.fix_quotation_expired_status
erpnext.patches.v12_0.update_appointment_reminder_scheduler_entry
erpnext.patches.v12_0.retain_permission_rules_for_video_doctype
+erpnext.patches.v12_0.remove_duplicate_leave_ledger_entries #2020-05-22
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive
+execute:frappe.reload_doc("HR", "doctype", "Employee Advance")
+erpnext.patches.v12_0.move_due_advance_amount_to_pending_amount
+execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
+execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True)
+erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price
+erpnext.patches.v12_0.set_valid_till_date_in_supplier_quotation
+erpnext.patches.v12_0.set_serial_no_status #2020-05-21
+erpnext.patches.v12_0.update_price_list_currency_in_bom
+execute:frappe.delete_doc_if_exists('Dashboard', 'Accounts')
+erpnext.patches.v13_0.update_actual_start_and_end_date_in_wo
+erpnext.patches.v13_0.set_company_field_in_healthcare_doctypes #2020-05-25
+erpnext.patches.v12_0.update_bom_in_so_mr
+execute:frappe.delete_doc("Report", "Department Analytics")
+execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True)
+erpnext.patches.v12_0.update_uom_conversion_factor
+erpnext.patches.v13_0.delete_old_purchase_reports
+erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions
diff --git a/erpnext/patches/v11_0/set_default_email_template_in_hr.py b/erpnext/patches/v11_0/set_default_email_template_in_hr.py
index 14954fbeb31..46223761095 100644
--- a/erpnext/patches/v11_0/set_default_email_template_in_hr.py
+++ b/erpnext/patches/v11_0/set_default_email_template_in_hr.py
@@ -1,8 +1,9 @@
from __future__ import unicode_literals
+from frappe import _
import frappe
def execute():
hr_settings = frappe.get_single("HR Settings")
- hr_settings.leave_approval_notification_template = "Leave Approval Notification"
- hr_settings.leave_status_notification_template = "Leave Status Notification"
- hr_settings.save()
\ No newline at end of file
+ hr_settings.leave_approval_notification_template = _("Leave Approval Notification")
+ hr_settings.leave_status_notification_template = _("Leave Status Notification")
+ hr_settings.save()
diff --git a/erpnext/patches/v12_0/add_default_dashboards.py b/erpnext/patches/v12_0/add_default_dashboards.py
deleted file mode 100644
index 2a91e1b9327..00000000000
--- a/erpnext/patches/v12_0/add_default_dashboards.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (c) 2019, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-import frappe
-from erpnext.setup.setup_wizard.operations.install_fixtures import add_dashboards
-
-def execute():
- frappe.reload_doc("desk", "doctype", "number_card_link")
- frappe.reload_doc("healthcare", "doctype", "patient_appointment")
- add_dashboards()
diff --git a/erpnext/patches/v12_0/create_accounting_dimensions_in_missing_doctypes.py b/erpnext/patches/v12_0/create_accounting_dimensions_in_missing_doctypes.py
index b71ea665943..657decfed23 100644
--- a/erpnext/patches/v12_0/create_accounting_dimensions_in_missing_doctypes.py
+++ b/erpnext/patches/v12_0/create_accounting_dimensions_in_missing_doctypes.py
@@ -20,7 +20,8 @@ def execute():
else:
insert_after_field = 'accounting_dimensions_section'
- for doctype in ["Subscription Plan", "Subscription", "Opening Invoice Creation Tool", "Opening Invoice Creation Tool Item"]:
+ for doctype in ["Subscription Plan", "Subscription", "Opening Invoice Creation Tool", "Opening Invoice Creation Tool Item",
+ "Expense Claim Detail", "Expense Taxes and Charges"]:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
diff --git a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py
index 3c9758eb84a..1ddbae6cd29 100644
--- a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py
+++ b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py
@@ -4,7 +4,7 @@ import frappe
def execute():
frappe.reload_doc('accounts', 'doctype', 'bank', force=1)
- if frappe.db.table_exists('Bank') and frappe.db.table_exists('Bank Account'):
+ if frappe.db.table_exists('Bank') and frappe.db.table_exists('Bank Account') and frappe.db.has_column('Bank Account', 'swift_number'):
frappe.db.sql("""
UPDATE `tabBank` b, `tabBank Account` ba
SET b.swift_number = ba.swift_number, b.branch_code = ba.branch_code
@@ -12,4 +12,4 @@ def execute():
""")
frappe.reload_doc('accounts', 'doctype', 'bank_account')
- frappe.reload_doc('accounts', 'doctype', 'payment_request')
\ No newline at end of file
+ frappe.reload_doc('accounts', 'doctype', 'payment_request')
diff --git a/erpnext/patches/v12_0/move_due_advance_amount_to_pending_amount.py b/erpnext/patches/v12_0/move_due_advance_amount_to_pending_amount.py
new file mode 100644
index 00000000000..f1ffaf9d2d4
--- /dev/null
+++ b/erpnext/patches/v12_0/move_due_advance_amount_to_pending_amount.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2019, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ ''' Move from due_advance_amount to pending_amount '''
+ frappe.db.sql(''' UPDATE `tabEmployee Advance` SET pending_amount=due_advance_amount ''')
diff --git a/erpnext/patches/v12_0/remove_duplicate_leave_ledger_entries.py b/erpnext/patches/v12_0/remove_duplicate_leave_ledger_entries.py
new file mode 100644
index 00000000000..24286dcebf9
--- /dev/null
+++ b/erpnext/patches/v12_0/remove_duplicate_leave_ledger_entries.py
@@ -0,0 +1,46 @@
+# Copyright (c) 2018, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ """Delete duplicate leave ledger entries of type allocation created."""
+ frappe.reload_doc('hr', 'doctype', 'leave_ledger_entry')
+ if not frappe.db.a_row_exists("Leave Ledger Entry"):
+ return
+
+ duplicate_records_list = get_duplicate_records()
+ delete_duplicate_ledger_entries(duplicate_records_list)
+
+def get_duplicate_records():
+ """Fetch all but one duplicate records from the list of expired leave allocation."""
+ return frappe.db.sql("""
+ SELECT name, employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
+ FROM `tabLeave Ledger Entry`
+ WHERE
+ transaction_type = 'Leave Allocation'
+ AND docstatus = 1
+ AND is_expired = 1
+ GROUP BY
+ employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
+ HAVING
+ count(name) > 1
+ ORDER BY
+ creation
+ """)
+
+def delete_duplicate_ledger_entries(duplicate_records_list):
+ """Delete duplicate leave ledger entries."""
+ if not duplicate_records_list: return
+ for d in duplicate_records_list:
+ frappe.db.sql('''
+ DELETE FROM `tabLeave Ledger Entry`
+ WHERE name != %s
+ AND employee = %s
+ AND transaction_name = %s
+ AND leave_type = %s
+ AND is_carry_forward = %s
+ AND from_date = %s
+ AND to_date = %s
+ ''', tuple(d))
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/rename_bank_reconciliation.py b/erpnext/patches/v12_0/rename_bank_reconciliation.py
index eda47a95e03..2efa854fba9 100644
--- a/erpnext/patches/v12_0/rename_bank_reconciliation.py
+++ b/erpnext/patches/v12_0/rename_bank_reconciliation.py
@@ -8,9 +8,6 @@ def execute():
if frappe.db.table_exists("Bank Reconciliation"):
frappe.rename_doc('DocType', 'Bank Reconciliation', 'Bank Clearance', force=True)
frappe.reload_doc('Accounts', 'doctype', 'Bank Clearance')
-
+
frappe.rename_doc('DocType', 'Bank Reconciliation Detail', 'Bank Clearance Detail', force=True)
frappe.reload_doc('Accounts', 'doctype', 'Bank Clearance Detail')
-
- frappe.delete_doc("DocType", "Bank Reconciliation")
- frappe.delete_doc("DocType", "Bank Reconciliation Detail")
diff --git a/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py b/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py
new file mode 100644
index 00000000000..a6011c4dace
--- /dev/null
+++ b/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py
@@ -0,0 +1,12 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.regional.italy.setup import add_permissions
+
+def execute():
+ countries = frappe.get_all("Company", fields="country")
+ countries = [country["country"] for country in countries]
+ if "Italy" in countries:
+ add_permissions()
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py b/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py
index 6f843cdabd7..52c9a2d7b3c 100644
--- a/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py
+++ b/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py
@@ -64,11 +64,13 @@ def execute():
return_document_map = make_return_document_map(doctype, return_document_map)
+ count = 0
+
#iterate through original documents and its return documents
for docname in return_document_map:
- doc_items = frappe.get_doc(doctype, docname).get("items")
+ doc_items = frappe.get_cached_doc(doctype, docname).get("items")
for return_doc in return_document_map[docname]:
- return_doc_items = frappe.get_doc(doctype, return_doc).get("items")
+ return_doc_items = frappe.get_cached_doc(doctype, return_doc).get("items")
#iterate through return document items and original document items for mapping
for return_item in return_doc_items:
@@ -80,9 +82,11 @@ def execute():
else:
continue
+ # commit after every 100 sql updates
+ count += 1
+ if count%100 == 0:
+ frappe.db.commit()
+
set_document_detail_in_return_document("Purchase Receipt")
set_document_detail_in_return_document("Delivery Note")
frappe.db.commit()
-
-
-
diff --git a/erpnext/patches/v12_0/set_serial_no_status.py b/erpnext/patches/v12_0/set_serial_no_status.py
new file mode 100644
index 00000000000..3b5f5ef3407
--- /dev/null
+++ b/erpnext/patches/v12_0/set_serial_no_status.py
@@ -0,0 +1,26 @@
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import getdate, nowdate
+
+def execute():
+ frappe.reload_doc('stock', 'doctype', 'serial_no')
+
+ serial_no_list = frappe.db.sql("""select name, delivery_document_type, warranty_expiry_date, warehouse from `tabSerial No`
+ where (status is NULL OR status='')""", as_dict = 1)
+ if len(serial_no_list) > 20000:
+ frappe.db.auto_commit_on_many_writes = True
+
+ for serial_no in serial_no_list:
+ if serial_no.get("delivery_document_type"):
+ status = "Delivered"
+ elif serial_no.get("warranty_expiry_date") and getdate(serial_no.get("warranty_expiry_date")) <= getdate(nowdate()):
+ status = "Expired"
+ elif not serial_no.get("warehouse"):
+ status = "Inactive"
+ else:
+ status = "Active"
+
+ frappe.db.set_value("Serial No", serial_no.get("name"), "status", status)
+
+ if frappe.db.auto_commit_on_many_writes:
+ frappe.db.auto_commit_on_many_writes = False
diff --git a/erpnext/patches/v12_0/set_valid_till_date_in_supplier_quotation.py b/erpnext/patches/v12_0/set_valid_till_date_in_supplier_quotation.py
new file mode 100644
index 00000000000..4a6e2288564
--- /dev/null
+++ b/erpnext/patches/v12_0/set_valid_till_date_in_supplier_quotation.py
@@ -0,0 +1,8 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc("buying", "doctype", "supplier_quotation")
+ frappe.db.sql("""UPDATE `tabSupplier Quotation`
+ SET valid_till = DATE_ADD(transaction_date , INTERVAL 1 MONTH)
+ WHERE docstatus < 2""")
diff --git a/erpnext/patches/v12_0/unset_customer_supplier_based_on_type_of_item_price.py b/erpnext/patches/v12_0/unset_customer_supplier_based_on_type_of_item_price.py
new file mode 100644
index 00000000000..b8efb210a03
--- /dev/null
+++ b/erpnext/patches/v12_0/unset_customer_supplier_based_on_type_of_item_price.py
@@ -0,0 +1,29 @@
+from __future__ import unicode_literals
+import frappe
+
+
+def execute():
+ """
+ set proper customer and supplier details for item price
+ based on selling and buying values
+ """
+
+ # update for selling
+ frappe.db.sql(
+ """UPDATE `tabItem Price` ip, `tabPrice List` pl
+ SET ip.`reference` = ip.`customer`, ip.`supplier` = NULL
+ WHERE ip.`selling` = 1
+ AND ip.`buying` = 0
+ AND (ip.`supplier` IS NOT NULL OR ip.`supplier` = '')
+ AND ip.`price_list` = pl.`name`
+ AND pl.`enabled` = 1""")
+
+ # update for buying
+ frappe.db.sql(
+ """UPDATE `tabItem Price` ip, `tabPrice List` pl
+ SET ip.`reference` = ip.`supplier`, ip.`customer` = NULL
+ WHERE ip.`selling` = 0
+ AND ip.`buying` = 1
+ AND (ip.`customer` IS NOT NULL OR ip.`customer` = '')
+ AND ip.`price_list` = pl.`name`
+ AND pl.`enabled` = 1""")
diff --git a/erpnext/patches/v12_0/update_bom_in_so_mr.py b/erpnext/patches/v12_0/update_bom_in_so_mr.py
new file mode 100644
index 00000000000..309ae4c2ab7
--- /dev/null
+++ b/erpnext/patches/v12_0/update_bom_in_so_mr.py
@@ -0,0 +1,19 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc("stock", "doctype", "material_request_item")
+ frappe.reload_doc("selling", "doctype", "sales_order_item")
+
+ for doctype in ["Sales Order", "Material Request"]:
+ condition = " and child_doc.stock_qty > child_doc.produced_qty"
+ if doctype == "Material Request":
+ condition = " and doc.per_ordered < 100 and doc.material_request_type = 'Manufacture'"
+
+ frappe.db.sql(""" UPDATE `tab{doc}` as doc, `tab{doc} Item` as child_doc, tabItem as item
+ SET
+ child_doc.bom_no = item.default_bom
+ WHERE
+ child_doc.item_code = item.name and child_doc.docstatus < 2
+ and item.default_bom is not null and item.default_bom != '' {cond}
+ """.format(doc = doctype, cond = condition))
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/update_price_list_currency_in_bom.py b/erpnext/patches/v12_0/update_price_list_currency_in_bom.py
new file mode 100644
index 00000000000..f5e7b947c23
--- /dev/null
+++ b/erpnext/patches/v12_0/update_price_list_currency_in_bom.py
@@ -0,0 +1,31 @@
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import getdate, flt
+from erpnext.setup.utils import get_exchange_rate
+
+def execute():
+ frappe.reload_doc("manufacturing", "doctype", "bom")
+ frappe.reload_doc("manufacturing", "doctype", "bom_item")
+
+ frappe.db.sql(""" UPDATE `tabBOM`, `tabPrice List`
+ SET
+ `tabBOM`.price_list_currency = `tabPrice List`.currency,
+ `tabBOM`.plc_conversion_rate = 1.0
+ WHERE
+ `tabBOM`.buying_price_list = `tabPrice List`.name AND `tabBOM`.docstatus < 2
+ AND `tabBOM`.rm_cost_as_per = 'Price List'
+ """)
+
+ for d in frappe.db.sql("""
+ SELECT
+ bom.creation, bom.name, bom.price_list_currency as currency,
+ company.default_currency as company_currency
+ FROM
+ `tabBOM` as bom, `tabCompany` as company
+ WHERE
+ bom.company = company.name AND bom.rm_cost_as_per = 'Price List' AND
+ bom.price_list_currency != company.default_currency AND bom.docstatus < 2""", as_dict=1):
+ plc_conversion_rate = get_exchange_rate(d.currency,
+ d.company_currency, getdate(d.creation), "for_buying")
+
+ frappe.db.set_value("BOM", d.name, "plc_conversion_rate", plc_conversion_rate)
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/update_uom_conversion_factor.py b/erpnext/patches/v12_0/update_uom_conversion_factor.py
new file mode 100644
index 00000000000..b5a20aa6fd9
--- /dev/null
+++ b/erpnext/patches/v12_0/update_uom_conversion_factor.py
@@ -0,0 +1,11 @@
+from __future__ import unicode_literals
+import frappe, json
+
+def execute():
+ from erpnext.setup.setup_wizard.operations.install_fixtures import add_uom_data
+
+ frappe.reload_doc("setup", "doctype", "UOM Conversion Factor")
+ frappe.reload_doc("setup", "doctype", "UOM")
+ frappe.reload_doc("stock", "doctype", "UOM Category")
+
+ add_uom_data()
\ No newline at end of file
diff --git a/erpnext/patches/v13_0/__init__.py b/erpnext/patches/v13_0/__init__.py
index e69de29bb2d..baffc488252 100644
--- a/erpnext/patches/v13_0/__init__.py
+++ b/erpnext/patches/v13_0/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/patches/v13_0/delete_old_purchase_reports.py b/erpnext/patches/v13_0/delete_old_purchase_reports.py
new file mode 100644
index 00000000000..8bdc07ee5b8
--- /dev/null
+++ b/erpnext/patches/v13_0/delete_old_purchase_reports.py
@@ -0,0 +1,23 @@
+# Copyright (c) 2019, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+
+def execute():
+ reports_to_delete = ["Requested Items To Be Ordered",
+ "Purchase Order Items To Be Received or Billed","Purchase Order Items To Be Received",
+ "Purchase Order Items To Be Billed"]
+
+ for report in reports_to_delete:
+ if frappe.db.exists("Report", report):
+ delete_auto_email_reports(report)
+
+ frappe.delete_doc("Report", report)
+
+def delete_auto_email_reports(report):
+ """ Check for one or multiple Auto Email Reports and delete """
+ auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": report}, ["name"])
+ for auto_email_report in auto_email_reports:
+ frappe.delete_doc("Auto Email Report", auto_email_report[0])
\ No newline at end of file
diff --git a/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py b/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py
index 179be2cfde5..5ade8ca0f4c 100644
--- a/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py
+++ b/erpnext/patches/v13_0/move_tax_slabs_from_payroll_period_to_income_tax_slab.py
@@ -7,22 +7,28 @@ import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
- if not frappe.db.table_exists("Payroll Period"):
+ if not (frappe.db.table_exists("Payroll Period") and frappe.db.table_exists("Taxable Salary Slab")):
return
for doctype in ("income_tax_slab", "salary_structure_assignment", "employee_other_income", "income_tax_slab_other_charges"):
frappe.reload_doc("hr", "doctype", doctype)
+ standard_tax_exemption_amount_exists = frappe.db.has_column("Payroll Period", "standard_tax_exemption_amount")
+
+ select_fields = "name, start_date, end_date"
+ if standard_tax_exemption_amount_exists:
+ select_fields = "name, start_date, end_date, standard_tax_exemption_amount"
+
for company in frappe.get_all("Company"):
payroll_periods = frappe.db.sql("""
SELECT
- name, start_date, end_date, standard_tax_exemption_amount
+ {0}
FROM
`tabPayroll Period`
WHERE company=%s
ORDER BY start_date DESC
- """, company.name, as_dict = 1)
+ """.format(select_fields), company.name, as_dict = 1)
for i, period in enumerate(payroll_periods):
income_tax_slab = frappe.new_doc("Income Tax Slab")
@@ -36,7 +42,8 @@ def execute():
income_tax_slab.effective_from = period.start_date
income_tax_slab.company = company.name
income_tax_slab.allow_tax_exemption = 1
- income_tax_slab.standard_tax_exemption_amount = period.standard_tax_exemption_amount
+ if standard_tax_exemption_amount_exists:
+ income_tax_slab.standard_tax_exemption_amount = period.standard_tax_exemption_amount
income_tax_slab.flags.ignore_mandatory = True
income_tax_slab.submit()
@@ -60,6 +67,9 @@ def execute():
""", (income_tax_slab.name, company.name, period.start_date))
# move other incomes to separate document
+ if not frappe.db.table_exists("Employee Tax Exemption Proof Submission"):
+ return
+
migrated = []
proofs = frappe.get_all("Employee Tax Exemption Proof Submission",
filters = {'docstatus': 1},
@@ -79,6 +89,9 @@ def execute():
except:
pass
+ if not frappe.db.table_exists("Employee Tax Exemption Declaration"):
+ return
+
declerations = frappe.get_all("Employee Tax Exemption Declaration",
filters = {'docstatus': 1},
fields =['payroll_period', 'employee', 'company', 'income_from_other_sources']
diff --git a/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py
new file mode 100644
index 00000000000..be5e30f3074
--- /dev/null
+++ b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py
@@ -0,0 +1,10 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ company = frappe.db.get_single_value('Global Defaults', 'default_company')
+ doctypes = ['Clinical Procedure', 'Inpatient Record', 'Lab Test', 'Sample Collection' 'Patient Appointment', 'Patient Encounter', 'Vital Signs', 'Therapy Session', 'Therapy Plan', 'Patient Assessment']
+ for entry in doctypes:
+ if frappe.db.exists('DocType', entry):
+ frappe.reload_doc('Healthcare', 'doctype', entry)
+ frappe.db.sql("update `tab{dt}` set company = {company} where ifnull(company, '') = ''".format(dt=entry, company=frappe.db.escape(company)))
diff --git a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py
new file mode 100644
index 00000000000..331c5590e58
--- /dev/null
+++ b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py
@@ -0,0 +1,42 @@
+
+# Copyright (c) 2019, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+from frappe.utils import add_to_date
+from frappe.utils.dashboard import get_config, make_records
+
+def execute():
+ frappe.reload_doc("manufacturing", "doctype", "work_order")
+ frappe.reload_doc("manufacturing", "doctype", "work_order_item")
+ frappe.reload_doc("manufacturing", "doctype", "job_card")
+
+ data = frappe.get_all("Work Order",
+ filters = {
+ "docstatus": 1,
+ "status": ("in", ["In Process", "Completed"])
+ })
+
+ for d in data:
+ doc = frappe.get_doc("Work Order", d.name)
+ doc.set_actual_dates()
+ doc.db_set("actual_start_date", doc.actual_start_date, update_modified=False)
+
+ if doc.status == "Completed":
+ frappe.db.set_value("Work Order", d.name, {
+ "actual_end_date": doc.actual_end_date,
+ "lead_time": doc.lead_time
+ }, update_modified=False)
+
+ if not doc.planned_end_date:
+ planned_end_date = add_to_date(doc.planned_start_date, minutes=doc.lead_time)
+ doc.db_set("planned_end_date", doc.actual_start_date, update_modified=False)
+
+ frappe.db.sql(""" UPDATE `tabJob Card` as jc, `tabWork Order` as wo
+ SET
+ jc.production_item = wo.production_item, jc.item_name = wo.item_name
+ WHERE
+ jc.work_order = wo.name and IFNULL(jc.production_item, "") = ""
+ """)
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/update_mins_to_first_response.py b/erpnext/patches/v7_0/update_mins_to_first_response.py
index 1df4b42cedb..16681357e68 100644
--- a/erpnext/patches/v7_0/update_mins_to_first_response.py
+++ b/erpnext/patches/v7_0/update_mins_to_first_response.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import frappe
-from frappe.core.doctype.communication.email import update_mins_to_first_communication
+from frappe.core.doctype.communication.communication import update_mins_to_first_communication
def execute():
frappe.reload_doctype('Issue')
diff --git a/erpnext/projects/dashboard_fixtures.py b/erpnext/projects/dashboard_fixtures.py
new file mode 100644
index 00000000000..d89ffe9d83b
--- /dev/null
+++ b/erpnext/projects/dashboard_fixtures.py
@@ -0,0 +1,50 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+import json
+from frappe import _
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ })
+
+def get_dashboards():
+ return [{
+ "doctype": "Dashboard",
+ "name": "Project",
+ "dashboard_name": "Project",
+ "charts": [
+ { "chart": "Project Summary", "width": "Full" }
+ ]
+ }]
+
+def get_charts():
+ company = frappe.get_doc("Company", get_company_for_dashboards())
+
+ return [
+ {
+ 'doctype': 'Dashboard Chart',
+ 'name': 'Project Summary',
+ 'chart_name': _('Project Summary'),
+ 'chart_type': 'Report',
+ 'report_name': 'Project Summary',
+ 'is_public': 1,
+ 'is_custom': 1,
+ 'filters_json': json.dumps({"company": company.name, "status": "Open"}),
+ 'type': 'Bar',
+ 'custom_options': '{"type": "bar", "colors": ["#fc4f51", "#78d6ff", "#7575ff"], "axisOptions": { "shortenYAxisNumbers": 1}, "barOptions": { "stacked": 1 }}',
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/projects/desk_page/projects/projects.json b/erpnext/projects/desk_page/projects/projects.json
index a07cdffcbeb..d91fe5304a3 100644
--- a/erpnext/projects/desk_page/projects/projects.json
+++ b/erpnext/projects/desk_page/projects/projects.json
@@ -17,18 +17,23 @@
}
],
"category": "Modules",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Project Summary",
+ "label": "Open Projects"
+ }
+ ],
"creation": "2020-03-02 15:46:04.874669",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Projects",
- "modified": "2020-04-01 11:28:51.245756",
+ "modified": "2020-05-28 13:38:19.934937",
"modified_by": "Administrator",
"module": "Projects",
"name": "Projects",
@@ -37,6 +42,7 @@
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#cef6d1",
"format": "{} Assigned",
"label": "Task",
"link_to": "Task",
@@ -44,8 +50,11 @@
"type": "DocType"
},
{
+ "color": "#ffe8cd",
+ "format": "{} Open",
"label": "Project",
"link_to": "Project",
+ "stats_filter": "{\n \"status\": \"Open\"\n}",
"type": "DocType"
},
{
@@ -57,6 +66,11 @@
"label": "Project Billing Summary",
"link_to": "Project Billing Summary",
"type": "Report"
+ },
+ {
+ "label": "Project Dashboard",
+ "link_to": "Project",
+ "type": "Dashboard"
}
]
}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index 58629634968..3570a0f2be4 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -18,7 +18,7 @@ frappe.ui.form.on("Project", {
};
},
onload: function (frm) {
- var so = frm.get_docfield("Project", "sales_order");
+ var so = frappe.meta.get_docfield("Project", "sales_order");
so.get_route_options_for_new_doc = function (field) {
if (frm.is_new()) return;
return {
@@ -135,4 +135,4 @@ function open_form(frm, doctype, child_doctype, parentfield) {
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
});
-}
+}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index 3eea390ff31..defc18bf4e9 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -258,7 +258,12 @@ var calculate_end_time = function(frm, cdt, cdn) {
var update_billing_hours = function(frm, cdt, cdn){
var child = locals[cdt][cdn];
- if(!child.billable) frappe.model.set_value(cdt, cdn, 'billing_hours', 0.0);
+ if(!child.billable) {
+ frappe.model.set_value(cdt, cdn, 'billing_hours', 0.0);
+ } else {
+ // bill all hours by default
+ frappe.model.set_value(cdt, cdn, "billing_hours", child.hours);
+ }
};
var update_time_rates = function(frm, cdt, cdn){
diff --git a/erpnext/projects/report/project_summary/__init__.py b/erpnext/projects/report/project_summary/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/projects/report/project_summary/project_summary.js b/erpnext/projects/report/project_summary/project_summary.js
new file mode 100644
index 00000000000..414b7b206a1
--- /dev/null
+++ b/erpnext/projects/report/project_summary/project_summary.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Project Summary"] = {
+ "filters": [
+ {
+ "fieldname": "company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": frappe.defaults.get_user_default("Company"),
+ "reqd": 1
+ },
+ {
+ "fieldname": "is_active",
+ "label": __("Is Active"),
+ "fieldtype": "Select",
+ "options": "\nYes\nNo",
+ "default": "Yes",
+ },
+ {
+ "fieldname": "status",
+ "label": __("Status"),
+ "fieldtype": "Select",
+ "options": "\nOpen\nCompleted\nCancelled",
+ "default": "Open"
+ },
+ {
+ "fieldname": "project_type",
+ "label": __("Project Type"),
+ "fieldtype": "Link",
+ "options": "Project Type"
+ },
+ {
+ "fieldname": "priority",
+ "label": __("Priority"),
+ "fieldtype": "Select",
+ "options": "\nLow\nMedium\nHigh"
+ }
+ ]
+};
diff --git a/erpnext/projects/report/project_summary/project_summary.json b/erpnext/projects/report/project_summary/project_summary.json
new file mode 100644
index 00000000000..0b18b3e2784
--- /dev/null
+++ b/erpnext/projects/report/project_summary/project_summary.json
@@ -0,0 +1,27 @@
+{
+ "add_total_row": 0,
+ "creation": "2020-05-04 19:31:54.575765",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-05-04 19:32:53.177213",
+ "modified_by": "Administrator",
+ "module": "Projects",
+ "name": "Project Summary",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Project",
+ "report_name": "Project Summary",
+ "report_type": "Script Report",
+ "roles": [
+ {
+ "role": "Projects User"
+ },
+ {
+ "role": "Projects Manager"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/erpnext/projects/report/project_summary/project_summary.py b/erpnext/projects/report/project_summary/project_summary.py
new file mode 100644
index 00000000000..ea7f1ab2e77
--- /dev/null
+++ b/erpnext/projects/report/project_summary/project_summary.py
@@ -0,0 +1,155 @@
+# 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 _
+
+def execute(filters=None):
+ columns = get_columns()
+ data = []
+
+ data = frappe.db.get_all("Project", filters=filters, fields=["name", 'status', "percent_complete", "expected_start_date", "expected_end_date", "project_type"], order_by="expected_end_date")
+
+ for project in data:
+ project["total_tasks"] = frappe.db.count("Task", filters={"project": project.name})
+ project["completed_tasks"] = frappe.db.count("Task", filters={"project": project.name, "status": "Completed"})
+ project["overdue_tasks"] = frappe.db.count("Task", filters={"project": project.name, "status": "Overdue"})
+
+ chart = get_chart_data(data)
+ report_summary = get_report_summary(data)
+
+ return columns, data, None, chart, report_summary
+
+def get_columns():
+ return [
+ {
+ "fieldname": "name",
+ "label": _("Project"),
+ "fieldtype": "Link",
+ "options": "Project",
+ "width": 200
+ },
+ {
+ "fieldname": "project_type",
+ "label": _("Type"),
+ "fieldtype": "Link",
+ "options": "Project Type",
+ "width": 120
+ },
+ {
+ "fieldname": "status",
+ "label": _("Status"),
+ "fieldtype": "Data",
+ "width": 120
+ },
+ {
+ "fieldname": "total_tasks",
+ "label": _("Total Tasks"),
+ "fieldtype": "Data",
+ "width": 120
+ },
+ {
+ "fieldname": "completed_tasks",
+ "label": _("Tasks Completed"),
+ "fieldtype": "Data",
+ "width": 120
+ },
+ {
+ "fieldname": "overdue_tasks",
+ "label": _("Tasks Overdue"),
+ "fieldtype": "Data",
+ "width": 120
+ },
+ {
+ "fieldname": "percent_complete",
+ "label": _("Completion"),
+ "fieldtype": "Data",
+ "width": 120
+ },
+ {
+ "fieldname": "expected_start_date",
+ "label": _("Start Date"),
+ "fieldtype": "Date",
+ "width": 120
+ },
+ {
+ "fieldname": "expected_end_date",
+ "label": _("End Date"),
+ "fieldtype": "Date",
+ "width": 120
+ },
+ ]
+
+def get_chart_data(data):
+ labels = []
+ total = []
+ completed = []
+ overdue = []
+
+ for project in data:
+ labels.append(project.name)
+ total.append(project.total_tasks)
+ completed.append(project.completed_tasks)
+ overdue.append(project.overdue_tasks)
+
+ return {
+ "data": {
+ 'labels': labels[:30],
+ 'datasets': [
+ {
+ "name": "Overdue",
+ "values": overdue[:30]
+ },
+ {
+ "name": "Completed",
+ "values": completed[:30]
+ },
+ {
+ "name": "Total Tasks",
+ "values": total[:30]
+ },
+ ]
+ },
+ "type": "bar",
+ "colors": ["#fc4f51", "#78d6ff", "#7575ff"],
+ "barOptions": {
+ "stacked": True
+ }
+ }
+
+def get_report_summary(data):
+ if not data:
+ return None
+
+ avg_completion = sum([project.percent_complete for project in data]) / len(data)
+ total = sum([project.total_tasks for project in data])
+ total_overdue = sum([project.overdue_tasks for project in data])
+ completed = sum([project.completed_tasks for project in data])
+
+ return [
+ {
+ "value": avg_completion,
+ "indicator": "Green" if avg_completion > 50 else "Red",
+ "label": "Average Completion",
+ "datatype": "Percent",
+ },
+ {
+ "value": total,
+ "indicator": "Blue",
+ "label": "Total Tasks",
+ "datatype": "Int",
+ },
+ {
+ "value": completed,
+ "indicator": "Green",
+ "label": "Completed Tasks",
+ "datatype": "Int",
+ },
+ {
+ "value": total_overdue,
+ "indicator": "Green" if total_overdue == 0 else "Red",
+ "label": "Overdue Tasks",
+ "datatype": "Int",
+ }
+ ]
diff --git a/erpnext/public/build.json b/erpnext/public/build.json
index e94d1ffe5c0..2695502269a 100644
--- a/erpnext/public/build.json
+++ b/erpnext/public/build.json
@@ -23,8 +23,6 @@
"public/js/queries.js",
"public/js/sms_manager.js",
"public/js/utils/party.js",
- "public/js/templates/address_list.html",
- "public/js/templates/contact_list.html",
"public/js/controllers/stock_controller.js",
"public/js/payment/payments.js",
"public/js/controllers/taxes_and_totals.js",
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 9c561894764..a4cc68b3e2c 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -73,6 +73,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
me.frm.set_query('contact_person', erpnext.queries.contact_query);
me.frm.set_query('supplier_address', erpnext.queries.address_query);
+ me.frm.set_query('billing_address', erpnext.queries.company_address_query);
+
if(this.frm.fields_dict.supplier) {
this.frm.set_query("supplier", function() {
return{ query: "erpnext.controllers.queries.supplier_query" }});
@@ -283,6 +285,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
"shipping_address_display", true);
},
+ billing_address: function() {
+ erpnext.utils.get_address_display(this.frm, "billing_address",
+ "billing_address_display", true);
+ },
+
tc_name: function() {
this.get_terms();
},
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 28c2102aef5..ca897dd4b17 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -552,7 +552,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if (show_batch_dialog)
return frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"])
.then((r) => {
- if(r.message.has_batch_no || r.message.has_serial_no) {
+ if (r.message &&
+ (r.message.has_batch_no || r.message.has_serial_no)) {
frappe.flags.hide_serial_batch_dialog = false;
}
});
@@ -917,7 +918,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
shipping_rule: function() {
var me = this;
- if(this.frm.doc.shipping_rule && this.frm.doc.shipping_address) {
+ if(this.frm.doc.shipping_rule) {
return this.frm.call({
doc: this.frm.doc,
method: "apply_shipping_rule",
@@ -1652,8 +1653,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if(!r.exc) {
$.each(me.frm.doc.items || [], function(i, item) {
if(item.item_code && r.message.hasOwnProperty(item.item_code)) {
- item.item_tax_template = r.message[item.item_code].item_tax_template;
- item.item_tax_rate = r.message[item.item_code].item_tax_rate;
+ if (!item.item_tax_template) {
+ item.item_tax_template = r.message[item.item_code].item_tax_template;
+ item.item_tax_rate = r.message[item.item_code].item_tax_rate;
+ }
me.add_taxes_from_item_tax_template(item.item_tax_rate);
} else {
item.item_tax_template = "";
@@ -1709,7 +1712,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
set_gross_profit: function(item) {
- if (this.frm.doc.doctype == "Sales Order" && item.valuation_rate) {
+ if (["Sales Order", "Quotation"].includes(this.frm.doc.doctype) && item.valuation_rate) {
var rate = flt(item.rate) * flt(this.frm.doc.conversion_rate || 1);
item.gross_profit = flt(((rate - item.valuation_rate) * item.stock_qty), precision("amount", item));
}
diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js
index 296c6280d84..d89d4712e6d 100644
--- a/erpnext/public/js/financial_statements.js
+++ b/erpnext/public/js/financial_statements.js
@@ -47,6 +47,16 @@ erpnext.financial_statements = {
// dropdown for links to other financial statements
erpnext.financial_statements.filters = get_filters()
+ let fiscal_year = frappe.defaults.get_user_default("fiscal_year")
+
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ period_start_date: fy.year_start_date,
+ period_end_date: fy.year_end_date
+ });
+ });
+
report.page.add_inner_button(__("Balance Sheet"), function() {
var filters = report.get_values();
frappe.set_route('query-report', 'Balance Sheet', {company: filters.company});
@@ -62,7 +72,7 @@ erpnext.financial_statements = {
}
};
-function get_filters(){
+function get_filters() {
let filters = [
{
"fieldname":"company",
@@ -99,7 +109,6 @@ function get_filters(){
"fieldname":"period_start_date",
"label": __("Start Date"),
"fieldtype": "Date",
- "default": frappe.datetime.nowdate(),
"hidden": 1,
"reqd": 1
},
@@ -107,7 +116,6 @@ function get_filters(){
"fieldname":"period_end_date",
"label": __("End Date"),
"fieldtype": "Date",
- "default": frappe.datetime.add_months(frappe.datetime.nowdate(), 12),
"hidden": 1,
"reqd": 1
},
@@ -162,15 +170,6 @@ function get_filters(){
}
]
- erpnext.dimension_filters.forEach((dimension) => {
- filters.push({
- "fieldname": dimension["fieldname"],
- "label": __(dimension["label"]),
- "fieldtype": "Link",
- "options": dimension["document_type"]
- });
- });
-
return filters;
}
diff --git a/erpnext/public/js/purchase_trends_filters.js b/erpnext/public/js/purchase_trends_filters.js
index cd767f5d167..c786a8674e6 100644
--- a/erpnext/public/js/purchase_trends_filters.js
+++ b/erpnext/public/js/purchase_trends_filters.js
@@ -51,7 +51,10 @@ erpnext.get_purchase_trends_filters = function() {
{ "value": "Supplier Group", "label": __("Supplier Group") },
{ "value": "Project", "label": __("Project") }
],
- "default": "Item"
+ "default": "Item",
+ "dashboard_config": {
+ "read_only": 1
+ }
},
{
"fieldname":"group_by",
diff --git a/erpnext/public/js/sales_trends_filters.js b/erpnext/public/js/sales_trends_filters.js
index b272fdd5fb0..b9c4dca9130 100644
--- a/erpnext/public/js/sales_trends_filters.js
+++ b/erpnext/public/js/sales_trends_filters.js
@@ -27,7 +27,10 @@ erpnext.get_sales_trends_filters = function() {
{ "value": "Territory", "label": __("Territory") },
{ "value": "Project", "label": __("Project") }
],
- "default": "Item"
+ "default": "Item",
+ "dashboard_config": {
+ "read_only": 1,
+ }
},
{
"fieldname":"group_by",
diff --git a/erpnext/public/js/templates/address_list.html b/erpnext/public/js/templates/address_list.html
deleted file mode 100644
index 0f967b67a0f..00000000000
--- a/erpnext/public/js/templates/address_list.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-{% for(var i=0, l=addr_list.length; i
-
- {%= i+1 %}. {%= addr_list[i].address_title %}{% if(addr_list[i].address_type!="Other") { %}
- ({%= __(addr_list[i].address_type) %}) {% } %}
- {% if(addr_list[i].is_primary_address) { %}
- ({%= __("Primary") %}) {% } %}
- {% if(addr_list[i].is_shipping_address) { %}
- ({%= __("Shipping") %}) {% } %}
-
-
- {%= __("Edit") %}
-
- {%= addr_list[i].display %}
-
-{% } %}
-{% if(!addr_list.length) { %}
-{%= __("No address added yet.") %}
-{% } %}
-{{ __("New Address") }}
\ No newline at end of file
diff --git a/erpnext/public/js/templates/contact_list.html b/erpnext/public/js/templates/contact_list.html
deleted file mode 100644
index 7e6969163b7..00000000000
--- a/erpnext/public/js/templates/contact_list.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-{% for(var i=0, l=contact_list.length; i
-
- {%= contact_list[i].first_name %} {%= contact_list[i].last_name %}
- {% if(contact_list[i].is_primary_contact) { %}
- ({%= __("Primary") %})
- {% } %}
- {% if(contact_list[i].designation){ %}
- – {%= contact_list[i].designation %}
- {% } %}
-
- {%= __("Edit") %}
-
- {% if (contact_list[i].phones || contact_list[i].email_ids) { %}
-
- {% if(contact_list[i].phone) { %}
- {%= __("Phone") %}: {%= contact_list[i].phone %} ({%= __("Primary") %})
- {% endif %}
- {% if(contact_list[i].mobile_no) { %}
- {%= __("Mobile No") %}: {%= contact_list[i].mobile_no %} ({%= __("Primary") %})
- {% endif %}
- {% if(contact_list[i].phone_nos) { %}
- {% for(var j=0, k=contact_list[i].phone_nos.length; j
- {% } %}
- {% endif %}
-
-
- {% if(contact_list[i].email_id) { %}
- {%= __("Email") %}: {%= contact_list[i].email_id %} ({%= __("Primary") %})
- {% endif %}
- {% if(contact_list[i].email_ids) { %}
- {% for(var j=0, k=contact_list[i].email_ids.length; j
- {% } %}
- {% endif %}
-
- {% endif %}
-
- {% if (contact_list[i].address) { %}
- {%= __("Address") %}: {%= contact_list[i].address %}
- {% endif %}
-
-
-{% } %}
-{% if(!contact_list.length) { %}
-{%= __("No contacts added yet.") %}
-{% } %}
-
- {{ __("New Contact") }}
-
\ No newline at end of file
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 58969f2a9fd..2cd79b5d5e7 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -191,6 +191,23 @@ $.extend(erpnext.utils, {
})
},
+ add_dimensions: function(report_name, index) {
+ let filters = frappe.query_reports[report_name].filters;
+
+ erpnext.dimension_filters.forEach((dimension) => {
+ let found = filters.some(el => el.fieldname === dimension['fieldname']);
+
+ if (!found) {
+ filters.splice(index, 0 ,{
+ "fieldname": dimension["fieldname"],
+ "label": __(dimension["label"]),
+ "fieldtype": "Link",
+ "options": dimension["document_type"]
+ });
+ }
+ });
+ },
+
make_subscription: function(doctype, docname) {
frappe.call({
method: "frappe.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat",
diff --git a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
index 0849fd7aeb0..7691fe35870 100644
--- a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
+++ b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
@@ -1,10 +1,12 @@
{
- "autoname": "format:MTNG-{date}",
+ "actions": [],
+ "autoname": "naming_series:",
"creation": "2018-10-15 16:25:41.548432",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
+ "naming_series",
"date",
"cb_00",
"status",
@@ -53,9 +55,16 @@
"fieldname": "sb_01",
"fieldtype": "Section Break",
"label": "Minutes"
+ },
+ {
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Naming Series",
+ "options": "MTNG-.YYYY.-.MM.-.DD.-"
}
],
- "modified": "2019-07-13 19:57:40.500541",
+ "links": [],
+ "modified": "2020-05-19 13:18:59.821740",
"modified_by": "Administrator",
"module": "Quality Management",
"name": "Quality Meeting",
diff --git a/erpnext/regional/address_template/templates/taiwan.html b/erpnext/regional/address_template/templates/taiwan.html
new file mode 100644
index 00000000000..1715bea48ae
--- /dev/null
+++ b/erpnext/regional/address_template/templates/taiwan.html
@@ -0,0 +1,4 @@
+{{ country }} {% if pincode %}{{ pincode }} {% endif -%}{{ county }}{{ city }}{{ address_line1 }}{% if address_line2 %}{{ address_line2 }}{% endif -%}
+{% if phone %} Phone: {{ phone }}{% endif -%}
+{% if fax %} Fax: {{ fax }}{% endif -%}
+{% if email_id %} Email: {{ email_id }}{% endif -%}
diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
index 59e955c23f4..c1680c4b492 100644
--- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
+++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
@@ -1,5 +1,4 @@
{
- "actions": [],
"creation": "2019-10-15 12:33:21.845329",
"doctype": "DocType",
"editable_grid": 1,
@@ -92,8 +91,7 @@
"label": "Upload XML Invoices"
}
],
- "links": [],
- "modified": "2019-12-10 16:37:26.793398",
+ "modified": "2020-05-25 21:32:49.064579",
"modified_by": "Administrator",
"module": "Regional",
"name": "Import Supplier Invoice",
diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
index 6784ea8a5bc..31a7545a0df 100644
--- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
+++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.py
@@ -58,13 +58,14 @@ class ImportSupplierInvoice(Document):
"naming_series": self.invoice_series,
"document_type": line.TipoDocumento.text,
"bill_date": get_datetime_str(line.Data.text),
- "invoice_no": line.Numero.text,
+ "bill_no": line.Numero.text,
"total_discount": 0,
"items": [],
"buying_price_list": self.default_buying_price_list
}
- if not invoices_args.get("invoice_no", ''): return
+ if not invoices_args.get("bill_no", ''):
+ frappe.throw(_("Numero has not set in the XML file"))
supp_dict = get_supplier_details(file_content)
invoices_args["destination_code"] = get_destination_code_from_file(file_content)
@@ -249,7 +250,7 @@ def create_supplier(supplier_group, args):
return existing_supplier_name
else:
-
+
new_supplier = frappe.new_doc("Supplier")
new_supplier.supplier_name = re.sub('&', '&', args.supplier)
new_supplier.supplier_group = supplier_group
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 33098587c2a..3085a310c41 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -251,8 +251,7 @@ def get_tax_template_for_sez(party_details, master_doctype, company, party_type)
def calculate_annual_eligible_hra_exemption(doc):
- basic_component = frappe.get_cached_value('Company', doc.company, "basic_component")
- hra_component = frappe.get_cached_value('Company', doc.company, "hra_component")
+ basic_component, hra_component = frappe.db.get_value('Company', doc.company, ["basic_component", "hra_component"])
if not (basic_component and hra_component):
frappe.throw(_("Please mention Basic and HRA component in Company"))
annual_exemption, monthly_exemption, hra_amount = 0, 0, 0
@@ -616,8 +615,9 @@ def get_transport_details(data, doc):
data.transDocDate = frappe.utils.formatdate(doc.lr_date, 'dd/mm/yyyy')
if doc.gst_transporter_id:
- validate_gstin_check_digit(doc.gst_transporter_id, label='GST Transporter ID')
- data.transporterId = doc.gst_transporter_id
+ if doc.gst_transporter_id[0:2] != "88":
+ validate_gstin_check_digit(doc.gst_transporter_id, label='GST Transporter ID')
+ data.transporterId = doc.gst_transporter_id
return data
diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py
index 2d0ad66b0a0..6ab73413df2 100644
--- a/erpnext/regional/italy/setup.py
+++ b/erpnext/regional/italy/setup.py
@@ -7,11 +7,13 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
+from frappe.permissions import add_permission, update_permission_property
from erpnext.regional.italy import fiscal_regimes, tax_exemption_reasons, mode_of_payment_codes, vat_collectability_options
def setup(company=None, patch=True):
make_custom_fields()
setup_report()
+ add_permissions()
def make_custom_fields(update=True):
invoice_item_fields = [
@@ -200,3 +202,21 @@ def setup_report():
dict(role='Accounts Manager')
]
)).insert()
+
+def add_permissions():
+ doctype = 'Import Supplier Invoice'
+ add_permission(doctype, 'All', 0)
+
+ for role in ('Accounts Manager', 'Accounts User','Purchase User', 'Auditor'):
+ add_permission(doctype, role, 0)
+ update_permission_property(doctype, role, 0, 'print', 1)
+ update_permission_property(doctype, role, 0, 'report', 1)
+
+ if role in ('Accounts Manager', 'Accounts User'):
+ update_permission_property(doctype, role, 0, 'write', 1)
+ update_permission_property(doctype, role, 0, 'create', 1)
+
+ update_permission_property(doctype, 'Accounts Manager', 0, 'delete', 1)
+ add_permission(doctype, 'Accounts Manager', 1)
+ update_permission_property(doctype, 'Accounts Manager', 1, 'write', 1)
+ update_permission_property(doctype, 'Accounts Manager', 1, 'create', 1)
\ No newline at end of file
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index fd1cc58c20a..43b1ea83eb9 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -117,12 +117,18 @@ class Gstr1Report(object):
else:
row.append(invoice_details.get(fieldname))
taxable_value = 0
+
+ if invoice in self.cgst_igst_invoices:
+ division_factor = 2
+ else:
+ division_factor = 1
+
for item_code, net_amount in self.invoice_items.get(invoice).items():
- if item_code in items:
- if self.item_tax_rate.get(invoice) and tax_rate in self.item_tax_rate.get(invoice, {}).get(item_code, []):
- taxable_value += abs(net_amount)
- elif not self.item_tax_rate.get(invoice):
- taxable_value += abs(net_amount)
+ if item_code in items:
+ if self.item_tax_rate.get(invoice) and tax_rate/division_factor in self.item_tax_rate.get(invoice, {}).get(item_code, []):
+ taxable_value += abs(net_amount)
+ elif not self.item_tax_rate.get(invoice):
+ taxable_value += abs(net_amount)
row += [tax_rate or 0, taxable_value]
@@ -196,7 +202,7 @@ class Gstr1Report(object):
if d.item_code not in self.invoice_items.get(d.parent, {}):
self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code,
sum(i.get('base_net_amount', 0) for i in items
- if i.item_code == d.item_code and i.parent == d.parent))
+ if i.item_code == d.item_code and i.parent == d.parent))
item_tax_rate = {}
@@ -221,6 +227,8 @@ class Gstr1Report(object):
self.items_based_on_tax_rate = {}
self.invoice_cess = frappe._dict()
+ self.cgst_igst_invoices = []
+
unidentified_gst_accounts = []
for parent, account, item_wise_tax_detail, tax_amount in self.tax_details:
if account in self.gst_accounts.cess_account:
@@ -243,6 +251,8 @@ class Gstr1Report(object):
tax_rate = tax_amounts[0]
if cgst_or_sgst:
tax_rate *= 2
+ if parent not in self.cgst_igst_invoices:
+ self.cgst_igst_invoices.append(parent)
rate_based_dict = self.items_based_on_tax_rate\
.setdefault(parent, {}).setdefault(tax_rate, [])
diff --git a/erpnext/regional/united_arab_emirates/utils.py b/erpnext/regional/united_arab_emirates/utils.py
index a01c6ceec36..772bbf5914b 100644
--- a/erpnext/regional/united_arab_emirates/utils.py
+++ b/erpnext/regional/united_arab_emirates/utils.py
@@ -1,6 +1,8 @@
from __future__ import unicode_literals
+import frappe
from frappe.utils import flt
from erpnext.controllers.taxes_and_totals import get_itemised_tax
+from six import iteritems
def update_itemised_tax_data(doc):
if not doc.taxes: return
@@ -9,7 +11,14 @@ def update_itemised_tax_data(doc):
for row in doc.items:
tax_rate = 0.0
- if itemised_tax.get(row.item_code):
+ item_tax_rate = frappe.parse_json(row.item_tax_rate)
+
+ # First check if tax rate is present
+ # If not then look up in item_wise_tax_detail
+ if item_tax_rate:
+ for account, rate in iteritems(item_tax_rate):
+ tax_rate += rate
+ elif itemised_tax.get(row.item_code):
tax_rate = sum([tax.get('tax_rate', 0) for d, tax in itemised_tax.get(row.item_code).items()])
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
diff --git a/erpnext/selling/desk_page/selling/selling.json b/erpnext/selling/desk_page/selling/selling.json
index a20806b264e..9ec634354d3 100644
--- a/erpnext/selling/desk_page/selling/selling.json
+++ b/erpnext/selling/desk_page/selling/selling.json
@@ -29,7 +29,7 @@
"category": "Modules",
"charts": [
{
- "chart_name": "Income",
+ "chart_name": "Incoming Bills (Purchase Invoice)",
"label": "Income"
}
],
@@ -39,11 +39,11 @@
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 1,
"idx": 0,
"is_standard": 1,
"label": "Selling",
- "modified": "2020-04-01 11:28:51.047373",
+ "modified": "2020-06-03 13:23:24.861706",
"modified_by": "Administrator",
"module": "Selling",
"name": "Selling",
@@ -52,18 +52,27 @@
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#ffe8cd",
+ "format": "{} Draft",
"label": "Sales Invoice",
"link_to": "Sales Invoice",
+ "stats_filter": "{ \"status\": \"Draft\" }",
"type": "DocType"
},
{
+ "color": "#ffe8cd",
+ "format": "{} To Deliver",
"label": "Sales Order",
"link_to": "Sales Order",
+ "stats_filter": "{\"Status\": \"To Deliver and Bill\"}",
"type": "DocType"
},
{
+ "color": "#cef6d1",
+ "format": "{} Open",
"label": "Quotation",
"link_to": "Quotation",
+ "stats_filter": "{ \"Status\": \"Open\" }",
"type": "DocType"
},
{
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 50e719f02e8..ac3bc201e96 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -3,16 +3,19 @@
from __future__ import unicode_literals
import frappe
+import json
from frappe.model.naming import set_name_by_naming_series
-from frappe import _, msgprint, throw
+from frappe import _, msgprint
import frappe.defaults
-from frappe.utils import flt, cint, cstr, today
+from frappe.utils import flt, cint, cstr, today, get_formatted_email
from frappe.desk.reportview import build_match_conditions, get_filters_cond
from erpnext.utilities.transaction_base import TransactionBase
from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this
from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
from frappe.model.rename_doc import update_linked_doctypes
from frappe.model.mapper import get_mapped_doc
+from frappe.utils.user import get_users_with_role
+
class Customer(TransactionBase):
def get_feed(self):
@@ -165,6 +168,10 @@ class Customer(TransactionBase):
contact.mobile_no = lead.mobile_no
contact.is_primary_contact = 1
contact.append('links', dict(link_doctype='Customer', link_name=self.name))
+ if lead.email_id:
+ contact.append('email_ids', dict(email_id=lead.email_id, is_primary=1))
+ if lead.mobile_no:
+ contact.append('phone_nos', dict(phone=lead.mobile_no, is_primary_mobile_no=1))
contact.flags.ignore_permissions = self.flags.ignore_permissions
contact.autoname()
if not frappe.db.exists("Contact", contact.name):
@@ -333,11 +340,15 @@ def get_loyalty_programs(doc):
return lp_details
def get_customer_list(doctype, txt, searchfield, start, page_len, filters=None):
+ from erpnext.controllers.queries import get_fields
+
if frappe.db.get_default("cust_master_name") == "Customer Name":
fields = ["name", "customer_group", "territory"]
else:
fields = ["name", "customer_name", "customer_group", "territory"]
+ fields = get_fields("Customer", fields)
+
match_conditions = build_match_conditions("Customer")
match_conditions = "and {}".format(match_conditions) if match_conditions else ""
@@ -345,14 +356,17 @@ def get_customer_list(doctype, txt, searchfield, start, page_len, filters=None):
filter_conditions = get_filters_cond(doctype, filters, [])
match_conditions += "{}".format(filter_conditions)
- return frappe.db.sql("""select %s from `tabCustomer` where docstatus < 2
- and (%s like %s or customer_name like %s)
- {match_conditions}
+ return frappe.db.sql("""
+ select %s
+ from `tabCustomer`
+ where docstatus < 2
+ and (%s like %s or customer_name like %s)
+ {match_conditions}
order by
- case when name like %s then 0 else 1 end,
- case when customer_name like %s then 0 else 1 end,
- name, customer_name limit %s, %s""".format(match_conditions=match_conditions) %
- (", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"),
+ case when name like %s then 0 else 1 end,
+ case when customer_name like %s then 0 else 1 end,
+ name, customer_name limit %s, %s
+ """.format(match_conditions=match_conditions) % (", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"),
("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
@@ -367,10 +381,45 @@ def check_credit_limit(customer, company, ignore_outstanding_sales_order=False,
.format(customer, customer_outstanding, credit_limit))
# If not authorized person raise exception
- credit_controller = frappe.db.get_value('Accounts Settings', None, 'credit_controller')
- if not credit_controller or credit_controller not in frappe.get_roles():
- throw(_("Please contact to the user who have Sales Master Manager {0} role")
- .format(" / " + credit_controller if credit_controller else ""))
+ credit_controller_role = frappe.db.get_single_value('Accounts Settings', 'credit_controller')
+ if not credit_controller_role or credit_controller_role not in frappe.get_roles():
+ # form a list of emails for the credit controller users
+ credit_controller_users = get_users_with_role(credit_controller_role or "Sales Master Manager")
+
+ # form a list of emails and names to show to the user
+ credit_controller_users_list = [user for user in credit_controller_users if frappe.db.exists("Employee", {"prefered_email": user})]
+ credit_controller_users = [get_formatted_email(user).replace("<", "(").replace(">", ")") for user in credit_controller_users_list]
+
+ if not credit_controller_users:
+ frappe.throw(_("Please contact your administrator to extend the credit limits for {0}.".format(customer)))
+
+ message = """Please contact any of the following users to extend the credit limits for {0}:
+ """.format(customer, ''.join(credit_controller_users))
+
+ # if the current user does not have permissions to override credit limit,
+ # prompt them to send out an email to the controller users
+ frappe.msgprint(message,
+ title="Notify",
+ raise_exception=1,
+ primary_action={
+ 'label': 'Send Email',
+ 'server_action': 'erpnext.selling.doctype.customer.customer.send_emails',
+ 'args': {
+ 'customer': customer,
+ 'customer_outstanding': customer_outstanding,
+ 'credit_limit': credit_limit,
+ 'credit_controller_users_list': credit_controller_users_list
+ }
+ }
+ )
+
+@frappe.whitelist()
+def send_emails(args):
+ args = json.loads(args)
+ subject = (_("Credit limit reached for customer {0}").format(args.get('customer')))
+ message = (_("Credit limit has been crossed for customer {0} ({1}/{2})")
+ .format(args.get('customer'), args.get('customer_outstanding'), args.get('credit_limit')))
+ frappe.sendmail(recipients=[args.get('credit_controller_users_list')], subject=subject, message=message)
def get_customer_outstanding(customer, company, ignore_outstanding_sales_order=False, cost_center=None):
# Outstanding based on GL Entries
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 7cfec5a046a..0e771c3025a 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -197,9 +197,9 @@ def set_expired_status():
cond = "qo.docstatus = 1 and qo.status != 'Expired' and qo.valid_till < %s"
# check if those QUO have SO against it
so_against_quo = """
- SELECT
+ SELECT
so.name FROM `tabSales Order` so, `tabSales Order Item` so_item
- WHERE
+ WHERE
so_item.docstatus = 1 and so.docstatus = 1
and so_item.parent = so.name
and so_item.prevdoc_docname = qo.name"""
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json
index d50397cfad4..59ae7b23239 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.json
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.json
@@ -48,6 +48,10 @@
"base_net_amount",
"pricing_rules",
"is_free_item",
+ "section_break_43",
+ "valuation_rate",
+ "column_break_45",
+ "gross_profit",
"item_weight_details",
"weight_per_unit",
"total_weight",
@@ -602,12 +606,40 @@
"label": "Against Blanket Order",
"no_copy": 1,
"print_hide": 1
+ },
+ {
+ "fieldname": "section_break_43",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "valuation_rate",
+ "fieldtype": "Currency",
+ "label": "Valuation Rate",
+ "no_copy": 1,
+ "options": "Company:company:default_currency",
+ "print_hide": 1,
+ "read_only": 1,
+ "report_hide": 1
+ },
+ {
+ "fieldname": "column_break_45",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "gross_profit",
+ "fieldtype": "Currency",
+ "label": "Gross Profit",
+ "no_copy": 1,
+ "options": "Company:company:default_currency",
+ "print_hide": 1,
+ "read_only": 1,
+ "report_hide": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-03-30 18:40:28.782720",
+ "modified": "2020-05-19 20:48:43.222229",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation Item",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 45a43c5e7e9..705dcb8e03a 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -34,6 +34,15 @@ frappe.ui.form.on("Sales Order", {
}
};
})
+
+ frm.set_query("bom_no", "items", function(doc, cdt, cdn) {
+ var row = locals[cdt][cdn];
+ return {
+ filters: {
+ "item": row.item_code
+ }
+ }
+ });
},
refresh: function(frm) {
if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed'
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 6462d3bc8c3..b57c4f30981 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -282,6 +282,7 @@
"width": "100px"
},
{
+ "fetch_from": "customer.tax_id",
"fieldname": "tax_id",
"fieldtype": "Data",
"label": "Tax Id",
@@ -1196,7 +1197,7 @@
"idx": 105,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-17 12:50:39.640534",
+ "modified": "2020-05-19 21:39:19.486684",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
index 73f233c537c..e59349926e6 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
@@ -72,6 +72,8 @@
"against_blanket_order",
"blanket_order",
"blanket_order_rate",
+ "manufacturing_section_section",
+ "bom_no",
"planning_section",
"projected_qty",
"actual_qty",
@@ -212,6 +214,7 @@
"fieldtype": "Link",
"label": "UOM",
"options": "UOM",
+ "print_hide": 0,
"reqd": 1
},
{
@@ -764,12 +767,24 @@
"fieldname": "against_blanket_order",
"fieldtype": "Check",
"label": "Against Blanket Order"
- }
+ },
+ {
+ "fieldname": "bom_no",
+ "fieldtype": "Link",
+ "label": "BOM No",
+ "no_copy": 1,
+ "options": "BOM",
+ "print_hide": 1
+ },
+ {
+ "fieldname": "manufacturing_section_section",
+ "fieldtype": "Section Break",
+ "label": "Manufacturing Section"
+ }
],
"idx": 1,
"istable": 1,
- "links": [],
- "modified": "2020-03-05 14:20:28.085117",
+ "modified": "2020-05-15 18:13:43.006493",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",
diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.js b/erpnext/selling/page/sales_funnel/sales_funnel.js
index 85c0cd8bf0c..e3d0a55c3a0 100644
--- a/erpnext/selling/page/sales_funnel/sales_funnel.js
+++ b/erpnext/selling/page/sales_funnel/sales_funnel.js
@@ -90,6 +90,10 @@ erpnext.SalesFunnel = class SalesFunnel {
get_data(btn) {
var me = this;
+ if (!this.company) {
+ frappe.throw(__("Please Select a Company."));
+ }
+
const method_map = {
"sales_funnel": "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data",
"opp_by_lead_source": "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source",
diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.py b/erpnext/selling/page/sales_funnel/sales_funnel.py
index d62e2093c69..dba24ef5b00 100644
--- a/erpnext/selling/page/sales_funnel/sales_funnel.py
+++ b/erpnext/selling/page/sales_funnel/sales_funnel.py
@@ -8,14 +8,23 @@ from frappe import _
from erpnext.accounts.report.utils import convert
import pandas as pd
+def validate_filters(from_date, to_date, company):
+ if from_date and to_date and (from_date >= to_date):
+ frappe.throw(_("To Date must be greater than From Date"))
+
+ if not company:
+ frappe.throw(_("Please Select a Company"))
+
@frappe.whitelist()
def get_funnel_data(from_date, to_date, company):
+ validate_filters(from_date, to_date, company)
+
active_leads = frappe.db.sql("""select count(*) from `tabLead`
where (date(`modified`) between %s and %s)
and status != "Do Not Contact" and company=%s""", (from_date, to_date, company))[0][0]
active_leads += frappe.db.sql("""select count(distinct contact.name) from `tabContact` contact
- left join `tabDynamic Link` dl on (dl.parent=contact.name) where dl.link_doctype='Customer'
+ left join `tabDynamic Link` dl on (dl.parent=contact.name) where dl.link_doctype='Customer'
and (date(contact.modified) between %s and %s) and status != "Passive" """, (from_date, to_date))[0][0]
opportunities = frappe.db.sql("""select count(*) from `tabOpportunity`
@@ -38,6 +47,8 @@ def get_funnel_data(from_date, to_date, company):
@frappe.whitelist()
def get_opp_by_lead_source(from_date, to_date, company):
+ validate_filters(from_date, to_date, company)
+
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability', 'source'])
if opportunities:
@@ -68,11 +79,13 @@ def get_opp_by_lead_source(from_date, to_date, company):
@frappe.whitelist()
def get_pipeline_data(from_date, to_date, company):
+ validate_filters(from_date, to_date, company)
+
opportunities = frappe.get_all("Opportunity", filters=[['status', 'in', ['Open', 'Quotation', 'Replied']], ['company', '=', company], ['transaction_date', 'Between', [from_date, to_date]]], fields=['currency', 'sales_stage', 'opportunity_amount', 'probability'])
if opportunities:
default_currency = frappe.get_cached_value('Global Defaults', 'None', 'default_currency')
-
+
cp_opportunities = [dict(x, **{'compound_amount': (convert(x['opportunity_amount'], x['currency'], default_currency, to_date) * x['probability']/100)}) for x in opportunities]
df = pd.DataFrame(cp_opportunities).groupby(['sales_stage'], as_index=True).agg({'compound_amount': 'sum'}).to_dict()
diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
index 4288b52acac..8967c6bad9f 100644
--- a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
+++ b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
@@ -185,4 +185,4 @@ def get_customer_stats(filters, tree_view=False):
if new_or_repeat == 'new':
customers.append(si.customer)
- return customers_in
\ No newline at end of file
+ return customers_in
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.json b/erpnext/selling/report/sales_analytics/sales_analytics.json
index 71932610a6a..bf9edd6cd49 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.json
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.json
@@ -1,31 +1,31 @@
{
- "add_total_row": 0,
- "creation": "2018-09-21 12:46:29.451048",
- "disable_prepared_report": 0,
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 0,
- "is_standard": "Yes",
- "modified": "2019-05-24 05:37:02.866139",
- "modified_by": "Administrator",
- "module": "Selling",
- "name": "Sales Analytics",
- "owner": "Administrator",
- "prepared_report": 0,
- "ref_doctype": "Sales Order",
- "report_name": "Sales Analytics",
- "report_type": "Script Report",
+ "add_total_row": 0,
+ "creation": "2018-09-21 12:46:29.451048",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2020-04-30 19:49:02.303320",
+ "modified_by": "Administrator",
+ "module": "Selling",
+ "name": "Sales Analytics",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Sales Order",
+ "report_name": "Sales Analytics",
+ "report_type": "Script Report",
"roles": [
{
"role": "Stock User"
- },
+ },
{
"role": "Maintenance User"
- },
+ },
{
"role": "Accounts User"
- },
+ },
{
"role": "Sales Manager"
}
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py
index f1726ab8bf7..97d9322918d 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.py
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.py
@@ -194,6 +194,9 @@ class Analytics(object):
def get_rows(self):
self.data = []
self.get_periodic_data()
+ total_row = {
+ "entity": "Total",
+ }
for entity, period_data in iteritems(self.entity_periodic_data):
row = {
@@ -207,6 +210,9 @@ class Analytics(object):
row[scrub(period)] = amount
total += amount
+ if not total_row.get(scrub(period)): total_row[scrub(period)] = 0
+ total_row[scrub(period)] += amount
+
row["total"] = total
if self.filters.tree_type == "Item":
@@ -214,6 +220,8 @@ class Analytics(object):
self.data.append(row)
+ self.data.append(total_row)
+
def get_rows_by_group(self):
self.get_periodic_data()
out = []
@@ -232,8 +240,10 @@ class Analytics(object):
self.entity_periodic_data.setdefault(d.parent, frappe._dict()).setdefault(period, 0.0)
self.entity_periodic_data[d.parent][period] += amount
total += amount
+
row["total"] = total
out = [row] + out
+
self.data = out
def get_periodic_data(self):
diff --git a/erpnext/selling/report/sales_analytics/test_analytics.py b/erpnext/selling/report/sales_analytics/test_analytics.py
index 4d81a1e4dda..7e8501dcc15 100644
--- a/erpnext/selling/report/sales_analytics/test_analytics.py
+++ b/erpnext/selling/report/sales_analytics/test_analytics.py
@@ -33,6 +33,21 @@ class TestAnalytics(unittest.TestCase):
report = execute(filters)
expected_data = [
+ {
+ 'entity': 'Total',
+ 'apr_2017': 0.0,
+ 'may_2017': 0.0,
+ 'jun_2017': 2000.0,
+ 'jul_2017': 1000.0,
+ 'aug_2017': 0.0,
+ 'sep_2017': 1500.0,
+ 'oct_2017': 1000.0,
+ 'nov_2017': 0.0,
+ 'dec_2017': 0.0,
+ 'jan_2018': 0.0,
+ 'feb_2018': 2000.0,
+ 'mar_2018': 0.0
+ },
{
"entity": "_Test Customer 1",
"entity_name": "_Test Customer 1",
@@ -134,6 +149,21 @@ class TestAnalytics(unittest.TestCase):
report = execute(filters)
expected_data = [
+ {
+ 'entity': 'Total',
+ 'apr_2017': 0.0,
+ 'may_2017': 0.0,
+ 'jun_2017': 20.0,
+ 'jul_2017': 10.0,
+ 'aug_2017': 0.0,
+ 'sep_2017': 15.0,
+ 'oct_2017': 10.0,
+ 'nov_2017': 0.0,
+ 'dec_2017': 0.0,
+ 'jan_2018': 0.0,
+ 'feb_2018': 20.0,
+ 'mar_2018': 0.0
+ },
{
"entity": "_Test Customer 1",
"entity_name": "_Test Customer 1",
diff --git a/erpnext/setup/desk_page/getting_started/getting_started.json b/erpnext/setup/desk_page/home/home.json
similarity index 97%
rename from erpnext/setup/desk_page/getting_started/getting_started.json
rename to erpnext/setup/desk_page/home/home.json
index 63d8984c405..63cd5c5ceca 100644
--- a/erpnext/setup/desk_page/getting_started/getting_started.json
+++ b/erpnext/setup/desk_page/home/home.json
@@ -47,26 +47,20 @@
}
],
"category": "Modules",
- "charts": [
- {
- "chart_name": "Bank Balance",
- "label": "Bank Balance"
- }
- ],
+ "charts": [],
"creation": "2020-01-23 13:46:38.833076",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
"idx": 0,
"is_standard": 1,
- "label": "Getting Started",
- "modified": "2020-04-01 11:30:19.763099",
+ "label": "Home",
+ "modified": "2020-05-11 10:20:37.358701",
"modified_by": "Administrator",
"module": "Setup",
- "name": "Getting Started",
+ "name": "Home",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 1,
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 0fbe49eab76..875904fe6fe 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -107,6 +107,9 @@ frappe.ui.form.on("Company", {
erpnext.company.set_chart_of_accounts_options(frm.doc);
+ if (!frappe.user.has_role('System Manager')) {
+ frm.get_field("delete_company_transactions").hide();
+ }
},
make_default_tax_template: function(frm) {
@@ -134,7 +137,7 @@ frappe.ui.form.on("Company", {
var d = frappe.prompt({
fieldtype:"Data",
fieldname: "company_name",
- label: __("Please re-type company name to confirm"),
+ label: __("Please enter the company name to confirm"),
reqd: 1,
description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.")
},
diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py
index b37cc17ba98..29f6c3731d7 100644
--- a/erpnext/setup/doctype/company/test_company.py
+++ b/erpnext/setup/doctype/company/test_company.py
@@ -47,9 +47,7 @@ class TestCompany(unittest.TestCase):
frappe.delete_doc("Company", "COA from Existing Company")
def test_coa_based_on_country_template(self):
- countries = ["India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France",
- "Guatemala", "Indonesia", "Italy", "Mexico", "Nicaragua", "Netherlands", "Singapore",
- "Brazil", "Argentina", "Hungary", "Taiwan"]
+ countries = ["Canada", "Germany", "France"]
for country in countries:
templates = get_charts_for_country(country)
diff --git a/erpnext/setup/setup_wizard/data/dashboard_charts.py b/erpnext/setup/setup_wizard/data/dashboard_charts.py
index b182dfc103f..9ce64eb9d92 100644
--- a/erpnext/setup/setup_wizard/data/dashboard_charts.py
+++ b/erpnext/setup/setup_wizard/data/dashboard_charts.py
@@ -32,7 +32,14 @@ def get_default_dashboards():
{ "chart": "Expenses" },
{ "chart": "Patient Appointments" }
]
- }
+ },
+ {
+ "doctype": "Dashboard",
+ "dashboard_name": "Project",
+ "charts": [
+ { "chart": "Project Summary", "width": "Full" }
+ ]
+ },
],
"Charts": [
{
@@ -109,6 +116,17 @@ def get_default_dashboards():
"type": "Bar",
"width": "Half"
},
+ {
+ 'doctype': 'Dashboard Chart',
+ 'name': 'Project Summary',
+ 'chart_name': 'Project Summary',
+ 'chart_type': 'Report',
+ 'report_name': 'Project Summary',
+ 'is_public': 1,
+ 'filters_json': json.dumps({"company": company.name, "status": "Open"}),
+ 'type': 'Bar',
+ 'custom_options': '{"type": "bar", "colors": ["#fc4f51", "#78d6ff", "#7575ff"], "axisOptions": { "shortenYAxisNumbers": 1}, "barOptions": { "stacked": 1 }}',
+ },
{
"doctype": "Dashboard Chart",
"time_interval": "Daily",
diff --git a/erpnext/setup/setup_wizard/data/uom_conversion_data.json b/erpnext/setup/setup_wizard/data/uom_conversion_data.json
index 174ecd5903e..27a917d9db8 100644
--- a/erpnext/setup/setup_wizard/data/uom_conversion_data.json
+++ b/erpnext/setup/setup_wizard/data/uom_conversion_data.json
@@ -1571,5 +1571,19 @@
"to_uom": "Parts Per Million",
"abbr": "ppm",
"value": "10000"
+ },
+ {
+ "category": "Mass",
+ "from_uom": "Pound",
+ "to_uom": "Ounce",
+ "abbr": "oz",
+ "value": "16"
+ },
+ {
+ "category": "Mass",
+ "from_uom": "Gram",
+ "to_uom": "Ounce",
+ "abbr": "oz",
+ "value": "0.035274"
}
]
\ No newline at end of file
diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py
index 3be6f448325..0d70d91f739 100644
--- a/erpnext/setup/setup_wizard/operations/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py
@@ -336,13 +336,14 @@ def add_uom_data():
"category_name": _(d.get("category"))
}).insert(ignore_permissions=True)
- uom_conversion = frappe.get_doc({
- "doctype": "UOM Conversion Factor",
- "category": _(d.get("category")),
- "from_uom": _(d.get("from_uom")),
- "to_uom": _(d.get("to_uom")),
- "value": d.get("value")
- }).insert(ignore_permissions=True)
+ if not frappe.db.exists("UOM Conversion Factor", {"from_uom": _(d.get("from_uom")), "to_uom": _(d.get("to_uom"))}):
+ uom_conversion = frappe.get_doc({
+ "doctype": "UOM Conversion Factor",
+ "category": _(d.get("category")),
+ "from_uom": _(d.get("from_uom")),
+ "to_uom": _(d.get("to_uom")),
+ "value": d.get("value")
+ }).insert(ignore_permissions=True)
def add_market_segments():
records = [
@@ -485,8 +486,6 @@ def install_defaults(args=None):
# bank account same as a CoA entry
pass
- add_dashboards()
-
# Now, with fixtures out of the way, onto concrete stuff
records = [
@@ -504,27 +503,6 @@ def install_defaults(args=None):
make_records(records)
-def add_dashboards():
- from erpnext.setup.setup_wizard.data.dashboard_charts import get_company_for_dashboards
-
- if not get_company_for_dashboards():
- return
-
- from erpnext.setup.setup_wizard.data.dashboard_charts import get_default_dashboards
- from frappe.modules.import_file import import_file_by_path
-
- dashboard_data = get_default_dashboards()
-
- # create account balance timeline before creating dashbaord charts
- doctype = "dashboard_chart_source"
- docname = "account_balance_timeline"
- folder = os.path.dirname(frappe.get_module("erpnext.accounts").__file__)
- doc_path = os.path.join(folder, doctype, docname, docname) + ".json"
- import_file_by_path(doc_path, force=0, for_sync=True)
-
- make_records(dashboard_data["Charts"])
- make_records(dashboard_data["Dashboards"])
-
def get_fy_details(fy_start_date, fy_end_date):
start_year = getdate(fy_start_date).year
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index e11e1bb5dcd..7096c17fb18 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -319,7 +319,7 @@ def apply_cart_settings(party=None, quotation=None):
def set_price_list_and_rate(quotation, cart_settings):
"""set price list based on billing territory"""
- _set_price_list(quotation, cart_settings)
+ _set_price_list(cart_settings, quotation)
# reset values
quotation.price_list_currency = quotation.currency = \
@@ -334,23 +334,24 @@ def set_price_list_and_rate(quotation, cart_settings):
# set it in cookies for using in product page
frappe.local.cookie_manager.set_cookie("selling_price_list", quotation.selling_price_list)
-def _set_price_list(quotation, cart_settings):
+def _set_price_list(cart_settings, quotation=None):
"""Set price list based on customer or shopping cart default"""
from erpnext.accounts.party import get_default_price_list
-
- # check if customer price list exists
+ party_name = quotation.get("party_name") if quotation else get_party().get("name")
selling_price_list = None
- if quotation.party_name:
- selling_price_list = frappe.db.get_value('Customer', quotation.party_name, 'default_price_list')
- # else check for territory based price list
+ # check if default customer price list exists
+ if party_name:
+ selling_price_list = get_default_price_list(frappe.get_doc("Customer", party_name))
+
+ # check default price list in shopping cart
if not selling_price_list:
selling_price_list = cart_settings.price_list
- if not selling_price_list and quotation.party_name:
- selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
+ if quotation:
+ quotation.selling_price_list = selling_price_list
- quotation.selling_price_list = selling_price_list
+ return selling_price_list
def set_taxes(quotation, cart_settings):
"""set taxes based on billing territory"""
@@ -541,27 +542,31 @@ def show_terms(doc):
return doc.tc_name
@frappe.whitelist(allow_guest=True)
-def apply_coupon_code(applied_code,applied_referral_sales_partner):
+def apply_coupon_code(applied_code, applied_referral_sales_partner):
quotation = True
- if applied_code:
- coupon_list=frappe.get_all('Coupon Code', filters={"docstatus": ("<", "2"), 'coupon_code':applied_code }, fields=['name'])
- if coupon_list:
- coupon_name=coupon_list[0].name
- from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code
- validate_coupon_code(coupon_name)
- quotation = _get_cart_quotation()
- quotation.coupon_code=coupon_name
+
+ if not applied_code:
+ frappe.throw(_("Please enter a coupon code"))
+
+ coupon_list = frappe.get_all('Coupon Code', filters={'coupon_code': applied_code})
+ if not coupon_list:
+ frappe.throw(_("Please enter a valid coupon code"))
+
+ coupon_name = coupon_list[0].name
+
+ from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code
+ validate_coupon_code(coupon_name)
+ quotation = _get_cart_quotation()
+ quotation.coupon_code = coupon_name
+ quotation.flags.ignore_permissions = True
+ quotation.save()
+
+ if applied_referral_sales_partner:
+ sales_partner_list = frappe.get_all('Sales Partner', filters={'referral_code': applied_referral_sales_partner})
+ if sales_partner_list:
+ sales_partner_name = sales_partner_list[0].name
+ quotation.referral_sales_partner = sales_partner_name
quotation.flags.ignore_permissions = True
quotation.save()
- if applied_referral_sales_partner:
- sales_partner_list=frappe.get_all('Sales Partner', filters={'docstatus': 0, 'referral_code':applied_referral_sales_partner }, fields=['name'])
- if sales_partner_list:
- sales_partner_name=sales_partner_list[0].name
- quotation.referral_sales_partner=sales_partner_name
- quotation.flags.ignore_permissions = True
- quotation.save()
- else:
- frappe.throw(_("Please enter valid coupon code !!"))
- else:
- frappe.throw(_("Please enter coupon code !!"))
+
return quotation
diff --git a/erpnext/shopping_cart/product_info.py b/erpnext/shopping_cart/product_info.py
index a7da09cb808..7c08f5b5b24 100644
--- a/erpnext/shopping_cart/product_info.py
+++ b/erpnext/shopping_cart/product_info.py
@@ -4,24 +4,28 @@
from __future__ import unicode_literals
import frappe
-from erpnext.shopping_cart.cart import _get_cart_quotation
+from erpnext.shopping_cart.cart import _get_cart_quotation, _set_price_list
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings \
import get_shopping_cart_settings, show_quantity_in_website
from erpnext.utilities.product import get_price, get_qty_in_stock, get_non_stock_item_status
@frappe.whitelist(allow_guest=True)
-def get_product_info_for_website(item_code):
+def get_product_info_for_website(item_code, skip_quotation_creation=False):
"""get product price / stock info for website"""
cart_settings = get_shopping_cart_settings()
if not cart_settings.enabled:
return frappe._dict()
- cart_quotation = _get_cart_quotation()
+ cart_quotation = frappe._dict()
+ if not skip_quotation_creation:
+ cart_quotation = _get_cart_quotation()
+
+ selling_price_list = cart_quotation.get("selling_price_list") if cart_quotation else _set_price_list(cart_settings, None)
price = get_price(
item_code,
- cart_quotation.selling_price_list,
+ selling_price_list,
cart_settings.default_customer_group,
cart_settings.company
)
@@ -40,7 +44,7 @@ def get_product_info_for_website(item_code):
if product_info["price"]:
if frappe.session.user != "Guest":
- item = cart_quotation.get({"item_code": item_code})
+ item = cart_quotation.get({"item_code": item_code}) if cart_quotation else None
if item:
product_info["qty"] = item[0].qty
@@ -51,7 +55,7 @@ def get_product_info_for_website(item_code):
def set_product_info_for_website(item):
"""set product price uom for website"""
- product_info = get_product_info_for_website(item.item_code)
+ product_info = get_product_info_for_website(item.item_code, skip_quotation_creation=True)
if product_info:
item.update(product_info)
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index 4ca43a89b8f..2b80fb8dfa1 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -10,7 +10,6 @@ def boot_session(bootinfo):
"""boot session - send website info if guest"""
bootinfo.custom_css = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
- bootinfo.website_settings = frappe.get_doc('Website Settings')
if frappe.session['user']!='Guest':
update_page_info(bootinfo)
diff --git a/erpnext/stock/dashboard_chart_source/__init__.py b/erpnext/stock/dashboard_chart_source/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/__init__.py b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js
new file mode 100644
index 00000000000..a4137547f7e
--- /dev/null
+++ b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.js
@@ -0,0 +1,14 @@
+frappe.provide('frappe.dashboards.chart_sources');
+
+frappe.dashboards.chart_sources["Warehouse wise Stock Value"] = {
+ method: "erpnext.stock.dashboard_chart_source.warehouse_wise_stock_value.warehouse_wise_stock_value.get",
+ filters: [
+ {
+ fieldname: "company",
+ label: __("Company"),
+ fieldtype: "Link",
+ options: "Company",
+ default: frappe.defaults.get_user_default("Company")
+ }
+ ]
+};
\ No newline at end of file
diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.json b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.json
new file mode 100644
index 00000000000..6d967c0fc00
--- /dev/null
+++ b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.json
@@ -0,0 +1,13 @@
+{
+ "creation": "2020-05-14 14:27:44.108017",
+ "docstatus": 0,
+ "doctype": "Dashboard Chart Source",
+ "idx": 0,
+ "modified": "2020-05-14 14:27:44.108017",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Warehouse wise Stock Value",
+ "owner": "Administrator",
+ "source_name": "Warehouse wise Stock Value ",
+ "timeseries": 0
+}
\ No newline at end of file
diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py
new file mode 100644
index 00000000000..374a34ea7ca
--- /dev/null
+++ b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe, json
+from frappe import _
+from frappe.utils.dashboard import cache_source
+from erpnext.stock.utils import get_stock_value_from_bin
+
+@frappe.whitelist()
+@cache_source
+def get(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None,
+ to_date = None, timespan = None, time_interval = None, heatmap_year = None):
+ labels, datapoints = [], []
+ filters = frappe.parse_json(filters)
+
+ warehouse_filters = [['is_group', '=', 0]]
+ if filters and filters.get("company"):
+ warehouse_filters.append(['company', '=', filters.get("company")])
+
+ warehouses = frappe.get_list("Warehouse", fields=['name'], filters=warehouse_filters, order_by='name')
+
+ for wh in warehouses:
+ balance = get_stock_value_from_bin(warehouse=wh.name)
+ wh["balance"] = balance[0][0]
+
+ warehouses = [x for x in warehouses if not (x.get('balance') == None)]
+
+ if not warehouses:
+ return []
+
+ sorted_warehouse_map = sorted(warehouses, key = lambda i: i['balance'], reverse=True)
+
+ if len(sorted_warehouse_map) > 10:
+ sorted_warehouse_map = sorted_warehouse_map[:10]
+
+ for warehouse in sorted_warehouse_map:
+ labels.append(_(warehouse.get("name")))
+ datapoints.append(warehouse.get("balance"))
+
+ return{
+ "labels": labels,
+ "datasets": [{
+ "name": _("Stock Value"),
+ "values": datapoints
+ }],
+ "type": "bar"
+ }
\ No newline at end of file
diff --git a/erpnext/stock/dashboard_fixtures.py b/erpnext/stock/dashboard_fixtures.py
new file mode 100644
index 00000000000..0f1fd128f0b
--- /dev/null
+++ b/erpnext/stock/dashboard_fixtures.py
@@ -0,0 +1,175 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+import json
+from frappe import _
+from frappe.utils import nowdate
+from erpnext.accounts.utils import get_fiscal_year
+
+def get_data():
+ return frappe._dict({
+ "dashboards": get_dashboards(),
+ "charts": get_charts(),
+ "number_cards": get_number_cards(),
+ })
+
+def get_company_for_dashboards():
+ company = frappe.defaults.get_defaults().company
+ if company:
+ return company
+ else:
+ company_list = frappe.get_list("Company")
+ if company_list:
+ return company_list[0].name
+ return None
+
+company = frappe.get_doc("Company", get_company_for_dashboards())
+fiscal_year = get_fiscal_year(nowdate(), as_dict=1)
+fiscal_year_name = fiscal_year.get("name")
+start_date = str(fiscal_year.get("year_start_date"))
+end_date = str(fiscal_year.get("year_end_date"))
+
+def get_dashboards():
+ return [{
+ "name": "Stock",
+ "dashboard_name": "Stock",
+ "charts": [
+ { "chart": "Warehouse wise Stock Value", "width": "Full"},
+ { "chart": "Purchase Receipt Trends", "width": "Half"},
+ { "chart": "Delivery Trends", "width": "Half"},
+ { "chart": "Oldest Items", "width": "Half"},
+ { "chart": "Item Shortage Summary", "width": "Half"}
+ ],
+ "cards": [
+ { "card": "Total Active Items"},
+ { "card": "Total Warehouses"},
+ { "card": "Total Stock Value"}
+ ]
+ }]
+
+def get_charts():
+ return [
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Purchase Receipt Trends",
+ "time_interval": "Monthly",
+ "chart_name": _("Purchase Receipt Trends"),
+ "timespan": "Last Year",
+ "color": "#7b933d",
+ "value_based_on": "base_net_total",
+ "filters_json": json.dumps([["Purchase Receipt", "docstatus", "=", 1]]),
+ "chart_type": "Sum",
+ "timeseries": 1,
+ "based_on": "posting_date",
+ "owner": "Administrator",
+ "document_type": "Purchase Receipt",
+ "type": "Bar",
+ "width": "Half",
+ "is_public": 1
+ },
+ {
+ "doctype": "Dashboard Chart",
+ "name": "Delivery Trends",
+ "time_interval": "Monthly",
+ "chart_name": _("Delivery Trends"),
+ "timespan": "Last Year",
+ "color": "#7b933d",
+ "value_based_on": "base_net_total",
+ "filters_json": json.dumps([["Delivery Note", "docstatus", "=", 1]]),
+ "chart_type": "Sum",
+ "timeseries": 1,
+ "based_on": "posting_date",
+ "owner": "Administrator",
+ "document_type": "Delivery Note",
+ "type": "Bar",
+ "width": "Half",
+ "is_public": 1
+ },
+ {
+ "name": "Warehouse wise Stock Value",
+ "chart_name": _("Warehouse wise Stock Value"),
+ "chart_type": "Custom",
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({}),
+ "is_custom": 0,
+ "is_public": 1,
+ "owner": "Administrator",
+ "source": "Warehouse wise Stock Value",
+ "type": "Bar"
+ },
+ {
+ "name": "Oldest Items",
+ "chart_name": _("Oldest Items"),
+ "chart_type": "Report",
+ "custom_options": json.dumps({
+ "colors": ["#5e64ff"]
+ }),
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({
+ "company": company.name,
+ "to_date": nowdate(),
+ "show_warehouse_wise_stock": 0
+ }),
+ "is_custom": 1,
+ "is_public": 1,
+ "owner": "Administrator",
+ "report_name": "Stock Ageing",
+ "type": "Bar"
+ },
+ {
+ "name": "Item Shortage Summary",
+ "chart_name": _("Item Shortage Summary"),
+ "chart_type": "Report",
+ "doctype": "Dashboard Chart",
+ "filters_json": json.dumps({
+ "company": company.name
+ }),
+ "is_custom": 1,
+ "is_public": 1,
+ "owner": "Administrator",
+ "report_name": "Item Shortage Report",
+ "type": "Bar"
+ }
+ ]
+
+def get_number_cards():
+ return [
+ {
+ "name": "Total Active Items",
+ "label": _("Total Active Items"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Item",
+ "filters_json": json.dumps([["Item", "disabled", "=", 0]]),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "name": "Total Warehouses",
+ "label": _("Total Warehouses"),
+ "function": "Count",
+ "doctype": "Number Card",
+ "document_type": "Warehouse",
+ "filters_json": json.dumps([["Warehouse", "disabled", "=", 0]]),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Monthly"
+ },
+ {
+ "name": "Total Stock Value",
+ "label": _("Total Stock Value"),
+ "function": "Sum",
+ "aggregate_function_based_on": "stock_value",
+ "doctype": "Number Card",
+ "document_type": "Bin",
+ "filters_json": json.dumps([]),
+ "is_public": 1,
+ "owner": "Administrator",
+ "show_percentage_stats": 1,
+ "stats_time_interval": "Daily"
+ }
+ ]
\ No newline at end of file
diff --git a/erpnext/stock/desk_page/stock/stock.json b/erpnext/stock/desk_page/stock/stock.json
index 38475a6f269..9404292c04f 100644
--- a/erpnext/stock/desk_page/stock/stock.json
+++ b/erpnext/stock/desk_page/stock/stock.json
@@ -1,9 +1,14 @@
{
"cards": [
+ {
+ "hidden": 0,
+ "label": "Items and Pricing",
+ "links": "[\n {\n \"label\": \"Item\",\n \"name\": \"Item\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"icon\": \"fa fa-sitemap\",\n \"label\": \"Item Group\",\n \"link\": \"Tree/Item Group\",\n \"name\": \"Item Group\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Product Bundle\",\n \"name\": \"Product Bundle\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Price List\",\n \"name\": \"Price List\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Price\",\n \"name\": \"Item Price\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Shipping Rule\",\n \"name\": \"Shipping Rule\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Pricing Rule\",\n \"name\": \"Pricing Rule\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Alternative\",\n \"name\": \"Item Alternative\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Manufacturer\",\n \"name\": \"Item Manufacturer\",\n \"type\": \"doctype\"\n }\n]"
+ },
{
"hidden": 0,
"label": "Stock Transactions",
- "links": "[\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Stock Entry\",\n \"name\": \"Stock Entry\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Customer\"\n ],\n \"label\": \"Delivery Note\",\n \"name\": \"Delivery Note\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"label\": \"Purchase Receipt\",\n \"name\": \"Purchase Receipt\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Material Request\",\n \"name\": \"Material Request\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Pick List\",\n \"name\": \"Pick List\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Delivery Trip\",\n \"name\": \"Delivery Trip\",\n \"type\": \"doctype\"\n }\n]"
+ "links": "[\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Material Request\",\n \"name\": \"Material Request\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Stock Entry\",\n \"name\": \"Stock Entry\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Customer\"\n ],\n \"label\": \"Delivery Note\",\n \"name\": \"Delivery Note\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\",\n \"Supplier\"\n ],\n \"label\": \"Purchase Receipt\",\n \"name\": \"Purchase Receipt\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"label\": \"Pick List\",\n \"name\": \"Pick List\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Delivery Trip\",\n \"name\": \"Delivery Trip\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
@@ -13,12 +18,7 @@
{
"hidden": 0,
"label": "Settings",
- "links": "[\n {\n \"label\": \"Stock Settings\",\n \"name\": \"Stock Settings\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Warehouse\",\n \"name\": \"Warehouse\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Unit of Measure (UOM)\",\n \"name\": \"UOM\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Brand\",\n \"name\": \"Brand\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Attribute\",\n \"name\": \"Item Attribute\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Variant Settings\",\n \"name\": \"Item Variant Settings\",\n \"type\": \"doctype\"\n }\n]"
- },
- {
- "hidden": 0,
- "label": "Items and Pricing",
- "links": "[\n {\n \"label\": \"Item\",\n \"name\": \"Item\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Product Bundle\",\n \"name\": \"Product Bundle\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"icon\": \"fa fa-sitemap\",\n \"label\": \"Item Group\",\n \"link\": \"Tree/Item Group\",\n \"name\": \"Item Group\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Price List\",\n \"name\": \"Price List\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Price\",\n \"name\": \"Item Price\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Shipping Rule\",\n \"name\": \"Shipping Rule\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Pricing Rule\",\n \"name\": \"Pricing Rule\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Alternative\",\n \"name\": \"Item Alternative\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Manufacturer\",\n \"name\": \"Item Manufacturer\",\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Variant Settings\",\n \"name\": \"Item Variant Settings\",\n \"type\": \"doctype\"\n }\n]"
+ "links": "[\n {\n \"label\": \"Stock Settings\",\n \"name\": \"Stock Settings\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Warehouse\",\n \"name\": \"Warehouse\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Unit of Measure (UOM)\",\n \"name\": \"UOM\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Variant Settings\",\n \"name\": \"Item Variant Settings\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Brand\",\n \"name\": \"Brand\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"label\": \"Item Attribute\",\n \"name\": \"Item Attribute\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
@@ -33,7 +33,7 @@
{
"hidden": 0,
"label": "Key Reports",
- "links": "[\n {\n \"dependencies\": [\n \"Item Price\"\n ],\n \"doctype\": \"Item Price\",\n \"is_query_report\": false,\n \"label\": \"Item-wise Price List Rate\",\n \"name\": \"Item-wise Price List Rate\",\n \"onboard\": 1,\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Stock Entry\"\n ],\n \"doctype\": \"Stock Entry\",\n \"is_query_report\": true,\n \"label\": \"Stock Analytics\",\n \"name\": \"Stock Analytics\",\n \"onboard\": 1,\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Delivery Note\"\n ],\n \"doctype\": \"Delivery Note\",\n \"is_query_report\": true,\n \"label\": \"Delivery Note Trends\",\n \"name\": \"Delivery Note Trends\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Receipt\"\n ],\n \"doctype\": \"Purchase Receipt\",\n \"is_query_report\": true,\n \"label\": \"Purchase Receipt Trends\",\n \"name\": \"Purchase Receipt Trends\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Delivery Note\"\n ],\n \"doctype\": \"Delivery Note\",\n \"is_query_report\": true,\n \"label\": \"Ordered Items To Be Delivered\",\n \"name\": \"Ordered Items To Be Delivered\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Receipt\"\n ],\n \"doctype\": \"Purchase Receipt\",\n \"is_query_report\": true,\n \"label\": \"Purchase Order Items To Be Received\",\n \"name\": \"Purchase Order Items To Be Received\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Bin\"\n ],\n \"doctype\": \"Bin\",\n \"is_query_report\": true,\n \"label\": \"Item Shortage Report\",\n \"name\": \"Item Shortage Report\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Batch\"\n ],\n \"doctype\": \"Batch\",\n \"is_query_report\": true,\n \"label\": \"Batch-Wise Balance History\",\n \"name\": \"Batch-Wise Balance History\",\n \"type\": \"report\"\n }\n]"
+ "links": "[\n {\n \"dependencies\": [\n \"Item Price\"\n ],\n \"doctype\": \"Item Price\",\n \"is_query_report\": false,\n \"label\": \"Item-wise Price List Rate\",\n \"name\": \"Item-wise Price List Rate\",\n \"onboard\": 1,\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Stock Entry\"\n ],\n \"doctype\": \"Stock Entry\",\n \"is_query_report\": true,\n \"label\": \"Stock Analytics\",\n \"name\": \"Stock Analytics\",\n \"onboard\": 1,\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Delivery Note\"\n ],\n \"doctype\": \"Delivery Note\",\n \"is_query_report\": true,\n \"label\": \"Delivery Note Trends\",\n \"name\": \"Delivery Note Trends\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Receipt\"\n ],\n \"doctype\": \"Purchase Receipt\",\n \"is_query_report\": true,\n \"label\": \"Purchase Receipt Trends\",\n \"name\": \"Purchase Receipt Trends\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Delivery Note\"\n ],\n \"doctype\": \"Delivery Note\",\n \"is_query_report\": true,\n \"label\": \"Ordered Items To Be Delivered\",\n \"name\": \"Ordered Items To Be Delivered\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Order\"\n ],\n \"doctype\": \"Purchase Order\",\n \"is_query_report\": true,\n \"label\": \"Purchase Order Analysis\",\n \"name\": \"Purchase Order Analysis\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Bin\"\n ],\n \"doctype\": \"Bin\",\n \"is_query_report\": true,\n \"label\": \"Item Shortage Report\",\n \"name\": \"Item Shortage Report\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Batch\"\n ],\n \"doctype\": \"Batch\",\n \"is_query_report\": true,\n \"label\": \"Batch-Wise Balance History\",\n \"name\": \"Batch-Wise Balance History\",\n \"type\": \"report\"\n }\n]"
},
{
"hidden": 0,
@@ -41,34 +41,46 @@
"links": "[\n {\n \"dependencies\": [\n \"Material Request\"\n ],\n \"doctype\": \"Material Request\",\n \"is_query_report\": true,\n \"label\": \"Requested Items To Be Transferred\",\n \"name\": \"Requested Items To Be Transferred\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Stock Ledger Entry\"\n ],\n \"doctype\": \"Stock Ledger Entry\",\n \"is_query_report\": true,\n \"label\": \"Batch Item Expiry Status\",\n \"name\": \"Batch Item Expiry Status\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Price List\"\n ],\n \"doctype\": \"Price List\",\n \"is_query_report\": true,\n \"label\": \"Item Prices\",\n \"name\": \"Item Prices\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"doctype\": \"Item\",\n \"is_query_report\": true,\n \"label\": \"Itemwise Recommended Reorder Level\",\n \"name\": \"Itemwise Recommended Reorder Level\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Item\"\n ],\n \"doctype\": \"Item\",\n \"is_query_report\": true,\n \"label\": \"Item Variant Details\",\n \"name\": \"Item Variant Details\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Order\"\n ],\n \"doctype\": \"Purchase Order\",\n \"is_query_report\": true,\n \"label\": \"Subcontracted Raw Materials To Be Transferred\",\n \"name\": \"Subcontracted Raw Materials To Be Transferred\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Purchase Order\"\n ],\n \"doctype\": \"Purchase Order\",\n \"is_query_report\": true,\n \"label\": \"Subcontracted Item To Be Received\",\n \"name\": \"Subcontracted Item To Be Received\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Stock Ledger Entry\"\n ],\n \"doctype\": \"Stock Ledger Entry\",\n \"is_query_report\": true,\n \"label\": \"Stock and Account Value Comparison\",\n \"name\": \"Stock and Account Value Comparison\",\n \"type\": \"report\"\n }\n]"
}
],
+ "cards_label": "Masters & Reports",
"category": "Modules",
- "charts": [],
+ "charts": [
+ {
+ "chart_name": "Warehouse wise Stock Value"
+ }
+ ],
"creation": "2020-03-02 15:43:10.096528",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Stock",
- "modified": "2020-04-01 11:28:51.148421",
+ "modified": "2020-05-27 20:38:25.255323",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock",
+ "onboarding": "Stock",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#cef6d1",
+ "format": "{} Available",
"label": "Item",
"link_to": "Item",
+ "stats_filter": "{\n \"disabled\" : 0\n}",
"type": "DocType"
},
{
- "label": "Pricing Rule",
- "link_to": "Pricing Rule",
+ "color": "#ffe8cd",
+ "format": "{} Pending",
+ "label": "Material Request",
+ "link_to": "Material Request",
+ "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"Pending\"\n}",
"type": "DocType"
},
{
@@ -76,6 +88,22 @@
"link_to": "Stock Entry",
"type": "DocType"
},
+ {
+ "color": "#ffe8cd",
+ "format": "{} To Bill",
+ "label": "Purchase Receipt",
+ "link_to": "Purchase Receipt",
+ "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"To Bill\"\n}",
+ "type": "DocType"
+ },
+ {
+ "color": "#ffe8cd",
+ "format": "{} To Bill",
+ "label": "Delivery Note",
+ "link_to": "Delivery Note",
+ "stats_filter": "{\n \"company\": [\"like\", '%' + frappe.defaults.get_global_default(\"company\") + '%'],\n \"status\": \"To Bill\"\n}",
+ "type": "DocType"
+ },
{
"label": "Stock Ledger",
"link_to": "Stock Ledger",
@@ -85,6 +113,12 @@
"label": "Stock Balance",
"link_to": "Stock Balance",
"type": "Report"
+ },
+ {
+ "label": "Dashboard",
+ "link_to": "Stock",
+ "type": "Dashboard"
}
- ]
+ ],
+ "shortcuts_label": "Quick Access"
}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 9f5dee901ce..84d2057f960 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -24,10 +24,10 @@
"return_against",
"customer_po_details",
"po_no",
- "section_break_18",
- "pick_list",
"column_break_17",
"po_date",
+ "section_break_18",
+ "pick_list",
"contact_info",
"shipping_address_name",
"shipping_address",
@@ -296,7 +296,6 @@
},
{
"collapsible": 1,
- "collapsible_depends_on": "po_no",
"fieldname": "customer_po_details",
"fieldtype": "Section Break",
"label": "Customer PO Details"
@@ -304,7 +303,7 @@
{
"allow_on_submit": 1,
"fieldname": "po_no",
- "fieldtype": "Data",
+ "fieldtype": "Small Text",
"label": "Customer's Purchase Order No",
"no_copy": 1,
"oldfieldname": "po_no",
@@ -318,7 +317,6 @@
"fieldtype": "Column Break"
},
{
- "depends_on": "eval:doc.po_no",
"fieldname": "po_date",
"fieldtype": "Date",
"label": "Customer's Purchase Order Date",
@@ -326,7 +324,6 @@
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "100px",
- "read_only": 1,
"width": "100px"
},
{
@@ -1256,7 +1253,7 @@
"idx": 146,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-17 12:51:41.288600",
+ "modified": "2020-05-19 17:03:45.880106",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index c62b3ab583d..3436a5d0136 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -467,7 +467,7 @@ class Item(WebsiteGenerator):
def set_shopping_cart_data(self, context):
from erpnext.shopping_cart.product_info import get_product_info_for_website
- context.shopping_cart = get_product_info_for_website(self.name)
+ context.shopping_cart = get_product_info_for_website(self.name, skip_quotation_creation=True)
def add_default_uom_in_conversion_factor_table(self):
uom_conv_list = [d.uom for d in self.get("uoms")]
@@ -572,6 +572,13 @@ class Item(WebsiteGenerator):
frappe.throw(_("Barcode {0} is not a valid {1} code").format(
item_barcode.barcode, item_barcode.barcode_type), InvalidBarcode)
+ if item_barcode.barcode != item_barcode.name:
+ # if barcode is getting updated , the row name has to reset.
+ # Delete previous old row doc and re-enter row as if new to reset name in db.
+ item_barcode.set("__islocal", True)
+ item_barcode.name = None
+ frappe.delete_doc("Item Barcode", item_barcode.name)
+
def validate_warehouse_for_reorder(self):
'''Validate Reorder level table for duplicate and conditional mandatory'''
warehouse = []
@@ -1136,6 +1143,17 @@ def set_item_default(item_code, company, fieldname, value):
d.db_insert()
item.clear_cache()
+@frappe.whitelist()
+def get_item_details(item_code, company=None):
+ out = frappe._dict()
+ if company:
+ out = get_item_defaults(item_code, company) or frappe._dict()
+
+ doc = frappe.get_cached_doc("Item", item_code)
+ out.update(doc.as_dict())
+
+ return out
+
@frappe.whitelist()
def get_uom_conv_factor(uom, stock_uom):
uoms = [uom, stock_uom]
diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py
index 71b998fb954..2f75bbd97c0 100644
--- a/erpnext/stock/doctype/item_attribute/item_attribute.py
+++ b/erpnext/stock/doctype/item_attribute/item_attribute.py
@@ -34,7 +34,7 @@ class ItemAttribute(Document):
if self.numeric_values:
validate_is_incremental(self, self.name, item.value, item.name)
else:
- validate_item_attribute_value(attributes_list, self.name, item.value, item.name)
+ validate_item_attribute_value(attributes_list, self.name, item.value, item.name, from_variant=False)
def validate_numeric(self):
if self.numeric_values:
diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py
index 957c41546b3..8e39eb5037d 100644
--- a/erpnext/stock/doctype/item_price/item_price.py
+++ b/erpnext/stock/doctype/item_price/item_price.py
@@ -69,3 +69,10 @@ class ItemPrice(Document):
self.reference = self.customer
if self.buying:
self.reference = self.supplier
+
+ if self.selling and not self.buying:
+ # if only selling then remove supplier
+ self.supplier = None
+ if self.buying and not self.selling:
+ # if only buying then remove customer
+ self.customer = None
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index db8bffda9dd..3a8deb6d254 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -18,7 +18,7 @@ frappe.ui.form.on('Material Request', {
// formatter for material request item
frm.set_indicator_formatter('item_code',
- function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange"; });
+ function(doc) { return (doc.stock_qty<=doc.ordered_qty) ? "green" : "orange"; });
frm.set_query("item_code", "items", function() {
return {
@@ -30,7 +30,16 @@ frappe.ui.form.on('Material Request', {
return {
filters: {'company': doc.company}
};
- })
+ });
+
+ frm.set_query("bom_no", "items", function(doc, cdt, cdn) {
+ var row = locals[cdt][cdn];
+ return {
+ filters: {
+ "item": row.item_code
+ }
+ }
+ });
},
onload: function(frm) {
diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.json b/erpnext/stock/doctype/material_request_item/material_request_item.json
index df140ffd754..32bd4a0a57a 100644
--- a/erpnext/stock/doctype/material_request_item/material_request_item.json
+++ b/erpnext/stock/doctype/material_request_item/material_request_item.json
@@ -53,6 +53,8 @@
"dimension_col_break",
"cost_center",
"section_break_37",
+ "bom_no",
+ "section_break_46",
"page_break"
],
"fields": [
@@ -371,8 +373,10 @@
"label": "Image"
},
{
+ "depends_on": "eval:parent.material_request_type == \"Manufacture\"",
"fieldname": "section_break_37",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Manufacturing"
},
{
"fieldname": "received_qty",
@@ -428,12 +432,24 @@
"fieldtype": "Link",
"label": "Source Warehouse (Material Transfer)",
"options": "Warehouse"
+ },
+ {
+ "fieldname": "bom_no",
+ "fieldtype": "Link",
+ "label": "BOM No",
+ "no_copy": 1,
+ "options": "BOM",
+ "print_hide": 1
+ },
+ {
+ "fieldname": "section_break_46",
+ "fieldtype": "Section Break"
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-05-01 09:00:00.992835",
+ "modified": "2020-05-15 09:00:00.992835",
"modified_by": "Administrator",
"module": "Stock",
"name": "Material Request Item",
diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js
index d46b98b461b..3a5ef769805 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.js
+++ b/erpnext/stock/doctype/pick_list/pick_list.js
@@ -31,10 +31,16 @@ frappe.ui.form.on('Pick List', {
};
});
frm.set_query('item_code', 'locations', () => {
+ return erpnext.queries.item({ "is_stock_item": 1 });
+ });
+ frm.set_query('batch_no', 'locations', (frm, cdt, cdn) => {
+ const row = locals[cdt][cdn];
return {
+ query: 'erpnext.controllers.queries.get_batch_no',
filters: {
- is_stock_item: 1
- }
+ item_code: row.item_code,
+ warehouse: row.warehouse
+ },
};
});
},
diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py
index 231af1a0227..4b8b594ed9d 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.py
+++ b/erpnext/stock/doctype/pick_list/pick_list.py
@@ -24,6 +24,9 @@ class PickList(Document):
for item in self.locations:
if not frappe.get_cached_value('Item', item.item_code, 'has_serial_no'):
continue
+ if not item.serial_no:
+ frappe.throw(_("Row #{0}: {1} does not have any available serial numbers in {2}".format(
+ frappe.bold(item.idx), frappe.bold(item.item_code), frappe.bold(item.warehouse))))
if len(item.serial_no.split('\n')) == item.picked_qty:
continue
frappe.throw(_('For item {0} at row {1}, count of serial numbers does not match with the picked quantity')
@@ -116,11 +119,13 @@ def get_items_with_location_and_quantity(item_doc, item_location_map):
if item_location.serial_no:
serial_nos = '\n'.join(item_location.serial_no[0: cint(stock_qty)])
+ auto_set_serial_no = frappe.db.get_single_value("Stock Settings", "automatically_set_serial_nos_based_on_fifo")
+
locations.append(frappe._dict({
'qty': qty,
'stock_qty': stock_qty,
'warehouse': item_location.warehouse,
- 'serial_no': serial_nos,
+ 'serial_no': serial_nos if auto_set_serial_no else item_doc.serial_no,
'batch_no': item_location.batch_no
}))
@@ -203,6 +208,7 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re
sle.batch_no = batch.name
and sle.`item_code`=%(item_code)s
and sle.`company` = %(company)s
+ and batch.disabled = 0
and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
{warehouse_condition}
GROUP BY
@@ -300,6 +306,7 @@ def create_delivery_note(source_name, target_doc=None):
set_delivery_note_missing_values(delivery_note)
delivery_note.pick_list = pick_list.name
+ delivery_note.customer = pick_list.customer if pick_list.customer else None
return delivery_note
@@ -467,4 +474,4 @@ def update_common_item_properties(item, location):
item.material_request = location.material_request
item.serial_no = location.serial_no
item.batch_no = location.batch_no
- item.material_request_item = location.material_request_item
\ No newline at end of file
+ item.material_request_item = location.material_request_item
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index e9568eeacc0..50c18f62824 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -25,7 +25,7 @@ frappe.ui.form.on("Purchase Receipt", {
frm.custom_make_buttons = {
'Stock Entry': 'Return',
- 'Purchase Invoice': 'Invoice'
+ 'Purchase Invoice': 'Purchase Invoice'
};
frm.set_query("expense_account", "items", function() {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 467a206d188..44d5f690285 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -32,6 +32,8 @@
"col_break_address",
"shipping_address",
"shipping_address_display",
+ "billing_address",
+ "billing_address_display",
"currency_and_price_list",
"currency",
"conversion_rate",
@@ -130,13 +132,17 @@
{
"fieldname": "supplier_section",
"fieldtype": "Section Break",
- "options": "fa fa-user"
+ "options": "fa fa-user",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -147,7 +153,9 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "naming_series",
@@ -159,7 +167,9 @@
"options": "MAT-PRE-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1
+ "set_only_once": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -174,6 +184,8 @@
"print_width": "150px",
"reqd": 1,
"search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "150px"
},
{
@@ -184,18 +196,24 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Supplier Name",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_delivery_note",
"fieldtype": "Data",
- "label": "Supplier Delivery Note"
+ "label": "Supplier Delivery Note",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -210,6 +228,8 @@
"print_width": "100px",
"reqd": 1,
"search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -223,6 +243,8 @@
"print_hide": 1,
"print_width": "100px",
"reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -231,7 +253,9 @@
"fieldname": "set_posting_time",
"fieldtype": "Check",
"label": "Edit Posting Date and Time",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "company",
@@ -245,6 +269,8 @@
"print_width": "150px",
"remember_last_selected_value": 1,
"reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "150px"
},
{
@@ -254,7 +280,9 @@
"label": "Is Return",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "is_return",
@@ -264,46 +292,60 @@
"no_copy": 1,
"options": "Purchase Receipt",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact"
+ "label": "Address and Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Select Supplier Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_person",
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "address_display",
"fieldtype": "Small Text",
"label": "Address",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_display",
"fieldtype": "Small Text",
"in_global_search": 1,
"label": "Contact",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_mobile",
"fieldtype": "Small Text",
"label": "Mobile No",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_email",
@@ -311,32 +353,42 @@
"label": "Contact Email",
"options": "Email",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Select Shipping Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag"
+ "options": "fa fa-tag",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "currency",
@@ -346,7 +398,9 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "Rate at which supplier's currency is converted to company's base currency",
@@ -357,13 +411,17 @@
"oldfieldtype": "Currency",
"precision": "9",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break2",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -371,7 +429,9 @@
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "buying_price_list",
@@ -380,7 +440,9 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "buying_price_list",
@@ -388,7 +450,9 @@
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -397,11 +461,15 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sec_warehouse",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "Sets 'Accepted Warehouse' in each row of the items table.",
@@ -409,7 +477,9 @@
"fieldtype": "Link",
"label": "Accepted Warehouse",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "Sets 'Rejected Warehouse' in each row of the items table.",
@@ -420,11 +490,15 @@
"oldfieldname": "rejected_warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -434,7 +508,9 @@
"oldfieldname": "is_subcontracted",
"oldfieldtype": "Select",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.is_subcontracted==\"Yes\"",
@@ -447,13 +523,17 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "50px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50px"
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart"
+ "options": "fa fa-shopping-cart",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_bulk_edit": 1,
@@ -463,20 +543,26 @@
"oldfieldname": "purchase_receipt_details",
"oldfieldtype": "Table",
"options": "Purchase Receipt Item",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "pricing_rule_details",
"fieldtype": "Section Break",
- "label": "Pricing Rules"
+ "label": "Pricing Rules",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Pricing Rule Detail",
"options": "Pricing Rule Detail",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "supplied_items",
@@ -485,7 +571,9 @@
"label": "Get Current Stock",
"oldfieldtype": "Button",
"options": "get_current_stock",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -496,7 +584,9 @@
"oldfieldtype": "Section Break",
"options": "fa fa-table",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplied_items",
@@ -507,18 +597,24 @@
"oldfieldtype": "Table",
"options": "Purchase Receipt Item Supplied",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break0",
"fieldtype": "Section Break",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total",
@@ -526,7 +622,9 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_net_total",
@@ -539,18 +637,24 @@
"print_width": "150px",
"read_only": 1,
"reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "150px"
},
{
"fieldname": "column_break_27",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "net_total",
@@ -560,42 +664,56 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "Add / Edit Taxes and Charges",
"fieldname": "taxes_charges_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_col",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
- "options": "Shipping Rule"
+ "options": "Shipping Rule",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_section",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges",
@@ -604,7 +722,9 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes",
@@ -612,13 +732,17 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup"
+ "label": "Tax Breakup",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_charges_calculation",
@@ -627,13 +751,17 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_added",
@@ -643,7 +771,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_deducted",
@@ -653,7 +783,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total_taxes_and_charges",
@@ -663,12 +795,16 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break3",
"fieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -679,7 +815,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_deducted",
@@ -689,7 +827,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_taxes_and_charges",
@@ -697,14 +837,18 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "discount_amount",
"fieldname": "section_break_42",
"fieldtype": "Section Break",
- "label": "Additional Discount"
+ "label": "Additional Discount",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Grand Total",
@@ -712,7 +856,9 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_discount_amount",
@@ -720,28 +866,38 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_44",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_46",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_grand_total",
@@ -751,7 +907,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounding_adjustment",
@@ -760,7 +918,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_in_words",
@@ -769,7 +929,9 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounded_total",
@@ -779,11 +941,15 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_50",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "grand_total",
@@ -793,7 +959,9 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "rounding_adjustment",
@@ -802,7 +970,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -812,7 +982,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "in_words",
@@ -821,13 +993,17 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total"
+ "label": "Disable Rounded Total",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -836,7 +1012,9 @@
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break",
- "options": "fa fa-legal"
+ "options": "fa fa-legal",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tc_name",
@@ -845,14 +1023,18 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
"label": "Terms and Conditions",
"oldfieldname": "terms",
- "oldfieldtype": "Text Editor"
+ "oldfieldtype": "Text Editor",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_no",
@@ -861,7 +1043,9 @@
"label": "Bill No",
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_date",
@@ -870,7 +1054,9 @@
"label": "Bill Date",
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -878,7 +1064,9 @@
"fieldtype": "Section Break",
"label": "More Information",
"oldfieldtype": "Section Break",
- "options": "fa fa-file-text"
+ "options": "fa fa-file-text",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Draft",
@@ -895,6 +1083,8 @@
"read_only": 1,
"reqd": 1,
"search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "150px"
},
{
@@ -910,6 +1100,8 @@
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "150px"
},
{
@@ -919,7 +1111,9 @@
"label": "Range",
"oldfieldname": "range",
"oldfieldtype": "Data",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break4",
@@ -927,6 +1121,8 @@
"oldfieldtype": "Column Break",
"print_hide": 1,
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -935,12 +1131,16 @@
"label": "% Amount Billed",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "subscription_detail",
"fieldtype": "Section Break",
- "label": "Auto Repeat Detail"
+ "label": "Auto Repeat Detail",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "auto_repeat",
@@ -949,13 +1149,17 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "printing_settings",
"fieldtype": "Section Break",
- "label": "Printing Settings"
+ "label": "Printing Settings",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -963,7 +1167,9 @@
"fieldtype": "Link",
"label": "Letter Head",
"options": "Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -975,13 +1181,17 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1
+ "report_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -989,11 +1199,15 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_97",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_details",
@@ -1004,6 +1218,8 @@
"options": "Other Details
",
"print_hide": 1,
"print_width": "30%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "30%"
},
{
@@ -1011,13 +1227,17 @@
"fieldtype": "Small Text",
"label": "Instructions",
"oldfieldname": "instructions",
- "oldfieldtype": "Text"
+ "oldfieldtype": "Text",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "remarks",
"fieldtype": "Small Text",
"label": "Remarks",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1025,19 +1245,25 @@
"fieldname": "transporter_info",
"fieldtype": "Section Break",
"label": "Transporter Details",
- "options": "fa fa-truck"
+ "options": "fa fa-truck",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "transporter_name",
"fieldtype": "Data",
"label": "Transporter Name",
"oldfieldname": "transporter_name",
- "oldfieldtype": "Data"
+ "oldfieldtype": "Data",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break5",
"fieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -1048,6 +1274,8 @@
"oldfieldname": "lr_no",
"oldfieldtype": "Data",
"print_width": "100px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -1058,6 +1286,8 @@
"oldfieldname": "lr_date",
"oldfieldtype": "Date",
"print_width": "100px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -1066,26 +1296,48 @@
"fieldname": "is_internal_supplier",
"fieldtype": "Check",
"label": "Is Internal Supplier",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "inter_company_reference",
"fieldtype": "Link",
"label": "Inter Company Reference",
"options": "Delivery Note",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode"
+ "label": "Scan Barcode",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address",
+ "fieldtype": "Link",
+ "label": "Select Billing Address",
+ "options": "Address",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "billing_address_display",
+ "fieldtype": "Small Text",
+ "label": "Billing Address",
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
}
],
"icon": "fa fa-truck",
"idx": 261,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-18 18:02:18.020763",
+ "modified": "2020-06-13 22:26:03.600092",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
@@ -1152,4 +1404,4 @@
"timeline_field": "supplier",
"title_field": "title",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.json b/erpnext/stock/doctype/quality_inspection/quality_inspection.json
index a9f3cd09ef5..c951066aa83 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.json
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"autoname": "naming_series:",
"creation": "2013-04-30 13:13:03",
"doctype": "DocType",
@@ -8,6 +9,7 @@
"field_order": [
"naming_series",
"report_date",
+ "status",
"column_break_4",
"inspection_type",
"reference_type",
@@ -20,17 +22,16 @@
"column_break1",
"item_name",
"description",
- "status",
+ "bom_no",
+ "specification_details",
+ "quality_inspection_template",
+ "readings",
"section_break_14",
"inspected_by",
"verified_by",
- "bom_no",
"column_break_17",
"remarks",
- "amended_from",
- "specification_details",
- "quality_inspection_template",
- "readings"
+ "amended_from"
],
"fields": [
{
@@ -231,7 +232,8 @@
"icon": "fa fa-search",
"idx": 1,
"is_submittable": 1,
- "modified": "2019-07-12 12:07:23.153698",
+ "links": [],
+ "modified": "2020-04-26 17:50:25.068222",
"modified_by": "Administrator",
"module": "Stock",
"name": "Quality Inspection",
diff --git a/erpnext/stock/doctype/serial_no/serial_no.json b/erpnext/stock/doctype/serial_no/serial_no.json
index 731a7302797..d9f8b627545 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.json
+++ b/erpnext/stock/doctype/serial_no/serial_no.json
@@ -420,14 +420,14 @@
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Status",
- "options": "\nActive\nDelivered\nExpired",
+ "options": "\nActive\nInactive\nDelivered\nExpired",
"read_only": 1
}
],
"icon": "fa fa-barcode",
"idx": 1,
"links": [],
- "modified": "2020-04-08 13:29:58.517772",
+ "modified": "2020-05-21 19:29:58.517772",
"modified_by": "Administrator",
"module": "Stock",
"name": "Serial No",
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 914eea379a8..f3514c7385d 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -42,6 +42,8 @@ class SerialNo(StockController):
self.status = "Delivered"
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
self.status = "Expired"
+ elif not self.warehouse:
+ self.status = "Inactive"
else:
self.status = "Active"
diff --git a/erpnext/stock/doctype/serial_no/serial_no_list.js b/erpnext/stock/doctype/serial_no/serial_no_list.js
index 651f790583d..7526d1d8a5c 100644
--- a/erpnext/stock/doctype/serial_no/serial_no_list.js
+++ b/erpnext/stock/doctype/serial_no/serial_no_list.js
@@ -5,6 +5,8 @@ frappe.listview_settings['Serial No'] = {
return [__("Delivered"), "green", "delivery_document_type,is,set"];
} else if (doc.warranty_expiry_date && frappe.datetime.get_diff(doc.warranty_expiry_date, frappe.datetime.nowdate()) <= 0) {
return [__("Expired"), "red", "warranty_expiry_date,not in,|warranty_expiry_date,<=,Today|delivery_document_type,is,not set"];
+ } else if (!doc.warehouse) {
+ return [__("Inactive"), "grey", "warehouse,is,not set"];
} else {
return [__("Active"), "green", "delivery_document_type,is,not set"];
}
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index ddf4ec03937..5fbd512bf4f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -181,7 +181,7 @@ class StockEntry(StockController):
stock_items = self.get_stock_items()
serialized_items = self.get_serialized_items()
for item in self.get("items"):
- if item.qty and item.qty < 0:
+ if flt(item.qty) and flt(item.qty) < 0:
frappe.throw(_("Row {0}: The item {1}, quantity must be positive number")
.format(item.idx, frappe.bold(item.item_code)))
@@ -363,6 +363,9 @@ class StockEntry(StockController):
+ self.work_order + ":" + ", ".join(other_ste), DuplicateEntryForWorkOrderError)
def set_incoming_rate(self):
+ if self.purpose == "Repack":
+ self.set_basic_rate_for_finished_goods()
+
for d in self.items:
if d.s_warehouse:
args = self.get_args_for_incoming_rate(d)
@@ -470,25 +473,36 @@ class StockEntry(StockController):
"qty": item.s_warehouse and -1*flt(item.transfer_qty) or flt(item.transfer_qty),
"serial_no": item.serial_no,
"voucher_type": self.doctype,
- "voucher_no": item.name,
+ "voucher_no": self.name,
"company": self.company,
"allow_zero_valuation": item.allow_zero_valuation_rate,
})
- def set_basic_rate_for_finished_goods(self, raw_material_cost, scrap_material_cost):
+ def set_basic_rate_for_finished_goods(self, raw_material_cost=0, scrap_material_cost=0):
+ total_fg_qty = 0
+ if not raw_material_cost and self.get("items"):
+ raw_material_cost = sum([flt(row.basic_amount) for row in self.items
+ if row.s_warehouse and not row.t_warehouse])
+
+ total_fg_qty = sum([flt(row.qty) for row in self.items
+ if row.t_warehouse and not row.s_warehouse])
+
if self.purpose in ["Manufacture", "Repack"]:
for d in self.get("items"):
if (d.transfer_qty and (d.bom_no or d.t_warehouse)
and (getattr(self, "pro_doc", frappe._dict()).scrap_warehouse != d.t_warehouse)):
- if self.work_order \
- and frappe.db.get_single_value("Manufacturing Settings", "material_consumption"):
+ if (self.work_order and self.purpose == "Manufacture"
+ and frappe.db.get_single_value("Manufacturing Settings", "material_consumption")):
bom_items = self.get_bom_raw_materials(d.transfer_qty)
raw_material_cost = sum([flt(row.qty)*flt(row.rate) for row in bom_items.values()])
- if raw_material_cost:
+ if raw_material_cost and self.purpose == "Manufacture":
d.basic_rate = flt((raw_material_cost - scrap_material_cost) / flt(d.transfer_qty), d.precision("basic_rate"))
d.basic_amount = flt((raw_material_cost - scrap_material_cost), d.precision("basic_amount"))
+ elif self.purpose == "Repack" and total_fg_qty and not d.set_basic_rate_manually:
+ d.basic_rate = flt(raw_material_cost) / flt(total_fg_qty)
+ d.basic_amount = d.basic_rate * d.qty
def distribute_additional_costs(self):
if self.purpose == "Material Issue":
@@ -718,11 +732,15 @@ class StockEntry(StockController):
pro_doc = frappe.get_doc("Work Order", self.work_order)
_validate_work_order(pro_doc)
pro_doc.run_method("update_status")
+
if self.fg_completed_qty:
pro_doc.run_method("update_work_order_qty")
if self.purpose == "Manufacture":
pro_doc.run_method("update_planned_qty")
+ if not pro_doc.operations:
+ pro_doc.set_actual_dates()
+
def get_item_details(self, args=None, for_update=False):
item = frappe.db.sql("""select i.name, i.stock_uom, i.description, i.image, i.item_name, i.item_group,
i.has_batch_no, i.sample_quantity, i.has_serial_no,
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index c16a41c24fa..7b9c129804e 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -23,6 +23,7 @@
"image",
"image_view",
"quantity_and_rate",
+ "set_basic_rate_manually",
"qty",
"basic_rate",
"basic_amount",
@@ -491,12 +492,21 @@
"no_copy": 1,
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "default": "0",
+ "depends_on": "eval:parent.purpose===\"Repack\" && doc.t_warehouse",
+ "fieldname": "set_basic_rate_manually",
+ "fieldtype": "Check",
+ "label": "Set Basic Rate Manually",
+ "show_days": 1,
+ "show_seconds": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-04-23 19:19:28.539769",
+ "modified": "2020-06-08 12:57:03.172887",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js
index cc0e2cfc425..877d0c3bbf4 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.js
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.js
@@ -15,3 +15,37 @@ frappe.ui.form.on('Stock Settings', {
frm.set_query("sample_retention_warehouse", filters);
}
});
+
+frappe.tour['Stock Settings'] = [
+ {
+ fieldname: "item_naming_by",
+ title: __("Item Naming By"),
+ description: __("By default, the Item Name is set as per the Item Code entered. If you want Items to be named by a set Naming Series choose the 'Naming Series' option.")
+ },
+ {
+ fieldname: "default_warehouse",
+ title: __("Default Warehouse"),
+ description: __("Set a Default Warehouse for Inventory Transactions. This will be fetched into the Default Warehouse in the Item master.")
+ },
+ {
+ fieldname: "allow_negative_stock",
+ title: __("Allow Negative Stock"),
+ description: __("This will allow stock items to be displayed in negative values. Using this option depends on your use case. With this option unchecked, the system warns before obstructing a transaction that is causing negative stock.")
+
+ },
+ {
+ fieldname: "valuation_method",
+ title: __("Valuation Method"),
+ description: __("Choose between FIFO and Moving Average Valuation Methods. Click ") + "here " + __(" to know more about them.")
+ },
+ {
+ fieldname: "show_barcode_field",
+ title: __("Show Barcode Field"),
+ description: __("Show 'Scan Barcode' field above every child table to insert Items with ease.")
+ },
+ {
+ fieldname: "automatically_set_serial_nos_based_on_fifo",
+ title: __("Automatically Set Serial Nos based on FIFO"),
+ description: __("Serial numbers for stock will be set automatically based on the Items entered based on first in first out in transactions like Purchase/Sales Invoices, Delivery Notes, etc.")
+ }
+];
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index eb4867d2cf3..cd86be31150 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -177,7 +177,7 @@ def convert_to_group_or_ledger():
return frappe.get_doc("Warehouse", args.docname).convert_to_group_or_ledger()
def get_child_warehouses(warehouse):
- lft, rgt = frappe.get_cached_value("Warehouse", warehouse, [lft, rgt])
+ lft, rgt = frappe.get_cached_value("Warehouse", warehouse, ["lft", "rgt"])
return frappe.db.sql_list("""select name from `tabWarehouse`
where lft >= %s and rgt <= %s""", (lft, rgt))
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index d50712aee7d..0ed3b276e39 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -305,7 +305,8 @@ def get_basic_details(args, item, overwrite_warehouse=True):
"weight_uom":item.weight_uom,
"last_purchase_rate": item.last_purchase_rate if args.get("doctype") in ["Purchase Order"] else 0,
"transaction_date": args.get("transaction_date"),
- "against_blanket_order": args.get("against_blanket_order")
+ "against_blanket_order": args.get("against_blanket_order"),
+ "bom_no": item.get("default_bom")
})
if item.get("enable_deferred_revenue") or item.get("enable_deferred_expense"):
@@ -630,7 +631,7 @@ def get_item_price(args, item_code, ignore_party=False):
elif args.get("supplier"):
conditions += " and supplier=%(supplier)s"
else:
- conditions += " and (customer is null or customer = '') and (supplier is null or supplier = '')"
+ conditions += "and (customer is null or customer = '') and (supplier is null or supplier = '')"
if args.get('transaction_date'):
conditions += """ and %(transaction_date)s between
diff --git a/erpnext/stock/module_onboarding/stock/stock.json b/erpnext/stock/module_onboarding/stock/stock.json
new file mode 100644
index 00000000000..de24575a140
--- /dev/null
+++ b/erpnext/stock/module_onboarding/stock/stock.json
@@ -0,0 +1,54 @@
+{
+ "allow_roles": [
+ {
+ "role": "Manufacturing Manager"
+ },
+ {
+ "role": "Stock Manager"
+ },
+ {
+ "role": "Manufacturing User"
+ },
+ {
+ "role": "Stock User"
+ }
+ ],
+ "creation": "2020-05-15 03:18:44.400108",
+ "docstatus": 0,
+ "doctype": "Module Onboarding",
+ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/stock",
+ "idx": 0,
+ "is_complete": 0,
+ "modified": "2020-05-19 19:03:23.602423",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Stock",
+ "owner": "Administrator",
+ "steps": [
+ {
+ "step": "Setup your Warehouse"
+ },
+ {
+ "step": "Create a Product"
+ },
+ {
+ "step": "Introduction to Stock Entry"
+ },
+ {
+ "step": "Create a Stock Entry"
+ },
+ {
+ "step": "Create a Supplier"
+ },
+ {
+ "step": "Create a Purchase Receipt"
+ },
+ {
+ "step": "Stock Settings"
+ }
+ ],
+ "subtitle": "Inventory, Warehouses, Analysis and more.",
+ "success_message": "The Stock Module is all set up!",
+ "title": "Let's Setup the Stock Module.",
+ "user_can_dismiss": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/buying_settings/buying_settings.json b/erpnext/stock/onboarding_step/buying_settings/buying_settings.json
new file mode 100644
index 00000000000..a788ccd4cc9
--- /dev/null
+++ b/erpnext/stock/onboarding_step/buying_settings/buying_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Update Settings",
+ "creation": "2020-05-06 15:53:44.667414",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:30:06.323797",
+ "modified_by": "Administrator",
+ "name": "Buying Settings",
+ "owner": "Administrator",
+ "reference_document": "Buying Settings",
+ "show_full_form": 0,
+ "title": "Configure Buying Settings.",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/create_a_product/create_a_product.json b/erpnext/stock/onboarding_step/create_a_product/create_a_product.json
new file mode 100644
index 00000000000..d2068e167b7
--- /dev/null
+++ b/erpnext/stock/onboarding_step/create_a_product/create_a_product.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-12 18:16:06.624554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-12 18:30:02.489949",
+ "modified_by": "Administrator",
+ "name": "Create a Product",
+ "owner": "Administrator",
+ "reference_document": "Item",
+ "show_full_form": 0,
+ "title": "Create a Product",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json b/erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json
new file mode 100644
index 00000000000..b7811a46df4
--- /dev/null
+++ b/erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-19 18:59:13.266713",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 18:59:13.266713",
+ "modified_by": "Administrator",
+ "name": "Create a Purchase Receipt",
+ "owner": "Administrator",
+ "reference_document": "Purchase Receipt",
+ "show_full_form": 1,
+ "title": "Create a Purchase Receipt",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/create_a_stock_entry/create_a_stock_entry.json b/erpnext/stock/onboarding_step/create_a_stock_entry/create_a_stock_entry.json
new file mode 100644
index 00000000000..2b83f657d6e
--- /dev/null
+++ b/erpnext/stock/onboarding_step/create_a_stock_entry/create_a_stock_entry.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-15 03:20:16.277043",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-15 03:30:58.047696",
+ "modified_by": "Administrator",
+ "name": "Create a Stock Entry",
+ "owner": "Administrator",
+ "reference_document": "Stock Entry",
+ "show_full_form": 1,
+ "title": "Create a Stock Entry",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json b/erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json
new file mode 100644
index 00000000000..7a64224bd43
--- /dev/null
+++ b/erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json
@@ -0,0 +1,19 @@
+{
+ "action": "Create Entry",
+ "creation": "2020-05-14 22:09:10.043554",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-14 22:09:10.043554",
+ "modified_by": "Administrator",
+ "name": "Create a Supplier",
+ "owner": "Administrator",
+ "reference_document": "Supplier",
+ "show_full_form": 0,
+ "title": "Create a Supplier",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json
new file mode 100644
index 00000000000..009a44f6e4d
--- /dev/null
+++ b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json
@@ -0,0 +1,19 @@
+{
+ "action": "Watch Video",
+ "creation": "2020-05-15 02:47:17.958806",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-26 15:55:41.457289",
+ "modified_by": "Administrator",
+ "name": "Introduction to Stock Entry",
+ "owner": "Administrator",
+ "show_full_form": 0,
+ "title": "Introduction to Stock Entry",
+ "validate_action": 1,
+ "video_url": "https://www.youtube.com/watch?v=Njt107hlY3I"
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json b/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json
new file mode 100644
index 00000000000..557c905bd6c
--- /dev/null
+++ b/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json
@@ -0,0 +1,20 @@
+{
+ "action": "Go to Page",
+ "creation": "2020-05-19 18:54:19.383397",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 0,
+ "is_skipped": 0,
+ "modified": "2020-05-19 18:54:19.383397",
+ "modified_by": "Administrator",
+ "name": "Setup your Warehouse",
+ "owner": "Administrator",
+ "path": "Tree/Warehouse",
+ "reference_document": "Warehouse",
+ "show_full_form": 0,
+ "title": "Setup your Warehouse",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/onboarding_step/stock_settings/stock_settings.json b/erpnext/stock/onboarding_step/stock_settings/stock_settings.json
new file mode 100644
index 00000000000..7591bff5386
--- /dev/null
+++ b/erpnext/stock/onboarding_step/stock_settings/stock_settings.json
@@ -0,0 +1,19 @@
+{
+ "action": "Show Form Tour",
+ "creation": "2020-05-15 02:53:57.209967",
+ "docstatus": 0,
+ "doctype": "Onboarding Step",
+ "idx": 0,
+ "is_complete": 0,
+ "is_mandatory": 0,
+ "is_single": 1,
+ "is_skipped": 0,
+ "modified": "2020-05-15 03:55:15.444151",
+ "modified_by": "Administrator",
+ "name": "Stock Settings",
+ "owner": "Administrator",
+ "reference_document": "Stock Settings",
+ "show_full_form": 0,
+ "title": "Explore Stock Settings",
+ "validate_action": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
index 27cf6b66ccb..5a931e7efac 100644
--- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
+++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+from frappe import _
from erpnext.controllers.trends import get_columns,get_data
def execute(filters=None):
@@ -10,5 +11,39 @@ def execute(filters=None):
data = []
conditions = get_columns(filters, "Delivery Note")
data = get_data(filters, conditions)
-
- return conditions["columns"], data
\ No newline at end of file
+
+ chart_data = get_chart_data(data, filters)
+
+ return conditions["columns"], data, None, chart_data
+
+def get_chart_data(data, filters):
+ if not data:
+ return []
+
+ labels, datapoints = [], []
+
+ if filters.get("group_by"):
+ # consider only consolidated row
+ data = [row for row in data if row[0]]
+
+ if len(data) > 10:
+ # get top 10 if data too long
+ data = sorted(data, key = lambda i: i[-1],reverse=True)
+ data = data[:10]
+
+ for row in data:
+ labels.append(row[0])
+ datapoints.append(row[-1])
+
+ return {
+ "data": {
+ "labels" : labels,
+ "datasets" : [
+ {
+ "name": _("Total Delivered Amount"),
+ "values": datapoints
+ }
+ ]
+ },
+ "type" : "bar"
+ }
\ No newline at end of file
diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.js b/erpnext/stock/report/item_shortage_report/item_shortage_report.js
new file mode 100644
index 00000000000..ca42a331e91
--- /dev/null
+++ b/erpnext/stock/report/item_shortage_report/item_shortage_report.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Item Shortage Report"] = {
+ "filters": [
+ {
+ "fieldname": "company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "width": "80",
+ "options": "Company",
+ "reqd": 1,
+ "default": frappe.defaults.get_default("company")
+ },
+ {
+ "fieldname": "warehouse",
+ "label": __("Warehouse"),
+ "fieldtype": "MultiSelectList",
+ "width": "100",
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Warehouse', txt);
+ }
+ }
+ ]
+};
diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.json b/erpnext/stock/report/item_shortage_report/item_shortage_report.json
index 577a8530b7e..17285c09de4 100644
--- a/erpnext/stock/report/item_shortage_report/item_shortage_report.json
+++ b/erpnext/stock/report/item_shortage_report/item_shortage_report.json
@@ -1,29 +1,30 @@
{
- "add_total_row": 0,
- "apply_user_permissions": 1,
- "creation": "2013-08-20 13:43:30",
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 3,
- "is_standard": "Yes",
- "json": "{\"add_total_row\": 0, \"sort_by\": \"Bin.projected_qty\", \"sort_order\": \"asc\", \"sort_by_next\": \"\", \"filters\": [[\"Bin\", \"projected_qty\", \"<\", \"0\"]], \"sort_order_next\": \"desc\", \"columns\": [[\"warehouse\", \"Bin\"], [\"item_code\", \"Bin\"], [\"actual_qty\", \"Bin\"], [\"ordered_qty\", \"Bin\"], [\"planned_qty\", \"Bin\"], [\"reserved_qty\", \"Bin\"], [\"projected_qty\", \"Bin\"]]}",
- "modified": "2017-02-24 20:00:46.439935",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Item Shortage Report",
- "owner": "Administrator",
- "query": "SELECT bin.warehouse as \"Warehouse:Link/Warehouse:150\",\n\tbin.item_code as \"Item Code:Link/Item:100\",\n\tbin.actual_qty as \"Actual Quantity:Float:120\",\n\tbin.ordered_qty as \"Ordered Quantity:Float:120\",\n\tbin.planned_qty as \"Planned Quantity:Float:120\",\n\tbin.reserved_qty as \"Reserved Quantity:Float:120\",\n\tbin.projected_qty as \"Project Quantity:Float:120\",\n\titem.item_name as \"Item Name:Data:150\",\n\titem.description as \"Description::200\"\nFROM tabBin as bin\nINNER JOIN tabItem as item\nON bin.item_code=item.name\nWHERE bin.projected_qty<0\nORDER BY bin.projected_qty;",
- "ref_doctype": "Bin",
- "report_name": "Item Shortage Report",
- "report_type": "Query Report",
+ "add_total_row": 0,
+ "creation": "2013-08-20 13:43:30",
+ "disable_prepared_report": 0,
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 3,
+ "is_standard": "Yes",
+ "json": "{\"add_total_row\": 0, \"sort_by\": \"Bin.projected_qty\", \"sort_order\": \"asc\", \"sort_by_next\": \"\", \"filters\": [[\"Bin\", \"projected_qty\", \"<\", \"0\"]], \"sort_order_next\": \"desc\", \"columns\": [[\"warehouse\", \"Bin\"], [\"item_code\", \"Bin\"], [\"actual_qty\", \"Bin\"], [\"ordered_qty\", \"Bin\"], [\"planned_qty\", \"Bin\"], [\"reserved_qty\", \"Bin\"], [\"projected_qty\", \"Bin\"]]}",
+ "modified": "2020-05-14 12:32:07.158991",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Shortage Report",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "query": "",
+ "ref_doctype": "Bin",
+ "report_name": "Item Shortage Report",
+ "report_type": "Script Report",
"roles": [
{
"role": "Sales User"
- },
+ },
{
"role": "Purchase User"
- },
+ },
{
"role": "Stock User"
}
diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.py b/erpnext/stock/report/item_shortage_report/item_shortage_report.py
new file mode 100644
index 00000000000..086d833bbc4
--- /dev/null
+++ b/erpnext/stock/report/item_shortage_report/item_shortage_report.py
@@ -0,0 +1,162 @@
+# 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 _
+
+def execute(filters=None):
+ columns = get_columns()
+ conditions = get_conditions(filters)
+ data = get_data(conditions, filters)
+
+ if not data:
+ return [], [], None, []
+
+ chart_data = get_chart_data(data)
+
+ return columns, data, None, chart_data
+
+def get_conditions(filters):
+ conditions = ""
+
+ if filters.get("warehouse"):
+ conditions += "AND warehouse in %(warehouse)s"
+ if filters.get("company"):
+ conditions += "AND company = %(company)s"
+
+ return conditions
+
+def get_data(conditions, filters):
+ data = frappe.db.sql("""
+ SELECT
+ bin.warehouse,
+ bin.item_code,
+ bin.actual_qty ,
+ bin.ordered_qty ,
+ bin.planned_qty ,
+ bin.reserved_qty ,
+ bin.reserved_qty_for_production,
+ bin.projected_qty ,
+ warehouse.company,
+ item.item_name ,
+ item.description
+ FROM
+ `tabBin` bin,
+ `tabWarehouse` warehouse,
+ `tabItem` item
+ WHERE
+ bin.projected_qty<0
+ AND warehouse.name = bin.warehouse
+ AND bin.item_code=item.name
+ {0}
+ ORDER BY bin.projected_qty;""".format(conditions), filters, as_dict=1)
+
+ return data
+
+def get_chart_data(data):
+ labels, datapoints = [], []
+
+ for row in data:
+ labels.append(row.get("item_code"))
+ datapoints.append(row.get("projected_qty"))
+
+ if len(data) > 10:
+ labels = labels[:10]
+ datapoints = datapoints[:10]
+
+ return {
+ "data": {
+ "labels": labels,
+ "datasets":[
+ {
+ "name": _("Projected Qty"),
+ "values": datapoints
+ }
+ ]
+ },
+ "type": "bar"
+ }
+
+def get_columns():
+ columns = [
+ {
+ "label": _("Warehouse"),
+ "fieldname": "warehouse",
+ "fieldtype": "Link",
+ "options": "Warehouse",
+ "width": 150
+ },
+ {
+ "label": _("Item"),
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "options": "Item",
+ "width": 150
+ },
+ {
+ "label": _("Actual Quantity"),
+ "fieldname": "actual_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Ordered Quantity"),
+ "fieldname": "ordered_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Planned Quantity"),
+ "fieldname": "planned_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Reserved Quantity"),
+ "fieldname": "reserved_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Reserved Quantity for Production"),
+ "fieldname": "reserved_qty_for_production",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Projected Quantity"),
+ "fieldname": "projected_qty",
+ "fieldtype": "Float",
+ "width": 120,
+ "convertible": "qty"
+ },
+ {
+ "label": _("Company"),
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "options": "Company",
+ "width": 120
+ },
+ {
+ "label": _("Item Name"),
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "width": 100
+ },
+ {
+ "label": _("Description"),
+ "fieldname": "description",
+ "fieldtype": "Data",
+ "width": 120
+ }
+ ]
+
+ return columns
+
+
diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
index 9a972104a27..5df3fa8067b 100644
--- a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
+++ b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
@@ -8,7 +8,7 @@ from frappe.utils import getdate, flt
def execute(filters=None):
if not filters: filters = {}
- float_preceision = frappe.db.get_default("float_preceision")
+ float_precision = frappe.db.get_default("float_precision")
condition = get_condition(filters)
@@ -25,7 +25,7 @@ def execute(filters=None):
data = []
for item in items:
total_outgoing = flt(consumed_item_map.get(item.name, 0)) + flt(delivered_item_map.get(item.name,0))
- avg_daily_outgoing = flt(total_outgoing / diff, float_preceision)
+ avg_daily_outgoing = flt(total_outgoing / diff, float_precision)
reorder_level = (avg_daily_outgoing * flt(item.lead_time_days)) + flt(item.safety_stock)
data.append([item.name, item.item_name, item.item_group, item.brand, item.description,
diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json
deleted file mode 100644
index dfaa9ed6cc7..00000000000
--- a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "add_total_row": 1,
- "creation": "2013-02-22 18:01:55",
- "disable_prepared_report": 0,
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 3,
- "is_standard": "Yes",
- "modified": "2019-04-01 22:12:05.573343",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Purchase Order Items To Be Received",
- "owner": "Administrator",
- "prepared_report": 0,
- "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`status` as \"Status:Data:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order Item`.`schedule_date` as \"Reqd by Date:Date:110\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order`.`supplier_name` as \"Supplier Name::150\",\n\t`tabPurchase Order Item`.`project` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.warehouse as \"Warehouse:Link/Warehouse:150\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n `tabPurchase Order Item`.brand as \"Brand::100\",\n\t`tabPurchase Order`.`company` as \"Company:Link/Company:\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status not in (\"Stopped\", \"Closed\")\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc",
- "ref_doctype": "Purchase Receipt",
- "report_name": "Purchase Order Items To Be Received",
- "report_type": "Query Report",
- "roles": [
- {
- "role": "Stock Manager"
- },
- {
- "role": "Stock User"
- },
- {
- "role": "Purchase User"
- },
- {
- "role": "Accounts User"
- }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/stock/report/purchase_order_items_to_be_received_or_billed/purchase_order_items_to_be_received_or_billed.json b/erpnext/stock/report/purchase_order_items_to_be_received_or_billed/purchase_order_items_to_be_received_or_billed.json
deleted file mode 100644
index 48c0f423fd9..00000000000
--- a/erpnext/stock/report/purchase_order_items_to_be_received_or_billed/purchase_order_items_to_be_received_or_billed.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "add_total_row": 0,
- "creation": "2019-09-16 14:10:33.102865",
- "disable_prepared_report": 0,
- "disabled": 0,
- "docstatus": 0,
- "doctype": "Report",
- "idx": 0,
- "is_standard": "Yes",
- "modified": "2019-09-21 15:19:55.710578",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Purchase Order Items To Be Received or Billed",
- "owner": "Administrator",
- "prepared_report": 0,
- "query": "SELECT\n\t`poi_pri`.`purchase_order` as \"Purchase Order:Link/Purchase Order:120\",\n\t`poi_pri`.`status` as \"Status:Data:120\",\n\t`poi_pri`.`transaction_date` as \"Date:Date:100\",\n\t`poi_pri`.`schedule_date` as \"Reqd by Date:Date:110\",\n\t`poi_pri`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`poi_pri`.`supplier_name` as \"Supplier Name::150\",\n\t`poi_pri`.`item_code` as \"Item Code:Link/Item:120\",\n\t`poi_pri`.`qty` as \"Qty:Float:100\",\n\t`poi_pri`.`base_amount` as \"Base Amount:Currency:100\",\n\t`poi_pri`.`received_qty` as \"Received Qty:Float:100\",\n\t`poi_pri`.`received_amount` as \"Received Qty Amount:Currency:100\",\n\t`poi_pri`.`qty_to_receive` as \"Qty to Receive:Float:100\",\n\t`poi_pri`.`amount_to_be_received` as \"Amount to Receive:Currency:100\",\n\t`poi_pri`.`billed_amount` as \"Billed Amount:Currency:100\",\n\t`poi_pri`.`amount_to_be_billed` as \"Amount To Be Billed:Currency:100\",\n\tSUM(`pii`.`qty`) AS \"Billed Qty:Float:100\",\n\t`poi_pri`.qty - SUM(`pii`.`qty`) AS \"Qty To Be Billed:Float:100\",\n\t`poi_pri`.`warehouse` as \"Warehouse:Link/Warehouse:150\",\n\t`poi_pri`.`item_name` as \"Item Name::150\",\n\t`poi_pri`.`description` as \"Description::200\",\n\t`poi_pri`.`brand` as \"Brand::100\",\n\t`poi_pri`.`project` as \"Project\",\n\t`poi_pri`.`company` as \"Company:Link/Company:\"\nFROM\n\t(SELECT\n\t\t`po`.`name` AS 'purchase_order',\n\t\t`po`.`status`,\n\t\t`po`.`company`,\n\t\t`poi`.`warehouse`,\n\t\t`poi`.`brand`,\n\t\t`poi`.`description`,\n\t\t`po`.`transaction_date`,\n\t\t`poi`.`schedule_date`,\n\t\t`po`.`supplier`,\n\t\t`po`.`supplier_name`,\n\t\t`poi`.`project`,\n\t\t`poi`.`item_code`,\n\t\t`poi`.`item_name`,\n\t\t`poi`.`qty`,\n\t\t`poi`.`base_amount`,\n\t\t`poi`.`received_qty`,\n\t\t(`poi`.billed_amt * ifnull(`po`.conversion_rate, 1)) as billed_amount,\n\t\t(`poi`.base_amount - (`poi`.billed_amt * ifnull(`po`.conversion_rate, 1))) as amount_to_be_billed,\n\t\t`poi`.`qty` - IFNULL(`poi`.`received_qty`, 0) AS 'qty_to_receive',\n\t\t(`poi`.`qty` - IFNULL(`poi`.`received_qty`, 0)) * `poi`.`rate` AS 'amount_to_be_received',\n\t\tSUM(`pri`.`amount`) AS 'received_amount',\n\t\t`poi`.`name` AS 'poi_name',\n\t\t`pri`.`name` AS 'pri_name'\n\tFROM\n\t\t`tabPurchase Order` po\n\t\tLEFT JOIN `tabPurchase Order Item` poi\n\t\tON `poi`.`parent` = `po`.`name`\n\t\tLEFT JOIN `tabPurchase Receipt Item` pri\n\t\tON `pri`.`purchase_order_item` = `poi`.`name`\n\t\t\tAND `pri`.`docstatus`=1\n\tWHERE\n\t\t`po`.`status` not in ('Stopped', 'Closed')\n\t\tAND `po`.`docstatus` = 1\n\t\tAND IFNULL(`poi`.`received_qty`, 0) < IFNULL(`poi`.`qty`, 0)\n\tGROUP BY `poi`.`name`\n\tORDER BY `po`.`transaction_date` ASC\n\t) poi_pri\n\tLEFT JOIN `tabPurchase Invoice Item` pii\n\tON `pii`.`po_detail` = `poi_pri`.`poi_name`\n\t\tAND `pii`.`docstatus`=1\nGROUP BY `poi_pri`.`poi_name`",
- "ref_doctype": "Purchase Order",
- "report_name": "Purchase Order Items To Be Received or Billed",
- "report_type": "Query Report",
- "roles": [
- {
- "role": "Purchase Manager"
- },
- {
- "role": "Purchase User"
- },
- {
- "role": "Stock User"
- },
- {
- "role": "Stock Manager"
- }
- ]
-}
\ No newline at end of file
diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
index 0e58920725e..8227f1548c1 100644
--- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
+++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+from frappe import _
from erpnext.controllers.trends import get_columns,get_data
def execute(filters=None):
@@ -11,4 +12,40 @@ def execute(filters=None):
conditions = get_columns(filters, "Purchase Receipt")
data = get_data(filters, conditions)
- return conditions["columns"], data
\ No newline at end of file
+ chart_data = get_chart_data(data, filters)
+
+ return conditions["columns"], data, None, chart_data
+
+def get_chart_data(data, filters):
+ if not data:
+ return []
+
+ labels, datapoints = [], []
+
+ if filters.get("group_by"):
+ # consider only consolidated row
+ data = [row for row in data if row[0]]
+
+ data = sorted(data, key = lambda i: i[-1], reverse=True)
+
+ if len(data) > 10:
+ # get top 10 if data too long
+ data = data[:10]
+
+ for row in data:
+ labels.append(row[0])
+ datapoints.append(row[-1])
+
+ return {
+ "data": {
+ "labels" : labels,
+ "datasets" : [
+ {
+ "name": _("Total Received Amount"),
+ "values": datapoints
+ }
+ ]
+ },
+ "type" : "bar",
+ "colors":["#5e64ff"]
+ }
\ No newline at end of file
diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.py b/erpnext/stock/report/stock_ageing/stock_ageing.py
index 803a5c81a3b..723ed5c1c46 100644
--- a/erpnext/stock/report/stock_ageing/stock_ageing.py
+++ b/erpnext/stock/report/stock_ageing/stock_ageing.py
@@ -37,7 +37,9 @@ def execute(filters=None):
data.append(row)
- return columns, data
+ chart_data = get_chart_data(data, filters)
+
+ return columns, data, None, chart_data
def get_average_age(fifo_queue, to_date):
batch_age = age_qty = total_qty = 0.0
@@ -51,7 +53,7 @@ def get_average_age(fifo_queue, to_date):
age_qty += batch_age * 1
total_qty += 1
- return (age_qty / total_qty) if total_qty else 0.0
+ return flt(age_qty / total_qty, 2) if total_qty else 0.0
def get_columns(filters):
columns = [
@@ -178,10 +180,10 @@ def get_fifo_queue(filters, sle=None):
qty_to_pop = abs(d.actual_qty)
while qty_to_pop:
batch = fifo_queue[0] if fifo_queue else [0, None]
- if 0 < batch[0] <= qty_to_pop:
+ if 0 < flt(batch[0]) <= qty_to_pop:
# if batch qty > 0
# not enough or exactly same qty in current batch, clear batch
- qty_to_pop -= batch[0]
+ qty_to_pop -= flt(batch[0])
transferred_item_details[(d.voucher_no, d.name)].append(fifo_queue.pop(0))
else:
# all from current batch
@@ -230,3 +232,34 @@ def get_sle_conditions(filters):
where wh.lft >= {0} and rgt <= {1})""".format(lft, rgt))
return "and {}".format(" and ".join(conditions)) if conditions else ""
+
+def get_chart_data(data, filters):
+ if not data:
+ return []
+
+ labels, datapoints = [], []
+
+ if filters.get("show_warehouse_wise_stock"):
+ return {}
+
+ data.sort(key = lambda row: row[6], reverse=True)
+
+ if len(data) > 10:
+ data = data[:10]
+
+ for row in data:
+ labels.append(row[0])
+ datapoints.append(row[6])
+
+ return {
+ "data" : {
+ "labels": labels,
+ "datasets": [
+ {
+ "name": _("Average Age"),
+ "values": datapoints
+ }
+ ]
+ },
+ "type" : "bar"
+ }
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index b4cb8cadb45..e1b3730f2f9 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -548,7 +548,16 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
if not allow_zero_rate and not valuation_rate and raise_error_if_no_rate \
and cint(erpnext.is_perpetual_inventory_enabled(company)):
frappe.local.message_log = []
- frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting / cancelling this entry.")
- .format(item_code, voucher_type, voucher_no))
+ form_link = frappe.utils.get_link_to_form("Item", item_code)
+
+ message = _("Valuation Rate for the Item {0}, is required to do accounting entries for {1} {2}.").format(form_link, voucher_type, voucher_no)
+ message += " " + _(" Here are the options to proceed:")
+ solutions = " " + _("If the item is transacting as a Zero Valuation Rate item in this entry, please enable 'Allow Zero Valuation Rate' in the {0} Item table.").format(voucher_type) + " "
+ solutions += "" + _("If not, you can Cancel / Submit this entry ") + _("{0}").format(frappe.bold("after")) + _(" performing either one below:") + " "
+ sub_solutions = "" + _("Create an incoming stock transaction for the Item.") + " "
+ sub_solutions += "" + _("Mention Valuation Rate in the Item master.") + " "
+ msg = message + solutions + sub_solutions + ""
+
+ frappe.throw(msg=msg, title=_("Valuation Rate Missing"))
return valuation_rate
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index f21dc3f8b03..11e758fce32 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -230,12 +230,12 @@ def get_valuation_method(item_code):
def get_fifo_rate(previous_stock_queue, qty):
"""get FIFO (average) Rate from Queue"""
- if qty >= 0:
+ if flt(qty) >= 0:
total = sum(f[0] for f in previous_stock_queue)
return sum(flt(f[0]) * flt(f[1]) for f in previous_stock_queue) / flt(total) if total else 0.0
else:
available_qty_for_outgoing, outgoing_cost = 0, 0
- qty_to_pop = abs(qty)
+ qty_to_pop = abs(flt(qty))
while qty_to_pop and previous_stock_queue:
batch = previous_stock_queue[0]
if 0 < batch[0] <= qty_to_pop:
diff --git a/erpnext/support/desk_page/support/support.json b/erpnext/support/desk_page/support/support.json
index 596987f46a5..a3fe72d0519 100644
--- a/erpnext/support/desk_page/support/support.json
+++ b/erpnext/support/desk_page/support/support.json
@@ -2,8 +2,8 @@
"cards": [
{
"hidden": 0,
- "label": "Service Level Agreement",
- "links": "[\n {\n \"description\": \"Service Level.\",\n \"label\": \"Service Level\",\n \"name\": \"Service Level\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Service Level Agreement.\",\n \"label\": \"Service Level Agreement\",\n \"name\": \"Service Level Agreement\",\n \"type\": \"doctype\"\n }\n]"
+ "label": "Issues",
+ "links": "[\n {\n \"description\": \"Support queries from customers.\",\n \"label\": \"Issue\",\n \"name\": \"Issue\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Issue Type.\",\n \"label\": \"Issue Type\",\n \"name\": \"Issue Type\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Issue Priority.\",\n \"label\": \"Issue Priority\",\n \"name\": \"Issue Priority\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
@@ -12,8 +12,8 @@
},
{
"hidden": 0,
- "label": "Issues",
- "links": "[\n {\n \"description\": \"Support queries from customers.\",\n \"label\": \"Issue\",\n \"name\": \"Issue\",\n \"onboard\": 1,\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Issue Type.\",\n \"label\": \"Issue Type\",\n \"name\": \"Issue Type\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Issue Priority.\",\n \"label\": \"Issue Priority\",\n \"name\": \"Issue Priority\",\n \"type\": \"doctype\"\n }\n]"
+ "label": "Service Level Agreement",
+ "links": "[\n {\n \"description\": \"Service Level.\",\n \"label\": \"Service Level\",\n \"name\": \"Service Level\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Service Level Agreement.\",\n \"label\": \"Service Level Agreement\",\n \"name\": \"Service Level Agreement\",\n \"type\": \"doctype\"\n }\n]"
},
{
"hidden": 0,
@@ -39,11 +39,11 @@
"docstatus": 0,
"doctype": "Desk Page",
"extends_another_page": 0,
- "icon": "",
+ "hide_custom": 0,
"idx": 0,
"is_standard": 1,
"label": "Support",
- "modified": "2020-04-01 11:28:51.120583",
+ "modified": "2020-05-28 13:51:23.869954",
"modified_by": "Administrator",
"module": "Support",
"name": "Support",
@@ -52,19 +52,22 @@
"pin_to_top": 0,
"shortcuts": [
{
+ "color": "#ffc4c4",
+ "format": "{} Assigned",
"label": "Issue",
"link_to": "Issue",
- "type": "DocType"
- },
- {
- "label": "Service Level",
- "link_to": "Service Level",
+ "stats_filter": "{\n \"_assign\": [\"like\", '%' + frappe.session.user + '%'],\n \"status\": \"Open\"\n}",
"type": "DocType"
},
{
"label": "Maintenance Visit",
"link_to": "Maintenance Visit",
"type": "DocType"
+ },
+ {
+ "label": "Service Level",
+ "link_to": "Service Level",
+ "type": "DocType"
}
]
}
\ No newline at end of file
diff --git a/erpnext/support/web_form/issues/issues.json b/erpnext/support/web_form/issues/issues.json
index 0f15e4737fd..1df9fb79696 100644
--- a/erpnext/support/web_form/issues/issues.json
+++ b/erpnext/support/web_form/issues/issues.json
@@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
- "modified": "2020-03-06 05:24:05.749664",
+ "modified": "2020-05-19 13:01:10.729088",
"modified_by": "Administrator",
"module": "Support",
"name": "issues",
@@ -76,7 +76,7 @@
{
"allow_read_on_all_link_options": 0,
"fieldname": "description",
- "fieldtype": "Text",
+ "fieldtype": "Text Editor",
"hidden": 0,
"label": "Description",
"max_length": 0,
diff --git a/erpnext/tests/test_woocommerce.py b/erpnext/tests/test_woocommerce.py
index ce0f47d685f..df715ab2027 100644
--- a/erpnext/tests/test_woocommerce.py
+++ b/erpnext/tests/test_woocommerce.py
@@ -24,7 +24,7 @@ class TestWoocommerce(unittest.TestCase):
woo_settings.creation_user = "Administrator"
woo_settings.save(ignore_permissions=True)
- def test_sales_order_for_woocommerece(self):
+ def test_sales_order_for_woocommerce(self):
frappe.flags.woocomm_test_order_data = {"id":75,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":False,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":"","date_paid_gmt":"","date_completed":"","date_completed_gmt":"","cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}
order()
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index ea96503dff9..024aa6f31dd 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -166,7 +166,7 @@ class TransactionBase(StatusUpdater):
last_transaction_time = frappe.db.sql("""
select MAX(timestamp(posting_date, posting_time)) as posting_time
from `tabStock Ledger Entry`
- where docstatus = 1 and fiscal_year = %s""", (fiscal_year))[0][0]
+ where docstatus = 1""")[0][0]
cur_doc_posting_datetime = "%s %s" % (self.posting_date, self.get("posting_time") or "00:00:00")
diff --git a/erpnext/www/all-products/index.html b/erpnext/www/all-products/index.html
index f09021412b7..0126b59c64a 100644
--- a/erpnext/www/all-products/index.html
+++ b/erpnext/www/all-products/index.html
@@ -11,7 +11,7 @@