Invoice question

In the "Invoice" example, how can I have the "name" in the form menu and display the name of the product that represents a value that does the multiplication or addition

Thank you for your order of: {formtext: name=quantity; default=25} teapots.

The price of each teapot is: ${formmenu: name=price; 12.00; default=24.00; 48.00}

The pre-tax total is: {=price*quantity; format=$,.2f}

Hi @Nikolas_Torres_Niko ,
Welcome to Text Blaze community.

Is this what you are trying to achieve?

{note}{products=[
["name": "teapots", "price": 12],
["name": "saucers", "price": 24],
["name": "spoons", "price": 48]
]}{endnote}Thank you for your order of: {formtext: name=quantity; default=25} {=product.name}.
The price of each item is: ${formmenu: name=product; values={=products}; itemformatter=(p) -> p.price & " (" & p.name & ")"}
The pre-tax total is: {=product.price*quantity; format=$,.2f}

To add,

I have used Text Blaze named list to define the products.

And used itemformatter to change the text I want.

As I have some parts in the snippet which I don't want to include in the snippet output, I wrapped it with {note}

thaks you so much for your answer, i was thinking to have a breakdown (desglose?) of some servicies or products that i can pre check as a shopping cart and have a total adding tax for example.

Estimación Valores Totales

{formtoggle: default=yes; name=Salón}Salón Ciprés {=280000; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=no; name=Coffee D}Coffee D {=12900cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=yes; name=Coffee B}Coffee B {=8900
cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=no; name=Coffee A1}Coffee A {=5900cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=yes; name=Almuerzo}Almuerzo {=5900
cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=yes; name=Coffee A2}Coffee A {=5900cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=no; name=Cena}Cena {=54000
cantidad; format=$,.0f} + IVA{endformtoggle}
{formtoggle: default=no; name=Cóctel}Cóctel {=52900*cantidad; format=$,.0f} + IVA{endformtoggle}

El total de la propuesta de consumo es de {=salón+coffee d+coffee b+coffee a1+almuerzo+coffee a2+cena+cóctel*cantidad; format=$,.2f}+ IVA (not right) para {formtext: name=Cantidad; default=12; cols=5}

im going to work in the solution that you proposted maybe using the repeat opcion for all variables and summing in the bottom.

Hi @Nikolas_Torres_Niko
Perhaps the below snippet works for you?

{note: preview=no}
{products=[
["name":"Salón Ciprés", "price":12900, "selected":yes],
["name":"Coffee D", "price":12900],
["name":"Coffee B", "price":8900],
["name":"Coffee A", "price":5900],
["name":"Almuerzo", "price":5900, "selected":yes],
["name":"Coffee A", "price":5900, "selected":yes],
["name":"Cena", "price":54000],
["name":"Cóctel", "price":52900]
]}
{if: count(selectedProducts) == 0}{selectedProducts=filter(products, (p) -> includes(keys(p), "selected"))}{endif}
{endnote}{note}{formmenu: name=selectedProducts; values={=products}; itemformatter=(p) -> p.name & " (" & p.price & ")"; multiple=yes}
{endnote}{repeat: for product in selectedProducts}
{=product.name} {=product.price*cantidad; format=$,.0f} + IVA{endrepeat}

El total de la propuesta de consumo es de {=sum(map(selectedProducts, (p)->p.price))*cantidad; format=$,.2f}+ IVA (not right) para {formtext: name=Cantidad; default=12; cols=5}

I used same type of list, used multiple formmenu. Also used few list functions like filter, map and sum.

You can use Spaces for the data and the logic can be much simpler. Please check out all the exciting discussion here.

1 Like

it looks great! thanks you very much! im going to work on it!