Merge branch 'develop' into call-summary-dialog

This commit is contained in:
Suraj Shetty 2019-06-19 19:18:52 +05:30 committed by GitHub
commit b9f346fc88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 69 additions and 192 deletions

View File

@ -43,8 +43,13 @@ frappe.ui.form.on('Bank Guarantee', {
reference_docname: function(frm) {
if (frm.doc.reference_docname && frm.doc.reference_doctype) {
let fields_to_fetch = ["project", "grand_total"];
let fields_to_fetch = ["grand_total"];
let party_field = frm.doc.reference_doctype == "Sales Order" ? "customer" : "supplier";
if (frm.doc.reference_doctype == "Sales Order") {
fields_to_fetch.push("project");
}
fields_to_fetch.push(party_field);
frappe.call({
method: "erpnext.accounts.doctype.bank_guarantee.bank_guarantee.get_vouchar_detials",

View File

@ -390,8 +390,8 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
if filters:
if filters.get("project"):
if not isinstance(filters.get("project"), list):
projects = frappe.safe_encode(filters.get("project"))
filters.project = [d.strip() for d in projects.strip().split(',') if d]
filters.project = frappe.parse_json(filters.get("project"))
additional_conditions.append("project in %(project)s")
if filters.get("cost_center"):

View File

@ -72,46 +72,25 @@ frappe.query_reports["General Ledger"] = {
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "MultiSelect",
get_data: function() {
"fieldtype": "MultiSelectList",
get_data: function(txt) {
if (!frappe.query_report.filters) return;
var party_type = frappe.query_report.get_filter_value('party_type');
var parties = frappe.query_report.get_filter_value('party');
if(!party_type) return;
const values = parties.split(/\s*,\s*/).filter(d => d);
const txt = parties.match(/[^,\s*]*$/)[0] || '';
let data = [];
let party_type = frappe.query_report.get_filter_value('party_type');
if (!party_type) return;
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: frappe.query_report.get_filter_value('party_type'),
txt: txt,
filters: {
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
});
return data;
return frappe.db.get_link_options(party_type, txt);
},
on_change: function() {
var party_type = frappe.query_report.get_filter_value('party_type');
var parties = frappe.query_report.get_filter_value('party');
const values = parties.split(/\s*,\s*/).filter(d => d);
if(!party_type || !parties || values.length>1) {
if(!party_type || parties.length === 0 || parties.length > 1) {
frappe.query_report.set_filter_value('party_name', "");
frappe.query_report.set_filter_value('tax_id', "");
return;
} else {
var party = values[0];
var party = parties[0];
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
frappe.db.get_value(party_type, party, fieldname, function(value) {
frappe.query_report.set_filter_value('party_name', value[fieldname]);
@ -154,62 +133,17 @@ frappe.query_reports["General Ledger"] = {
{
"fieldname":"cost_center",
"label": __("Cost Center"),
"fieldtype": "MultiSelect",
get_data: function() {
var cost_centers = frappe.query_report.get_filter_value("cost_center") || "";
const values = cost_centers.split(/\s*,\s*/).filter(d => d);
const txt = cost_centers.match(/[^,\s*]*$/)[0] || '';
let data = [];
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: "Cost Center",
txt: txt,
filters: {
"company": frappe.query_report.get_filter_value("company"),
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
});
return data;
"fieldtype": "MultiSelectList",
get_data: function(txt) {
return frappe.db.get_link_options('Cost Center', txt);
}
},
{
"fieldname":"project",
"label": __("Project"),
"fieldtype": "MultiSelect",
get_data: function() {
var projects = frappe.query_report.get_filter_value("project") || "";
const values = projects.split(/\s*,\s*/).filter(d => d);
const txt = projects.match(/[^,\s*]*$/)[0] || '';
let data = [];
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: "Project",
txt: txt,
filters: {
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
});
return data;
"fieldtype": "MultiSelectList",
get_data: function(txt) {
return frappe.db.get_link_options('Project', txt);
}
},
{

View File

@ -26,8 +26,7 @@ def execute(filters=None):
account_details.setdefault(acc.name, acc)
if filters.get('party'):
parties = cstr(filters.get("party")).strip()
filters.party = [d.strip() for d in parties.split(',') if d]
filters.party = frappe.parse_json(filters.get("party"))
validate_filters(filters, account_details)
@ -61,12 +60,10 @@ def validate_filters(filters, account_details):
frappe.throw(_("From Date must be before To Date"))
if filters.get('project'):
projects = cstr(filters.get("project")).strip()
filters.project = [d.strip() for d in projects.split(',') if d]
filters.project = frappe.parse_json(filters.get('project'))
if filters.get('cost_center'):
cost_centers = cstr(filters.get("cost_center")).strip()
filters.cost_center = [d.strip() for d in cost_centers.split(',') if d]
filters.cost_center = frappe.parse_json(filters.get('cost_center'))
def validate_party(filters):

View File

@ -13,33 +13,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
{
"fieldname":"project",
"fieldname": "project",
"label": __("Project"),
"fieldtype": "MultiSelect",
get_data: function() {
var projects = frappe.query_report.get_filter_value("project") || "";
const values = projects.split(/\s*,\s*/).filter(d => d);
const txt = projects.match(/[^,\s*]*$/)[0] || '';
let data = [];
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: "Project",
txt: txt,
filters: {
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
});
return data;
"fieldtype": "MultiSelectList",
get_data: function(txt) {
return frappe.db.get_link_options('Project', txt);
}
},
{

View File

@ -8,33 +8,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
{
"fieldname":"project",
"fieldname": "project",
"label": __("Project"),
"fieldtype": "MultiSelect",
get_data: function() {
var projects = frappe.query_report.get_filter_value("project") || "";
const values = projects.split(/\s*,\s*/).filter(d => d);
const txt = projects.match(/[^,\s*]*$/)[0] || '';
let data = [];
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: "Project",
txt: txt,
filters: {
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
});
return data;
"fieldtype": "MultiSelectList",
get_data: function(txt) {
return frappe.db.get_link_options('Project', txt);
}
},
{

View File

@ -2,20 +2,8 @@
// For license information, please see license.txt
frappe.ui.form.on('Employee Benefit Application', {
setup: function(frm) {
if(!frm.doc.employee || !frm.doc.date) {
frappe.throw(__("Please select Employee and Date first"));
} else {
frm.set_query("earning_component", "employee_benefits", function() {
return {
query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
filters: {date: frm.doc.date, employee: frm.doc.employee}
};
});
}
},
employee: function(frm) {
frm.trigger('set_earning_component');
var method, args;
if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){
method = "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining";
@ -35,6 +23,21 @@ frappe.ui.form.on('Employee Benefit Application', {
get_max_benefits(frm, method, args);
}
},
date: function(frm) {
frm.trigger('set_earning_component');
},
set_earning_component: function(frm) {
if(!frm.doc.employee && !frm.doc.date) return;
frm.set_query("earning_component", "employee_benefits", function() {
return {
query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components",
filters: {date: frm.doc.date, employee: frm.doc.employee}
};
});
},
payroll_period: function(frm) {
var method, args;
if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){

View File

@ -144,7 +144,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;
}
item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
if (item.discount_amount) {
item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
}
this.calculate_taxes_and_totals();
},

View File

@ -118,34 +118,13 @@ function get_filters(){
"options": erpnext.get_presentation_currency_list()
},
{
"fieldname":"cost_center",
"fieldname": "cost_center",
"label": __("Cost Center"),
"fieldtype": "MultiSelect",
get_data: function() {
var cost_centers = frappe.query_report.get_filter_value("cost_center") || "";
const values = cost_centers.split(/\s*,\s*/).filter(d => d);
const txt = cost_centers.match(/[^,\s*]*$/)[0] || '';
let data = [];
frappe.call({
type: "GET",
method:'frappe.desk.search.search_link',
async: false,
no_spinner: true,
args: {
doctype: "Cost Center",
txt: txt,
filters: {
"company": frappe.query_report.get_filter_value("company"),
"name": ["not in", values]
}
},
callback: function(r) {
data = r.results;
}
"fieldtype": "MultiSelectList",
get_data: function(txt) {
return frappe.db.get_link_options('Cost Center', txt, {
company: frappe.query_report.get_filter_value("company")
});
return data;
}
}
]

View File

@ -20,8 +20,7 @@ class DeliveryTrip(Document):
# Google Maps returns distances in meters by default
self.default_distance_uom = frappe.db.get_single_value("Global Defaults", "default_distance_unit") or "Meter"
self.uom_conversion_factor = frappe.db.get_value("UOM Conversion Factor",
{"from_uom": "Meter", "to_uom": self.default_distance_uom},
"value")
{"from_uom": "Meter", "to_uom": self.default_distance_uom}, "value")
def validate(self):
self.validate_stop_addresses()
@ -139,7 +138,7 @@ class DeliveryTrip(Document):
# Include last leg in the final distance calculation
self.uom = self.default_distance_uom
total_distance = sum([leg.get("distance", {}).get("value", 0.0)
for leg in directions.get("legs")]) # in meters
for leg in directions.get("legs")]) # in meters
self.total_distance = total_distance * self.uom_conversion_factor
else:
idx += len(route) - 1
@ -358,8 +357,12 @@ def notify_customers(delivery_trip):
email_recipients = []
for stop in delivery_trip.delivery_stops:
contact_info = frappe.db.get_value("Contact", stop.contact,
["first_name", "last_name", "email_id", "gender"], as_dict=1)
contact_info = frappe.db.get_value("Contact", stop.contact, ["first_name", "last_name", "email_id"], as_dict=1)
context.update({"items": []})
if stop.delivery_note:
items = frappe.get_all("Delivery Note Item", filters={"parent": stop.delivery_note, "docstatus": 1}, fields=["*"])
context.update({"items": items})
if contact_info and contact_info.email_id:
context.update(stop.as_dict())
@ -369,9 +372,9 @@ def notify_customers(delivery_trip):
dispatch_template = frappe.get_doc("Email Template", dispatch_template_name)
frappe.sendmail(recipients=contact_info.email_id,
subject=dispatch_template.subject,
message=frappe.render_template(dispatch_template.response, context),
attachments=get_attachments(stop))
subject=dispatch_template.subject,
message=frappe.render_template(dispatch_template.response, context),
attachments=get_attachments(stop))
stop.db_set("email_sent_to", contact_info.email_id)
email_recipients.append(contact_info.email_id)
@ -388,9 +391,7 @@ def get_attachments(delivery_stop):
return []
dispatch_attachment = frappe.db.get_single_value("Delivery Settings", "dispatch_attachment")
attachments = frappe.attach_print("Delivery Note",
delivery_stop.delivery_note,
file_name="Delivery Note",
print_format=dispatch_attachment)
attachments = frappe.attach_print("Delivery Note", delivery_stop.delivery_note,
file_name="Delivery Note", print_format=dispatch_attachment)
return [attachments]