Merge branch 'version-11-hotfix' into v11-work-order-bugs
This commit is contained in:
@@ -13,6 +13,7 @@ class Loan(AccountsController):
|
||||
def validate(self):
|
||||
validate_repayment_method(self.repayment_method, self.loan_amount, self.monthly_repayment_amount, self.repayment_periods)
|
||||
self.set_missing_fields()
|
||||
self.validate_loan_application()
|
||||
self.make_repayment_schedule()
|
||||
self.set_repayment_period()
|
||||
self.calculate_totals()
|
||||
@@ -33,6 +34,13 @@ class Loan(AccountsController):
|
||||
if self.status == "Repaid/Closed":
|
||||
self.total_amount_paid = self.total_payment
|
||||
|
||||
def validate_loan_application(self):
|
||||
if self.loan_application:
|
||||
loan = frappe.db.get_value("Loan", {"loan_application": self.loan_application}, "name")
|
||||
|
||||
if loan and loan != self.name:
|
||||
frappe.throw(_("Loan {0} already created for Loan Application {1}").format(frappe.bold(loan),
|
||||
frappe.bold(self.loan_application)))
|
||||
|
||||
def make_jv_entry(self):
|
||||
self.check_permission('write')
|
||||
|
||||
@@ -23,20 +23,25 @@ frappe.ui.form.on('Loan Application', {
|
||||
},
|
||||
add_toolbar_buttons: function(frm) {
|
||||
if (frm.doc.status == "Approved") {
|
||||
frm.add_custom_button(__('Create Loan'), function() {
|
||||
frappe.call({
|
||||
method: "erpnext.hr.doctype.loan_application.loan_application.make_loan",
|
||||
args: {
|
||||
"source_name": frm.doc.name
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).addClass("btn-primary");
|
||||
// show create loan button if loan not created against loan aplication
|
||||
frappe.db.get_value("Loan", {"loan_application": frm.doc.name}, "name", (r) => {
|
||||
if (!r) {
|
||||
frm.add_custom_button(__('Create Loan'), function() {
|
||||
frappe.call({
|
||||
method: "erpnext.hr.doctype.loan_application.loan_application.make_loan",
|
||||
args: {
|
||||
"source_name": frm.doc.name
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).addClass("btn-primary");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -80,10 +80,14 @@ frappe.query_reports["Sales Analytics"] = {
|
||||
|
||||
var tree_type = frappe.query_report.filters[0].value;
|
||||
|
||||
if(tree_type == "Customer" || tree_type == "Item") {
|
||||
if(tree_type == "Customer") {
|
||||
row_values = data.slice(4,length-1).map(function (column) {
|
||||
return column.content;
|
||||
})
|
||||
} else if (tree_type == "Item") {
|
||||
row_values = data.slice(5,length-1).map(function (column) {
|
||||
return column.content;
|
||||
})
|
||||
}
|
||||
else {
|
||||
row_values = data.slice(3,length-1).map(function (column) {
|
||||
|
||||
@@ -114,7 +114,7 @@ class Analytics(object):
|
||||
if self.filters["value_quantity"] == 'Value':
|
||||
value_field = 'base_amount'
|
||||
else:
|
||||
value_field = 'qty'
|
||||
value_field = 'stock_qty'
|
||||
|
||||
self.entries = frappe.db.sql("""
|
||||
select i.item_code as entity, i.item_name as entity_name, i.stock_uom, i.{value_field} as value_field, s.{date_field}
|
||||
@@ -301,8 +301,10 @@ class Analytics(object):
|
||||
def get_chart_data(self):
|
||||
length = len(self.columns)
|
||||
|
||||
if self.filters.tree_type in ["Customer", "Supplier", "Item"]:
|
||||
labels = [d.get("label") for d in self.columns[2:length-1]]
|
||||
if self.filters.tree_type in ["Customer", "Supplier"]:
|
||||
labels = [d.get("label") for d in self.columns[2:length - 1]]
|
||||
elif self.filters.tree_type == "Item":
|
||||
labels = [d.get("label") for d in self.columns[3:length - 1]]
|
||||
else:
|
||||
labels = [d.get("label") for d in self.columns[1:length-1]]
|
||||
self.chart = {
|
||||
|
||||
Reference in New Issue
Block a user