Index: src/org/mifos/application/accounts/loan/struts/action/LoanAccountAction.java
===================================================================
--- src/org/mifos/application/accounts/loan/struts/action/LoanAccountAction.java	(revision 12280)
+++ src/org/mifos/application/accounts/loan/struts/action/LoanAccountAction.java	(working copy)
@@ -427,7 +427,6 @@
 				.getInstance().getBusinessService(
 						BusinessServiceName.LoanProduct))
 				.getApplicablePrdOfferings(customer.getCustomerLevel());
-		removePrdOfferingNotMatchingPrdType(loanOfferings, customer);
 		removePrdOfferingsNotMachingCustomerMeeting(loanOfferings, customer);
 		SessionUtils.setCollectionAttribute(LoanConstants.LOANPRDOFFERINGS,
 				loanOfferings, request);
@@ -1684,62 +1683,7 @@
 		loadCustomFieldDefinitions(request);
 	}
 
-	private void removePrdOfferingNotMatchingPrdType(
-			List<LoanOfferingBO> loanOfferings, CustomerBO customer) {
-		Set<AccountBO> accounts = customer.getAccounts();
-		Iterator<AccountBO> itr = accounts.iterator();
-		ArrayList listAccountStateID = new ArrayList();
-		while (itr.hasNext()) {
-			AccountBO accountBo = itr.next();
-			listAccountStateID.add(accountBo.getAccountState().getId());
 
-		}
-		if (!(listAccountStateID.contains(AccountStates.LOANACC_OBLIGATIONSMET))) {
-			for (Iterator<LoanOfferingBO> iter = loanOfferings.iterator(); iter
-					.hasNext();) {
-				LoanOfferingBO loanOffering = iter.next();
-				if (!(loanOffering.getLoanAmountFromLastLoan().isEmpty())) {
-					iter.remove();
-				}
-				else if (!(loanOffering.getNoOfInstallFromLastLoan().isEmpty())) {
-					iter.remove();
-				}
-			}
-
-		}
-		else {
-			for (Iterator<LoanOfferingBO> iter = loanOfferings.iterator(); iter
-					.hasNext();) {
-				LoanOfferingBO loanOffering = iter.next();
-				if (!loanOffering.getLoanAmountFromLastLoan().isEmpty()) {
-					removePrdOfferingNotMatchingCustomerLastLoanAmount(
-							customer, loanOffering, iter);
-				}
-				else if (!loanOffering.getNoOfInstallFromLastLoan().isEmpty()) {
-					removePrdOfferingNotMatchingCustomerLastLoanAmount(
-							customer, loanOffering, iter);
-				}
-
-			}
-		}
-	}
-
-	private void removePrdOfferingNotMatchingCustomerLastLoanAmount(
-			CustomerBO customer, LoanOfferingBO loanOffering,
-			Iterator<LoanOfferingBO> iter) {
-		Double lastLoanAmount = getCustomerLastMaxLoanAmount(customer);
-		List listLoanAmount = loanOffering.eligibleLoanAmount(lastLoanAmount
-				.toString(), loanOffering);
-		List listNoOfInstall = loanOffering.eligibleNoOfInstall(lastLoanAmount
-				.toString(), loanOffering);
-		if (listLoanAmount.isEmpty()) {
-			iter.remove();
-		}
-		else if (listNoOfInstall.isEmpty()) {
-			iter.remove();
-		}
-	}
-
 	public Double getCustomerLastMaxLoanAmount(CustomerBO customer) {
 		ArrayList list = new ArrayList();
 		Set<AccountBO> accounts = customer.getAccounts();
@@ -1765,6 +1709,9 @@
 			}
 
 		}
+		if (list.isEmpty()) {
+			list.add(new Integer("0"));
+		}
 		return Double.parseDouble(Collections.max(list).toString());
 
 	}
Index: src/org/mifos/application/productdefinition/business/LoanOfferingBO.java
===================================================================
--- src/org/mifos/application/productdefinition/business/LoanOfferingBO.java	(revision 12280)
+++ src/org/mifos/application/productdefinition/business/LoanOfferingBO.java	(working copy)
@@ -974,7 +974,9 @@
 					if (((loanAmountFromLastLoanAmountBO.getStartRange() <= Double
 							.parseDouble(calaculateValue)) && (loanAmountFromLastLoanAmountBO
 							.getEndRange() >= Double
-							.parseDouble(calaculateValue)))) {
+							.parseDouble(calaculateValue)))
+							|| ((i == loanOfferingBO.loanAmountFromLastLoan
+									.size() - 1) && list.isEmpty())) {
 						list.add(loanAmountFromLastLoanAmountBO
 								.getMaxLoanAmount());
 						list.add(loanAmountFromLastLoanAmountBO
@@ -1038,7 +1040,9 @@
 					if (((noOfInstallFromLastLoanAmountBO.getStartRange() <= Double
 							.parseDouble(calaculateValue)) && (noOfInstallFromLastLoanAmountBO
 							.getEndRange() >= Double
-							.parseDouble(calaculateValue)))) {
+							.parseDouble(calaculateValue)))
+							|| ((i == loanOfferingBO.loanAmountFromLastLoan
+									.size() - 1) && list.isEmpty())) {
 						list.add(noOfInstallFromLastLoanAmountBO
 								.getMaxNoOfInstall());
 						list.add(noOfInstallFromLastLoanAmountBO
Index: test/org/mifos/application/accounts/loan/struts/action/TestLoanAccountAction.java
===================================================================
--- test/org/mifos/application/accounts/loan/struts/action/TestLoanAccountAction.java	(revision 12280)
+++ test/org/mifos/application/accounts/loan/struts/action/TestLoanAccountAction.java	(working copy)
@@ -1257,14 +1257,13 @@
 		LoanOfferingBO loanOffering = getLoanOfferingFromLastLoan("fdfsdfsd",
 				"ertg", ApplicableTo.GROUPS, WEEKLY, EVERY_WEEK);
 		createInitialObjects();
-		makeRepaymentForLastLoanAmount();
+	
 		LoanAccountAction loanAccountAction = new LoanAccountAction();
 		LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
 		loanAccountActionForm.setCustomerId(group.getCustomerId().toString());
 		loanAccountAction.updateLoanOffering(loanOffering,
 				loanAccountActionForm);
-		setUp();
-		request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
+			request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
 		SessionUtils.setAttribute(LoanConstants.LOANOFFERING, loanOffering,
 				request);
 		SessionUtils.setAttribute(LoanConstants.LOANFUNDS,
@@ -1298,8 +1297,8 @@
 				.getSession().getAttribute("loanAccountActionForm");
 		LoanBO loan = TestObjectFactory.getObject(LoanBO.class, new Integer(
 				actionForm.getAccountId()).intValue());
-		assertEquals(loan.getLoanAmount(), new Money("400"));
-		assertEquals(loan.getNoOfInstallments(), new Short("40"));
+		assertEquals(loan.getLoanAmount(), new Money("200"));
+		assertEquals(loan.getNoOfInstallments(), new Short("20"));
 		TestObjectFactory.cleanUp(loan);
 		accountBO = null;
 	}
