Skip to content

Commit

Permalink
feat: copy serial number from service request
Browse files Browse the repository at this point in the history
  • Loading branch information
muruthigitau committed Nov 29, 2024
1 parent 7b6972a commit cf5f40a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion utility_billing/utility_billing/overrides/server/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def set_missing_values(source, target):


def update_item(source, target, source_parent):
"""Update the item details for the invoice."""
"""Update the item details for the invoice and copy serial number as meter number if applicable."""
target.amount = flt(source.amount) - flt(source.billed_amt)
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = (
Expand All @@ -234,6 +234,21 @@ def update_item(source, target, source_parent):

set_cost_center(source_parent, target)

sales_order = frappe.get_doc("Sales Order", source_parent.name)

if sales_order.utility_service_request:
utility_service_request = frappe.get_doc(
"Utility Service Request", sales_order.utility_service_request
)

for request_item in utility_service_request.items:
if request_item.item_code == target.item_code:
if request_item.meter_number:
target.serial_no = request_item.meter_number
break

return target


def set_cost_center(source_parent, target):
"""Set the cost center for the invoice item."""
Expand Down

0 comments on commit cf5f40a

Please sign in to comment.