add: select child for invoice and show total
This commit is contained in:
parent
cd8e4c9b3d
commit
745eddea31
@ -1,12 +1,16 @@
|
||||
package com.bib.essensbestellungsverwaltung;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class InvoiceController {
|
||||
@FXML
|
||||
@ -14,6 +18,9 @@ public class InvoiceController {
|
||||
@FXML
|
||||
ChoiceBox monatChoiceBox;
|
||||
|
||||
@FXML
|
||||
ChoiceBox childChoiceBox;
|
||||
|
||||
@FXML
|
||||
Spinner jahrSpinner;
|
||||
|
||||
@ -21,12 +28,32 @@ public class InvoiceController {
|
||||
public void initialize() {
|
||||
monatChoiceBox.setValue(intToMonth(Calendar.getInstance().get(Calendar.MONTH) + 1));
|
||||
jahrSpinner.getValueFactory().setValue(Calendar.getInstance().get(Calendar.YEAR));
|
||||
|
||||
List<Child> childList = AccountMgr.getAllChildren();
|
||||
ObservableList<Object> childOptions = FXCollections.observableArrayList(childList.stream().map(c -> c.getId() + ": " + c.getFirstname() + " " + c.getName()).toList().toArray(new String[0]));
|
||||
childChoiceBox.setItems(childOptions);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void onRechnungErstellenClick(MouseEvent mouseEvent) {
|
||||
responseText.setText(monatChoiceBox.getValue().toString() + jahrSpinner.getValue());
|
||||
// hier rechnung erstellen
|
||||
if(childChoiceBox.getValue() == null){
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Es wurde kein Kind ausgewählt");
|
||||
alert.setHeaderText("Bitte wählen sie ein Kind aus");
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
String childId = childChoiceBox.getValue().toString().split(":")[0];
|
||||
String date = String.format("%d-%02d", Integer.parseInt(jahrSpinner.getValue().toString()), monthToInt(monatChoiceBox.getValue().toString()));
|
||||
|
||||
System.out.println("Invoice (" + date + ") from child: " + childId);
|
||||
|
||||
List<String> invoice = AccountMgr.getInvoice(date, childId);
|
||||
|
||||
responseText.setText(invoice.get(invoice.size() - 1));
|
||||
|
||||
//TODO: show invoice
|
||||
//TODO: export invoice as word or pdf
|
||||
}
|
||||
|
||||
private int monthToInt(String month) {
|
||||
|
@ -17,14 +17,10 @@
|
||||
</font></Text>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="122.0" spacing="20.0">
|
||||
<children>
|
||||
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
|
||||
<VBox alignment="CENTER" layoutX="150.0" layoutY="10.0" prefHeight="200.0" prefWidth="100.0">
|
||||
<children>
|
||||
<Label text="Jahr" />
|
||||
<Spinner fx:id="jahrSpinner">
|
||||
<valueFactory>
|
||||
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="2023" max="2100" min="2020" />
|
||||
</valueFactory>
|
||||
</Spinner>
|
||||
<Label text="Kind" />
|
||||
<ChoiceBox fx:id="childChoiceBox"></ChoiceBox>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
|
||||
@ -50,6 +46,16 @@
|
||||
</ChoiceBox>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
|
||||
<children>
|
||||
<Label text="Jahr" />
|
||||
<Spinner fx:id="jahrSpinner">
|
||||
<valueFactory>
|
||||
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="2023" max="2100" min="2020" />
|
||||
</valueFactory>
|
||||
</Spinner>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<Button mnemonicParsing="false" onMouseClicked="#onRechnungErstellenClick" text="Rechnung erstellen" />
|
||||
|
Loading…
Reference in New Issue
Block a user