From 8e1e5ac2689a3de725c7ff9e27f2b5638740e563 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Wed, 21 Jun 2017 18:16:07 +0530 Subject: [PATCH] Exceeding quantity issue in import po --- application/controllers/purchaseorder.php | 13 +++++ application/models/purchaseorder_model.php | 12 +++- application/views/editimportpo.php | 18 ++++-- application/views/importpo.php | 67 ++++++++++++++++++++-- 4 files changed, 100 insertions(+), 10 deletions(-) diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index 9433bc14..cf89af0f 100755 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -303,6 +303,19 @@ class purchaseorder extends BaseController // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; } + + foreach($data['POItem'] as $CUR) + { + + //print_r($CUR->CurrencyType); + $Currency=$CUR->CurrencyType; + + + // $data[$Rate->ExchangeRate]=$Rate->ExchangeRate; + } + //echo "$Currency"; + $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); + //print_r($data); $data['ExchangeRate']=$exRate; $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index f9277f25..0490175c 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -550,6 +550,16 @@ function GetImportPurchaseOrderDetailsForPDF($PONO = '') } + + function GetCurrencyDetail($Currency='') + { + + $subQuery='SELECT CurrencyCode,CurrencyName from T_Currency_Details where CurrencyCode=?'; + $query=$this->db->query($subQuery,array($Currency)); + return $query->result(); + + } + @@ -559,7 +569,7 @@ function GetImportPurchaseOrderDetails($PONO = '') $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, Mat.UOM,Quantity,Rate,Req.Status,ROUND((Quantity *Rate),2 ) as BasicValue , - ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((Quantity *Rate)+(RMCIncludingCustomersPerKG*Quantity),2)as TotalOrderValue,ROUND((ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue, + ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((Quantity *Rate)+(RMCIncludingCustomersPerKG*Quantity),2)as TotalOrderValue,ROUND((ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue,CurrencyType, Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode diff --git a/application/views/editimportpo.php b/application/views/editimportpo.php index 4474d8c1..83e5558e 100755 --- a/application/views/editimportpo.php +++ b/application/views/editimportpo.php @@ -3,6 +3,7 @@ $AvlAmount = 0; $ReqType =''; //echo $ExchangeRate; +//echo $Currency; @@ -180,7 +181,8 @@ if(!empty($POMaster)) 'Select Currency'); + $options = array("0"=>'Select Currency'); + //print_r( $options); if(!empty($Currency)) { @@ -196,6 +198,10 @@ if(!empty($POMaster)) echo form_dropdown('currencytype', $options,set_value('currencytype'),'id="currencytype"' ,'required="true"' ,'class="form-control select2'); + + + + ?> -" /> +" /> + @@ -1789,7 +1796,10 @@ var NilType = ''; }; $('#ExchangeRate').val(); -$('#AvlBudAmt').val(); +$('#EditAvlBudAmt').val(); + + + var txtexchangerate=parseFloat($('#ExchangeRate').val()); $('#EditExchangeRt').val(txtexchangerate); @@ -3119,7 +3129,7 @@ $("#editimportpomodel").on("shown.bs.modal", function(e) { //alert($('#Reqnumber'+userid).val()); $('#EditdeptName').val($('#departmentName'+userid).val()); $("#EditCostCenter").val($('#costCode'+userid).val()); - $('#EditAvlBudAmt').val($('#AvilBudget'+userid).val()); + // $('#EditAvlBudAmt').val($('#AvilBudget'+userid).val()); $('#EditItemName').val($('#materialName'+userid).val()); $('#EditUOM').val($('#uom'+userid).val()); diff --git a/application/views/importpo.php b/application/views/importpo.php index 69851c7a..c7c7b778 100755 --- a/application/views/importpo.php +++ b/application/views/importpo.php @@ -377,7 +377,7 @@ if(!empty($AvlBudAmt))
'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()'); + $data = array('name' => 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange(),ExceedQuantityCheck()'); echo form_input($data); ?> @@ -913,7 +913,7 @@ if(!empty($AvlBudAmt))
'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()'); + $data = array('name' => 'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange(),ExceedEditQuantityCheck()'); echo form_input($data); ?> @@ -1794,6 +1794,24 @@ function Ratechange(){ } } +function validateEditExceedLimit() + { + var avalbudAmt = parseFloat($('#EditAvlBudAmt').val()); + var basicAmountRate = parseFloat($('#txtEditBasicValue').val()); + var totalAmount = parseFloat($('#EditTotalExp').val()); + + if(basicAmountRate > avalbudAmt || totalAmount > avalbudAmt) + { + alert('Basic amount is exceeding the Budget Limit.Please adjust the product value.'); + $('#EditRate').focus(); + return false; + } + else + { + return true; + } + + } function Calculateloadingcharge() { @@ -1953,6 +1971,43 @@ function EditCalculateCustomduty() } + +function ExceedQuantityCheck() + { + // RequistQuantity + var EnterQuantity = $("#Quantity").val()== '' ? "0.00" : parseFloat($("#Quantity").val()); + var ReqQuantity = parseFloat(RequistQuantity); + if(EnterQuantity > ReqQuantity) + { + alert('Your exceeding the Quantity from the Requisition Quantity:'+ RequistQuantity +'.Please adjust the Quantity to proceed further.'); + //$('#Quantity').val(RequistQuantity); + $('#Quantity').focus(); + return false; + } +else{ +return true; +} + } + + + function ExceedEditQuantityCheck() + { + // RequistQuantity + var EnterQuantity = $("#EditQuantity").val()== '' ? "0.00" : parseFloat($("#EditQuantity").val()); + var ReqQuantity = parseFloat(RequistQuantity); + if(EnterQuantity > ReqQuantity) + { + alert('Your exceeding the Quantity from the Requisition Quantity:'+ RequistQuantity +'.Please adjust the Quantity to proceed further.'); + //$('#Quantity').val(RequistQuantity); + $('#EditQuantity').focus(); + return false; + } +else{ +return true; +} + } + + function CalculateExciseDuty() { @@ -2587,7 +2642,7 @@ $('.AddImport').click(function() { //alert('out'); - if(validateImport()) + if(validateImport()&&ExceedQuantityCheck()) { //alert('in'); @@ -2846,7 +2901,7 @@ $('#txttotalavlmodvat').val((parseFloat(TotalAvlmodvat) + parseFloat(AvailableMo $('#txttotalgrossexpense').val((parseFloat(TotalGrossExpense) + parseFloat(Grossexpenses)).toFixed(2) ); $('#txtToatlOrder').val((parseFloat(TotalOrder) + parseFloat(totalexp)).toFixed(2) ); //alert(JSON.stringify(totalexp)); -alert(TotalOrder); +//alert(TotalOrder); @@ -3002,7 +3057,8 @@ $("#editimportpomodel").on("shown.bs.modal", function(e) { $('.EditImport').click(function(){ //alert('inside edit'); - + if(validateEditExceedLimit() && ExceedEditQuantityCheck()) + { var CostCode = $("#EditCostCenter").val(); var AvilBudget = $('#EditAvlBudAmt').val(); var editMaterialCode = $("#EditMaterialCode").val(); @@ -3085,6 +3141,7 @@ $('.EditImport').click(function(){ $('#RMCIncludingCustomers'+userid).val(RMC); $('#TotalExp'+userid).val(TotalExp); populateValueMainFormForEditImportTax(); + } //$('#Grossexpenses'+userid).val(GrossExpense); //addHidden(theForm,"taxamt"+temp,taxamt);//RMC