15 Commits

  1. 36
      README.md
  2. 2
      pom.xml
  3. BIN
      screenshots/jobs
  4. BIN
      screenshots/newjob
  5. BIN
      screenshots/positions
  6. BIN
      screenshots/settings
  7. 12
      src/main/java/com/jFxKasse/application/Main.java
  8. 23
      src/main/java/com/jFxKasse/application/PrintJob.java
  9. 2
      src/main/java/com/jFxKasse/application/TimeDate.java
  10. 227
      src/main/java/com/jFxKasse/controller/KeyController.java
  11. 157
      src/main/java/com/jFxKasse/controller/MainWindowController.java
  12. 1
      src/main/java/com/jFxKasse/controller/PrinterController.java
  13. 1
      src/main/java/com/jFxKasse/controller/XMLController.java
  14. 32
      src/main/java/com/jFxKasse/datatypes/Category.java
  15. 34
      src/main/java/com/jFxKasse/datatypes/Job.java
  16. 22
      src/main/java/com/jFxKasse/datatypes/PrintData.java
  17. 18
      src/main/java/com/jFxKasse/datatypes/PrintDataSimple.java
  18. 169
      src/main/java/com/jFxKasse/datatypes/PrintDataSplitted.java
  19. 1
      src/main/java/com/jFxKasse/datatypes/tableDataCurrentOrder.java
  20. 121
      src/main/resources/fxml/MainWindow.fxml

36
README.md

