<script type="text/javascript">
	function netAmount(event,key_element) 
	{
		event.preventDefault();
        var interest = isDefaulter($('.interest_'+key_element).val());

        var amount = isDefaulter($('.amount_'+key_element).val());

        $('.amount_in_words_'+key_element).val(numberInWords(amount));

        if(interest > 0 && interest <= 100)
        {
        	var interest_amount = Math.round(isDefaulter((interest/100) * amount));
         	
        }
        else
        {
        	interest_amount = 0;
        }

        var net_amount = amount + interest_amount;
        
        
        $('.net_amount_'+key_element).val(net_amount);
        $('.net_amount_in_words_'+key_element).val(numberInWords(net_amount));
        var number_of_months = isDefaulter($('.number_'+key_element).val());
     
		if(number_of_months > 0)
		{
		  	var installment_amount = Math.round(isDefaulter(net_amount/number_of_months));



		        
		        $('.installment_amount_'+key_element).val(installment_amount);
		        $('.installment_amount_in_words_'+key_element).val(numberInWords(installment_amount));
		}
        



	}

    function getDeduction(event,deduction_id)
    {

        //DEFAULT EVENT REQUEST PREVENT
        event.preventDefault();

        var deduction_id = $(deduction_id).val();


        var route1 = '/getdeduction/'+deduction_id;



    $.get(route1,function(data)
                    {
                     
                           $('.title').val(data.title);
                           $('.deduction').val(data.id);
                           $('.deduction_amount').val(data.amount);

                           $('.deduction_amount_in_words').val(numberInWords(data.amount));
                         
                    });
    

    }
function showDeductionModal(form_id,modal_id,user_id,minute_id)
{

        $('#'+form_id)[0].reset();
    
        $('.user').val(user_id);
        $('.minute').val(minute_id);
 
       $('#'+modal_id).modal('show');



}

    function storeDeduction(event,obj)
    {
        event.preventDefault();

        var obj = $('#form_add_deduction');

        var form = document.querySelector('#form_add_deduction'); // Find the <form> element
        var formData = new FormData(form); // Wrap form contents

        var route = obj.attr('action'); 




        showLoader();

        $.ajax({
        url: route,
        type: obj.attr('method'),
        data:  formData,
        dataType: "json",
        contentType: false,
        cache: false,
        processData:false,
        success: function(result){
            if(result)
            {
    
               

                $('#md_add_deduction').modal('hide');

                  getDetailsByUser(event,result.minute_id,result.user_id);
        
                messageToaster('success','Deduction has been added.','Success');
                    
            }
            removeLoader();
        },
        error: function(data)
               {
                   ajax_show_error(data);
               }            
        });


    }

</script>