From c3b74affe33758013cc87f11d1447242f2c56317 Mon Sep 17 00:00:00 2001 From: P-Froggy <60393001+P-Froggy@users.noreply.github.com> Date: Thu, 18 Jun 2020 01:48:37 +0200 Subject: [PATCH 01/34] fix: Set Value of wrong Bank Account Field in Payment Entry Company bank account was wrongly inserted into the field "Party Bank Account" in payment entry, instead of "Bank Account". Also changes the label of "Default Bank Account" to "Default Company Bank Account", like suggested in PR #20632 --- erpnext/accounts/doctype/payment_entry/payment_entry.js | 8 ++++---- erpnext/buying/doctype/supplier/supplier.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index a378a51cdf..a47da78f1f 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -25,7 +25,7 @@ frappe.ui.form.on('Payment Entry', { }); frm.set_query("party_type", function() { return{ - "filters": { + filters: { "name": ["in", Object.keys(frappe.boot.party_account_types)], } } @@ -33,7 +33,7 @@ frappe.ui.form.on('Payment Entry', { frm.set_query("party_bank_account", function() { return { filters: { - "is_company_account":0, + is_company_account: 0, party_type: frm.doc.party_type, party: frm.doc.party } @@ -42,7 +42,7 @@ frappe.ui.form.on('Payment Entry', { frm.set_query("bank_account", function() { return { filters: { - "is_company_account":1 + is_company_account: 1 } } }); @@ -341,7 +341,7 @@ frappe.ui.form.on('Payment Entry', { () => { frm.set_party_account_based_on_party = false; if (r.message.bank_account) { - frm.set_value("party_bank_account", r.message.bank_account); + frm.set_value("bank_account", r.message.bank_account); } } ]); diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 4606395ebe..40362b1d40 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -97,7 +97,7 @@ { "fieldname": "default_bank_account", "fieldtype": "Link", - "label": "Default Bank Account", + "label": "Default Company Bank Account", "options": "Bank Account" }, { @@ -384,7 +384,7 @@ "idx": 370, "image_field": "image", "links": [], - "modified": "2020-03-17 09:48:30.578242", + "modified": "2020-06-17 23:18:20", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", From a96a16cf59ab21dbae813a4f868f97b3c33c8a0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2020 11:07:58 +0000 Subject: [PATCH 02/34] build(deps): bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c5509d6e1a..b19f566fd0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1084,9 +1084,9 @@ lodash.set@^4.3.2: integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.7.14: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== lowercase-keys@^1.0.0: version "1.0.1" From 9119b4c5386b489fbdd343288089e55b21b77771 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Tue, 28 Jul 2020 08:49:44 +0530 Subject: [PATCH 03/34] fix: Unable to submit backdated stock transactions for different items (#22648) * fix: Unable to submit backdated stock transactions for different items * fix: Test cases * fix: Test Cases * fix: Test Cases * fix: Test for stock account JV * fix: Journal Entry Test --- .../doctype/coupon_code/test_coupon_code.py | 27 +++++++----- .../journal_entry/test_journal_entry.py | 42 +++++++++++++++--- .../doctype/pos_invoice/test_pos_invoice.py | 44 ++++++++++++------- erpnext/accounts/general_ledger.py | 5 ++- erpnext/stock/doctype/item/item.py | 4 +- .../doctype/stock_entry/test_stock_entry.py | 26 ++++++++--- 6 files changed, 102 insertions(+), 46 deletions(-) diff --git a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py index 990b896fde..3a0d4162ae 100644 --- a/erpnext/accounts/doctype/coupon_code/test_coupon_code.py +++ b/erpnext/accounts/doctype/coupon_code/test_coupon_code.py @@ -26,22 +26,22 @@ def test_create_test_data(): "item_group": "_Test Item Group", "item_name": "_Test Tesla Car", "apply_warehouse_wise_reorder_level": 0, - "warehouse":"_Test Warehouse - _TC", + "warehouse":"Stores - TCP1", "gst_hsn_code": "999800", "valuation_rate": 5000, "standard_rate":5000, "item_defaults": [{ - "company": "_Test Company", - "default_warehouse": "_Test Warehouse - _TC", + "company": "_Test Company with perpetual inventory", + "default_warehouse": "Stores - TCP1", "default_price_list":"_Test Price List", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "buying_cost_center": "_Test Cost Center - _TC", - "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC" + "expense_account": "Cost of Goods Sold - TCP1", + "buying_cost_center": "Main - TCP1", + "selling_cost_center": "Main - TCP1", + "income_account": "Sales - TCP1" }], "show_in_website": 1, "route":"-test-tesla-car", - "website_warehouse": "_Test Warehouse - _TC" + "website_warehouse": "Stores - TCP1" }) item.insert() # create test item price @@ -63,12 +63,12 @@ def test_create_test_data(): "items": [{ "item_code": "_Test Tesla Car" }], - "warehouse":"_Test Warehouse - _TC", + "warehouse":"Stores - TCP1", "coupon_code_based":1, "selling": 1, "rate_or_discount": "Discount Percentage", "discount_percentage": 30, - "company": "_Test Company", + "company": "_Test Company with perpetual inventory", "currency":"INR", "for_price_list":"_Test Price List" }) @@ -112,7 +112,10 @@ class TestCouponCode(unittest.TestCase): self.assertEqual(coupon_code.get("used"),0) def test_2_sales_order_with_coupon_code(self): - so = make_sales_order(customer="_Test Customer",selling_price_list="_Test Price List",item_code="_Test Tesla Car", rate=5000,qty=1, do_not_submit=True) + so = make_sales_order(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', + customer="_Test Customer", selling_price_list="_Test Price List", item_code="_Test Tesla Car", rate=5000,qty=1, + do_not_submit=True) + so = frappe.get_doc('Sales Order', so.name) # check item price before coupon code is applied self.assertEqual(so.items[0].rate, 5000) @@ -120,7 +123,7 @@ class TestCouponCode(unittest.TestCase): so.sales_partner='_Test Coupon Partner' so.save() # check item price after coupon code is applied - self.assertEqual(so.items[0].rate, 3500) + self.assertEqual(so.items[0].rate, 3500) so.submit() def test_3_check_coupon_code_used_after_so(self): diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 23ad1eef14..479d4b64bb 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -6,6 +6,7 @@ import unittest, frappe from frappe.utils import flt, nowdate from erpnext.accounts.doctype.account.test_account import get_inventory_account from erpnext.exceptions import InvalidAccountCurrency +from erpnext.accounts.general_ledger import StockAccountInvalidTransaction class TestJournalEntry(unittest.TestCase): def test_journal_entry_with_against_jv(self): @@ -81,19 +82,46 @@ class TestJournalEntry(unittest.TestCase): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory set_perpetual_inventory() - jv = frappe.copy_doc(test_records[0]) + jv = frappe.copy_doc({ + "cheque_date": nowdate(), + "cheque_no": "33", + "company": "_Test Company with perpetual inventory", + "doctype": "Journal Entry", + "accounts": [ + { + "account": "Debtors - TCP1", + "party_type": "Customer", + "party": "_Test Customer", + "credit_in_account_currency": 400.0, + "debit_in_account_currency": 0.0, + "doctype": "Journal Entry Account", + "parentfield": "accounts", + "cost_center": "Main - TCP1" + }, + { + "account": "_Test Bank - TCP1", + "credit_in_account_currency": 0.0, + "debit_in_account_currency": 400.0, + "doctype": "Journal Entry Account", + "parentfield": "accounts", + "cost_center": "Main - TCP1" + } + ], + "naming_series": "_T-Journal Entry-", + "posting_date": nowdate(), + "user_remark": "test", + "voucher_type": "Bank Entry" + }) + jv.get("accounts")[0].update({ - "account": get_inventory_account('_Test Company'), - "company": "_Test Company", + "account": get_inventory_account('_Test Company with perpetual inventory'), + "company": "_Test Company with perpetual inventory", "party_type": None, "party": None }) - jv.insert() - - from erpnext.accounts.general_ledger import StockAccountInvalidTransaction self.assertRaises(StockAccountInvalidTransaction, jv.submit) - + jv.cancel() set_perpetual_inventory(0) def test_multi_currency(self): diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index f29572542c..9c62a87677 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -23,13 +23,13 @@ class TestPOSInvoice(unittest.TestCase): import time time.sleep(1) self.assertRaises(frappe.TimestampMismatchError, w2.save) - + def test_change_naming_series(self): inv = create_pos_invoice(do_not_submit=1) inv.naming_series = 'TEST-' self.assertRaises(frappe.CannotChangeConstantError, inv.save) - + def test_discount_and_inclusive_tax(self): inv = create_pos_invoice(qty=100, rate=50, do_not_save=1) inv.append("taxes", { @@ -66,7 +66,7 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(inv.net_total, 4298.25) self.assertEqual(inv.grand_total, 4900.00) - + def test_tax_calculation_with_multiple_items(self): inv = create_pos_invoice(qty=84, rate=4.6, do_not_save=True) item_row = inv.get("items")[0] @@ -148,7 +148,7 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(inv.grand_total, 5675.57) self.assertEqual(inv.rounding_adjustment, 0.43) self.assertEqual(inv.rounded_total, 5676.0) - + def test_tax_calculation_with_multiple_items_and_discount(self): inv = create_pos_invoice(qty=1, rate=75, do_not_save=True) item_row = inv.get("items")[0] @@ -194,7 +194,7 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(pos_return.get('payments')[0].amount, -500) self.assertEqual(pos_return.get('payments')[1].amount, -500) - + def test_pos_change_amount(self): pos = create_pos_invoice(company= "_Test Company", debit_to="Debtors - _TC", income_account = "Sales - _TC", expense_account = "Cost of Goods Sold - _TC", rate=105, @@ -208,33 +208,43 @@ class TestPOSInvoice(unittest.TestCase): self.assertEqual(pos.grand_total, 105.0) self.assertEqual(pos.change_amount, 5.0) - + def test_without_payment(self): inv = create_pos_invoice(do_not_save=1) # Check that the invoice cannot be submitted without payments inv.payments = [] self.assertRaises(frappe.ValidationError, inv.insert) - + def test_serialized_item_transaction(self): from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos - se = make_serialized_item(target_warehouse="_Test Warehouse - _TC") + se = make_serialized_item(company='_Test Company with perpetual inventory', + target_warehouse="Stores - TCP1", cost_center='Main - TCP1', expense_account='Cost of Goods Sold - TCP1') + serial_nos = get_serial_nos(se.get("items")[0].serial_no) - pos = create_pos_invoice(item=se.get("items")[0].item_code, rate=1000, do_not_save=1) + pos = create_pos_invoice(company='_Test Company with perpetual inventory', debit_to='Debtors - TCP1', + account_for_change_amount='Cash - TCP1', warehouse='Stores - TCP1', income_account='Sales - TCP1', + expense_account='Cost of Goods Sold - TCP1', cost_center='Main - TCP1', + item=se.get("items")[0].item_code, rate=1000, do_not_save=1) + pos.get("items")[0].serial_no = serial_nos[0] - pos.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 1000}) + pos.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - TCP1', 'amount': 1000}) pos.insert() pos.submit() - pos2 = create_pos_invoice(item=se.get("items")[0].item_code, rate=1000, do_not_save=1) + pos2 = create_pos_invoice(company='_Test Company with perpetual inventory', debit_to='Debtors - TCP1', + account_for_change_amount='Cash - TCP1', warehouse='Stores - TCP1', income_account='Sales - TCP1', + expense_account='Cost of Goods Sold - TCP1', cost_center='Main - TCP1', + item=se.get("items")[0].item_code, rate=1000, do_not_save=1) + pos2.get("items")[0].serial_no = serial_nos[0] - pos2.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 1000}) - + pos2.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - TCP1', 'amount': 1000}) + self.assertRaises(frappe.ValidationError, pos2.insert) - + def test_loyalty_points(self): from erpnext.accounts.doctype.loyalty_program.test_loyalty_program import create_records from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points @@ -255,14 +265,14 @@ class TestPOSInvoice(unittest.TestCase): inv.cancel() after_cancel_lp_details = get_loyalty_program_details_with_points(inv.customer, company=inv.company, loyalty_program=inv.loyalty_program) self.assertEqual(after_cancel_lp_details.loyalty_points, before_lp_details.loyalty_points) - + def test_loyalty_points_redeemption(self): from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points # add 10 loyalty points create_pos_invoice(customer="Test Loyalty Customer", rate=10000) before_lp_details = get_loyalty_program_details_with_points("Test Loyalty Customer", company="_Test Company", loyalty_program="Test Single Loyalty") - + inv = create_pos_invoice(customer="Test Loyalty Customer", rate=10000, do_not_save=1) inv.redeem_loyalty_points = 1 inv.loyalty_points = before_lp_details.loyalty_points @@ -299,7 +309,7 @@ def create_pos_invoice(**args): pos_inv.return_against = args.return_against pos_inv.currency=args.currency or "INR" pos_inv.conversion_rate = args.conversion_rate or 1 - pos_inv.account_for_change_amount = "Cash - _TC" + pos_inv.account_for_change_amount = args.account_for_change_amount or "Cash - _TC" pos_inv.append("items", { "item_code": args.item or args.item_code or "_Test Item", diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index a245d63f52..cf3deb828f 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -158,8 +158,10 @@ def validate_account_for_perpetual_inventory(gl_map): if account not in aii_accounts: continue + # Always use current date to get stock and account balance as there can future entries for + # other items account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(account, - gl_map[0].posting_date, gl_map[0].company) + getdate(), gl_map[0].company) if gl_map[0].voucher_type=="Journal Entry": # In case of Journal Entry, there are no corresponding SL entries, @@ -169,7 +171,6 @@ def validate_account_for_perpetual_inventory(gl_map): frappe.throw(_("Account: {0} can only be updated via Stock Transactions") .format(account), StockAccountInvalidTransaction) - # This has been comment for a temporary, will add this code again on release of immutable ledger elif account_bal != stock_bal: precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"), currency=frappe.get_cached_value('Company', gl_map[0].company, "default_currency")) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index d5f479ff82..d7b43bf399 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -13,7 +13,7 @@ from erpnext.controllers.item_variant import (ItemVariantExistsError, from erpnext.setup.doctype.item_group.item_group import (get_parent_item_groups, invalidate_cache_for) from frappe import _, msgprint from frappe.utils import (cint, cstr, flt, formatdate, get_timestamp, getdate, - now_datetime, random_string, strip, get_link_to_form) + now_datetime, random_string, strip, get_link_to_form, nowtime) from frappe.utils.html_utils import clean_html from frappe.website.doctype.website_slideshow.website_slideshow import \ get_slideshow @@ -194,7 +194,7 @@ class Item(WebsiteGenerator): if default_warehouse: stock_entry = make_stock_entry(item_code=self.name, target=default_warehouse, qty=self.opening_stock, - rate=self.valuation_rate, company=default.company) + rate=self.valuation_rate, company=default.company, posting_date=getdate(), posting_time=nowtime()) stock_entry.add_comment("Comment", _("Opening Stock")) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 0fbc63101e..8e25804511 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -413,7 +413,7 @@ class TestStockEntry(unittest.TestCase): def test_serial_item_error(self): se, serial_nos = self.test_serial_by_series() if not frappe.db.exists('Serial No', 'ABCD'): - make_serialized_item("_Test Serialized Item", "ABCD\nEFGH") + make_serialized_item(item_code="_Test Serialized Item", serial_no="ABCD\nEFGH") se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" @@ -823,15 +823,29 @@ class TestStockEntry(unittest.TestCase): ]) ) -def make_serialized_item(item_code=None, serial_no=None, target_warehouse=None): +def make_serialized_item(**args): + args = frappe._dict(args) se = frappe.copy_doc(test_records[0]) - se.get("items")[0].item_code = item_code or "_Test Serialized Item With Series" - se.get("items")[0].serial_no = serial_no + + if args.company: + se.company = args.company + + se.get("items")[0].item_code = args.item_code or "_Test Serialized Item With Series" + + if args.serial_no: + se.get("items")[0].serial_no = args.serial_no + + if args.cost_center: + se.get("items")[0].cost_center = args.cost_center + + if args.expense_account: + se.get("items")[0].expense_account = args.expense_account + se.get("items")[0].qty = 2 se.get("items")[0].transfer_qty = 2 - if target_warehouse: - se.get("items")[0].t_warehouse = target_warehouse + if args.target_warehouse: + se.get("items")[0].t_warehouse = args.target_warehouse se.set_stock_entry_type() se.insert() From 48be7d37b864165f94b7d0e2e2481c24f0553cd7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 28 Jul 2020 09:00:09 +0530 Subject: [PATCH 04/34] fix: add order_by explicitly for lead (#22820) --- erpnext/hr/doctype/holiday_list/holiday_list_calendar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/hr/doctype/holiday_list/holiday_list_calendar.js b/erpnext/hr/doctype/holiday_list/holiday_list_calendar.js index 3cc8dd5036..4e188add3e 100644 --- a/erpnext/hr/doctype/holiday_list/holiday_list_calendar.js +++ b/erpnext/hr/doctype/holiday_list/holiday_list_calendar.js @@ -9,6 +9,7 @@ frappe.views.calendar["Holiday List"] = { "title": "description", "allDay": "allDay" }, + order_by: `from_date`, get_events_method: "erpnext.hr.doctype.holiday_list.holiday_list.get_events", filters: [ { From 701474cbaa80be58c51c2eb4fc75cb4040bc9c75 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 Jul 2020 09:11:37 +0530 Subject: [PATCH 05/34] fix: POS patch fix (#22818) --- erpnext/patches/v12_0/rename_pos_closing_doctype.py | 4 ++-- erpnext/patches/v13_0/replace_pos_payment_mode_table.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v12_0/rename_pos_closing_doctype.py b/erpnext/patches/v12_0/rename_pos_closing_doctype.py index 8ca92ef65c..0577f81234 100644 --- a/erpnext/patches/v12_0/rename_pos_closing_doctype.py +++ b/erpnext/patches/v12_0/rename_pos_closing_doctype.py @@ -12,11 +12,11 @@ def execute(): frappe.rename_doc('DocType', 'POS Closing Voucher Taxes', 'POS Closing Entry Taxes', force=True) if not frappe.db.exists('DocType', 'POS Closing Voucher Details'): - frappe.rename_doc('DocType', 'POS Closing Voucher Details', 'POS Closing Entry Details', force=True) + frappe.rename_doc('DocType', 'POS Closing Voucher Details', 'POS Closing Entry Detail', force=True) frappe.reload_doc('Accounts', 'doctype', 'POS Closing Entry') frappe.reload_doc('Accounts', 'doctype', 'POS Closing Entry Taxes') - frappe.reload_doc('Accounts', 'doctype', 'POS Closing Entry Details') + frappe.reload_doc('Accounts', 'doctype', 'POS Closing Entry Detail') if frappe.db.exists("DocType", "POS Closing Voucher"): frappe.delete_doc("DocType", "POS Closing Voucher") diff --git a/erpnext/patches/v13_0/replace_pos_payment_mode_table.py b/erpnext/patches/v13_0/replace_pos_payment_mode_table.py index 4a621b6a51..1ca211bf1b 100644 --- a/erpnext/patches/v13_0/replace_pos_payment_mode_table.py +++ b/erpnext/patches/v13_0/replace_pos_payment_mode_table.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe def execute(): - frappe.reload_doc("Selling", "doctype", "POS Payment Method") + frappe.reload_doc("accounts", "doctype", "POS Payment Method") pos_profiles = frappe.get_all("POS Profile") for pos_profile in pos_profiles: From 81ae6c32400991a5dcbcc9602b99a01b153b893b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 28 Jul 2020 12:27:41 +0530 Subject: [PATCH 06/34] fix: reload HR Settings to fix failing setup (#22802) Co-authored-by: Marica --- erpnext/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index a24f5f76c8..3bd416952f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -15,7 +15,7 @@ erpnext.patches.v4_0.move_warehouse_user_to_restrictions erpnext.patches.v4_0.global_defaults_to_system_settings erpnext.patches.v4_0.update_incharge_name_to_sales_person_in_maintenance_schedule execute:frappe.reload_doc("accounts", "doctype", "POS Payment Method") #2020-05-28 -execute:frappe.reload_doc("HR", "doctype", "HR Settings") #2020-01-16 +execute:frappe.reload_doc("HR", "doctype", "HR Settings") #2020-01-16 #2020-07-24 execute:frappe.reload_doc('stock', 'doctype', 'warehouse') # 2017-04-24 execute:frappe.reload_doc('accounts', 'doctype', 'sales_invoice') # 2016-08-31 execute:frappe.reload_doc('selling', 'doctype', 'sales_order') # 2014-01-29 From 7cbc7946af0e2b8506657583ebfb07579a39c7fc Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 28 Jul 2020 14:11:12 +0530 Subject: [PATCH 07/34] fix: validate check out and check in time for inpatient occupancy --- .../doctype/inpatient_record/inpatient_record.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py index cf63b65f4d..cbcb24faee 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe, json from frappe import _ -from frappe.utils import today, now_datetime, getdate +from frappe.utils import today, now_datetime, getdate, get_datetime from frappe.model.document import Document from frappe.desk.reportview import get_match_cond @@ -30,6 +30,11 @@ class InpatientRecord(Document): (getdate(self.discharge_ordered_date) < getdate(self.scheduled_date)): frappe.throw(_('Expected and Discharge dates cannot be less than Admission Schedule date')) + for entry in self.inpatient_occupancies: + if entry.check_in and entry.check_out and \ + get_datetime(entry.check_in) > get_datetime(entry.check_out): + frappe.throw(_('Check Out datetime cannot be less than Check In datetime for entry #{0}').format(entry.idx)) + def validate_already_scheduled_or_admitted(self): query = """ select name, status From a695971596d715f14c537ad4960af148336a157b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 28 Jul 2020 20:15:29 +0530 Subject: [PATCH 08/34] fix: show the standard validation message Co-authored-by: Marica --- erpnext/healthcare/doctype/inpatient_record/inpatient_record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py index cbcb24faee..69356baad5 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py @@ -33,7 +33,7 @@ class InpatientRecord(Document): for entry in self.inpatient_occupancies: if entry.check_in and entry.check_out and \ get_datetime(entry.check_in) > get_datetime(entry.check_out): - frappe.throw(_('Check Out datetime cannot be less than Check In datetime for entry #{0}').format(entry.idx)) + frappe.throw(_('Row #{0}: Check Out datetime cannot be less than Check In datetime').format(entry.idx)) def validate_already_scheduled_or_admitted(self): query = """ From 5903002039c2b71f45ca5cdbc80bbc86ac0ede8e Mon Sep 17 00:00:00 2001 From: anoop Date: Tue, 28 Jul 2020 21:15:54 +0530 Subject: [PATCH 09/34] fix: exclude Cancelled appointments while Get Items in Sales Invoice --- erpnext/healthcare/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py index 9abaa0784a..dbd3b83f09 100644 --- a/erpnext/healthcare/utils.py +++ b/erpnext/healthcare/utils.py @@ -40,7 +40,7 @@ def get_appointments_to_invoice(patient, company): patient_appointments = frappe.get_list( 'Patient Appointment', fields = '*', - filters = {'patient': patient.name, 'company': company, 'invoiced': 0}, + filters = {'patient': patient.name, 'company': company, 'invoiced': 0, 'status': ['not in', 'Cancelled']}, order_by = 'appointment_date' ) From 9e81bb9a111ac114bc58f3de952adcf460212d5f Mon Sep 17 00:00:00 2001 From: Prssanna Desai Date: Wed, 29 Jul 2020 17:28:30 +0530 Subject: [PATCH 10/34] fix: add range filters to oldest items chart (#22842) --- erpnext/stock/dashboard_chart/oldest_items/oldest_items.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json b/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json index 6da3b28baf..9c10a5346b 100644 --- a/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json +++ b/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json @@ -6,11 +6,11 @@ "docstatus": 0, "doctype": "Dashboard Chart", "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", - "filters_json": "{\"show_warehouse_wise_stock\":0}", + "filters_json": "{\"range1\":30,\"range2\":60,\"range3\":90,\"show_warehouse_wise_stock\":0}", "idx": 0, "is_public": 1, "is_standard": 1, - "modified": "2020-07-22 13:04:36.271198", + "modified": "2020-07-29 14:50:26.846482", "modified_by": "Administrator", "module": "Stock", "name": "Oldest Items", From 031768f49d3cae952ac46b11d000aea90776223f Mon Sep 17 00:00:00 2001 From: Saqib Date: Thu, 30 Jul 2020 12:40:53 +0530 Subject: [PATCH 11/34] chore: asset form reorder (#22833) Co-authored-by: Marica --- erpnext/assets/doctype/asset/asset.json | 74 +++++++++++++++++-------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 97165a31d2..a3152abf20 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "allow_rename": 1, "autoname": "naming_series:", @@ -7,8 +8,9 @@ "document_type": "Document", "engine": "InnoDB", "field_order": [ + "is_existing_asset", + "section_break_2", "naming_series", - "asset_name", "item_code", "item_name", "asset_category", @@ -17,29 +19,31 @@ "supplier", "customer", "image", - "purchase_invoice", + "journal_entry_for_scrap", "column_break_3", "company", + "asset_name", "location", "custodian", "department", - "purchase_date", "disposal_date", - "journal_entry_for_scrap", - "purchase_receipt", "accounting_dimensions_section", "cost_center", "dimension_col_break", - "section_break_5", - "gross_purchase_amount", + "purchase_details_section", + "purchase_receipt", + "purchase_invoice", "available_for_use_date", - "column_break_18", + "column_break_23", + "gross_purchase_amount", + "purchase_date", + "section_break_23", "calculate_depreciation", "allow_monthly_depreciation", - "is_existing_asset", + "column_break_33", "opening_accumulated_depreciation", "number_of_depreciations_booked", - "section_break_23", + "section_break_36", "finance_books", "section_break_33", "depreciation_method", @@ -64,7 +68,6 @@ "status", "booked_fixed_asset", "column_break_51", - "purchase_receipt_amount", "default_finance_book", "amended_from" @@ -187,6 +190,8 @@ "fieldname": "purchase_date", "fieldtype": "Date", "label": "Purchase Date", + "read_only": 1, + "read_only_depends_on": "eval:!doc.is_existing_asset", "reqd": 1 }, { @@ -204,25 +209,20 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "section_break_5", - "fieldtype": "Section Break" - }, { "fieldname": "gross_purchase_amount", "fieldtype": "Currency", "label": "Gross Purchase Amount", "options": "Company:company:default_currency", + "read_only": 1, + "read_only_depends_on": "eval:!doc.is_existing_asset", "reqd": 1 }, { "fieldname": "available_for_use_date", "fieldtype": "Date", - "label": "Available-for-use Date" - }, - { - "fieldname": "column_break_18", - "fieldtype": "Column Break" + "label": "Available-for-use Date", + "reqd": 1 }, { "default": "0", @@ -252,12 +252,14 @@ "no_copy": 1 }, { - "depends_on": "calculate_depreciation", + "collapsible": 1, + "collapsible_depends_on": "eval:doc.calculate_depreciation || doc.is_existing_asset", "fieldname": "section_break_23", "fieldtype": "Section Break", "label": "Depreciation" }, { + "columns": 10, "fieldname": "finance_books", "fieldtype": "Table", "label": "Finance Books", @@ -305,8 +307,7 @@ { "depends_on": "calculate_depreciation", "fieldname": "section_break_14", - "fieldtype": "Section Break", - "label": "Depreciation Schedule" + "fieldtype": "Section Break" }, { "fieldname": "schedules", @@ -456,12 +457,37 @@ "fieldname": "allow_monthly_depreciation", "fieldtype": "Check", "label": "Allow Monthly Depreciation" + }, + { + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "collapsible": 1, + "collapsible_depends_on": "is_existing_asset", + "fieldname": "purchase_details_section", + "fieldtype": "Section Break", + "label": "Purchase Details" + }, + { + "fieldname": "column_break_23", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_33", + "fieldtype": "Column Break" + }, + { + "depends_on": "calculate_depreciation", + "fieldname": "section_break_36", + "fieldtype": "Section Break" } ], "idx": 72, "image_field": "image", "is_submittable": 1, - "modified": "2019-10-22 15:47:36.050828", + "links": [], + "modified": "2020-07-28 15:04:44.452224", "modified_by": "Administrator", "module": "Assets", "name": "Asset", From 621529adfbf5fb2e1ab1161f6e6d99a275e28ae7 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 30 Jul 2020 13:18:41 +0530 Subject: [PATCH 12/34] fix: unlink item from healthcare service unit type (#22828) Co-authored-by: Marica --- .../healthcare_service_unit_type.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 bb86eaacc4..a318e50600 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 @@ -39,7 +39,9 @@ class HealthcareServiceUnitType(Document): def on_trash(self): if self.item: try: - frappe.delete_doc('Item', self.item) + item = self.item + self.db_set('item', '') + frappe.delete_doc('Item', item) except Exception: frappe.throw(_('Not permitted. Please disable the Service Unit Type')) From a14618efe401c488599860b03ae5a1829cae78ed Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 30 Jul 2020 17:22:29 +0530 Subject: [PATCH 13/34] fix: validate theme_scss attribute --- erpnext/public/js/website_theme.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/website_theme.js b/erpnext/public/js/website_theme.js index 84de2f5b51..9662f78538 100644 --- a/erpnext/public/js/website_theme.js +++ b/erpnext/public/js/website_theme.js @@ -4,8 +4,8 @@ frappe.ui.form.on('Website Theme', { validate(frm) { let theme_scss = frm.doc.theme_scss; - if (theme_scss.includes('frappe/public/scss/website') - && !theme_scss.includes('erpnext/public/scss/website') + if (theme_scss && (theme_scss.includes('frappe/public/scss/website') + && !theme_scss.includes('erpnext/public/scss/website')) ) { frm.set_value('theme_scss', `${frm.doc.theme_scss}\n@import "erpnext/public/scss/website";`); From 9837285bf1e77463e2e3e76f6e2f2d10146f9030 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 30 Jul 2020 20:52:20 +0530 Subject: [PATCH 14/34] fix: Ignore cancelled gl entries to get account balance --- erpnext/accounts/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 824b2f2efb..51ac7cfbfa 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -122,7 +122,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company cost_center = frappe.form_dict.get("cost_center") - cond = [] + cond = ["is_cancelled=0"] if date: cond.append("posting_date <= %s" % frappe.db.escape(cstr(date))) else: @@ -206,7 +206,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company return flt(bal) def get_count_on(account, fieldname, date): - cond = [] + cond = ["is_cancelled=0"] if date: cond.append("posting_date <= %s" % frappe.db.escape(cstr(date))) else: From cf00ee49ec2b5a72d6319890899071724164ab71 Mon Sep 17 00:00:00 2001 From: Marica Date: Fri, 31 Jul 2020 15:14:50 +0530 Subject: [PATCH 15/34] fix: PO/SO view title (#22858) --- erpnext/buying/doctype/purchase_order/purchase_order.json | 4 ++-- erpnext/selling/doctype/sales_order/sales_order.json | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index 502dbba571..4201e0b635 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -1084,7 +1084,7 @@ "idx": 105, "is_submittable": 1, "links": [], - "modified": "2020-07-18 05:09:33.800633", + "modified": "2020-07-31 14:13:44.610190", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", @@ -1135,5 +1135,5 @@ "sort_field": "modified", "sort_order": "DESC", "timeline_field": "supplier", - "title_field": "title" + "title_field": "supplier" } \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index 8fa56ac959..a68b7387b7 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -1,7 +1,6 @@ { "actions": [], "allow_import": 1, - "allow_workflow": 1, "autoname": "naming_series:", "creation": "2013-06-18 12:39:59", "doctype": "DocType", @@ -1461,7 +1460,7 @@ "idx": 105, "is_submittable": 1, "links": [], - "modified": "2020-07-18 05:13:06.680696", + "modified": "2020-07-31 14:13:17.962015", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", @@ -1535,7 +1534,7 @@ "sort_field": "modified", "sort_order": "DESC", "timeline_field": "customer", - "title_field": "title", + "title_field": "customer", "track_changes": 1, "track_seen": 1 } \ No newline at end of file From 2a4c90302b7597927d39039aeb8376e498f84fbb Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Fri, 31 Jul 2020 17:59:30 +0530 Subject: [PATCH 16/34] fix: minor recritment analytics fixes (#22830) Co-authored-by: Rucha Mahabal --- .../recruitment_analytics.py | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/erpnext/hr/report/recruitment_analytics/recruitment_analytics.py b/erpnext/hr/report/recruitment_analytics/recruitment_analytics.py index 867209436c..e961114ac2 100644 --- a/erpnext/hr/report/recruitment_analytics/recruitment_analytics.py +++ b/erpnext/hr/report/recruitment_analytics/recruitment_analytics.py @@ -96,33 +96,35 @@ def get_data(filters): def get_parent_row(sp_jo_map, sp, jo_ja_map, ja_joff_map): data = [] - for jo in sp_jo_map[sp]: - row = { - "staffing_plan" : sp, - "job_opening" : jo["name"], - } - data.append(row) - child_row = get_child_row( jo["name"], jo_ja_map, ja_joff_map) - data += child_row + if sp in sp_jo_map.keys(): + for jo in sp_jo_map[sp]: + row = { + "staffing_plan" : sp, + "job_opening" : jo["name"], + } + data.append(row) + child_row = get_child_row( jo["name"], jo_ja_map, ja_joff_map) + data += child_row return data def get_child_row(jo, jo_ja_map, ja_joff_map): data = [] - for ja in jo_ja_map[jo]: - row = { - "indent":1, - "job_applicant": ja.name, - "applicant_name": ja.applicant_name, - "application_status": ja.status, - } - if ja.name in ja_joff_map.keys(): - jo_detail =ja_joff_map[ja.name][0] - row["job_offer"] = jo_detail.name - row["job_offer_status"] = jo_detail.status - row["offer_date"]= jo_detail.offer_date.strftime("%d-%m-%Y") - row["designation"] = jo_detail.designation + if jo in jo_ja_map.keys(): + for ja in jo_ja_map[jo]: + row = { + "indent":1, + "job_applicant": ja.name, + "applicant_name": ja.applicant_name, + "application_status": ja.status, + } + if ja.name in ja_joff_map.keys(): + jo_detail =ja_joff_map[ja.name][0] + row["job_offer"] = jo_detail.name + row["job_offer_status"] = jo_detail.status + row["offer_date"]= jo_detail.offer_date.strftime("%d-%m-%Y") + row["designation"] = jo_detail.designation - data.append(row) + data.append(row) return data def get_staffing_plan(filters): @@ -177,7 +179,7 @@ def get_job_applicant(jo_list): def get_job_offer(ja_list): ja_joff_map = {} - offers = frappe.get_all("Job offer", filters = [["job_applicant", "IN", ja_list]], fields =["name", "job_applicant", "status", 'offer_date', 'designation']) + offers = frappe.get_all("Job Offer", filters = [["job_applicant", "IN", ja_list]], fields =["name", "job_applicant", "status", 'offer_date', 'designation']) for offer in offers: if offer.job_applicant not in ja_joff_map.keys(): From dcb462f3058266fbf9b73955ff964787b4cca7e4 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 1 Aug 2020 13:47:09 +0530 Subject: [PATCH 17/34] fix: Import pycountry and taxjar only if taxjar is enabled --- erpnext/erpnext_integrations/taxjar_integration.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 633692dd24..24fc3d44b9 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -1,8 +1,5 @@ import traceback -import pycountry -import taxjar - import frappe from erpnext import get_default_company from frappe import _ @@ -32,6 +29,7 @@ def get_client(): def create_transaction(doc, method): + import taxjar """Create an order transaction in TaxJar""" if not TAXJAR_CREATE_TRANSACTIONS: @@ -208,6 +206,7 @@ def get_shipping_address_details(doc): def get_iso_3166_2_state_code(address): + import pycountry country_code = frappe.db.get_value("Country", address.get("country"), "code") error_message = _("""{0} is not a valid state! Check for typos or enter the ISO code for your state.""").format(address.get("state")) From b9dc21129c95df9774fbf09627afefd0e6496d47 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 1 Aug 2020 22:51:40 +0530 Subject: [PATCH 18/34] fix: Loan Seurity shortfall calculation fixes --- .../loan_management/doctype/loan/loan.json | 4 +- .../loan_management/doctype/loan/test_loan.py | 2 +- .../loan_security_pledge.py | 22 ++++++++++ .../loan_security_shortfall.py | 44 ++++++++++--------- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/erpnext/loan_management/doctype/loan/loan.json b/erpnext/loan_management/doctype/loan/loan.json index 192beee7e3..aa5e21b426 100644 --- a/erpnext/loan_management/doctype/loan/loan.json +++ b/erpnext/loan_management/doctype/loan/loan.json @@ -20,8 +20,8 @@ "section_break_8", "loan_type", "loan_amount", - "is_secured_loan", "rate_of_interest", + "is_secured_loan", "disbursement_date", "disbursed_amount", "column_break_11", @@ -334,7 +334,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2020-07-02 20:46:40.128142", + "modified": "2020-08-01 12:36:11.255233", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan", diff --git a/erpnext/loan_management/doctype/loan/test_loan.py b/erpnext/loan_management/doctype/loan/test_loan.py index c65996e65f..23815d5982 100644 --- a/erpnext/loan_management/doctype/loan/test_loan.py +++ b/erpnext/loan_management/doctype/loan/test_loan.py @@ -269,7 +269,7 @@ class TestLoan(unittest.TestCase): self.assertTrue(loan_security_shortfall) self.assertEquals(loan_security_shortfall.loan_amount, 1000000.00) - self.assertEquals(loan_security_shortfall.security_value, 400000.00) + self.assertEquals(loan_security_shortfall.security_value, 800000.00) self.assertEquals(loan_security_shortfall.shortfall_amount, 600000.00) frappe.db.sql(""" UPDATE `tabLoan Security Price` SET loan_security_price = 250 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 961c05c9c1..2bb6fd84e5 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 @@ -14,6 +14,7 @@ class LoanSecurityPledge(Document): def validate(self): self.set_pledge_amount() self.validate_duplicate_securities() + self.validate_loan_security_type() def on_submit(self): if self.loan: @@ -31,6 +32,27 @@ class LoanSecurityPledge(Document): frappe.throw(_('Loan Security {0} added multiple times').format(frappe.bold( security.loan_security))) + def validate_loan_security_type(self): + existing_pledge = '' + + if self.loan: + existing_pledge = frappe.db.get_value('Loan Security Pledge', {'loan': self.loan}, ['name']) + + if existing_pledge: + loan_security_type = frappe.db.get_value('Pledge', {'parent': existing_pledge}, ['loan_security_type']) + else: + loan_security_type = self.securities[0].loan_security_type + + ltv_ratio_map = frappe._dict(frappe.get_all("Loan Security Type", + fields=["name", "loan_to_value_ratio"], as_list=1)) + + ltv_ratio = ltv_ratio_map.get(loan_security_type) + + for security in self.securities: + if ltv_ratio_map.get(security.loan_security_type) != ltv_ratio: + frappe.throw(_("Loan Securities with different LTV ratio cannot be pledged against one loan")) + + def set_pledge_amount(self): total_security_value = 0 maximum_loan_value = 0 diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index ffd96737a5..24527a17b8 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -7,6 +7,7 @@ import frappe from frappe.utils import get_datetime from frappe.model.document import Document from six import iteritems +from erpnext.loan_management.doctype.loan_security_unpledge.loan_security_unpledge import get_pledged_security_qty class LoanSecurityShortfall(Document): pass @@ -50,31 +51,29 @@ def check_for_ltv_shortfall(process_loan_security_shortfall): "valid_upto": (">=", update_time) }, as_list=1)) - ltv_ratio_map = frappe._dict(frappe.get_all("Loan Security Type", - fields=["name", "loan_to_value_ratio"], as_list=1)) - - loans = frappe.db.sql(""" SELECT l.name, l.loan_amount, l.total_principal_paid, lp.loan_security, lp.haircut, lp.qty, lp.loan_security_type - FROM `tabLoan` l, `tabPledge` lp , `tabLoan Security Pledge`p WHERE lp.parent = p.name and p.loan = l.name and l.docstatus = 1 - and l.is_secured_loan and l.status = 'Disbursed' and p.status = 'Pledged'""", as_dict=1) + loans = frappe.get_all('Loan', fields=['name', 'loan_amount', 'total_principal_paid'], filters={'status': 'Disbursed'}) loan_security_map = {} for loan in loans: - loan_security_map.setdefault(loan.name, { - "loan_amount": loan.loan_amount - loan.total_principal_paid, - "security_value": 0.0 - }) + outstanding_amount = loan.loan_amount - loan.total_principal_paid + pledged_securities = get_pledged_security_qty(loan.name) + ltv_ratio = '' + security_value = 0.0 - current_loan_security_amount = loan_security_price_map.get(loan.loan_security, 0) * loan.qty - ltv_ratio = ltv_ratio_map.get(loan.loan_security_type) + for security, qty in pledged_securities.items(): + if not ltv_ratio: + ltv_ratio = get_ltv_ratio(security) + security_value += loan_security_price_map.get(security) * qty - loan_security_map[loan.name]['security_value'] += current_loan_security_amount - (current_loan_security_amount * loan.haircut/100) + current_ratio = (outstanding_amount/security_value) * 100 - for loan, value in iteritems(loan_security_map): - if (value["loan_amount"]/value['security_value'] * 100) > ltv_ratio: - create_loan_security_shortfall(loan, value, process_loan_security_shortfall) + if current_ratio > ltv_ratio: + shortfall_amount = outstanding_amount - ((security_value * ltv_ratio) / 100) + create_loan_security_shortfall(loan.name, outstanding_amount, security_value, shortfall_amount, + process_loan_security_shortfall) -def create_loan_security_shortfall(loan, value, process_loan_security_shortfall): +def create_loan_security_shortfall(loan, loan_amount, security_value, shortfall_amount, process_loan_security_shortfall): existing_shortfall = frappe.db.get_value("Loan Security Shortfall", {"loan": loan, "status": "Pending"}, "name") @@ -85,9 +84,14 @@ def create_loan_security_shortfall(loan, value, process_loan_security_shortfall) ltv_shortfall.loan = loan ltv_shortfall.shortfall_time = get_datetime() - ltv_shortfall.loan_amount = value["loan_amount"] - ltv_shortfall.security_value = value["security_value"] - ltv_shortfall.shortfall_amount = value["loan_amount"] - value["security_value"] + ltv_shortfall.loan_amount = loan_amount + ltv_shortfall.security_value = security_value + ltv_shortfall.shortfall_amount = shortfall_amount ltv_shortfall.process_loan_security_shortfall = process_loan_security_shortfall ltv_shortfall.save() +def get_ltv_ratio(loan_security): + loan_security_type = frappe.db.get_value('Loan Security', loan_security, 'loan_security_type') + ltv_ratio = frappe.db.get_value('Loan Security Type', loan_security_type, 'loan_to_value_ratio') + return ltv_ratio + From d909669a18c39098db734ad3b6b0a1c5b7789f74 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 2 Aug 2020 17:00:53 +0530 Subject: [PATCH 19/34] fix: Test cases --- .../doctype/loan_security_shortfall/loan_security_shortfall.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index 24527a17b8..aae68df93a 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -51,7 +51,8 @@ def check_for_ltv_shortfall(process_loan_security_shortfall): "valid_upto": (">=", update_time) }, as_list=1)) - loans = frappe.get_all('Loan', fields=['name', 'loan_amount', 'total_principal_paid'], filters={'status': 'Disbursed'}) + loans = frappe.get_all('Loan', fields=['name', 'loan_amount', 'total_principal_paid'], + filters={'status': 'Disbursed', 'is_secured': 1}) loan_security_map = {} From 4104887abb6a3a50a529831ad25d63aae081463a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 2 Aug 2020 18:23:54 +0530 Subject: [PATCH 20/34] fix: fieldname in filter --- .../doctype/loan_security_shortfall/loan_security_shortfall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index aae68df93a..02efe240bd 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -52,7 +52,7 @@ def check_for_ltv_shortfall(process_loan_security_shortfall): }, as_list=1)) loans = frappe.get_all('Loan', fields=['name', 'loan_amount', 'total_principal_paid'], - filters={'status': 'Disbursed', 'is_secured': 1}) + filters={'status': 'Disbursed', 'is_secured_loan': 1}) loan_security_map = {} From ba52dd8ba6b36837fb7148714a0cf162b8b2ad2d Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Mon, 3 Aug 2020 08:57:49 +0530 Subject: [PATCH 21/34] fix: minor payroll_dashboard fixes (#22832) * fix: minor payroll_dashboard fixes * Update erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js Co-authored-by: Rucha Mahabal Co-authored-by: Nabin Hait Co-authored-by: Rucha Mahabal --- .../job_application_status/job_application_status.json | 6 +++--- .../monthly_attendance_sheet.js | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/dashboard_chart/job_application_status/job_application_status.json b/erpnext/hr/dashboard_chart/job_application_status/job_application_status.json index bfcfa96752..42a830970e 100644 --- a/erpnext/hr/dashboard_chart/job_application_status/job_application_status.json +++ b/erpnext/hr/dashboard_chart/job_application_status/job_application_status.json @@ -7,14 +7,14 @@ "doctype": "Dashboard Chart", "document_type": "Job Applicant", "dynamic_filters_json": "", - "filters_json": "[[\"Job Applicant\",\"creation\",\"Previous\",\"1 month\"]]", + "filters_json": "[[\"Job Applicant\",\"creation\",\"Timespan\",\"last month\",false]]", "group_by_based_on": "status", "group_by_type": "Count", "idx": 0, "is_public": 1, "is_standard": 1, - "last_synced_on": "2020-07-22 14:27:40.118498", - "modified": "2020-07-22 14:33:00.404144", + "last_synced_on": "2020-07-28 16:19:12.109979", + "modified": "2020-07-28 16:19:45.279490", "modified_by": "Administrator", "module": "HR", "name": "Job Application Status", diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js index 4b9b928640..42f7cdb50f 100644 --- a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js +++ b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js @@ -35,7 +35,15 @@ frappe.query_reports["Monthly Attendance Sheet"] = { "fieldname":"employee", "label": __("Employee"), "fieldtype": "Link", - "options": "Employee" + "options": "Employee", + get_query: () => { + var company = frappe.query_report.get_filter_value('company'); + return { + filters: { + 'company': company + } + }; + } }, { "fieldname":"company", From 4cc99286c07c1551139088bcf7a6290b73390de7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Aug 2020 09:33:31 +0530 Subject: [PATCH 22/34] fix: Update modified timestamp in accounts settings (#22873) --- .../accounts/doctype/accounts_settings/accounts_settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 8ca8b71ef8..b2e8b090c7 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -225,7 +225,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2020-06-22 20:13:26.043092", + "modified": "2020-08-03 20:13:26.043092", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", From 9cc2d340badf537294b3fd065ef4294777ea3e67 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Aug 2020 10:43:47 +0530 Subject: [PATCH 23/34] Reset home page based on product settings (#22875) --- erpnext/portal/doctype/products_settings/products_settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/portal/doctype/products_settings/products_settings.py b/erpnext/portal/doctype/products_settings/products_settings.py index b984aeb67d..ae7dc68020 100644 --- a/erpnext/portal/doctype/products_settings/products_settings.py +++ b/erpnext/portal/doctype/products_settings/products_settings.py @@ -11,9 +11,9 @@ from frappe.model.document import Document class ProductsSettings(Document): def validate(self): if self.home_page_is_products: - frappe.db.set_value("Website Settings", "home_page", "products") + frappe.db.set_value("Website Settings", None, "home_page", "products") elif frappe.db.get_single_value("Website Settings", "home_page") == 'products': - frappe.db.set_value("Website Settings", "home_page", "home") + frappe.db.set_value("Website Settings", None, "home_page", "home") self.validate_field_filters() self.validate_attribute_filters() From 5e438cc853aa48e80c28b88eebcdcfce873c40af Mon Sep 17 00:00:00 2001 From: Wolfram Schmidt Date: Mon, 3 Aug 2020 09:16:50 +0200 Subject: [PATCH 24/34] Update lead_source.json (#22872) Allow Lead Source to be renamed. This is usefull for cleaning up data at a later point and allow correcting spelling errors. Co-authored-by: Rucha Mahabal --- erpnext/selling/doctype/lead_source/lead_source.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/lead_source/lead_source.json b/erpnext/selling/doctype/lead_source/lead_source.json index 868f6d11d0..373e83af9c 100644 --- a/erpnext/selling/doctype/lead_source/lead_source.json +++ b/erpnext/selling/doctype/lead_source/lead_source.json @@ -1,7 +1,7 @@ { "allow_copy": 0, "allow_import": 0, - "allow_rename": 0, + "allow_rename": 1, "autoname": "field:source_name", "beta": 0, "creation": "2016-09-16 01:47:47.382372", @@ -74,7 +74,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-09-16 02:03:01.441622", + "modified": "2020-09-16 02:03:01.441622", "modified_by": "Administrator", "module": "Selling", "name": "Lead Source", @@ -128,4 +128,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_seen": 0 -} \ No newline at end of file +} From 5572f8eb1e09ba4428c79c0161ba3d69b6ab228b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 3 Aug 2020 13:40:11 +0530 Subject: [PATCH 25/34] fix: Test case for subscription --- .../accounts/doctype/subscription/test_subscription.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index f41f08a6c4..811fc356cf 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -7,8 +7,8 @@ import unittest import frappe from erpnext.accounts.doctype.subscription.subscription import get_prorata_factor -from frappe.utils.data import nowdate, add_days, add_to_date, add_months, date_diff, flt, get_date_str - +from frappe.utils.data import (nowdate, add_days, add_to_date, add_months, date_diff, flt, get_date_str, + get_first_day, get_last_day) def create_plan(): if not frappe.db.exists('Subscription Plan', '_Test Plan Name'): @@ -68,14 +68,14 @@ class TestSubscription(unittest.TestCase): subscription.party_type = 'Customer' subscription.party = '_Test Customer' subscription.trial_period_start = nowdate() - subscription.trial_period_end = add_days(nowdate(), 30) + subscription.trial_period_end = add_months(nowdate(), 1) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() self.assertEqual(subscription.trial_period_start, nowdate()) - self.assertEqual(subscription.trial_period_end, add_days(nowdate(), 30)) + self.assertEqual(subscription.trial_period_end, add_months(nowdate(), 1)) self.assertEqual(add_days(subscription.trial_period_end, 1), get_date_str(subscription.current_invoice_start)) - self.assertEqual(add_days(subscription.current_invoice_start, 30), get_date_str(subscription.current_invoice_end)) + self.assertEqual(add_to_date(subscription.current_invoice_start, months=1, days=-1), get_date_str(subscription.current_invoice_end)) self.assertEqual(subscription.invoices, []) self.assertEqual(subscription.status, 'Trialling') From 1dfd9fd756aa006ce6ab304be99b46a15dd9ec7f Mon Sep 17 00:00:00 2001 From: Prssanna Desai Date: Mon, 3 Aug 2020 14:48:45 +0530 Subject: [PATCH 26/34] fix: check if row['delay'] exists (#22889) --- .../selling/report/sales_order_analysis/sales_order_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py index 7e8e6e9e8b..f5feb95f1a 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py @@ -96,7 +96,7 @@ def prepare_data(data, filters): # prepare data for report view row["qty_to_bill"] = flt(row["qty"]) - flt(row["billed_qty"]) - row["delay"] = 0 if row["delay"] < 0 else row["delay"] + row["delay"] = 0 if row["delay"] and row["delay"] < 0 else row["delay"] if filters.get("group_by_so"): so_name = row["sales_order"] From dd97524db5bb277cb963bc6d5e0135a70837f906 Mon Sep 17 00:00:00 2001 From: Marica Date: Mon, 3 Aug 2020 14:55:40 +0530 Subject: [PATCH 27/34] fix: Misleading description in Warehouse (#22877) Co-authored-by: Rucha Mahabal --- erpnext/stock/doctype/warehouse/warehouse.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/warehouse/warehouse.json b/erpnext/stock/doctype/warehouse/warehouse.json index 3b49c4ca52..c0c9fbc92d 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.json +++ b/erpnext/stock/doctype/warehouse/warehouse.json @@ -45,7 +45,6 @@ "oldfieldtype": "Section Break" }, { - "description": "If blank, parent Warehouse Account or company default will be considered", "fieldname": "warehouse_name", "fieldtype": "Data", "label": "Warehouse Name", @@ -236,7 +235,7 @@ "idx": 1, "is_tree": 1, "links": [], - "modified": "2020-07-16 15:43:50.653256", + "modified": "2020-08-03 11:19:35.943330", "modified_by": "Administrator", "module": "Stock", "name": "Warehouse", From b50b20458e76fd43a82a065b9cd217154a2eba48 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 3 Aug 2020 15:51:57 +0530 Subject: [PATCH 28/34] fix: TypeError while concatenating account number and name in COA (#22885) Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> --- .../doctype/account/chart_of_accounts/chart_of_accounts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index 1bf9196a4f..0e3b24cda3 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -225,7 +225,7 @@ def build_tree_from_json(chart_template, chart_data=None): account['parent_account'] = parent account['expandable'] = True if identify_is_group(child) else False - account['value'] = (child.get('account_number') + ' - ' + account_name) \ + account['value'] = (cstr(child.get('account_number')).strip() + ' - ' + account_name) \ if child.get('account_number') else account_name accounts.append(account) _import_accounts(child, account['value']) From 1895e9b89a52fd9ee0ddade238bd4c0e66438b60 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Mon, 3 Aug 2020 18:50:11 +0530 Subject: [PATCH 29/34] fix: Shopping cart issue v13 (#22868) * refactoring shopping cart settings * adding column_break in shopping cart settings * fix: mandatory depend on fix company * fix: resetting company, price_list, default_customer_group, quotation_series when card is diabled. --- .../shopping_cart_settings.js | 6 ++++++ .../shopping_cart_settings.json | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js index 14500ba6b3..21fa4c3065 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.js @@ -12,5 +12,11 @@ frappe.ui.form.on("Shopping Cart Settings", { if (frm.doc.enabled === 1) { frm.set_value('enable_variants', 1); } + else { + frm.set_value('company', ''); + frm.set_value('price_list', ''); + frm.set_value('default_customer_group', ''); + frm.set_value('quotation_series', ''); + } } }); diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json index c574afa68c..32004efdca 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.json @@ -95,15 +95,16 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Company", + "mandatory_depends_on": "eval: doc.enabled === 1", "options": "Company", - "remember_last_selected_value": 1, - "reqd": 1 + "remember_last_selected_value": 1 }, { "description": "Prices will not be shown if Price List is not set", "fieldname": "price_list", "fieldtype": "Link", "label": "Price List", + "mandatory_depends_on": "eval: doc.enabled === 1", "options": "Price List" }, { @@ -115,14 +116,14 @@ "fieldtype": "Link", "ignore_user_permissions": 1, "label": "Default Customer Group", - "options": "Customer Group", - "reqd": 1 + "mandatory_depends_on": "eval: doc.enabled === 1", + "options": "Customer Group" }, { "fieldname": "quotation_series", "fieldtype": "Select", "label": "Quotation Series", - "reqd": 1 + "mandatory_depends_on": "eval: doc.enabled === 1" }, { "collapsible": 1, @@ -171,7 +172,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2020-07-17 17:53:22.667228", + "modified": "2020-08-02 18:21:43.873303", "modified_by": "Administrator", "module": "Shopping Cart", "name": "Shopping Cart Settings", From 101fe2b769e84c5348875b60527289b746c9c834 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 3 Aug 2020 19:42:24 +0530 Subject: [PATCH 30/34] fix: Assessment Result child table not visible when accessed via dashboard (#22880) Co-authored-by: Nabin Hait --- .../assessment_result/assessment_result.js | 11 +- .../assessment_result/assessment_result.json | 648 ++---------------- .../assessment_result_detail.json | 242 ++----- 3 files changed, 111 insertions(+), 790 deletions(-) diff --git a/erpnext/education/doctype/assessment_result/assessment_result.js b/erpnext/education/doctype/assessment_result/assessment_result.js index 12fdd91c25..63d1aee0cb 100644 --- a/erpnext/education/doctype/assessment_result/assessment_result.js +++ b/erpnext/education/doctype/assessment_result/assessment_result.js @@ -6,10 +6,11 @@ frappe.ui.form.on('Assessment Result', { if (!frm.doc.__islocal) { frm.trigger('setup_chart'); } + frm.set_df_property('details', 'read_only', 1); }, onload: function(frm) { - frm.set_query('assessment_plan', function(){ + frm.set_query('assessment_plan', function() { return { filters: { docstatus: 1 @@ -27,14 +28,14 @@ frappe.ui.form.on('Assessment Result', { }, callback: function(r) { if (r.message) { - frm.doc.details = []; + frappe.model.clear_table(frm.doc, 'details'); $.each(r.message, function(i, d) { - var row = frappe.model.add_child(frm.doc, 'Assessment Result Detail', 'details'); + var row = frm.add_child('details'); row.assessment_criteria = d.assessment_criteria; row.maximum_score = d.maximum_score; }); + frm.refresh_field('details'); } - refresh_field('details'); } }); } @@ -80,7 +81,7 @@ frappe.ui.form.on('Assessment Result Detail', { score: function(frm, cdt, cdn) { var d = locals[cdt][cdn]; - if(!d.maximum_score || !frm.doc.grading_scale) { + if (!d.maximum_score || !frm.doc.grading_scale) { d.score = ''; frappe.throw(__('Please fill in all the details to generate Assessment Result.')); } diff --git a/erpnext/education/doctype/assessment_result/assessment_result.json b/erpnext/education/doctype/assessment_result/assessment_result.json index 212d47cff0..7a893aabb8 100644 --- a/erpnext/education/doctype/assessment_result/assessment_result.json +++ b/erpnext/education/doctype/assessment_result/assessment_result.json @@ -1,724 +1,182 @@ { - "allow_copy": 0, - "allow_guest_to_view": 0, + "actions": [], "allow_import": 1, - "allow_rename": 0, "autoname": "EDU-RES-.YYYY.-.#####", - "beta": 0, "creation": "2015-11-13 17:18:06.468332", - "custom": 0, - "docstatus": 0, "doctype": "DocType", - "document_type": "", "editable_grid": 1, "engine": "InnoDB", + "field_order": [ + "assessment_plan", + "program", + "course", + "academic_year", + "academic_term", + "column_break_3", + "student", + "student_name", + "student_group", + "assessment_group", + "grading_scale", + "section_break_5", + "details", + "section_break_8", + "maximum_score", + "column_break_11", + "total_score", + "grade", + "section_break_13", + "comment", + "amended_from" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "assessment_plan", "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": "Assessment Plan", - "length": 0, - "no_copy": 0, "options": "Assessment Plan", - "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": "assessment_plan.program", "fieldname": "program", "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": "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": "assessment_plan.course", "fieldname": "course", "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": "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": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Course" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "assessment_plan.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": "assessment_plan.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, - "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 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "student", "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": "Student", - "length": 0, - "no_copy": 0, "options": "Student", - "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.title", "fieldname": "student_name", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, "in_global_search": 1, "in_list_view": 1, - "in_standard_filter": 0, "label": "Student 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, "fetch_from": "assessment_plan.student_group", "fieldname": "student_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": 0, "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": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Student Group" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "assessment_plan.assessment_group", "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": 0, "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": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Assessment Group" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "assessment_plan.grading_scale", "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": 0, "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": 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_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": "Result", - "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": "Result" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", "fieldname": "details", "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": "Details", - "length": 0, - "no_copy": 0, "options": "Assessment Result Detail", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "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": "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, - "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": "Section Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "assessment_plan.maximum_assessment_score", "fieldname": "maximum_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 Score", - "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, "fetch_from": "assessment_plan.maximum_assessment_score", "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 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "total_score", "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": "Total Score", - "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": "grade", "fieldtype": "Data", - "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": "Grade", - "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_13", "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": "Summary", - "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": "Summary" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "comment", "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": "Comment", - "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": "Comment" }, { - "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 Result", - "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, - "modified": "2018-08-30 02:10:36.813413", + "links": [], + "modified": "2020-08-03 11:47:54.119486", "modified_by": "Administrator", "module": "Education", "name": "Assessment Result", - "name_case": "", "owner": "Administrator", "permissions": [ { @@ -728,28 +186,18 @@ "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": 1, "sort_field": "modified", "sort_order": "DESC", - "title_field": "student_name", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 + "title_field": "student_name" } \ No newline at end of file diff --git a/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.json b/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.json index 85d943beaa..450f41cbbb 100644 --- a/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.json +++ b/erpnext/education/doctype/assessment_result_detail/assessment_result_detail.json @@ -1,194 +1,66 @@ { - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "autoname": "", - "beta": 0, - "creation": "2016-12-14 17:44:35.583123", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", + "actions": [], + "creation": "2016-12-14 17:44:35.583123", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "assessment_criteria", + "maximum_score", + "column_break_2", + "score", + "grade" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 4, - "fieldname": "assessment_criteria", - "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": "Assessment Criteria", - "length": 0, - "no_copy": 0, - "options": "Assessment Criteria", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "columns": 4, + "fieldname": "assessment_criteria", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Assessment Criteria", + "options": "Assessment Criteria", + "read_only": 1, + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 2, - "fieldname": "maximum_score", - "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": "Maximum Score", - "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, - "unique": 0 - }, + "columns": 2, + "fieldname": "maximum_score", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Maximum Score", + "read_only": 1 + }, { - "allow_bulk_edit": 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, - "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, - "unique": 0 - }, + "fieldname": "column_break_2", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 2, - "fieldname": "score", - "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": "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, - "unique": 0 - }, + "columns": 2, + "fieldname": "score", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Score", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 2, - "fieldname": "grade", - "fieldtype": "Data", - "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": "Grade", - "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, - "unique": 0 + "columns": 2, + "fieldname": "grade", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Grade", + "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": "2017-11-10 19:11:14.362410", - "modified_by": "Administrator", - "module": "Education", - "name": "Assessment Result Detail", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "restrict_to_domain": "Education", - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 0, - "track_seen": 0 + ], + "istable": 1, + "links": [], + "modified": "2020-07-31 13:27:17.699022", + "modified_by": "Administrator", + "module": "Education", + "name": "Assessment Result Detail", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "restrict_to_domain": "Education", + "sort_field": "modified", + "sort_order": "DESC" } \ No newline at end of file From 48163e31c54d8e3c1edb9ea082cfba0780d50579 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Aug 2020 20:38:28 +0530 Subject: [PATCH 31/34] Dunning cleanup (#22898) * fix: Dunning cleanup * fix: Added dashboard for Dunning --- erpnext/accounts/doctype/dunning/dunning.js | 19 ++++++++++++++++--- erpnext/accounts/doctype/dunning/dunning.json | 8 ++++---- erpnext/accounts/doctype/dunning/dunning.py | 16 +++++++++------- .../doctype/dunning/dunning_dashboard.py | 17 +++++++++++++++++ .../sales_invoice/sales_invoice_dashboard.py | 2 +- 5 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 erpnext/accounts/doctype/dunning/dunning_dashboard.py diff --git a/erpnext/accounts/doctype/dunning/dunning.js b/erpnext/accounts/doctype/dunning/dunning.js index c563368894..9909c6c2ab 100644 --- a/erpnext/accounts/doctype/dunning/dunning.js +++ b/erpnext/accounts/doctype/dunning/dunning.js @@ -44,6 +44,19 @@ frappe.ui.form.on("Dunning", { ); frm.page.set_inner_btn_group_as_primary(__("Create")); } + + if(frm.doc.docstatus > 0) { + frm.add_custom_button(__('Ledger'), function() { + frappe.route_options = { + "voucher_no": frm.doc.name, + "from_date": frm.doc.posting_date, + "to_date": frm.doc.posting_date, + "company": frm.doc.company, + "show_cancelled_entries": frm.doc.docstatus === 2 + }; + frappe.set_route("query-report", "General Ledger"); + }, __('View')); + } }, overdue_days: function (frm) { frappe.db.get_value( @@ -125,9 +138,9 @@ frappe.ui.form.on("Dunning", { }, calculate_interest_and_amount: function (frm) { const interest_per_year = frm.doc.outstanding_amount * frm.doc.rate_of_interest / 100; - const interest_amount = interest_per_year / 365 * frm.doc.overdue_days || 0; - const dunning_amount = interest_amount + frm.doc.dunning_fee; - const grand_total = frm.doc.outstanding_amount + dunning_amount; + const interest_amount = flt((interest_per_year * cint(frm.doc.overdue_days)) / 365 || 0, precision('interest_amount')); + const dunning_amount = flt(interest_amount + frm.doc.dunning_fee, precision('dunning_amount')); + const grand_total = flt(frm.doc.outstanding_amount + dunning_amount, precision('grand_total')); frm.set_value("interest_amount", interest_amount); frm.set_value("dunning_amount", dunning_amount); frm.set_value("grand_total", grand_total); diff --git a/erpnext/accounts/doctype/dunning/dunning.json b/erpnext/accounts/doctype/dunning/dunning.json index b3eddf5f22..d55bfd1ac4 100644 --- a/erpnext/accounts/doctype/dunning/dunning.json +++ b/erpnext/accounts/doctype/dunning/dunning.json @@ -29,10 +29,10 @@ "company_address_display", "section_break_6", "dunning_type", - "interest_amount", + "dunning_fee", "column_break_8", "rate_of_interest", - "dunning_fee", + "interest_amount", "section_break_12", "dunning_amount", "grand_total", @@ -215,7 +215,7 @@ }, { "default": "0", - "fetch_from": "dunning_type.interest_rate", + "fetch_from": "dunning_type.rate_of_interest", "fetch_if_empty": 1, "fieldname": "rate_of_interest", "fieldtype": "Float", @@ -315,7 +315,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2020-07-21 18:20:23.512151", + "modified": "2020-08-03 18:55:43.683053", "modified_by": "Administrator", "module": "Accounts", "name": "Dunning", diff --git a/erpnext/accounts/doctype/dunning/dunning.py b/erpnext/accounts/doctype/dunning/dunning.py index 0be6a480c9..3e372affa1 100644 --- a/erpnext/accounts/doctype/dunning/dunning.py +++ b/erpnext/accounts/doctype/dunning/dunning.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe import json from six import string_types -from frappe.utils import getdate, get_datetime, rounded, flt +from frappe.utils import getdate, get_datetime, rounded, flt, cint from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_year from erpnext.accounts.general_ledger import make_gl_entries, make_reverse_gl_entries from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions @@ -27,11 +27,11 @@ class Dunning(AccountsController): amounts = calculate_interest_and_amount( self.posting_date, self.outstanding_amount, self.rate_of_interest, self.dunning_fee, self.overdue_days) if self.interest_amount != amounts.get('interest_amount'): - self.interest_amount = amounts.get('interest_amount') + self.interest_amount = flt(amounts.get('interest_amount'), self.precision('interest_amount')) if self.dunning_amount != amounts.get('dunning_amount'): - self.dunning_amount = amounts.get('dunning_amount') + self.dunning_amount = flt(amounts.get('dunning_amount'), self.precision('dunning_amount')) if self.grand_total != amounts.get('grand_total'): - self.grand_total = amounts.get('grand_total') + self.grand_total = flt(amounts.get('grand_total'), self.precision('grand_total')) def on_submit(self): self.make_gl_entries() @@ -47,10 +47,13 @@ class Dunning(AccountsController): gl_entries = [] invoice_fields = ["project", "cost_center", "debit_to", "party_account_currency", "conversion_rate", "cost_center"] inv = frappe.db.get_value("Sales Invoice", self.sales_invoice, invoice_fields, as_dict=1) + accounting_dimensions = get_accounting_dimensions() invoice_fields.extend(accounting_dimensions) + dunning_in_company_currency = flt(self.dunning_amount * inv.conversion_rate) default_cost_center = frappe.get_cached_value('Company', self.company, 'cost_center') + gl_entries.append( self.get_gl_dict({ "account": inv.debit_to, @@ -91,9 +94,8 @@ def resolve_dunning(doc, state): def calculate_interest_and_amount(posting_date, outstanding_amount, rate_of_interest, dunning_fee, overdue_days): interest_amount = 0 if rate_of_interest: - interest_per_year = rounded(flt(outstanding_amount) * flt(rate_of_interest))/100 - interest_amount = ( - interest_per_year / days_in_year(get_datetime(posting_date).year)) * int(overdue_days) + interest_per_year = flt(outstanding_amount) * flt(rate_of_interest) / 100 + interest_amount = (interest_per_year * cint(overdue_days)) / 365 grand_total = flt(outstanding_amount) + flt(interest_amount) + flt(dunning_fee) dunning_amount = flt(interest_amount) + flt(dunning_fee) return { diff --git a/erpnext/accounts/doctype/dunning/dunning_dashboard.py b/erpnext/accounts/doctype/dunning/dunning_dashboard.py new file mode 100644 index 0000000000..19a73ddfa4 --- /dev/null +++ b/erpnext/accounts/doctype/dunning/dunning_dashboard.py @@ -0,0 +1,17 @@ +from __future__ import unicode_literals +from frappe import _ + +def get_data(): + return { + 'fieldname': 'dunning', + 'non_standard_fieldnames': { + 'Journal Entry': 'reference_name', + 'Payment Entry': 'reference_name' + }, + 'transactions': [ + { + 'label': _('Payment'), + 'items': ['Payment Entry', 'Journal Entry'] + } + ] + } \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py index 4a8fcc03fd..f1069282ed 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py @@ -18,7 +18,7 @@ def get_data(): 'transactions': [ { 'label': _('Payment'), - 'items': ['Payment Entry', 'Payment Request', 'Journal Entry', 'Invoice Discounting'] + 'items': ['Payment Entry', 'Payment Request', 'Journal Entry', 'Invoice Discounting', 'Dunning'] }, { 'label': _('Reference'), From e211bb7a538cde4208c84da2801ea9f69d4a24f4 Mon Sep 17 00:00:00 2001 From: Marica Date: Mon, 3 Aug 2020 20:40:09 +0530 Subject: [PATCH 32/34] fix: Reposition description in Warehouse (#22895) --- erpnext/stock/doctype/warehouse/warehouse.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/warehouse/warehouse.json b/erpnext/stock/doctype/warehouse/warehouse.json index c0c9fbc92d..1cc600b9ca 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.json +++ b/erpnext/stock/doctype/warehouse/warehouse.json @@ -85,6 +85,7 @@ "fieldtype": "Column Break" }, { + "description": "If blank, parent Warehouse Account or company default will be considered in transactions", "fieldname": "account", "fieldtype": "Link", "label": "Account", @@ -235,7 +236,7 @@ "idx": 1, "is_tree": 1, "links": [], - "modified": "2020-08-03 11:19:35.943330", + "modified": "2020-08-03 18:41:52.442502", "modified_by": "Administrator", "module": "Stock", "name": "Warehouse", From b7311c8fc1b4039a114dd0dfa5a3f1ba85f5f48c Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 3 Aug 2020 20:41:25 +0530 Subject: [PATCH 33/34] fix: SQL query in accounts receivable, payable reports (#22888) --- .../report/accounts_receivable/accounts_receivable.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 66aa18058b..59117c8174 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -643,8 +643,10 @@ class ReceivablePayableReport(object): account_type = "Receivable" if self.party_type == "Customer" else "Payable" accounts = [d.name for d in frappe.get_all("Account", filters={"account_type": account_type, "company": self.filters.company})] - conditions.append("account in (%s)" % ','.join(['%s'] *len(accounts))) - values += accounts + + if accounts: + conditions.append("account in (%s)" % ','.join(['%s'] *len(accounts))) + values += accounts def add_customer_filters(self, conditions, values): if self.filters.get("customer_group"): From a042d4721eaadbb835ce114e66d9b15d01dfa100 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Aug 2020 20:42:15 +0530 Subject: [PATCH 34/34] fix: Bank Clearance of POS purchase invoice (#22882) --- .../doctype/bank_clearance/bank_clearance.py | 21 +++++++++++++++---- .../purchase_invoice/purchase_invoice.json | 8 ++++--- .../sales_invoice_payment.json | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 6fec3ab368..76d82e7339 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -60,12 +60,12 @@ class BankClearance(Document): """.format(condition=condition), {"account": self.account, "from":self.from_date, "to": self.to_date, "bank_account": self.bank_account}, as_dict=1) - pos_entries = [] + pos_sales_invoices, pos_purchase_invoices = [], [] if self.include_pos_transactions: - pos_entries = frappe.db.sql(""" + pos_sales_invoices = frappe.db.sql(""" select "Sales Invoice Payment" as payment_document, sip.name as payment_entry, sip.amount as debit, - si.posting_date, si.debit_to as against_account, sip.clearance_date, + si.posting_date, si.customer as against_account, sip.clearance_date, account.account_currency, 0 as credit from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account where @@ -75,7 +75,20 @@ class BankClearance(Document): si.posting_date ASC, si.name DESC """, {"account":self.account, "from":self.from_date, "to":self.to_date}, as_dict=1) - entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), + pos_purchase_invoices = frappe.db.sql(""" + select + "Purchase Invoice" as payment_document, pi.name as payment_entry, pi.paid_amount as credit, + pi.posting_date, pi.supplier as against_account, pi.clearance_date, + account.account_currency, 0 as debit + from `tabPurchase Invoice` pi, `tabAccount` account + where + pi.cash_bank_account=%(account)s and pi.docstatus=1 and account.name = pi.cash_bank_account + and pi.posting_date >= %(from)s and pi.posting_date <= %(to)s + order by + pi.posting_date ASC, pi.name DESC + """, {"account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1) + + entries = sorted(list(payment_entries) + list(journal_entries + list(pos_sales_invoices) + list(pos_purchase_invoices)), key=lambda k: k['posting_date'] or getdate(nowdate())) self.set('payment_entries', []) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index df77dc8417..2e91c8ef19 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -969,8 +969,10 @@ { "fieldname": "clearance_date", "fieldtype": "Date", - "hidden": 1, - "label": "Clearance Date" + "label": "Clearance Date", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 }, { "fieldname": "col_br_payments", @@ -1332,7 +1334,7 @@ "idx": 204, "is_submittable": 1, "links": [], - "modified": "2020-07-24 09:46:40.405463", + "modified": "2020-08-03 12:46:01.411074", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json index 2f9d381c92..5ab46b7fd5 100644 --- a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json +++ b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json @@ -64,6 +64,7 @@ "fieldname": "clearance_date", "fieldtype": "Date", "label": "Clearance Date", + "no_copy": 1, "print_hide": 1, "read_only": 1 }, @@ -78,7 +79,7 @@ ], "istable": 1, "links": [], - "modified": "2020-05-05 16:51:20.091441", + "modified": "2020-08-03 12:45:39.986598", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Payment",