我正在设计和实施贷款管理系统。其中一项功能要求是
- 每日计算利息,并按月复利。
我想使用会话bean实现此要求。我如何才能最好地设计会话bean? 我有账户和利息实体。利息实体包含账户实体的利息设置。我试图在下面的DayInterest会话bean中实现功能需求,以便更好地理解我想要实现的目标。
package com.fsm.dayend;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.fsm.account.AccountFacade;
import javax.ejb.EJB;
import com.fsm.account.Account;
/**
*
* @author Fact
*/
@Stateless
public class DayInterest implements DayInterestLocal {
@PersistenceContext(unitName = "com.fsm_DebtorsAccounts-ejb_ejb_1.0-SNAPSHOTPU")
private EntityManager em;
@EJB
AccountFacade accountFacade;
private Account account;
public DayInterest() {
}
public DayInterest(Account account) {
this.account = account;
}
public void updateInterest(){
double interestAccrued= account.getBalance()*account.getInterest().getRate()* 1/360;
account.getInterest().setAccrued(account.getInterest().getAccrued()+interestAccrued);
accountFacade.edit(account);
}
}