Browse Source

bill splitted

master
Hendrik Schutter 4 years ago
parent
commit
88b39820ca
  1. 24
      src/main/java/com/jFxKasse/application/PrintJob.java
  2. 2
      src/main/java/com/jFxKasse/controller/PrinterController.java
  3. 38
      src/main/java/com/jFxKasse/datatypes/Category.java
  4. 21
      src/main/java/com/jFxKasse/datatypes/PrintData.java
  5. 10
      src/main/java/com/jFxKasse/datatypes/PrintDataSimple.java
  6. 132
      src/main/java/com/jFxKasse/datatypes/PrintDataSplitted.java

24
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;
@ -53,9 +56,26 @@ public class PrintJob
pc.selectPrinter(xmlc.getPrintername());
if (xmlc.getCategorySplitted()) {
// split the bills
PrintDataSplitted pdsplitted = new PrintDataSplitted(xmlc.getLinebreak(),
xmlc.getOffsetHeader(), xmlc.getOffsetFooter(),
timedate.getSystemTime() + " " + timedate.getSystemDate(),
xmlc.getHeader(), xmlc.getFooter());
// TODO
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
PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(),

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

@ -83,13 +83,13 @@ public class PrinterController implements Printable
}
}
/**
*
* @param input data as String
*/
public void printString(String text)
{
PrintService service = selectedPrinter;
DocPrintJob job = service.createPrintJob();

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

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

21
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;
}
/**

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

@ -53,14 +53,14 @@ 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
int quantity = Integer.parseInt(positionQuantity[i]);

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

@ -1,12 +1,17 @@
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 String printString;
private int categoryCount = 0;
/**
* 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
@ -23,17 +28,20 @@ public class PrintDataSplitted extends PrintData
/**
* Generates the String
* @return the final Print String
* @return the final Array with the Print Strings
*/
public String getPrintString()
public ArrayList<String> getPrintStrings()
{
generatePrintString();
return this.printString;
return printString;
}
@Override
protected void generatePrintString()
{
String firstBill;
/* Header */
String header = "\n";
for (int i = 1; i < headerSpace; i++) {
@ -49,45 +57,113 @@ public class PrintDataSplitted extends PrintData
+ setRight("Druck: ", timeAndDatePrint) + "\n"
+ setRight("Bestellnummer: ", jobID);
/* Positionen */
/* Splitted Bills */
String positionen = "\n";
/* Price */
int posCount = positionenQuantity.length()
- positionenQuantity.replace(";", "").length() + 1;
String price = setRight("Gesamt: ", (jobValue + " €"));
String[] positionQuantity = positionenQuantity.split(";");
/* Footer */
String[] positionName = positionenName.split(";");
String footer = setCenter(this.footer);
String[] positionValue = positionenValue.split(";");
for (int i = 1; i < footerSpace; i++) {
footer = footer + "\n";
}
footer = footer + "_";
for (int i = 0; i < posCount; i++) { //All different posNames
/* 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]);
for (int j = 0; j < quantity; j++) { //quantities
positionen = positionen + setRight(breakLines(positionName[i]),
positionValue[i] + " €") + "\n";
}
insertToCategory(quantity, positionName[i], positionValue[i],
positionCategory[i]);
}
/* Price */
// loops through all categories
for (int i = 0; i < categories.size(); i++) {
String price = setRight("Gesamt: ", (jobValue + " €"));
String thisBill;
/* Footer */
/* Header */
header = "\n";
for (int o = 1; o < headerSpace; o++) {
header = header + "\n";
}
String footer = setCenter(this.footer);
// 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 = setCenter(this.footer);
for (int o = 1; 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();
printString.add(thisBill);
for (int i = 1; i < footerSpace; i++) {
footer = footer + "\n";
}
footer = footer + "_";
/* Build final Print String */
}
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++;
}
printString = header + "\n" + getSeparator() + "\n" + info + "\n"
+ getSeparator() + "\n" + positionen + "\n" + getSeparator() + "\n"
+ price + "\n" + getSeparator() + "\n" + footer;
}
}

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close