Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"column_break_jkfg",
"rent_expense_item",
"batta_ot_expense_item",
"advance_account"
"advance_account",
"batta_expense_cost_head"
],
"fields": [
{
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ending_date_and_time",
"check_in_time",
"total_hours",
"last_trip",
"section_break_tjbr",
"purpose",
"fuel_details_section",
Expand Down Expand Up @@ -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",
Expand Down
32 changes: 31 additions & 1 deletion beams/beams/doctype/bureau_trip_sheet/bureau_trip_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -105,14 +119,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):
Expand All @@ -126,6 +151,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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -336,25 +337,29 @@ 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:
accounts.append({
"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:
Expand All @@ -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:
Expand Down
Loading