Run sql query as the result of complementary attribute

here attached the test of complete project result attached
in note section all data comes from llx_societe_extrafields and there is one hidden extra field - the manual one which i have to edit to make db updated

there are negative values how to no calculate negative?
IN2411-0001-5.pdf (8.7 KB)

Hello
i almost finished you may have advice for how to update unit price in invoice line with the total price calculated from extra fields