Skip to content

155 fix transactions page #159

Merged
merged 5 commits into from
May 26, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +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() + " shares",
moneyPrefix + t.getCalculator().calculateTotal().floatValue() + " NOK",
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 @@ -102,16 +104,23 @@ protected void initLayout() {
* transaction.
* @param shares the amount of shares gained or lost during this
* transaction.
* @param nok the amount of money in NOK gained or lost during
* the transactions.
* @param gross the gross amount of NOK gained or lost upon
* transaction.
* @param commission the calculated commission fee for the transaction.
* @param tax the calculated tax for the transaction.
* @param totalChange the total amount of NOK gained or lost upon
* transaction.
* @param week the week this transaction took place.
*/
public void addTransactionCard(final String type,
final String symbol,
final String companyName,
final String shares,
final String nok,
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 @@ -120,13 +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);
Label textRow2 = new Label(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);
infoBox.getChildren().addAll(row1, row2, row3, row4, row5);

Region spacer = new Region();
VBox.setVgrow(spacer, Priority.ALWAYS);
Expand All @@ -147,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