mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 06:29:20 +00:00
feat: add total_billing_hours to Sales Invoice
This commit is contained in:
@@ -829,7 +829,7 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
'timesheet_detail': row.name
|
'timesheet_detail': row.name
|
||||||
});
|
});
|
||||||
frm.refresh_field('timesheets');
|
frm.refresh_field('timesheets');
|
||||||
calculate_total_billing_amount(frm);
|
frm.trigger("calculate_timesheet_totals");
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
@@ -937,50 +937,46 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
frm: frm
|
frm: frm
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
create_dunning: function(frm) {
|
create_dunning: function(frm) {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
|
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
|
||||||
frm: frm
|
frm: frm
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
})
|
|
||||||
|
|
||||||
frappe.ui.form.on('Sales Invoice Timesheet', {
|
calculate_timesheet_totals: function(frm) {
|
||||||
|
frm.set_value("total_billing_amount",
|
||||||
|
frm.doc.timesheets.reduce((a, b) => a + (b["billing_amount"] || 0.0), 0.0));
|
||||||
|
frm.set_value("total_billing_hours",
|
||||||
|
frm.doc.timesheets.reduce((a, b) => a + (b["billing_hours"] || 0.0), 0.0));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
frappe.ui.form.on("Sales Invoice Timesheet", {
|
||||||
time_sheet: function(frm, cdt, cdn){
|
time_sheet: function(frm, cdt, cdn){
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(d.time_sheet) {
|
if(d.time_sheet) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data",
|
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data",
|
||||||
args: {
|
args: {
|
||||||
'name': d.time_sheet,
|
"name": d.time_sheet,
|
||||||
'project': frm.doc.project || null
|
"project": frm.doc.project || null
|
||||||
},
|
},
|
||||||
callback: function(r, rt) {
|
callback: function(r) {
|
||||||
if(r.message){
|
if(r.message) {
|
||||||
let data = r.message;
|
frappe.model.set_value(cdt, cdn, "billing_hours", r.message.billing_hours);
|
||||||
frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours);
|
frappe.model.set_value(cdt, cdn, "billing_amount", r.message.billing_amount);
|
||||||
frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount);
|
frappe.model.set_value(cdt, cdn, "timesheet_detail", r.message.timesheet_detail);
|
||||||
frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail);
|
frm.trigger("calculate_timesheet_totals");
|
||||||
calculate_total_billing_amount(frm)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
var calculate_total_billing_amount = function(frm) {
|
|
||||||
var doc = frm.doc;
|
|
||||||
|
|
||||||
doc.total_billing_amount = 0.0
|
|
||||||
if(doc.timesheets) {
|
|
||||||
$.each(doc.timesheets, function(index, data){
|
|
||||||
doc.total_billing_amount += data.billing_amount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_field('total_billing_amount')
|
|
||||||
}
|
|
||||||
|
|
||||||
var select_loyalty_program = function(frm, loyalty_programs) {
|
var select_loyalty_program = function(frm, loyalty_programs) {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
"time_sheet_list",
|
"time_sheet_list",
|
||||||
"timesheets",
|
"timesheets",
|
||||||
"total_billing_amount",
|
"total_billing_amount",
|
||||||
|
"total_billing_hours",
|
||||||
"section_break_30",
|
"section_break_30",
|
||||||
"total_qty",
|
"total_qty",
|
||||||
"base_total",
|
"base_total",
|
||||||
@@ -1983,6 +1984,13 @@
|
|||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"label": "Dispatch Address",
|
"label": "Dispatch Address",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_billing_hours",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Total Billing Hours",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
@@ -1995,7 +2003,7 @@
|
|||||||
"link_fieldname": "consolidated_invoice"
|
"link_fieldname": "consolidated_invoice"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-07-08 14:03:55.502522",
|
"modified": "2021-08-02 18:36:51.978581",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
|||||||
@@ -764,12 +764,11 @@ class SalesInvoice(SellingController):
|
|||||||
self.calculate_billing_amount_for_timesheet()
|
self.calculate_billing_amount_for_timesheet()
|
||||||
|
|
||||||
def calculate_billing_amount_for_timesheet(self):
|
def calculate_billing_amount_for_timesheet(self):
|
||||||
total_billing_amount = 0.0
|
def timesheet_sum(field):
|
||||||
for data in self.timesheets:
|
return sum((ts.get(field) or 0.0) for ts in self.timesheets)
|
||||||
if data.billing_amount:
|
|
||||||
total_billing_amount += data.billing_amount
|
|
||||||
|
|
||||||
self.total_billing_amount = total_billing_amount
|
self.total_billing_amount = timesheet_sum("billing_amount")
|
||||||
|
self.total_billing_hours = timesheet_sum("billing_hours")
|
||||||
|
|
||||||
def get_warehouse(self):
|
def get_warehouse(self):
|
||||||
user_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
|
user_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
|
||||||
|
|||||||
Reference in New Issue
Block a user