Hassan,
While assistance with SQL and custom fields/triggers is outside the scope of support, I can let you know that you cannot get what you are trying to do with the trigger being on the invoice table as it is written before the invoice items. Try using the ar table when the record inserted is for an invoice (i.e., TransType = 1).