Translated form 940 logic from Publican to luca