siddharth_application/assets/js/CreatePOValidation.js
2017-11-28 10:46:55 +05:30

244 lines
6.6 KiB
JavaScript
Executable File

/**
/**
* File : CreatePOValidation.js
*
* This file contain the validation of edit Create Po
*
* @author Gandhimathi
*/
$(document).ready(function(){
//Initialize Select2 Elements
$("#drpSupplier").select2();
});
function myFunction() {
if(validate())
{
var input = $('#POType').val();
$('#' + input).modal('show');
}
}
function validate()
{
var radioValue = $("input[name='DateRange']:checked").val();
var PoType = $('#POType').val();
var currencyType = $('#currencytype').val();
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(radioValue==0 && $('#Deliverydate').val()==''){
alert('Please Select the Delivery Date');
$('#Deliverydate').focus();
return false;
}
else if(radioValue==1 && $('#Scheduleby').val().trim()==''){
alert('Please Enter the Schedule By');
$('#Deliverydate').focus();
return false;
}
else if($('#DeliveryAddr').val() == '')
{
alert('Please Enter the Delivery Address');
$('#DeliveryAddr').focus();
return false;
}
else if($('#insuranceStatus').val() == "1" && $('#insuranceNo').val().trim() == ''){
alert('Please Enter the Insurance No');
$('#insuranceNo').focus();
return false;
}
else if(PoType=='CAPITAL' && capitalType=='International'){
if(currencyType=='0'){
alert('Please Select the Currency Type');
$('#currencytype').focus();
return false;
}
else if(radioValue==2 && $('#Dispatch').val().trim()==''){
alert('Please Enter the Dispatch Instruction');
$('#Deliverydate').focus();
return false;
}
else if($('#PlaceOforigin').val().trim() == ''){
alert('Please Enter the Place Of Origin');
$('#PlaceOforigin').focus();
return false;
}
else if($('#ExchangeRt').val()==''){
alert('Please Enter the Exchange Rate');
$('#ExchangeRt').focus();
return false;
}
else{
return true;
}
}
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($('#Quantity').val() == "0")
{
alert('Please Enter the Valid Quantity value');
$('#Quantity').focus();
return false;
}
else if($('#Rate').val() == '')
{
alert('Please Enter the Rate of the Item');
$('#Rate').focus();
return false;
}
// else if($('#Rate').val() == "0")
// {
// alert('Please Enter the Valid 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();
ExceedQuantityCheck();
}
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()
{
// alert("add budget");
var avalbudAmt = parseFloat($('#AvlBudAmt').val());
var basicAmountRate = parseFloat($('#txtBasicValue').val());
// var totalAmount = parseFloat($('#txtTotalOrderValue').val());
//alert(basicAmountRate);
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();
}
}