diff --git a/assets/js/CreatePOValidation.js b/assets/js/CreatePOValidation.js new file mode 100644 index 00000000..90ae1b3c --- /dev/null +++ b/assets/js/CreatePOValidation.js @@ -0,0 +1,176 @@ +/** +/** + * File : CreatePOValidation.js + * + * This file contain the validation of edit Create Po + * + * @author Gandhimathi + */ +$(document).ready(function(){ + + var CreatePOForm = $("#CreatePO"); + $( ".datePicker" ).datepicker({ dateFormat: 'yy/mm/dd' }); + + //Initialize Select2 Elements + $("#drpSupplier").select2(); + + +}); +function myFunction() { + + if(validate()) + { + var input = $('#POType').val(); + + $('#' + input).modal('show'); + } + +} +function validate() +{ + if($('#PODate').val() == '') + { + alert('Please Enter the Purchase Order date'); + $('#PODate').focus(); + return false; + } + else if($('#drpSupplier').val() == "0") + { + alert('Please Select the Supplier details'); + $('#drpSupplier').focus(); + return false; + } + else if($('#DeliveryAddr').val() == '') + { + alert('Please Enter the Delivery Address'); + $('#DeliveryAddr').focus(); + return false; + } + else if($('#Deliverydt').val() == '') + { + alert('Please Enter the Delivery Date'); + $('#Deliverydt').focus(); + return false; + } + else + { + return true; + } +} + + +function validateRevenueTax() + { + if($('#ReqNo').val() == "0") + { + alert('Please select the Requisition Number'); + $('#ReqNo').focus(); + return false; + } + else if($('#CostCenter').val() == "0") + { + alert('Please select the Cost center'); + $('#CostCenter').focus(); + return false; + } + else if($('#MaterialCode').val() == "0") + { + alert('Please select the Material Code'); + $('#MaterialCode').focus(); + return false; + } + else if($('#Quantity').val() == '') + { + alert('Please Enter the Quantity value'); + $('#Quantity').focus(); + return false; + } + else if($('#Rate').val() == '') + { + alert('Please Enter the Rate of the Item'); + $('#Rate').focus(); + return false; + } + else + { + return true; + } + } +function calculateTotalValue() + { + var Packaging = $('#txtAfterPackaging').val() == '' ? '0.00' : $('#txtAfterPackaging').val(); + var ExciseDuty = $('#txtAfterExciseDuty').val() == '' ? '0.00' : $('#txtAfterExciseDuty').val(); + var Vat = $('#txtAfterVat').val() == '' ? '0.00' : $('#txtAfterVat').val(); + var CST = $('#txtAfterCST').val() == '' ? '0.00' : $('#txtAfterCST').val(); + var GST = $('#txtAfterGST').val() == '' ? '0.00' : $('#txtAfterGST').val(); + var OtherTax = $('#txtAfterOtherTax').val() == '' ? '0.00' : $('#txtAfterOtherTax').val(); + var Freight = $('#txtAfterFreight').val() == '' ? '0.00' : $('#txtAfterFreight').val(); + var Insurance = $('#txtInsurance').val() == '' ? '0.00' : $('#txtInsurance').val(); + var Discount = $('#txtAfterDiscount').val() == '' ? '0.00' : $('#txtAfterDiscount').val(); + var BasicVal = $('#txtBasicValue').val() == '' ? '0.00' : $('#txtBasicValue').val(); + + var totvalue = ( parseFloat(BasicVal) + parseFloat(Packaging)+ parseFloat(ExciseDuty)+ parseFloat(Vat) + parseFloat(CST)+ parseFloat(GST) + parseFloat( OtherTax) + parseFloat(Freight) + parseFloat(Insurance)) - parseFloat(Discount); + + var tot = parseFloat(totvalue).toFixed(2); + + $('#txtTotalOrderValue').val(tot); + validateExceedLimit(); + } +function calculateTaxValue() + { + var Packaging = $('#txtAfterPackaging').val() == '' ? '0.00' : $('#txtAfterPackaging').val(); + var ExciseDuty = $('#txtAfterExciseDuty').val() == '' ? '0.00' : $('#txtAfterExciseDuty').val(); + var Vat = $('#txtAfterVat').val() == '' ? '0.00' : $('#txtAfterVat').val(); + var CST = $('#txtAfterCST').val() == '' ? '0.00' : $('#txtAfterCST').val(); + var GST = $('#txtAfterGST').val() == '' ? '0.00' : $('#txtAfterGST').val(); + var OtherTax = $('#txtAfterOtherTax').val() == '' ? '0.00' : $('#txtAfterOtherTax').val(); + var Freight = $('#txtAfterFreight').val() == '' ? '0.00' : $('#txtAfterFreight').val(); + var Insurance = $('#txtInsurance').val() == '' ? '0.00' : $('#txtInsurance').val(); + var Discount = $('#txtAfterDiscount').val() == '' ? '0.00' : $('#txtAfterDiscount').val(); + + + var totvalue = ( parseFloat(Packaging)+ parseFloat(ExciseDuty)+ parseFloat(Vat) + parseFloat(CST)+ parseFloat(GST) + parseFloat(OtherTax) + parseFloat(Freight) + parseFloat(Insurance)) - parseFloat(Discount); + + var tot = parseFloat(totvalue).toFixed(2); + alert('tot:'+tot); + return tot; + } + function validateExceedLimit() + { + var avalbudAmt = parseFloat($('#AvlBudAmt').val()); + var basicAmountRate = parseFloat($('#txtBasicValue').val()); + var totalAmount = parseFloat($('#txtTotalOrderValue').val()); + + if(basicAmountRate > avalbudAmt || totalAmount > avalbudAmt) + { + alert('Basic amount is exceeding the Budget Limit.Please adjust the product value.'); + $('#Rate').focus(); + return false; + } + else + { + return true; + } + + } +function isNumberKey(evt) + { + var charCode = (evt.which) ? evt.which : evt.keyCode; + if (charCode != 46 && charCode > 31 + && (charCode < 48 || charCode > 57)) + return false; + + return true; + } + function change(){ + ExceedQuantityCheck(); + if($('#Quantity').val() != '' && $('#Rate').val() != '') + { + var txtQuantity = parseFloat( $('#Quantity').val()); + var txtUnitPrice = parseFloat($('#Rate').val()); + var Tot = txtQuantity * txtUnitPrice + $('#txtBasicValue').val(Tot); + calculateTotalValue(); + + } +}