@ -1,2 +1,38 @@
# jFxKasse
easy payment system for small to middel sized events with a sales slip printer
Simples Kassensystem für kleine bis mittlere Veranstaltungen mit Bon-Drucker
## Video Tutorials (German | Deutsch)
[YouTube Video: jFxKasse - Kassensystem - Kurzanleitung](https://www.youtube.com/watch?v=DV9DDESw40I)
[YouTube Video: jFxKasse - Kassensystem - Installieren](https://www.youtube.com/watch?v=IY1bqRjwh0Q)
## Screenshots
### Main View | Hauptansicht
![](https://git.mosad.xyz/localhorst/jFxKasse/raw/branch/master/screenshots/newjob)
### Jobs | Auftäge
![](https://git.mosad.xyz/localhorst/jFxKasse/raw/branch/master/screenshots/jobs)
### Positions | Positionen
![](https://git.mosad.xyz/localhorst/jFxKasse/raw/branch/master/screenshots/positions)
### Settings | Einstellungen
![](https://git.mosad.xyz/localhorst/jFxKasse/raw/branch/master/screenshots/settings)
## Requirements | Anforderungen
### Software
* Java JRE 11
* Display/Bildschirm > 1366px X 768px
* Windoofs, Mac, GNU/Linux (openSuse tested)
### Hardware
I used this printer: [Epson TM T20II](https://www.epson.de/products/sd/pos-printer/epson-tm-t20ii)
Other sales slip printer are possible.

2
pom.xml

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>jFxKasse</artifactId>
<version>0.2.0</version>
<version>0.3.2</version>
<name>jFxKasse</name>
<dependencies>

BIN
screenshots/jobs

After

Width: 1374  |  Height: 765  |  Size: 123 KiB

BIN
screenshots/newjob

After

Width: 1374  |  Height: 765  |  Size: 128 KiB

BIN
screenshots/positions

After

Width: 1374  |  Height: 765  |  Size: 107 KiB

BIN
screenshots/settings

After

Width: 1374  |  Height: 765  |  Size: 83 KiB

12
src/main/java/com/jFxKasse/application/Main.java

@ -1,6 +1,8 @@
package com.jFxKasse.application;
import javafx.application.Application;
import javafx.event.EventHandler;
import java.io.File;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
@ -12,7 +14,10 @@ import com.jFxKasse.controller.MainWindowController;
import com.jFxKasse.controller.PrinterController;
import com.jFxKasse.controller.XMLController;
import com.jFxKasse.controller.DBController;
import com.jFxKasse.controller.KeyController;
import javafx.scene.Scene;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
public class Main extends Application
@ -31,6 +36,8 @@ public class Main extends Application
private DBController dbc = new DBController(filepath);
private PrinterController pc = new PrinterController();
private KeyController kc;
private Stage primaryStage;
@ -65,6 +72,9 @@ public class Main extends Application
primaryStage.setScene(scene);
primaryStage.show(); // shows the stage
//attach the KeyController
kc = new KeyController(scene, mwc);
Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(1), ev -> {
mwc.updateTimeLabel(); // update time label on UI
@ -96,7 +106,7 @@ public class Main extends Application
// config.xml found, app starting normal
System.out.println("XML found!");
mwc.initUI(); // Starting the UI elements
mwc.setDBLabel(); // Set databese labels
mwc.setDBLabel(); // Set database labels
dbc.setDbname(xmlc.getDatabaseName()); // handover database name
dbc.connectDatabase(); // estabishing DB conection
mwc.fillTablePositionen(); // fill TreeTable 'Positionen'

23
src/main/java/com/jFxKasse/application/PrintJob.java

@ -1,10 +1,13 @@
package com.jFxKasse.application;
import java.util.ArrayList;
import com.jFxKasse.controller.DBController;
import com.jFxKasse.controller.PrinterController;
import com.jFxKasse.controller.XMLController;
import com.jFxKasse.datatypes.PrintDataSimple;
import com.jFxKasse.datatypes.PrintDataSplitted;
import javafx.geometry.Insets;
import javafx.scene.control.ButtonType;
@ -51,10 +54,28 @@ public class PrintJob
} else {
// printer selected
pc.selectPrinter(xmlc.getPrintername());
/* Single bill or splitted */
if (xmlc.getCategorySplitted()) {
// split the bills
// TODO
PrintDataSplitted pdsplitted = new PrintDataSplitted(
xmlc.getLinebreak(), xmlc.getOffsetHeader(),
xmlc.getOffsetFooter(),
timedate.getSystemTime() + " " + timedate.getSystemDate(),
xmlc.getHeader(), xmlc.getFooter());
pdsplitted.setData(Integer.toString(jobID), dbc.getTime_Job(jobID),
dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
dbc.getJobValue_Job(jobID));
System.out.println("Printing job ...");
ArrayList<String> printString = pdsplitted.getPrintStrings();
for (int i = 0; i < printString.size(); i++) {
pc.printString(printString.get(i));
}
} else {
// one single bills

2
src/main/java/com/jFxKasse/application/TimeDate.java

@ -6,7 +6,6 @@ import java.util.Date;
public class TimeDate
{
public String getSystemTime()
{
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
@ -22,5 +21,4 @@ public class TimeDate
String dateStr = dateFormat.format(date);
return dateStr;
}
}

227
src/main/java/com/jFxKasse/controller/KeyController.java

@ -0,0 +1,227 @@
package com.jFxKasse.controller;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
public class KeyController
{
private MainWindowController mwc;
public KeyController(Scene scene, MainWindowController mwc)
{
this.mwc = mwc;
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent keyEvent)
{
switch (mwc.getActiveTab()) {
case 0:
handleTabNewJob(keyEvent);
break;
case 1:
handleTabJobs(keyEvent);
break;
case 2:
handleTabPosEdit(keyEvent);
break;
case 3:
handleTabSettings(keyEvent);
break;
default:
}
}
});
}
private void handleTabNewJob(KeyEvent key)
{
if ((key.getCode() == KeyCode.ENTER)
&& (!mwc.btnPrintBill.isDisabled())) {
mwc.btnPrintBillAction(null);
}
if ((key.getCode() == KeyCode.ESCAPE) && (!mwc.btnLock.isDisabled())) {
mwc.btnLockAction(null);
}
if ((key.getCode() == KeyCode.DELETE)
&& (!mwc.btnDeleteSelectedPosition.isDisabled())) {
mwc.btnDeleteSelectedPositionAction(null);
}
handelGridButtons(key);
}
private void handleTabJobs(KeyEvent key)
{
if ((key.getCode() == KeyCode.ENTER)
&& (!mwc.btnReprintJob.isDisabled())) {
mwc.btnReprintJobAction(null);
}
if ((key.getCode() == KeyCode.DELETE)
&& (!mwc.btnCancelJob.isDisabled())) {
mwc.btnCancelJobAction(null);
}
if ((key.getCode() == KeyCode.S) && (!mwc.btnCalcStats.isDisabled())) {
mwc.btnCalcStatsAction(null);
}
}
private void handleTabPosEdit(KeyEvent key)
{
if ((key.getCode() == KeyCode.ENTER)
&& (!mwc.btnSaveEntry.isDisabled())) {
mwc.btnSaveEntryAction(null);
}
if ((key.getCode() == KeyCode.DELETE)
&& (!mwc.btnClearEntry.isDisabled())) {
mwc.btnClearEntryAction(null);
}
}
private void handleTabSettings(KeyEvent key)
{
if ((key.getCode() == KeyCode.ENTER)
&& (!mwc.btnSavePrinter.isDisabled())) {
mwc.btnSavePrinterAction(null);
}
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnSaveCat.isDisabled())) {
mwc.btnSaveCatAction(null);
}
if ((key.getCode() == KeyCode.ENTER)
&& (!mwc.btnCreateNewDatabase.isDisabled())) {
try {
mwc.btnCreateNewDatabaseAction(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
void handelGridButtons(KeyEvent key)
{
switch (key.getCode()) {
case Q:
mwc.gridButton01Action(null);
break;
case W:
mwc.gridButton02Action(null);
break;
case E:
mwc.gridButton03Action(null);
break;
case R:
mwc.gridButton04Action(null);
break;
case T:
mwc.gridButton05Action(null);
break;
case Z:
mwc.gridButton06Action(null);
break;
case U:
mwc.gridButton07Action(null);
break;
case I:
mwc.gridButton08Action(null);
break;
case O:
mwc.gridButton09Action(null);
break;
case P:
mwc.gridButton10Action(null);
break;
case A:
mwc.gridButton11Action(null);
break;
case S:
mwc.gridButton12Action(null);
break;
case D:
mwc.gridButton13Action(null);
break;
case F:
mwc.gridButton14Action(null);
break;
case G:
mwc.gridButton15Action(null);
break;
case H:
mwc.gridButton16Action(null);
break;
case J:
mwc.gridButton17Action(null);
break;
case K:
mwc.gridButton18Action(null);
break;
case L:
mwc.gridButton19Action(null);
break;
case Y:
mwc.gridButton20Action(null);
break;
case X:
mwc.gridButton21Action(null);
break;
case C:
mwc.gridButton22Action(null);
break;
case V:
mwc.gridButton23Action(null);
break;
case B:
mwc.gridButton24Action(null);
break;
case N:
mwc.gridButton25Action(null);
break;
default:
break;
}
}
}

157
src/main/java/com/jFxKasse/controller/MainWindowController.java

@ -46,9 +46,18 @@ public class MainWindowController
@FXML
private AnchorPane paneDB;
@FXML
private Tab tapNewJob;
@FXML
private Tab tapJobs;
@FXML
private Tab tapPosEdit;
@FXML
private Tab tapSettings;
@FXML
private TreeTableView<tableDataCurrentOrder> tableCurrentOrder;
@ -199,34 +208,34 @@ public class MainWindowController
private Button gridButton25;
@FXML
private Button btnSavePrinter;
public Button btnSavePrinter;
@FXML
private Button btnDeleteSelectedPosition;
public Button btnDeleteSelectedPosition;
@FXML
private Button btnPrintBill;
public Button btnPrintBill;
@FXML
private Button btnLock;
public Button btnLock;
@FXML
private Button btnReprintJob;
public Button btnReprintJob;
@FXML
private Button btnCancelJob;
public Button btnCancelJob;
@FXML
private Button btnCalcStats;
public Button btnCalcStats;
@FXML
private Button btnSaveEntry;
public Button btnSaveEntry;
@FXML
private Button btnClearEntry;
public Button btnClearEntry;
@FXML
private Button btnCreateNewDatabase;
public Button btnCreateNewDatabase;
@FXML
private Button btnOpenFolder;
@ -268,7 +277,7 @@ public class MainWindowController
private JFXTextField tftKat05;
@FXML
private Button btnSaveCat;
public Button btnSaveCat;
@FXML
private Label labelAllPrize;
@ -378,7 +387,7 @@ public class MainWindowController
// creates a dialog
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Über jFxKasse");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.2");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.3.2");
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
@ -398,8 +407,8 @@ public class MainWindowController
+ " \n(c) 2018 Hendrik Schutter"),
0, 0);
dialog.getDialogPane().setContent(grid); // Setzt die GridPane auf die
dialog.setResizable(true); // DialogPane
dialog.getDialogPane().setContent(grid);
dialog.setResizable(true);
dialog.showAndWait();
}
@ -525,6 +534,8 @@ public class MainWindowController
{
dbc.setStatus_Jobs(selectedJobId + 1, "storniert");
fillTableJobs();
btnCancelJob.setDisable(true);
btnReprintJob.setDisable(true);
}
@FXML
@ -583,14 +594,17 @@ public class MainWindowController
@FXML
public void btnPrintBillAction(ActionEvent event)
{
btnPrintBill.setDisable(true);
tapPosEdit.setDisable(false);
btnDeleteSelectedPosition.setDisable(true);
isPrintBtnDisabled = true;
tapJobs.setDisable(false);
setJobPrizeLabel(0);
currentJob.setJobtime(
timedate.getSystemTime() + " " + timedate.getSystemDate());
rootCurrentJob.getChildren().remove(0,
rootCurrentJob.getChildren().size());
@ -621,151 +635,151 @@ public class MainWindowController
@FXML
public void gridButton01Action(ActionEvent event)
{
handelGridButtons(1);
handleGridButtons(1);
}
@FXML
public void gridButton02Action(ActionEvent event)
{
handelGridButtons(2);
handleGridButtons(2);
}
@FXML
public void gridButton03Action(ActionEvent event)
{
handelGridButtons(3);
handleGridButtons(3);
}
@FXML
public void gridButton04Action(ActionEvent event)
{
handelGridButtons(4);
handleGridButtons(4);
}
@FXML
public void gridButton05Action(ActionEvent event)
{
handelGridButtons(5);
handleGridButtons(5);
}
@FXML
public void gridButton06Action(ActionEvent event)
{
handelGridButtons(6);
handleGridButtons(6);
}
@FXML
public void gridButton07Action(ActionEvent event)
{
handelGridButtons(7);
handleGridButtons(7);
}
@FXML
public void gridButton08Action(ActionEvent event)
{
handelGridButtons(8);
handleGridButtons(8);
}
@FXML
public void gridButton09Action(ActionEvent event)
{
handelGridButtons(9);
handleGridButtons(9);
}
@FXML
public void gridButton10Action(ActionEvent event)
{
handelGridButtons(10);
handleGridButtons(10);
}
@FXML
public void gridButton11Action(ActionEvent event)
{
handelGridButtons(11);
handleGridButtons(11);
}
@FXML
public void gridButton12Action(ActionEvent event)
{
handelGridButtons(12);
handleGridButtons(12);
}
@FXML
public void gridButton13Action(ActionEvent event)
{
handelGridButtons(13);
handleGridButtons(13);
}
@FXML
public void gridButton14Action(ActionEvent event)
{
handelGridButtons(14);
handleGridButtons(14);
}
@FXML
public void gridButton15Action(ActionEvent event)
{
handelGridButtons(15);
handleGridButtons(15);
}
@FXML
public void gridButton16Action(ActionEvent event)
{
handelGridButtons(16);
handleGridButtons(16);
}
@FXML
public void gridButton17Action(ActionEvent event)
{
handelGridButtons(17);
handleGridButtons(17);
}
@FXML
public void gridButton18Action(ActionEvent event)
{
handelGridButtons(18);
handleGridButtons(18);
}
@FXML
public void gridButton19Action(ActionEvent event)
{
handelGridButtons(19);
handleGridButtons(19);
}
@FXML
public void gridButton20Action(ActionEvent event)
{
handelGridButtons(20);
handleGridButtons(20);
}
@FXML
public void gridButton21Action(ActionEvent event)
{
handelGridButtons(21);
handleGridButtons(21);
}
@FXML
public void gridButton22Action(ActionEvent event)
{
handelGridButtons(22);
handleGridButtons(22);
}
@FXML
public void gridButton23Action(ActionEvent event)
{
handelGridButtons(23);
handleGridButtons(23);
}
@FXML
public void gridButton24Action(ActionEvent event)
{
handelGridButtons(24);
handleGridButtons(24);
}
@FXML
public void gridButton25Action(ActionEvent event)
{
handelGridButtons(25);
handleGridButtons(25);
}
@FXML
@ -804,11 +818,21 @@ public class MainWindowController
tftKat05.setDisable(true);
titlePaneStats.setVisible(false);
btnPrintBill.setDisable(true);
btnReprintJob.setDisable(true);
btnCancelJob.setDisable(true);
btnDeleteSelectedPosition.setDisable(true);
tapJobs.setDisable(true);
btnOpenFolder.setFocusTraversable(false);
switchSeparate.setFocusTraversable(false);
ueberbtn.setFocusTraversable(false);
isPrintBtnDisabled = true;
btnPrintBill
.setStyle("-fx-background-color: #2ac8fc; -fx-text-fill: black;");
btnLock.setFocusTraversable(false);
initPositionen();
initCurrentOrderTreeTableView();
initJobTreeTableView();
}
public int getSelectedCat()
@ -831,8 +855,11 @@ public class MainWindowController
public void changed(ObservableValue<? extends Number> ov,
Number value, Number new_value)
{
selectedCatName = catChoise.getItems().get((int) new_value)
.toString();
try {
selectedCatName = catChoise.getItems().get((int) new_value)
.toString();
} catch (Exception e) {
}
}
});
@ -958,9 +985,8 @@ public class MainWindowController
int selected = entryTreeTable.getSelectionModel()
.getSelectedIndex(); // get selected item
idPositionen = columnPosnumber.getCellData(selected);
try {
idPositionen = columnPosnumber.getCellData(selected);
tftNewPosition
.setText(dbc.getName_Positionen(idPositionen));
tftNewValue.setText(dbc.getValue_Positionen(idPositionen));
@ -972,7 +998,7 @@ public class MainWindowController
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
// e.printStackTrace();
}
}
});
@ -1159,6 +1185,7 @@ public class MainWindowController
{
for (int i = 0; i < 25; i++) {
getButtonByID(i).setText(dbc.getName_Positionen(i + 1));
getButtonByID(i).setFocusTraversable(false);
if ((getColorID(dbc.getColor_Positionen(i + 1)) == 0)
|| (getColorID(dbc.getColor_Positionen(i + 1)) == 7)) {
getButtonByID(i).setStyle("-fx-background-color: "
@ -1235,8 +1262,14 @@ public class MainWindowController
}
}
private void handelGridButtons(int pID)
private void handleGridButtons(int pID)
{
if (!getButtonByID(pID - 1).isVisible()) {
// Button is not visible, no action
return;
}
currentJob.addPosition(dbc.getName_Positionen(pID),
Float.parseFloat(dbc.getValue_Positionen(pID)),
dbc.getCategoryNameFromPositionen(pID));
@ -1254,6 +1287,9 @@ public class MainWindowController
}
setJobPrizeLabel(currentJob.getJobValue());
btnPrintBill.setFocusTraversable(false);
}
private void initCurrentOrderTreeTableView()
@ -1373,12 +1409,15 @@ public class MainWindowController
rootJobs.getChildren().add(new TreeItem<tableDataJob>(tmp));
}
if (!dbc.getJobCount().equals("0")) {
tapJobs.setDisable(false);
}
}
public void createNewJob()
{
currentJob = new Job(dbc.getLatestJobNumber_Job() + 1,
timedate.getSystemTime() + " " + timedate.getSystemDate());
currentJob = new Job(dbc.getLatestJobNumber_Job() + 1);
labelJobCounter.setText("Auftragsnummer: "
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
}
@ -1440,4 +1479,26 @@ public class MainWindowController
btnLock.setDisable(true);
}
public int getActiveTab()
{
if (tapNewJob.isSelected()) {
return 0;
}
if (tapJobs.isSelected()) {
return 1;
}
if (tapPosEdit.isSelected()) {
return 2;
}
if (tapSettings.isSelected()) {
return 3;
}
return 404;
}
}

