wrong in code when catch returned order in total daily invoiced sales

HI guys i want to make report to show total amount sales for specified customer included returned order so that i make grouping to one data item by posting date.i successfully do it

but i don’t know how i show affect of return order

can any one told me how i show effect of returned order in total group of quantity

as ex

posting date quantity amount

01/01/13 500 30000

02/01/13 300 20000

suppose i made return order in day 02/01/13 as quantity 20

it must be 280 but it not affect because grouping in sales invoice line.

i write this code in after get record of sales invoice line table as following

recSalesCrhdr.SETFILTER(recSalesCrhdr.“Applies-to Doc. Type”,’=%1’,recSalesCrhdr.“Applies-to Doc. Type”::Invoice);
recSalesCrhdr.SETRANGE(recSalesCrhdr.“Applies-to Doc. No.”,“SalesInvoiceHeader”.“No.”);
IF recSalesCrhdr.FINDFIRST THEN

CurrReport.SKIP

as Sales Cr.Memo Header is recSalesCrhdr and sales invoice header table represent by record SalesInvoiceHeader

Now what is the problem in code above that prevent it from catch returned order quantity

I write this code above but quantity not come 280 wy what is the proplem in code

thanks

OK guys thank you it solved

i replace sales invoice header table with sales invoice line table

thanks