Merge branch 'develop' into fix-timesheet-tests
This commit is contained in:
commit
b96956f35c
@ -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"):
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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):
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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){
|
||||
|
@ -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();
|
||||
},
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -29,7 +29,20 @@ frappe.query_reports["HSN-wise-summary of outward supplies"] = {
|
||||
"placeholder":"Company GSTIN",
|
||||
"options": [""],
|
||||
"width": "80"
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80"
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80"
|
||||
},
|
||||
|
||||
],
|
||||
onload: (report) => {
|
||||
fetch_gstins(report);
|
||||
|
@ -88,7 +88,9 @@ def get_conditions(filters):
|
||||
|
||||
for opts in (("company", " and company=%(company)s"),
|
||||
("gst_hsn_code", " and gst_hsn_code=%(gst_hsn_code)s"),
|
||||
("company_gstin", " and company_gstin=%(company_gstin)s")):
|
||||
("company_gstin", " and company_gstin=%(company_gstin)s"),
|
||||
("from_date", " and posting_date >= %(from_date)s"),
|
||||
("to_date", "and posting_date <= %(to_date)s")):
|
||||
if filters.get(opts[0]):
|
||||
conditions += opts[1]
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user