From 675ecd736798bcd3410b50f489dda05a7a1df6af Mon Sep 17 00:00:00 2001 From: hridyalakshmi Date: Wed, 1 Apr 2026 09:27:49 +0530 Subject: [PATCH 1/3] feat: Cost Head Mapping in Journal Entry --- .../beams_accounts_settings.json | 11 +++++++++-- .../monthly_consolidated_trip_sheet.py | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/beams/beams/doctype/beams_accounts_settings/beams_accounts_settings.json b/beams/beams/doctype/beams_accounts_settings/beams_accounts_settings.json index 8c26946f..9a6f58b8 100644 --- a/beams/beams/doctype/beams_accounts_settings/beams_accounts_settings.json +++ b/beams/beams/doctype/beams_accounts_settings/beams_accounts_settings.json @@ -34,7 +34,8 @@ "column_break_jkfg", "rent_expense_item", "batta_ot_expense_item", - "advance_account" + "advance_account", + "batta_expense_cost_head" ], "fields": [ { @@ -203,12 +204,18 @@ "fieldtype": "Link", "label": "Advance Account", "options": "Account" + }, + { + "fieldname": "batta_expense_cost_head", + "fieldtype": "Link", + "label": "Batta Expense Cost Head", + "options": "Cost Head" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2026-03-17 14:51:14.096058", + "modified": "2026-03-31 19:44:46.985532", "modified_by": "Administrator", "module": "BEAMS", "name": "Beams Accounts Settings", diff --git a/beams/beams/doctype/monthly_consolidated_trip_sheet/monthly_consolidated_trip_sheet.py b/beams/beams/doctype/monthly_consolidated_trip_sheet/monthly_consolidated_trip_sheet.py index fb6da957..5d74f968 100644 --- a/beams/beams/doctype/monthly_consolidated_trip_sheet/monthly_consolidated_trip_sheet.py +++ b/beams/beams/doctype/monthly_consolidated_trip_sheet/monthly_consolidated_trip_sheet.py @@ -301,6 +301,7 @@ def create_journal_entry(monthly_consolidated_trip_sheet_name): fuel_expense_account = settings.get("fuel_expense_item") ot_account = settings.get("batta_ot_expense_item") fuel_card_account = settings.get("fuel_card_account") + batta_cost_head = settings.get("batta_expense_cost_head") supplier_payable_account = _get_supplier_payable_account(doc.supplier, company) if not supplier_payable_account: @@ -336,18 +337,21 @@ def create_journal_entry(monthly_consolidated_trip_sheet_name): "account": batta_account, "debit_in_account_currency": total_batta_je, "credit_in_account_currency": 0, + "cost_head": batta_cost_head }) if ot_account and total_ot_je: accounts.append({ "account": ot_account, "debit_in_account_currency": total_ot_je, "credit_in_account_currency": 0, + "cost_head": batta_cost_head }) if fuel_expense_account and total_fuel_expense: accounts.append({ "account": fuel_expense_account, "debit_in_account_currency": total_fuel_expense, "credit_in_account_currency": 0, + "cost_head": batta_cost_head }) # Credits — fuel card / fuel log only (advance is already reflected in batta_after / ot_after) if fuel_card_account and total_fuel_log: @@ -355,6 +359,7 @@ def create_journal_entry(monthly_consolidated_trip_sheet_name): "account": fuel_card_account, "debit_in_account_currency": 0, "credit_in_account_currency": total_fuel_log, + "cost_head": batta_cost_head }) # Supplier balancing: credit when company owes supplier, debit when recovering if supplier_payable_account and supplier_amount != 0: @@ -364,6 +369,7 @@ def create_journal_entry(monthly_consolidated_trip_sheet_name): "party": doc.supplier, "debit_in_account_currency": abs(supplier_amount) if supplier_amount < 0 else 0, "credit_in_account_currency": supplier_amount if supplier_amount > 0 else 0, + "cost_head": batta_cost_head }) if not accounts: From f7b0a9847ead8decacd717ff2a00c75e9e9470df Mon Sep 17 00:00:00 2001 From: NaseeraVP Date: Wed, 1 Apr 2026 10:54:25 +0530 Subject: [PATCH 2/3] feat: add Last Trip logic to prevent duplicate OT calculation --- .../bureau_trip_sheet/bureau_trip_sheet.json | 9 ++++++++- .../doctype/bureau_trip_sheet/bureau_trip_sheet.py | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.json b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.json index ff9a812e..fba8d0a1 100644 --- a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.json +++ b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.json @@ -23,6 +23,7 @@ "ending_date_and_time", "check_in_time", "total_hours", + "last_trip", "section_break_tjbr", "purpose", "fuel_details_section", @@ -341,12 +342,18 @@ "fieldname": "check_in_time", "fieldtype": "Datetime", "label": "Check In Time" + }, + { + "default": "0", + "fieldname": "last_trip", + "fieldtype": "Check", + "label": "Last Trip" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2026-03-26 15:50:44.470313", + "modified": "2026-04-01 10:46:15.616295", "modified_by": "Administrator", "module": "BEAMS", "name": "Bureau Trip Sheet", diff --git a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py index a0c4505f..d9c1be9c 100644 --- a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py +++ b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py @@ -105,14 +105,25 @@ def calculate_total_daily_batta(self): self.total_daily_batta = flt(self.batta) or 0 def calculate_total_ot_batta(self): - """Total OT batta = (total_hours - ot_working_hours) * ot_batta rate, when supplier and hours are set.""" + """ + Calculate OT batta ONLY when last_trip is checked + """ + + if not self.last_trip: + self.total_ot_batta = 0 + return + total_hours = flt(self.total_hours or 0) ot_rate = flt(self.ot_batta or 0) + if not self.supplier or not total_hours: self.total_ot_batta = 0 return + ot_working_hours = flt(get_ot_working_hours(self.supplier) or 0) + ot_hours = max(0, total_hours - ot_working_hours) + self.total_ot_batta = round(ot_hours * ot_rate, 2) def calculate_daily_batta(self): From d5ec1bf17dcb5c85b287538b82439b28434db83a Mon Sep 17 00:00:00 2001 From: NaseeraVP Date: Wed, 1 Apr 2026 12:42:54 +0530 Subject: [PATCH 3/3] fix:Fixed Editable Fields Overwritten by Auto Calculation in Bureau Trip Sheet --- .../bureau_trip_sheet/bureau_trip_sheet.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py index a0c4505f..4b82711f 100644 --- a/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py +++ b/beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py @@ -53,6 +53,20 @@ def calculate_batta(self): ''' Calculate total trip batta from daily rate × number of days (or food allowance total). ''' + policy = get_batta_policy_values(supplier=self.supplier) + + if policy.get("is_actual_with") or policy.get("is_actual_without") or policy.get("is_actual_food"): + + self.total_food_allowance = ( + flt(self.breakfast) + + flt(self.lunch) + + flt(self.dinner) + ) + + self.batta = self.total_food_allowance + + return + if self.total_food_allowance: self.batta = self.total_food_allowance else: @@ -126,6 +140,11 @@ def calculate_daily_batta(self): - Else → No Allowance When policy allows actual (editable) daily amounts, user-entered values are preserved on save. ''' + policy = get_batta_policy_values(supplier=self.supplier) + + if policy.get("is_actual_with") or policy.get("is_actual_without") or policy.get("is_actual_food"): + return + # Preserve manually entered daily rates before reset. manual_daily_batta_without_overnight = flt(self.get("daily_batta_without_overnight_stay")) manual_daily_batta_with_overnight = flt(self.get("daily_batta_with_overnight_stay"))