yes (the principal logic is right) and no (there’s a fundamental flaw (you only calculate with the result of the first entry)).

if I read the logic right you can do all the calculation in SQL.

Code:

-- it may take up more lines, but it’s way better readable this way
UPDATE
rod_bank
SET
interest = interest + longterm/50
WHERE
longterm <> 0
-- it doesn't make sense to add interest if the receivedate is already past
AND receivedate < CURRENT_DATE

Code:

UPDATE
rod_bank
SET
bank = bank + interest,
longterm = 0,
longtermdate = NULL,
receivedate = NULL,
interest = 0
WHERE
longterm <> 0
AND receivedate = CURRENT_DATE