How to display only the invoice number counter and the current year in the custom fields company?
For example, my invoice number is Rxx-1-1-2023, and I want to display only xx-2023 there. If I use the code $invoice_number, it will display the entire number, which I don’t want. Also, I don’t want to change the invoice format; I just need to display it in this shortened format in one place.
If I use the code:
HR00 {$counter}-{$year}
it doesn’t display anything, it just shows for example HR00 {}-{}
I corresponded a bit with chat gpt and he says this
To achieve the desired result within the JSON structure, you can use a simple template placeholder and then replace it with the formatted invoice number in your code. Here’s the modified code:
Then, in your code, you can replace $formatted_invoice_number with the actual formatted invoice number using the appropriate programming language. For example, in JavaScript:
// Given input
const inputText = "Reference number: HR00 R43-1-1-2023";
// Extracting the invoice number
const invoiceNumber = inputText.split(' ')[2]; // Assuming the invoice number is the third word after splitting by spaces
// Formatting the invoice number
const formattedInvoiceNumber = invoiceNumber.slice(1, 3) + "-" + invoiceNumber.slice(8);
// Replace the placeholder with the formatted invoice number
const modifiedText = yourJsonCode.stack[0].text.replace("$formatted_invoice_number", formattedInvoiceNumber);
console.log(modifiedText); // Output: "Reference number: HR00 43-2023"
By following this approach, you can dynamically replace the placeholder with the formatted invoice number within your existing JSON structure.
now I’m interested in which file I can add this second code and in that way create a new $short_code