diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsController.java index 47729e5..dabc63b 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsController.java @@ -58,25 +58,21 @@ private void filterData(final String searchKeyword, final Integer weekTarget) { if (t.getShare().getStock().getCompany().toLowerCase().contains(searchKeyword.toLowerCase()) || t.getShare().getStock().getSymbol().toLowerCase().contains(searchKeyword.toLowerCase())) { String transactionType = "Purchase"; - String sharePrefix = "+ "; - String moneyPrefix = "- "; if(t.getClass().equals(Sale.class)){ transactionType = "Sale"; - sharePrefix = "- "; - moneyPrefix = "+ "; } getViewElement().addTransactionCard( transactionType, t.getShare().getStock().getSymbol(), t.getShare().getStock().getCompany(), - sharePrefix + t.getShare().getQuantity().floatValue(), - moneyPrefix + t.getCalculator().calculateGross().floatValue(), - moneyPrefix + t.getCalculator().calculateCommission().floatValue(), - moneyPrefix + t.getCalculator().calculateTax().floatValue(), - moneyPrefix + t.getCalculator().calculateTotal().floatValue(), - weekTarget.toString()); + t.getShare().getQuantity(), + t.getCalculator().calculateGross(), + t.getCalculator().calculateCommission(), + t.getCalculator().calculateTax(), + t.getCalculator().calculateTotal(), + weekTarget); } }); } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java index 4a0300f..7edaae8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java @@ -1,6 +1,8 @@ package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.transactions; import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; + +import java.math.BigDecimal; import java.util.List; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; @@ -113,12 +115,12 @@ protected void initLayout() { public void addTransactionCard(final String type, final String symbol, final String companyName, - final String shares, - final String gross, - final String commission, - final String tax, - final String totalChange, - final String week) { + final BigDecimal shares, + final BigDecimal gross, + final BigDecimal commission, + final BigDecimal tax, + final BigDecimal totalChange, + final int week) { VBox card = new VBox(); // Header (SALE / PURCHASE) @@ -127,17 +129,49 @@ public void addTransactionCard(final String type, // Company Details Label companyLabel = new Label(symbol + ", " + companyName); - // Info Rows (+- shares, +- NOK) + // Card rows VBox infoBox = new VBox(); - Label textRow1 = new Label("Shares: " + shares); - Label textRow2 = new Label("Gross: " + gross); - Label textRow3 = new Label("tax: " + tax); - Label textRow4 = new Label("Comission fee : " + commission); - Label textRow5 = new Label("Total: " + totalChange + "NOK"); + Region spacer1 = new Region(); + HBox.setHgrow(spacer1, Priority.ALWAYS); + HBox row1 = new HBox( + new Label("Quantity: "), + spacer1, + new Label(String.format("%.3f", shares.floatValue())) + ); + Region spacer2 = new Region(); + HBox.setHgrow(spacer2, Priority.ALWAYS); + HBox row2 = new HBox( + new Label("Gross: "), + spacer2, + new Label(String.format("%.3f", gross.floatValue()) + "NOK") + ); + + Region spacer3 = new Region(); + HBox.setHgrow(spacer3, Priority.ALWAYS); + HBox row3 = new HBox( + new Label("Tax: "), + spacer3, + new Label(String.format("%.3f", tax.floatValue()) + "NOK") + ); + + Region spacer4 = new Region(); + HBox.setHgrow(spacer4, Priority.ALWAYS); + HBox row4 = new HBox( + new Label("Commission fee: "), + spacer4, + new Label(String.format("%.3f", commission.floatValue()) + "NOK") + ); + Region spacer5 = new Region(); + HBox.setHgrow(spacer5, Priority.ALWAYS); + HBox row5 = new HBox( + new Label("Total: "), + spacer5, + new Label(String.format("%.3f", totalChange.floatValue()) + "NOK") + ); - infoBox.getChildren().addAll(textRow1, textRow2, textRow3, textRow4, textRow5); + infoBox.getChildren().addAll(row1, row2, row3, row4, row5); Region spacer = new Region(); VBox.setVgrow(spacer, Priority.ALWAYS); @@ -158,8 +192,7 @@ public void addTransactionCard(final String type, typeLabel.getStyleClass().add("transactions-typeLabel"); infoBox.getStyleClass().add("transactions-infoBox"); companyLabel.getStyleClass().add("transactions-cardText"); - textRow1.getStyleClass().add("transactions-cardText"); - textRow2.getStyleClass().add("transactions-cardText"); + infoBox.getChildren().forEach(n -> n.getStyleClass().add("transactions-cardText")); cardWeekLabel.getStyleClass().add("transactions-cardText"); } diff --git a/src/main/resources/styles.css b/src/main/resources/styles.css index 60c21b6..0721c0c 100644 --- a/src/main/resources/styles.css +++ b/src/main/resources/styles.css @@ -1207,7 +1207,6 @@ } .transactions-cardText { - -fx-font-family: "Consolas, Menlo, monospace"; -fx-font-size: 15px; -fx-text-fill: #f0f4ff; }