Ako neko ima da se razumije, malo sam zapeo…
Ukratko, ovaj kod prikazuje puni broj racuna koji je formata: RXX-1-1-2023
$invoice_number
U kodu to onda izgleda ovako:
{
"stack": [
{
"text": "Reference number: HR00 $invoice_number"
}
],
"alignment": "right",
"margin": [
-25,
0,
0,
0
]
}
Meni treba da prikazem skracenu verziju pr. XX-2023
Pokusao sam i na sluzbenom forumu ali nisam dobio nikakav odgovor:
Ispod su dva koda od GPT-a, a zelio bi sve staviti u jedan kod ako je to moguce?
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:
{
"stack": [
{
"text": "Reference number: HR00 $formatted_invoice_number"
}
],
"alignment": "right",
"margin": [
-25,
0,
0,
0
]
}
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.