add discount related functions
add code to calculate field because disabled input fields were not included in the POST
refactor code