/*ALIAS>prop_db*/

/*SQLStart>2550*/
UPDATE documents d SET d.da_if3=
(

    CASE WHEN ((SELECT sum(ri_price) from RentsInfo where ri_docid = d.doc_id)- (select sum(p_val) from Payment where p_id = d.doc_id  and p_num > 0) - (d.doc_initsum))<0.01
    THEN 1
    ELSE 0
    END

)
WHERE d.da_if3=0
/*SQLStop*/

/*SQLStart>2552*/
update system_strings set sys_str = '6.7.207.1' where sys_id = 1401;  /*BackOffice*/
/*SQLStop*/