Deductions & credits

Column d should be 132 (323-191).

Column e should be 132 (smaller of 323 or 191).

Line 24 should be 1,584 (132*12).

That should take care of your negative number problem.