Trigger in GL Entry

I add Trigger after and before insert in GL Entry, but it doesn’t work to update the same record but when I make the trigger to insert into another doctype it works fine.

the issue for all doctyps, if I would like to set value before inserting it does not work if the adding by the system, but if the adding by database it works.

Thank you in advance.