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;
|
package com.bib.essensbestellungsverwaltung;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
import javafx.scene.control.Spinner;
|
import javafx.scene.control.Spinner;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InvoiceController {
|
public class InvoiceController {
|
||||||
@FXML
|
@FXML
|
||||||
@ -14,6 +18,9 @@ public class InvoiceController {
|
|||||||
@FXML
|
@FXML
|
||||||
ChoiceBox monatChoiceBox;
|
ChoiceBox monatChoiceBox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
ChoiceBox childChoiceBox;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
Spinner jahrSpinner;
|
Spinner jahrSpinner;
|
||||||
|
|
||||||
@ -21,12 +28,32 @@ public class InvoiceController {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
monatChoiceBox.setValue(intToMonth(Calendar.getInstance().get(Calendar.MONTH) + 1));
|
monatChoiceBox.setValue(intToMonth(Calendar.getInstance().get(Calendar.MONTH) + 1));
|
||||||
jahrSpinner.getValueFactory().setValue(Calendar.getInstance().get(Calendar.YEAR));
|
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
|
@FXML
|
||||||
void onRechnungErstellenClick(MouseEvent mouseEvent) {
|
void onRechnungErstellenClick(MouseEvent mouseEvent) {
|
||||||
responseText.setText(monatChoiceBox.getValue().toString() + jahrSpinner.getValue());
|
if(childChoiceBox.getValue() == null){
|
||||||
// hier rechnung erstellen
|
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) {
|
private int monthToInt(String month) {
|
||||||
|
@ -17,14 +17,10 @@
|
|||||||
</font></Text>
|
</font></Text>
|
||||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="122.0" spacing="20.0">
|
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="122.0" spacing="20.0">
|
||||||
<children>
|
<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>
|
<children>
|
||||||
<Label text="Jahr" />
|
<Label text="Kind" />
|
||||||
<Spinner fx:id="jahrSpinner">
|
<ChoiceBox fx:id="childChoiceBox"></ChoiceBox>
|
||||||
<valueFactory>
|
|
||||||
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="2023" max="2100" min="2020" />
|
|
||||||
</valueFactory>
|
|
||||||
</Spinner>
|
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
|
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
|
||||||
@ -50,6 +46,16 @@
|
|||||||
</ChoiceBox>
|
</ChoiceBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</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>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Button mnemonicParsing="false" onMouseClicked="#onRechnungErstellenClick" text="Rechnung erstellen" />
|
<Button mnemonicParsing="false" onMouseClicked="#onRechnungErstellenClick" text="Rechnung erstellen" />
|
||||||
|
Loading…
Reference in New Issue
Block a user