Skip to content

Commit

Permalink
Feat: Fixed transaction cards to include details
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 26, 2026
1 parent 68a3548 commit 4e6a18f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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");
}

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,6 @@
}

.transactions-cardText {
-fx-font-family: "Consolas, Menlo, monospace";
-fx-font-size: 15px;
-fx-text-fill: #f0f4ff;
}
Expand Down

0 comments on commit 4e6a18f

Please sign in to comment.