Rabatt und Skonto hinzugefügt.
ZUGFERD-Profil wegen Skonto auf EXTENDED geändert.
This commit is contained in:
parent
721586e845
commit
81c38ab329
|
@ -0,0 +1,7 @@
|
|||
/.jsdtscope
|
||||
/org.eclipse.core.resources.prefs
|
||||
/org.eclipse.jdt.core.prefs
|
||||
/org.eclipse.wst.common.component
|
||||
/org.eclipse.wst.common.project.facet.core.xml
|
||||
/org.eclipse.wst.jsdt.ui.superType.container
|
||||
/org.eclipse.wst.jsdt.ui.superType.name
|
Binary file not shown.
|
@ -16,12 +16,17 @@ import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
|||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||
import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
||||
import org.apache.pdfbox.pdmodel.font.Standard14Fonts;
|
||||
import org.mustangproject.Allowance;
|
||||
import org.mustangproject.BankDetails;
|
||||
import org.mustangproject.CashDiscount;
|
||||
import org.mustangproject.Charge;
|
||||
import org.mustangproject.Contact;
|
||||
import org.mustangproject.Invoice;
|
||||
import org.mustangproject.Item;
|
||||
import org.mustangproject.Product;
|
||||
import org.mustangproject.TradeParty;
|
||||
import org.mustangproject.ZUGFeRD.PDFAConformanceLevel;
|
||||
import org.mustangproject.ZUGFeRD.Profile;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
||||
|
||||
|
@ -34,7 +39,13 @@ public class ZugferdUtil {
|
|||
|
||||
public static void main(String[] args) throws IOException, JSONException{
|
||||
|
||||
String originalPath="/Users/benediktwismans/tmp/rechnung_sdw.2025.06241.pdf";
|
||||
|
||||
// readZugferdDaten(new File("/Users/benediktwismans/tmp/rechnung_sdw.2025.06253.pdf"));
|
||||
//
|
||||
// System.exit(0);
|
||||
|
||||
|
||||
String originalPath="/Users/benediktwismans/tmp/rechnung.pdf";
|
||||
//String originalPath="/Users/benediktwismans/tmp/rechnung_sdw.2025.06234.pdf";
|
||||
|
||||
String copyPath="/Users/benediktwismans/tmp/zugferd.pdf";
|
||||
|
@ -44,8 +55,8 @@ public class ZugferdUtil {
|
|||
File pdf=new File(copyPath);
|
||||
|
||||
// JSON
|
||||
String content = Files.readString(Path.of("/Users/benediktwismans/tmp/sdw.json"), Charset.forName("UTF-8"));
|
||||
// String content = Files.readString(Path.of("/Users/benediktwismans/tmp/zugferd.json"), Charset.forName("UTF-8"));
|
||||
// String content = Files.readString(Path.of("/Users/benediktwismans/tmp/sdw.json"), Charset.forName("UTF-8"));
|
||||
String content = Files.readString(Path.of("/Users/benediktwismans/tmp/zugferd.json"), Charset.forName("UTF-8"));
|
||||
JSONObject json=new JSONObject(content);
|
||||
System.out.println(json.toString(3));
|
||||
|
||||
|
@ -64,8 +75,9 @@ public class ZugferdUtil {
|
|||
ze.setProducer("SDW Bischberg Dipl.Wirtsch.-Inf. Benedikt Wismans");
|
||||
ze.setCreator("Benedikt Wismans");
|
||||
|
||||
// ze.setZUGFeRDVersion(2);
|
||||
// ze.setConformanceLevel(PDFAConformanceLevel.UNICODE);
|
||||
ze.setZUGFeRDVersion(2);
|
||||
ze.setConformanceLevel(PDFAConformanceLevel.UNICODE);
|
||||
ze.setProfile("EXTENDED");
|
||||
|
||||
/*
|
||||
* Mustangproject checks if the input PDF/A file looks halfway valid and
|
||||
|
@ -120,14 +132,25 @@ public class ZugferdUtil {
|
|||
// System.out.println(i);
|
||||
// System.out.println(position.toString(2));
|
||||
|
||||
|
||||
Item item=new Item(
|
||||
new Product(produkt.getString("name"), produkt.getString("beschreibung", ""), produkt.getString("einheit"), new BigDecimal(produkt.getString("steuersatz"))),
|
||||
new BigDecimal(position.getString("preis")),
|
||||
new BigDecimal(position.getString("menge")));
|
||||
|
||||
if (position.getDouble("rabatt")>0) {
|
||||
item.addAllowance(new Allowance().setPercent(new BigDecimal(position.getString("rabatt"))).setTaxPercent(new BigDecimal(produkt.getString("steuersatz"))));
|
||||
|
||||
// Charge ist ein Zuschlag, wird nicht unterstützt
|
||||
// item.addCharge(new Charge().setPercent(new BigDecimal(position.getString("rabatt"))).setTaxPercent(new BigDecimal(produkt.getString("steuersatz"))));
|
||||
}
|
||||
invoice.addItem(item);
|
||||
}
|
||||
|
||||
if (json.getDouble("skonto")>0 && json.getInteger("skontotage")>0) {
|
||||
|
||||
invoice.addCashDiscount(new CashDiscount(new BigDecimal(json.getString("skonto")), json.getInteger("skontotage")));
|
||||
}
|
||||
|
||||
ze.setTransaction(invoice);
|
||||
}
|
||||
|
||||
|
@ -142,11 +165,37 @@ public class ZugferdUtil {
|
|||
}
|
||||
|
||||
|
||||
public static void readZugferdDaten(File pdf) throws IOException {
|
||||
|
||||
ZUGFeRDImporter zi=new ZUGFeRDImporter(pdf.getCanonicalPath());
|
||||
|
||||
System.out.println("getInvoiceID " + zi.getInvoiceID());
|
||||
System.out.println("getInvoiceCurrencyCode " + zi.getInvoiceCurrencyCode());
|
||||
System.out.println("getDueDate " + zi.getDueDate());
|
||||
System.out.println("getIBAN " + zi.getIBAN());
|
||||
System.out.println("getBIC " + zi.getBIC());
|
||||
System.out.println("getLineTotalAmount " + zi.getLineTotalAmount());
|
||||
System.out.println("getTaxTotalAmount " + zi.getTaxTotalAmount());
|
||||
System.out.println("getAmount " + zi.getAmount());
|
||||
String profil="getZUGFeRDProfil "+zi.getZUGFeRDProfil();
|
||||
String version="getVersion ?";
|
||||
try {
|
||||
version="getVersion "+String.valueOf(zi.getVersion());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println(profil);
|
||||
System.out.println(version);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static File appendZugferdDaten(File pdf) throws IOException {
|
||||
|
||||
ZUGFeRDImporter zi=new ZUGFeRDImporter(pdf.getCanonicalPath());
|
||||
|
||||
String[] zugferddata=new String[8];
|
||||
String[] zugferddata=new String[10];
|
||||
zugferddata[0]="getInvoiceID " + zi.getInvoiceID();
|
||||
zugferddata[1]="getInvoiceCurrencyCode " + zi.getInvoiceCurrencyCode();
|
||||
zugferddata[2]="getDueDate " + zi.getDueDate();
|
||||
|
@ -156,6 +205,14 @@ public class ZugferdUtil {
|
|||
zugferddata[6]="getTaxTotalAmount " + zi.getTaxTotalAmount();
|
||||
zugferddata[7]="getAmount " + zi.getAmount();
|
||||
|
||||
org.mustangproject.ZUGFeRD.PostalTradeAddress buyer=zi.getBuyerTradePartyAddress();
|
||||
zugferddata[8]="getBuyerTradeParty "+zi.getBuyerTradePartyName(); //+" "+buyer.getPostcodeCode()+" "+buyer.getCityName()+" "+buyer.getLineOne();
|
||||
|
||||
org.mustangproject.ZUGFeRD.PostalTradeAddress seller=zi.getSellerTradePartyAddress();
|
||||
zugferddata[9]="getSellerTradeParty "+zi.getHolder(); //+" "+seller.getPostcodeCode()+" "+seller.getCityName()+" "+seller.getLineOne();
|
||||
|
||||
|
||||
|
||||
String profil="getZUGFeRDProfil "+zi.getZUGFeRDProfil();
|
||||
String version="getVersion ?";
|
||||
try {
|
||||
|
@ -172,6 +229,9 @@ public class ZugferdUtil {
|
|||
System.out.println(zugferddata[5]);
|
||||
System.out.println(zugferddata[6]);
|
||||
System.out.println(zugferddata[7]);
|
||||
System.out.println(zugferddata[8]);
|
||||
System.out.println(zugferddata[9]);
|
||||
|
||||
System.out.println(profil);
|
||||
System.out.println(version);
|
||||
|
||||
|
@ -190,17 +250,19 @@ public class ZugferdUtil {
|
|||
write(contentStream, 30,690, "NACH dem Hinzufügen zu diesem PDF-Dokument wieder ausgelesen und");
|
||||
write(contentStream, 30,675, "sind im folgenden aufgeführt.");
|
||||
|
||||
write(contentStream, 100,600, zugferddata[0]);
|
||||
write(contentStream, 100,580, zugferddata[1]);
|
||||
write(contentStream, 100,560, zugferddata[2]);
|
||||
write(contentStream, 100,540, zugferddata[3]);
|
||||
write(contentStream, 100,520, zugferddata[4]);
|
||||
write(contentStream, 100,500, zugferddata[5]);
|
||||
write(contentStream, 100,480, zugferddata[6]);
|
||||
write(contentStream, 100,460, zugferddata[7]);
|
||||
write(contentStream, 30,600, zugferddata[0]);
|
||||
write(contentStream, 30,580, zugferddata[1]);
|
||||
write(contentStream, 30,560, zugferddata[2]);
|
||||
write(contentStream, 30,540, zugferddata[3]);
|
||||
write(contentStream, 30,520, zugferddata[4]);
|
||||
write(contentStream, 30,500, zugferddata[5]);
|
||||
write(contentStream, 30,480, zugferddata[6]);
|
||||
write(contentStream, 30,460, zugferddata[7]);
|
||||
write(contentStream, 30,440, zugferddata[8]);
|
||||
write(contentStream, 30,420, zugferddata[9]);
|
||||
|
||||
write(contentStream, 30,420, profil);
|
||||
write(contentStream, 30,400, version);
|
||||
write(contentStream, 30,380, profil);
|
||||
write(contentStream, 30,360, version);
|
||||
|
||||
contentStream.close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue