fix: update billing hours when hours is changed

This commit is contained in:
Mihir Kandoi
2025-04-28 16:07:54 +05:30
parent 0763a8d42d
commit a9df1f5f6b
2 changed files with 10 additions and 6 deletions

View File

@@ -296,6 +296,7 @@ frappe.ui.form.on("Timesheet Detail", {
hours: function (frm, cdt, cdn) {
calculate_end_time(frm, cdt, cdn);
update_billing_hours(frm, cdt, cdn);
calculate_billing_costing_amount(frm, cdt, cdn);
calculate_time_and_amount(frm);
},

View File

@@ -108,12 +108,15 @@ class Timesheet(Document):
self.per_billed = (self.total_billed_hours * 100) / self.total_billable_hours
def update_billing_hours(self, args):
if args.is_billable and (
flt(args.billing_hours) == 0.0 or flt(args.billing_hours) != flt(args.hours)
):
args.billing_hours = args.hours
else:
args.billing_hours = 0
if args.is_billable:
if flt(args.billing_hours) == 0.0:
args.billing_hours = args.hours
elif flt(args.billing_hours) > flt(args.hours):
frappe.msgprint(
_("Warning - Row {0}: Billing Hours are more than Actual Hours").format(args.idx),
indicator="orange",
alert=True,
)
def set_status(self):
self.status = {"0": "Draft", "1": "Submitted", "2": "Cancelled"}[str(self.docstatus or 0)]