diff --git a/src/main/java/com/seg83/childbank/gui/component/MainFrame.java b/src/main/java/com/seg83/childbank/gui/component/MainFrame.java
index 5c3b67d..60c773d 100644
--- a/src/main/java/com/seg83/childbank/gui/component/MainFrame.java
+++ b/src/main/java/com/seg83/childbank/gui/component/MainFrame.java
@@ -8,6 +8,7 @@
import com.seg83.childbank.gui.component.welcome.SetupPanel;
import com.seg83.childbank.gui.component.welcome.WelcomePanel;
import com.seg83.childbank.gui.event.PanelSwitchEvent;
+import com.seg83.childbank.service.DepositService;
import com.seg83.childbank.service.InterestService;
import com.seg83.childbank.service.SetupService;
import jakarta.annotation.PostConstruct;
@@ -32,10 +33,11 @@ public class MainFrame extends JFrame {
private SetupService setupService;
private InterestService interestService;
+ private DepositService depositService;
public MainFrame() throws HeadlessException {
setTitle("ChildBank");
- setSize(600, 400);
+ setSize(700, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
log.info("Create MainFrame");
@@ -43,7 +45,7 @@ public MainFrame() throws HeadlessException {
@Autowired
private void setPanels(HomePanel homePanel, WelcomePanel welcomePanel, SetupPanel setupPanel, SetupService setupService, InterestService interestService,
- SettingsPanel settingsPanel, FixedAccountPanel fixedAccountPanel, CurrentAccountPanel currentAccountPanel, TaskPanel taskPanel) {
+ SettingsPanel settingsPanel, FixedAccountPanel fixedAccountPanel, CurrentAccountPanel currentAccountPanel, TaskPanel taskPanel, DepositService depositService) {
this.homePanel = homePanel;
this.welcomePanel = welcomePanel;
this.setupPanel = setupPanel;
@@ -53,6 +55,7 @@ private void setPanels(HomePanel homePanel, WelcomePanel welcomePanel, SetupPane
this.fixedAccountPanel = fixedAccountPanel;
this.currentAccountPanel = currentAccountPanel;
this.taskPanel = taskPanel;
+ this.depositService = depositService;
}
@PostConstruct
@@ -98,6 +101,7 @@ private void initSetupPanel() {
private void initHomePanel() {
homePanel.$$$getRootComponent$$$().updateUI();
interestService.calculateCurrentInterest();
+ depositService.processMaturedDeposits();
homePanel.updateCurrentBallance();
homePanel.updateGoal();
homePanel.updateFixBallance();
@@ -120,6 +124,7 @@ private void initSettingsPanel() {
private void initFixedAccountPanel() {
fixedAccountPanel.createTable();
+ fixedAccountPanel.setTotalFixedLabel();
fixedAccountPanel.$$$getRootComponent$$$().updateUI();
setContentPane(this.fixedAccountPanel.$$$getRootComponent$$$());
// 显式刷新
@@ -137,7 +142,7 @@ private void initCurrentPanel() {
repaint();
log.info("Create currentAccountPanel in MainFrame");
}
-
+
private void initTaskPanel() {
taskPanel.createTable();
taskPanel.$$$getRootComponent$$$().updateUI();
diff --git a/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/InterestRatePop.java b/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/InterestRatePop.java
index 59f61b3..7772179 100644
--- a/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/InterestRatePop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/InterestRatePop.java
@@ -95,6 +95,9 @@ private void onCancel() {
public void init() {
log.debug("Initializing rate setting dialog");
+ // Clear the text fields
+ textField1.setText("");
+ passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
diff --git a/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/ToFixedPop.java b/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/ToFixedPop.java
index 62957d7..71733f1 100644
--- a/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/ToFixedPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/currentpanel/CurrentPops/ToFixedPop.java
@@ -99,7 +99,7 @@ private void onOK() {
String month = monthField.getText();
int monthInt;
try {
- monthInt = Integer.parseInt(amount);
+ monthInt = Integer.parseInt(month);
} catch (NumberFormatException e) {
// show a dialog
JOptionPane.showMessageDialog(this, "Amount should be an Integer", "Error", JOptionPane.ERROR_MESSAGE);
@@ -127,8 +127,12 @@ private void onOK() {
if (!check) {
JOptionPane.showMessageDialog(this, "Password mistake", "Error", JOptionPane.ERROR_MESSAGE);
} else {
- depositService.depositFixAccount(amountInt, rateDouble, todayStr, futureDateStr);
- dispose();
+ if (depositService.depositFixAccount(amountInt, rateDouble, todayStr, futureDateStr)) {
+ dispose();
+ } else {
+ JOptionPane.showMessageDialog(this, "Deposit failed", "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
}
}
@@ -141,6 +145,10 @@ private void onCancel() {
public void init() {
log.debug("Initializing tofix dialog");
+ // Clear the text fields
+ amountField.setText("");
+ monthField.setText("");
+ passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
diff --git a/src/main/java/com/seg83/childbank/gui/component/fixedpanel/FixedAccountPanel.java b/src/main/java/com/seg83/childbank/gui/component/fixedpanel/FixedAccountPanel.java
index 16637a4..84b16e7 100644
--- a/src/main/java/com/seg83/childbank/gui/component/fixedpanel/FixedAccountPanel.java
+++ b/src/main/java/com/seg83/childbank/gui/component/fixedpanel/FixedAccountPanel.java
@@ -35,7 +35,6 @@ public class FixedAccountPanel {
private JTable table1;
private JLabel totalLabel;
-
public FixedAccountPanel() {
// $$$setupUI$$$();
backButton.addActionListener(e -> {
@@ -43,10 +42,6 @@ public FixedAccountPanel() {
});
}
- @PostConstruct
- public void init() {
- setTotalFixedLabel();
- }
public void createTable() {
// TODO: use actual data
@@ -72,9 +67,8 @@ public void createTable() {
columnModel.getColumn(4).setPreferredWidth(200); // Expire Date 列
}
-
public void setTotalFixedLabel() {
- totalLabel.setText(String.valueOf(depositService.calculateTotalDeposits()));
+ totalLabel.setText("$" + depositService.calculateTotalDeposits());
}
{
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.form b/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.form
index 33a829c..9a1a06b 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.form
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.form
@@ -8,8 +8,8 @@
-
-
+
+
@@ -18,12 +18,50 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.java b/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.java
index 02a8095..d915164 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.java
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/HomePanel.java
@@ -59,6 +59,8 @@ public class HomePanel {
private JButton goalAlterationButton;
private JLabel displayGoal;
private JLabel fixedLabel;
+ private JProgressBar progressBar;
+ private JLabel progressText;
/**
* Constructor for HomePanel class.
@@ -118,6 +120,8 @@ public void updateCurrentBallance() {
public void updateGoal() {
String str = goalService.toUiContent("total") + "/" + goalService.toUiContent("goal");
displayGoal.setText(str);
+ progressBar.setValue(goalService.calcGoal());
+ progressText.setText(goalService.calcGoal() + "%");
rootHomePanel.revalidate();
rootHomePanel.repaint();
}
@@ -125,7 +129,7 @@ public void updateGoal() {
public void updateFixBallance() {
updateGoal();
double newBallance = depositService.calculateTotalDeposits();
- fixedLabel.setText(String.valueOf(newBallance));
+ fixedLabel.setText("$" + newBallance);
rootHomePanel.revalidate();
rootHomePanel.repaint();
}
@@ -149,85 +153,97 @@ public void updateFixBallance() {
rootHomePanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
rootHomePanel.setBorder(BorderFactory.createTitledBorder(null, "HomePage", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
- panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+ panel1.setLayout(new GridLayoutManager(4, 1, new Insets(1, 1, 1, 1), -1, -1));
rootHomePanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
panel1.setBorder(BorderFactory.createTitledBorder(null, "Goal", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
displayGoal = new JLabel();
displayGoal.setText("$1734/$2000");
- panel1.add(displayGoal, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel1.add(displayGoal, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 7), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
- rootHomePanel.add(panel2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel1.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
+ progressBar = new JProgressBar();
+ panel2.add(progressBar, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ progressText = new JLabel();
+ progressText.setText("114%");
+ panel2.add(progressText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final Spacer spacer1 = new Spacer();
+ panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 5), null, 0, false));
+ final Spacer spacer2 = new Spacer();
+ panel1.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ final JPanel panel3 = new JPanel();
+ panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
+ rootHomePanel.add(panel3, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
currPanel = new JPanel();
currPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
- panel2.add(currPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel3.add(currPanel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
currPanel.setBorder(BorderFactory.createTitledBorder(null, "Current Balance", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
currLabel = new JLabel();
currLabel.setText("$1234");
currPanel.add(currLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- final JPanel panel3 = new JPanel();
- panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
- panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- panel3.setBorder(BorderFactory.createTitledBorder(null, "Fixed Balance", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
+ final JPanel panel4 = new JPanel();
+ panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+ panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel4.setBorder(BorderFactory.createTitledBorder(null, "Fixed Balance", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
fixedLabel = new JLabel();
fixedLabel.setText("$500");
- panel3.add(fixedLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- final JPanel panel4 = new JPanel();
- panel4.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
- rootHomePanel.add(panel4, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- panel4.setBorder(BorderFactory.createTitledBorder(null, "Operations", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel4.getFont()), null));
+ panel4.add(fixedLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel5 = new JPanel();
- panel5.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1));
- panel4.add(panel5, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- panel5.setBorder(BorderFactory.createTitledBorder(null, "More Function", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
+ panel5.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
+ rootHomePanel.add(panel5, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel5.setBorder(BorderFactory.createTitledBorder(null, "Operations", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel5.getFont()), null));
+ final JPanel panel6 = new JPanel();
+ panel6.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1));
+ panel5.add(panel6, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel6.setBorder(BorderFactory.createTitledBorder(null, "More Function", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
currentAccountOperationButton = new JButton();
currentAccountOperationButton.setText("Current Account Operation");
- panel5.add(currentAccountOperationButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- final Spacer spacer1 = new Spacer();
- panel5.add(spacer1, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ panel6.add(currentAccountOperationButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final Spacer spacer3 = new Spacer();
+ panel6.add(spacer3, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
tasksAndRewardsButton = new JButton();
tasksAndRewardsButton.setText("Tasks and rewards");
- panel5.add(tasksAndRewardsButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel6.add(tasksAndRewardsButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
systemSettingsButton = new JButton();
systemSettingsButton.setText("System settings");
- panel5.add(systemSettingsButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- final Spacer spacer2 = new Spacer();
- panel5.add(spacer2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- final Spacer spacer3 = new Spacer();
- panel5.add(spacer3, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- fixedDepositAndWithdrawalButton = new JButton();
- fixedDepositAndWithdrawalButton.setText("Fixed Account Operation");
- panel5.add(fixedDepositAndWithdrawalButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel6.add(systemSettingsButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer4 = new Spacer();
- panel5.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ panel6.add(spacer4, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer5 = new Spacer();
- panel5.add(spacer5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- final JPanel panel6 = new JPanel();
- panel6.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1));
- panel4.add(panel6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
- panel6.setBorder(BorderFactory.createTitledBorder(null, "Quick Operations", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
- quickDepositButton = new JButton();
- quickDepositButton.setText("Quick deposit");
- panel6.add(quickDepositButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false));
+ panel6.add(spacer5, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ fixedDepositAndWithdrawalButton = new JButton();
+ fixedDepositAndWithdrawalButton.setText("Fixed Account Operation");
+ panel6.add(fixedDepositAndWithdrawalButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer6 = new Spacer();
- panel6.add(spacer6, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
- quickWithdrawalButton = new JButton();
- quickWithdrawalButton.setText("Quick withdrawal");
- panel6.add(quickWithdrawalButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false));
+ panel6.add(spacer6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer7 = new Spacer();
panel6.add(spacer7, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ final JPanel panel7 = new JPanel();
+ panel7.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1));
+ panel5.add(panel7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel7.setBorder(BorderFactory.createTitledBorder(null, "Quick Operations", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
+ quickDepositButton = new JButton();
+ quickDepositButton.setText("Quick deposit");
+ panel7.add(quickDepositButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false));
final Spacer spacer8 = new Spacer();
- panel6.add(spacer8, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
- operationHistoryButton = new JButton();
- operationHistoryButton.setText("Operation history");
- panel6.add(operationHistoryButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel7.add(spacer8, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ quickWithdrawalButton = new JButton();
+ quickWithdrawalButton.setText("Quick withdrawal");
+ panel7.add(quickWithdrawalButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 10), null, 0, false));
final Spacer spacer9 = new Spacer();
- panel6.add(spacer9, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel7.add(spacer9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer10 = new Spacer();
- panel6.add(spacer10, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ panel7.add(spacer10, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ operationHistoryButton = new JButton();
+ operationHistoryButton.setText("Operation history");
+ panel7.add(operationHistoryButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final Spacer spacer11 = new Spacer();
+ panel7.add(spacer11, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ final Spacer spacer12 = new Spacer();
+ panel7.add(spacer12, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
goalAlterationButton = new JButton();
goalAlterationButton.setText("Goal Alteration");
- panel6.add(goalAlterationButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ panel7.add(goalAlterationButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/DepositPop.java b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/DepositPop.java
index 68cca28..9c793b8 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/DepositPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/DepositPop.java
@@ -121,6 +121,9 @@ private void onCancel() {
public void init() {
log.debug("Initializing DepositePop dialog");
+ // Clear the text fields
+ textField1.setText("");
+ passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/GoalAlterationPop.java b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/GoalAlterationPop.java
index 0e1d6f0..74895d7 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/GoalAlterationPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/GoalAlterationPop.java
@@ -95,6 +95,9 @@ public void init() {
log.debug("Initializing GoalPop dialog");
log.info("Load current goal");
+ // Clear the text fields
+ textField1.setText("");
+ passwordField1.setText("");
String goal = goalService.toUiContent("goal");
goalDisplay.setText(goal);
this.pack(); // 使用已经存在的this引用而不是创建新的实例
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/HistoryPop.java b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/HistoryPop.java
index b4a842d..2826044 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/HistoryPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/HistoryPop.java
@@ -84,6 +84,8 @@ private void createTable() {
public void init() {
log.debug("Initializing HistoryPop dialog");
+ // Clear the text fields
+ table1.removeAll();
createTable();
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
diff --git a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/WithdrawPop.java b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/WithdrawPop.java
index c9ba439..2e3a4fa 100644
--- a/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/WithdrawPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/homepanel/homepop/WithdrawPop.java
@@ -92,8 +92,11 @@ private void onOK() {
if (!check) {
JOptionPane.showMessageDialog(this, "Password mistake", "Error", JOptionPane.ERROR_MESSAGE);
} else {
- currentService.withdrawCurrentAccount(amountInt);
- dispose();
+ if (currentService.withdrawCurrentAccount(amountInt)) {
+ dispose();
+ } else {
+ JOptionPane.showMessageDialog(this, "Not enough balance", "Error", JOptionPane.ERROR_MESSAGE);
+ }
}
}
@@ -104,18 +107,21 @@ private void onCancel() {
dispose();
}
+ // IntelliJ IDEA GUI Designer code
+
/**
* Initializes the WithdrawPop dialog.
*/
public void init() {
log.debug("Initializing DepositePop dialog");
+ // Clear the text fields
+ textField1.setText("");
+ passwordField1.setText("");
this.pack(); // Use the existing this reference instead of creating a new instance
setLocationRelativeTo(null); // Place the window at the center of the screen
this.setVisible(true);
}
- // IntelliJ IDEA GUI Designer code
-
/**
* @noinspection ALL
*/
diff --git a/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPanel.java b/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPanel.java
index 08d563c..d6ff9b4 100644
--- a/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPanel.java
+++ b/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPanel.java
@@ -66,10 +66,10 @@ public void createTable() {
table1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// 设置列宽
TableColumnModel columnModel = table1.getColumnModel();
- columnModel.getColumn(0).setPreferredWidth(25); // ID 列
- columnModel.getColumn(1).setPreferredWidth(80);
+ columnModel.getColumn(0).setPreferredWidth(10); // ID 列
+ columnModel.getColumn(1).setPreferredWidth(100);
columnModel.getColumn(2).setPreferredWidth(200);
- columnModel.getColumn(3).setPreferredWidth(80);
+ columnModel.getColumn(3).setPreferredWidth(70);
}
public void updatePanel() {
diff --git a/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPop.java b/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPop.java
index 544b410..eee6e1f 100644
--- a/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPop.java
+++ b/src/main/java/com/seg83/childbank/gui/component/taskpanel/TaskPop.java
@@ -94,6 +94,9 @@ private void onCancel() {
public void init() {
log.debug("Initializing DepositePop dialog");
+ // Clear the text fields
+ textField1.setText("");
+ passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
diff --git a/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.form b/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.form
index 34965e6..01afde7 100644
--- a/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.form
+++ b/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.form
@@ -37,7 +37,7 @@
-
+
diff --git a/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.java b/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.java
index f2453fb..3e37a41 100644
--- a/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.java
+++ b/src/main/java/com/seg83/childbank/gui/component/welcome/SetupPanel.java
@@ -115,7 +115,7 @@ public SetupPanel() {
welcomeToTheVirtualTextPane = new JTextPane();
welcomeToTheVirtualTextPane.setBackground(new Color(-1118482));
welcomeToTheVirtualTextPane.setEditable(false);
- welcomeToTheVirtualTextPane.setText("Welcome to the Virtual Bank Application for Kids, designed to be a secure and educational tool that grows with your child on their financial literacy journey. In this application, all deposits require a parental permission password to ensure security, while withdrawals can be managed independently by children within preset limits using their transaction password. Parents have the ability to assign tasks and set rewards, allowing them to oversee task completion and reward achievements directly through the app. Additionally, the app includes robust security settings for managing password changes and account resets. A dedicated section for app functionalities and contact information is available for help and support. Our Virtual Bank Application for Kids is more than just a tool; it is a rich and supportive environment aimed at nurturing financially savvy children. We invite you to explore, learn, and grow with us in the safe, fun world of virtual banking for kids! Now, let's set two passwords for admin and kids first!");
+ welcomeToTheVirtualTextPane.setText(" Welcome to the Virtual Bank Application for Kids, designed to be a secure and educational tool that grows with your child on their financial literacy journey. \n In this application, all deposits require a parental permission password to ensure security, while withdrawals can be managed independently by children within preset limits using their transaction password. \n Parents have the ability to assign tasks and set rewards, allowing them to oversee task completion and reward achievements directly through the app.\n\n Additionally, the app includes robust security settings for managing password changes and account resets. A dedicated section for app functionalities and contact information is available for help and support. Our Virtual Bank Application for Kids is more than just a tool; it is a rich and supportive environment aimed at nurturing financially savvy children. \n We invite you to explore, learn, and grow with us in the safe, fun world of virtual banking for kids! Now, let's set two passwords for admin and kids first!");
scrollPane1.setViewportView(welcomeToTheVirtualTextPane);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(8, 1, new Insets(0, 0, 0, 0), -1, -1));
diff --git a/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.form b/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.form
index 5dc87f3..604d7d9 100644
--- a/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.form
+++ b/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.form
@@ -29,14 +29,14 @@
-
+
-
+
diff --git a/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.java b/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.java
index d663d57..1b11dde 100644
--- a/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.java
+++ b/src/main/java/com/seg83/childbank/gui/component/welcome/WelcomePanel.java
@@ -62,8 +62,8 @@ public WelcomePanel() {
weInviteYouToTextPane = new JTextPane();
weInviteYouToTextPane.setBackground(new Color(-1118482));
weInviteYouToTextPane.setEditable(false);
- weInviteYouToTextPane.setText("We invite you to explore, learn, and grow with us in the safe, fun world of virtual banking for kids! ");
- rootPanel.add(weInviteYouToTextPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
+ weInviteYouToTextPane.setText(" We invite you to explore, learn, and grow with us in the safe, fun world of virtual banking for kids! ");
+ rootPanel.add(weInviteYouToTextPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
}
/**
diff --git a/src/main/java/com/seg83/childbank/service/CurrentService.java b/src/main/java/com/seg83/childbank/service/CurrentService.java
index 5b00176..47de590 100644
--- a/src/main/java/com/seg83/childbank/service/CurrentService.java
+++ b/src/main/java/com/seg83/childbank/service/CurrentService.java
@@ -67,13 +67,18 @@ public void payDailyCurrentInterest(double amount) {
*
* @param amount The amount to withdraw.
*/
- public void withdrawCurrentAccount(int amount) {
+ public boolean withdrawCurrentAccount(int amount) {
double currentAmount = (Double) currentAccountDao.getAttribute("currentAccountAmount");
double newAmount = currentAmount - amount;
+ if (newAmount < 0) {
+ log.error("Withdraw current {} failed, not enough balance", amount);
+ return false;
+ }
currentAccountDao.setAttribute("currentAccountAmount", newAmount);
log.info("Withdraw current {} now {} -> {}", amount, currentAmount, newAmount);
// Create a history
historyService.createOperationHistory(amount, "current withdraw");
+ return true;
}
public void modifyInterestRate(double rate) {
diff --git a/src/main/java/com/seg83/childbank/service/DepositService.java b/src/main/java/com/seg83/childbank/service/DepositService.java
index 35b7688..cb9a320 100644
--- a/src/main/java/com/seg83/childbank/service/DepositService.java
+++ b/src/main/java/com/seg83/childbank/service/DepositService.java
@@ -57,11 +57,16 @@ public void createDepositAccountBill(double amount, double rate, String effectiv
depositAccountBillsDao.createDepositAccountBill(amount, rate, effectiveDate, expireDate);
}
- public void depositFixAccount(double amount, double rate, String effectiveDate, String expireDate) {
- currentService.withdrawCurrentAccount((int) amount);
- createDepositAccountBill(amount, rate, effectiveDate, expireDate);
- log.info("Deposit fix {}", amount);
- historyService.createOperationHistory(amount, "Fix deposit");
+ public boolean depositFixAccount(double amount, double rate, String effectiveDate, String expireDate) {
+ if (currentService.withdrawCurrentAccount((int) amount)) {
+ createDepositAccountBill(amount, rate, effectiveDate, expireDate);
+ log.info("Deposit fix {}", amount);
+ historyService.createOperationHistory(amount, "Fix deposit");
+ return true;
+ }else {
+ log.error("Deposit fix failed");
+ return false;
+ }
}
public void processMaturedDeposits() {
@@ -77,9 +82,11 @@ public void processMaturedDeposits() {
long days = convert.calculateDaysBetween(bill.getDepositAccountBillEffectiveDate(), bill.getDepositAccountBillExpireDate());
double interest = amount * rate * days / 365;
double totalAmount = amount + interest;
+ // To .2 decimal places
+ totalAmount = Math.round(totalAmount * 100) / 100.0;
currentService.depositCurrentAccount(totalAmount);
- historyService.createOperationHistory(totalAmount, "Matured fixed deposit");
+ historyService.createOperationHistory(totalAmount, "Deposit Expire");
depositAccountBillsDao.deleteDepositAccountBill(bill.getDepositAccountBillId());
log.info("Processed matured deposit with amount: {}, interest: {}, total: {}", amount, interest, totalAmount);
}
@@ -89,7 +96,7 @@ public void processMaturedDeposits() {
public double calculateTotalDeposits() {
double total = 0;
for (int i = 0; i < depositAccountBillsDao.ElementCount; i++) {
- total = total + (double) depositAccountBillsDao.getAttribute("depositAccountBillAmount", (int) (i + 1));
+ total = total + (double) depositAccountBillsDao.getAttribute("depositAccountBillAmount", i + 1);
}
return total;
}