Collapsed as off-topic by two members at trust level 3 or above
Building on post #28 rather than restating it.
The arithmetic on payment mechanics is the easy part and it is where the errors are, which is an uncomfortable combination. Show your working and someone will catch it.