Hi,
Your query works fine.
I got another issue here. If I changed T0.VatSumSy to T0.TotalSumSy to capture the total to be charged on tax rate. The FMS query only reads the tax code in the first row. If the invoice got 2 different tax codes with different rate, it will only capture the first row tax rate.
E.g.
ItemCode | UnitPrice | Qty | Total | TaxCode | TaxRate | TaxAmt |
A001 | 10 | 100 | 1,000 | SR | 6 | 60 |
B002 | 20 | 200 | 4,000 | ZRE | 0 | 0 |
I got 2 UDFs with FMS query.
Tax6%
SELECT sum(T0.[VatSumSy]) FROM INV1 T0 inner join OINV t1 on t1.docentry = t0.docentry WHERE RTRIM($[$-38.18.0]) in ('SR','DS','AJS') and t1.docentry = $[OINV.docentry]
Tax0%
SELECT sum(T0.[VatSumSy]) FROM INV1 T0 inner join OINV t1 on t1.docentry = t0.docentry WHERE RTRIM($[$-38.18.0]) in ('ZRE','RS','GS') and t1.docentry = $[OINV.docentry]
UDF with Tax6% comes out 5000 while UDF with Tax0% also comes out 0.
Kindly guide me how to do on the totalSumSy.
Thanks & BR,
Leng