1
src/main/java/com/jFxKasse/controller/PrinterController.java

@ -83,7 +83,6 @@ public class PrinterController implements Printable
}
}
/**
*
* @param input data as String

1
src/main/java/com/jFxKasse/controller/XMLController.java

@ -9,7 +9,6 @@ import java.util.Properties;
public class XMLController
{
private String databaseName = null;
private String printername = null;

32
src/main/java/com/jFxKasse/datatypes/Category.java

@ -0,0 +1,32 @@
package com.jFxKasse.datatypes;
public class Category
{
private String categoryName;
private String positionsString = "\n";
public Category(String categoryName)
{
this.categoryName = categoryName;
}
public String getCategoryName()
{
return categoryName;
}
public void addPosition(int quantity, String name, String value,
PrintData pd)
{
for (int i = 0; i < quantity; i++) {
positionsString = positionsString
+ pd.setRight(pd.breakLines(name), value + " €") + "\n";
}
}
public String getPositionsString()
{
return positionsString;
}
}

34
src/main/java/com/jFxKasse/datatypes/Job.java

@ -1,10 +1,10 @@
package com.jFxKasse.datatypes;
import java.math.BigDecimal;
import java.util.ArrayList;
public class Job
{
private int jobnumber;
private float jobvalue;
@ -19,18 +19,19 @@ public class Job
private ArrayList<String> positionenCat;
public Job(int pJobnumber, String pTime)
public Job(int pJobnumber)
{
this.jobnumber = pJobnumber;
this.jobtime = pTime;
positionenQuantity = new ArrayList<Integer>();
positionenName = new ArrayList<String>();
positionenValue = new ArrayList<Float>();
positionenCat = new ArrayList<String>();
// System.out.println("Größe: " + positionenName.size());
}
public void setJobtime(String jobtime)
{
this.jobtime = jobtime;
}
public int getJobnumber()
@ -54,13 +55,10 @@ public class Job
public void addPosition(String pPositionenName, float pPositionenValue,
String pPositionenCat)
{
// System.out.println("addName");
for (int i = 0; i < positionenName.size(); i++) {
if (positionenName.get(i).equals(pPositionenName)) {
// Item is already in list, increase quantity
positionenQuantity.set(i, positionenQuantity.get(i) + 1);
// System.out.println("Item exists, increasing quantity");
return;
}
}
@ -75,24 +73,15 @@ public class Job
public void printJobOnConsole()
{
System.out.println("---------------------------------------------");
System.out.println("JobNummer: " + jobnumber);
System.out.println("---------------------------------------------");
// System.out.println("Größe: " + positionenName.size());
for (int i = 0; i < positionenName.size(); i++) {
System.out.println(
positionenQuantity.get(i) + " " + positionenName.get(i) + " "
+ positionenValue.get(i) + " " + positionenCat.get(i));
/*
* System.out.println("i is: " + i);
* System.out.println(positionenName.get(i));
* System.out.println(positionenQuantity.get(i));
*/
}
System.out.println("---------------------------------------------");
@ -101,33 +90,28 @@ public class Job
public ArrayList<tableDataCurrentOrder> getCurrentJobPositionen()
{
ArrayList<tableDataCurrentOrder> jobitems = new ArrayList<tableDataCurrentOrder>();
for (int i = 0; i < positionenName.size(); i++) {
tableDataCurrentOrder tmp = new tableDataCurrentOrder(
positionenName.get(i), positionenQuantity.get(i));
jobitems.add(tmp);
}
return jobitems;
}
private void calcJobValue()
{
jobvalue = 0;
for (int i = 0; i < positionenValue.size(); i++) {
jobvalue = jobvalue
+ (positionenQuantity.get(i) * positionenValue.get(i));
}
//Round to two decimals
jobvalue = BigDecimal.valueOf(jobvalue).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
}
public String createPosQuantityDBString()

