Merge branch 'develop' into call-summary-dialog
This commit is contained in:
commit
b9f346fc88
@ -43,8 +43,13 @@ frappe.ui.form.on('Bank Guarantee', {
|
|||||||
|
|
||||||
reference_docname: function(frm) {
|
reference_docname: function(frm) {
|
||||||
if (frm.doc.reference_docname && frm.doc.reference_doctype) {
|
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";
|
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);
|
fields_to_fetch.push(party_field);
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.bank_guarantee.bank_guarantee.get_vouchar_detials",
|
method: "erpnext.accounts.doctype.bank_guarantee.bank_guarantee.get_vouchar_detials",
|
||||||
|
|||||||
@ -390,8 +390,8 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
|||||||
if filters:
|
if filters:
|
||||||
if filters.get("project"):
|
if filters.get("project"):
|
||||||
if not isinstance(filters.get("project"), list):
|
if not isinstance(filters.get("project"), list):
|
||||||
projects = frappe.safe_encode(filters.get("project"))
|
filters.project = frappe.parse_json(filters.get("project"))
|
||||||
filters.project = [d.strip() for d in projects.strip().split(',') if d]
|
|
||||||
additional_conditions.append("project in %(project)s")
|
additional_conditions.append("project in %(project)s")
|
||||||
|
|
||||||
if filters.get("cost_center"):
|
if filters.get("cost_center"):
|
||||||
|
|||||||
@ -72,46 +72,25 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"party",
|
"fieldname":"party",
|
||||||
"label": __("Party"),
|
"label": __("Party"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
if (!frappe.query_report.filters) return;
|
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);
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
const txt = parties.match(/[^,\s*]*$/)[0] || '';
|
if (!party_type) return;
|
||||||
let data = [];
|
|
||||||
|
|
||||||
frappe.call({
|
return frappe.db.get_link_options(party_type, txt);
|
||||||
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;
|
|
||||||
},
|
},
|
||||||
on_change: function() {
|
on_change: function() {
|
||||||
var party_type = frappe.query_report.get_filter_value('party_type');
|
var party_type = frappe.query_report.get_filter_value('party_type');
|
||||||
var parties = frappe.query_report.get_filter_value('party');
|
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('party_name', "");
|
||||||
frappe.query_report.set_filter_value('tax_id', "");
|
frappe.query_report.set_filter_value('tax_id', "");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
var party = values[0];
|
var party = parties[0];
|
||||||
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
|
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
|
||||||
frappe.db.get_value(party_type, party, fieldname, function(value) {
|
frappe.db.get_value(party_type, party, fieldname, function(value) {
|
||||||
frappe.query_report.set_filter_value('party_name', value[fieldname]);
|
frappe.query_report.set_filter_value('party_name', value[fieldname]);
|
||||||
@ -154,62 +133,17 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
{
|
{
|
||||||
"fieldname":"cost_center",
|
"fieldname":"cost_center",
|
||||||
"label": __("Cost Center"),
|
"label": __("Cost Center"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
var cost_centers = frappe.query_report.get_filter_value("cost_center") || "";
|
return frappe.db.get_link_options('Cost Center', txt);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"project",
|
"fieldname":"project",
|
||||||
"label": __("Project"),
|
"label": __("Project"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
var projects = frappe.query_report.get_filter_value("project") || "";
|
return frappe.db.get_link_options('Project', txt);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,8 +26,7 @@ def execute(filters=None):
|
|||||||
account_details.setdefault(acc.name, acc)
|
account_details.setdefault(acc.name, acc)
|
||||||
|
|
||||||
if filters.get('party'):
|
if filters.get('party'):
|
||||||
parties = cstr(filters.get("party")).strip()
|
filters.party = frappe.parse_json(filters.get("party"))
|
||||||
filters.party = [d.strip() for d in parties.split(',') if d]
|
|
||||||
|
|
||||||
validate_filters(filters, account_details)
|
validate_filters(filters, account_details)
|
||||||
|
|
||||||
@ -61,12 +60,10 @@ def validate_filters(filters, account_details):
|
|||||||
frappe.throw(_("From Date must be before To Date"))
|
frappe.throw(_("From Date must be before To Date"))
|
||||||
|
|
||||||
if filters.get('project'):
|
if filters.get('project'):
|
||||||
projects = cstr(filters.get("project")).strip()
|
filters.project = frappe.parse_json(filters.get('project'))
|
||||||
filters.project = [d.strip() for d in projects.split(',') if d]
|
|
||||||
|
|
||||||
if filters.get('cost_center'):
|
if filters.get('cost_center'):
|
||||||
cost_centers = cstr(filters.get("cost_center")).strip()
|
filters.cost_center = frappe.parse_json(filters.get('cost_center'))
|
||||||
filters.cost_center = [d.strip() for d in cost_centers.split(',') if d]
|
|
||||||
|
|
||||||
|
|
||||||
def validate_party(filters):
|
def validate_party(filters):
|
||||||
|
|||||||
@ -13,33 +13,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
|
|
||||||
frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
|
frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
|
||||||
{
|
{
|
||||||
"fieldname":"project",
|
"fieldname": "project",
|
||||||
"label": __("Project"),
|
"label": __("Project"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
var projects = frappe.query_report.get_filter_value("project") || "";
|
return frappe.db.get_link_options('Project', txt);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,33 +8,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
|
|
||||||
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
||||||
{
|
{
|
||||||
"fieldname":"project",
|
"fieldname": "project",
|
||||||
"label": __("Project"),
|
"label": __("Project"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
var projects = frappe.query_report.get_filter_value("project") || "";
|
return frappe.db.get_link_options('Project', txt);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,20 +2,8 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Employee Benefit Application', {
|
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) {
|
employee: function(frm) {
|
||||||
|
frm.trigger('set_earning_component');
|
||||||
var method, args;
|
var method, args;
|
||||||
if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){
|
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";
|
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);
|
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) {
|
payroll_period: function(frm) {
|
||||||
var method, args;
|
var method, args;
|
||||||
if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){
|
if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){
|
||||||
|
|||||||
@ -144,7 +144,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;
|
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();
|
this.calculate_taxes_and_totals();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -118,34 +118,13 @@ function get_filters(){
|
|||||||
"options": erpnext.get_presentation_currency_list()
|
"options": erpnext.get_presentation_currency_list()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"cost_center",
|
"fieldname": "cost_center",
|
||||||
"label": __("Cost Center"),
|
"label": __("Cost Center"),
|
||||||
"fieldtype": "MultiSelect",
|
"fieldtype": "MultiSelectList",
|
||||||
get_data: function() {
|
get_data: function(txt) {
|
||||||
var cost_centers = frappe.query_report.get_filter_value("cost_center") || "";
|
return frappe.db.get_link_options('Cost Center', txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company")
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -20,8 +20,7 @@ class DeliveryTrip(Document):
|
|||||||
# Google Maps returns distances in meters by default
|
# 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.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",
|
self.uom_conversion_factor = frappe.db.get_value("UOM Conversion Factor",
|
||||||
{"from_uom": "Meter", "to_uom": self.default_distance_uom},
|
{"from_uom": "Meter", "to_uom": self.default_distance_uom}, "value")
|
||||||
"value")
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_stop_addresses()
|
self.validate_stop_addresses()
|
||||||
@ -139,7 +138,7 @@ class DeliveryTrip(Document):
|
|||||||
# Include last leg in the final distance calculation
|
# Include last leg in the final distance calculation
|
||||||
self.uom = self.default_distance_uom
|
self.uom = self.default_distance_uom
|
||||||
total_distance = sum([leg.get("distance", {}).get("value", 0.0)
|
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
|
self.total_distance = total_distance * self.uom_conversion_factor
|
||||||
else:
|
else:
|
||||||
idx += len(route) - 1
|
idx += len(route) - 1
|
||||||
@ -358,8 +357,12 @@ def notify_customers(delivery_trip):
|
|||||||
email_recipients = []
|
email_recipients = []
|
||||||
|
|
||||||
for stop in delivery_trip.delivery_stops:
|
for stop in delivery_trip.delivery_stops:
|
||||||
contact_info = frappe.db.get_value("Contact", stop.contact,
|
contact_info = frappe.db.get_value("Contact", stop.contact, ["first_name", "last_name", "email_id"], as_dict=1)
|
||||||
["first_name", "last_name", "email_id", "gender"], 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:
|
if contact_info and contact_info.email_id:
|
||||||
context.update(stop.as_dict())
|
context.update(stop.as_dict())
|
||||||
@ -369,9 +372,9 @@ def notify_customers(delivery_trip):
|
|||||||
dispatch_template = frappe.get_doc("Email Template", dispatch_template_name)
|
dispatch_template = frappe.get_doc("Email Template", dispatch_template_name)
|
||||||
|
|
||||||
frappe.sendmail(recipients=contact_info.email_id,
|
frappe.sendmail(recipients=contact_info.email_id,
|
||||||
subject=dispatch_template.subject,
|
subject=dispatch_template.subject,
|
||||||
message=frappe.render_template(dispatch_template.response, context),
|
message=frappe.render_template(dispatch_template.response, context),
|
||||||
attachments=get_attachments(stop))
|
attachments=get_attachments(stop))
|
||||||
|
|
||||||
stop.db_set("email_sent_to", contact_info.email_id)
|
stop.db_set("email_sent_to", contact_info.email_id)
|
||||||
email_recipients.append(contact_info.email_id)
|
email_recipients.append(contact_info.email_id)
|
||||||
@ -388,9 +391,7 @@ def get_attachments(delivery_stop):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
dispatch_attachment = frappe.db.get_single_value("Delivery Settings", "dispatch_attachment")
|
dispatch_attachment = frappe.db.get_single_value("Delivery Settings", "dispatch_attachment")
|
||||||
attachments = frappe.attach_print("Delivery Note",
|
attachments = frappe.attach_print("Delivery Note", delivery_stop.delivery_note,
|
||||||
delivery_stop.delivery_note,
|
file_name="Delivery Note", print_format=dispatch_attachment)
|
||||||
file_name="Delivery Note",
|
|
||||||
print_format=dispatch_attachment)
|
|
||||||
|
|
||||||
return [attachments]
|
return [attachments]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user