From 5c767e798290bdbd6e98f6ceba298c474592fcc2 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Sat, 2 Dec 2023 12:53:39 +0200 Subject: [PATCH] Small update on invoices --- automation/send-invoice.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/automation/send-invoice.php b/automation/send-invoice.php index 8f0d329..7e7c93f 100644 --- a/automation/send-invoice.php +++ b/automation/send-invoice.php @@ -65,8 +65,14 @@ try { $insertStmt->execute(); $invoiceNumber = $pdo->lastInsertId(); - $currentDateFormatted = date("Ymd"); // This will format the date as 'YYYYMMDD' + $currentDateFormatted = date("Ymd"); $invoiceIdFormatted = "I" . $invoiceNumber . "-" . $currentDateFormatted; + + $updateQuery = "UPDATE invoices SET invoice_number = :invoiceIdFormatted WHERE id = :invoiceNumber"; + $stmt = $pdo->prepare($updateQuery); + $stmt->bindParam(':invoiceIdFormatted', $invoiceIdFormatted, PDO::PARAM_STR); + $stmt->bindParam(':invoiceNumber', $invoiceNumber, PDO::PARAM_INT); + $stmt->execute(); $issueDate = date("Y-m-d"); $dueDate = date("Y-m-d", strtotime("+30 days"));