22
src/main/java/com/jFxKasse/datatypes/PrintData.java

@ -13,13 +13,13 @@ public abstract class PrintData
protected String footer;
protected String positionenQuantity;
protected String positionsQuantity;
protected String positionenName;
protected String positionsName;
protected String positionenValue;
protected String positionsValue;
protected String positionenCategory;
protected String positionsCategory;
protected String jobID;
@ -60,17 +60,16 @@ public abstract class PrintData
* @param jobValue
*/
public void setData(String jobID, String timeAndDateOrder,
String positionenQuantity, String positionenName,
String positionenValue, String positionenCategory, String jobValue)
String positionsQuantity, String positionsName,
String positionsValue, String positionsCategory, String jobValue)
{
this.jobID = jobID;
this.timeAndDateOrder = timeAndDateOrder;
this.positionenQuantity = positionenQuantity;
this.positionenName = positionenName;
this.positionenValue = positionenValue;
this.positionenCategory = positionenCategory;
this.positionsQuantity = positionsQuantity;
this.positionsName = positionsName;
this.positionsValue = positionsValue;
this.positionsCategory = positionsCategory;
this.jobValue = jobValue;
}
/**
@ -104,7 +103,6 @@ public abstract class PrintData
// data string not long enough
next = false;
}
}
// add the last part
return tmp + "\n" + data.substring(count);

18
src/main/java/com/jFxKasse/datatypes/PrintDataSimple.java

@ -6,7 +6,7 @@ public class PrintDataSimple extends PrintData
private String printString;
/**
* Constructor with all data that is not in the DB
* Constructor with all data that is not in the DB
* @param lineBreak
* @param headerSpace
* @param footerSpace
@ -35,7 +35,7 @@ public class PrintDataSimple extends PrintData
protected void generatePrintString()
{
/* Header */
String header = "\n";
String header = " ";
for (int i = 1; i < headerSpace; i++) {
header = header + "\n";
}
@ -53,18 +53,18 @@ public class PrintDataSimple extends PrintData
String positionen = "\n";
int posCount = positionenQuantity.length()
- positionenQuantity.replace(";", "").length() + 1;
int posCount = positionsQuantity.length()
- positionsQuantity.replace(";", "").length() + 1;
String[] positionQuantity = positionenQuantity.split(";");
String[] positionQuantity = positionsQuantity.split(";");
String[] positionName = positionenName.split(";");
String[] positionName = positionsName.split(";");
String[] positionValue = positionenValue.split(";");
String[] positionValue = positionsValue.split(";");
for (int i = 0; i < posCount; i++) { //All different posNames
for (int i = 0; i < posCount; i++) { // All different posNames
int quantity = Integer.parseInt(positionQuantity[i]);
for (int j = 0; j < quantity; j++) { //quantities
for (int j = 0; j < quantity; j++) { // quantities
positionen = positionen + setRight(breakLines(positionName[i]),
positionValue[i] + " €") + "\n";
}

169
src/main/java/com/jFxKasse/datatypes/PrintDataSplitted.java

@ -0,0 +1,169 @@
package com.jFxKasse.datatypes;
import java.util.ArrayList;
public class PrintDataSplitted extends PrintData
{
private ArrayList<String> printString = new ArrayList<String>();
private ArrayList<Category> categories = new ArrayList<Category>();
private int categoryCount = 0;
/**
* Constructor with all data that is not in the DB
* @param lineBreak
* @param headerSpace
* @param footerSpace
* @param timeAndDatePrint
* @param header
* @param footer
*/
public PrintDataSplitted(int lineBreak, int headerSpace, int footerSpace,
String timeAndDatePrint, String header, String footer)
{
super(lineBreak, headerSpace, footerSpace, timeAndDatePrint, header,
footer);
}
/**
* Generates the String
* @return the final Array with the Print Strings
*/
public ArrayList<String> getPrintStrings()
{
generatePrintString();
return printString;
}
@Override
protected void generatePrintString()
{
String firstBill;
/* Header */
String header = "-";
for (int i = 1; i < headerSpace; i++) {
header = header + "\n";
}
// This is the final header
header = header + setCenter(this.header);
/* Info */
String info = setRight("Bestellung: ", timeAndDateOrder) + "\n"
+ setRight("Druck: ", timeAndDatePrint) + "\n"
+ setRight("Bestellnummer: ", jobID);
/* Splitted Bills */
/* Price */
String price = setRight("Gesamt: ", (jobValue + " €"));
/* Footer */
String footer = setCenter(this.footer);
for (int i = 1; i < footerSpace; i++) {
footer = footer + "\n";
}
footer = footer + "_";
/* Build first Print String */
firstBill = header + "\n" + getSeparator() + "\n" + info + "\n"
+ getSeparator() + "\n" + setCenter("Bon wurde aufgeteilt") + "\n"
+ getSeparator() + "\n" + price + "\n" + getSeparator() + "\n"
+ footer;
printString.add(firstBill);
/* first bill ends here */
/* Categories in extra bills */
String positions = null;
int posCount = positionsQuantity.length()
- positionsQuantity.replace(";", "").length() + 1;
String[] positionQuantity = positionsQuantity.split(";");
String[] positionName = positionsName.split(";");
String[] positionValue = positionsValue.split(";");
String[] positionCategory = positionsCategory.split(";");
for (int i = 0; i < posCount; i++) { // All different posNames
int quantity = Integer.parseInt(positionQuantity[i]);
insertToCategory(quantity, positionName[i], positionValue[i],
positionCategory[i]);
}
// loops through all categories
for (int i = 0; i < categories.size(); i++) {
String thisBill;
/* Header */
header = " ";
for (int o = 1; o < headerSpace; o++) {
header = header + "\n";
}
// This is the final header
header = header + setCenter(this.header);
/* Info */
info = setRight("Bestellung: ", timeAndDateOrder) + "\n"
+ setRight("Druck: ", timeAndDatePrint) + "\n"
+ setRight("Bestellnummer: ", jobID);
/* Positions */
positions = categories.get(i).getPositionsString();
/* Footer */
footer = "\n";
for (int o = 2; o < footerSpace; o++) {
footer = footer + "\n";
}
footer = footer + "_";
thisBill = header + "\n" + getSeparator() + "\n" + info + "\n"
+ getSeparator() + "\n"
+ setCenter(categories.get(i).getCategoryName()) + "\n"
+ getSeparator() + positions + "\n" + getSeparator() + "\n"
+ footer;
printString.add(thisBill);
}
}
private void insertToCategory(int quantity, String name, String value,
String category)
{
boolean createNewCategorie = true;
for (int i = 0; i < categoryCount; i++) {
if (category.equals(categories.get(i).getCategoryName())) {
categories.get(i).addPosition(quantity, name, value, this);
createNewCategorie = false;
}
}
if (createNewCategorie) {
// position has a new category
categories.add(new Category(category));
categories.get(categoryCount).addPosition(quantity, name, value, this);
categoryCount++;
}
}
}

1
src/main/java/com/jFxKasse/datatypes/tableDataCurrentOrder.java

@ -16,7 +16,6 @@ public class tableDataCurrentOrder
{
this.position.set(pPosition);
this.quantity.set(pQuantity);
}
public StringProperty positionProperty()

121
src/main/resources/fxml/MainWindow.fxml

@ -23,11 +23,14 @@
<children>
<TabPane layoutX="4.0" layoutY="5.0" nodeOrientation="RIGHT_TO_LEFT" prefHeight="924.0" prefWidth="1536.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="Einstellungen">
<Tab fx:id="tapSettings" text="Einstellungen">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="ueberbtn" layoutX="84.0" layoutY="79.0" mnemonicParsing="false" onAction="#ueberbtnAction" prefHeight="0.0" prefWidth="46.0" text="Über" />
<Button fx:id="ueberbtn" layoutX="273.0" layoutY="448.0" mnemonicParsing="false" onAction="#ueberbtnAction" prefHeight="35.0" prefWidth="324.0" text="Informationen über jFxKasse">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></Button>
<TitledPane alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="790.0" layoutY="10.0" prefHeight="270.0" prefWidth="566.0" text="Datenbank Einstellungen">
<content>
<AnchorPane fx:id="paneDB" minHeight="0.0" minWidth="0.0" prefHeight="238.0" prefWidth="564.0">
@ -37,7 +40,10 @@
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewDBName" alignment="CENTER" layoutX="25.0" layoutY="10.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftNewDBName" alignment="CENTER" layoutX="25.0" layoutY="10.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<Label fx:id="labelDBStatus" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="1.0" layoutY="75.0" prefHeight="34.0" prefWidth="551.0" text="Keine Datenbank gefunden!">
<font>
<Font name="Cantarell Regular" size="18.0" />
@ -89,11 +95,26 @@
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftKat01" alignment="CENTER" layoutX="50.0" layoutY="5.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftKat02" alignment="CENTER" layoutX="50.0" layoutY="45.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftKat03" alignment="CENTER" layoutX="50.0" layoutY="85.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftKat04" alignment="CENTER" layoutX="50.0" layoutY="125.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftKat05" alignment="CENTER" layoutX="50.0" layoutY="165.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftKat01" alignment="CENTER" layoutX="50.0" layoutY="5.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat02" alignment="CENTER" layoutX="50.0" layoutY="45.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat03" alignment="CENTER" layoutX="50.0" layoutY="85.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat04" alignment="CENTER" layoutX="50.0" layoutY="125.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat05" alignment="CENTER" layoutX="50.0" layoutY="165.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<Button fx:id="btnSaveCat" layoutX="200.0" layoutY="204.0" mnemonicParsing="false" onAction="#btnSaveCatAction" text="Kategorien speichern">
<font>
<Font name="Cantarell Regular" size="13.0" />
@ -110,9 +131,12 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="327.0" prefWidth="564.0">
<children>
<ChoiceBox fx:id="printerChoise" layoutX="298.0" layoutY="10.0" prefWidth="150.0" />
<ChoiceBox fx:id="printerChoise" layoutX="270.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="178.0" />
<Spinner fx:id="linesSpinner" layoutX="35.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
<JFXTextField fx:id="tftheader" alignment="CENTER" layoutX="65.0" layoutY="90.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
<JFXTextField fx:id="tftheader" alignment="CENTER" layoutX="65.0" layoutY="90.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXToggleButton fx:id="switchSeparate" layoutX="270.0" layoutY="170.0" text="Kategorien separat drucken">
<font>
<Font name="Cantarell Regular" size="18.0" />
@ -155,7 +179,10 @@
</Button>
<Spinner fx:id="offsetHeaderSpinner" layoutX="324.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
<Spinner fx:id="offsetFooterSpinner" layoutX="35.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
<JFXTextField fx:id="tftfooter" alignment="CENTER" layoutX="65.0" layoutY="130.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
<JFXTextField fx:id="tftfooter" alignment="CENTER" layoutX="65.0" layoutY="130.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
</children>
</AnchorPane>
</content>
@ -171,67 +198,67 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TreeTableView fx:id="entryTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="502.0" prefWidth="1346.0">
<TreeTableView fx:id="entryTreeTable" layoutX="11.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="502.0" prefWidth="1346.0">
<placeholder>
<Label text="" />
</placeholder>
<columns>
<TreeTableColumn fx:id="columnColor" editable="false" maxWidth="428.0" minWidth="119.333251953125" prefWidth="119.333251953125" resizable="false" sortable="false" text="Farbe" />
<TreeTableColumn fx:id="columnCat" editable="false" maxWidth="800.0" minWidth="94.0" prefWidth="300.0" resizable="false" sortable="false" text="Kategorie" />
<TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="693.3333129882812" minWidth="44.33331298828125" prefWidth="140.33331298828125" resizable="false" sortable="false" text="Preis" />
<TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="1581.6666870117188" minWidth="38.0" prefWidth="596.333251953125" resizable="false" sortable="false" text="Positionen" />
<TreeTableColumn fx:id="columnPosnumber" editable="false" maxWidth="1218.0" minWidth="59.0" prefWidth="165.0" resizable="false" sortable="false" text="Nummer" />
<TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="1581.6666870117188" minWidth="38.0" prefWidth="596.333251953125" resizable="false" sortable="false" text="Positionen" />
<TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="693.3333129882812" minWidth="44.33331298828125" prefWidth="140.33331298828125" resizable="false" sortable="false" text="Preis" />
<TreeTableColumn fx:id="columnCat" editable="false" maxWidth="800.0" minWidth="94.0" prefWidth="300.0" resizable="false" sortable="false" text="Kategorie" />
<TreeTableColumn fx:id="columnColor" editable="false" maxWidth="428.0" minWidth="119.333251953125" prefWidth="119.333251953125" resizable="false" sortable="false" text="Farbe" />
</columns>
<columnResizePolicy>
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TreeTableView>
<Button fx:id="btnSaveEntry" layoutX="494.0" layoutY="631.0" mnemonicParsing="false" onAction="#btnSaveEntryAction" text="Ausgewählten Eintrag speichern">
<Button fx:id="btnClearEntry" layoutX="232.0" layoutY="590.0" mnemonicParsing="false" onAction="#btnClearEntryAction" text="Ausgewählten Eintrag zurücksetzten">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
<Button fx:id="btnClearEntry" layoutX="462.0" layoutY="525.0" mnemonicParsing="false" onAction="#btnClearEntryAction" text="Ausgewählten Eintrag zurücksetzten">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
<TitledPane fx:id="titledPaneEntry" alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="792.0" layoutY="525.0" prefHeight="163.0" prefWidth="565.0" text="Eintrag editieren">
<TitledPane fx:id="titledPaneEntry" alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="724.0" layoutY="525.0" prefHeight="163.0" prefWidth="633.0" text="Eintrag editieren">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="135.0" prefWidth="640.0">
<children>
<Label fx:id="labelNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:">
<Label fx:id="labelNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="516.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewPosition" alignment="CENTER" layoutX="160.0" layoutY="10.0" prefHeight="25.0" prefWidth="279.0">
<JFXTextField fx:id="tftNewPosition" alignment="CENTER" layoutX="307.0" layoutY="8.0" prefHeight="27.0" prefWidth="203.0">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
</JFXTextField>
<Label fx:id="labelNewValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="442.0" layoutY="50.0" prefHeight="34.0" prefWidth="118.0" text="Preis in Euro:">
<Label fx:id="labelNewValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="504.0" layoutY="50.0" prefHeight="34.0" prefWidth="118.0" text="Preis in Euro:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewValue" alignment="CENTER" labelFloat="true" layoutX="380.0" layoutY="50.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="58.0">
<JFXTextField fx:id="tftNewValue" alignment="CENTER" labelFloat="true" layoutX="442.0" layoutY="42.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="27.0" prefWidth="66.0">
<font>
<Font name="Cantarell Regular" size="13.0" />
<Font name="Cantarell Regular" size="18.0" />
</font>
</JFXTextField>
<Label fx:id="labelNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:">
<Label fx:id="labelNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="517.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<ChoiceBox fx:id="colorChoise" layoutX="346.0" layoutY="90.0" prefHeight="25.0" prefWidth="96.0" />
<Label fx:id="labelSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="204.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:">
<ChoiceBox fx:id="colorChoise" layoutX="340.0" layoutY="90.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="169.0" />
<Label fx:id="labelSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="185.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<ChoiceBox fx:id="catChoise" layoutX="25.0" layoutY="90.0" prefHeight="25.0" prefWidth="180.0" />
<ChoiceBox fx:id="catChoise" layoutX="16.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="180.0" />
<Button fx:id="btnSaveEntry" layoutX="23.0" layoutY="86.0" mnemonicParsing="false" onAction="#btnSaveEntryAction" text="Ausgewählten Eintrag speichern">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
</children>
</AnchorPane>
</content>
@ -243,20 +270,20 @@
</AnchorPane>
</content>
</Tab>
<Tab text="Aufträge">
<Tab fx:id="tapJobs" text="Aufträge">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0">
<children>
<TreeTableView fx:id="jobsTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="541.0" prefWidth="1346.0">
<TreeTableView fx:id="jobsTreeTable" layoutX="11.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="541.0" prefWidth="1346.0">
<placeholder>
<Label text="" />
</placeholder>
<columns>
<TreeTableColumn fx:id="columnJobValue" editable="false" prefWidth="111.0" resizable="false" text="Betrag" />
<TreeTableColumn fx:id="columnState" editable="false" prefWidth="101.0" resizable="false" text="Zustand" />
<TreeTableColumn fx:id="columnPositions" editable="false" prefWidth="861.0" resizable="false" sortable="false" text="Positionen" />
<TreeTableColumn fx:id="columnTime" editable="false" prefWidth="159.0" resizable="false" text="Zeit" />
<TreeTableColumn fx:id="columnJobNumber" editable="false" maxWidth="3000.0" prefWidth="110.666748046875" resizable="false" text="Nummer" />
<TreeTableColumn fx:id="columnJobNumber" editable="false" maxWidth="3000.0" prefWidth="85.0