public void payInstallment(Payment payment) throws Exception {
		if (payment == null) {
			throw new Exception("Payment tidak boleh null.");
		}

		if (payment.getPaymentStatus() == null) {
			throw new Exception("Payment status tidak boleh null.");
		}

		if (!payment.getPaymentStatus().equals('N')) {
			throw new Exception(
					"Payment tidak dapat dibayarkan karena status payment bukan 'N' (New).");
		}

		if (payment.getAmount().compareTo(BigDecimal.ZERO) != 1) {
			throw new Exception("Amount harus lebih besar dari nol.");
		}

		Transaction transaction = null;
		Session session = HibernateUtil.openSession();

		transaction = session.beginTransaction();

		LoanAccountService loanAccountService = new LoanAccountService();
		LoanAccount loanAccount = loanAccountService.getLoanAccount(payment
				.getAcountNo());

		if (loanAccount == null) {
			transaction.rollback();
			session.close();
			throw new Exception("Loan account " + payment.getAcountNo()
					+ "tidak ditemukan.");
		}

		session.refresh(loanAccount);
		Hibernate.initialize(loanAccount.getLoanAccountSchedules());
		List<LoanAccountSchedule> loanAccountSchedules = loanAccount
				.getLoanAccountSchedules();

		LoanAccountSchedule loanAccountSchedule = null;

		for (LoanAccountSchedule schedule : loanAccountSchedules) {
			if (schedule.getPaidStatus().equals('U')) {
				loanAccountSchedule = schedule;
				break;
			}
		}

		if (loanAccountSchedule == null) {
			transaction.rollback();
			session.close();
			throw new Exception("Tidak ada angsuran yang belum dibayar.");
		}

		if (loanAccountSchedule.getOutstanding().compareTo(payment.getAmount()) != 0) {
			transaction.rollback();
			session.close();
			throw new Exception(
					"Cicilan tidak sesuai dengan jumlah pembayaran.");
		}

		loanAccountSchedule.setPaidStatus('P');
		payment.setPaymentStatus('P');

		session.update(loanAccountSchedule);
		session.update(payment);

		transaction.commit();
		session.close();
	}