Merge pull request #21471 from Alchez/dev-update-lead-contact
fix: update lead if contact details are changed (develop)
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 53ff222..68aeb6d 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -326,7 +326,7 @@
"reference_doctype": args.dt,
"reference_name": args.dn,
"party_type": args.get("party_type") or "Customer",
- "party": args.get("party") or ref_doc.customer,
+ "party": args.get("party") or ref_doc.get("customer"),
"bank_account": bank_account
})
@@ -420,7 +420,7 @@
def update_payment_req_status(doc, method):
from erpnext.accounts.doctype.payment_entry.payment_entry import get_reference_details
-
+
for ref in doc.references:
payment_request_name = frappe.db.get_value("Payment Request",
{"reference_doctype": ref.reference_doctype, "reference_name": ref.reference_name,
@@ -430,7 +430,7 @@
ref_details = get_reference_details(ref.reference_doctype, ref.reference_name, doc.party_account_currency)
pay_req_doc = frappe.get_doc('Payment Request', payment_request_name)
status = pay_req_doc.status
-
+
if status != "Paid" and not ref_details.outstanding_amount:
status = 'Paid'
elif status != "Partially Paid" and ref_details.outstanding_amount != ref_details.total_amount:
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
index b62238b..c2c7207 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
@@ -84,6 +84,7 @@
def get_profit_loss_data(fiscal_year, companies, columns, filters):
income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)
+ company_currency = get_company_currency(filters)
data = []
data.extend(income or [])
@@ -93,7 +94,7 @@
chart = get_pl_chart_data(filters, columns, income, expense, net_profit_loss)
- report_summary = get_pl_summary(companies, '', income, expense, net_profit_loss, True)
+ report_summary = get_pl_summary(companies, '', income, expense, net_profit_loss, company_currency, True)
return data, None, chart, report_summary
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 127f313..1f78c7a 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -102,7 +102,7 @@
data.append(row)
- if filters.get('group_by'):
+ if filters.get('group_by') and item_list:
total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
data.append(total_row)
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 0c8957a..92a22e6 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -111,7 +111,7 @@
data.append(row)
- if filters.get('group_by'):
+ if filters.get('group_by') and item_list:
total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
data.append(total_row)
diff --git a/erpnext/buying/doctype/supplier/supplier_dashboard.py b/erpnext/buying/doctype/supplier/supplier_dashboard.py
index d0d5b73..1625103 100644
--- a/erpnext/buying/doctype/supplier/supplier_dashboard.py
+++ b/erpnext/buying/doctype/supplier/supplier_dashboard.py
@@ -23,15 +23,11 @@
},
{
'label': _('Payments'),
- 'items': ['Payment Entry']
- },
- {
- 'label': _('Bank'),
- 'items': ['Bank Account']
+ 'items': ['Payment Entry', 'Bank Account']
},
{
'label': _('Pricing'),
'items': ['Pricing Rule']
}
]
- }
\ No newline at end of file
+ }
diff --git a/erpnext/education/doctype/fees/fees.js b/erpnext/education/doctype/fees/fees.js
index e2c6f1d..17ef449 100644
--- a/erpnext/education/doctype/fees/fees.js
+++ b/erpnext/education/doctype/fees/fees.js
@@ -112,6 +112,8 @@
args: {
"dt": frm.doc.doctype,
"dn": frm.doc.name,
+ "party_type": "Student",
+ "party": frm.doc.student,
"recipient_id": frm.doc.student_email
},
callback: function(r) {
diff --git a/erpnext/education/doctype/fees/fees.py b/erpnext/education/doctype/fees/fees.py
index aa616e6..f31003b 100644
--- a/erpnext/education/doctype/fees/fees.py
+++ b/erpnext/education/doctype/fees/fees.py
@@ -75,7 +75,8 @@
self.make_gl_entries()
if self.send_payment_request and self.student_email:
- pr = make_payment_request(dt="Fees", dn=self.name, recipient_id=self.student_email,
+ pr = make_payment_request(party_type="Student", party=self.student, dt="Fees",
+ dn=self.name, recipient_id=self.student_email,
submit_doc=True, use_dummy_message=True)
frappe.msgprint(_("Payment request {0} created").format(getlink("Payment Request", pr.name)))
diff --git a/erpnext/education/doctype/student/student_dashboard.py b/erpnext/education/doctype/student/student_dashboard.py
index 0cbd17b..d261462 100644
--- a/erpnext/education/doctype/student/student_dashboard.py
+++ b/erpnext/education/doctype/student/student_dashboard.py
@@ -6,6 +6,9 @@
'heatmap': True,
'heatmap_message': _('This is based on the attendance of this Student'),
'fieldname': 'student',
+ 'non_standard_fieldnames': {
+ 'Bank Account': 'party'
+ },
'transactions': [
{
'label': _('Admission'),
@@ -29,7 +32,7 @@
},
{
'label': _('Fee'),
- 'items': ['Fees']
+ 'items': ['Fees', 'Bank Account']
}
]
- }
\ No newline at end of file
+ }
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
index 5f36bdd..87c22cc 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
@@ -80,6 +80,7 @@
frappe.call({
method: 'complete_procedure',
doc: frm.doc,
+ freeze: true,
callback: function(r) {
if (r.message) {
frappe.show_alert({
@@ -87,8 +88,8 @@
['<a class="bold" href="#Form/Stock Entry/'+ r.message + '">' + r.message + '</a>']),
indicator: 'green'
});
- frm.reload_doc();
}
+ frm.reload_doc();
}
});
}
@@ -111,9 +112,10 @@
frappe.call({
doc: frm.doc,
method: 'make_material_receipt',
+ freeze: true,
callback: function(r) {
if (!r.exc) {
- cur_frm.reload_doc();
+ frm.reload_doc();
let doclist = frappe.model.sync(r.message);
frappe.set_route('Form', doclist[0].doctype, doclist[0].name);
}
@@ -122,7 +124,7 @@
}
);
} else {
- cur_frm.reload_doc();
+ frm.reload_doc();
}
}
}
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
index db3afc8..b7d7a62 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
@@ -87,7 +87,8 @@
else:
frappe.throw(_('Please set Customer in Patient {0}').format(frappe.bold(self.patient)), title=_('Customer Not Found'))
- frappe.db.set_value('Clinical Procedure', self.name, 'status', 'Completed')
+ self.db_set('status', 'Completed')
+
if self.consume_stock and self.items:
return stock_entry
@@ -245,9 +246,9 @@
def insert_clinical_procedure_to_medical_record(doc):
- subject = cstr(doc.procedure_template)
+ subject = frappe.bold(_("Clinical Procedure conducted: ")) + cstr(doc.procedure_template) + "<br>"
if doc.practitioner:
- subject += ' ' + doc.practitioner
+ subject += frappe.bold(_('Healthcare Practitioner: ')) + doc.practitioner
if subject and doc.notes:
subject += '<br/>' + doc.notes
diff --git a/erpnext/healthcare/doctype/exercise_type/exercise_type.js b/erpnext/healthcare/doctype/exercise_type/exercise_type.js
index f450c9b..68db047 100644
--- a/erpnext/healthcare/doctype/exercise_type/exercise_type.js
+++ b/erpnext/healthcare/doctype/exercise_type/exercise_type.js
@@ -24,6 +24,8 @@
this.exercise_cards = $('<div class="exercise-cards"></div>').appendTo(this.wrapper);
+ this.row = $('<div class="exercise-row"></div>').appendTo(this.wrapper);
+
let me = this;
this.exercise_toolbar.find(".btn-add")
@@ -32,7 +34,7 @@
me.show_add_card_dialog(frm);
});
- if (frm.doc.steps_table.length > 0) {
+ if (frm.doc.steps_table && frm.doc.steps_table.length > 0) {
this.make_cards(frm);
this.make_buttons(frm);
}
@@ -41,7 +43,6 @@
make_cards: function(frm) {
var me = this;
$(me.exercise_cards).empty();
- this.row = $('<div class="exercise-row"></div>').appendTo(me.exercise_cards);
$.each(frm.doc.steps_table, function(i, step) {
$(repl(`
@@ -78,6 +79,7 @@
frm.doc.steps_table.pop(id);
frm.refresh_field('steps_table');
$('#col-'+id).remove();
+ frm.dirty();
}, 300);
});
},
@@ -106,7 +108,10 @@
],
primary_action: function() {
let data = d.get_values();
- let i = frm.doc.steps_table.length;
+ let i = 0;
+ if (frm.doc.steps_table) {
+ i = frm.doc.steps_table.length;
+ }
$(repl(`
<div class="exercise-col col-sm-4" id="%(col_id)s">
<div class="card h-100 exercise-card" id="%(card_id)s">
@@ -165,9 +170,10 @@
frm.doc.steps_table[id].image = data.image;
frm.doc.steps_table[id].description = data.step_description;
refresh_field('steps_table');
+ frm.dirty();
new_dialog.hide();
},
- primary_action_label: __("Save"),
+ primary_action_label: __("Edit"),
});
new_dialog.set_values({
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index 4e4015d..ea8ce25 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -288,23 +288,23 @@
table_row = False
subject = cstr(doc.lab_test_name)
if doc.practitioner:
- subject += " "+ doc.practitioner
+ subject += frappe.bold(_("Healthcare Practitioner: "))+ doc.practitioner + "<br>"
if doc.normal_test_items:
item = doc.normal_test_items[0]
comment = ""
if item.lab_test_comment:
comment = str(item.lab_test_comment)
- table_row = item.lab_test_name
+ table_row = frappe.bold(_("Lab Test Conducted: ")) + item.lab_test_name
if item.lab_test_event:
- table_row += " " + item.lab_test_event
+ table_row += frappe.bold(_("Lab Test Event: ")) + item.lab_test_event
if item.result_value:
- table_row += " " + item.result_value
+ table_row += " " + frappe.bold(_("Lab Test Result: ")) + item.result_value
if item.normal_range:
- table_row += " normal_range("+item.normal_range+")"
- table_row += " "+comment
+ table_row += " " + _("Normal Range:") + item.normal_range
+ table_row += " " + comment
elif doc.special_test_items:
item = doc.special_test_items[0]
@@ -316,12 +316,12 @@
item = doc.sensitivity_test_items[0]
if item.antibiotic and item.antibiotic_sensitivity:
- table_row = item.antibiotic +" "+ item.antibiotic_sensitivity
+ table_row = item.antibiotic + " " + item.antibiotic_sensitivity
if table_row:
- subject += "<br/>"+table_row
+ subject += "<br>" + table_row
if doc.lab_test_comment:
- subject += "<br/>"+ cstr(doc.lab_test_comment)
+ subject += "<br>" + cstr(doc.lab_test_comment)
medical_record = frappe.new_doc("Patient Medical Record")
medical_record.patient = doc.patient
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
index 767643b..1734c28 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
@@ -18,6 +18,9 @@
def after_insert(self):
insert_encounter_to_medical_record(self)
+ def on_submit(self):
+ update_encounter_medical_record(self)
+
def on_cancel(self):
if self.appointment:
frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Open')
@@ -66,22 +69,26 @@
frappe.db.delete_doc_if_exists('Patient Medical Record', 'reference_name', encounter.name)
def set_subject_field(encounter):
- subject = encounter.practitioner + '\n'
+ subject = frappe.bold(_('Healthcare Practitioner: ')) + encounter.practitioner + '<br>'
if encounter.symptoms:
- subject += _('Symptoms: ') + cstr(encounter.symptoms) + '\n'
+ subject += frappe.bold(_('Symptoms: ')) + '<br>'
+ for entry in encounter.symptoms:
+ subject += cstr(entry.complaint) + '<br>'
else:
- subject += _('No Symptoms') + '\n'
+ subject += frappe.bold(_('No Symptoms')) + '<br>'
if encounter.diagnosis:
- subject += _('Diagnosis: ') + cstr(encounter.diagnosis) + '\n'
+ subject += frappe.bold(_('Diagnosis: ')) + '<br>'
+ for entry in encounter.diagnosis:
+ subject += cstr(entry.diagnosis) + '<br>'
else:
- subject += _('No Diagnosis') + '\n'
+ subject += frappe.bold(_('No Diagnosis')) + '<br>'
if encounter.drug_prescription:
- subject += '\n' + _('Drug(s) Prescribed.')
+ subject += '<br>' + _('Drug(s) Prescribed.')
if encounter.lab_test_prescription:
- subject += '\n' + _('Test(s) Prescribed.')
+ subject += '<br>' + _('Test(s) Prescribed.')
if encounter.procedure_prescription:
- subject += '\n' + _('Procedure(s) Prescribed.')
+ subject += '<br>' + _('Procedure(s) Prescribed.')
return subject
diff --git a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json
index 3655e24..ed82355 100644
--- a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json
+++ b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json
@@ -57,7 +57,7 @@
},
{
"fieldname": "subject",
- "fieldtype": "Small Text",
+ "fieldtype": "Text Editor",
"ignore_xss_filter": 1,
"label": "Subject"
},
@@ -125,7 +125,7 @@
],
"in_create": 1,
"links": [],
- "modified": "2020-03-23 19:26:59.308383",
+ "modified": "2020-04-29 12:26:57.679402",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Medical Record",
diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
index 201264f..c19be17 100644
--- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
+++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
@@ -21,8 +21,14 @@
self.status = 'Completed'
def set_totals(self):
- total_sessions = sum([int(d.no_of_sessions) for d in self.get('therapy_plan_details')])
- total_sessions_completed = sum([int(d.sessions_completed) for d in self.get('therapy_plan_details')])
+ total_sessions = 0
+ total_sessions_completed = 0
+ for entry in self.therapy_plan_details:
+ if entry.no_of_sessions:
+ total_sessions += entry.no_of_sessions
+ if entry.sessions_completed:
+ total_sessions_completed += entry.sessions_completed
+
self.db_set('total_sessions', total_sessions)
self.db_set('total_sessions_completed', total_sessions_completed)
diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session.js b/erpnext/healthcare/doctype/therapy_session/therapy_session.js
index bb67575..abe4def 100644
--- a/erpnext/healthcare/doctype/therapy_session/therapy_session.js
+++ b/erpnext/healthcare/doctype/therapy_session/therapy_session.js
@@ -13,23 +13,92 @@
refresh: function(frm) {
if (!frm.doc.__islocal) {
- let target = 0;
- let completed = 0;
- $.each(frm.doc.exercises, function(_i, e) {
- target += e.counts_target;
- completed += e.counts_completed;
- });
- frm.dashboard.add_indicator(__('Counts Targetted: {0}', [target]), 'blue');
- frm.dashboard.add_indicator(__('Counts Completed: {0}', [completed]), (completed < target) ? 'orange' : 'green');
+ frm.dashboard.add_indicator(__('Counts Targeted: {0}', [frm.doc.total_counts_targeted]), 'blue');
+ frm.dashboard.add_indicator(__('Counts Completed: {0}', [frm.doc.total_counts_completed]),
+ (frm.doc.total_counts_completed < frm.doc.total_counts_targeted) ? 'orange' : 'green');
}
if (frm.doc.docstatus === 1) {
- frm.add_custom_button(__('Patient Assessment'),function() {
+ frm.add_custom_button(__('Patient Assessment'), function() {
frappe.model.open_mapped_doc({
method: 'erpnext.healthcare.doctype.patient_assessment.patient_assessment.create_patient_assessment',
frm: frm,
})
}, 'Create');
+
+ frm.add_custom_button(__('Sales Invoice'), function() {
+ frappe.model.open_mapped_doc({
+ method: 'erpnext.healthcare.doctype.therapy_session.therapy_session.invoice_therapy_session',
+ frm: frm,
+ })
+ }, 'Create');
+ }
+ },
+
+ patient: function(frm) {
+ if (frm.doc.patient) {
+ frappe.call({
+ 'method': 'erpnext.healthcare.doctype.patient.patient.get_patient_detail',
+ args: {
+ patient: frm.doc.patient
+ },
+ callback: function (data) {
+ let age = '';
+ if (data.message.dob) {
+ age = calculate_age(data.message.dob);
+ } else if (data.message.age) {
+ age = data.message.age;
+ if (data.message.age_as_on) {
+ age = __('{0} as on {1}', [age, data.message.age_as_on]);
+ }
+ }
+ frm.set_value('patient_age', age);
+ frm.set_value('gender', data.message.sex);
+ frm.set_value('patient_name', data.message.patient_name);
+ }
+ });
+ } else {
+ frm.set_value('patient_age', '');
+ frm.set_value('gender', '');
+ frm.set_value('patient_name', '');
+ }
+ },
+
+ appointment: function(frm) {
+ if (frm.doc.appointment) {
+ frappe.call({
+ 'method': 'frappe.client.get',
+ args: {
+ doctype: 'Patient Appointment',
+ name: frm.doc.appointment
+ },
+ callback: function(data) {
+ let values = {
+ 'patient':data.message.patient,
+ 'therapy_type': data.message.therapy_type,
+ 'therapy_plan': data.message.therapy_plan,
+ 'practitioner': data.message.practitioner,
+ 'department': data.message.department,
+ 'start_date': data.message.appointment_date,
+ 'start_time': data.message.appointment_time,
+ 'service_unit': data.message.service_unit,
+ 'company': data.message.company
+ };
+ frm.set_value(values);
+ }
+ });
+ } else {
+ let values = {
+ 'patient': '',
+ 'therapy_type': '',
+ 'therapy_plan': '',
+ 'practitioner': '',
+ 'department': '',
+ 'start_date': '',
+ 'start_time': '',
+ 'service_unit': '',
+ };
+ frm.set_value(values);
}
},
@@ -44,6 +113,8 @@
callback: function(data) {
frm.set_value('duration', data.message.default_duration);
frm.set_value('rate', data.message.rate);
+ frm.set_value('service_unit', data.message.healthcare_service_unit);
+ frm.set_value('department', data.message.medical_department);
frm.doc.exercises = [];
$.each(data.message.exercises, function(_i, e) {
let exercise = frm.add_child('exercises');
diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session.json b/erpnext/healthcare/doctype/therapy_session/therapy_session.json
index 5ff7196..00d74a0 100644
--- a/erpnext/healthcare/doctype/therapy_session/therapy_session.json
+++ b/erpnext/healthcare/doctype/therapy_session/therapy_session.json
@@ -9,9 +9,11 @@
"naming_series",
"appointment",
"patient",
+ "patient_name",
"patient_age",
"gender",
"column_break_5",
+ "company",
"therapy_plan",
"therapy_type",
"practitioner",
@@ -20,7 +22,6 @@
"duration",
"rate",
"location",
- "company",
"column_break_12",
"service_unit",
"start_date",
@@ -28,6 +29,10 @@
"invoiced",
"exercises_section",
"exercises",
+ "section_break_23",
+ "total_counts_targeted",
+ "column_break_25",
+ "total_counts_completed",
"amended_from"
],
"fields": [
@@ -159,7 +164,8 @@
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
- "options": "Company"
+ "options": "Company",
+ "reqd": 1
},
{
"default": "0",
@@ -173,11 +179,38 @@
"fieldtype": "Data",
"label": "Patient Age",
"read_only": 1
+ },
+ {
+ "fieldname": "total_counts_targeted",
+ "fieldtype": "Int",
+ "label": "Total Counts Targeted",
+ "read_only": 1
+ },
+ {
+ "fieldname": "total_counts_completed",
+ "fieldtype": "Int",
+ "label": "Total Counts Completed",
+ "read_only": 1
+ },
+ {
+ "fieldname": "section_break_23",
+ "fieldtype": "Section Break"
+ },
+ {
+ "fieldname": "column_break_25",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fetch_from": "patient.patient_name",
+ "fieldname": "patient_name",
+ "fieldtype": "Data",
+ "label": "Patient Name",
+ "read_only": 1
}
],
"is_submittable": 1,
"links": [],
- "modified": "2020-04-21 13:16:46.378798",
+ "modified": "2020-04-29 16:49:16.286006",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Therapy Session",
diff --git a/erpnext/healthcare/doctype/therapy_session/therapy_session.py b/erpnext/healthcare/doctype/therapy_session/therapy_session.py
index 45d2ee6..9650183 100644
--- a/erpnext/healthcare/doctype/therapy_session/therapy_session.py
+++ b/erpnext/healthcare/doctype/therapy_session/therapy_session.py
@@ -6,10 +6,17 @@
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
+from frappe import _
+from frappe.utils import cstr, getdate
+from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
class TherapySession(Document):
+ def validate(self):
+ self.set_total_counts()
+
def on_submit(self):
self.update_sessions_count_in_therapy_plan()
+ insert_session_medical_record(self)
def on_cancel(self):
self.update_sessions_count_in_therapy_plan(on_cancel=True)
@@ -24,6 +31,18 @@
entry.sessions_completed += 1
therapy_plan.save()
+ def set_total_counts(self):
+ target_total = 0
+ counts_completed = 0
+ for entry in self.exercises:
+ if entry.counts_target:
+ target_total += entry.counts_target
+ if entry.counts_completed:
+ counts_completed += entry.counts_completed
+
+ self.db_set('total_counts_targeted', target_total)
+ self.db_set('total_counts_completed', counts_completed)
+
@frappe.whitelist()
def create_therapy_session(source_name, target_doc=None):
@@ -52,4 +71,62 @@
}
}, target_doc, set_missing_values)
- return doc
\ No newline at end of file
+ return doc
+
+
+@frappe.whitelist()
+def invoice_therapy_session(source_name, target_doc=None):
+ def set_missing_values(source, target):
+ target.customer = frappe.db.get_value('Patient', source.patient, 'customer')
+ target.due_date = getdate()
+ target.debit_to = get_receivable_account(source.company)
+ item = target.append('items', {})
+ item = get_therapy_item(source, item)
+ target.set_missing_values(for_validate=True)
+
+ doc = get_mapped_doc('Therapy Session', source_name, {
+ 'Therapy Session': {
+ 'doctype': 'Sales Invoice',
+ 'field_map': [
+ ['patient', 'patient'],
+ ['referring_practitioner', 'practitioner'],
+ ['company', 'company'],
+ ['due_date', 'start_date']
+ ]
+ }
+ }, target_doc, set_missing_values)
+
+ return doc
+
+
+def get_therapy_item(therapy, item):
+ item.item_code = frappe.db.get_value('Therapy Type', therapy.therapy_type, 'item')
+ item.description = _('Therapy Session Charges: {0}').format(therapy.practitioner)
+ item.income_account = get_income_account(therapy.practitioner, therapy.company)
+ item.cost_center = frappe.get_cached_value('Company', therapy.company, 'cost_center')
+ item.rate = therapy.rate
+ item.amount = therapy.rate
+ item.qty = 1
+ item.reference_dt = 'Therapy Session'
+ item.reference_dn = therapy.name
+ return item
+
+
+def insert_session_medical_record(doc):
+ subject = frappe.bold(_('Therapy: ')) + cstr(doc.therapy_type) + '<br>'
+ if doc.therapy_plan:
+ subject += frappe.bold(_('Therapy Plan: ')) + cstr(doc.therapy_plan) + '<br>'
+ if doc.practitioner:
+ subject += frappe.bold(_('Healthcare Practitioner: ')) + doc.practitioner
+ subject += frappe.bold(_('Total Counts Targeted: ')) + cstr(doc.total_counts_targeted) + '<br>'
+ subject += frappe.bold(_('Total Counts Completed: ')) + cstr(doc.total_counts_completed) + '<br>'
+
+ medical_record = frappe.new_doc('Patient Medical Record')
+ medical_record.patient = doc.patient
+ medical_record.subject = subject
+ medical_record.status = 'Open'
+ medical_record.communication_date = doc.start_date
+ medical_record.reference_doctype = 'Therapy Session'
+ medical_record.reference_name = doc.name
+ medical_record.reference_owner = doc.owner
+ medical_record.save(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
index 959e850..b0e78e8 100644
--- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py
+++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py
@@ -35,17 +35,17 @@
def set_subject_field(doc):
subject = ''
- if(doc.temperature):
- subject += _('Temperature: ') + '\n'+ cstr(doc.temperature) + '. '
- if(doc.pulse):
- subject += _('Pulse: ') + '\n' + cstr(doc.pulse) + '. '
- if(doc.respiratory_rate):
- subject += _('Respiratory Rate: ') + '\n' + cstr(doc.respiratory_rate) + '. '
- if(doc.bp):
- subject += _('BP: ') + '\n' + cstr(doc.bp) + '. '
- if(doc.bmi):
- subject += _('BMI: ') + '\n' + cstr(doc.bmi) + '. '
- if(doc.nutrition_note):
- subject += _('Note: ') + '\n' + cstr(doc.nutrition_note) + '. '
+ if doc.temperature:
+ subject += frappe.bold(_('Temperature: ')) + cstr(doc.temperature) + '<br>'
+ if doc.pulse:
+ subject += frappe.bold(_('Pulse: ')) + cstr(doc.pulse) + '<br>'
+ if doc.respiratory_rate:
+ subject += frappe.bold(_('Respiratory Rate: ')) + cstr(doc.respiratory_rate) + '<br>'
+ if doc.bp:
+ subject += frappe.bold(_('BP: ')) + cstr(doc.bp) + '<br>'
+ if doc.bmi:
+ subject += frappe.bold(_('BMI: ')) + cstr(doc.bmi) + '<br>'
+ if doc.nutrition_note:
+ subject += frappe.bold(_('Note: ')) + cstr(doc.nutrition_note) + '<br>'
return subject
diff --git a/erpnext/hr/doctype/employee/employee_dashboard.py b/erpnext/hr/doctype/employee/employee_dashboard.py
index 11ad83b..0203332 100644
--- a/erpnext/hr/doctype/employee/employee_dashboard.py
+++ b/erpnext/hr/doctype/employee/employee_dashboard.py
@@ -6,6 +6,9 @@
'heatmap': True,
'heatmap_message': _('This is based on the attendance of this Employee'),
'fieldname': 'employee',
+ 'non_standard_fieldnames': {
+ 'Bank Account': 'party'
+ },
'transactions': [
{
'label': _('Leave and Attendance'),
@@ -33,7 +36,7 @@
},
{
'label': _('Payroll'),
- 'items': ['Salary Structure Assignment', 'Salary Slip', 'Additional Salary', 'Timesheet','Employee Incentive', 'Retention Bonus']
+ 'items': ['Salary Structure Assignment', 'Salary Slip', 'Additional Salary', 'Timesheet','Employee Incentive', 'Retention Bonus', 'Bank Account']
},
{
'label': _('Training'),
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index df76458..5ba7f1c 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -149,7 +149,7 @@
return salary_structures_assignments
@frappe.whitelist()
-def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None, for_preview=0):
+def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None, for_preview=0, ignore_permissions=False):
def postprocess(source, target):
if employee:
employee_details = frappe.db.get_value("Employee", employee,
@@ -169,7 +169,7 @@
"name": "salary_structure"
}
}
- }, target_doc, postprocess, ignore_child_tables=True)
+ }, target_doc, postprocess, ignore_child_tables=True, ignore_permissions=ignore_permissions)
if cint(as_print):
doc.name = 'Preview for {0}'.format(employee)
diff --git a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py
index e5622b7..eab58ff 100644
--- a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py
+++ b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py
@@ -12,7 +12,8 @@
columns, data, chart = [], [], []
if filters.get('fiscal_year'):
company = erpnext.get_default_company()
- period_list = get_period_list(filters.get('fiscal_year'), filters.get('fiscal_year'),"Monthly", company)
+ period_list = get_period_list(filters.get('fiscal_year'), filters.get('fiscal_year'),
+ '', '', 'Fiscal Year', 'Monthly', company=company)
columns=get_columns()
data=get_log_data(filters)
chart=get_chart_data(data,period_list)
diff --git a/erpnext/loan_management/doctype/loan_security/loan_security.json b/erpnext/loan_management/doctype/loan_security/loan_security.json
index e6984ee..1d0bb30 100644
--- a/erpnext/loan_management/doctype/loan_security/loan_security.json
+++ b/erpnext/loan_management/doctype/loan_security/loan_security.json
@@ -1,23 +1,26 @@
{
- "autoname": "field:loan_security_name",
+ "actions": [],
+ "allow_rename": 1,
"creation": "2019-09-02 15:07:08.885593",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
- "loan_security_type",
- "loan_security_code",
"loan_security_name",
- "unit_of_measure",
- "column_break_3",
"haircut",
+ "loan_security_code",
+ "column_break_3",
+ "loan_security_type",
+ "unit_of_measure",
"disabled"
],
"fields": [
{
"fieldname": "loan_security_name",
"fieldtype": "Data",
+ "in_list_view": 1,
"label": "Loan Security Name",
+ "reqd": 1,
"unique": 1
},
{
@@ -33,8 +36,10 @@
{
"fieldname": "loan_security_type",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "Loan Security Type",
- "options": "Loan Security Type"
+ "options": "Loan Security Type",
+ "reqd": 1
},
{
"fieldname": "loan_security_code",
@@ -52,11 +57,15 @@
"fetch_from": "loan_security_type.unit_of_measure",
"fieldname": "unit_of_measure",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "Unit Of Measure",
- "options": "UOM"
+ "options": "UOM",
+ "read_only": 1,
+ "reqd": 1
}
],
- "modified": "2019-11-16 11:36:37.901656",
+ "links": [],
+ "modified": "2020-04-29 13:21:26.043492",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Security",
@@ -87,7 +96,6 @@
"write": 1
}
],
- "quick_entry": 1,
"search_fields": "loan_security_code",
"sort_field": "modified",
"sort_order": "DESC",
diff --git a/erpnext/loan_management/doctype/loan_security/loan_security.py b/erpnext/loan_management/doctype/loan_security/loan_security.py
index 800ad12..8858c81 100644
--- a/erpnext/loan_management/doctype/loan_security/loan_security.py
+++ b/erpnext/loan_management/doctype/loan_security/loan_security.py
@@ -7,4 +7,5 @@
from frappe.model.document import Document
class LoanSecurity(Document):
- pass
+ def autoname(self):
+ self.name = self.loan_security_name
diff --git a/erpnext/loan_management/doctype/loan_security_type/loan_security_type.json b/erpnext/loan_management/doctype/loan_security_type/loan_security_type.json
index 5f29609..f46b88c 100644
--- a/erpnext/loan_management/doctype/loan_security_type/loan_security_type.json
+++ b/erpnext/loan_management/doctype/loan_security_type/loan_security_type.json
@@ -9,9 +9,9 @@
"loan_security_type",
"unit_of_measure",
"haircut",
- "disabled",
"column_break_5",
- "loan_to_value_ratio"
+ "loan_to_value_ratio",
+ "disabled"
],
"fields": [
{
@@ -23,7 +23,9 @@
{
"fieldname": "loan_security_type",
"fieldtype": "Data",
+ "in_list_view": 1,
"label": "Loan Security Type",
+ "reqd": 1,
"unique": 1
},
{
@@ -34,8 +36,10 @@
{
"fieldname": "unit_of_measure",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "Unit Of Measure",
- "options": "UOM"
+ "options": "UOM",
+ "reqd": 1
},
{
"fieldname": "column_break_5",
@@ -48,7 +52,7 @@
}
],
"links": [],
- "modified": "2020-02-28 12:43:20.364447",
+ "modified": "2020-04-28 14:06:49.046177",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Security Type",
diff --git a/erpnext/non_profit/doctype/member/member_dashboard.py b/erpnext/non_profit/doctype/member/member_dashboard.py
index 945fb7b..743db25 100644
--- a/erpnext/non_profit/doctype/member/member_dashboard.py
+++ b/erpnext/non_profit/doctype/member/member_dashboard.py
@@ -6,10 +6,17 @@
'heatmap': True,
'heatmap_message': _('Member Activity'),
'fieldname': 'member',
+ 'non_standard_fieldnames': {
+ 'Bank Account': 'party'
+ },
'transactions': [
{
'label': _('Membership Details'),
'items': ['Membership']
+ },
+ {
+ 'label': _('Fee'),
+ 'items': ['Bank Account']
}
]
- }
\ No newline at end of file
+ }
diff --git a/erpnext/public/js/utils/dimension_tree_filter.js b/erpnext/public/js/utils/dimension_tree_filter.js
index 75c5a82..b223fc5 100644
--- a/erpnext/public/js/utils/dimension_tree_filter.js
+++ b/erpnext/public/js/utils/dimension_tree_filter.js
@@ -24,7 +24,7 @@
onload: function(frm) {
erpnext.dimension_filters.forEach((dimension) => {
frappe.model.with_doctype(dimension['document_type'], () => {
- if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
+ if(frappe.meta.has_field(dimension['document_type'], 'is_group')) {
frm.set_query(dimension['fieldname'], {
"is_group": 0
});
@@ -42,19 +42,21 @@
update_dimension: function(frm) {
erpnext.dimension_filters.forEach((dimension) => {
- if (frm.is_new()) {
- if (frm.doc.company && Object.keys(default_dimensions || {}).length > 0
+ if(frm.is_new()) {
+ if(frm.doc.company && Object.keys(default_dimensions || {}).length > 0
&& default_dimensions[frm.doc.company]) {
- if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
- frm.set_value(dimension['fieldname'],
- default_dimensions[frm.doc.company][dimension['document_type']]);
- }
+ let default_dimension = default_dimensions[frm.doc.company][dimension['document_type']];
- $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
- frappe.model.set_value(row.doctype, row.name, dimension['fieldname'],
- default_dimensions[frm.doc.company][dimension['document_type']])
- });
+ if(default_dimension) {
+ if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
+ frm.set_value(dimension['fieldname'], default_dimension);
+ }
+
+ $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
+ frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], default_dimension);
+ });
+ }
}
}
});
@@ -76,20 +78,6 @@
var row = frappe.get_doc(cdt, cdn);
frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
});
- },
-
- items_add: function(frm, cdt, cdn) {
- erpnext.dimension_filters.forEach((dimension) => {
- var row = frappe.get_doc(cdt, cdn);
- frm.script_manager.copy_from_first_row("items", row, [dimension['fieldname']]);
- });
- },
-
- accounts_add: function(frm, cdt, cdn) {
- erpnext.dimension_filters.forEach((dimension) => {
- var row = frappe.get_doc(cdt, cdn);
- frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
- });
}
});
});
\ No newline at end of file
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 094f010..3309858 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -288,7 +288,7 @@
})
def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component):
- salary_slip = make_salary_slip(salary_structure, employee=employee, for_preview=1)
+ salary_slip = make_salary_slip(salary_structure, employee=employee, for_preview=1, ignore_permissions=True)
basic_amt, hra_amt = 0, 0
for earning in salary_slip.earnings:
if earning.salary_component == basic_component:
diff --git a/erpnext/selling/doctype/customer/customer_dashboard.py b/erpnext/selling/doctype/customer/customer_dashboard.py
index 654dd48..22e30e3 100644
--- a/erpnext/selling/doctype/customer/customer_dashboard.py
+++ b/erpnext/selling/doctype/customer/customer_dashboard.py
@@ -11,7 +11,8 @@
'non_standard_fieldnames': {
'Payment Entry': 'party',
'Quotation': 'party_name',
- 'Opportunity': 'party_name'
+ 'Opportunity': 'party_name',
+ 'Bank Account': 'party'
},
'dynamic_links': {
'party_name': ['Customer', 'quotation_to']
@@ -27,7 +28,7 @@
},
{
'label': _('Payments'),
- 'items': ['Payment Entry']
+ 'items': ['Payment Entry', 'Bank Account']
},
{
'label': _('Support'),
diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py
index 0cb606b..857b982 100644
--- a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py
+++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py
@@ -11,8 +11,8 @@
def get_data_column(filters, partner_doctype):
data = []
- period_list = get_period_list(filters.fiscal_year, filters.fiscal_year,
- filters.period, company=filters.company)
+ period_list = get_period_list(filters.fiscal_year, filters.fiscal_year, '', '',
+ 'Fiscal Year', filters.period, company=filters.company)
rows = get_data(filters, period_list, partner_doctype)
columns = get_columns(filters, period_list, partner_doctype)
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 496a865..e4412e0 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -215,9 +215,7 @@
source_doctype: "Material Request",
target: frm,
date_field: "schedule_date",
- setters: {
- company: frm.doc.company,
- },
+ setters: {},
get_query_filters: {
docstatus: 1,
material_request_type: ["in", ["Material Transfer", "Material Issue"]],
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index bdd0bd0..704ae41 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-04-09 11:43:55",
@@ -12,7 +13,6 @@
"stock_entry_type",
"outgoing_stock_entry",
"purpose",
- "company",
"work_order",
"purchase_order",
"delivery_note_no",
@@ -20,6 +20,7 @@
"pick_list",
"purchase_receipt_no",
"col2",
+ "company",
"posting_date",
"posting_time",
"set_posting_time",
@@ -65,6 +66,7 @@
"dimension_col_break",
"printing_settings",
"select_print_heading",
+ "print_settings_col_break",
"letter_head",
"more_info",
"is_opening",
@@ -291,6 +293,7 @@
"fieldtype": "Section Break"
},
{
+ "description": "Sets 'Source Warehouse' in each row of the items table.",
"fieldname": "from_warehouse",
"fieldtype": "Link",
"in_list_view": 1,
@@ -320,6 +323,7 @@
"fieldtype": "Column Break"
},
{
+ "description": "Sets 'Target Warehouse' in each row of the items table.",
"fieldname": "to_warehouse",
"fieldtype": "Link",
"in_list_view": 1,
@@ -622,12 +626,17 @@
"label": "Pick List",
"options": "Pick List",
"read_only": 1
+ },
+ {
+ "fieldname": "print_settings_col_break",
+ "fieldtype": "Column Break"
}
],
"icon": "fa fa-file-text",
"idx": 1,
"is_submittable": 1,
- "modified": "2019-09-27 14:38:20.801420",
+ "links": [],
+ "modified": "2020-04-23 12:56:52.881752",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index a848c80..c16a41c 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -14,12 +14,12 @@
"t_warehouse",
"sec_break1",
"item_code",
- "item_group",
"col_break2",
"item_name",
"section_break_8",
"description",
"column_break_10",
+ "item_group",
"image",
"image_view",
"quantity_and_rate",
@@ -178,6 +178,7 @@
"bold": 1,
"fieldname": "basic_rate",
"fieldtype": "Currency",
+ "in_list_view": 1,
"label": "Basic Rate (as per Stock UOM)",
"oldfieldname": "incoming_rate",
"oldfieldtype": "Currency",
@@ -420,6 +421,7 @@
"options": "Item"
},
{
+ "collapsible": 1,
"fieldname": "reference_section",
"fieldtype": "Section Break",
"label": "Reference"
@@ -466,7 +468,6 @@
"fetch_from": "item_code.item_group",
"fieldname": "item_group",
"fieldtype": "Data",
- "in_list_view": 1,
"label": "Item Group"
},
{
@@ -495,7 +496,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-03-19 12:34:09.836295",
+ "modified": "2020-04-23 19:19:28.539769",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index 28d7208..0190f09 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -46,19 +46,6 @@
"out_qty": min(sle.actual_qty, 0)
})
- # get the name of the item that was produced using this item
- if sle.voucher_type == "Stock Entry":
- purpose, work_order, fg_completed_qty = frappe.db.get_value(sle.voucher_type, sle.voucher_no, ["purpose", "work_order", "fg_completed_qty"])
-
- if purpose == "Manufacture" and work_order:
- finished_product = frappe.db.get_value("Work Order", work_order, "item_name")
- finished_qty = fg_completed_qty
-
- sle.update({
- "finished_product": finished_product,
- "finished_qty": finished_qty,
- })
-
data.append(sle)
if include_uom:
@@ -77,8 +64,6 @@
{"label": _("In Qty"), "fieldname": "in_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Out Qty"), "fieldname": "out_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Balance Qty"), "fieldname": "qty_after_transaction", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Finished Product"), "fieldname": "finished_product", "width": 100},
- {"label": _("Finished Qty"), "fieldname": "finished_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
{"label": _("Voucher #"), "fieldname": "voucher_no", "fieldtype": "Dynamic Link", "options": "voucher_type", "width": 150},
{"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 150},
{"label": _("Item Group"), "fieldname": "item_group", "fieldtype": "Link", "options": "Item Group", "width": 100},