Merge pull request #22854 from nabinhait/gl-balance-fix
fix: Ignore cancelled gl entries to get account balance
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 4bbf63b..adfaade 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -25,7 +25,7 @@
});
frm.set_query("party_type", function() {
return{
- "filters": {
+ filters: {
"name": ["in", Object.keys(frappe.boot.party_account_types)],
}
}
@@ -33,7 +33,7 @@
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 @@
frm.set_query("bank_account", function() {
return {
filters: {
- "is_company_account":1
+ is_company_account: 1
}
}
});
@@ -342,7 +342,7 @@
() => {
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/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json
index 97165a3..a3152ab 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
},
{
@@ -205,24 +210,19 @@
"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",
diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json
index 4606395..40362b1 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",
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 bb86eaa..a318e50 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 @@
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'))
diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py
index cf63b65..69356ba 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 @@
(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(_('Row #{0}: Check Out datetime cannot be less than Check In datetime').format(entry.idx))
+
def validate_already_scheduled_or_admitted(self):
query = """
select name, status
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index 9abaa07..dbd3b83 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -40,7 +40,7 @@
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'
)
diff --git a/erpnext/public/js/website_theme.js b/erpnext/public/js/website_theme.js
index 84de2f5..9662f78 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";`);
diff --git a/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json b/erpnext/stock/dashboard_chart/oldest_items/oldest_items.json
index 6da3b28..9c10a53 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",