Skip to content

Commit

Permalink
Merge pull request #9 from navariltd/dev1
Browse files Browse the repository at this point in the history
feat - Validate the relevant invoice number
  • Loading branch information
maniamartial authored Dec 16, 2024
2 parents 44816ae + 4dcecaf commit c909b16
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def on_submit(doc: Document, method: str | None = None) -> None:
{"name": doc.return_against},
["custom_cu_invoice_number"],
)
validate_relevant_invoice_number(relevant_invoice_number)

item_details = [] # ItemDetails list

Expand Down Expand Up @@ -355,3 +356,10 @@ def format_time_for_invoice(time: str) -> str:
"""Format time to ensure leading zero for single-digit hours."""
hour, minute, second = time.split(":")
return f"{int(hour):02d}:{minute}:{second}"

def validate_relevant_invoice_number(relevant_invoice_number):
if len(relevant_invoice_number) != 19:
frappe.throw(
"The <b>Relevant Invoice Number</b> must be exactly 19 characters long and should be the CU number. Current length: {}.".format(len(relevant_invoice_number))
)

0 comments on commit c909b16

Please sign in to comment.