How to create a invoice without items duplicates.

Hi everyone i'm trying to format my invoice word doc to not show repeated items entries. Is it possible to do with a  if expression inside the document? Something like a Unique() expression.

Solved Solved
1 4 208
1 ACCEPTED SOLUTION

Don't iterate across the child records, iterate across a table of items.

Consider these 3 tables:

Order:

id
a

Order_Item

id order_id item_id qty
1 a ddd 5
2 a fff 7

Item

id name
aaa ...
ddd ...
ggg ...
fff ...

Then your template would be like this:

<<START: UNIQUE([related...][item_id])>> 
NAME: <<[item_id].[name]>> 
Total QTY: <<SUM(SELECT(order_item[qty] , AND( [order]=[_THISROW] , [item_id]=[_THISROW-1] ) ) )>>
<<END>>

View solution in original post

4 REPLIES 4

Need more info. Are you using a START expression?

Sorry for late response, I will try to clarify my full problem.
I'm trying to make a restaurant invoice app, I successfully make it and it can also output a pdf, but then I find out that if I make two inputs of the same item, it outputs, as well, two different lines for each item, I searched online and I find a solution which creates a unique value by concatenating the [ItemName] and [Invoice_No] and then summing the [qty] with rows that include this unique value to generate a value for the item and the same goes for the price, but it does not solve my initial problem that is: in the template I get two lines for the same item, like this. 

c4rvalho_0-1693935674058.png

What i want is that only one petit gateau shows, now my pdf looks like this

c4rvalho_1-1693935764530.png

it is stretched because it's for a invoice printer, transcribing it goes like that:

<<Start:[Related ComandaDets]>><<[Repeat Items Qty]>>

<<[Item_Name]>>

<<[Unity_Price]>>

<<[Repeat Items Price]>><<End>>

Don't iterate across the child records, iterate across a table of items.

Consider these 3 tables:

Order:

id
a

Order_Item

id order_id item_id qty
1 a ddd 5
2 a fff 7

Item

id name
aaa ...
ddd ...
ggg ...
fff ...

Then your template would be like this:

<<START: UNIQUE([related...][item_id])>> 
NAME: <<[item_id].[name]>> 
Total QTY: <<SUM(SELECT(order_item[qty] , AND( [order]=[_THISROW] , [item_id]=[_THISROW-1] ) ) )>>
<<END>>

Thanks Marc,

It was very clarifying, for some reason I thought that I was locked to the table that the automation was designed to work with, for that reason I was struggling with this. Thank you for your time.

Top Labels in this Space