Skip to content

Commit

Permalink
Merge pull request #7 from navariltd/dev1
Browse files Browse the repository at this point in the history
feat - Cater for different naming series for invoice number and credi…
  • Loading branch information
maniamartial authored Nov 11, 2024
2 parents 23e9d7e + df9e66d commit 5fcc2f3
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,23 @@ def make_tims_request(
# Update Sales Invoice record
qr_code = get_qr_code(invoice_info["QRCode"])

# frappe.db.set_value(
# "Sales Invoice",
# f"INV-{invoice}",
# {
# "custom_cu_invoice_number": invoice_info["ControlCode"],
# "custom_qr_code": qr_code,
# },
# update_modified=True,
# )
# invoice_info = payload.get("Invoice", {})
'''Change the prefix to CN- if the invoice is a credit note'''
invoice_prefix = "CN-" if invoice_info["InvoiceCategory"] == "Credit Note" else "INV-"
invoice_number = f"{invoice_prefix}{invoice}"

frappe.db.set_value(
"Sales Invoice",
f"INV-{invoice}",
invoice_number,
{
"custom_cu_invoice_number": invoice_info["ControlCode"],
"custom_qr_code": qr_code,
Expand Down Expand Up @@ -342,4 +356,3 @@ 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}"

0 comments on commit 5fcc2f3

Please sign in to comment.