From 792f2140b2df6553f64e06c02384d27ed5459ef0 Mon Sep 17 00:00:00 2001 From: pawelsa Date: Sun, 24 May 2026 00:11:45 +0200 Subject: [PATCH 01/11] refactor(SaleCalculator): Remove negative taxes. --- .../edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java b/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java index 47819d5..f9552fa 100644 --- a/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java +++ b/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java @@ -63,7 +63,7 @@ public BigDecimal calculateTax() { BigDecimal profit = calculateGross().subtract(purchasePrice.multiply(quantity)) .subtract(calculateCommision()); // (gross - tax - buy costs) - return profit.multiply(taxPercentage); + return profit.max(BigDecimal.ZERO).multiply(taxPercentage); } From d147b8390497601ed7d07bf540d1bbd0cbe5b556 Mon Sep 17 00:00:00 2001 From: pawelsa Date: Sun, 24 May 2026 00:14:20 +0200 Subject: [PATCH 02/11] refactor: Sizing and naming in Launcher --- src/main/java/edu/ntnu/idi/idatt/Launcher.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ntnu/idi/idatt/Launcher.java b/src/main/java/edu/ntnu/idi/idatt/Launcher.java index 18c49a6..a7030b1 100644 --- a/src/main/java/edu/ntnu/idi/idatt/Launcher.java +++ b/src/main/java/edu/ntnu/idi/idatt/Launcher.java @@ -11,16 +11,16 @@ public final class Launcher { * Entry point of application. */ static void main() { - Application.launch(StockGame.class); + Application.launch(Millions.class); } - public static final class StockGame extends Application { + public static final class Millions extends Application { @Override public void start(Stage stage) { - stage.setWidth(1200); - stage.setHeight(700); - stage.setTitle("Stock Game"); + stage.setWidth(1440); + stage.setHeight(820); + stage.setTitle("Millions"); SceneManager.init(stage, SceneFactory.createStartView()); stage.show(); From 68e9dd397c742e839a99e7818f1ef5fa00e5278d Mon Sep 17 00:00:00 2001 From: pawelsa Date: Sun, 24 May 2026 00:14:39 +0200 Subject: [PATCH 03/11] refactor(AbstractViewUI): Size up navigation --- .../edu/ntnu/idi/idatt/view/components/AbstractViewUI.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java b/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java index 8c1a119..1f45c17 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java @@ -59,9 +59,9 @@ public void createUIComponents() { navigation = new VBox(); navigation.setMaxHeight(Double.MAX_VALUE); navigation.getStyleClass().add("dark"); - navigation.setPrefWidth(150); // ScrollPane's affect this massively - navigation.setMaxWidth(150); - navigation.setMinWidth(150); + navigation.setPrefWidth(300); // ScrollPane's affect this massively + navigation.setMaxWidth(300); + navigation.setMinWidth(300); header = new HBox(); header.getStyleClass().add("light"); From 2d8e70c8ed1808c466422bcdf22bb0978d26368c Mon Sep 17 00:00:00 2001 From: pawelsa Date: Sun, 24 May 2026 00:15:00 +0200 Subject: [PATCH 04/11] feat(RecipeComponent): Add a component for transaction reciepts --- .../components/elements/RecieptComponent.java | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/main/java/edu/ntnu/idi/idatt/view/components/elements/RecieptComponent.java diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/elements/RecieptComponent.java b/src/main/java/edu/ntnu/idi/idatt/view/components/elements/RecieptComponent.java new file mode 100644 index 0000000..fc156d1 --- /dev/null +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/elements/RecieptComponent.java @@ -0,0 +1,104 @@ +package edu.ntnu.idi.idatt.view.components.elements; + +import java.util.List; + +import edu.ntnu.idi.idatt.model.transaction.Purchase; +import edu.ntnu.idi.idatt.model.transaction.Sale; +import edu.ntnu.idi.idatt.model.transaction.Transaction; +import edu.ntnu.idi.idatt.service.transaction.PurchaseCalculator; +import edu.ntnu.idi.idatt.service.transaction.SaleCalculator; +import edu.ntnu.idi.idatt.view.components.primitives.ActionEventHandler; +import edu.ntnu.idi.idatt.view.components.ui.UICompositor; +import edu.ntnu.idi.idatt.view.util.CssUtils; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +public class RecieptComponent extends VBox { + + private Button doneButton; + + public RecieptComponent(Transaction transaction) { + + Label title = new Label("Reciept"); + CssUtils.apply(title, CssUtils.BIG_TEXT_32); + + Label operation = new Label(); + String operationString = "Transaction type: %s, week: %d"; + + Label shareName = new Label(String.format("Share: %s", transaction.getShare().getStock().toString())); + Label shareAmount = new Label(String.format("Amount: %.3f", transaction.getShare().getQuantity())); + + Label gross = new Label(); + String grossString = "Gross: %.2f $"; + + Label tax = new Label(); + String taxString = "Taxes: %.2f $"; + + Label comission = new Label(); + String comissionString = "Comission: %.2f $"; + + Label total = new Label(); + String totalString = "Total: %.2f $"; + + Label profits = new Label(); + + List