Skip to content

Commit

Permalink
feat: add total_billing_hours to Sales Invoice (fp frappe#26783) (f…
Browse files Browse the repository at this point in the history
…rappe#27742)

* feat: add `total_billing_hours` to Sales Invoice

* fix: re-save doctypes

* fix: indentation

* fix: replace reference to old function

(cherry picked from commit 09ccdee)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/sales_invoice.js
#	erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
#	erpnext/projects/doctype/timesheet/timesheet.py
  • Loading branch information
sagarvora authored and frappe-bot committed Oct 4, 2021
1 parent 21a5498 commit 77e4408
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
21 changes: 21 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,24 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},

currency() {
<<<<<<< HEAD
this._super();
$.each(cur_frm.doc.timesheets, function(i, d) {
let row = frappe.get_doc(d.doctype, d.name)
set_timesheet_detail_rate(row.doctype, row.name, cur_frm.doc.currency, row.timesheet_detail)
});
calculate_total_billing_amount(cur_frm)
=======
var me = this;
super.currency();
if (this.frm.doc.timesheets) {
this.frm.doc.timesheets.forEach((d) => {
let row = frappe.get_doc(d.doctype, d.name)
set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail)
});
frm.trigger("calculate_timesheet_totals");
}
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
}
});

Expand Down Expand Up @@ -996,6 +1008,7 @@ frappe.ui.form.on('Sales Invoice', {
});
}
});
<<<<<<< HEAD


frappe.ui.form.on("Sales Invoice Timesheet", {
Expand All @@ -1004,6 +1017,14 @@ frappe.ui.form.on("Sales Invoice Timesheet", {
}
});

=======

frappe.ui.form.on("Sales Invoice Timesheet", {
timesheets_remove(frm) {
frm.trigger("calculate_timesheet_totals");
}
});
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))

var set_timesheet_detail_rate = function(cdt, cdn, currency, timelog) {
frappe.call({
Expand Down
9 changes: 8 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,13 @@
"label": "Dispatch Address",
"read_only": 1
},
{
"fieldname": "total_billing_hours",
"fieldtype": "Float",
"label": "Total Billing Hours",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "total_billing_hours",
"fieldtype": "Float",
Expand All @@ -2033,7 +2040,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2021-09-28 13:09:34.391799",
"modified": "2021-10-02 03:36:10.251715",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
"column_break_9",
"billing_amount",
"section_break_11",
<<<<<<< HEAD
"timesheet_detail",
"column_break_5",
"time_sheet",
=======
"time_sheet",
"timesheet_detail",
"column_break_13",
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
"project_name"
],
"fields": [
Expand Down Expand Up @@ -91,7 +97,10 @@
"fieldtype": "Column Break"
},
{
<<<<<<< HEAD

=======
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"label": "Totals"
Expand All @@ -110,11 +119,19 @@
"fieldtype": "Data",
"label": "Project Name",
"read_only": 1
},
{
"fieldname": "column_break_13",
"fieldtype": "Column Break"
}
],
"istable": 1,
"links": [],
<<<<<<< HEAD
"modified": "2021-08-15 18:37:08.084930",
=======
"modified": "2021-10-02 03:48:44.979777",
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Timesheet",
Expand Down
14 changes: 14 additions & 0 deletions erpnext/projects/doctype/timesheet/timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to

query = f"""
SELECT
<<<<<<< HEAD
=======
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
tsd.name as name,
tsd.parent as time_sheet,
tsd.from_time as from_time,
Expand All @@ -235,6 +238,7 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to
tsd.activity_type as activity_type,
tsd.description as description,
ts.currency as currency,
<<<<<<< HEAD
tsd.project_name as project_name
FROM `tabTimesheet Detail` tsd
Expand All @@ -244,12 +248,22 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to
WHERE
=======
tsd.project_name as project_name
FROM `tabTimesheet Detail` tsd
INNER JOIN `tabTimesheet` ts
ON ts.name = tsd.parent
WHERE
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
tsd.parenttype = 'Timesheet'
AND tsd.docstatus = 1
AND tsd.is_billable = 1
AND tsd.sales_invoice is NULL
{condition}
<<<<<<< HEAD
=======
>>>>>>> 09ccdee2db ( feat: add `total_billing_hours` to Sales Invoice (fp #26783) (#27742))
ORDER BY tsd.from_time ASC
"""

Expand Down

0 comments on commit 77e4408

Please sign in to comment.