Skip to content

Commit

Permalink
Merge branch 'version-13-hotfix' into sm-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Aug 24, 2021
2 parents 1ce8754 + 27fad29 commit 3910092
Show file tree
Hide file tree
Showing 45 changed files with 1,043 additions and 613 deletions.
8 changes: 2 additions & 6 deletions erpnext/accounts/doctype/pos_invoice/pos_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,13 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend(
this.frm.refresh_field("base_paid_amount");
},

write_off_outstanding_amount_automatically: function() {
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
write_off_outstanding_amount_automatically() {
if (cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
// this will make outstanding amount 0
this.frm.set_value("write_off_amount",
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
);
this.frm.toggle_enable("write_off_amount", false);

} else {
this.frm.toggle_enable("write_off_amount", true);
}

this.calculate_outstanding_amount(false);
Expand Down
5 changes: 3 additions & 2 deletions erpnext/accounts/doctype/pos_invoice/pos_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,8 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "currency",
"print_hide": 1
"print_hide": 1,
"read_only_depends_on": "eval: doc.write_off_outstanding_amount_automatically"
},
{
"fieldname": "base_write_off_amount",
Expand Down Expand Up @@ -1554,7 +1555,7 @@
"icon": "fa fa-file-text",
"is_submittable": 1,
"links": [],
"modified": "2021-08-17 20:13:44.255437",
"modified": "2021-08-18 16:13:52.080543",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Invoice",
Expand Down
10 changes: 2 additions & 8 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
this.frm.refresh_fields();
},

write_off_outstanding_amount_automatically: function() {
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
write_off_outstanding_amount_automatically() {
if (cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
// this will make outstanding amount 0
this.frm.set_value("write_off_amount",
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
);
this.frm.toggle_enable("write_off_amount", false);

} else {
this.frm.toggle_enable("write_off_amount", true);
}

this.calculate_outstanding_amount(false);
Expand Down Expand Up @@ -787,8 +783,6 @@ frappe.ui.form.on('Sales Invoice', {
if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
else hide_field(['c_form_applicable', 'c_form_no']);

frm.toggle_enable("write_off_amount", !!!cint(doc.write_off_outstanding_amount_automatically));

frm.refresh_fields();
},

Expand Down
5 changes: 3 additions & 2 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,8 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "currency",
"print_hide": 1
"print_hide": 1,
"read_only_depends_on": "eval:doc.write_off_outstanding_amount_automatically"
},
{
"fieldname": "base_write_off_amount",
Expand Down Expand Up @@ -2016,7 +2017,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2021-08-17 20:16:12.737743",
"modified": "2021-08-18 16:07:45.122570",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
22 changes: 20 additions & 2 deletions erpnext/accounts/workspace/accounting/accounting.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
{
"hidden": 0,
"is_query_report": 0,
"label": "Bank Statement",
"label": "Banking and Payments",
"onboard": 0,
"type": "Card Break"
},
Expand Down Expand Up @@ -642,6 +642,24 @@
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Payment Entry",
"link_to": "Payment Entry",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Payment Reconciliation",
"link_to": "Payment Reconciliation",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
Expand Down Expand Up @@ -1064,7 +1082,7 @@
"type": "Link"
}
],
"modified": "2021-06-10 03:17:31.427945",
"modified": "2021-08-23 16:06:34.167267",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounting",
Expand Down
13 changes: 13 additions & 0 deletions erpnext/buying/doctype/supplier/supplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,23 @@ frappe.ui.form.on("Supplier", {
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
}, __('Create'));

frm.add_custom_button(__('Get Supplier Group Details'), function () {
frm.trigger("get_supplier_group_details");
}, __('Actions'));

// indicators
erpnext.utils.set_party_dashboard_indicators(frm);
}
},
get_supplier_group_details: function(frm) {
frappe.call({
method: "get_supplier_group_details",
doc: frm.doc,
callback: function() {
frm.refresh();
}
});
},

