Allow Record.duration to be null

It wasn't possible to create new records because duration field was set to be not null.
This commit fixes that bug.
Prj_duration counts as function

Подсчёт длительность проекта вынесен в отдельную функию.
Merge remote-tracking branch 'origin/master' into features_func