is_internal_supplier: function(frm) {
if (frm.doc.is_internal_supplier == 1) {
Expand Down
17 changes: 17 additions & 0 deletions erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ def validate(self):
validate_party_accounts(self)
self.validate_internal_supplier()

@frappe.whitelist()
def get_supplier_group_details(self):
doc = frappe.get_doc('Supplier Group', self.supplier_group)
self.payment_terms = ""
self.accounts = []

if doc.accounts:
for account in doc.accounts:
child = self.append('accounts')
child.company = account.company
child.account = account.account

if doc.payment_terms:
self.payment_terms = doc.payment_terms

self.save()

def validate_internal_supplier(self):
internal_supplier = frappe.db.get_value("Supplier",
{"is_internal_supplier": 1, "represents_company": self.represents_company, "name": ("!=", self.name)}, "name")
Expand Down
24 changes: 24 additions & 0 deletions erpnext/buying/doctype/supplier/test_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@


class TestSupplier(unittest.TestCase):
def test_get_supplier_group_details(self):
doc = frappe.new_doc("Supplier Group")
doc.supplier_group_name = "_Testing Supplier Group"
doc.payment_terms = "_Test Payment Term Template 3"
doc.accounts = []
test_account_details = {
"company": "_Test Company",
"account": "Creditors - _TC",
}
doc.append("accounts", test_account_details)
doc.save()
s_doc = frappe.new_doc("Supplier")
s_doc.supplier_name = "Testing Supplier"
s_doc.supplier_group = "_Testing Supplier Group"
s_doc.payment_terms = ""
s_doc.accounts = []
s_doc.insert()
s_doc.get_supplier_group_details()
self.assertEqual(s_doc.payment_terms, "_Test Payment Term Template 3")
self.assertEqual(s_doc.accounts[0].company, "_Test Company")
self.assertEqual(s_doc.accounts[0].account, "Creditors - _TC")
s_doc.delete()
doc.delete()

def test_supplier_default_payment_terms(self):
# Payment Term based on Days after invoice date
frappe.db.set_value(
Expand Down
5 changes: 5 additions & 0 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,11 @@ def validate_quantity(child_item, d):

for d in data:
new_child_flag = False

if not d.get("item_code"):
# ignore empty rows
continue

if not d.get("docname"):
new_child_flag = True
check_doc_permissions(parent, 'create')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 13:22:47.008622",
"modified": "2020-07-22 13:36:48.114479",
"last_synced_on": "2021-01-30 21:03:30.086891",
"modified": "2021-02-01 13:36:04.469863",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Clinical Procedures",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Percentage",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 13:22:46.691764",
"modified": "2020-07-22 13:40:17.215775",
"last_synced_on": "2021-02-01 13:36:38.787783",
"modified": "2021-02-01 13:37:18.718275",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Clinical Procedures Status",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Pie",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}
7 changes: 4 additions & 3 deletions erpnext/healthcare/dashboard_chart/diagnoses/diagnoses.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Patient Encounter Diagnosis",
"dynamic_filters_json": "",
"filters_json": "[]",
"group_by_based_on": "diagnosis",
"group_by_type": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 13:22:47.895521",
"modified": "2020-07-22 13:43:32.369481",
"last_synced_on": "2021-01-30 21:03:33.729487",
"modified": "2021-02-01 13:34:57.385335",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Diagnoses",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Percentage",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}
6 changes: 3 additions & 3 deletions erpnext/healthcare/dashboard_chart/lab_tests/lab_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 13:22:47.344055",
"modified": "2020-07-22 13:37:34.490129",
"last_synced_on": "2021-01-30 21:03:28.272914",
"modified": "2021-02-01 13:36:08.391433",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Tests",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Percentage",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}
6 changes: 3 additions & 3 deletions erpnext/healthcare/dashboard_chart/symptoms/symptoms.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 13:22:47.296748",
"modified": "2020-07-22 13:40:59.655129",
"last_synced_on": "2021-01-30 21:03:32.067473",
"modified": "2021-02-01 13:35:30.953718",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Symptoms",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Percentage",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}
8 changes: 4 additions & 4 deletions erpnext/healthcare/doctype/lab_test/lab_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def after_insert(self):
frappe.db.set_value('Lab Prescription', self.prescription, 'lab_test_created', 1)
if frappe.db.get_value('Lab Prescription', self.prescription, 'invoiced'):
self.invoiced = True
if not self.lab_test_name and self.template:
if self.template:
self.load_test_from_template()
self.reload()

Expand All @@ -50,7 +50,7 @@ def set_secondary_uom_result(self):
item.secondary_uom_result = float(item.result_value) * float(item.conversion_factor)
except:
item.secondary_uom_result = ''
frappe.msgprint(_('Row #{0}: Result for Secondary UOM not calculated'.format(item.idx)), title = _('Warning'))
frappe.msgprint(_('Row #{0}: Result for Secondary UOM not calculated').format(item.idx), title = _('Warning'))

def validate_result_values(self):
if self.normal_test_items:
Expand Down Expand Up @@ -229,9 +229,9 @@ def create_sample_doc(template, patient, invoice, company = None):
sample_collection = frappe.get_doc('Sample Collection', sample_exists[0][0])
quantity = int(sample_collection.sample_qty) + int(template.sample_qty)
if template.sample_details:
sample_details = sample_collection.sample_details + '\n-\n' + _('Test: ')
sample_details = sample_collection.sample_details + '\n-\n' + _('Test :')
sample_details += (template.get('lab_test_name') or template.get('template')) + '\n'
sample_details += _('Collection Details: ') + '\n\t' + template.sample_details
sample_details += _('Collection Details:') + '\n\t' + template.sample_details
frappe.db.set_value('Sample Collection', sample_collection.name, 'sample_details', sample_details)

frappe.db.set_value('Sample Collection', sample_collection.name, 'sample_qty', quantity)
Expand Down
Loading

0 comments on commit 3910092

Please sign in to comment.